Skip to content

Assert the comparisons in test_depth and test_sub_mesh_pattern - #218

Open
ulfarsson wants to merge 1 commit into
developfrom
tests-assert-dropped-comparisons
Open

ulfarsson wants to merge 1 commit into
developfrom
tests-assert-dropped-comparisons

Conversation

@ulfarsson

Copy link
Copy Markdown
Member

Two tests computed comparisons and dropped them, so those lines could never fail. All 153 lines of test_depth, in tests/patterns/test_perm.py, read like Perm((1, 0)).depth() == 1, with no assert. So did the last two lines of test_sub_mesh_pattern, in tests/patterns/test_meshpatt.py. Each of these 155 comparisons is now asserted, and no code changes:

>>> from permuta import Perm
>>> Perm((1, 0)).depth()
1

test_depth held the line Perm((1, 0)).depth() == 1, which computed True and dropped it. It now reads assert Perm((1, 0)).depth() == 1.

Details

Why

A comparison that is not asserted cannot fail. test_depth passed whatever Perm.depth returned, and the two lines of test_sub_mesh_pattern passed whatever MeshPatt.sub_mesh_pattern gave for their cases. All 155 comparisons hold on develop, so asserting them changes no result today. It makes the tests check what they compute, for anyone who changes these methods later.

A scan of every test file with Python's ast module finds no other comparison computed and dropped. The only others are the three in test_last_skew_component, which #217 asserts.

What changes

  • tests/patterns/test_perm.py: assert in front of each of test_depth's 153 comparisons. Their values are FindStat's St000029, as the test's comment says.
  • tests/patterns/test_meshpatt.py: assert in front of the last two comparisons of test_sub_mesh_pattern.
  • Each changed line gains assert at its start and nothing else. black leaves both files as they are.
  • No entry in CHANGELOG.md, as nothing outside the tests changes.

Checks


AI assistance: written with Claude Code (Opus 5.5) as the Permuta developer, and reviewed before submission by Claude Code (Opus 5.5) as an automated reviewer; Henning Ulfarsson checked and opened it.

test_depth computed each of its 153 comparisons and dropped it, and so
did the last two lines of test_sub_mesh_pattern, so none of them could
fail. Each is now asserted. All of them hold, so no result changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant