File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -417,7 +417,20 @@ def pytest_runtest_setup(item):
417
417
418
418
@pytest .hookimpl (tryfirst = True )
419
419
def pytest_collection_modifyitems (items ):
420
+ order_django_test_classes = False
421
+ if django_settings_is_configured ():
422
+ _setup_django ()
423
+ from django .test import TestCase , TransactionTestCase
424
+ order_django_test_classes = True
425
+
420
426
def get_order_number (test ):
427
+ if order_django_test_classes and hasattr (test , "cls" ) and test .cls :
428
+ # Beware, TestCase is a subclass of TransactionTestCase
429
+ if issubclass (test .cls , TestCase ):
430
+ return 0
431
+ if issubclass (test .cls , TransactionTestCase ):
432
+ return 1
433
+
421
434
marker_db = test .get_closest_marker ('django_db' )
422
435
if marker_db :
423
436
transaction = validate_django_db (marker_db )[0 ]
You can’t perform that action at this time.
0 commit comments