コード例 #1
0
    def test_clean(self):
        field = MultipleValuesField(min_values=2, max_values=3)

        assert field.clean('hello,world') == ['hello', 'world']

        with pytest.raises(forms.ValidationError):
            field.clean('hello')
        with pytest.raises(forms.ValidationError):
            field.clean('hello,world,and,many,happy,rainbows')
コード例 #2
0
    def test_clean(self):
        field = MultipleValuesField(min_values=2, max_values=3)

        assert field.clean('hello,world') == ['hello', 'world']

        with pytest.raises(forms.ValidationError):
            field.clean('hello')
        with pytest.raises(forms.ValidationError):
            field.clean('hello,world,and,many,happy,rainbows')
コード例 #3
0
    def test_clean(self):
        field = MultipleValuesField(min_values=2, max_values=3)

        assert field.clean("hello,world") == ["hello", "world"]

        with pytest.raises(forms.ValidationError):
            field.clean("hello")
        with pytest.raises(forms.ValidationError):
            field.clean("hello,world,and,many,happy,rainbows")
コード例 #4
0
    def test_clean_all_valid(self):
        field = MultipleValuesField(forms.IntegerField(), all_valid=False)

        assert field.clean("1,2,3") == [1, 2, 3]
        assert field.clean("a,1,b,2") == [1, 2]