Skip to content

Commit 31ee604

Browse files
committed
lint
1 parent 09eff8d commit 31ee604

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

devserver/testcases.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ def __init__(self, address, port):
4545
self.error = None
4646
super(ThreadedTestServerThread, self).__init__()
4747

48+
def _should_loaddata(self):
49+
# Must do database stuff in this new thread if database in memory.
50+
if not hasattr(self, 'fixtures'):
51+
return False
52+
if settings.DATABASE_ENGINE != 'sqlite3':
53+
return False
54+
if settings.TEST_DATABASE_NAME and settings.TEST_DATABASE_NAME != ':memory:':
55+
return False
56+
return True
57+
4858
def run(self):
4959
"""Sets up test server and database and loops over handling http requests."""
5060
# AdminMediaHandler was removed in Django 1.5; use it only when available.
@@ -70,14 +80,10 @@ def __init__(self, *args, **kwargs):
7080
self.started.set()
7181
return
7282

73-
# Must do database stuff in this new thread if database in memory.
74-
if settings.DATABASE_ENGINE == 'sqlite3' \
75-
and (not settings.TEST_DATABASE_NAME or settings.TEST_DATABASE_NAME == ':memory:'):
76-
# Import the fixture data into the test database.
77-
if hasattr(self, 'fixtures'):
78-
# We have to use this slightly awkward syntax due to the fact
79-
# that we're using *args and **kwargs together.
80-
call_command('loaddata', *self.fixtures, **{'verbosity': 0})
83+
if self._should_loaddata():
84+
# We have to use this slightly awkward syntax due to the fact
85+
# that we're using *args and **kwargs together.
86+
call_command('loaddata', *self.fixtures, **{'verbosity': 0})
8187

8288
# Loop until we get a stop event.
8389
while not self._stopevent.isSet():

0 commit comments

Comments
 (0)