Skip to content

Commit 44d4dfb

Browse files
committed
tests: add test_south_migrations (without initial data)
1 parent cf75321 commit 44d4dfb

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

pytest_django/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _handle_south():
107107
# if `south` >= 0.7.1 we can use the test helper
108108
from south.management.commands import patch_for_test_db_setup
109109
except ImportError:
110-
# if `south` < 0.7.1 make sure it's migrations are disabled
110+
# if `south` < 0.7.1 make sure its migrations are disabled
111111
management.get_commands()
112112
management._commands['syncdb'] = 'django.core'
113113
else:

tests/test_db_setup.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def test_inner_south():
246246
@pytest.mark.skipif(sys.version_info[0] == 3,
247247
reason='South is not properly supported on Python 3')
248248
class TestSouth:
249-
"""Test interaction with initial_data and South."""
249+
"""Test interaction with South, with and without initial_data."""
250250

251251
@pytest.mark.django_project(extra_settings="""
252252
INSTALLED_APPS += [ 'south', ]
@@ -329,6 +329,36 @@ def test_inner_south():
329329
result.stderr.fnmatch_lines(['*no such table: app_item*'])
330330
result.stdout.fnmatch_lines(['*mark_south_migration_forwards*'])
331331

332+
@pytest.mark.django_project(extra_settings="""
333+
INSTALLED_APPS += [ 'south', ]
334+
SOUTH_TESTS_MIGRATE = True
335+
SOUTH_MIGRATION_MODULES = {
336+
'app': 'tpkg.app.south_migrations',
337+
}
338+
""")
339+
def test_south_migrations(self, django_testdir):
340+
"""South migration with a normal testdir (no initial data)."""
341+
testdir = django_testdir
342+
testdir.create_test_module('''
343+
import pytest
344+
345+
@pytest.mark.django_db
346+
def test_inner_south():
347+
pass
348+
''')
349+
350+
testdir.mkpydir('tpkg/app/south_migrations')
351+
testdir.create_app_file("""
352+
from south.v2 import SchemaMigration
353+
354+
class Migration(SchemaMigration):
355+
def forwards(self, orm):
356+
print("mark_south_migration_forwards")
357+
""", 'south_migrations/0001_initial.py')
358+
result = testdir.runpytest('--tb=short', '-v', '-s')
359+
assert result.ret == 0
360+
result.stdout.fnmatch_lines(['*mark_south_migration_forwards*'])
361+
332362
@pytest.mark.django_project(extra_settings="""
333363
INSTALLED_APPS += [ 'south', ]
334364
SOUTH_TESTS_MIGRATE = False

0 commit comments

Comments
 (0)