Skip to content

Add tests for uncovered config error/deletion paths#218

Merged
derek73 merged 1 commit into
masterfrom
test/config-coverage-gaps
Jul 5, 2026
Merged

Add tests for uncovered config error/deletion paths#218
derek73 merged 1 commit into
masterfrom
test/config-coverage-gaps

Conversation

@derek73

@derek73 derek73 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What

Adds three regression tests to tests/test_constants.py covering the last untested behavioral paths in nameparser/config/__init__.py, raising its line coverage from 95% → 97%.

Test Covers
test_tuplemanager_delattr_removes_dict_entry del tm.key — the non-dunder branch of TupleManager.__delattr__
test_assigning_non_setmanager_to_cached_union_member_raises _CachedUnionMember.__set__ TypeError guard when a bare list is assigned to titles/prefixes/etc. instead of a SetManager
test_setstate_raises_on_missing_descriptor_field Constants.__setstate__ ValueError guard when a pickle blob is missing a descriptor-backed collection

Why

These were the only remaining uncovered lines that represent real behavior rather than reprs. The two error-path tests assert on the exception message content (via pytest.raises(..., match=...)), not just the type — those messages exist specifically to make failures diagnosable, so a message regression would otherwise slip through.

The remaining uncovered lines in the module are two __repr__ methods, a __call__, and a version-conditional typing_extensions import — none worth a test.

Notes for reviewer

  • Test-only change; no production code touched.
  • Uses pytest.raises for the two error assertions (the base class has no assertRaises shim, and adding one for two call sites wasn't worth ~40 lines of exception-handling machinery).
  • Full suite green: 1310 passed, 22 xfailed; ruff clean.

🤖 Generated with Claude Code

Close the three behavioral coverage gaps in nameparser/config/__init__.py
(95% -> 97% line coverage). All were untested code paths, not reprs:

- TupleManager.__delattr__ non-dunder branch (del tm.key)
- _CachedUnionMember.__set__ TypeError guard when a bare iterable is
  assigned to a cached-union attribute instead of a SetManager
- Constants.__setstate__ ValueError guard when a pickle blob is missing
  a descriptor-backed collection

The two error-path tests assert on message content, not just exception
type, since those messages exist to make failures diagnosable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@derek73 derek73 self-assigned this Jul 5, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 5, 2026
@derek73 derek73 merged commit ac46732 into master Jul 5, 2026
8 checks passed
@derek73 derek73 deleted the test/config-coverage-gaps branch July 5, 2026 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant