diff options
| author | Simon Charette <charette.s@gmail.com> | 2018-07-12 00:12:20 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-01-10 19:11:21 -0500 |
| commit | 8c775391b78b2a4a2b57c5e89ed4888f36aada4b (patch) | |
| tree | 3daeb3ef031be73079bd56e7c83f0f8f974d8f60 /tests/test_utils/test_testcase.py | |
| parent | 647be06538474078ac79c1338f02f5d9bc56a79b (diff) | |
Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases.
Diffstat (limited to 'tests/test_utils/test_testcase.py')
| -rw-r--r-- | tests/test_utils/test_testcase.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/test_utils/test_testcase.py b/tests/test_utils/test_testcase.py index 8a367391cb..f374549400 100644 --- a/tests/test_utils/test_testcase.py +++ b/tests/test_utils/test_testcase.py @@ -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() |
