Skip to content

Commit 7eb356d

Browse files
derek73claude
andcommitted
test: guard against #108 exponential blow-up on repeated prefixes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c19ce96 commit 7eb356d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_prefixes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ def test_title_before_and_after_prefixed_last_name(self) -> None:
5555
self.m(hn.last, "van Gogh", hn)
5656
self.m(hn.suffix, "dr", hn)
5757

58+
def test_many_repeated_prefixes_does_not_blow_up(self) -> None:
59+
# Issue #108: a name with a long run of repeated prefixes used to grow
60+
# the pieces list exponentially and exhaust memory. Guard against a
61+
# regression: this must parse quickly and not raise. If an exponential
62+
# code path is reintroduced, this test will hang (CI timeout catches it).
63+
name = "Jan " + "van der " * 30 + "Berg"
64+
hn = HumanName(name)
65+
self.assertFalse(hn.unparsable)
66+
self.m(hn.first, "Jan", hn)
67+
5868
def test_two_part_last_name_with_suffix_comma(self) -> None:
5969
hn = HumanName("pennie von bergen wessels, III")
6070
self.m(hn.first, "pennie", hn)

0 commit comments

Comments
 (0)