示例#1
0
    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
示例#2
0
    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"])
示例#3
0
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)
示例#4
0
    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)