diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ build/ dist/ .hypothesis -.pytest_cache +.cache +.pytest_cache \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,8 @@ include Makefile +include pytest.ini include requirements.txt include requirements-swh.txt +include requirements-test.txt include version.txt recursive-include swh/web/static * recursive-include swh/web/templates * diff --git a/Makefile.local b/Makefile.local --- a/Makefile.local +++ b/Makefile.local @@ -16,11 +16,6 @@ run-migrations: python3 swh/web/manage.py migrate 2>/dev/null -.PHONY: run-tests-migrations -run-tests-migrations: - rm -f swh/web/settings/testdb.sqlite3 2>/dev/null - django-admin migrate --settings=swh.web.settings.tests 2>/dev/null - run-django-webpack-devserver: run-migrations bash -c "trap 'trap - SIGINT SIGTERM ERR; kill %1' SIGINT SIGTERM ERR; npm run start-dev & cd swh/web && python3 manage.py runserver --nostatic" @@ -39,5 +34,5 @@ run-gunicorn-server: run-migrations gunicorn3 -b 127.0.0.1:5004 swh.web.wsgi -test: build-webpack-dev-no-verbose run-tests-migrations +test: build-webpack-dev-no-verbose diff --git a/debian/control b/debian/control --- a/debian/control +++ b/debian/control @@ -15,7 +15,8 @@ python3-htmlmin, python3-magic (>= 0.3.0~), python3-lxml, - python3-nose, + python3-pytest, + python3-pytest-django, python3-pygments, python3-pypandoc, python3-requests, diff --git a/debian/rules b/debian/rules --- a/debian/rules +++ b/debian/rules @@ -1,10 +1,8 @@ #!/usr/bin/make -f export PYBUILD_NAME=swh.web -export PYBUILD_TEST_ARGS=--with-doctest -sv ./swh/web/tests -export PYBUILD_BEFORE_TEST=cd {build_dir}; python3 swh/web/manage.py migrate -export PYBUILD_AFTER_TEST=cd {build_dir}; rm -f swh/web/settings/testdb.sqlite3 -export DJANGO_SETTINGS_MODULE=swh.web.settings.tests +export PYBUILD_OPTION=--test-pytest +export PYBUILD_TEST_ARGS=./swh/web/tests %: dh $@ --with python3 --buildsystem=pybuild diff --git a/pytest.ini b/pytest.ini --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,4 @@ [pytest] norecursedirs = docs node_modules +DJANGO_SETTINGS_MODULE = swh.web.settings.tests + diff --git a/requirements-test.txt b/requirements-test.txt --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1 +1,3 @@ -nose +pytest +pytest-django + diff --git a/swh/web/settings/tests.py b/swh/web/settings/tests.py --- a/swh/web/settings/tests.py +++ b/swh/web/settings/tests.py @@ -75,11 +75,5 @@ ALLOWED_HOSTS += ['testserver'] -# As nose is used as a test runner, we cannot benefit from the in-memory -# django test database used when running tests through '$ python3 manage.py test'. -# So instead use a different database file that will be created on the fly -# when running the tests. -DATABASES['default']['NAME'] = os.path.join(PROJECT_DIR, 'testdb.sqlite3') - # Silent DEBUG output when running unit tests LOGGING['handlers']['console']['level'] = 'INFO' diff --git a/swh/web/tests/__init__.py b/swh/web/tests/__init__.py --- a/swh/web/tests/__init__.py +++ b/swh/web/tests/__init__.py @@ -1,13 +0,0 @@ -# Copyright (C) 2017-2018 The Software Heritage developers -# See the AUTHORS file at the top-level directory of this distribution -# License: GNU General Public License version 3, or any later version -# See top-level LICENSE file for more information - -# this configuration is needed to successfully run the tests locally -# when calling 'make test' - -import django -import os - -os.environ["DJANGO_SETTINGS_MODULE"] = "swh.web.settings.tests" -django.setup()