From 4d52eaa4801df3f3169df8e58758bcccf22dc4de Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 17 Jun 2023 19:35:21 +0200 Subject: drop support for Python 2.x --- test.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'test.py') 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) -- cgit v1.2.3