Skip to content

Commit 9df4d2e

Browse files
committed
inline/optimize
1 parent 5f3e832 commit 9df4d2e

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

pytest_django/plugin.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -426,24 +426,23 @@ def pytest_runtest_setup(item):
426426

427427

428428
def pytest_collection_modifyitems(session, config, items):
429-
def get_marker_transaction(test):
430-
marker = test.get_closest_marker('django_db')
431-
if marker:
432-
return validate_django_db(marker)[0]
433-
return None
429+
def get_order_number(test):
430+
marker_db = test.get_closest_marker('django_db')
431+
if marker_db:
432+
transaction = validate_django_db(marker_db)[0]
434433

435-
def has_fixture(test, fixture):
436-
return fixture in getattr(test, 'funcargnames', [])
434+
if transaction is True:
435+
return 1
436+
else:
437+
transaction = None
437438

438-
def get_order_number(test):
439-
if get_marker_transaction(test) is True:
440-
return 1
441-
if has_fixture(test, "transactional_db"):
439+
fixtures = getattr(test, 'funcargnames', [])
440+
if "transactional_db" in fixtures:
442441
return 1
443442

444-
if get_marker_transaction(test) is False:
443+
if transaction is False:
445444
return 0
446-
if has_fixture(test, "db"):
445+
if "db" in fixtures:
447446
return 0
448447

449448
return 2

0 commit comments

Comments
 (0)