@@ -1758,12 +1758,18 @@ def test_downcasing_mc(self):
1758
1758
1759
1759
class HumanNameOutputFormatTests (HumanNameTestBase ):
1760
1760
1761
- def test_formating (self ):
1761
+ def test_formatting_init_argument (self ):
1762
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" ,
1763
+ string_format = "TEST1" )
1764
+ self .assertEqual (u (hn ), "TEST1" )
1765
+
1766
+ def test_formatting_constants_attribute (self ):
1767
+ from nameparser .config import CONSTANTS
1768
+ _orig = CONSTANTS .string_format
1769
+ CONSTANTS .string_format = "TEST2"
1762
1770
hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1763
- hn .string_format = "{title} {first} {middle} {last} {suffix} ({nickname})"
1764
- self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III (Kenny)" )
1765
- hn .string_format = "{last}, {title} {first} {middle}, {suffix} ({nickname})"
1766
- self .assertEqual (u (hn ), "Doe, Rev John A. Kenneth, III (Kenny)" )
1771
+ self .assertEqual (u (hn ), "TEST2" )
1772
+ CONSTANTS .string_format = _orig
1767
1773
1768
1774
def test_quote_nickname_formating (self ):
1769
1775
hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
@@ -1821,6 +1827,13 @@ def test_formating_of_nicknames_with_double_quotes(self):
1821
1827
hn .nickname = ''
1822
1828
self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III" )
1823
1829
1830
+ def test_formating_of_nicknames_in_middle (self ):
1831
+ hn = HumanName ("Rev John A. Kenneth Doe III (Kenny)" )
1832
+ hn .string_format = "{title} {first} ({nickname}) {middle} {last} {suffix}"
1833
+ self .assertEqual (u (hn ), "Rev John (Kenny) A. Kenneth Doe III" )
1834
+ hn .nickname = ''
1835
+ self .assertEqual (u (hn ), "Rev John A. Kenneth Doe III" )
1836
+
1824
1837
TEST_NAMES = (
1825
1838
"John Doe" ,
1826
1839
"John Doe, Jr." ,
0 commit comments