diff options
| author | wrwrwr <git@wr.waw.pl> | 2014-11-29 18:09:40 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-01 11:34:15 -0500 |
| commit | 9136ceb6fb8225625631671147ff70c1fcfbbcdc (patch) | |
| tree | fe846d89151c87b7474fbe2ef8cdedcde578dba4 /tests/select_for_update/tests.py | |
| parent | e6f19ec3223ba7c398aea515c5e0f8b93e6f4359 (diff) | |
Replaced router.routers usage with override_settings(DATABASE_ROUTERS); refs #23933.
Diffstat (limited to 'tests/select_for_update/tests.py')
| -rw-r--r-- | tests/select_for_update/tests.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index a0bd206923..d3f71ab65c 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -6,9 +6,10 @@ import unittest from django.conf import settings from django.db import transaction, connection, router from django.db.utils import ConnectionHandler, DEFAULT_DB_ALIAS, DatabaseError -from django.test import (TransactionTestCase, skipIfDBFeature, - skipUnlessDBFeature) -from django.test import override_settings +from django.test import ( + TransactionTestCase, override_settings, skipIfDBFeature, + skipUnlessDBFeature, +) from multiple_database.routers import TestRouter @@ -257,14 +258,10 @@ class SelectForUpdateTests(TransactionTestCase): self.assertIsInstance(status[-1], DatabaseError) @skipUnlessDBFeature('has_select_for_update') + @override_settings(DATABASE_ROUTERS=[TestRouter()]) def test_select_for_update_on_multidb(self): - old_routers = router.routers - try: - router.routers = [TestRouter()] - query = Person.objects.select_for_update() - self.assertEqual(router.db_for_write(Person), query.db) - finally: - router.routers = old_routers + query = Person.objects.select_for_update() + self.assertEqual(router.db_for_write(Person), query.db) @skipUnlessDBFeature('has_select_for_update') def test_select_for_update_with_get(self): |
