Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove default attribute from formatted string (#44) #45

Merged
merged 3 commits into from
Mar 21, 2016

Conversation

derek73
Copy link
Owner

@derek73 derek73 commented Mar 19, 2016

Setting empty_attribute_default = None causes 'None" to show up in the name's string formatting. My attempt to fix it doesn't' pass the tests.

@derek73
Copy link
Owner Author

derek73 commented Mar 19, 2016

So, if you set CONSTANTS.empty_attribute_default = None, 11 tests fail, below. Maybe they are all just problems with the tests, because its explicitly testing for '' instead of hn.C.empty_attribute_default?

(nameparser) breeze:python-nameparser $ python tests.py 
..........x.....x..........................................................................................................................x..........................F.x.FFFFx..FFF............F..........FJüan de la Véña
<HumanName : [
    title: 'None' 
    first: 'Jüan' 
    middle: 'None' 
    last: 'de la Véña' 
    suffix: 'None'
    nickname: 'None'
]>
..F.....xx.x..............x...................x.x........
======================================================================
FAIL: test_roman_numeral_initials (__main__.HumanNameConjunctionTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1160, in test_roman_numeral_initials
    self.m(hn.suffix, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Larry V I'
<HumanName : [
    title: 'None' 
    first: 'Larry' 
    middle: 'V' 
    last: 'I' 
    suffix: 'None'
    nickname: 'None'
]>

======================================================================
FAIL: test_nickname_in_double_quotes (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1329, in test_nickname_in_double_quotes
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Benjamin Franklin'
<HumanName : [
    title: 'None' 
    first: 'Benjamin' 
    middle: 'None' 
    last: 'Franklin' 
    suffix: 'None'
    nickname: 'Ben'
]>

======================================================================
FAIL: test_nickname_in_parenthesis (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1297, in test_nickname_in_parenthesis
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Benjamin Franklin'
<HumanName : [
    title: 'None' 
    first: 'Benjamin' 
    middle: 'None' 
    last: 'Franklin' 
    suffix: 'None'
    nickname: 'Ben'
]>

======================================================================
FAIL: test_nickname_in_parenthesis_with_comma (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1304, in test_nickname_in_parenthesis_with_comma
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Franklin, Benjamin'
<HumanName : [
    title: 'None' 
    first: 'Benjamin' 
    middle: 'None' 
    last: 'Franklin' 
    suffix: 'None'
    nickname: 'Ben'
]>

======================================================================
FAIL: test_nickname_in_parenthesis_with_comma_and_suffix (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1311, in test_nickname_in_parenthesis_with_comma_and_suffix
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Franklin, Benjamin, Jr.'
<HumanName : [
    title: 'None' 
    first: 'Benjamin' 
    middle: 'None' 
    last: 'Franklin' 
    suffix: 'Jr.'
    nickname: 'Ben'
]>

======================================================================
FAIL: test_single_quotes_on_both_name_not_treated_as_nickname (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1343, in test_single_quotes_on_both_name_not_treated_as_nickname
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'La'tanya O'connor'
<HumanName : [
    title: 'None' 
    first: 'La'tanya' 
    middle: 'None' 
    last: 'O'connor' 
    suffix: 'None'
    nickname: 'None'
]>

======================================================================
FAIL: test_single_quotes_on_end_of_last_name_not_treated_as_nickname (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1350, in test_single_quotes_on_end_of_last_name_not_treated_as_nickname
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Mari' Aube''
<HumanName : [
    title: 'None' 
    first: 'Mari'' 
    middle: 'None' 
    last: 'Aube'' 
    suffix: 'None'
    nickname: 'None'
]>

======================================================================
FAIL: test_single_quotes_on_first_name_not_treated_as_nickname (__main__.HumanNameNicknameTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 1336, in test_single_quotes_on_first_name_not_treated_as_nickname
    self.m(hn.middle, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for 'Brian O'connor'
<HumanName : [
    title: 'None' 
    first: 'Brian' 
    middle: 'None' 
    last: 'O'connor' 
    suffix: 'None'
    nickname: 'None'
]>

======================================================================
FAIL: test_blank_name (__main__.HumanNamePythonTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 183, in test_blank_name
    self.m(hn.first, "", hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'None' != '' for ''
<HumanName : [
    title: 'None' 
    first: 'None' 
    middle: 'None' 
    last: 'None' 
    suffix: 'None'
    nickname: 'None'
]>

======================================================================
FAIL: test_slice (__main__.HumanNamePythonTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 149, in test_slice
    self.m(hn[1:], ['John', 'P.', 'Doe-Ray', 'CLU, CFP, LUTC',''], hn)
  File "tests.py", line 46, in m
    hn
AssertionError: '[u'John', u'P.', u'Doe-Ray', u'CLU, CFP, LUTC', None]' != '[u'John', u'P.', u'Doe-Ray', u'CLU, CFP, LUTC', u'']' for 'Doe-Ray, Dr. John P., CLU, CFP, LUTC'
<HumanName : [
    title: 'Dr.' 
    first: 'John' 
    middle: 'P.' 
    last: 'Doe-Ray' 
    suffix: 'CLU, CFP, LUTC'
    nickname: 'None'
]>

======================================================================
FAIL: test_variations_of_TEST_NAMES (__main__.HumanNameVariationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests.py", line 2075, in test_variations_of_TEST_NAMES
    self.m(getattr(hn, attr), getattr(nocomma, attr), hn)
  File "tests.py", line 46, in m
    hn
AssertionError: 'John' != 'None' for 'John Doe'
<HumanName : [
    title: 'None' 
    first: 'John' 
    middle: 'None' 
    last: 'Doe' 
    suffix: 'None'
    nickname: 'None'
]>

----------------------------------------------------------------------
Ran 261 tests in 0.058s

FAILED (failures=11, expected failures=11)

@derek73 derek73 added this to the v0.3.15 milestone Mar 21, 2016
run all tests with both empty string and None values for empty_attribute_default
derek73 added a commit that referenced this pull request Mar 21, 2016
remove default attribute from formatted string (#44)
@derek73 derek73 merged commit 1fedd4e into master Mar 21, 2016
@derek73 derek73 deleted the 44_none_default branch March 21, 2016 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant