Handle ordered option failing under Python 2.6
This commit is contained in:
@@ -202,6 +202,8 @@ def test_to_dict_verbose(addressbook):
|
|||||||
person = addressbook.Person.new_message(**{'name': 'Test'})
|
person = addressbook.Person.new_message(**{'name': 'Test'})
|
||||||
|
|
||||||
assert person.to_dict(verbose=True)['phones'] == []
|
assert person.to_dict(verbose=True)['phones'] == []
|
||||||
|
|
||||||
|
if sys.version_info >= (2, 7):
|
||||||
assert person.to_dict(verbose=True, ordered=True)['phones'] == []
|
assert person.to_dict(verbose=True, ordered=True)['phones'] == []
|
||||||
|
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
@@ -211,4 +213,8 @@ def test_to_dict_verbose(addressbook):
|
|||||||
def test_to_dict_ordered(addressbook):
|
def test_to_dict_ordered(addressbook):
|
||||||
person = addressbook.Person.new_message(**{'name': 'Alice', 'phones': [{'type': 'mobile', 'number': '555-1212'}], 'id': 123L, 'employment': {'school': 'MIT'}, 'email': 'alice@example.com'})
|
person = addressbook.Person.new_message(**{'name': 'Alice', 'phones': [{'type': 'mobile', 'number': '555-1212'}], 'id': 123L, 'employment': {'school': 'MIT'}, 'email': 'alice@example.com'})
|
||||||
|
|
||||||
|
if sys.version_info >= (2, 7):
|
||||||
assert list(person.to_dict(ordered=True).keys()) == ['id', 'name', 'email', 'phones', 'employment']
|
assert list(person.to_dict(ordered=True).keys()) == ['id', 'name', 'email', 'phones', 'employment']
|
||||||
|
else:
|
||||||
|
with pytest.raises(Exception):
|
||||||
|
person.to_dict(ordered=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user