1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #32260 -- Made View.as_view() do not use update_wrapper().

View.as_view() should not use update_wrapper() for copying attributes
it's unintended and have side-effects such as adding `self` to the
signature.

This also fixes system check for arguments of custom error handler
views with class-based views.

Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
This commit is contained in:
Daniyal
2020-12-12 01:00:50 +05:30
committed by Mariusz Felisiak
parent 0c0b87725b
commit 7c08f26bf0
7 changed files with 79 additions and 17 deletions

View File

@@ -172,12 +172,16 @@ class ViewTest(SimpleTestCase):
def test_class_attributes(self):
"""
The callable returned from as_view() has proper
docstring, name and module.
The callable returned from as_view() has proper special attributes.
"""
self.assertEqual(SimpleView.__doc__, SimpleView.as_view().__doc__)
self.assertEqual(SimpleView.__name__, SimpleView.as_view().__name__)
self.assertEqual(SimpleView.__module__, SimpleView.as_view().__module__)
cls = SimpleView
view = cls.as_view()
self.assertEqual(view.__doc__, cls.__doc__)
self.assertEqual(view.__name__, 'view')
self.assertEqual(view.__module__, cls.__module__)
self.assertEqual(view.__qualname__, f'{cls.as_view.__qualname__}.<locals>.view')
self.assertEqual(view.__annotations__, cls.dispatch.__annotations__)
self.assertFalse(hasattr(view, '__wrapped__'))
def test_dispatch_decoration(self):
"""