示例#1
0
    def test_formfield(self):
        model_field = EnumField(choices=["this", "that"])
        form_field = model_field.formfield()

        assert form_field.clean("this") == "this"
        assert form_field.clean("that") == "that"

        with pytest.raises(ValidationError):
            form_field.clean("")

        with pytest.raises(ValidationError):
            form_field.clean("invalid")
示例#2
0
    def test_formfield(self):
        model_field = EnumField(choices=['this', 'that'])
        form_field = model_field.formfield()

        assert form_field.clean('this') == 'this'
        assert form_field.clean('that') == 'that'

        with pytest.raises(ValidationError):
            form_field.clean('')

        with pytest.raises(ValidationError):
            form_field.clean('invalid')
    def test_formfield(self):
        model_field = EnumField(choices=['this', 'that'])
        form_field = model_field.formfield()

        assert form_field.clean('this') == 'this'
        assert form_field.clean('that') == 'that'

        with pytest.raises(ValidationError):
            form_field.clean('')

        with pytest.raises(ValidationError):
            form_field.clean('invalid')