Skip to content

Increase coverage 2025 12 01#412

Merged
blueloveTH merged 6 commits intomainfrom
increase-coverage-2025-12-01
Dec 4, 2025
Merged

Increase coverage 2025 12 01#412
blueloveTH merged 6 commits intomainfrom
increase-coverage-2025-12-01

Conversation

@zhs628
Copy link
Collaborator

@zhs628 zhs628 commented Dec 4, 2025

Summary by CodeRabbit

  • Tests
    • Added a new test validating command-line argument handling and invocation behavior.
    • Updated a traceback test to reference the current test layout.
    • Removed legacy command-line argument validation from an older test.
    • Added a comprehensive suite for 2D array features: rendering (including color), chunked-array behavior, view mutations, boundary checks, deletion/length semantics, and memory/debug scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

Relocates sys argument assertions from tests/80_sys.py to a new tests/801_sys.py, updates an expected traceback file path in tests/802_traceback.py, and adds a comprehensive new test module tests/901_array2d_extra1.py exercising array2d, chunked_array2d, color32, and vec2i behaviors.

Changes

Cohort / File(s) Summary
Sys argument testing relocation
tests/801_sys.py
Added new test asserting exactly one CLI argument and that it equals 'tests/801_sys.py'.
Sys test cleanup
tests/80_sys.py
Removed top-level sys import and assertions that checked sys.argv contents.
Traceback reference update
tests/802_traceback.py
Updated expected traceback string to reference tests/802_traceback.py (was tests/80_traceback.py).
Array2D extended tests
tests/901_array2d_extra1.py
New, extensive test file covering array2d rendering, color handling, chunked_array2d behavior, views, mutations, GC/debug hooks, and boundary/length assertions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review tests/901_array2d_extra1.py for correct and safe use of array2d/chunked_array2d APIs, color construction/validation branches, and view mutation/boundary checks.
  • Confirm the new tests/801_sys.py invocation expectations match the test runner setup and that removing checks from tests/80_sys.py doesn't affect test ordering.
  • Verify the updated expected traceback in tests/802_traceback.py matches actual runtime output.

Poem

🐰 I hopped through tests with careful paws,
Moved sys lines and fixed their claws,
I colored grids where pixels play,
Chunks and views danced in array,
A tiny rabbit sings, "All green today!"

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title uses a vague, non-descriptive date-based format that does not convey meaningful information about what changes are in the PR. Replace with a descriptive title that summarizes the main change, e.g., 'Add test coverage for sys module, traceback, and array2d functionality'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch increase-coverage-2025-12-01

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 325218b and 5c5f96a.

📒 Files selected for processing (1)
  • tests/901_array2d_extra1.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/901_array2d_extra1.py (2)
include/typings/array2d.pyi (9)
  • array2d (122-131)
  • chunked_array2d (134-169)
  • fromlist (131-131)
  • render (37-37)
  • render_with_color (38-38)
  • view (166-166)
  • origin (119-119)
  • default (145-145)
  • view_chunks (169-169)
include/typings/vmath.pyi (2)
  • color32 (184-220)
  • vec2i (129-143)
🪛 Ruff (0.14.7)
tests/901_array2d_extra1.py

63-63: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)


72-72: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)


79-79: Avoid equality comparisons to False; use not array2d.fromlist(data).any(): for false checks

Replace with not array2d.fromlist(data).any()

(E712)


123-123: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: build_win
  • GitHub Check: build_darwin_libs
  • GitHub Check: build_win32
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_win32_amalgamated
  • GitHub Check: build_ios_libs
  • GitHub Check: build_linux
  • GitHub Check: build_linux_multiarch (aarch64)
  • GitHub Check: build_mac
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_linux_multiarch (aarch64)
  • GitHub Check: build_ios_libs
  • GitHub Check: build_linux
  • GitHub Check: build_win32
  • GitHub Check: build_darwin
🔇 Additional comments (1)
tests/901_array2d_extra1.py (1)

1-57: New coverage around array2d/chunked_array2d/GC paths looks solid.

The render, render_with_color, view/origin, deletion, len, GC, and view_chunks tests exercise important code paths and edge conditions without obvious correctness issues; nice targeted additions to the suite.

Also applies to: 81-144


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

Copy link

@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

🧹 Nitpick comments (3)
tests/100_array2d_extra1.py (3)

58-72: Consider removing unused exception variables.

The exception variables e are captured but never used. In test code, you can either omit the variable name or use it to validate the error message.

