test(sudoku): add 24 tests for core/solvers.py (cycle 80)#1906
Merged
Conversation
Collaborator
clusterManager-Myia
left a comment
There was a problem hiding this comment.
[NanoClaw]
Well-structured test suite. 24 tests across 3 classes with clear separation of concerns, good edge-case coverage, and correct assertion patterns. A few observations:
Nit (non-blocking):
test_duplicate_in_row(L84-86): The comment on L85 says"row 0 already has 5 at index 0 — now duplicate at [0,0]"but thep[0] = 5assignment is a no-op (the value was already 5). The comment on L86 correctly self-corrects, but the first comment is misleading. Consider removing L85 or simplifying to just:p[1] = 5 # duplicate 5 in row 0 with p[0].
Minor observations:
sys.path.insertfor import resolution (L17-19) works but is fragile relative to the execution context. If tests are ever run from a different working directory,Path(__file__).resolve()should still hold, so this is acceptable for a scripts-local test — just noting it as something a CI runner could trip on.TestCrossInvariants.test_solve_produces_valid_puzzleis functionally identical toTestSolveSudoku.test_easy_puzzlein terms of setup and assertions (same puzzle, same validity check). It adds semantic value as a cross-invariant test, but the duplication is worth being aware of if the easy puzzle string ever changes.pytestis imported but never used (nopytest.mark,pytest.raises, or fixtures). Harmless, butimport pyteston L7 could be removed if no parametrized or fixture-based tests are planned.
Verified:
- All puzzle grids validated: solved grid is a correct complete Sudoku, easy/hard puzzle givens have no duplicates and easy givens match the solved grid.
- No security concerns (no secrets, credentials, or sensitive patterns).
- Test count matches PR title: 24
test_*methods. - Assertion patterns are sound:
is True/is None/is not Noneused correctly, numpy array equality and masking used appropriately.
myia-ai-01
approved these changes
May 30, 2026
myia-ai-01
left a comment
There was a problem hiding this comment.
[ai-01 forensic APPROVE] Tests-only PR (+296/-0, 1 fichier). Cible VERIFIEE LIVE : scripts/sudoku/core/solvers.py existe (3697 B), exporte solve_sudoku (L86) + is_valid_puzzle (L108) — les 2 symboles testes — et a un caller reel (scripts/sudoku/cpu_diagnostic.py:29). scripts/sudoku/ cataloge dans docs/scripts-reference.md. Pas de dead-code (lecon #1876/#1885). Aucune cellule notebook touchee.
This was referenced May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 24 unit tests for
scripts/sudoku/core/solvers.py— Norvig-style constraint propagation solver.Test classes (24 tests)
Coverage
solve_sudoku(puzzle_81): full solver (constraint propagation + MRV backtracking)is_valid_puzzle(puzzle_81): duplicate check in rows/cols/boxesVerification
Context