From 3a02d07024ac167d0d6701f9da2a086971224f0c Mon Sep 17 00:00:00 2001
From: ulif <uli@gnufix.de>
Date: Thu, 30 Jul 2015 12:29:57 +0200
Subject: [PATCH] Adapt more get_wordlist() tests to WordList.

WordLists should generally fullfill all promises of get_wordlist,
except closing file descriptors. The latter is not supported because
we might want to read a file several times.
---
 tests/test_wordlist.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tests/test_wordlist.py b/tests/test_wordlist.py
index db252d3..fc612c0 100644
--- a/tests/test_wordlist.py
+++ b/tests/test_wordlist.py
@@ -255,3 +255,17 @@ class TestWordList(object):
         assert long_list[0] == "a"
         assert long_list[-1] == "@"
         assert len(long_list) == 8192
+
+    def test_get_wordlist_simple(self, tmpdir):
+        # simple wordlists can be created
+        in_file = tmpdir.mkdir("work").join("mywordlist")
+        in_file.write("a\nb\n")
+        result = list(WordList(str(in_file)))
+        assert ['a', 'b'] == result
+
+    def test_get_wordlist_ignore_empty_lines(self, tmpdir):
+        # we ignore empty lines in wordlists
+        in_file = tmpdir.mkdir("work").join("mywordlist")
+        in_file.write("\n\na\n\n")
+        result = list(WordList(str(in_file)))
+        assert ['a'] == result
-- 
GitLab