From b72ad88d02042070bd2aaa51528d4a70fa82a04b Mon Sep 17 00:00:00 2001 From: ulif <uli@gnufix.de> Date: Thu, 30 Jul 2015 12:48:52 +0200 Subject: [PATCH] More test with open fds and WordList. Make sure WordLists handle open file descriptors correctly. --- tests/test_wordlist.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_wordlist.py b/tests/test_wordlist.py index 351ec59..1759171 100644 --- a/tests/test_wordlist.py +++ b/tests/test_wordlist.py @@ -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") -- GitLab