Use pytest as test runner

* Used pytest to run tests within tox environments

* Removed test runner within setup.py
This commit is contained in:
David Smith 2020-11-29 21:27:16 +00:00
parent 146a96fca0
commit fd759e44d2
3 changed files with 6 additions and 34 deletions

View file

@ -5,3 +5,6 @@ all_files = 1
[upload_sphinx]
upload-dir = build/docs/html
[tool:pytest]
DJANGO_SETTINGS_MODULE = analytical.tests.settings

View file

@ -17,42 +17,9 @@ except ImportError:
pass
class TestCommand(Command):
description = "run package tests"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from analytical.tests.utils import run_tests
run_tests()
cmdclass['test'] = TestCommand
def read_file(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
try:
import django
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"analytical.tests.settings"
)
django.setup()
except ImportError:
print(
"Could not import django. "
"This is fine, unless you intend to run unit tests."
)
import analytical as package # noqa
setup(

View file

@ -10,11 +10,13 @@ envlist =
description = Unit tests
deps =
coverage
pytest
pytest-django
django111: Django>=1.11,<2.0
django22: Django>=2.2,<3.0
django30: Django>=3.0,<3.1
commands =
coverage run setup.py test
coverage run -m pytest
coverage xml
[gh-actions]