1
1
import unittest
2
- from mock import Mock
3
2
from mock import patch
4
3
5
4
from lib .helpers .wordlist_helper import WordList
@@ -13,16 +12,16 @@ def setUp(self):
13
12
self .default_wordlist = list (word_file .read ().splitlines ())
14
13
15
14
def test_get_wordlist_from_stdin (self ):
16
- stdin_list = ['keyword1' , 'keyword1' ]
15
+ stdin_wordlist = ['keyword1' , 'keyword1' ]
17
16
expected_wordlist = []
18
- expected_wordlist .extend (stdin_list )
17
+ expected_wordlist .extend (stdin_wordlist )
19
18
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 ):
23
20
wordlist , wordlist_types = self .wordlist .get_wordlist ()
24
21
self .assertEqual (wordlist , expected_wordlist )
25
22
26
23
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