From 10d109eb6c210b4e0b94991ddbb4b279e0583eab Mon Sep 17 00:00:00 2001 From: David Smith Date: Sun, 29 Nov 2020 21:27:16 +0000 Subject: [PATCH] Use pytest as test runner * Used pytest to run tests within tox environments * Removed test runner within setup.py --- setup.cfg | 3 +++ setup.py | 33 --------------------------------- tox.ini | 4 +++- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/setup.cfg b/setup.cfg index e9db078..d3d35ec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,3 +5,6 @@ all_files = 1 [upload_sphinx] upload-dir = build/docs/html + +[tool:pytest] +DJANGO_SETTINGS_MODULE = analytical.tests.settings \ No newline at end of file diff --git a/setup.py b/setup.py index 33554a7..f03ae69 100644 --- a/setup.py +++ b/setup.py @@ -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( diff --git a/tox.ini b/tox.ini index 831fc68..b60187e 100644 --- a/tox.ini +++ b/tox.ini @@ -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]