1
1
import unittest
2
+ import pytest
2
3
from mock import patch
3
4
4
5
from lib .helpers .wordlist_helper import WordList
5
6
from lib .helpers .wordlist_helper import DEFAULT_WORDLIST_FILE
6
7
7
8
9
+ @pytest .fixture (scope = 'class' )
10
+ def user_wordlist (request , tmpdir_factory ):
11
+ user_wordlist = ['user-word1' , 'user-word2' ]
12
+ tmpdir = tmpdir_factory .mktemp ('user_wordlist' )
13
+ user_wordlist_file = tmpdir .join ('user-wordlist.txt' )
14
+ user_wordlist_file .write ('\n ' .join (user_wordlist ))
15
+ request .cls .user_wordlist_file = str (user_wordlist_file )
16
+ request .cls .user_wordlist = user_wordlist
17
+
18
+
19
+ @pytest .mark .usefixtures ('user_wordlist' )
8
20
class TestWordList (unittest .TestCase ):
9
21
def setUp (self ):
10
22
self .wordlist = WordList ()
@@ -19,6 +31,15 @@ def test_get_wordlist_from_stdin(self):
19
31
wordlist , wordlist_types = self .wordlist .get_wordlist ()
20
32
self .assertEqual (wordlist , expected_wordlist )
21
33
34
+ def test_get_wordlist_from_stdin_and_wordlist (self ):
35
+ stdin_wordlist = ['keyword1' , 'keyword1' ]
36
+ expected_wordlist = []
37
+ expected_wordlist .extend (stdin_wordlist )
38
+ expected_wordlist .extend (self .user_wordlist )
39
+ with patch ('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist' , return_value = stdin_wordlist ):
40
+ wordlist , wordlist_types = self .wordlist .get_wordlist (self .user_wordlist_file )
41
+ self .assertEqual (wordlist , expected_wordlist )
42
+
22
43
def test_using_default_wordlist (self ):
23
44
stdin_wordlist = []
24
45
with patch ('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist' , return_value = stdin_wordlist ):
0 commit comments