예제 #1
0
    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')
예제 #2
0
    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')
예제 #3
0
    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')))
예제 #4
0
    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")))
예제 #5
0
    def test_Field_raises_ValidationError_when_value_cannot_be_None(self):
        field = Field(can_be_none=False)

        self.assertRaises(ValidationError, field.validate, None)