diff --git a/osc/core.py b/osc/core.py index 0b48d63c..9108c742 100644 --- a/osc/core.py +++ b/osc/core.py @@ -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) diff --git a/tests/common.py b/tests/common.py index f0fee8b5..f194b4a2 100644 --- a/tests/common.py +++ b/tests/common.py @@ -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) diff --git a/tests/test_commit.py b/tests/test_commit.py index aed14b44..02baa855 100644 --- a/tests/test_commit.py +++ b/tests/test_commit.py @@ -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')