def test_raises_on_non_readable_path(self): io = IO() with self.assertRaises(IOError): reader = io.read_dictionary("path/that/doesnt/exist") for line in reader: pass
def test_reads_correct_entries_despite_blanks(self): io = IO() reader = io.read_dictionary(self.valid_path_with_blanks) values = list(reader) self.assertListEqual(values, ["foo", "bar", "baz"])
def run(args): """Runs the core of the script; builds the graph and performs the required search type Split out as a separate function to facilitate optional profiling :param args: the arguments object generated by the script call """ io = IO() reader = io.read_dictionary(args.dictionary_path) graph = WordGraph() for word in reader: graph.add(word) if args.all_paths: paths = graph.find_all_paths(args.word_from, args.word_to) for path in paths: print io.format_word_path(path) else: path = graph.find_path(args.word_from, args.word_to) print io.format_word_path(path)
def test_reads_entries_as_strings(self): io = IO() reader = io.read_dictionary(self.valid_path_with_blanks) values = list(reader) for value in values: self.assertIsInstance(value, str)