示例#1
0
    def test_choice_field(self):
        choices = ('first', 'second')
        f = ChoiceField('test', choices=choices)

        assert f.process_value('first') == 'first'
        assert f.process_value('second') == 'second'

        with pytest.raises(ValueError):
            assert f.process_value('third')
示例#2
0
    def test_choice_field_with_capitalization(self):
        choices = ('First', )
        f = ChoiceField('test', choices=choices, capitalize=True)

        assert f.process_value('first') == 'First'