def test_basic_question_is_valid__invalid_validator__exception(): question = BasicQuestion(SOME_NAME, SOME_STRING, SOME_DEFAULT, validator=object()) with pytest.raises(ValueError): question.validate(SOME_STRING, SOME_ANSWERS)
def test_basic_question_is_valid__validator__result_of_validator( is_valid, validator_response): question = BasicQuestion(SOME_NAME, SOME_STRING, SOME_DEFAULT, validator=lambda v, a: validator_response) result = question.validate(SOME_STRING, SOME_ANSWERS) assert result.valid == is_valid
def test_basic_question_is_valid__no_validator__always_valid(value): question = BasicQuestion(SOME_NAME, SOME_STRING, SOME_DEFAULT) result = question.validate(value, SOME_ANSWERS) assert result.valid