@@ -1433,6 +1433,13 @@ def test_suffix_with_double_comma_format(self):
1433
1433
self .m (hn .last , "Doe" , hn )
1434
1434
self .m (hn .suffix , "jr., MD" , hn )
1435
1435
1436
+ @unittest .expectedFailure
1437
+ def test_phd_with_erroneous_space (self ):
1438
+ hn = HumanName ("John Smith, Ph. D." )
1439
+ self .m (hn .first , "John" , hn )
1440
+ self .m (hn .last , "Smith" , hn )
1441
+ self .m (hn .suffix , "Ph. D." , hn )
1442
+
1436
1443
#http://en.wikipedia.org/wiki/Ma_(surname)
1437
1444
def test_potential_suffix_that_is_also_last_name (self ):
1438
1445
hn = HumanName ("Jack Ma" )
@@ -1750,13 +1757,69 @@ def test_downcasing_mc(self):
1750
1757
1751
1758
1752
1759
class HumanNameOutputFormatTests (HumanNameTestBase ):
1760
+
1753
1761
def test_formating (self ):
1754
1762
hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1755
1763
hn .string_format = "{title} {first} {middle} {last} {suffix} ({nickname})"
1756
1764
self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III (Kenny)" )
1757
1765
hn .string_format = "{last}, {title} {first} {middle}, {suffix} ({nickname})"
1758
1766
self .assertEqual (u (hn ), "Doe, Rev John A. Kenneth, III (Kenny)" )
1759
1767
1768
+ def test_quote_nickname_formating (self ):
1769
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1770
+ hn .string_format = "{title} {first} {middle} {last} {suffix} '{nickname}'"
1771
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III 'Kenny'" )
1772
+ hn .string_format = "{last}, {title} {first} {middle}, {suffix} '{nickname}'"
1773
+ self .assertEqual (u (hn ), "Doe, Rev John A. Kenneth, III 'Kenny'" )
1774
+
1775
+ def test_formating_removing_keys_from_format_string (self ):
1776
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1777
+ hn .string_format = "{title} {first} {middle} {last} {suffix} '{nickname}'"
1778
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III 'Kenny'" )
1779
+ hn .string_format = "{last}, {title} {first} {middle}, {suffix}"
1780
+ self .assertEqual (u (hn ), "Doe, Rev John A. Kenneth, III" )
1781
+ hn .string_format = "{last}, {title} {first} {middle}"
1782
+ self .assertEqual (u (hn ), "Doe, Rev John A. Kenneth" )
1783
+ hn .string_format = "{last}, {first} {middle}"
1784
+ self .assertEqual (u (hn ), "Doe, John A. Kenneth" )
1785
+ hn .string_format = "{last}, {first}"
1786
+ self .assertEqual (u (hn ), "Doe, John" )
1787
+ hn .string_format = "{first} {last}"
1788
+ self .assertEqual (u (hn ), "John Doe" )
1789
+
1790
+ def test_formating_removing_pieces_from_name_buckets (self ):
1791
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1792
+ hn .string_format = "{title} {first} {middle} {last} {suffix} '{nickname}'"
1793
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III 'Kenny'" )
1794
+ hn .string_format = "{title} {first} {middle} {last} {suffix}"
1795
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III" )
1796
+ hn .middle = ''
1797
+ self .assertEqual (u (hn ), "Rev John Doe III" )
1798
+ hn .suffix = ''
1799
+ self .assertEqual (u (hn ), "Rev John Doe" )
1800
+ hn .title = ''
1801
+ self .assertEqual (u (hn ), "John Doe" )
1802
+
1803
+ def test_formating_of_nicknames_with_parenthesis (self ):
1804
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1805
+ hn .string_format = "{title} {first} {middle} {last} {suffix} ({nickname})"
1806
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III (Kenny)" )
1807
+ hn .nickname = ''
1808
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III" )
1809
+
1810
+ def test_formating_of_nicknames_with_single_quotes (self ):
1811
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1812
+ hn .string_format = "{title} {first} {middle} {last} {suffix} '{nickname}'"
1813
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III 'Kenny'" )
1814
+ hn .nickname = ''
1815
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III" )
1816
+
1817
+ def test_formating_of_nicknames_with_double_quotes (self ):
1818
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1819
+ hn .string_format = "{title} {first} {middle} {last} {suffix} \" {nickname}\" "
1820
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III \" Kenny\" " )
1821
+ hn .nickname = ''
1822
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III" )
1760
1823
1761
1824
TEST_NAMES = (
1762
1825
"John Doe" ,
0 commit comments