From 31d1822532d716d5b2f1422372d07dd05067bfc6 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Wed, 30 Oct 2019 14:14:04 +0100 Subject: [PATCH] Refs #20456 -- Added test for initialization of request/args/kwargs attributes in View.Setup(). --- tests/generic_views/test_base.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py index e48413d4a4..f6479d858c 100644 --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -259,6 +259,17 @@ class ViewTest(SimpleTestCase): with self.assertRaisesMessage(AttributeError, msg): TestView.as_view()(self.rf.get('/')) + def test_setup_adds_args_kwargs_request(self): + request = self.rf.get('/') + args = ('arg 1', 'arg 2') + kwargs = {'kwarg_1': 1, 'kwarg_2': 'year'} + + view = View() + view.setup(request, *args, **kwargs) + self.assertEqual(request, view.request) + self.assertEqual(args, view.args) + self.assertEqual(kwargs, view.kwargs) + def test_direct_instantiation(self): """ It should be possible to use the view by directly instantiating it