Used addCleanup() to call recorder.flush() in migration loader tests.

This commit is contained in:
Tim Graham 2016-02-24 11:22:09 -05:00
parent c5517b9e74
commit 8ad7b8118c
1 changed files with 3 additions and 5 deletions

View File

@ -207,6 +207,7 @@ class LoaderTests(TestCase):
"Tests loading a squashed migration"
migration_loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
self.addCleanup(recorder.flush)
# Loading with nothing applied should just give us the one node
self.assertEqual(
len([x for x in migration_loader.graph.nodes if x[0] == "migrations"]),
@ -219,7 +220,6 @@ class LoaderTests(TestCase):
len([x for x in migration_loader.graph.nodes if x[0] == "migrations"]),
2,
)
recorder.flush()
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed_complex"})
def test_loading_squashed_complex(self):
@ -227,6 +227,7 @@ class LoaderTests(TestCase):
loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
self.addCleanup(recorder.flush)
def num_nodes():
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
@ -267,8 +268,6 @@ class LoaderTests(TestCase):
loader.build_graph()
self.assertEqual(num_nodes(), 0)
recorder.flush()
@override_settings(MIGRATION_MODULES={
"app1": "migrations.test_migrations_squashed_complex_multi_apps.app1",
"app2": "migrations.test_migrations_squashed_complex_multi_apps.app2",
@ -321,6 +320,7 @@ class LoaderTests(TestCase):
loader = MigrationLoader(connection)
recorder = MigrationRecorder(connection)
self.addCleanup(recorder.flush)
def num_nodes():
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
@ -365,5 +365,3 @@ class LoaderTests(TestCase):
recorder.record_applied("migrations", "7_auto")
loader.build_graph()
self.assertEqual(num_nodes(), 0)
recorder.flush()