Workarounds:
1. Helper function for dict -> object
class _Object(object): def __init__(self, data): for name, value in data: setattr(self, name, value)
def dict_to_object(data): return _Object(data)
self.assertThat( dict_to_object(params), MatchesStructure.fromExample(user, 'this', 'that', 'tother'))
2. Helper function for object -> dict
def getattrs(obj, *keys): d = {} for key in keys: d[key] = getattr(obj, key) return d
self.assertThat(params, Equals(dict_to_object(user, 'this', 'that', 'tother')))
Workarounds:
1. Helper function for dict -> object
class _Object(object):
setattr( self, name, value)
def __init__(self, data):
for name, value in data:
def dict_to_ object( data):
return _Object(data)
self.assertThat( to_object( params) , cture.fromExamp le(user, 'this', 'that', 'tother'))
dict_
MatchesStru
2. Helper function for object -> dict
def getattrs(obj, *keys):
d = {}
for key in keys:
d[key] = getattr(obj, key)
return d
self.assertThat (params, Equals( dict_to_ object( user, 'this', 'that', 'tother')))