Skip to content

Commit daa2394

Browse files
derek73claude
andcommitted
test: cover patronymic_name_order + middle_name_as_last interaction
Both flags on: post_process() runs the patronymic hook before the fold, so rotation should settle first/middle/last before the fold collapses middle into last. Also covers the subtler case where a comma suppresses rotation (_had_comma guard) but the fold still absorbs the unrotated middle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 275360c commit daa2394

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/test_middle_name_as_last.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,35 @@ def test_default_constants_unaffected(self) -> None:
7979
n = HumanName("Mohamad Ahmad Ali Hassan")
8080
self.m(n.middle, "Ahmad Ali", n)
8181
self.m(n.last, "Hassan", n)
82+
83+
84+
class MiddleNameAsLastWithPatronymicOrderTests(HumanNameTestBase):
85+
"""Both localization flags on: patronymic reordering must settle
86+
first/middle/last before the fold collapses middle into last, per the
87+
design's stated ordering rationale (post_process() runs the patronymic
88+
hook before the middle_name_as_last hook)."""
89+
90+
def setup_method(self) -> None:
91+
self.C = Constants(middle_name_as_last=True, patronymic_name_order=True)
92+
93+
def hn(self, name: str) -> HumanName:
94+
return HumanName(name, constants=self.C)
95+
96+
def test_rotate_then_fold_no_comma(self) -> None:
97+
# patronymic_name_order rotates "Ivanov Petr Sergeyevich" to
98+
# first=Petr, middle=Sergeyevich, last=Ivanov; the fold then
99+
# collapses that settled middle into last.
100+
n = self.hn("Ivanov Petr Sergeyevich")
101+
self.m(n.first, "Petr", n)
102+
self.m(n.middle, "", n)
103+
self.m(n.last, "Sergeyevich Ivanov", n)
104+
105+
def test_fold_applies_even_when_comma_suppresses_rotation(self) -> None:
106+
# A comma suppresses patronymic_name_order's rotation (_had_comma
107+
# guard), so middle stays "Sergeyevich" unrotated going into the
108+
# fold. The fold still absorbs it into last, producing the same
109+
# first/last as the no-comma case above via a different mechanism.
110+
n = self.hn("Ivanov, Petr Sergeyevich")
111+
self.m(n.first, "Petr", n)
112+
self.m(n.middle, "", n)
113+
self.m(n.last, "Sergeyevich Ivanov", n)

0 commit comments

Comments
 (0)