From 27ef627f1d5ece31bb98c9795599746e6e246f63 Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Wed, 3 Jun 2020 17:49:51 +0200 Subject: [PATCH] Get rid of bytes usage in tests.common Simply use the .encode() method (encode using the utf-8 encoding). --- tests/common.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/common.py b/tests/common.py index 353b7398..16715006 100644 --- a/tests/common.py +++ b/tests/common.py @@ -7,9 +7,6 @@ import sys from xml.etree import cElementTree as ET EXPECTED_REQUESTS = [] -if sys.version_info[0:2] in ((2, 6), (2, 7)): - bytes = lambda x, *args: x - try: #python 2.x from cStringIO import StringIO @@ -111,7 +108,7 @@ class MyHTTPHandler(HTTPHandler): if 'text' not in kwargs and 'file' in kwargs: f = BytesIO(open(os.path.join(self.__fixtures_dir, kwargs['file']), 'rb').read()) elif 'text' in kwargs and 'file' not in kwargs: - f = BytesIO(bytes(kwargs['text'], 'utf-8')) + f = BytesIO(kwargs['text'].encode('utf-8')) else: raise RuntimeError('either specify text or file') resp = addinfourl(f, {}, url)