From cb3ec3a09137a94307a58f53bf33b96b33e4d66c Mon Sep 17 00:00:00 2001 From: Peter Marheine Date: Thu, 23 Dec 2021 10:33:08 +1100 Subject: [PATCH] Stop using nosetests Nose is no longer maintained and is incompatible with Python 3.10, so can no longer be used. This change runs `coverage` manually to collect coverage and uses `pytest` to run doctests, collectively covering what was tested using django_nose. --- demo/demoproject/settings.py | 11 ----------- demo/setup.py | 2 +- tox.ini | 16 ++++++++++++++-- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/demo/demoproject/settings.py b/demo/demoproject/settings.py index 6e690f1..87e4bc4 100644 --- a/demo/demoproject/settings.py +++ b/demo/demoproject/settings.py @@ -53,8 +53,6 @@ INSTALLED_APPS = ( "django.contrib.sites", "django.contrib.messages", "django.contrib.staticfiles", - # Stuff that must be at the end. - "django_nose", ) @@ -111,15 +109,6 @@ DOWNLOADVIEW_RULES += [ # Test/development settings. DEBUG = True -TEST_RUNNER = "django_nose.NoseTestSuiteRunner" -NOSE_ARGS = [ - "--verbosity=2", - "--no-path-adjustment", - "--nocapture", - "--all-modules", - "--with-coverage", - "--with-doctest", -] TEMPLATES = [ diff --git a/demo/setup.py b/demo/setup.py index 1055fa7..3b9a946 100644 --- a/demo/setup.py +++ b/demo/setup.py @@ -21,6 +21,6 @@ setup( packages=["demoproject"], include_package_data=True, zip_safe=False, - install_requires=["django-downloadview", "django-nose"], + install_requires=["django-downloadview", "pytest-django"], entry_points={"console_scripts": ["demo = demoproject.manage:main"]}, ) diff --git a/tox.ini b/tox.ini index e228195..8a1fbf3 100644 --- a/tox.ini +++ b/tox.ini @@ -27,11 +27,16 @@ deps = dj31: Django>=3.1,<3.2 dj32: Django>=3.2,<3.3 djmain: https://github.com/django/django/archive/main.tar.gz - nose + pytest + pytest-cov commands = pip install -e . pip install -e demo - python -Wd {envbindir}/demo test --cover-package=django_downloadview --cover-package=demoproject --cover-xml {posargs: tests demoproject} + # doctests + pytest --cov=django_downloadview --cov=demoproject {posargs} + # all other test cases + coverage run --append {envbindir}/demo test {posargs: tests demoproject} + coverage xml pip freeze ignore_outcome = djmain: True @@ -65,3 +70,10 @@ commands = [flake8] max-line-length = 88 ignore = E203, W503 + +[coverage:run] +source = django_downloadview,demo + +[pytest] +DJANGO_SETTINGS_MODULE = demoproject.settings +addopts = --doctest-modules --ignore=docs/