Fixed #8646 -- Modified test client to set a fully WSGI compliant environment. Thanks to Adam Lofts for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9396 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cb6a5886f6
commit
ecc1ed4ce1
|
@ -158,6 +158,7 @@ class Client(object):
|
||||||
self.defaults = defaults
|
self.defaults = defaults
|
||||||
self.cookies = SimpleCookie()
|
self.cookies = SimpleCookie()
|
||||||
self.exc_info = None
|
self.exc_info = None
|
||||||
|
self.errors = StringIO()
|
||||||
|
|
||||||
def store_exc_info(self, **kwargs):
|
def store_exc_info(self, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -193,6 +194,12 @@ class Client(object):
|
||||||
'SERVER_NAME': 'testserver',
|
'SERVER_NAME': 'testserver',
|
||||||
'SERVER_PORT': '80',
|
'SERVER_PORT': '80',
|
||||||
'SERVER_PROTOCOL': 'HTTP/1.1',
|
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||||
|
'wsgi.version': (1,0),
|
||||||
|
'wsgi.url_scheme': 'http',
|
||||||
|
'wsgi.errors': self.errors,
|
||||||
|
'wsgi.multiprocess': True,
|
||||||
|
'wsgi.multithread': False,
|
||||||
|
'wsgi.run_once': False,
|
||||||
}
|
}
|
||||||
environ.update(self.defaults)
|
environ.update(self.defaults)
|
||||||
environ.update(request)
|
environ.update(request)
|
||||||
|
@ -254,11 +261,11 @@ class Client(object):
|
||||||
Requests a response from the server using GET.
|
Requests a response from the server using GET.
|
||||||
"""
|
"""
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': None,
|
|
||||||
'CONTENT_TYPE': 'text/html; charset=utf-8',
|
'CONTENT_TYPE': 'text/html; charset=utf-8',
|
||||||
'PATH_INFO': urllib.unquote(path),
|
'PATH_INFO': urllib.unquote(path),
|
||||||
'QUERY_STRING': urlencode(data, doseq=True),
|
'QUERY_STRING': urlencode(data, doseq=True),
|
||||||
'REQUEST_METHOD': 'GET',
|
'REQUEST_METHOD': 'GET',
|
||||||
|
'wsgi.input': FakePayload('')
|
||||||
}
|
}
|
||||||
r.update(extra)
|
r.update(extra)
|
||||||
|
|
||||||
|
@ -289,11 +296,11 @@ class Client(object):
|
||||||
Request a response from the server using HEAD.
|
Request a response from the server using HEAD.
|
||||||
"""
|
"""
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': None,
|
|
||||||
'CONTENT_TYPE': 'text/html; charset=utf-8',
|
'CONTENT_TYPE': 'text/html; charset=utf-8',
|
||||||
'PATH_INFO': urllib.unquote(path),
|
'PATH_INFO': urllib.unquote(path),
|
||||||
'QUERY_STRING': urlencode(data, doseq=True),
|
'QUERY_STRING': urlencode(data, doseq=True),
|
||||||
'REQUEST_METHOD': 'HEAD',
|
'REQUEST_METHOD': 'HEAD',
|
||||||
|
'wsgi.input': FakePayload('')
|
||||||
}
|
}
|
||||||
r.update(extra)
|
r.update(extra)
|
||||||
|
|
||||||
|
@ -304,11 +311,10 @@ class Client(object):
|
||||||
Request a response from the server using OPTIONS.
|
Request a response from the server using OPTIONS.
|
||||||
"""
|
"""
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': None,
|
|
||||||
'CONTENT_TYPE': None,
|
|
||||||
'PATH_INFO': urllib.unquote(path),
|
'PATH_INFO': urllib.unquote(path),
|
||||||
'QUERY_STRING': urlencode(data, doseq=True),
|
'QUERY_STRING': urlencode(data, doseq=True),
|
||||||
'REQUEST_METHOD': 'OPTIONS',
|
'REQUEST_METHOD': 'OPTIONS',
|
||||||
|
'wsgi.input': FakePayload('')
|
||||||
}
|
}
|
||||||
r.update(extra)
|
r.update(extra)
|
||||||
|
|
||||||
|
@ -338,11 +344,10 @@ class Client(object):
|
||||||
Send a DELETE request to the server.
|
Send a DELETE request to the server.
|
||||||
"""
|
"""
|
||||||
r = {
|
r = {
|
||||||
'CONTENT_LENGTH': None,
|
|
||||||
'CONTENT_TYPE': None,
|
|
||||||
'PATH_INFO': urllib.unquote(path),
|
'PATH_INFO': urllib.unquote(path),
|
||||||
'REQUEST_METHOD': 'DELETE',
|
'REQUEST_METHOD': 'DELETE',
|
||||||
}
|
'wsgi.input': FakePayload('')
|
||||||
|
}
|
||||||
r.update(extra)
|
r.update(extra)
|
||||||
|
|
||||||
return self.request(**r)
|
return self.request(**r)
|
||||||
|
|
Loading…
Reference in New Issue