예제 #1
0
    def test(self):
        expected = 42

        def default_callable():
            return expected

        test_value = StringField(default=expected).bind(Json(), 'a')
        test_value.process(None)
        self.assertEqual(test_value.data, expected)

        test_callable = StringField(default=default_callable).bind(Json(), 'a')
        test_callable.process(None)
        self.assertEqual(test_callable.data, expected)
예제 #2
0
 def test_no_filters(self):
     my_filter = lambda x: x
     self.assertRaises(TypeError,
                       ListField,
                       self.t,
                       filters=[my_filter],
                       _json=Json(),
                       _name='foo')
예제 #3
0
 def setUp(self):
     t = StringField(validators=[validators.DataRequired()]).bind(
         Json(), 'a')
     self.flags = t.flags