from Algorithm import Algorithm, from_data, from_file # Algorithm.is_in_alphabet tests = {'1': ['1', '111111', '', '2', '12'], '123': ['1111', '123123', '', '0123', '1230', '12032']} tests_anses = {'1': [True, True, True, False, False], '123': [True, True, True, False, False, False]} for test_alph in tests: for i in range(len(tests[test_alph])): assert Algorithm.is_in_alphabet(tests[test_alph][i], test_alph) == tests_anses[test_alph][i], ( str(tests[test_alph][i]) + ' in ' + test_alph + ' not ' + str(tests_anses[test_alph][i])) # Algorihtm.get_substitution_parts alphabet = 'ab' tests = ['ab ba', ' ', ' a', 'a ', 'a .a'] tests_anses = [('ab', 'ba', False), ('', '', False), ('', 'a', False), ('a', '', False), ('a', 'a', True)] for i in range(len(tests)): assert Algorithm.get_substitution_parts(tests[i], alphabet) == tests_anses[i], ( str(Algorithm.get_substitution_parts(tests[i], alphabet)) + ' != ' + str(tests_anses[i])) # Algorihtm.get_option_parts options = Algorithm.get_base_options() tests = ['write intermediate: True', 'file with input: output.txt'] tests_anses = [('write intermediate', 'True'), ('file with input', 'output.txt')] for i in range(len(tests)): assert Algorithm.get_option_parts(tests[i], options) == tests_anses[i], ( '\n' + str(Algorithm.get_option_parts(tests[i], options)) + '\n' + str(tests_anses[i])) tests = ['write intermediate: True, file with input: input.txt', 'file without input: input.txt'] for test in tests: try: Algorithm.get_option_parts(test, options) print(test)