From 8ad7b8118c99ef53fb055596b59388f9b8c3bc0b Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 24 Feb 2016 11:22:09 -0500 Subject: [PATCH] Used addCleanup() to call recorder.flush() in migration loader tests. --- tests/migrations/test_loader.py | 8 +++----- 1 file 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()