diff options
author | Daniyal <abbasi.daniyal98@gmail.com> | 2020-12-12 01:00:50 +0530 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-03-30 07:58:09 +0200 |
commit | 7c08f26bf0439c1ed593b51b51ad847f7e262bc1 (patch) | |
tree | 1b8279c7034f160610a2702f0bbac34cbba082be /tests/generic_views | |
parent | 0c0b87725bbcffca3bc3a7a2c649995695a5ae3b (diff) | |
download | django-7c08f26bf0439c1ed593b51b51ad847f7e262bc1.tar.gz |
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>
Diffstat (limited to 'tests/generic_views')
-rw-r--r-- | tests/generic_views/test_base.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py index f4b8a487ff..5872ecf3db 100644 --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -172,12 +172,16 @@ class ViewTest(SimpleTestCase): def test_class_attributes(self): """ - The callable returned from as_view() has proper - docstring, name and module. - """ - self.assertEqual(SimpleView.__doc__, SimpleView.as_view().__doc__) - self.assertEqual(SimpleView.__name__, SimpleView.as_view().__name__) - self.assertEqual(SimpleView.__module__, SimpleView.as_view().__module__) + The callable returned from as_view() has proper special attributes. + """ + 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): """ |