Skip to content

Commit 207e070

Browse files
committed
Fix the order of the test cases that use the live_server fixture
The `live_server` fixture requires `transactional_db`, but it does so at runtime, i.e., after the `pytest_collection_modifyitems()` hook is called.
1 parent 0a8473e commit 207e070

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pytest_django/plugin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ def get_order_number(test: pytest.Item) -> int:
463463
uses_db = False
464464
transactional = False
465465
fixtures = getattr(test, "fixturenames", [])
466-
transactional = transactional or "transactional_db" in fixtures
466+
transactional = transactional or (
467+
"transactional_db" in fixtures or "live_server" in fixtures
468+
)
467469
uses_db = uses_db or "db" in fixtures
468470

469471
if transactional:

tests/test_db_setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def test_run_second_decorator():
5454
def test_run_second_fixture(transactional_db):
5555
pass
5656
57+
def test_run_second_live_server_fixture(live_server):
58+
pass
59+
5760
def test_run_second_reset_sequences_fixture(django_db_reset_sequences):
5861
pass
5962
@@ -107,6 +110,7 @@ def test_run_last_test_case(self):
107110
"*test_run_first_serialized_rollback_decorator*",
108111
"*test_run_second_decorator*",
109112
"*test_run_second_fixture*",
113+
"*test_run_second_live_server_fixture*",
110114
"*test_run_second_reset_sequences_fixture*",
111115
"*test_run_second_transaction_test_case*",
112116
"*test_run_second_fixture_class*",

0 commit comments

Comments
 (0)