From a308d0ae11049a1353f0a783291fcd340d6fae34 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 30 Dec 2025 21:55:55 +0000 Subject: [PATCH] Fix `PytestCollectionWarning` for `TestRunner` class Fix this warning seen in the pytest output: ``` pytest_django/runner.py:6 /.../pytest-django/pytest_django/runner.py:6: PytestCollectionWarning: cannot collect test class 'TestRunner' because it has a __init__ constructor (from: tests/test_runner.py) class TestRunner: ``` The fix uses [`__test__ = False`](https://docs.pytest.org/en/stable/example/pythoncollection.html#:~:text=boolean%20%5F%5Ftest%5F%5F%20attribute) to flag the class as non-test. --- pytest_django/runner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytest_django/runner.py b/pytest_django/runner.py index c040b749..50ee8996 100644 --- a/pytest_django/runner.py +++ b/pytest_django/runner.py @@ -6,6 +6,8 @@ class TestRunner: """A Django test runner which uses pytest to discover and run tests when using `manage.py test`.""" + __test__ = False + def __init__( self, *,