Merge "Improve Python 3.x compatibility"
This commit is contained in:
19
HACKING.rst
19
HACKING.rst
@@ -211,6 +211,25 @@ Example::
|
||||
LOG.error(msg % {"s_id": "1234", "m_key": "imageId"})
|
||||
|
||||
|
||||
Python 3.x compatibility
|
||||
------------------------
|
||||
Nova code should stay Python 3.x compatible. That means all Python 2.x-only
|
||||
constructs should be avoided. An example is
|
||||
|
||||
except x,y:
|
||||
|
||||
Use
|
||||
|
||||
except x as y:
|
||||
|
||||
instead. Other Python 3.x compatility issues, like e.g. print operator
|
||||
can be avoided in new code by using
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
at the top of your module.
|
||||
|
||||
|
||||
Creating Unit Tests
|
||||
-------------------
|
||||
For every new feature, unit tests should be created that both test and
|
||||
|
||||
@@ -309,7 +309,7 @@ class ApiEc2TestCase(test.TestCase):
|
||||
|
||||
try:
|
||||
self.ec2.create_key_pair('test')
|
||||
except boto_exc.EC2ResponseError, e:
|
||||
except boto_exc.EC2ResponseError as e:
|
||||
if e.code == 'InvalidKeyPair.Duplicate':
|
||||
pass
|
||||
else:
|
||||
|
||||
@@ -219,7 +219,7 @@ class BaseMigrationTestCase(test.TestCase):
|
||||
for key, value in defaults.items():
|
||||
self.test_databases[key] = value
|
||||
self.snake_walk = cp.getboolean('walk_style', 'snake_walk')
|
||||
except ConfigParser.ParsingError, e:
|
||||
except ConfigParser.ParsingError as e:
|
||||
self.fail("Failed to read test_migrations.conf config "
|
||||
"file. Got error: %s" % e)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user