def test_load_choices_with_no_choice_mark(): test_directory = os.path.dirname(os.path.abspath(__file__)) test_file = test_directory + "/test_choices.csv" choices = choice.load_choices(test_file) expected_choices = { 1: { 'text': "a long time ago", 'choices': [('yes', 2), ('no', 3)] } } assert expected_choices == choices
def test_load_choices_with_choice_mark(): test_directory = os.path.dirname(os.path.abspath(__file__)) test_file = test_directory + "/test_choices_with_choice_mark.csv" choices = choice.load_choices(test_file) expected_choices = { 1: { 'text': "a long time ago", 'html': 'tests/pic.png', 'sound': 'tests/sound.mp3', 'choices': [('yes', 2), ('no', 3)] } } assert expected_choices == choices
def test_catch_excepetion_and_output_line_if_csv_not_valid(capsys): test_directory = os.path.dirname(os.path.abspath(__file__)) test_file = test_directory + "/test_invalid_choice.csv" choice.load_choices(test_file) out, _ = capsys.readouterr() assert "Error reading choice" in out
def test_load_choices_with_pass_through_step(): test_directory = os.path.dirname(os.path.abspath(__file__)) test_file = test_directory + "/test_pass_through_step.csv" choices = choice.load_choices(test_file)
def test_load_choices_ignores_lines_that_start_with_new_line(): test_directory = os.path.dirname(os.path.abspath(__file__)) test_file = test_directory + "/test_ends_with_new_lines_and_spaces.csv" choices = choice.load_choices(test_file)
def test_throws_exception_when_file_not_found(): with pytest.raises(IOError): c = choice.load_choices("file_not_found.csv")