Skip to content

Commit 8c6f20c

Browse files
committed
Finished changing it to work properly with setup.py.
Changed the tests to include the proper namespace along with being able to run the tests by using `python setup.py test`.
1 parent f7f4842 commit 8c6f20c

9 files changed

+23
-13
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,11 @@ pip install -r test-requirements.txt
104104
pytest
105105
```
106106

107+
Or you can optionally run:
108+
109+
```bash
110+
pip install -r test-requirements.txt
111+
python setup.py test
112+
```
113+
107114
If you're thinking of adding a new feature to the project, consider also contributing with a couple of tests. A well-tested codebase is a sane codebase. :)

setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[aliases]
2+
test=pytest

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ def dependencies(file):
2727
]
2828
},
2929
install_requires=dependencies('requirements.txt'),
30+
setup_requires=['pytest-runner'],
3031
tests_require=dependencies('test-requirements.txt'),
3132
include_package_data=True)
File renamed without changes.
File renamed without changes.
File renamed without changes.

VHostScan/tests/helpers/test_file_helper.py renamed to tests/helpers/test_file_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55
from collections import namedtuple
6-
from lib.helpers.file_helper import parse_word_list_argument, get_combined_word_lists
6+
from VHostScan.lib.helpers.file_helper import parse_word_list_argument, get_combined_word_lists
77

88
WORDLIST_FILES = {
99
'simpsons': ['marge', 'bart', 'homer', 'lisa', 'maggie'],

VHostScan/tests/helpers/test_wordlist_helper.py renamed to tests/helpers/test_wordlist_helper.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import pytest
33
from unittest.mock import patch
44

5-
from lib.helpers.wordlist_helper import WordList
6-
from lib.helpers.wordlist_helper import DEFAULT_WORDLIST_FILE
5+
from VHostScan.lib.helpers.wordlist_helper import WordList
6+
from VHostScan.lib.helpers.wordlist_helper import DEFAULT_WORDLIST_FILE
77

88

99
@pytest.fixture(scope='class')
@@ -28,7 +28,7 @@ def test_get_wordlist_from_stdin(self):
2828
stdin_wordlist = ['keyword1', 'keyword1']
2929
expected_wordlist = []
3030
expected_wordlist.extend(stdin_wordlist)
31-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
31+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
3232
wordlist, wordlist_types = self.wordlist.get_wordlist()
3333
self.assertEqual(wordlist, expected_wordlist)
3434

@@ -37,59 +37,59 @@ def test_get_wordlist_from_stdin_and_wordlist(self):
3737
expected_wordlist = []
3838
expected_wordlist.extend(stdin_wordlist)
3939
expected_wordlist.extend(self.user_wordlist)
40-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
40+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
4141
wordlist, wordlist_types = self.wordlist.get_wordlist(self.user_wordlist_file)
4242
self.assertEqual(wordlist, expected_wordlist)
4343

4444
def test_using_default_wordlist(self):
4545
stdin_wordlist = []
46-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
46+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
4747
wordlist, wordlist_types = self.wordlist.get_wordlist()
4848
self.assertEqual(wordlist, self.default_wordlist)
4949

5050
def test_ip_using_prefix(self):
5151
stdin_wordlist = ['127.0.0.1']
5252
prefix = 'dev-'
53-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
53+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
5454
wordlist, wordlist_types = self.wordlist.get_wordlist(None, prefix)
5555
self.assertEqual(wordlist, stdin_wordlist)
5656

5757
def test_ip_using_suffix(self):
5858
stdin_wordlist = ['127.0.0.1']
5959
suffix = 'test'
60-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
60+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
6161
wordlist, wordlist_types = self.wordlist.get_wordlist(None,None,suffix)
6262
self.assertEqual(wordlist,stdin_wordlist)
6363

6464
def test_word_with_prefix(self):
6565
stdin_wordlist = ['www','www2','www3']
6666
expected_wordlist = stdin_wordlist + ['dev-www','dev-www2','dev-www3']
6767
prefix = 'dev-'
68-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
68+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
6969
wordlist, wordlist_types = self.wordlist.get_wordlist(None,prefix)
7070
self.assertEqual(wordlist,expected_wordlist)
7171

7272
def test_words_with_suffix(self):
7373
stdin_wordlist = ['www','www2','www3']
7474
expected_wordlist = stdin_wordlist + ['wwwtest','www2test','www3test']
7575
suffix = 'test'
76-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
76+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
7777
wordlist, wordlist_types = self.wordlist.get_wordlist(None,None,suffix)
7878
self.assertEqual(wordlist, expected_wordlist)
7979

8080
def test_words_with_host_and_prefix(self):
8181
stdin_wordlist = ['www.%s']
8282
expected_wordlist = stdin_wordlist + ['test-www.%s']
8383
prefix = 'test-'
84-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
84+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
8585
wordlist, wordlist_types = self.wordlist.get_wordlist(None, prefix)
8686
self.assertEqual(wordlist, expected_wordlist)
8787

8888
def test_words_with_host_and_suffix(self):
8989
stdin_wordlist = ['www.%s']
9090
expected_wordlist = stdin_wordlist + ['wwwtest.%s']
9191
suffix = 'test'
92-
with patch('lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
92+
with patch('VHostScan.lib.helpers.wordlist_helper.WordList.get_stdin_wordlist', return_value=stdin_wordlist):
9393
wordlist, wordlist_types = self.wordlist.get_wordlist(None,None,suffix)
9494
self.assertEqual(wordlist, expected_wordlist)
9595

VHostScan/tests/test_input.py renamed to tests/test_input.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import argparse
22
import pytest
33

4-
from lib.input import cli_argument_parser
4+
from VHostScan.lib.input import cli_argument_parser
55

66
def test_parse_arguments_default_value(tmpdir):
77
words = ['word1', 'word2', 'word3']

0 commit comments

Comments
 (0)