Skip to content

Commit

Permalink
Checks for tags on any SimpleTestCase not just TransactionTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech committed Nov 7, 2023
1 parent 9047da6 commit c5eeb37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ def pytest_report_header(config: pytest.Config) -> list[str] | None:


# Convert Django test tags on test classes to pytest marks.
# Unlike the Django test runner, we only check tags on Django
# test classes, to keep the plugin's effect contained.
def pytest_collectstart(collector: pytest.Collector) -> None:
if "django" not in sys.modules:
return
Expand All @@ -389,9 +391,9 @@ def pytest_collectstart(collector: pytest.Collector) -> None:
if not tags:
return

from django.test import TransactionTestCase
from django.test import SimpleTestCase

if not issubclass(collector.obj, TransactionTestCase):
if not issubclass(collector.obj, SimpleTestCase):
return

for tag in tags:
Expand All @@ -410,9 +412,9 @@ def pytest_itemcollected(item: pytest.Item) -> None:
if not tags:
return

from django.test import TransactionTestCase
from django.test import SimpleTestCase

if not issubclass(item.cls, TransactionTestCase):
if not issubclass(item.cls, SimpleTestCase):
return

for tag in tags:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_unittest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from django.test import TestCase, tag
from django.test import SimpleTestCase, TestCase, tag

from .helpers import DjangoPytester

Expand Down Expand Up @@ -58,7 +58,7 @@ def tearDown(self) -> None:


@tag("tag1", "tag2")
class TestDjangoTagsToPytestMarkers(TestCase):
class TestDjangoTagsToPytestMarkers(SimpleTestCase):
"""Django test tags are converted to Pytest markers, at the class & method
levels."""

Expand Down

0 comments on commit c5eeb37

Please sign in to comment.