def test_field_counter(): f1 = String() f2 = String() assert f2.counter > f1.counter # be damn sure that we don't have non-determinism in anything # (only works in python < 3.6) json = {chr(x): chr(x) for x in range(97, 105)} for _ in range(1000): class Foo(JsonSerde): a = String() b = String() c = String() d = String() e = String() f = String() g = String() h = String() f1 = Foo.from_json(json) f2 = Foo.from_json(json) assert f1 == f2 assert not (f1 != f2) assert hash(f1) == hash(f2) assert repr(f1) == repr(f2)
class Foo(JsonSerde): a = String() b = String() c = String() d = String() e = String() f = String() g = String() h = String()
class Foo(JsonSerde): wat = String(is_optional=True, default_factory=default)
class Foo(JsonSerde): wat = String(is_optional=True, default='wat')
class Bar(JsonSerde): bar = String(is_optional=True, write_absent=False)
class Foo(JsonSerde): foo = String(is_optional=True, write_absent=True)
class Inner(JsonSerde): foo = String()
class Bar(JsonSerde): wat = String(is_optional=True, write_null=False)
class Foo(JsonSerde): wat = String(is_optional=True, write_null=True)
class Foo(JsonSerde): wat = String(rename='bar')
class Foo(JsonSerde): wat = String()
class Bar(JsonSerde): baz = String()
class Foo(JsonSerde): foo = String(is_optional=True)
class Foo(JsonSerde): foo = String()
class Foo(JsonSerde): bar = String()
class Foo(JsonSerde): wat = String(rename="bar")