1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Made reused RequestFactory instances class attributes.

This commit is contained in:
Simon Charette
2018-11-26 14:01:27 -05:00
committed by Tim Graham
parent 7f63b894c0
commit 0f212db29d
25 changed files with 93 additions and 109 deletions

View File

@@ -19,6 +19,7 @@ class DefaultsTests(TestCase):
'/nonexistent_url/', # this is in urls.py
'/other_nonexistent_url/', # this NOT in urls.py
]
request_factory = RequestFactory()
@classmethod
def setUpTestData(cls):
@@ -73,8 +74,7 @@ class DefaultsTests(TestCase):
self.assertEqual(response.status_code, 500)
def test_bad_request(self):
rf = RequestFactory()
request = rf.get('/')
request = self.request_factory.get('/')
response = bad_request(request, Exception())
self.assertEqual(response.status_code, 400)
self.assertEqual(response.content, b'<h1>Bad Request (400)</h1>')
@@ -116,8 +116,7 @@ class DefaultsTests(TestCase):
Default error views should raise TemplateDoesNotExist when passed a
template that doesn't exist.
"""
rf = RequestFactory()
request = rf.get('/')
request = self.request_factory.get('/')
with self.assertRaises(TemplateDoesNotExist):
bad_request(request, Exception(), template_name='nonexistent')