summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2023-06-17 19:35:21 +0200
committerHelmut Grohne <helmut@subdivi.de>2023-06-18 22:44:01 +0200
commit4d52eaa4801df3f3169df8e58758bcccf22dc4de (patch)
treeb8740a88e380a750d9d2607bb39cbc759a8d7175 /test.py
parent682ce67b73453809237532a7ce2feee07f2900d5 (diff)
downloadwsgitools-4d52eaa4801df3f3169df8e58758bcccf22dc4de.tar.gz
drop support for Python 2.x
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/test.py b/test.py
index c9d97f1..9690baf 100755
--- a/test.py
+++ b/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import base64
import unittest
@@ -11,7 +11,7 @@ import sys
from wsgitools.internal import bytes2str, str2bytes
-class Request(object):
+class Request:
def __init__(self, case):
"""
@type case: unittest.TestCase
@@ -77,7 +77,7 @@ class Request(object):
iterator.close()
return res
-class Result(object):
+class Result:
def __init__(self, case):
"""
@type case: unittest.TestCase
@@ -202,7 +202,7 @@ class AuthDigestMiddlewareTest(unittest.TestCase):
nonce = nonce.split('"')[1]
req = self.req.copy()
token = md5(str2bytes("bar:foo:%s" % password)).hexdigest()
- other = md5(str2bytes("GET:")).hexdigest()
+ other = md5(b"GET:").hexdigest()
resp = md5(str2bytes("%s:%s:%s" % (token, nonce, other))).hexdigest()
req.setheader('Authorization', 'Digest algorithm=md5,nonce="%s",' \
'uri=,username=bar,response="%s"' % (nonce, resp))
@@ -221,8 +221,8 @@ class AuthDigestMiddlewareTest(unittest.TestCase):
res.getheader("WWW-Authenticate").split())))
nonce = nonce.split('"')[1]
req = self.req.copy()
- token = md5(str2bytes("bar:foo:baz")).hexdigest()
- other = md5(str2bytes("GET:")).hexdigest()
+ token = md5(b"bar:foo:baz").hexdigest()
+ other = md5(b"GET:").hexdigest()
resp = "%s:%s:1:qux:auth:%s" % (token, nonce, other)
resp = md5(str2bytes(resp)).hexdigest()
req.setheader('Authorization', 'Digest algorithm=md5,nonce="%s",' \
@@ -259,7 +259,7 @@ class NoWriteCallableMiddlewareTest(unittest.TestCase):
self.assertEqual(res.writtendata, [])
self.assertEqual(b"".join(res.returneddata), b"firstsecond")
-class StupidIO(object):
+class StupidIO:
"""file-like without tell method, so StaticFile is not able to
determine the content-length."""
def __init__(self, content):
@@ -317,7 +317,7 @@ class CachingMiddlewareTest(unittest.TestCase):
if "maxage0" in environ["SCRIPT_NAME"]:
headers.append(("Cache-Control", "max-age=0"))
start_response("200 Found", headers)
- return [str2bytes("%d" % count)]
+ return [b"%d" % count]
def testCache(self):
res = Request(self)(self.cached)
@@ -385,10 +385,7 @@ class RequestLogWSGIFilterTest(unittest.TestCase):
def testSimple(self):
app = applications.StaticContent("200 Found",
[("Content-Type", "text/plain")], b"nothing")
- if isinstance("x", bytes):
- log = io.BytesIO()
- else:
- log = io.StringIO()
+ log = io.StringIO()
logfilter = filters.RequestLogWSGIFilter.creator(log)
app = filters.WSGIFilterMiddleware(app, logfilter)
req = Request(self)