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

installed pytest dependency,added runner #367

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line :p

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fenn-cs, Not needed but you may wanna add .coverage* and coverage.xml to .gitignore as well.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line :p

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