Port script utils to Python 3

* Replace StandardError with exception.BadStoreUri: StandardError was
  removed in Python 3.
* tox.ini: add script util tests to Python 3.4

Change-Id: I26a723d3b5712fede9ad8ca67187fd5fbe31fc2a
This commit is contained in:
Victor Stinner 2015-10-19 19:21:48 +02:00
parent b9aaa2f39e
commit 6283970aa4
3 changed files with 9 additions and 6 deletions

View File

@ -97,9 +97,9 @@ def validate_location_uri(location):
elif location.startswith(("file:///", "filesystem:///")):
msg = _("File based imports are not allowed. Please use a non-local "
"source of image data.")
# NOTE: raise Exception and let the encompassing block save
# the error msg in the task.message.
raise StandardError(msg)
# NOTE: raise BadStoreUri and let the encompassing block save the error
# msg in the task.message.
raise exception.BadStoreUri(msg)
else:
# TODO(nikhil): add other supported uris

View File

@ -89,9 +89,10 @@ class TestScriptsUtils(test_utils.BaseTestCase):
script_utils.validate_location_uri, '')
def test_validate_location_file_location_error(self):
self.assertRaises(StandardError, script_utils.validate_location_uri,
"file:///tmp")
self.assertRaises(StandardError, script_utils.validate_location_uri,
self.assertRaises(exception.BadStoreUri,
script_utils.validate_location_uri, "file:///tmp")
self.assertRaises(exception.BadStoreUri,
script_utils.validate_location_uri,
"filesystem:///tmp")
def test_validate_location_unsupported_error(self):

View File

@ -27,6 +27,8 @@ commands =
glance.tests.unit.async.flows.test_introspect \
glance.tests.unit.async.test_async \
glance.tests.unit.async.test_taskflow_executor \
glance.tests.unit.common.scripts.image_import.test_main \
glance.tests.unit.common.scripts.test_scripts_utils \
glance.tests.unit.common.test_client \
glance.tests.unit.common.test_config \
glance.tests.unit.common.test_exception \