[Python-checkins] cpython (3.4): Issue #23477: Improve test coverage of wsgiref.simple_server.
berker.peksag
python-checkins at python.org
Mon Mar 2 05:54:21 CET 2015
https://hg.python.org/cpython/rev/9f2ef8654bf8
changeset: 94813:9f2ef8654bf8
branch: 3.4
parent: 94811:617feb5d8af2
user: Berker Peksag <berker.peksag at gmail.com>
date: Mon Mar 02 06:53:33 2015 +0200
summary:
Issue #23477: Improve test coverage of wsgiref.simple_server.
The test checks that the environ argument contains correct headers,
querystring and path information.
Patch by Alex Shkop.
files:
Lib/test/test_wsgiref.py | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -48,6 +48,18 @@
])
return [b"Hello, world!"]
+
+def header_app(environ, start_response):
+ start_response("200 OK", [
+ ('Content-Type', 'text/plain'),
+ ('Date', 'Mon, 05 Jun 2006 18:49:54 GMT')
+ ])
+ return [';'.join([
+ environ['HTTP_X_TEST_HEADER'], environ['QUERY_STRING'],
+ environ['PATH_INFO']
+ ]).encode('iso-8859-1')]
+
+
def run_amock(app=hello_app, data=b"GET / HTTP/1.0\n\n"):
server = make_server("", 80, app, MockServer, MockHandler)
inp = BufferedReader(BytesIO(data))
@@ -118,6 +130,19 @@
out, err = run_amock()
self.check_hello(out)
+ def test_environ(self):
+ request = (
+ b"GET /p%61th/?query=test HTTP/1.0\n"
+ b"X-Test-Header: Python test \n"
+ b"X-Test-Header: Python test 2\n"
+ b"Content-Length: 0\n\n"
+ )
+ out, err = run_amock(header_app, request)
+ self.assertEqual(
+ out.splitlines()[-1],
+ b"Python test,Python test 2;query=test;/path/"
+ )
+
def test_request_length(self):
out, err = run_amock(data=b"GET " + (b"x" * 65537) + b" HTTP/1.0\n\n")
self.assertEqual(out.splitlines()[0],
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list