Skip to content

Commit 90d40b2

Browse files
committed
minor progress
1 parent 4917b34 commit 90d40b2

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pytest_django/fixtures.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
"django_username_field",
6161
"live_server",
6262
"rf",
63+
"django_testcase",
64+
"django_testcase_class",
6365
"settings",
6466
"transactional_db",
6567
]
@@ -216,7 +218,7 @@ def django_db_setup(
216218

217219

218220
@pytest.fixture()
219-
def pytest_django_testcase_class(
221+
def django_testcase_class(
220222
request: pytest.FixtureRequest,
221223
):
222224
if is_django_unittest(request):
@@ -294,24 +296,22 @@ def setUpClass(cls) -> None:
294296
def tearDownClass(cls) -> None:
295297
super(django.test.TestCase, cls).tearDownClass()
296298

297-
return PytestDjangoTestCase
299+
yield PytestDjangoTestCase
298300

299301

300302
@pytest.fixture()
301303
def _django_db_helper(
302304
request: pytest.FixtureRequest,
303305
django_db_setup: None,
304306
django_db_blocker: DjangoDbBlocker,
305-
pytest_django_testcase_class,
307+
django_testcase_class,
306308
) -> Generator[None, None, None]:
307309
if is_django_unittest(request):
308310
yield
309311
return
310312

311313
with django_db_blocker.unblock():
312-
import django.db
313-
314-
PytestDjangoTestCase = pytest_django_testcase_class
314+
PytestDjangoTestCase = django_testcase_class
315315

316316
PytestDjangoTestCase.setUpClass()
317317

@@ -395,7 +395,7 @@ def _set_suffix_to_test_databases(suffix: str) -> None:
395395

396396

397397
@pytest.fixture()
398-
def pytest_django_testcase(_django_db_helper: None) -> None:
398+
def django_testcase(_django_db_helper: None) -> None:
399399
yield _django_db_helper
400400

401401

pytest_django/plugin.py

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
django_username_field, # noqa: F401
4545
live_server, # noqa: F401
4646
rf, # noqa: F401
47+
django_testcase, # noqa: F401
48+
django_testcase_class, # noqa: F401
4749
settings, # noqa: F401
4850
transactional_db, # noqa: F401
4951
validate_django_db,

0 commit comments

Comments
 (0)