Skip to content

Better handling of south migrations for newer versions of south. #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,22 @@ def pytest_addoption(parser):
'option will be ignored if not --reuse-db is given.')


def _disable_south_management_command():
management.get_commands()
# make sure `south` migrations are disabled
management._commands['syncdb'] = 'django.core'
def _handle_south_management_command():
try:
# if `south` >= 0.7.1 we can use the test helper
from south.management.commands import patch_for_test_db_setup
except ImportError:
# if `south` < 0.7.1 make sure it's migrations are disabled
management.get_commands()
management._commands['syncdb'] = 'django.core'
else:
patch_for_test_db_setup()


def pytest_sessionstart(session):
global suite_runner, old_db_config

_disable_south_management_command()
_handle_south_management_command()

suite_runner = get_runner(session.config)
suite_runner.setup_test_environment()
Expand Down