@@ -1365,6 +1365,20 @@ def test_nickname_in_parenthesis(self):
13651365 self .m (hn .last , "Franklin" , hn )
13661366 self .m (hn .nickname , "Ben" , hn )
13671367
1368+ def test_two_word_nickname_in_parenthesis (self ):
1369+ hn = HumanName ("Benjamin (Big Ben) Franklin" )
1370+ self .m (hn .first , "Benjamin" , hn )
1371+ self .m (hn .middle , "" , hn )
1372+ self .m (hn .last , "Franklin" , hn )
1373+ self .m (hn .nickname , "Big Ben" , hn )
1374+
1375+ def test_two_words_in_quotes (self ):
1376+ hn = HumanName ('Benjamin "Big Ben" Franklin' )
1377+ self .m (hn .first , "Benjamin" , hn )
1378+ self .m (hn .middle , "" , hn )
1379+ self .m (hn .last , "Franklin" , hn )
1380+ self .m (hn .nickname , "Big Ben" , hn )
1381+
13681382 def test_nickname_in_parenthesis_with_comma (self ):
13691383 hn = HumanName ("Franklin, Benjamin (Ben)" )
13701384 self .m (hn .first , "Benjamin" , hn )
@@ -1380,9 +1394,6 @@ def test_nickname_in_parenthesis_with_comma_and_suffix(self):
13801394 self .m (hn .suffix , "Jr." , hn )
13811395 self .m (hn .nickname , "Ben" , hn )
13821396
1383- # it would be hard to support this without breaking some of the
1384- # other examples with single quotes in the names.
1385- @unittest .expectedFailure
13861397 def test_nickname_in_single_quotes (self ):
13871398 hn = HumanName ("Benjamin 'Ben' Franklin" )
13881399 self .m (hn .first , "Benjamin" , hn )
@@ -1398,9 +1409,9 @@ def test_nickname_in_double_quotes(self):
13981409 self .m (hn .nickname , "Ben" , hn )
13991410
14001411 def test_single_quotes_on_first_name_not_treated_as_nickname (self ):
1401- hn = HumanName ("Brian O'connor" )
1412+ hn = HumanName ("Brian Andrew O'connor" )
14021413 self .m (hn .first , "Brian" , hn )
1403- self .m (hn .middle , "" , hn )
1414+ self .m (hn .middle , "Andrew " , hn )
14041415 self .m (hn .last , "O'connor" , hn )
14051416 self .m (hn .nickname , "" , hn )
14061417
@@ -1419,19 +1430,26 @@ def test_single_quotes_on_end_of_last_name_not_treated_as_nickname(self):
14191430 self .m (hn .nickname , "" , hn )
14201431
14211432 # http://code.google.com/p/python-nameparser/issues/detail?id=17
1422- def test_parenthesis_are_removed (self ):
1423- hn = HumanName ("John Jones (Google Docs )" )
1433+ def test_parenthesis_are_removed_from_name (self ):
1434+ hn = HumanName ("John Jones (Unknown )" )
14241435 self .m (hn .first , "John" , hn )
14251436 self .m (hn .last , "Jones" , hn )
14261437 # not testing the nicknames because we don't actually care
1427- # about Google Docs.
1428-
1429- def test_parenthesis_are_removed2 (self ):
1438+ # about Google Docs here
1439+
1440+ def test_duplicate_parenthesis_are_removed_from_name (self ):
14301441 hn = HumanName ("John Jones (Google Docs), Jr. (Unknown)" )
14311442 self .m (hn .first , "John" , hn )
14321443 self .m (hn .last , "Jones" , hn )
14331444 self .m (hn .suffix , "Jr." , hn )
14341445
1446+ def test_parenthesis_and_quotes_together (self ):
1447+ hn = HumanName ("Jennifer 'Jen' Jones (Duff)" )
1448+ self .m (hn .first , "Jennifer" , hn )
1449+ self .m (hn .last , "Jones" , hn )
1450+ self .m (hn .nickname , "Jen Duff" , hn )
1451+
1452+
14351453
14361454class PrefixesTestCase (HumanNameTestBase ):
14371455
0 commit comments