def test_invalid_outputs(self):
     field = fields.Float()
     self._dump_raises(field, 'abc',
                       "could not convert string to float: 'abc'")
     self._dump_raises(
         field, [],
         "float() argument must be a string or a number, not 'list'")
 def test_valid_outputs(self):
     field = fields.Float()
     self._dump_equal(field, '1', 1.0)
     self._dump_equal(field, '0', 0.0)
     self._dump_equal(field, 1, 1.0)
     self._dump_equal(field, 0, 0.0)
     self._dump_equal(field, 1, 1.0)
     self._dump_equal(field, 0, 0.0)
 def test_valid_inputs(self):
     field = fields.Float()
     self._load_equal(field, '1', 1.0)
     self._load_equal(field, '0', 0.0)
     self._load_equal(field, 1, 1.0)
     self._load_equal(field, 0, 0.0)
     self._load_equal(field, 1.0, 1.0)
     self._load_equal(field, 0.0, 0.0)
class MyContract(Contract):
    property1 = fields.Boolean()
    # property2 = fields.Date()
    property3 = fields.Integer()
    property4 = fields.String()
    property5 = fields.List(fields.Integer())
    # property6 = fields.UUID()
    # property7 = fields.DateTime()
    property8 = fields.Float()
    property9 = fields.Nested(NestedContract)
 def test_valid_outputs(self):
     field = fields.Float(min_value=1, max_value=3)
     self._dump_equal(field, 0.0, 0.0)
     self._dump_equal(field, 4.0, 4.0)
 def test_invalid_inputs(self):
     field = fields.Float(min_value=1, max_value=3)
     self._load_raises(field, 0.9,
                       ['Ensure this value is greater than or equal to 1.'])
     self._load_raises(field, 3.1,
                       ['Ensure this value is less than or equal to 3.'])
 def test_valid_inputs(self):
     field = fields.Float(min_value=1, max_value=3)
     self._load_equal(field, 1.0, 1.0)
     self._load_equal(field, 3.0, 3.0)
 def test_invalid_inputs(self):
     field = fields.Float()
     self._load_raises(field, 'abc', ['A valid number is required.'])