Skip to content

Assert the results in two core-strategy tests - #217

Open
ulfarsson wants to merge 2 commits into
developfrom
core-strategies-test-asserts
Open

ulfarsson wants to merge 2 commits into
developfrom
core-strategies-test-asserts

Conversation

@ulfarsson

@ulfarsson ulfarsson commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Two tests in tests/enumeration_strategies/test_core_strategies.py checked nothing. test_last_skew_component compared three results with == but never asserted them. The first two lines of TestRuCu.test_applies asserted a strategy object, which is always true, in place of its applies(). Both tests now assert what they compute, and no code changes:

>>> from permuta import Perm
>>> from permuta.enumeration_strategies.core_strategies import RuCuCoreStrategy
>>> strategy = RuCuCoreStrategy([Perm((1, 2, 0, 3))])
>>> bool(strategy), strategy.applies()
(True, False)

A strategy object is true even for a basis it does not apply to, so assert RuCuCoreStrategy(basis) passes whatever applies() returns.

Details

Why

A test that does not assert cannot fail. test_last_skew_component passed whatever last_skew_component returned. TestRuCu.test_applies passed whatever RuCuCoreStrategy answered for Av(2314, 3124) and Av(1234, 2314, 3124), both classes of Corollary 4.3. Now the tests check the skew components they name, and that the strategy applies to both classes.

Other tests already caught some faults in these functions, so the suite as a whole was not blind there. This change makes the two tests check what their names say, for anyone who relies on them, such as the maintainers when they change these functions.

What changes

  • TestRuCu.test_applies: its first two lines call .applies(), as its other lines do.
  • test_last_skew_component: its three comparisons are asserted. A fourth case gives it a permutation of one point, as Ru2143CoreStrategy does for the extra pattern 12, which no test did before.
  • test_init_strategy, in tests/enumeration_strategies/test_enumeration_strategies.py, asserts nothing either, but by design: it checks that every strategy can be built and asked on two bases without raising. It stays as it is.
  • No entry in CHANGELOG.md, as nothing outside the tests changes.

Checks

  • tox: flake8, mypy, pylint and black pass. On CPython 3.15 all 696 tests pass; on PyPy 3.12, 694 pass and 2 are skipped, which need CPython's reference counting and tracemalloc. These are develop's counts, as the change adds no test.
  • The expected values, checked apart from Permuta: each last skew component by hand, and both classes against Corollary 4.3's form, Av(2314, 3124) with extra patterns 1 ⊕ p for p skew-indecomposable, such as 1234 = 1 ⊕ 123.
  • Both tests catch what they let pass before. Run alone against mutants of last_skew_component, CoreStrategy._applies_to_symmetry, RuCuCoreStrategy, zero_plus_skewind and fstrip, the two tests now kill 34 of 45, where develop's versions killed 31: the three more are faults in last_skew_component, two that the old test computed and dropped, and one that refuses a permutation of one point, which the whole suite let pass. A scan in last_skew_component that starts one place late passes every test of develop's file and fails the new test_last_skew_component, which also fails when last_skew_component returns the last sum component, where develop's version passed.
  • Downstream: Tilings' 3,722 tests pass at its develop with this Permuta, on both Pythons.
  • Merges: none conflicts with Keep a copied PropertyBitmaps' labels apart from the original's #212, Document the memory cost of reading PropertyBitmaps.bitmaps #213, Require Ru2143CoreStrategy's extra basis patterns to start with 1 #214, Read a class's minimal basis in the core strategies #215 or Refuse a basis holding the pattern 1 in every core strategy #216, one at a time or all together. In the merged tree, the core strategies' tests and doctests pass.

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.

ulfarsson and others added 2 commits November 26, 2026 15:00
test_last_skew_component compared three results with == but never
asserted them, and the first two lines of TestRuCu.test_applies
asserted a strategy object, which is always true, in place of its
applies(). Neither could fail there. Both now assert what they
compute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No test gave last_skew_component a single point, though
Ru2143CoreStrategy does for the extra pattern 12, so a fault that
refused one point passed the whole suite. The test now checks that
the last skew component of 1 is 1.

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