Skip to content

Test enum and string values in household calculations without axes - #4148

Merged
anth-volk merged 1 commit into
masterfrom
test/country-calculate-enum-and-string-values
Oct 30, 2026
Merged

anth-volk merged 1 commit into
masterfrom
test/country-calculate-enum-and-string-values

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

Fixes #4147

Summary

  • PolicyEngineCountry.calculate formats each value of a household calculation without axes by the variable's value_type. Since Make the SPM country tests unit tests, with two integration tests against the installed US model #4136 moved the SPM country tests onto stand-in simulations, every unit test that calls it uses float or int variables, so no test reached the Enum branch (result.decode()[entity_index].name) or the str branch (str(result[entity_index])). codecov/project fell 0.03 points on Make the SPM country tests unit tests, with two integration tests against the installed US model #4136.
  • TestHouseholdCalculation gains test__calculate_returns_enum_names_and_plain_strings_without_axes, parametrized over an enum variable and a string variable. A stand-in simulation returns an EnumArray of the module's ExampleEnum or a NumPy string array, as the neighbouring tests stand in for _create_simulation. The test checks that the household cell holds the enum member's name ("SECOND") or the string, as a plain str.
  • The axes path was already covered by the _serialize_axis_result tests.
  • No production code changes.

Testing

  • The two new cases, each run by node ID: both pass. A coverage run of just those two shows calculate's Enum and str branches executed.
  • ruff format --check and ruff check on the changed test module, mypy (its configured files), and .github/scripts/check_changelog_fragment.sh against master: all pass.

🤖 Generated with Claude Code

Since the SPM country tests moved to stand-in simulations, no unit test
reached the Enum and str branches of PolicyEngineCountry.calculate for a
household without axes. A stand-in simulation now calculates one variable
of each kind, and the test checks that the result holds the enum member's
name and a plain str.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.11%. Comparing base (22c4f36) to head (424cf47).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4148       +/-   ##
===========================================
+ Coverage   50.63%   88.11%   +37.47%     
===========================================
  Files         258      285       +27     
  Lines       14955    16577     +1622     
  Branches     2399     2712      +313     
===========================================
+ Hits         7573    14607     +7034     
+ Misses       6751     1292     -5459     
- Partials      631      678       +47     

☔ 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.

@anth-volk
anth-volk marked this pull request as ready for review October 30, 2026 17:31
@anth-volk
anth-volk merged commit 71edf9f into master Oct 30, 2026
15 checks passed
@anth-volk
anth-volk deleted the test/country-calculate-enum-and-string-values branch October 30, 2026 17:37

This branch was previously deployed

1 inactive deployment
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.

Test enum and string values in household calculations without axes

1 participant