Skip to content

Commit bba0d82

Browse files
committed
Mock stdin wordlist
1 parent 6206f29 commit bba0d82

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/helpers/wordlist_helper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def get_wordlist(self, wordlist_files=None):
1919
wordlist = []
2020
wordlist_types = []
2121
stdin_words = self.get_stdin_wordlist()
22-
print(stdin_words)
2322
if stdin_words:
2423
wordlist_types.append('stdin')
2524
wordlist.extend(stdin_words)

tests/helpers/test_wordlist_helper.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import unittest
2-
from mock import Mock
32
from mock import patch
43

54
from lib.helpers.wordlist_helper import WordList
@@ -13,16 +12,16 @@ def setUp(self):
1312
self.default_wordlist = list(word_file.read().splitlines())
1413

1514
def test_get_wordlist_from_stdin(self):
16-
stdin_list = ['keyword1', 'keyword1']
15+
stdin_wordlist = ['keyword1', 'keyword1']
1716
expected_wordlist = []
18-
expected_wordlist.extend(stdin_list)
17+
expected_wordlist.extend(stdin_wordlist)
1918
expected_wordlist.extend(self.default_wordlist)
20-
with patch('sys.stdin') as mock_stdin:
21-
mock_stdin.read = Mock(return_value='\n'.join(stdin_list))
22-
mock_stdin.isatty = Mock(return_value=False)
19+
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
2320
wordlist, wordlist_types = self.wordlist.get_wordlist()
2421
self.assertEqual(wordlist, expected_wordlist)
2522

2623
def test_using_default_wordlist(self):
27-
wordlist, wordlist_types = self.wordlist.get_wordlist()
28-
self.assertEqual(wordlist, self.default_wordlist)
24+
stdin_wordlist = []
25+
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
26+
wordlist, wordlist_types = self.wordlist.get_wordlist()
27+
self.assertEqual(wordlist, self.default_wordlist)

0 commit comments

Comments
 (0)