Skip to content

Fix latest sdl2-compat/sdl3 fails#3687

Merged
ankith26 merged 1 commit intomainfrom
ankith26-sdl2-compat-skips
Feb 7, 2026
Merged

Fix latest sdl2-compat/sdl3 fails#3687
ankith26 merged 1 commit intomainfrom
ankith26-sdl2-compat-skips

Conversation

@ankith26
Copy link
Member

ref: #3680

@ankith26 ankith26 requested a review from a team as a code owner January 28, 2026 12:48
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

Two test files were modified: test/draw_test.py relaxes 16-bit color equality assertions to a per-component delta of 2; test/surface_test.py makes the RLEACCEL assertion in test_fill_rle conditional on SDL version (< 2.32.50).

Changes

Cohort / File(s) Summary
16-bit color tolerance in draw tests
test/draw_test.py
Replaces exact equality for 16-bit depth pixel color with per-component comparisons allowing a delta of 2; 8/24/32-bit checks remain exact.
SDL-version-gated RLEACCEL assertion
test/surface_test.py
test_fill_rle now asserts the RLEACCEL flag only when SDL version is less than 2.32.50; for >= 2.32.50 the flag is not required.

Sequence Diagram(s)

(Skipped — changes are test-only adjustments and do not introduce multi-component control-flow requiring sequence visualization.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Surface, sdl3, bugfix

Suggested reviewers

  • Starbuck5
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix latest sdl2-compat/sdl3 fails' directly relates to the changeset, which modifies tests to handle latest SDL version compatibility issues.
Description check ✅ Passed The description provides a reference link to related PR #3680, which contextualizes the changes as fixes for SDL compatibility issues mentioned in the title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
test/draw_test.py (1)

7503-7544: Fix assertAlmostEqual misuse with pygame.Color.

assertAlmostEqual expects numeric values and a numeric delta; using pygame.Color with a tuple delta will likely raise TypeError and fail the test. Compare channels explicitly instead.

🐛 Proposed fix (per-channel tolerance)
-                elif depth == 16:
-                    # allow small delta difference to account for SDL3 changes.
-                    self.assertAlmostEqual(
-                        surf.get_at(pixel), pixel_colors_16[i], delta=delta_color
-                    )
+                elif depth == 16:
+                    # allow small delta difference to account for SDL3 changes.
+                    actual = surf.get_at(pixel)
+                    expected = pixel_colors_16[i]
+                    for chan, (a, e) in enumerate(zip(actual, expected)):
+                        self.assertLessEqual(
+                            abs(a - e),
+                            delta_color[chan],
+                            f"pixel={pixel}, channel={chan}",
+                        )

@ankith26 ankith26 force-pushed the ankith26-sdl2-compat-skips branch from 11d4bb1 to 4133601 Compare January 28, 2026 13:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@test/draw_test.py`:
- Around line 7540-7543: The zip() call in the pixel comparison loop (for x, y
in zip(surf.get_at(pixel), pixel_colors_16[i])) needs strict=True to satisfy
Ruff B905 and ensure component counts match; update that zip invocation to
zip(..., strict=True) in the test loop that compares surf.get_at(pixel) with
pixel_colors_16[i] so the test will raise if the iterables differ in length.

@Starbuck5 Starbuck5 added the sdl3 label Feb 7, 2026
Copy link
Member

@Starbuck5 Starbuck5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RLEACCEL is a menace

@ankith26 ankith26 added this to the 2.5.7 milestone Feb 7, 2026
@ankith26 ankith26 merged commit 75d893c into main Feb 7, 2026
25 of 28 checks passed
@ankith26 ankith26 deleted the ankith26-sdl2-compat-skips branch February 7, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants