File tree 4 files changed +20
-3
lines changed 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,16 @@ command line options.
229
229
230
230
This fixture is by default requested from :fixture: `django_db_setup `.
231
231
232
+ django_db_createdb
233
+ """"""""""""""""""
234
+
235
+ .. fixture :: django_db_createdb
236
+
237
+ Returns whether or not the database is to be re-created before running any
238
+ tests.
239
+
240
+ This fixture is by default requested from :fixture: `django_db_setup `.
241
+
232
242
django_db_blocker
233
243
"""""""""""""""""
234
244
Original file line number Diff line number Diff line change @@ -61,8 +61,12 @@ def django_db_use_migrations(request):
61
61
62
62
@pytest .fixture (scope = 'session' )
63
63
def django_db_keepdb (request ):
64
- return (request .config .getvalue ('reuse_db' ) and not
65
- request .config .getvalue ('create_db' ))
64
+ return request .config .getvalue ('reuse_db' )
65
+
66
+
67
+ @pytest .fixture (scope = 'session' )
68
+ def django_db_createdb (request ):
69
+ return request .config .getvalue ('create_db' )
66
70
67
71
68
72
@pytest .fixture (scope = 'session' )
@@ -72,6 +76,7 @@ def django_db_setup(
72
76
django_db_blocker ,
73
77
django_db_use_migrations ,
74
78
django_db_keepdb ,
79
+ django_db_createdb ,
75
80
django_db_modify_db_settings ,
76
81
):
77
82
"""Top level fixture to ensure test databases are available"""
@@ -82,7 +87,7 @@ def django_db_setup(
82
87
if not django_db_use_migrations :
83
88
_disable_native_migrations ()
84
89
85
- if django_db_keepdb :
90
+ if django_db_keepdb and not django_db_createdb :
86
91
setup_databases_args ['keepdb' ] = True
87
92
88
93
with django_db_blocker .unblock ():
Original file line number Diff line number Diff line change 19
19
from .fixtures import django_db_setup # noqa
20
20
from .fixtures import django_db_use_migrations # noqa
21
21
from .fixtures import django_db_keepdb # noqa
22
+ from .fixtures import django_db_createdb # noqa
22
23
from .fixtures import django_db_modify_db_settings # noqa
23
24
from .fixtures import django_db_modify_db_settings_xdist_suffix # noqa
24
25
from .fixtures import _live_server_helper # noqa
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ def test_db_can_be_accessed():
75
75
])
76
76
77
77
# Make sure the database has been re-created and the mark is gone
78
+ assert db_exists ()
78
79
assert not mark_exists ()
79
80
80
81
You can’t perform that action at this time.
0 commit comments