diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cae6aa2..309aa3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: pip install -r requirements-test.txt - name: Test suite run: | - ./runtests.py + pytest pre-commit: runs-on: ubuntu-latest diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index ccdf8d5..18a6d11 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -26,7 +26,7 @@ To set up your environment to be able to work on django-mailer, do the following 4. Install test requirements:: - $ pip install coverage mock + $ pip install -r requirements-test.txt 5. Create a branch for local development:: @@ -34,7 +34,7 @@ To set up your environment to be able to work on django-mailer, do the following 6. Now you can make your changes locally. Run the tests in the virtualenv using:: - $ ./runtests.py + $ pytest To run the tests in all supported environments, do:: diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..2eff0f6 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +DJANGO_SETTINGS_MODULE = tests.settings +#django_find_project = false +norecursedirs = examples build dist diff --git a/requirements-test.txt b/requirements-test.txt index ce6b2f4..84b89d0 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,2 +1,3 @@ -mock==3.0.5;python_version<'3.6' -mock==4.0.1;python_version>='3.6' +pytest +pytest-django +pytest-cov diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..6ad763d --- /dev/null +++ b/tests/settings.py @@ -0,0 +1,16 @@ +INSTALLED_APPS = [ + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sites", + "mailer", +] +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:", + } +} + +SITE_ID = 1 +SECRET_KEY = "notasecret" +MIDDLEWARE_CLASSES = [] diff --git a/tox.ini b/tox.ini index 6210da1..bb328be 100644 --- a/tox.ini +++ b/tox.ini @@ -17,10 +17,9 @@ basepython = py311: python3.11 commands = - test: coverage run ./runtests.py + test: pytest --cov=mailer checkmanifest: check-manifest deps = - coverage -r requirements-test.txt -e . checkmanifest: checkmanifest