From 9136ceb6fb8225625631671147ff70c1fcfbbcdc Mon Sep 17 00:00:00 2001 From: wrwrwr Date: Sat, 29 Nov 2014 18:09:40 +0100 Subject: Replaced router.routers usage with override_settings(DATABASE_ROUTERS); refs #23933. --- tests/contenttypes_tests/tests.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'tests/contenttypes_tests') diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py index a21d783008..0e33f40c5c 100644 --- a/tests/contenttypes_tests/tests.py +++ b/tests/contenttypes_tests/tests.py @@ -8,9 +8,9 @@ from django.contrib.contenttypes.fields import ( from django.contrib.contenttypes import management from django.contrib.contenttypes.models import ContentType from django.core import checks -from django.db import connections, models, router -from django.test import TestCase -from django.test.utils import captured_stdout, override_settings +from django.db import connections, models +from django.test import TestCase, override_settings +from django.test.utils import captured_stdout from django.utils.encoding import force_str from .models import Author, Article, SchemeIncludedURL @@ -397,12 +397,10 @@ class TestRouter(object): return 'default' +@override_settings(DATABASE_ROUTERS=[TestRouter()]) class ContentTypesMultidbTestCase(TestCase): def setUp(self): - self.old_routers = router.routers - router.routers = [TestRouter()] - # Whenever a test starts executing, only the "default" database is # connected. We explicitly connect to the "other" database here. If we # don't do it, then it will be implicitly connected later when we query @@ -411,9 +409,6 @@ class ContentTypesMultidbTestCase(TestCase): # "SET SQL_AUTO_IS_NULL = 0"), which will affect assertNumQueries(). connections['other'].ensure_connection() - def tearDown(self): - router.routers = self.old_routers - def test_multidb(self): """ Test that, when using multiple databases, we use the db_for_read (see -- cgit v1.3