def it_accepts_valid_choice():
        result = validate_choice('choice', ('choice', 'another_choice'))
        assert result is 'choice'

        with raises(ValidationError) as excinfo:
            validate_choice('c', 'abc')
        assert excinfo.value.code == INVALID_LIST
Beispiel #2
0
    def it_accepts_valid_choice():
        result = validate_choice('choice', ('choice', 'another_choice'))
        assert result is 'choice'

        with raises(ValidationError) as excinfo:
            validate_choice('c', 'abc')
        assert excinfo.value.code == INVALID_LIST
    def it_accepts_list_types():
        result = validate_list(['choice', 'another_choice'])
        assert result == ['choice', 'another_choice']

        result = validate_list(('choice', 'another_choice'))
        assert result == ['choice', 'another_choice']

        def iterator():
            yield 'choice'

        result = validate_list(iterator())
        assert result == ['choice']

        with raises(ValidationError) as excinfo:
            validate_choice('c', 'abc')
        assert excinfo.value.code == INVALID_LIST
Beispiel #4
0
    def it_accepts_list_types():
        result = validate_list(['choice', 'another_choice'])
        assert result == ['choice', 'another_choice']

        result = validate_list(('choice', 'another_choice'))
        assert result == ['choice', 'another_choice']

        def iterator():
            yield 'choice'

        result = validate_list(iterator())
        assert result == ['choice']

        with raises(ValidationError) as excinfo:
            validate_choice('c', 'abc')
        assert excinfo.value.code == INVALID_LIST
 def it_rejects_invalid_choice():
     with raises(ValidationError) as excinfo:
         validate_choice('not-a-choice', ('choice', 'another_choice'))
     assert excinfo.value.code == INVALID_CHOICE
Beispiel #6
0
 def it_rejects_invalid_choice():
     with raises(ValidationError) as excinfo:
         validate_choice('not-a-choice', ('choice', 'another_choice'))
     assert excinfo.value.code == INVALID_CHOICE