def test_Field_validates_any_value(self): field = Field(can_be_none=True) try: field.validate(u'hello') field.validate(666) field.validate(None) except ValidationError: self.fail('Field.validate() raised ValidationError unexpectedly')
def test_Field_json_methods(self): f = Field() self.assertEquals(u'hello world', f.from_json(f.to_json(u'hello world'))) self.assertEquals(u'hello world', f.to_json(f.from_json(u'hello world')))
def test_Field_json_methods(self): f = Field() self.assertEquals(u"hello world", f.from_json(f.to_json(u"hello world"))) self.assertEquals(u"hello world", f.to_json(f.from_json(u"hello world")))
def test_Field_raises_ValidationError_when_value_cannot_be_None(self): field = Field(can_be_none=False) self.assertRaises(ValidationError, field.validate, None)