class ExampleClass(Serializable): bool_tag = Bool().example(True) bool_default = Bool(default_value=False) bool_both = Bool(default_value=False).example(True) int_tag = Integer().example(1) int_default = Integer(default_value=2) int_both = Integer(default_value=100).example(3) dict_tag = Dict().example({'a': 'b'}) dict_default = Dict(default_value={'c': 'd'}) dict_both = Dict(default_value={'z': 'z'}).example({'e': 'f', 'g': 'h'}) instance_tag = Instance(Point).example(Point(x=0, y=1)) instance_default = Instance(Point, default_value=Point(x=2, y=3)) instance_both = Instance(Point, default_value=Point(x=4, y=5)).example( Point(x=6, y=7), ) # Instance provides a default example if the value is a Serializable # that can provide an example. instance_neither = Instance(Point)
class Point(Serializable): x = Integer().example(100) y = Integer().example(101)
class A(Serializable): value = Integer().tag(example=ord('a')) next_ = Instance(B)
class B(Serializable): value = Integer(example=ord('b')) next_ = Instance(C)