From e6b59c5550227505dfc787ebec605e51e50a6e46 Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Fri, 10 Aug 2007 19:13:33 +0000 Subject: Make sure the mock object passed to finish_request() is buffered. --- Lib/test/test_wsgiref.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index 544e42b..bcf6352 100755 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -7,7 +7,7 @@ from wsgiref import util from wsgiref.validate import validator from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app from wsgiref.simple_server import make_server -from io import StringIO, BytesIO +from io import StringIO, BytesIO, BufferedReader from SocketServer import BaseServer import re, sys @@ -49,11 +49,13 @@ def hello_app(environ,start_response): def run_amock(app=hello_app, data=b"GET / HTTP/1.0\n\n"): server = make_server("", 80, app, MockServer, MockHandler) - inp, out, err, olderr = BytesIO(data), StringIO(), StringIO(), sys.stderr - sys.stderr = err + inp = BufferedReader(BytesIO(data)) + out = StringIO() + olderr = sys.stderr + err = sys.stderr = StringIO() try: - server.finish_request((inp,out), ("127.0.0.1",8888)) + server.finish_request((inp, out), ("127.0.0.1",8888)) finally: sys.stderr = olderr -- cgit v0.12