@@ -11,15 +11,15 @@ def test_database_exists_from_previous_run(connection):
11
11
12
12
# When using a real SQLite backend (via TEST_NAME), check if the file
13
13
# exists, because it gets created automatically.
14
- if connection .settings_dict [' ENGINE' ] == ' django.db.backends.sqlite3' :
14
+ if connection .settings_dict [" ENGINE" ] == " django.db.backends.sqlite3" :
15
15
if not os .path .exists (test_db_name ):
16
16
return False
17
17
18
- orig_db_name = connection .settings_dict [' NAME' ]
19
- connection .settings_dict [' NAME' ] = test_db_name
18
+ orig_db_name = connection .settings_dict [" NAME" ]
19
+ connection .settings_dict [" NAME" ] = test_db_name
20
20
21
21
# With SQLite memory databases the db never exists.
22
- if connection .settings_dict [' NAME' ] == ' :memory:' :
22
+ if connection .settings_dict [" NAME" ] == " :memory:" :
23
23
return False
24
24
25
25
try :
@@ -29,7 +29,7 @@ def test_database_exists_from_previous_run(connection):
29
29
return False
30
30
finally :
31
31
connection .close ()
32
- connection .settings_dict [' NAME' ] = orig_db_name
32
+ connection .settings_dict [" NAME" ] = orig_db_name
33
33
34
34
35
35
def _monkeypatch (obj , method_name , new_method ):
@@ -43,8 +43,9 @@ def _monkeypatch(obj, method_name, new_method):
43
43
setattr (obj , method_name , wrapped_method )
44
44
45
45
46
- def create_test_db_with_reuse (self , verbosity = 1 , autoclobber = False ,
47
- keepdb = False , serialize = False ):
46
+ def create_test_db_with_reuse (
47
+ self , verbosity = 1 , autoclobber = False , keepdb = False , serialize = False
48
+ ):
48
49
"""
49
50
This method is a monkey patched version of create_test_db that
50
51
will not actually create a new database, but just reuse the
@@ -53,14 +54,16 @@ def create_test_db_with_reuse(self, verbosity=1, autoclobber=False,
53
54
This is only used with Django < 1.8.
54
55
"""
55
56
test_database_name = self ._get_test_db_name ()
56
- self .connection .settings_dict [' NAME' ] = test_database_name
57
+ self .connection .settings_dict [" NAME" ] = test_database_name
57
58
58
59
if verbosity >= 1 :
59
- test_db_repr = ''
60
+ test_db_repr = ""
60
61
if verbosity >= 2 :
61
62
test_db_repr = " ('%s')" % test_database_name
62
- print ("Re-using existing test database for alias '%s'%s..." % (
63
- self .connection .alias , test_db_repr ))
63
+ print (
64
+ "Re-using existing test database for alias '%s'%s..."
65
+ % (self .connection .alias , test_db_repr )
66
+ )
64
67
65
68
return test_database_name
66
69
@@ -70,5 +73,6 @@ def monkey_patch_creation_for_db_reuse():
70
73
71
74
for connection in connections .all ():
72
75
if test_database_exists_from_previous_run (connection ):
73
- _monkeypatch (connection .creation , 'create_test_db' ,
74
- create_test_db_with_reuse )
76
+ _monkeypatch (
77
+ connection .creation , "create_test_db" , create_test_db_with_reuse
78
+ )
0 commit comments