Fix test_to_dict_enum under Python3

This commit is contained in:
Jason Paryani
2014-06-26 01:07:16 -07:00
parent 3a0eaacc9d
commit 5befda532f

View File

@@ -172,10 +172,18 @@ def test_set_dict_union(addressbook):
assert person.employment.employer.name == 'foo' assert person.employment.employer.name == 'foo'
try:
basestring # attempt to evaluate basestring
def isstr(s):
return isinstance(s, basestring)
except NameError:
def isstr(s):
return isinstance(s, str)
def test_to_dict_enum(addressbook): def test_to_dict_enum(addressbook):
person = addressbook.Person.new_message(**{'phones': [{'number': '999-9999', 'type': 'mobile'}]}) person = addressbook.Person.new_message(**{'phones': [{'number': '999-9999', 'type': 'mobile'}]})
field = person.to_dict()['phones'][0]['type'] field = person.to_dict()['phones'][0]['type']
assert isinstance(field, basestring) assert isstr(field)
assert field == 'mobile' assert field == 'mobile'