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