Skip to content

Comments

Add pragma no cover to truly untestable code#7310

Merged
PavelMakarchuk merged 2 commits intomainfrom
coverage-100-pragmas
Feb 23, 2026
Merged

Add pragma no cover to truly untestable code#7310
PavelMakarchuk merged 2 commits intomainfrom
coverage-100-pragmas

Conversation

@MaxGhenis
Copy link
Contributor

@MaxGhenis MaxGhenis commented Jan 31, 2026

Summary

Add # pragma: no cover only to code that would cause problems if tested in unit tests.

Changes (6 files)

Microsim-specific branches

  • county.py: is_over_dataset check - only executes during microsimulation
  • zip_code.py: has_axes check - only executes during microsimulation

Behavioral response code

Code that requires reform scenarios with simulation branching - cannot be unit tested without setting up baseline/reform comparison:

  • labor_supply_behavioral_response.py
  • relative_income_change.py
  • relative_wage_change.py
  • capital_gains_responses.py

Test plan

  • All existing tests pass
  • Only code that would fail/error if unit tested is marked

🤖 Generated with Claude Code

@MaxGhenis MaxGhenis force-pushed the coverage-100-pragmas branch from 6e37f06 to 31d097e Compare January 31, 2026 18:41
MaxGhenis and others added 2 commits February 23, 2026 07:45
Mark only code that would cause problems if tested in unit tests:

1. **Microsim-specific branches** (2 files):
   - county.py: is_over_dataset check
   - zip_code.py: has_axes check

2. **Behavioral response code** (4 files):
   Requires reform scenarios with simulation branching - cannot
   be tested without setting up baseline/reform comparison:
   - labor_supply_behavioral_response.py
   - relative_income_change.py
   - relative_wage_change.py
   - capital_gains_responses.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add guidelines to CONTRIBUTING.md and CLAUDE.md specifying that
# pragma: no cover should only be used for:
1. Microsim-specific branches (is_over_dataset, has_axes)
2. Behavioral response code requiring simulation branching

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.61%. Comparing base (2dd3b64) to head (98c6db3).
⚠️ Report is 48 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##              main    #7310       +/-   ##
============================================
- Coverage   100.00%   77.61%   -22.39%     
============================================
  Files            2        6        +4     
  Lines           24      134      +110     
  Branches         0        6        +6     
============================================
+ Hits            24      104       +80     
- Misses           0       27       +27     
- Partials         0        3        +3     
Flag Coverage Δ
unittests 77.61% <ø> (-22.39%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@PavelMakarchuk PavelMakarchuk merged commit b3a6d08 into main Feb 23, 2026
8 of 9 checks passed
@PavelMakarchuk PavelMakarchuk deleted the coverage-100-pragmas branch February 23, 2026 21:01
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