@@ -29,9 +29,11 @@ def test_db_order(django_testdir) -> None:
29
29
"""Test order in which tests are being executed."""
30
30
31
31
django_testdir .create_test_module ('''
32
- from unittest import TestCase
33
32
import pytest
34
- from django.test import SimpleTestCase, TestCase as DjangoTestCase, TransactionTestCase
33
+ from unittest import TestCase
34
+ from django.test import SimpleTestCase
35
+ from django.test import TestCase as DjangoTestCase
36
+ from django.test import TransactionTestCase
35
37
36
38
from .app.models import Item
37
39
@@ -45,13 +47,32 @@ def test_run_second_fixture(transactional_db):
45
47
def test_run_second_reset_sequences_fixture(django_db_reset_sequences):
46
48
pass
47
49
50
+ class MyTransactionTestCase(TransactionTestCase):
51
+ def test_run_second_transaction_test_case(self):
52
+ pass
53
+
48
54
def test_run_first_fixture(db):
49
55
pass
50
56
57
+ class TestClass:
58
+ def test_run_second_fixture_class(self, transactional_db):
59
+ pass
60
+
61
+ def test_run_first_fixture_class(self, db):
62
+ pass
63
+
51
64
@pytest.mark.django_db(reset_sequences=True)
52
65
def test_run_second_reset_sequences_decorator():
53
66
pass
54
67
68
+ class MyDjangoTestCase(DjangoTestCase):
69
+ def test_run_first_django_test_case(self):
70
+ pass
71
+
72
+ class MySimpleTestCase(SimpleTestCase):
73
+ def test_run_last_simple_test_case(self):
74
+ pass
75
+
55
76
@pytest.mark.django_db
56
77
def test_run_first_decorator():
57
78
pass
@@ -63,34 +84,24 @@ def test_run_first_serialized_rollback_decorator():
63
84
class MyTestCase(TestCase):
64
85
def test_run_last_test_case(self):
65
86
pass
66
-
67
- class MySimpleTestCase(SimpleTestCase):
68
- def test_run_last_simple_test_case(self):
69
- pass
70
-
71
- class MyDjangoTestCase(DjangoTestCase):
72
- def test_run_first_django_test_case(self):
73
- pass
74
-
75
- class MyTransactionTestCase(TransactionTestCase):
76
- def test_run_second_transaction_test_case(self):
77
- pass
78
87
''' )
79
88
result = django_testdir .runpytest_subprocess ('-q' , '--collect-only' )
80
89
assert result .ret == 0
81
90
result .stdout .fnmatch_lines ([
82
91
"*test_run_first_fixture*" ,
92
+ "*test_run_first_fixture_class*" ,
93
+ "*test_run_first_django_test_case*" ,
83
94
"*test_run_first_decorator*" ,
84
95
"*test_run_first_serialized_rollback_decorator*" ,
85
- "*test_run_first_django_test_case*" ,
86
96
"*test_run_second_decorator*" ,
87
97
"*test_run_second_fixture*" ,
88
98
"*test_run_second_reset_sequences_fixture*" ,
89
- "*test_run_second_reset_sequences_decorator*" ,
90
99
"*test_run_second_transaction_test_case*" ,
91
- "*test_run_last_test_case*" ,
100
+ "*test_run_second_fixture_class*" ,
101
+ "*test_run_second_reset_sequences_decorator*" ,
92
102
"*test_run_last_simple_test_case*" ,
93
- ])
103
+ "*test_run_last_test_case*" ,
104
+ ], consecutive = True )
94
105
95
106
96
107
def test_db_reuse (django_testdir ) -> None :
0 commit comments