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

[1.5.x] Fixed #19316 -- Set View args/kwargs/request before dispatch

Backport of ea6b95db from master.
This commit is contained in:
George Hickman
2012-11-22 20:10:01 +01:00
committed by Claude Paroz
parent 84dc6afac7
commit 12cf9d2be3
2 changed files with 14 additions and 3 deletions

View File

@@ -216,6 +216,17 @@ class ViewTest(unittest.TestCase):
response_allows = set(response['Allow'].split(', '))
self.assertEqual(set(expected_methods + ('OPTIONS',)), response_allows)
def test_args_kwargs_request_on_self(self):
"""
Test a view only has args, kwargs & request once `as_view`
has been called.
"""
bare_view = InstanceView()
view = InstanceView.as_view()(self.rf.get('/'))
for attribute in ('args', 'kwargs', 'request'):
self.assertNotIn(attribute, dir(bare_view))
self.assertIn(attribute, dir(view))
class TemplateViewTest(TestCase):
urls = 'regressiontests.generic_views.urls'