def test_obj2dict_object_classkey(self): class A(object): pass obj = A() obj.foo = 'bar' assert dutils.obj2dict(obj, classkey='kls') == { 'foo': 'bar', 'kls': 'A'}
def test_obj2dict_list(self): assert dutils.obj2dict([{'foo': 'bar'}]) == [{'foo': 'bar'}]
def test_obj2dict_dict(self): assert dutils.obj2dict({'foo': 'bar'}) == {'foo': 'bar'}
def test_obj2dict_simple_types(self): assert dutils.obj2dict(1) == 1 assert dutils.obj2dict('foo') == 'foo' assert dutils.obj2dict(None) is None
def test_obj2dict_object(self): class A(object): pass obj = A() obj.foo = 'bar' assert dutils.obj2dict(obj) == {'foo': 'bar'}