Пример #1
0
 def test_max(self):
     field = Integer(max=3)
     field.data = field.convert(["4"])
     assert field.data == 4
     assert not field.validate()
     assert field.errors == ["Must be at most 3."]
Пример #2
0
 def test_min(self):
     field = Integer(min=5)
     field.data = field.convert(["4"])
     assert field.data == 4
     assert not field.validate()
     assert field.errors == ["Must be at least 5."]
Пример #3
0
 def test_none_required(self):
     field = Integer()
     field.data = field.convert(None)
     assert field.data is None
     assert not field.validate()
     assert field.errors == ["Required."]
Пример #4
0
 def test_none_default(self):
     field = Integer(default=4)
     field.data = field.convert(None)
     assert field.data == 4
     assert field.validate()
     assert field.errors == []
Пример #5
0
 def test_none(self):
     field = Integer(required=False)
     field.data = field.convert(None)
     assert field.data is None
     assert field.validate()
     assert field.errors == []
Пример #6
0
 def test_basic(self):
     field = Integer()
     field.data = field.convert(["4"])
     assert field.data == 4
     assert field.validate()
     assert field.errors == []