Skip to content

Commit 7aa1ea0

Browse files
committedMay 27, 2018
Store temporary variables on config rather than function
1 parent 182f0ba commit 7aa1ea0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
 

‎pytest_django/fixtures.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,24 @@ def run_checks(request):
115115
from django.core.management import call_command
116116
from django.core.management.base import SystemCheckError
117117

118+
config = request.config
119+
118120
# Only run once per process
119-
if getattr(run_checks, 'ran', False):
121+
if getattr(config, '_pytest_django_checks_ran', False):
120122
return
121-
run_checks.ran = True
123+
config._pytest_django_checks_ran = True
122124

123125
out = StringIO()
124126
try:
125127
call_command('check', stdout=out, stderr=out)
126-
except SystemCheckError as ex:
127-
run_checks.exc = ex
128+
except SystemCheckError as exc:
129+
config._pytest_django_checks_exc = exc
128130

129131
if hasattr(request.config, 'slaveinput'):
130132
# Kill the xdist test process horribly
131133
# N.B. 'shouldstop' may be obeyed properly in the future as hinted at in
132134
# https://github.com/pytest-dev/pytest-xdist/commit/e8fa73719662d1be5074a0750329fe0c35583484
133-
print(ex.args[0])
135+
print(exc.args[0])
134136
sys.exit(1)
135137
else:
136138
# Ensure we get the EXIT_TESTSFAILED exit code

‎pytest_django/plugin.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ def pytest_runtest_setup(item):
331331

332332

333333
def pytest_terminal_summary(terminalreporter, exitstatus):
334-
check_exc = getattr(run_checks, 'exc', None)
334+
config = terminalreporter.config
335+
check_exc = getattr(config, '_pytest_django_checks_exc', None)
335336
if check_exc:
336337
terminalreporter.write('\n')
337338
terminalreporter.write(str(check_exc))

0 commit comments

Comments
 (0)
Please sign in to comment.