Kaydet (Commit) e6b59c55 authored tarafından Jeremy Hylton's avatar Jeremy Hylton

Make sure the mock object passed to finish_request() is buffered.

üst 7ffe2998
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment