From e8f8ce9bb52244772ee102e15d31ce59ac091dc0 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Fri, 22 Sep 2023 16:34:28 +0100 Subject: [PATCH 1/2] Switched to pytest for tests --- .github/workflows/build.yml | 2 +- CONTRIBUTING.rst | 4 ++-- pytest.ini | 4 ++++ requirements-test.txt | 5 +++-- tests/settings.py | 16 ++++++++++++++++ tox.ini | 3 +-- 6 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 pytest.ini create mode 100644 tests/settings.py 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 From c967978b011c61caa90286a5bf185e901806d281 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Fri, 22 Sep 2023 16:39:29 +0100 Subject: [PATCH 2/2] Build fixes --- .github/workflows/build.yml | 6 +++--- .pre-commit-config.yaml | 2 +- MANIFEST.in | 3 ++- tox.ini | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 309aa3a..096d7d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,16 +70,16 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.9' + python-version: '3.10' - uses: actions/cache@v2 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ '3.9' }}-${{ hashFiles('requirements*.txt') }} + key: ${{ runner.os }}-pip-${{ '3.10' }}-${{ hashFiles('requirements*.txt') }} - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e . - pip install checkmanifest + pip install check-manifest - name: check-manifest run: | check-manifest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 738d3c6..3fc12c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: rev: '1.0.1' hooks: - id: flynt - language_version: python3.8 + language_version: python3.10 - repo: https://github.com/psf/black rev: 22.3.0 hooks: diff --git a/MANIFEST.in b/MANIFEST.in index 4edc1b7..5a0b49f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,10 +3,11 @@ include LICENSE include *.rst include MANIFEST.in include .coveragerc -include tox.ini +include *.ini include *.py include *.sh include *.txt +include *.yaml graft docs graft src diff --git a/tox.ini b/tox.ini index bb328be..83aff4e 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ commands = deps = -r requirements-test.txt -e . - checkmanifest: checkmanifest + checkmanifest: check-manifest django22: Django==2.2.19 django30: Django==3.0.14 django31: Django==3.1.12