summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keystoneclient/__init__.py6
-rw-r--r--keystoneclient/common/cms.py8
-rw-r--r--keystoneclient/tests/unit/v2_0/test_auth.py7
-rw-r--r--keystoneclient/tests/unit/v3/test_auth.py8
-rw-r--r--setup.cfg1
-rw-r--r--tox.ini2
6 files changed, 10 insertions, 22 deletions
diff --git a/keystoneclient/__init__.py b/keystoneclient/__init__.py
index ee848db..e8ef58e 100644
--- a/keystoneclient/__init__.py
+++ b/keystoneclient/__init__.py
@@ -27,6 +27,7 @@ Identity V2 and V3 clients can also be created directly. See
"""
+import importlib
import sys
import pbr.version
@@ -67,10 +68,9 @@ class _LazyImporter(object):
'v2_0',
'v3',
]
- # __import__ rather than importlib for Python 2.6.
if name in lazy_submodules:
- __import__('keystoneclient.%s' % name)
- return getattr(self, name)
+ return importlib.import_module('keystoneclient.%s' % name)
+
# Return module attributes like __all__ etc.
return getattr(self._module, name)
diff --git a/keystoneclient/common/cms.py b/keystoneclient/common/cms.py
index 21cd394..c1260d3 100644
--- a/keystoneclient/common/cms.py
+++ b/keystoneclient/common/cms.py
@@ -101,7 +101,7 @@ def _process_communicate_handle_oserror(process, data, files):
except OSError as e:
if e.errno != errno.EPIPE:
raise
- # OSError with EPIPE only occurs with Python 2.6.x/old 2.7.x
+ # OSError with EPIPE only occurs with old Python 2.7.x versions
# http://bugs.python.org/issue10963
# The quick exit is typically caused by the openssl command not being
@@ -191,11 +191,7 @@ def cms_verify(formatted, signing_cert_file_name, ca_file_name,
else:
raise exceptions.CertificateConfigError(err)
elif retcode != OpensslCmsExitStatus.SUCCESS:
- # NOTE(dmllr): Python 2.6 compatibility:
- # CalledProcessError did not have output keyword argument
- e = subprocess.CalledProcessError(retcode, 'openssl')
- e.output = err
- raise e
+ raise subprocess.CalledProcessError(retcode, 'openssl', output=err)
return output
diff --git a/keystoneclient/tests/unit/v2_0/test_auth.py b/keystoneclient/tests/unit/v2_0/test_auth.py
index a10fd96..803fa5c 100644
--- a/keystoneclient/tests/unit/v2_0/test_auth.py
+++ b/keystoneclient/tests/unit/v2_0/test_auth.py
@@ -15,6 +15,7 @@ import datetime
from oslo_serialization import jsonutils
from oslo_utils import timeutils
+from testtools import testcase
from keystoneclient import exceptions
from keystoneclient.tests.unit.v2_0 import utils
@@ -91,17 +92,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(status_code=401, json=error)
- # Workaround for issue with assertRaises on python2.6
- # where with assertRaises(exceptions.Unauthorized): doesn't work
- # right
- def client_create_wrapper():
+ with testcase.ExpectedException(exceptions.Unauthorized):
with self.deprecations.expect_deprecations_here():
client.Client(username=self.TEST_USER,
password="bad_key",
project_id=self.TEST_TENANT_ID,
auth_url=self.TEST_URL)
- self.assertRaises(exceptions.Unauthorized, client_create_wrapper)
self.assertRequestBodyIs(json=self.TEST_REQUEST_BODY)
def test_auth_redirect(self):
diff --git a/keystoneclient/tests/unit/v3/test_auth.py b/keystoneclient/tests/unit/v3/test_auth.py
index 211633b..177eb3b 100644
--- a/keystoneclient/tests/unit/v3/test_auth.py
+++ b/keystoneclient/tests/unit/v3/test_auth.py
@@ -11,6 +11,7 @@
# under the License.
from oslo_serialization import jsonutils
+from testtools import testcase
from keystoneclient import exceptions
from keystoneclient.tests.unit.v3 import utils
@@ -103,11 +104,7 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(status_code=401, json=error)
- # Workaround for issue with assertRaises on python2.6
- # where with assertRaises(exceptions.Unauthorized): doesn't work
- # right
- def client_create_wrapper():
- # Creating a HTTPClient not using session is deprecated.
+ with testcase.ExpectedException(exceptions.Unauthorized):
with self.deprecations.expect_deprecations_here():
client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
username=self.TEST_USER,
@@ -115,7 +112,6 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
project_id=self.TEST_TENANT_ID,
auth_url=self.TEST_URL)
- self.assertRaises(exceptions.Unauthorized, client_create_wrapper)
self.assertRequestBodyIs(json=self.TEST_REQUEST_BODY)
def test_auth_redirect(self):
diff --git a/setup.cfg b/setup.cfg
index bb45837..52307d6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -15,7 +15,6 @@ classifier =
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
- Programming Language :: Python :: 2.6
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
diff --git a/tox.ini b/tox.ini
index 8e48eb3..e4843de 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
-envlist = py26,py27,py34,pep8,bandit
+envlist = py27,py34,pep8,bandit
[testenv]
usedevelop = True