Skip to content

test(conditions): cover add_equivalence branches - #4790

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
moneytool:test/conditions-add-equivalence-coverage
Oct 21, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
moneytool:test/conditions-add-equivalence-coverage

Conversation

@moneytool

Copy link
Copy Markdown
Contributor

Issue #, if available: Follow-up to #4742 (#4737)

Description of changes:

#4742 was merged with Codecov reporting 91.17% patch coverage, with 3 lines in src/cfnlint/conditions/_utils.py not covered. This adds two tests to TestAddEquivalence that cover them. No source changes.

  • test_repeated_subterm_shares_one_variable: an expression whose Or(a, b) subterm appears in two branches (Or(And(Or(a,b),c), And(Or(a,b),d))). This hits the subterm cache in _tseitin; the earlier test case was simplified by sympy before reaching it. The test asserts the encoding uses a single auxiliary variable for the shared subterm, and checks equisatisfiability against the direct Equivalent encoding over all 32 assignments.
  • test_boolean_function_without_nnf_rewrite_is_a_literal: covers the guard for a BooleanFunction that to_nnf leaves unchanged. Every built-in function is rewritten (Implies, Equivalent, Xor, ITE, Nand, Nor, Xnor), so the test uses a minimal custom subclass and checks that it is encoded as an atom, again against the direct encoding. The guard is kept because without it such a subclass would recurse indefinitely.

With these tests, _utils.py has 100% statement and branch coverage (65/65 statements, 32/32 branches). pytest test/unit/module/conditions test/unit/module/context passes, and ruff and isort are clean.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kddejong
kddejong force-pushed the test/conditions-add-equivalence-coverage branch from 04cebf7 to bdc2997 Compare October 20, 2026 23:47
@codecov

codecov Bot commented Oct 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (16acc6f) to head (bdc2997).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4790      +/-   ##
==========================================
+ Coverage   94.70%   94.72%   +0.01%     
==========================================
  Files         439      439              
  Lines       15895    15895              
  Branches     3078     3078              
==========================================
+ Hits        15053    15056       +3     
+ Misses        459      458       -1     
+ Partials      383      381       -2     
Flag Coverage Δ
unittests 94.72% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 7380f3a into aws-cloudformation:main Oct 21, 2026
21 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