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)
Пример #2
0
 class Vector(Serializable):
     head = Instance(Point)
     tail = Instance(Point).example(Point(x=1, y=3))
Пример #3
0
 class A(Serializable):
     value = Integer().tag(example=ord('a'))
     next_ = Instance(B)
Пример #4
0
 class C(Serializable):
     point = Instance(Point)
     unicode_ = Unicode().tag(example='foo')
 class B(Serializable):
     value = Integer(example=ord('b'))
     next_ = Instance(C)