diff options
Diffstat (limited to 'tests/generic_views/test_base.py')
-rw-r--r-- | tests/generic_views/test_base.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py index 72c813b204..a5e528585c 100644 --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -145,12 +145,14 @@ class ViewTest(unittest.TestCase): # Check each of the allowed method names for method in SimpleView.http_method_names: kwargs = dict(((method, "value"),)) - self.assertRaises(TypeError, SimpleView.as_view, **kwargs) + with self.assertRaises(TypeError): + SimpleView.as_view(**kwargs) # Check the case view argument is ok if predefined on the class... CustomizableView.as_view(parameter="value") # ...but raises errors otherwise. - self.assertRaises(TypeError, CustomizableView.as_view, foobar="value") + with self.assertRaises(TypeError): + CustomizableView.as_view(foobar="value") def test_calling_more_than_once(self): """ @@ -280,7 +282,8 @@ class TemplateViewTest(SimpleTestCase): """ A template view must provide a template name. """ - self.assertRaises(ImproperlyConfigured, self.client.get, '/template/no_template/') + with self.assertRaises(ImproperlyConfigured): + self.client.get('/template/no_template/') @require_jinja2 def test_template_engine(self): @@ -527,4 +530,5 @@ class SingleObjectTemplateResponseMixinTest(unittest.TestCase): TemplateDoesNotExist. """ view = views.TemplateResponseWithoutTemplate() - self.assertRaises(ImproperlyConfigured, view.get_template_names) + with self.assertRaises(ImproperlyConfigured): + view.get_template_names() |