mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
[2.2.x] Made test table cleanup in OperationTestBase more robust.
Some non-unique constraint names were added inb69f8eb04cwhich resulted in failures depending on the order in which tests were run. Backport of62b8596616from master.
This commit is contained in:
committed by
Tim Graham
parent
d3b4f4b962
commit
2ca200a7c3
@@ -122,13 +122,16 @@ class MultiDBOperationTests(OperationTestBase):
|
||||
self.assertEqual(Pony.objects.count(), 0)
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()])
|
||||
def test_run_sql(self):
|
||||
def test_run_sql_migrate_nothing_router(self):
|
||||
self._test_run_sql("test_mltdb_runsql", should_run=False)
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()])
|
||||
def test_run_sql2(self):
|
||||
def test_run_sql_migrate_foo_router_without_hints(self):
|
||||
self._test_run_sql("test_mltdb_runsql2", should_run=False)
|
||||
self._test_run_sql("test_mltdb_runsql2", should_run=True, hints={'foo': True})
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()])
|
||||
def test_run_sql_migrate_foo_router_with_hints(self):
|
||||
self._test_run_sql('test_mltdb_runsql3', should_run=True, hints={'foo': True})
|
||||
|
||||
def _test_run_python(self, app_label, should_run, hints=None):
|
||||
with override_settings(DATABASE_ROUTERS=[MigrateEverythingRouter()]):
|
||||
@@ -156,10 +159,13 @@ class MultiDBOperationTests(OperationTestBase):
|
||||
self.assertEqual(Pony.objects.count(), 0)
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[MigrateNothingRouter()])
|
||||
def test_run_python(self):
|
||||
def test_run_python_migrate_nothing_router(self):
|
||||
self._test_run_python("test_mltdb_runpython", should_run=False)
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()])
|
||||
def test_run_python2(self):
|
||||
def test_run_python_migrate_foo_router_without_hints(self):
|
||||
self._test_run_python("test_mltdb_runpython2", should_run=False)
|
||||
self._test_run_python("test_mltdb_runpython2", should_run=True, hints={'foo': True})
|
||||
|
||||
@override_settings(DATABASE_ROUTERS=[MigrateWhenFooRouter()])
|
||||
def test_run_python_migrate_foo_router_with_hints(self):
|
||||
self._test_run_python('test_mltdb_runpython3', should_run=True, hints={'foo': True})
|
||||
|
||||
Reference in New Issue
Block a user