mirror of
https://github.com/django/django.git
synced 2025-08-30 23:37:50 +00:00
Refs #31395 -- Removed support for assigning objects which don't support deepcopy() in setUpTestData().
Per deprecation timeline.
This commit is contained in:
parent
97237ad3fe
commit
2e10abeb7f
3 changed files with 5 additions and 41 deletions
|
@ -1,9 +1,8 @@
|
|||
from functools import wraps
|
||||
|
||||
from django.db import IntegrityError, connections, transaction
|
||||
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
from django.test.testcases import TestData
|
||||
from django.utils.deprecation import RemovedInDjango41Warning
|
||||
|
||||
from .models import Car, Person, PossessedCar
|
||||
|
||||
|
@ -54,11 +53,6 @@ class TestTestCase(TestCase):
|
|||
self.reset_sequences = old_reset_sequences
|
||||
|
||||
|
||||
class NonDeepCopyAble:
|
||||
def __deepcopy__(self, memo):
|
||||
raise TypeError
|
||||
|
||||
|
||||
def assert_no_queries(test):
|
||||
@wraps(test)
|
||||
def inner(self):
|
||||
|
@ -79,7 +73,6 @@ class TestDataTests(TestCase):
|
|||
car=cls.car,
|
||||
belongs_to=cls.jim_douglas,
|
||||
)
|
||||
cls.non_deepcopy_able = NonDeepCopyAble()
|
||||
|
||||
@assert_no_queries
|
||||
def test_class_attribute_equality(self):
|
||||
|
@ -104,21 +97,6 @@ class TestDataTests(TestCase):
|
|||
self.assertIs(self.herbie.car, self.car)
|
||||
self.assertIs(self.herbie.belongs_to, self.jim_douglas)
|
||||
|
||||
@ignore_warnings(category=RemovedInDjango41Warning)
|
||||
def test_undeepcopyable(self):
|
||||
self.assertIs(self.non_deepcopy_able, self.__class__.non_deepcopy_able)
|
||||
|
||||
def test_undeepcopyable_warning(self):
|
||||
msg = (
|
||||
"Assigning objects which don't support copy.deepcopy() during "
|
||||
"setUpTestData() is deprecated. Either assign the "
|
||||
"non_deepcopy_able attribute during setUpClass() or setUp(), or "
|
||||
"add support for deepcopy() to "
|
||||
"test_utils.test_testcase.TestDataTests.non_deepcopy_able."
|
||||
)
|
||||
with self.assertRaisesMessage(RemovedInDjango41Warning, msg):
|
||||
self.non_deepcopy_able
|
||||
|
||||
def test_repr(self):
|
||||
self.assertEqual(
|
||||
repr(TestData('attr', 'value')),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue