Improve Python 3.x compatibility

Some mechanical translation of the deprecated
except x,y construct. Should work with Python >= 2.6
just fine

Change-Id: I394f9956b9e3e3d9f5f1e9ad50c35b13200af2a1
This commit is contained in:
Dirk Mueller
2013-04-22 16:38:55 +02:00
parent 11c2c40d46
commit 45feb672af
9 changed files with 18 additions and 18 deletions
+2 -2
View File
@@ -61,7 +61,7 @@ class TestClient(testtools.TestCase):
# rather than assertRaises() so that we can check the body of
# the exception.
self.fail('An exception should have bypassed this line.')
except exc.CommunicationError, comm_err:
except exc.CommunicationError as comm_err:
fail_msg = ("Exception message '%s' should contain '%s'" %
(comm_err.message, self.endpoint))
self.assertTrue(self.endpoint in comm_err.message, fail_msg)
@@ -100,7 +100,7 @@ class TestClient(testtools.TestCase):
client.raw_request('GET', '/v1/images/detail?limit=20')
self.fail('An exception should have bypassed this line.')
except exc.CommunicationError, comm_err:
except exc.CommunicationError as comm_err:
fail_msg = ("Exception message '%s' should contain '%s'" %
(comm_err.message, endpoint))
self.assertTrue(endpoint in comm_err.message, fail_msg)
+2 -2
View File
@@ -27,7 +27,7 @@ class TestUtils(testtools.TestCase):
try:
data = ''.join([f for f in utils.integrity_iter('A', None)])
self.fail('integrity checked passed without checksum.')
except IOError, e:
except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was 7fc56270e7a70fa81a5935b72eacbe29 expected None'
self.assertTrue(msg in str(e))
@@ -36,7 +36,7 @@ class TestUtils(testtools.TestCase):
try:
data = ''.join([f for f in utils.integrity_iter('BB', 'wrong')])
self.fail('integrity checked passed with wrong checksum')
except IOError, e:
except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was 9d3d9048db16a7eee539e93e3618cbe7 expected wrong'
self.assertTrue('expected wrong' in str(e))
+2 -2
View File
@@ -333,7 +333,7 @@ class ImageManagerTest(testtools.TestCase):
try:
data = ''.join([b for b in data])
self.fail('data did not raise an error.')
except IOError, e:
except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
self.assertTrue(msg in str(e))
@@ -507,7 +507,7 @@ class ImageTest(testtools.TestCase):
try:
data = ''.join([b for b in image.data()])
self.fail('data did not raise an error.')
except IOError, e:
except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was fd7c5c4fdaa97163ee4ba8842baa537a expected wrong'
self.assertTrue(msg in str(e))
+1 -1
View File
@@ -289,7 +289,7 @@ class TestController(testtools.TestCase):
try:
body = ''.join([b for b in body])
self.fail('data did not raise an error.')
except IOError, e:
except IOError as e:
self.assertEqual(errno.EPIPE, e.errno)
msg = 'was 9d3d9048db16a7eee539e93e3618cbe7 expected wrong'
self.assertTrue(msg in str(e))