mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #33216 -- Made @deconstructible do not change path for subclasses.
This commit is contained in:
committed by
Mariusz Felisiak
parent
194ca77092
commit
205f67cd5b
@@ -19,6 +19,10 @@ class DeconstructibleWithPathClass:
|
||||
pass
|
||||
|
||||
|
||||
class DeconstructibleWithPathChildClass(DeconstructibleWithPathClass):
|
||||
pass
|
||||
|
||||
|
||||
@deconstructible(
|
||||
path='utils_tests.deconstructible_classes.DeconstructibleInvalidPathClass',
|
||||
)
|
||||
@@ -26,6 +30,10 @@ class DeconstructibleInvalidPathClass:
|
||||
pass
|
||||
|
||||
|
||||
class DeconstructibleInvalidPathChildClass(DeconstructibleInvalidPathClass):
|
||||
pass
|
||||
|
||||
|
||||
class DeconstructibleTests(SimpleTestCase):
|
||||
def test_deconstruct(self):
|
||||
obj = DeconstructibleClass('arg', key='value')
|
||||
@@ -51,6 +59,16 @@ class DeconstructibleTests(SimpleTestCase):
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
|
||||
def test_deconstruct_child_with_path(self):
|
||||
obj = DeconstructibleWithPathChildClass('arg', key='value')
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(
|
||||
path,
|
||||
'utils_tests.test_deconstruct.DeconstructibleWithPathChildClass',
|
||||
)
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
|
||||
def test_invalid_path(self):
|
||||
obj = DeconstructibleInvalidPathClass()
|
||||
docs_version = get_docs_version()
|
||||
@@ -66,3 +84,13 @@ class DeconstructibleTests(SimpleTestCase):
|
||||
)
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
obj.deconstruct()
|
||||
|
||||
def test_parent_invalid_path(self):
|
||||
obj = DeconstructibleInvalidPathChildClass('arg', key='value')
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(
|
||||
path,
|
||||
'utils_tests.test_deconstruct.DeconstructibleInvalidPathChildClass',
|
||||
)
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
|
||||
Reference in New Issue
Block a user