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