def test_float_field_dumps_enforce_type(self): field = FloatField(enforce_type=True) for value in [1, True, "foo", object(), {}, []]: with self.assertRaises(ValueError): field.dumps(value) self.assertEqual(1.2, field.dumps(1.2))
def test_float_field_dumps_no_enforce_type(self): field = FloatField() for value in [1, 1.2, True, "foo", object(), {}, []]: self.assertEqual(value, field.dumps(value))