mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f68fa8b45d
commit
9c19aff7c7
@@ -13,7 +13,7 @@ class DeconstructibleChildClass(DeconstructibleClass):
|
||||
|
||||
|
||||
@deconstructible(
|
||||
path='utils_tests.deconstructible_classes.DeconstructibleWithPathClass'
|
||||
path="utils_tests.deconstructible_classes.DeconstructibleWithPathClass"
|
||||
)
|
||||
class DeconstructibleWithPathClass:
|
||||
pass
|
||||
@@ -24,7 +24,7 @@ class DeconstructibleWithPathChildClass(DeconstructibleWithPathClass):
|
||||
|
||||
|
||||
@deconstructible(
|
||||
path='utils_tests.deconstructible_classes.DeconstructibleInvalidPathClass',
|
||||
path="utils_tests.deconstructible_classes.DeconstructibleInvalidPathClass",
|
||||
)
|
||||
class DeconstructibleInvalidPathClass:
|
||||
pass
|
||||
@@ -36,61 +36,61 @@ class DeconstructibleInvalidPathChildClass(DeconstructibleInvalidPathClass):
|
||||
|
||||
class DeconstructibleTests(SimpleTestCase):
|
||||
def test_deconstruct(self):
|
||||
obj = DeconstructibleClass('arg', key='value')
|
||||
obj = DeconstructibleClass("arg", key="value")
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(path, 'utils_tests.test_deconstruct.DeconstructibleClass')
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
self.assertEqual(path, "utils_tests.test_deconstruct.DeconstructibleClass")
|
||||
self.assertEqual(args, ("arg",))
|
||||
self.assertEqual(kwargs, {"key": "value"})
|
||||
|
||||
def test_deconstruct_with_path(self):
|
||||
obj = DeconstructibleWithPathClass('arg', key='value')
|
||||
obj = DeconstructibleWithPathClass("arg", key="value")
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(
|
||||
path,
|
||||
'utils_tests.deconstructible_classes.DeconstructibleWithPathClass',
|
||||
"utils_tests.deconstructible_classes.DeconstructibleWithPathClass",
|
||||
)
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
self.assertEqual(args, ("arg",))
|
||||
self.assertEqual(kwargs, {"key": "value"})
|
||||
|
||||
def test_deconstruct_child(self):
|
||||
obj = DeconstructibleChildClass('arg', key='value')
|
||||
obj = DeconstructibleChildClass("arg", key="value")
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(path, 'utils_tests.test_deconstruct.DeconstructibleChildClass')
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
self.assertEqual(path, "utils_tests.test_deconstruct.DeconstructibleChildClass")
|
||||
self.assertEqual(args, ("arg",))
|
||||
self.assertEqual(kwargs, {"key": "value"})
|
||||
|
||||
def test_deconstruct_child_with_path(self):
|
||||
obj = DeconstructibleWithPathChildClass('arg', key='value')
|
||||
obj = DeconstructibleWithPathChildClass("arg", key="value")
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(
|
||||
path,
|
||||
'utils_tests.test_deconstruct.DeconstructibleWithPathChildClass',
|
||||
"utils_tests.test_deconstruct.DeconstructibleWithPathChildClass",
|
||||
)
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
self.assertEqual(args, ("arg",))
|
||||
self.assertEqual(kwargs, {"key": "value"})
|
||||
|
||||
def test_invalid_path(self):
|
||||
obj = DeconstructibleInvalidPathClass()
|
||||
docs_version = get_docs_version()
|
||||
msg = (
|
||||
f'Could not find object DeconstructibleInvalidPathClass in '
|
||||
f'utils_tests.deconstructible_classes.\n'
|
||||
f'Please note that you cannot serialize things like inner '
|
||||
f'classes. Please move the object into the main module body to '
|
||||
f'use migrations.\n'
|
||||
f'For more information, see '
|
||||
f'https://docs.djangoproject.com/en/{docs_version}/topics/'
|
||||
f'migrations/#serializing-values'
|
||||
f"Could not find object DeconstructibleInvalidPathClass in "
|
||||
f"utils_tests.deconstructible_classes.\n"
|
||||
f"Please note that you cannot serialize things like inner "
|
||||
f"classes. Please move the object into the main module body to "
|
||||
f"use migrations.\n"
|
||||
f"For more information, see "
|
||||
f"https://docs.djangoproject.com/en/{docs_version}/topics/"
|
||||
f"migrations/#serializing-values"
|
||||
)
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
obj.deconstruct()
|
||||
|
||||
def test_parent_invalid_path(self):
|
||||
obj = DeconstructibleInvalidPathChildClass('arg', key='value')
|
||||
obj = DeconstructibleInvalidPathChildClass("arg", key="value")
|
||||
path, args, kwargs = obj.deconstruct()
|
||||
self.assertEqual(
|
||||
path,
|
||||
'utils_tests.test_deconstruct.DeconstructibleInvalidPathChildClass',
|
||||
"utils_tests.test_deconstruct.DeconstructibleInvalidPathChildClass",
|
||||
)
|
||||
self.assertEqual(args, ('arg',))
|
||||
self.assertEqual(kwargs, {'key': 'value'})
|
||||
self.assertEqual(args, ("arg",))
|
||||
self.assertEqual(kwargs, {"key": "value"})
|
||||
|
||||
Reference in New Issue
Block a user