Refs #20456 -- Added test for initialization of request/args/kwargs attributes in View.Setup().

This commit is contained in:
Felipe Lee 2019-10-30 14:14:04 +01:00 committed by Mariusz Felisiak
parent 54a7b02112
commit 31d1822532
1 changed files with 11 additions and 0 deletions

View File

@ -259,6 +259,17 @@ class ViewTest(SimpleTestCase):
with self.assertRaisesMessage(AttributeError, msg): with self.assertRaisesMessage(AttributeError, msg):
TestView.as_view()(self.rf.get('/')) 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): def test_direct_instantiation(self):
""" """
It should be possible to use the view by directly instantiating it It should be possible to use the view by directly instantiating it