mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases.
This commit is contained in:
parent
647be06538
commit
8c775391b7
27 changed files with 391 additions and 109 deletions
|
@ -1,7 +1,7 @@
|
|||
from django.db import IntegrityError, transaction
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
||||
from .models import PossessedCar
|
||||
from .models import Car, PossessedCar
|
||||
|
||||
|
||||
class TestTestCase(TestCase):
|
||||
|
@ -18,3 +18,12 @@ class TestTestCase(TestCase):
|
|||
car.delete()
|
||||
finally:
|
||||
self._rollback_atomics = rollback_atomics
|
||||
|
||||
def test_disallowed_database_queries(self):
|
||||
message = (
|
||||
"Database queries to 'other' are not allowed in this test. "
|
||||
"Add 'other' to test_utils.test_testcase.TestTestCase.databases to "
|
||||
"ensure proper test isolation and silence this failure."
|
||||
)
|
||||
with self.assertRaisesMessage(AssertionError, message):
|
||||
Car.objects.using('other').get()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue