@@ -45,6 +45,16 @@ def __init__(self, address, port):
45
45
self .error = None
46
46
super (ThreadedTestServerThread , self ).__init__ ()
47
47
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
+
48
58
def run (self ):
49
59
"""Sets up test server and database and loops over handling http requests."""
50
60
# AdminMediaHandler was removed in Django 1.5; use it only when available.
@@ -70,14 +80,10 @@ def __init__(self, *args, **kwargs):
70
80
self .started .set ()
71
81
return
72
82
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 })
81
87
82
88
# Loop until we get a stop event.
83
89
while not self ._stopevent .isSet ():
0 commit comments