Skip to content

Commit ec876c3

Browse files
committed
Cover opt-in-handler interactions and case for the surname fold (#121)
Pins down behavior the review flagged as untested: case-insensitive matching, a suffix alongside the fold, and running with patronymic_name_order/middle_name_as_last enabled (confirming no double-processing against handle_non_first_name_prefix).
1 parent ceb605c commit ec876c3

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

tests/test_prefixes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,33 @@ def test_bare_non_first_name_prefix_guard(self) -> None:
351351
hn = HumanName("de")
352352
self.m(hn.first, "de", hn)
353353
self.m(hn.last, "", hn)
354+
355+
# --- interactions with opt-in handlers that also run in post_process ---
356+
357+
def test_leading_non_first_name_prefix_case_insensitive(self) -> None:
358+
hn = HumanName("DE MESNIL")
359+
self.m(hn.first, "", hn)
360+
self.m(hn.last, "DE MESNIL", hn)
361+
362+
def test_leading_non_first_name_prefix_with_suffix(self) -> None:
363+
hn = HumanName("de Mesnil Jr.")
364+
self.m(hn.first, "", hn)
365+
self.m(hn.last, "de Mesnil", hn)
366+
self.m(hn.suffix, "Jr.", hn)
367+
368+
def test_leading_non_first_name_prefix_with_patronymic_name_order(self) -> None:
369+
# The fold requires a single-token first_list; patronymic_name_order
370+
# only matters once first_list has more than one piece, so the fold
371+
# and this opt-in handler don't fight over the same input shape here.
372+
constants = Constants(patronymic_name_order=True)
373+
hn = HumanName("de Mesnil", constants=constants)
374+
self.m(hn.first, "", hn)
375+
self.m(hn.last, "de Mesnil", hn)
376+
377+
def test_leading_non_first_name_prefix_with_middle_name_as_last(self) -> None:
378+
# handle_non_first_name_prefix runs first and empties middle_list, so
379+
# the later opt-in handle_middle_name_as_last has nothing left to do.
380+
constants = Constants(middle_name_as_last=True)
381+
hn = HumanName("de Mesnil Garcia", constants=constants)
382+
self.m(hn.first, "", hn)
383+
self.m(hn.last, "de Mesnil Garcia", hn)

0 commit comments

Comments
 (0)