summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/test.py b/test.py
index 3c77c06..ed7d6e3 100755
--- a/test.py
+++ b/test.py
@@ -78,7 +78,7 @@ class Request:
res.headersdata = headers
return write
iterator = app(self.environ, start_response)
- self.returneddata = list(iterator)
+ res.returneddata = list(iterator)
if hasattr(iterator, "close"):
iterator.close()
return res
@@ -235,6 +235,20 @@ class AuthDigestMiddlewareTest(unittest.TestCase):
from wsgitools import middlewares
+def writing_application(environ, start_response):
+ write = start_response("404 Not found", [("Content-Type", "text/plain")])
+ write = start_response("200 Ok", [("Content-Type", "text/plain")])
+ write("first")
+ yield ""
+ yield "second"
+
+class NoWriteCallableMiddlewareTest(unittest.TestCase):
+ def testWrite(self):
+ app = middlewares.NoWriteCallableMiddleware(writing_application)
+ res = Request(self)(app)
+ self.assertEqual(res.writtendata, [])
+ self.assertEqual("".join(res.returneddata), "firstsecond")
+
class StupidIO:
"""file-like without tell method, so StaticFile is not able to
determine the content-length."""
@@ -324,6 +338,7 @@ fullsuite.addTest(alltests(StaticFileTest))
fullsuite.addTest(alltests(AuthDigestMiddlewareTest))
fullsuite.addTest(alltests(ContentLengthMiddlewareTest))
fullsuite.addTest(alltests(BasicAuthMiddlewareTest))
+fullsuite.addTest(alltests(NoWriteCallableMiddlewareTest))
if __name__ == "__main__":
runner = unittest.TextTestRunner(verbosity=2)