summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_wsgiref.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_wsgiref.py')
-rw-r--r--Lib/test/test_wsgiref.py47
1 files changed, 12 insertions, 35 deletions
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
index b78d0c8..49d372d 100644
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -47,7 +47,7 @@ def hello_app(environ,start_response):
('Content-Type','text/plain'),
('Date','Mon, 05 Jun 2006 18:49:54 GMT')
])
- return ["Hello, world!"]
+ return [b"Hello, world!"]
def run_amock(app=hello_app, data=b"GET / HTTP/1.0\n\n"):
server = make_server("", 80, app, MockServer, MockHandler)
@@ -165,7 +165,7 @@ class IntegrationTests(TestCase):
def test_wsgi_input(self):
def bad_app(e,s):
e["wsgi.input"].read()
- s(b"200 OK", [(b"Content-Type", b"text/plain; charset=utf-8")])
+ s("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
return [b"data"]
out, err = run_amock(validator(bad_app))
self.assertTrue(out.endswith(
@@ -177,8 +177,8 @@ class IntegrationTests(TestCase):
def test_bytes_validation(self):
def app(e, s):
- s(b"200 OK", [
- (b"Content-Type", b"text/plain; charset=utf-8"),
+ s("200 OK", [
+ ("Content-Type", "text/plain; charset=utf-8"),
("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
])
return [b"data"]
@@ -420,29 +420,6 @@ class HeaderTests(TestCase):
'\r\n'
)
- def testBytes(self):
- h = Headers([
- (b"Content-Type", b"text/plain; charset=utf-8"),
- ])
- self.assertEqual("text/plain; charset=utf-8", h.get("Content-Type"))
-
- h[b"Foo"] = bytes(b"bar")
- self.assertEqual("bar", h.get("Foo"))
- self.assertEqual("bar", h.get(b"Foo"))
-
- h.setdefault(b"Bar", b"foo")
- self.assertEqual("foo", h.get("Bar"))
- self.assertEqual("foo", h.get(b"Bar"))
-
- h.add_header(b'content-disposition', b'attachment',
- filename=b'bud.gif')
- self.assertEqual('attachment; filename="bud.gif"',
- h.get("content-disposition"))
-
- del h['content-disposition']
- self.assertNotIn(b'content-disposition', h)
-
-
class ErrorHandler(BaseCGIHandler):
"""Simple handler subclass for testing BaseHandler"""
@@ -529,10 +506,10 @@ class HandlerTests(TestCase):
def trivial_app1(e,s):
s('200 OK',[])
- return [e['wsgi.url_scheme']]
+ return [e['wsgi.url_scheme'].encode('iso-8859-1')]
def trivial_app2(e,s):
- s('200 OK',[])(e['wsgi.url_scheme'])
+ s('200 OK',[])(e['wsgi.url_scheme'].encode('iso-8859-1'))
return []
def trivial_app3(e,s):
@@ -590,13 +567,13 @@ class HandlerTests(TestCase):
("Status: %s\r\n"
"Content-Type: text/plain\r\n"
"Content-Length: %d\r\n"
- "\r\n%s" % (h.error_status,len(h.error_body),h.error_body)
- ).encode("iso-8859-1"))
+ "\r\n" % (h.error_status,len(h.error_body))).encode('iso-8859-1')
+ + h.error_body)
self.assertIn("AssertionError", h.stderr.getvalue())
def testErrorAfterOutput(self):
- MSG = "Some output has been sent"
+ MSG = b"Some output has been sent"
def error_app(e,s):
s("200 OK",[])(MSG)
raise AssertionError("This should be caught by handler")
@@ -605,7 +582,7 @@ class HandlerTests(TestCase):
h.run(error_app)
self.assertEqual(h.stdout.getvalue(),
("Status: 200 OK\r\n"
- "\r\n"+MSG).encode("iso-8859-1"))
+ "\r\n".encode("iso-8859-1")+MSG))
self.assertIn("AssertionError", h.stderr.getvalue())
@@ -654,8 +631,8 @@ class HandlerTests(TestCase):
def testBytesData(self):
def app(e, s):
- s(b"200 OK", [
- (b"Content-Type", b"text/plain; charset=utf-8"),
+ s("200 OK", [
+ ("Content-Type", "text/plain; charset=utf-8"),
])
return [b"data"]