Пример #1
0
 def test_max(self):
     field = Float(max=3)
     field.data = field.convert(["3.14"])
     assert field.data == 3.14
     assert not field.validate()
     assert field.errors == ["Must be at most 3."]
Пример #2
0
 def test_min(self):
     field = Float(min=5)
     field.data = field.convert(["3.14"])
     assert field.data == 3.14
     assert not field.validate()
     assert field.errors == ["Must be at least 5."]
Пример #3
0
 def test_none_required(self):
     field = Float()
     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 = Float(default=3.14)
     field.data = field.convert(None)
     assert field.data == 3.14
     assert field.validate()
     assert field.errors == []
Пример #5
0
 def test_none(self):
     field = Float(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 = Float()
     field.data = field.convert(["3.14"])
     assert field.data == 3.14
     assert field.validate()
     assert field.errors == []