File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change
1
+ try :
2
+ # Django 1.11
3
+ from django .test .utils import setup_databases , teardown_databases # noqa
4
+ except ImportError :
5
+ # In Django prior to 1.11, teardown_databases is only available as a method on DiscoverRunner
6
+ from django .test .runner import setup_databases , DiscoverRunner as _DiscoverRunner # noqa
7
+
8
+ def teardown_databases (db_cfg , verbosity ):
9
+ (_DiscoverRunner (verbosity = verbosity ,
10
+ interactive = False )
11
+ .teardown_databases (db_cfg ))
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ def django_db_setup(
72
72
django_db_modify_db_settings ,
73
73
):
74
74
"""Top level fixture to ensure test databases are available"""
75
- from django . test . runner import setup_databases , DiscoverRunner
75
+ from . compat import setup_databases , teardown_databases
76
76
77
77
setup_databases_args = {}
78
78
@@ -98,9 +98,10 @@ def django_db_setup(
98
98
99
99
def teardown_database ():
100
100
with django_db_blocker :
101
- (DiscoverRunner (verbosity = pytest .config .option .verbose ,
102
- interactive = False )
103
- .teardown_databases (db_cfg ))
101
+ teardown_databases (
102
+ db_cfg ,
103
+ verbosity = pytest .config .option .verbose ,
104
+ )
104
105
105
106
if not django_db_keepdb :
106
107
request .addfinalizer (teardown_database )
You can’t perform that action at this time.
0 commit comments