Apply this diff:

-except TypeError as e:
+except TypeError:
     pass

Or validate the exception:

 except TypeError as e:
-    pass
+    assert "color32" in str(e) or "None" in str(e)

As per static analysis hints.


76-77: Prefer not over == False for boolean checks.

Apply this diff:

-assert array2d.fromlist(data).any() == False
+assert not array2d.fromlist(data).any()

As per static analysis hints.


95-100: Consider adding assertion to verify deletion.

The test exercises __delitem__ but doesn't verify the item was actually deleted. Consider adding an assertion to validate the operation.

 del data[vec2i(0,0)]
+assert data[vec2i(0,0)] == data.default
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10c53e0 and 73a0f48.

📒 Files selected for processing (1)
  • tests/100_array2d_extra1.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/100_array2d_extra1.py (1)
include/typings/array2d.pyi (9)
  • array2d (122-131)
  • chunked_array2d (134-169)
  • fromlist (131-131)
  • render (37-37)
  • render_with_color (38-38)
  • view (166-166)
  • origin (119-119)
  • default (145-145)
  • view_chunks (169-169)
🪛 Ruff (0.14.7)
tests/100_array2d_extra1.py

63-63: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


71-71: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


77-77: Avoid equality comparisons to False; use not array2d.fromlist(data).any(): for false checks

Replace with not array2d.fromlist(data).any()

(E712)


121-121: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_linux
  • GitHub Check: build_darwin
  • GitHub Check: build_linux_multiarch (aarch64)
  • GitHub Check: build_win32
  • GitHub Check: build_win
🔇 Additional comments (6)
tests/100_array2d_extra1.py (6)

9-13: LGTM!

Clear baseline test for render() functionality.


16-56: Good coverage of color rendering combinations.

The tests exercise various combinations of foreground and background colors, including edge cases with None values. Note that these tests appear focused on ensuring no crashes occur rather than validating output, which is acceptable for rendering functions.


80-88: LGTM!

Good test of chunked array view-based item assignment and state validation.


91-92: LGTM!

Good validation of origin-aware coordinate transformation.


104-109: LGTM!

Correct test of __len__ on chunked arrays. With chunk_size=4, a 10×10 grid requires 3×3 = 9 chunks.


137-141: LGTM!

Excellent test coverage of view_chunks with negative indices and coordinate transformations. The assertions properly validate both read and write operations through chunk views.

Copy link

@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

♻️ Duplicate comments (1)
tests/901_array2d_extra1.py (1)

114-121: Replace assert False with an explicit AssertionError in the GC callback.

Using assert False risks being optimized away under python -O, which would hide this test failure, and this pattern has been called out before in a similar array2d GC test.

You can keep the behavior but make it robust and slightly clarify the parameter name:

-def gc_collect_callback(statue, msg):
-    if statue == 'stop':
+def gc_collect_callback(status, msg):
+    if status == 'stop':
         for line in msg.split('\n'):
             print(line)
             if "5290" in line and "str" in line:
                 return
         print(msg)
-        assert False
+        raise AssertionError("Expected GC output not found")

This preserves the existing printing behavior while ensuring the test always fails when the expected GC summary is missing.

🧹 Nitpick comments (2)
tests/901_array2d_extra1.py (2)

19-27: Clarify range comments vs actual values.

The comments say r/g/b are in [0,5,10,...,250,255], but range(51) gives i, j ∈ [0..50], so the max here is 250, not 255. Either bump the range or tweak the comments so they match.


76-78: Prefer not … over == False in tests.

Slightly clearer and matches Ruff’s suggestion:

-data = [[False, False], [False, False]]
-assert array2d.fromlist(data).any() == False
+data = [[False, False], [False, False]]
+assert not array2d.fromlist(data).any()
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73a0f48 and c9531a8.

📒 Files selected for processing (4)
  • tests/801_sys.py (1 hunks)
  • tests/802_traceback.py (1 hunks)
  • tests/80_sys.py (0 hunks)
  • tests/901_array2d_extra1.py (1 hunks)
💤 Files with no reviewable changes (1)
  • tests/80_sys.py
🧰 Additional context used
🪛 Ruff (0.14.7)
tests/901_array2d_extra1.py

63-63: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


71-71: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)


77-77: Avoid equality comparisons to False; use not array2d.fromlist(data).any(): for false checks

Replace with not array2d.fromlist(data).any()

(E712)


