Skip to content
This repository was archived by the owner on Nov 8, 2018. It is now read-only.

Commit 5e759c5

Browse files
committed
installed pytest dependency,added runner
Signed-off-by: Fenn-25 <fenn25.fn@gmail.com>
1 parent 235db36 commit 5e759c5

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ submit/
1111
*.DS_Store
1212
*/migrations/
1313
credentials.json
14+
.pytest_cache

infohub/runner.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class PytestTestRunner(object):
2+
"""Runs pytest to discover and run tests."""
3+
4+
def __init__(self, verbosity=1, failfast=False, keepdb=False, **kwargs):
5+
self.verbosity = verbosity
6+
self.failfast = failfast
7+
self.keepdb = keepdb
8+
9+
def run_tests(self, test_labels):
10+
"""Run pytest and return the exitcode.
11+
12+
It translates some of Django's test command option to pytest's.
13+
"""
14+
import pytest
15+
16+
argv = []
17+
if self.verbosity == 0:
18+
argv.append('--quiet')
19+
if self.verbosity == 2:
20+
argv.append('--verbose')
21+
if self.verbosity == 3:
22+
argv.append('-vv')
23+
if self.failfast:
24+
argv.append('--exitfirst')
25+
if self.keepdb:
26+
argv.append('--reuse-db')
27+
28+
argv.extend(test_labels)
29+
return pytest.main(argv)

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
DJANGO_SETTINGS_MODULE = infohub.settings

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ six==1.11.0
3636
social-auth-app-django==2.1.0
3737
social-auth-core==1.6.0
3838
static3==0.7.0
39+
pytest==3.5.1
40+
mock==2.0.0
41+
pytest-selenium==1.10.0
42+
pytest-django==3.1.2
43+
selenium==3.4.3
44+
pytest-variables==1.6.1
45+
pytest-base-url==1.3.0
46+
pytest-metadata==1.7.0

0 commit comments

Comments
 (0)