summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-02-24 11:22:09 -0500
committerTim Graham <timograham@gmail.com>2016-02-24 11:22:09 -0500
commit8ad7b8118c99ef53fb055596b59388f9b8c3bc0b (patch)
tree7303671988609c28c40a0150691b745349f48575
parentc5517b9e7439e542b381a0054bbdab9b5d2bc34b (diff)
Used addCleanup() to call recorder.flush() in migration loader tests.
-rw-r--r--tests/migrations/test_loader.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
index 4e3da7f1a2..ed33604ff4 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -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()