|
60 | 60 | "django_username_field",
|
61 | 61 | "live_server",
|
62 | 62 | "rf",
|
| 63 | + "django_testcase", |
| 64 | + "django_testcase_class", |
63 | 65 | "settings",
|
64 | 66 | "transactional_db",
|
65 | 67 | ]
|
@@ -216,7 +218,7 @@ def django_db_setup(
|
216 | 218 |
|
217 | 219 |
|
218 | 220 | @pytest.fixture()
|
219 |
| -def pytest_django_testcase_class( |
| 221 | +def django_testcase_class( |
220 | 222 | request: pytest.FixtureRequest,
|
221 | 223 | ):
|
222 | 224 | if is_django_unittest(request):
|
@@ -294,24 +296,22 @@ def setUpClass(cls) -> None:
|
294 | 296 | def tearDownClass(cls) -> None:
|
295 | 297 | super(django.test.TestCase, cls).tearDownClass()
|
296 | 298 |
|
297 |
| - return PytestDjangoTestCase |
| 299 | + yield PytestDjangoTestCase |
298 | 300 |
|
299 | 301 |
|
300 | 302 | @pytest.fixture()
|
301 | 303 | def _django_db_helper(
|
302 | 304 | request: pytest.FixtureRequest,
|
303 | 305 | django_db_setup: None,
|
304 | 306 | django_db_blocker: DjangoDbBlocker,
|
305 |
| - pytest_django_testcase_class, |
| 307 | + django_testcase_class, |
306 | 308 | ) -> Generator[None, None, None]:
|
307 | 309 | if is_django_unittest(request):
|
308 | 310 | yield
|
309 | 311 | return
|
310 | 312 |
|
311 | 313 | with django_db_blocker.unblock():
|
312 |
| - import django.db |
313 |
| - |
314 |
| - PytestDjangoTestCase = pytest_django_testcase_class |
| 314 | + PytestDjangoTestCase = django_testcase_class |
315 | 315 |
|
316 | 316 | PytestDjangoTestCase.setUpClass()
|
317 | 317 |
|
@@ -395,7 +395,7 @@ def _set_suffix_to_test_databases(suffix: str) -> None:
|
395 | 395 |
|
396 | 396 |
|
397 | 397 | @pytest.fixture()
|
398 |
| -def pytest_django_testcase(_django_db_helper: None) -> None: |
| 398 | +def django_testcase(_django_db_helper: None) -> None: |
399 | 399 | yield _django_db_helper
|
400 | 400 |
|
401 | 401 |
|
|
0 commit comments