From 113005b528d01c6128529f012efe9dde50980adf Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Fri, 16 Aug 2024 10:12:32 +0200 Subject: [PATCH] Run tests with standard django-admin --- .github/workflows/test.yml | 3 +-- README.rst | 2 +- pyproject.toml | 6 ------ tests/thumbnail_tests/test_alternative_resolutions.py | 4 ---- tests/thumbnail_tests/test_backends.py | 3 --- tests/thumbnail_tests/test_commands.py | 3 --- tests/thumbnail_tests/test_engines.py | 3 --- tests/thumbnail_tests/test_filters.py | 3 --- tests/thumbnail_tests/test_storage.py | 4 ---- tests/thumbnail_tests/test_templatetags.py | 3 --- tox.ini | 8 ++++---- 11 files changed, 6 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b1355760..8c8dc6120 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade tox tox-gh-actions + python -m pip install --upgrade tox tox-gh-actions toml - name: Tox tests run: | @@ -58,4 +58,3 @@ jobs: uses: codecov/codecov-action@v3 with: name: Python ${{ matrix.python-version }} - diff --git a/README.rst b/README.rst index aff6cb009..99c3af5b6 100644 --- a/README.rst +++ b/README.rst @@ -44,7 +44,7 @@ in Google Groups. Tests ----- -The tests should run with tox and pytest. Running `tox` will run all tests for all environments. +The tests should run with tox. Running `tox` will run all tests for all environments. However, it is possible to run a certain environment with `tox -e `, a list of all environments can be found with `tox -l`. These tests require the dependencies of the different engines defined in the documentation. It is possible to install these dependencies into a vagrant image with the diff --git a/pyproject.toml b/pyproject.toml index 807ec1784..972c0d2f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,12 +13,6 @@ exclude_lines = [ "if __name__ == .__main__.:", ] -[tool.pytest.ini_options] -python_files = ["test_*.py", "*tests.py"] -norecursedirs =[".*", "tmp*", "__pycache__"] -testpaths = ["tests"] -django_find_project = false - [tool.ruff] exclude = [ ".tox", diff --git a/tests/thumbnail_tests/test_alternative_resolutions.py b/tests/thumbnail_tests/test_alternative_resolutions.py index 439191878..8eddbaa09 100644 --- a/tests/thumbnail_tests/test_alternative_resolutions.py +++ b/tests/thumbnail_tests/test_alternative_resolutions.py @@ -1,7 +1,5 @@ import os -import pytest - from sorl.thumbnail import get_thumbnail from sorl.thumbnail.conf import settings from sorl.thumbnail.engines.pil_engine import Engine as PILEngine @@ -9,8 +7,6 @@ from .utils import BaseStorageTestCase -pytestmark = pytest.mark.django_db - class AlternativeResolutionsTest(BaseStorageTestCase): name = 'retina.jpg' diff --git a/tests/thumbnail_tests/test_backends.py b/tests/thumbnail_tests/test_backends.py index a0101090a..b4116c1ff 100644 --- a/tests/thumbnail_tests/test_backends.py +++ b/tests/thumbnail_tests/test_backends.py @@ -5,7 +5,6 @@ import unittest from io import StringIO -import pytest from django.test import TestCase from django.test.utils import override_settings from PIL import Image @@ -19,8 +18,6 @@ from .models import Item from .utils import BaseTestCase, FakeFile, same_open_fd_count -pytestmark = pytest.mark.django_db - class BackendTest(BaseTestCase): def test_delete(self): diff --git a/tests/thumbnail_tests/test_commands.py b/tests/thumbnail_tests/test_commands.py index 4b506b75e..31c48be9a 100644 --- a/tests/thumbnail_tests/test_commands.py +++ b/tests/thumbnail_tests/test_commands.py @@ -1,7 +1,6 @@ import os from io import StringIO -import pytest from django.core import management from sorl.thumbnail.conf import settings @@ -9,8 +8,6 @@ from .models import Item from .utils import BaseTestCase -pytestmark = pytest.mark.django_db - class CommandTests(BaseTestCase): def make_test_thumbnails(self, *sizes): diff --git a/tests/thumbnail_tests/test_engines.py b/tests/thumbnail_tests/test_engines.py index 0f1837bbc..9ad8e318c 100644 --- a/tests/thumbnail_tests/test_engines.py +++ b/tests/thumbnail_tests/test_engines.py @@ -3,7 +3,6 @@ import unittest from subprocess import PIPE, Popen -import pytest from django.core.files.storage import default_storage from django.template.loader import render_to_string from PIL import Image @@ -20,8 +19,6 @@ from .models import Item from .utils import BaseTestCase -pytestmark = pytest.mark.django_db - class SimpleTestCase(BaseTestCase): def test_simple(self): diff --git a/tests/thumbnail_tests/test_filters.py b/tests/thumbnail_tests/test_filters.py index 6b239b7f4..763c0c935 100644 --- a/tests/thumbnail_tests/test_filters.py +++ b/tests/thumbnail_tests/test_filters.py @@ -1,10 +1,7 @@ -import pytest from django.template.loader import render_to_string from tests.thumbnail_tests.utils import BaseTestCase -pytestmark = pytest.mark.django_db - class FilterTestCase(BaseTestCase): def test_html_filter(self): diff --git a/tests/thumbnail_tests/test_storage.py b/tests/thumbnail_tests/test_storage.py index 751fd6c2c..2b8c244dc 100644 --- a/tests/thumbnail_tests/test_storage.py +++ b/tests/thumbnail_tests/test_storage.py @@ -1,14 +1,10 @@ import unittest -import pytest - from sorl.thumbnail import default, get_thumbnail from sorl.thumbnail.helpers import get_module_class from .utils import BaseStorageTestCase -pytestmark = pytest.mark.django_db - class StorageTestCase(BaseStorageTestCase): name = 'org.jpg' diff --git a/tests/thumbnail_tests/test_templatetags.py b/tests/thumbnail_tests/test_templatetags.py index 72ba5cff4..02fa90d4c 100644 --- a/tests/thumbnail_tests/test_templatetags.py +++ b/tests/thumbnail_tests/test_templatetags.py @@ -2,7 +2,6 @@ import re from subprocess import PIPE, Popen -import pytest from django.template.loader import render_to_string from django.test import Client, TestCase from django.test.utils import override_settings @@ -14,8 +13,6 @@ from .models import Item from .utils import DATA_DIR, BaseTestCase -pytestmark = pytest.mark.django_db - class TemplateTestCaseA(BaseTestCase): def test_model(self): diff --git a/tox.ini b/tox.ini index 3d03c7abc..00af77b4e 100644 --- a/tox.ini +++ b/tox.ini @@ -29,9 +29,7 @@ envlist = [testenv] deps = - pytest - pytest-cov - pytest-django + coverage pillow redis: redis dynamodb: boto @@ -53,7 +51,9 @@ setenv = pgmagick: DJANGO_SETTINGS_MODULE=tests.settings.pgmagick dbm: DJANGO_SETTINGS_MODULE=tests.settings.dbm commands = - python -m pytest -rw --cov-append --cov-config setup.cfg --cov sorl --cov-report=xml {posargs:} + coverage run {envbindir}/django-admin test -v2 {posargs:} + coverage report -m + coverage xml [testenv:py38-qa] skip_install = True