Skip to content

Commit 657c5b8

Browse files
Songkran Nethangigkokman
authored andcommitted
Adding wordlist helper
1 parent 1dfa952 commit 657c5b8

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/helpers/wordlist_helper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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 []

tests/helpers/test_wordlist_helper.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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)

0 commit comments

Comments
 (0)