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.
This commit is contained in:
Peter Marheine 2021-12-23 10:33:08 +11:00
parent 95b36fc843
commit cb3ec3a091
3 changed files with 15 additions and 14 deletions

View file

@ -53,8 +53,6 @@ INSTALLED_APPS = (
"django.contrib.sites", "django.contrib.sites",
"django.contrib.messages", "django.contrib.messages",
"django.contrib.staticfiles", "django.contrib.staticfiles",
# Stuff that must be at the end.
"django_nose",
) )
@ -111,15 +109,6 @@ DOWNLOADVIEW_RULES += [
# Test/development settings. # Test/development settings.
DEBUG = True DEBUG = True
TEST_RUNNER = "django_nose.NoseTestSuiteRunner"
NOSE_ARGS = [
"--verbosity=2",
"--no-path-adjustment",
"--nocapture",
"--all-modules",
"--with-coverage",
"--with-doctest",
]
TEMPLATES = [ TEMPLATES = [

View file

@ -21,6 +21,6 @@ setup(
packages=["demoproject"], packages=["demoproject"],
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
install_requires=["django-downloadview", "django-nose"], install_requires=["django-downloadview", "pytest-django"],
entry_points={"console_scripts": ["demo = demoproject.manage:main"]}, entry_points={"console_scripts": ["demo = demoproject.manage:main"]},
) )

16
tox.ini
View file

@ -27,11 +27,16 @@ deps =
dj31: Django>=3.1,<3.2 dj31: Django>=3.1,<3.2
dj32: Django>=3.2,<3.3 dj32: Django>=3.2,<3.3
djmain: https://github.com/django/django/archive/main.tar.gz djmain: https://github.com/django/django/archive/main.tar.gz
nose pytest
pytest-cov
commands = commands =
pip install -e . pip install -e .
pip install -e demo 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 pip freeze
ignore_outcome = ignore_outcome =
djmain: True djmain: True
@ -65,3 +70,10 @@ commands =
[flake8] [flake8]
max-line-length = 88 max-line-length = 88
ignore = E203, W503 ignore = E203, W503
[coverage:run]
source = django_downloadview,demo
[pytest]
DJANGO_SETTINGS_MODULE = demoproject.settings
addopts = --doctest-modules --ignore=docs/