121-121: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: build_ios_libs
  • GitHub Check: build_darwin_libs
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_linux_multiarch (aarch64)
  • GitHub Check: build_darwin
  • GitHub Check: build_android_libs
  • GitHub Check: build_linux
  • GitHub Check: build_win32
  • GitHub Check: build_win
  • GitHub Check: build_win32
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_darwin
  • GitHub Check: build_linux
  • GitHub Check: build_linux_multiarch (aarch64)
🔇 Additional comments (2)
tests/802_traceback.py (1)

9-12: Traceback expectation path matches renamed test file.

Updating the expected File "tests/802_traceback.py", line 5 line keeps the test aligned with the file rename; no other behavioral changes here.

tests/801_sys.py (1)

1-4: Sys argv contract test looks consistent.

The assertions cleanly capture the expected sys.argv shape for this test entry point; nothing problematic stands out.

Copy link

@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

♻️ Duplicate comments (2)
tests/901_array2d_extra1.py (2)

58-75: TypeError tests still don't fail when exception is not raised.

As previously noted, these try/except blocks will silently pass if render_with_color does not raise TypeError. Additionally, assert False is removed under python -O.


113-135: assert False still present in GC callback.

As previously noted, line 123 uses assert False which is removed under python -O. This should be replaced with raise AssertionError().

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9531a8 and 325218b.

📒 Files selected for processing (1)
  • tests/901_array2d_extra1.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/901_array2d_extra1.py (2)
include/typings/array2d.pyi (9)
  • array2d (122-131)
  • chunked_array2d (134-169)
  • fromlist (131-131)
  • render (37-37)
  • render_with_color (38-38)
  • view (166-166)
  • origin (119-119)
  • default (145-145)
  • view_chunks (169-169)
include/typings/vmath.pyi (2)
  • color32 (184-220)
  • vec2i (129-143)
🪛 Ruff (0.14.7)
tests/901_array2d_extra1.py

63-63: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)


72-72: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)


79-79: Avoid equality comparisons to False; use not array2d.fromlist(data).any(): for false checks

Replace with not array2d.fromlist(data).any()

(E712)


123-123: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: build_mac
  • GitHub Check: build_win
  • GitHub Check: build_android_libs
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_linux_multiarch (aarch64)
  • GitHub Check: build_darwin_libs
  • GitHub Check: build_darwin
  • GitHub Check: build_linux
  • GitHub Check: build_win32
  • GitHub Check: build_win32
  • GitHub Check: build_linux_multiarch (aarch64)
  • GitHub Check: build_linux_multiarch (armv7)
  • GitHub Check: build_darwin
  • GitHub Check: build_linux
  • GitHub Check: build_win
🔇 Additional comments (8)
tests/901_array2d_extra1.py (8)

1-7: LGTM!

Imports and module documentation are clear.


8-13: LGTM!

The render test correctly verifies the string output of a 2D array.


15-56: LGTM!

The render_with_color tests properly exercise valid combinations of color foreground/background arrays including None defaults.


81-90: LGTM!

View mutation test correctly verifies that changes through a view are reflected in the underlying chunked array.


92-94: LGTM!

The origin offset test correctly verifies coordinate transformation between view and world coordinates.


96-103: LGTM!

Deletion test correctly verifies that deleted items revert to the default value.


105-111: LGTM!

The length test correctly expects 9 chunks for a 10×10 world grid with chunk size 4.


138-143: LGTM!

The view_chunks test correctly exercises coordinate transformations between world coordinates and chunk-based views.

Comment on lines +77 to +79
# ====array2d_like_any
data = [[False, False], [False, False]]
assert array2d.fromlist(data).any() == False
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Avoid direct equality comparison to False.

Line 79 uses == False which is not Pythonic. Use the not operator instead.

Apply this diff:

-assert array2d.fromlist(data).any() == False
+assert not array2d.fromlist(data).any()

As per static analysis hints.

🧰 Tools
🪛 Ruff (0.14.7)

79-79: Avoid equality comparisons to False; use not array2d.fromlist(data).any(): for false checks

Replace with not array2d.fromlist(data).any()

(E712)

🤖 Prompt for AI Agents
In tests/901_array2d_extra1.py around lines 77 to 79, the assertion uses a
direct equality to False (array2d.fromlist(data).any() == False); replace it
with a Pythonic negation by using the not operator (i.e., assert not
array2d.fromlist(data).any()) so the test asserts the boolean result without ==
False.

@blueloveTH blueloveTH merged commit fc991ab into main Dec 4, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants