Skip to content

Commit

Permalink
WIP: Tests running with standard django-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Aug 16, 2024
1 parent 6386604 commit 91cbd91
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <env>`, 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
Expand Down
9 changes: 0 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,3 @@ omit = */sorl-thumbnail/sorl/__init__.py
[cov:report]
exclude_lines = pragma: no cover
if __name__ == .__main__.:

;; The pytest framework

[tool:pytest]
python_files = test_*.py *tests.py
norecursedirs = .* tmp* __pycache__
testpaths = tests
django_find_project = false

5 changes: 0 additions & 5 deletions tests/thumbnail_tests/test_alternative_resolutions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import os

import pytest

from sorl.thumbnail import get_thumbnail
from sorl.thumbnail.conf import settings
from sorl.thumbnail.images import ImageFile
Expand All @@ -10,9 +8,6 @@
from .utils import BaseStorageTestCase


pytestmark = pytest.mark.django_db


class AlternativeResolutionsTest(BaseStorageTestCase):
name = 'retina.jpg'

Expand Down
4 changes: 0 additions & 4 deletions tests/thumbnail_tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import unittest
from PIL import Image

import pytest
from django.test import TestCase
from django.test.utils import override_settings

Expand All @@ -19,9 +18,6 @@
from .models import Item


pytestmark = pytest.mark.django_db


class BackendTest(BaseTestCase):
def test_delete(self):
im1 = Item.objects.get(image='100x100.jpg').image
Expand Down
4 changes: 0 additions & 4 deletions tests/thumbnail_tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from io import StringIO
import os

import pytest
from django.core import management

from sorl.thumbnail.conf import settings
from .models import Item
from .utils import BaseTestCase


pytestmark = pytest.mark.django_db


class CommandTests(BaseTestCase):
def make_test_thumbnails(self, *sizes):
item = Item.objects.get(image='500x500.jpg')
Expand Down
4 changes: 0 additions & 4 deletions tests/thumbnail_tests/test_engines.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import unittest
from subprocess import Popen, PIPE

import pytest
from PIL import Image
from django.core.files.storage import default_storage
from django.template.loader import render_to_string
Expand All @@ -20,9 +19,6 @@
from .utils import BaseTestCase


pytestmark = pytest.mark.django_db


class SimpleTestCase(BaseTestCase):
def test_simple(self):
item = Item.objects.get(image='500x500.jpg')
Expand Down
4 changes: 0 additions & 4 deletions tests/thumbnail_tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
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):
text = '<img alt="A image!" src="https://dummyimage.com/800x800" />'
Expand Down
4 changes: 0 additions & 4 deletions tests/thumbnail_tests/test_storage.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import unittest
import pytest

from sorl.thumbnail import get_thumbnail, default
from sorl.thumbnail.helpers import get_module_class

from .utils import BaseStorageTestCase


pytestmark = pytest.mark.django_db


class StorageTestCase(BaseStorageTestCase):
name = 'org.jpg'

Expand Down
4 changes: 0 additions & 4 deletions tests/thumbnail_tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
from django.template.loader import render_to_string
from django.test import Client, TestCase
from django.test.utils import override_settings
import pytest

from sorl.thumbnail.conf import settings
from sorl.thumbnail.engines.pil_engine import Engine as PILEngine
from .models import Item
from .utils import BaseTestCase, DATA_DIR


pytestmark = pytest.mark.django_db


class TemplateTestCaseA(BaseTestCase):
def test_model(self):
item = Item.objects.get(image='500x500.jpg')
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ envlist =

[testenv]
deps =
pytest
pytest-cov
pytest-django
coverage
pillow
redis: redis
dynamodb: boto
Expand All @@ -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
Expand Down

0 comments on commit 91cbd91

Please sign in to comment.