Exemplo n.º 1
0
def test_set_context():
    class f():
        def __init__(self):
            self.parent = None

        def __call__(self, value):
            return self.parent.foo

        def set_context(self, parent):
            self.parent = parent

    field = Field(validators=[f()])
    field.foo = 'bar'

    assert field.run_validation(123) == 'bar'
Exemplo n.º 2
0
def test_deepcopy():
    field = Field(source='foo')
    field.foo = 'bar'
    field = copy.deepcopy(field)
    assert field.source == 'foo'
    assert not hasattr(field, 'foo')