1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-24 13:56:13 +01:00

change to open() with 'rb' to get bytes in python3

With this change you get bytes with python3 and string in python2

disable travis tests for python 3.x until the full python3 branch
is merged. Otherwise the tests will fail and master isn't python3
ready anyways
This commit is contained in:
lethliel 2018-11-09 10:33:30 +01:00
parent aa88b6b795
commit 39ae30bcc2
2 changed files with 7 additions and 5 deletions

View File

@ -1,9 +1,9 @@
language: python language: python
python: python:
- '2.7' - '2.7'
- '3.3' #- '3.3'
- '3.4' #- '3.4'
- 3.5-dev #- 3.5-dev
addons: addons:
apt: apt:
packages: packages:

View File

@ -20,6 +20,8 @@ except ImportError:
from urllib.request import HTTPHandler, addinfourl, build_opener from urllib.request import HTTPHandler, addinfourl, build_opener
from urllib.parse import urlparse, parse_qs from urllib.parse import urlparse, parse_qs
from io import BytesIO
def urlcompare(url, *args): def urlcompare(url, *args):
"""compare all components of url except query string - it is converted to """compare all components of url except query string - it is converted to
dict, therefor different ordering does not makes url's different, as well dict, therefor different ordering does not makes url's different, as well
@ -105,9 +107,9 @@ class MyHTTPHandler(HTTPHandler):
if 'exception' in kwargs: if 'exception' in kwargs:
raise kwargs['exception'] raise kwargs['exception']
if 'text' not in kwargs and 'file' in kwargs: if 'text' not in kwargs and 'file' in kwargs:
f = StringIO(open(os.path.join(self.__fixtures_dir, kwargs['file']), 'r').read()) f = BytesIO(open(os.path.join(self.__fixtures_dir, kwargs['file']), 'rb').read())
elif 'text' in kwargs and 'file' not in kwargs: elif 'text' in kwargs and 'file' not in kwargs:
f = StringIO(kwargs['text']) f = BytesIO(bytes(kwargs['text'], 'utf-8'))
else: else:
raise RuntimeError('either specify text or file') raise RuntimeError('either specify text or file')
resp = addinfourl(f, {}, url) resp = addinfourl(f, {}, url)