Writing doctrines for the method, abbreviation of the dictionary by searching for the transmitted keyword in the keys of the original dictionary and returning a new abbreviated dictionary. My documentation is as follows:
def abbreviate_dict(key_word, original_dict):
"""
>>> orig_dict = {apple_stems: 2, apple_cores: 5, apple_seeds: 3}
>>> abbreviate_dict('apple', orig_dict)
{'cores': 5, 'seeds': 3, 'stems': 2}
"""
etc.
return new_dict
The function works, but when I run py.test doctest, the function does not pass the test because it returns strings as unicode. I don't programmatically switch strings to unicode in my function, but I know that python 2.7 is returning to unicode.
Expected:
{'cores': 5, 'seeds': 3, 'stems': 2}
Got:
{u'cores': 5, u'seeds': 3, u'stems': 2}
How can I make doctest recognize that unicode and regular string outputs are the same?
af3ld source
share