Skip to content

Commit 5fc4b6b

Browse files
derek73claude
andcommitted
test: expand suffixes_prefixes_titles coverage and add assertNotIn helper
Add missing test cases flagged during PR review: - prime-then-mutate test that would catch a regression to cached staleness - add tests for suffix_acronyms and suffix_not_acronyms (previously untested) - remove test for prefixes (mirroring the existing titles remove test) - assertFalse(x in ...) -> assertNotIn for the two remove tests Also adds assertNotIn to HumanNameTestBase to support the new assertions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f69ecee commit 5fc4b6b

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

tests/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@ def assertFalse(self, expr: object, msg: object = None) -> None:
3838

3939
def assertIn(self, member: object, container: object, msg: object = None) -> None:
4040
assert member in container, msg # type: ignore[operator]
41+
42+
def assertNotIn(self, member: object, container: object, msg: object = None) -> None:
43+
assert member not in container, msg # type: ignore[operator]

tests/test_constants.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,34 @@ def test_suffixes_prefixes_titles_reflects_remove_title(self) -> None:
123123
c.titles.add('emerita')
124124
self.assertIn('emerita', c.suffixes_prefixes_titles)
125125
c.titles.remove('emerita')
126-
self.assertFalse('emerita' in c.suffixes_prefixes_titles)
126+
self.assertNotIn('emerita', c.suffixes_prefixes_titles)
127+
128+
def test_suffixes_prefixes_titles_reflects_remove_prefix(self) -> None:
129+
"""suffixes_prefixes_titles must not include a word that was only in prefixes and is then removed."""
130+
c = Constants()
131+
c.prefixes.add('xpfx')
132+
self.assertIn('xpfx', c.suffixes_prefixes_titles)
133+
c.prefixes.remove('xpfx')
134+
self.assertNotIn('xpfx', c.suffixes_prefixes_titles)
135+
136+
def test_suffixes_prefixes_titles_reflects_add_suffix_acronym(self) -> None:
137+
"""suffixes_prefixes_titles must include suffix acronyms added after construction."""
138+
c = Constants()
139+
c.suffix_acronyms.add('xsfx')
140+
self.assertIn('xsfx', c.suffixes_prefixes_titles)
141+
142+
def test_suffixes_prefixes_titles_reflects_add_suffix_not_acronym(self) -> None:
143+
"""suffixes_prefixes_titles must include non-acronym suffixes added after construction."""
144+
c = Constants()
145+
c.suffix_not_acronyms.add('xsfx')
146+
self.assertIn('xsfx', c.suffixes_prefixes_titles)
147+
148+
def test_suffixes_prefixes_titles_reflects_add_after_initial_read(self) -> None:
149+
"""suffixes_prefixes_titles must reflect mutations even after the cache has been primed."""
150+
c = Constants()
151+
_ = c.suffixes_prefixes_titles # prime the cache
152+
c.titles.add('emerita')
153+
self.assertIn('emerita', c.suffixes_prefixes_titles)
127154

128155
def test_is_rootname_consistent_with_is_title(self) -> None:
129156
"""is_rootname must return False for words recognised by is_title."""

0 commit comments

Comments
 (0)