Skip to content

Commit 0015a93

Browse files
committed
test: cover leading period-abbreviation edge cases and exclusions (#109)
1 parent 1203f59 commit 0015a93

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

tests/test_titles.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,46 @@ def test_leading_period_abbreviation_lastname_comma(self) -> None:
291291
self.m(hn.title, "Major.", hn)
292292
self.m(hn.first, "John", hn)
293293
self.m(hn.last, "Smith", hn)
294+
295+
def test_leading_period_abbreviation_unknown_word(self) -> None:
296+
hn = HumanName("Foo. John Smith")
297+
self.m(hn.title, "Foo.", hn)
298+
self.m(hn.first, "John", hn)
299+
self.m(hn.last, "Smith", hn)
300+
301+
def test_leading_period_abbreviation_chained(self) -> None:
302+
hn = HumanName("Foo. Xyz. John Smith")
303+
self.m(hn.title, "Foo. Xyz.", hn)
304+
self.m(hn.first, "John", hn)
305+
self.m(hn.last, "Smith", hn)
306+
307+
def test_leading_single_letter_initial_excluded(self) -> None:
308+
hn = HumanName("J. Smith")
309+
self.m(hn.first, "J.", hn)
310+
self.m(hn.last, "Smith", hn)
311+
self.m(hn.title, "", hn)
312+
313+
def test_leading_internal_period_abbreviation_excluded(self) -> None:
314+
hn = HumanName("E.T. Smith")
315+
self.m(hn.first, "E.T.", hn)
316+
self.m(hn.last, "Smith", hn)
317+
self.m(hn.title, "", hn)
318+
319+
def test_period_abbreviation_after_first_name_stays_middle(self) -> None:
320+
hn = HumanName("John Major. Smith")
321+
self.m(hn.first, "John", hn)
322+
self.m(hn.middle, "Major.", hn)
323+
self.m(hn.last, "Smith", hn)
324+
self.m(hn.title, "", hn)
325+
326+
def test_known_title_with_period_still_a_title(self) -> None:
327+
hn = HumanName("Dr. John Smith")
328+
self.m(hn.title, "Dr.", hn)
329+
self.m(hn.first, "John", hn)
330+
self.m(hn.last, "Smith", hn)
331+
332+
def test_middle_initial_with_period_unaffected(self) -> None:
333+
hn = HumanName("John Q. Smith")
334+
self.m(hn.first, "John", hn)
335+
self.m(hn.middle, "Q.", hn)
336+
self.m(hn.last, "Smith", hn)

0 commit comments

Comments
 (0)