File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+
3
+
4
+ class WordList :
5
+ def get_stdin_wordlist (self ):
6
+ return list (line for line in sys .stdin .read ().splitlines ()) if not sys .stdin .isatty () else []
Original file line number Diff line number Diff line change
1
+ import unittest
2
+ from mock import Mock
3
+ from mock import patch
4
+
5
+ from lib .helpers .wordlist_helper import WordList
6
+
7
+
8
+ class TestWordList (unittest .TestCase ):
9
+ def setUp (self ):
10
+ self .wordlist = WordList ()
11
+
12
+ def test_get_wordlist_from_stdin (self ):
13
+ stdin_list = ['keyword1' , 'keyword1' ]
14
+ with patch ('sys.stdin' ) as mock_stdin :
15
+ mock_stdin .read = Mock (return_value = '\n ' .join (stdin_list ))
16
+ mock_stdin .isatty = Mock (return_value = False )
17
+ self .assertEqual (self .wordlist .get_stdin_wordlist (), stdin_list )
You can’t perform that action at this time.
0 commit comments