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

Commit

Permalink
installed pytest dependency,added runner
Browse files Browse the repository at this point in the history
Signed-off-by: Fenn-25 <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Jul 10, 2018
1 parent 235db36 commit 5e759c5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ submit/
*.DS_Store
*/migrations/
credentials.json
.pytest_cache
29 changes: 29 additions & 0 deletions infohub/runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class PytestTestRunner(object):
"""Runs pytest to discover and run tests."""

def __init__(self, verbosity=1, failfast=False, keepdb=False, **kwargs):
self.verbosity = verbosity
self.failfast = failfast
self.keepdb = keepdb

def run_tests(self, test_labels):
"""Run pytest and return the exitcode.
It translates some of Django's test command option to pytest's.
"""
import pytest

argv = []
if self.verbosity == 0:
argv.append('--quiet')
if self.verbosity == 2:
argv.append('--verbose')
if self.verbosity == 3:
argv.append('-vv')
if self.failfast:
argv.append('--exitfirst')
if self.keepdb:
argv.append('--reuse-db')

argv.extend(test_labels)
return pytest.main(argv)
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = infohub.settings
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ six==1.11.0
social-auth-app-django==2.1.0
social-auth-core==1.6.0
static3==0.7.0
pytest==3.5.1
mock==2.0.0
pytest-selenium==1.10.0
pytest-django==3.1.2
selenium==3.4.3
pytest-variables==1.6.1
pytest-base-url==1.3.0
pytest-metadata==1.7.0

0 comments on commit 5e759c5

Please sign in to comment.