mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Made reused RequestFactory instances class attributes.
This commit is contained in:
committed by
Tim Graham
parent
7f63b894c0
commit
0f212db29d
@@ -428,9 +428,10 @@ class BrokenLinkEmailsMiddlewareTest(SimpleTestCase):
|
||||
|
||||
@override_settings(ROOT_URLCONF='middleware.cond_get_urls')
|
||||
class ConditionalGetMiddlewareTest(SimpleTestCase):
|
||||
request_factory = RequestFactory()
|
||||
|
||||
def setUp(self):
|
||||
self.req = RequestFactory().get('/')
|
||||
self.req = self.request_factory.get('/')
|
||||
self.resp = self.client.get(self.req.path_info)
|
||||
|
||||
# Tests for the ETag header
|
||||
@@ -569,7 +570,7 @@ class ConditionalGetMiddlewareTest(SimpleTestCase):
|
||||
"""
|
||||
get_response = ConditionalGetMiddleware().process_response(self.req, self.resp)
|
||||
etag = get_response['ETag']
|
||||
put_request = RequestFactory().put('/', HTTP_IF_MATCH=etag)
|
||||
put_request = self.request_factory.put('/', HTTP_IF_MATCH=etag)
|
||||
put_response = HttpResponse(status=200)
|
||||
conditional_get_response = ConditionalGetMiddleware().process_response(put_request, put_response)
|
||||
self.assertEqual(conditional_get_response.status_code, 200) # should never be a 412
|
||||
@@ -580,7 +581,7 @@ class ConditionalGetMiddlewareTest(SimpleTestCase):
|
||||
HEAD request since it can't do so accurately without access to the
|
||||
response body of the corresponding GET.
|
||||
"""
|
||||
request = RequestFactory().head('/')
|
||||
request = self.request_factory.head('/')
|
||||
response = HttpResponse(status=200)
|
||||
conditional_get_response = ConditionalGetMiddleware().process_response(request, response)
|
||||
self.assertNotIn('ETag', conditional_get_response)
|
||||
@@ -700,9 +701,10 @@ class GZipMiddlewareTest(SimpleTestCase):
|
||||
incompressible_string = b''.join(int2byte(random.randint(0, 255)) for _ in range(500))
|
||||
sequence = [b'a' * 500, b'b' * 200, b'a' * 300]
|
||||
sequence_unicode = ['a' * 500, 'é' * 200, 'a' * 300]
|
||||
request_factory = RequestFactory()
|
||||
|
||||
def setUp(self):
|
||||
self.req = RequestFactory().get('/')
|
||||
self.req = self.request_factory.get('/')
|
||||
self.req.META['HTTP_ACCEPT_ENCODING'] = 'gzip, deflate'
|
||||
self.req.META['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1'
|
||||
self.resp = HttpResponse()
|
||||
|
||||
Reference in New Issue
Block a user