Skip to content
Snippets Groups Projects
Commit b72ad88d authored by ulif's avatar ulif
Browse files

More test with open fds and WordList.

Make sure WordLists handle open file descriptors correctly.
parent 03ec0150
No related branches found
No related tags found
No related merge requests found
......@@ -219,6 +219,24 @@ class TestWordList(object):
assert w_list.fd is not None
assert w_list.path is None
def test_open_file_descriptor_simple(self, tmpdir):
# we handle simple lists from open file descriptors correctly
in_file = tmpdir.mkdir("work").join("mywordlist")
in_file.write("foo\nbar\n\nbaz\n")
with open(str(in_file), "r") as my_open_file:
w_list = WordList(my_open_file)
result = tuple(w_list)
assert result == ("foo", "bar", "baz")
def test_open_file_descriptor_signed(self):
# we can handle signed wordlists from open file descriptors
in_path = os.path.join(
os.path.dirname(__file__), "sample_signed_wordlist.asc")
with open(str(in_path), "r") as my_open_file:
w_list = WordList(my_open_file)
result = tuple(w_list)
assert ("foo", "bar", "-dash-at-start", "baz") == result
def test_detect_unsigned_wordlists(self, tmpdir):
# we can detect unsigned wordlist files.
in_file = tmpdir.mkdir("work").join("mywordlist")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment