Used addCleanup() to call recorder.flush() in migration loader tests.
This commit is contained in:
parent
c5517b9e74
commit
8ad7b8118c
|
@ -207,6 +207,7 @@ class LoaderTests(TestCase):
|
||||||
"Tests loading a squashed migration"
|
"Tests loading a squashed migration"
|
||||||
migration_loader = MigrationLoader(connection)
|
migration_loader = MigrationLoader(connection)
|
||||||
recorder = MigrationRecorder(connection)
|
recorder = MigrationRecorder(connection)
|
||||||
|
self.addCleanup(recorder.flush)
|
||||||
# Loading with nothing applied should just give us the one node
|
# Loading with nothing applied should just give us the one node
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len([x for x in migration_loader.graph.nodes if x[0] == "migrations"]),
|
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"]),
|
len([x for x in migration_loader.graph.nodes if x[0] == "migrations"]),
|
||||||
2,
|
2,
|
||||||
)
|
)
|
||||||
recorder.flush()
|
|
||||||
|
|
||||||
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed_complex"})
|
@override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_squashed_complex"})
|
||||||
def test_loading_squashed_complex(self):
|
def test_loading_squashed_complex(self):
|
||||||
|
@ -227,6 +227,7 @@ class LoaderTests(TestCase):
|
||||||
|
|
||||||
loader = MigrationLoader(connection)
|
loader = MigrationLoader(connection)
|
||||||
recorder = MigrationRecorder(connection)
|
recorder = MigrationRecorder(connection)
|
||||||
|
self.addCleanup(recorder.flush)
|
||||||
|
|
||||||
def num_nodes():
|
def num_nodes():
|
||||||
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
|
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
|
||||||
|
@ -267,8 +268,6 @@ class LoaderTests(TestCase):
|
||||||
loader.build_graph()
|
loader.build_graph()
|
||||||
self.assertEqual(num_nodes(), 0)
|
self.assertEqual(num_nodes(), 0)
|
||||||
|
|
||||||
recorder.flush()
|
|
||||||
|
|
||||||
@override_settings(MIGRATION_MODULES={
|
@override_settings(MIGRATION_MODULES={
|
||||||
"app1": "migrations.test_migrations_squashed_complex_multi_apps.app1",
|
"app1": "migrations.test_migrations_squashed_complex_multi_apps.app1",
|
||||||
"app2": "migrations.test_migrations_squashed_complex_multi_apps.app2",
|
"app2": "migrations.test_migrations_squashed_complex_multi_apps.app2",
|
||||||
|
@ -321,6 +320,7 @@ class LoaderTests(TestCase):
|
||||||
|
|
||||||
loader = MigrationLoader(connection)
|
loader = MigrationLoader(connection)
|
||||||
recorder = MigrationRecorder(connection)
|
recorder = MigrationRecorder(connection)
|
||||||
|
self.addCleanup(recorder.flush)
|
||||||
|
|
||||||
def num_nodes():
|
def num_nodes():
|
||||||
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
|
plan = set(loader.graph.forwards_plan(('migrations', '7_auto')))
|
||||||
|
@ -365,5 +365,3 @@ class LoaderTests(TestCase):
|
||||||
recorder.record_applied("migrations", "7_auto")
|
recorder.record_applied("migrations", "7_auto")
|
||||||
loader.build_graph()
|
loader.build_graph()
|
||||||
self.assertEqual(num_nodes(), 0)
|
self.assertEqual(num_nodes(), 0)
|
||||||
|
|
||||||
recorder.flush()
|
|
||||||
|
|
Loading…
Reference in New Issue