Skip to content

Commit 4b76b24

Browse files
committed
Only call Django's migrate command on version 1.7 and up
1 parent 937f179 commit 4b76b24

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pytest_django/db_reuse.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def create_test_db_with_reuse(self, verbosity=1, autoclobber=False,
9696
will not actually create a new database, but just reuse the
9797
existing.
9898
"""
99+
from django import VERSION as DJANGO_VERSION
99100
from django.core.management import call_command
100101

101102
test_database_name = self._get_test_db_name()
@@ -113,13 +114,14 @@ def create_test_db_with_reuse(self, verbosity=1, autoclobber=False,
113114
if hasattr(self.connection.features, 'confirm'):
114115
self.connection.features.confirm()
115116

116-
call_command(
117-
'migrate',
118-
verbosity=max(verbosity - 1, 0),
119-
interactive=False,
120-
database=self.connection.alias,
121-
run_syncdb=True,
122-
)
117+
if DJANGO_VERSION > (1, 7):
118+
call_command(
119+
'migrate',
120+
verbosity=max(verbosity - 1, 0),
121+
interactive=False,
122+
database=self.connection.alias,
123+
run_syncdb=True,
124+
)
123125

124126
return test_database_name
125127

0 commit comments

Comments
 (0)