예제 #1
0
    def test_to_dict_obj(self):
        class Foo(object):
            def __init__(self):
                self.foo = 42

        expected = {'foo': 42}
        assert fields.to_marshallable_type(Foo()) == expected
예제 #2
0
    def test_to_dict_custom_marshal(self):
        class Foo(object):
            def __marshallable__(self):
                return {'foo': 42}

        expected = {'foo': 42}
        assert fields.to_marshallable_type(Foo()) == expected
예제 #3
0
 def test_to_dict(self):
     expected = data = {'foo': 42}
     assert fields.to_marshallable_type(data) == expected
예제 #4
0
 def test_to_dict_custom_marshal(self):
     class Foo(object):
         def __marshallable__(self):
             return {'foo': 42}
     expected = {'foo': 42}
     assert fields.to_marshallable_type(Foo()) == expected
예제 #5
0
 def test_to_dict_obj(self):
     class Foo(object):
         def __init__(self):
             self.foo = 42
     expected = {'foo': 42}
     assert fields.to_marshallable_type(Foo()) == expected
예제 #6
0
 def test_to_dict(self):
     expected = data = {'foo': 42}
     assert fields.to_marshallable_type(data) == expected
예제 #7
0
 def output(self, key, obj, **kwargs):
     to_marshal = to_marshallable_type(obj)
     to_marshal['uid'] = obj.id
     return super().output(key, to_marshal)