diff options
author | Helmut Grohne <helmut@subdivi.de> | 2013-06-06 11:06:26 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2013-06-06 11:06:26 +0200 |
commit | 27ed9839582c4fce9a0fff82281fb2e302be808e (patch) | |
tree | 23e01db53d7d51b73de739dfbdb19e4584fb8a8f | |
parent | a5634dea0d4f24d6f27ba5d7e50c773979eec93c (diff) | |
download | wsgitools-27ed9839582c4fce9a0fff82281fb2e302be808e.tar.gz |
fix RequestLogWSGIFilterTest
Clarify the type of the log file-like passed to RequestLogWSGIFilter.
-rwxr-xr-x | test.py | 5 | ||||
-rw-r--r-- | wsgitools/filters.py | 3 |
2 files changed, 7 insertions, 1 deletions
@@ -377,7 +377,10 @@ class RequestLogWSGIFilterTest(unittest.TestCase): def testSimple(self): app = applications.StaticContent("200 Found", [("Content-Type", "text/plain")], b"nothing") - log = io.StringIO() + if isinstance("x", bytes): + log = io.BytesIO() + else: + log = io.StringIO() logfilter = filters.RequestLogWSGIFilter.creator(log) app = filters.WSGIFilterMiddleware(app, logfilter) req = Request(self) diff --git a/wsgitools/filters.py b/wsgitools/filters.py index 882a0bf..471c949 100644 --- a/wsgitools/filters.py +++ b/wsgitools/filters.py @@ -217,6 +217,9 @@ class RequestLogWSGIFilter(BaseWSGIFilter): """Returns a function creating L{RequestLogWSGIFilter}s on given log file. log has to be a file-like object. @type log: file-like + @param log: elements of type str are written to the log. That means in + Py3.X the contents are decoded and in Py2.X the log is assumed + to be encoded in latin1. This follows the spirit of WSGI. @type flush: bool @param flush: if True, invoke the flush method on log after each write invocation |