Add tests for uncovered config error/deletion paths#218
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds three regression tests to
tests/test_constants.pycovering the last untested behavioral paths innameparser/config/__init__.py, raising its line coverage from 95% → 97%.test_tuplemanager_delattr_removes_dict_entrydel tm.key— the non-dunder branch ofTupleManager.__delattr__test_assigning_non_setmanager_to_cached_union_member_raises_CachedUnionMember.__set__TypeErrorguard when a bare list is assigned totitles/prefixes/etc. instead of aSetManagertest_setstate_raises_on_missing_descriptor_fieldConstants.__setstate__ValueErrorguard when a pickle blob is missing a descriptor-backed collectionWhy
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-conditionaltyping_extensionsimport — none worth a test.Notes for reviewer
pytest.raisesfor the two error assertions (the base class has noassertRaisesshim, and adding one for two call sites wasn't worth ~40 lines of exception-handling machinery).🤖 Generated with Claude Code