Skip to content
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

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

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions pytest_django/plugin.py
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