1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

Fix Python 3 support.

This change fixes errors when running test suite with Python 3.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
This commit is contained in:
Oleg Girko 2015-08-13 12:40:16 +01:00
parent c23e20bc29
commit 4d3fcd9dc1
3 changed files with 9 additions and 4 deletions

View File

@ -3701,7 +3701,7 @@ def show_project_sourceinfo(apiurl, project, nofilename, *packages):
def get_project_sourceinfo(apiurl, project, nofilename, *packages):
try:
si = show_project_sourceinfo(apiurl, project, nofilename, *packages)
except HTTPError, e:
except HTTPError as e:
# old API servers (e.g. 2.3.5) do not know the 'nofilename' parameter, so retry without
if e.code == 400 and nofilename:
return get_project_sourceinfo(apiurl, project, False, *packages)

View File

@ -92,7 +92,7 @@ class MyHTTPHandler(HTTPHandler):
elif exp is None:
raise RuntimeError('exp or expfile required')
if exp is not None:
if req.get_data() != bytes(exp, "utf-8"):
if req.data != bytes(exp, "utf-8"):
raise RequestDataMismatch(req.get_full_url(), repr(req.get_data()), repr(exp))
return self.__get_response(req.get_full_url(), **kwargs)

View File

@ -2,9 +2,14 @@ import osc.core
import osc.oscerr
import os
import sys
import urllib2
from common import GET, PUT, POST, DELETE, OscTestCase
from xml.etree import cElementTree as ET
try:
from urllib.error import HTTPError
except ImportError:
#python 2.x
from urllib2 import HTTPError
FIXTURES_DIR = os.path.join(os.getcwd(), 'commit_fixtures')
def suite():
@ -302,7 +307,7 @@ class TestCommit(OscTestCase):
self._change_to_pkg('simple')
p = osc.core.Package('.')
self._check_status(p, 'nochange', 'M')
self.assertRaises(urllib2.HTTPError, p.commit)
self.assertRaises(HTTPError, p.commit)
exp = 'Sending nochange\nTransmitting file data .'
self.assertEqual(sys.stdout.getvalue(), exp)
self._check_status(p, 'nochange', 'M')