Skip to content

Fix the order of the test cases that use the live_server fixture #1196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ def get_order_number(test: pytest.Item) -> int:
uses_db = False
transactional = False
fixtures = getattr(test, "fixturenames", [])
transactional = transactional or "transactional_db" in fixtures
transactional = transactional or (
"transactional_db" in fixtures or "live_server" in fixtures
)
uses_db = uses_db or "db" in fixtures

if transactional:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_db_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def test_run_second_decorator():
def test_run_second_fixture(transactional_db):
pass

def test_run_second_live_server_fixture(live_server):
pass

def test_run_second_reset_sequences_fixture(django_db_reset_sequences):
pass

Expand Down Expand Up @@ -107,6 +110,7 @@ def test_run_last_test_case(self):
"*test_run_first_serialized_rollback_decorator*",
"*test_run_second_decorator*",
"*test_run_second_fixture*",
"*test_run_second_live_server_fixture*",
"*test_run_second_reset_sequences_fixture*",
"*test_run_second_transaction_test_case*",
"*test_run_second_fixture_class*",
Expand Down