From 5befda532fb2f0ef0366e15c715c428bcaef0b92 Mon Sep 17 00:00:00 2001 From: Jason Paryani Date: Thu, 26 Jun 2014 01:07:16 -0700 Subject: [PATCH] Fix `test_to_dict_enum` under Python3 --- test/test_struct.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_struct.py b/test/test_struct.py index c292c6b..c459ff5 100644 --- a/test/test_struct.py +++ b/test/test_struct.py @@ -172,10 +172,18 @@ def test_set_dict_union(addressbook): 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): person = addressbook.Person.new_message(**{'phones': [{'number': '999-9999', 'type': 'mobile'}]}) field = person.to_dict()['phones'][0]['type'] - assert isinstance(field, basestring) + assert isstr(field) assert field == 'mobile'