diff options
| author | Matthijs Kooijman <matthijs@stdin.nl> | 2019-12-20 20:49:56 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-01-20 14:39:02 +0100 |
| commit | 2a2ea4ee18fdcf2c95bf6435bc63b74623e3085b (patch) | |
| tree | 32c7c87c71535a8493c07e2073f1bfcd1aa7e24d /tests/admin_views | |
| parent | 26be703fe679a58bbdccf37a276a9c430ccb29f7 (diff) | |
Refs #31117 -- Made various tests properly handle unexpected databases aliases.
- Used selected "databases" instead of django.db.connections.
- Made routers in tests.migrations skip migrations on unexpected
databases.
- Added DiscoverRunnerGetDatabasesTests.assertSkippedDatabases() hook
which properly asserts messages about skipped databases.
Diffstat (limited to 'tests/admin_views')
| -rw-r--r-- | tests/admin_views/test_multidb.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/tests/admin_views/test_multidb.py b/tests/admin_views/test_multidb.py index a02b637d34..7ff1f7f663 100644 --- a/tests/admin_views/test_multidb.py +++ b/tests/admin_views/test_multidb.py @@ -2,7 +2,6 @@ from unittest import mock from django.contrib import admin from django.contrib.auth.models import User -from django.db import connections from django.test import TestCase, override_settings from django.urls import path, reverse @@ -34,7 +33,7 @@ class MultiDatabaseTests(TestCase): def setUpTestData(cls): cls.superusers = {} cls.test_book_ids = {} - for db in connections: + for db in cls.databases: Router.target_db = db cls.superusers[db] = User.objects.create_superuser( username='admin', password='something', email='test@test.org', @@ -45,7 +44,7 @@ class MultiDatabaseTests(TestCase): @mock.patch('django.contrib.admin.options.transaction') def test_add_view(self, mock): - for db in connections: + for db in self.databases: with self.subTest(db=db): Router.target_db = db self.client.force_login(self.superusers[db]) @@ -57,7 +56,7 @@ class MultiDatabaseTests(TestCase): @mock.patch('django.contrib.admin.options.transaction') def test_change_view(self, mock): - for db in connections: + for db in self.databases: with self.subTest(db=db): Router.target_db = db self.client.force_login(self.superusers[db]) @@ -69,7 +68,7 @@ class MultiDatabaseTests(TestCase): @mock.patch('django.contrib.admin.options.transaction') def test_delete_view(self, mock): - for db in connections: + for db in self.databases: with self.subTest(db=db): Router.target_db = db self.client.force_login(self.superusers[db]) |
