Example #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."]
Example #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."]
Example #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."]
Example #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 == []
Example #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 == []
Example #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 == []