File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ def teardown_database():
99
99
verbosity = pytest .config .option .verbose ,
100
100
)
101
101
102
- if not django_db_keepdb :
102
+ if not request . config . getvalue ( 'reuse_db' ) :
103
103
request .addfinalizer (teardown_database )
104
104
105
105
Original file line number Diff line number Diff line change @@ -20,6 +20,27 @@ def test_db_can_be_accessed():
20
20
21
21
result = django_testdir .runpytest_subprocess ('-v' , '--reuse-db' )
22
22
assert result .ret == 0
23
+ assert db_exists ()
24
+ result .stdout .fnmatch_lines ([
25
+ "*test_db_can_be_accessed PASSED*" ,
26
+ ])
27
+
28
+
29
+ def test_db_reuse_create_simple (django_testdir ):
30
+ "A test for all backends to check that `--reuse-db` with `--create-db` works."
31
+ django_testdir .create_test_module ('''
32
+ import pytest
33
+
34
+ from .app.models import Item
35
+
36
+ @pytest.mark.django_db
37
+ def test_db_can_be_accessed():
38
+ assert Item.objects.count() == 0
39
+ ''' )
40
+
41
+ result = django_testdir .runpytest_subprocess ('-v' , '--reuse-db' , '--create-db' )
42
+ assert result .ret == 0
43
+ assert db_exists ()
23
44
result .stdout .fnmatch_lines ([
24
45
"*test_db_can_be_accessed PASSED*" ,
25
46
])
You can’t perform that action at this time.
0 commit comments