diff options
author | Eric Brown <browne@vmware.com> | 2016-01-13 12:36:01 -0800 |
---|---|---|
committer | Eric Brown <browne@vmware.com> | 2016-01-17 03:32:34 +0000 |
commit | dd19bc143b700f4c51188a40d35f29764ec83a23 (patch) | |
tree | 8f108a740411c1cf7f3329994cc1c17e2e22ef30 /nova/test.py | |
parent | deb1ee440923b0b292f3536a2f8bda672c03984a (diff) | |
download | nova-dd19bc143b700f4c51188a40d35f29764ec83a23.tar.gz |
Use of six.PY3 should be forward compatible
Care should be taken in using a condition like so:
if six.PY3:
foo()
else:
bar()
This assumes PY2 and PY4 would behave the same. Rather the
conditional should check for PY2 and use the else for PY3 and
future versions of Python.
http://astrofrog.github.io/blog/2016/01/12/stop-writing-python-4-incompatible-code/
Change-Id: I9bc00e2f01fe8fe970d6c5327207c08a90885cda
Diffstat (limited to 'nova/test.py')
-rw-r--r-- | nova/test.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/nova/test.py b/nova/test.py index cffaed044e..ca0adec707 100644 --- a/nova/test.py +++ b/nova/test.py @@ -63,13 +63,13 @@ logging.setup(CONF, 'nova') _TRUE_VALUES = ('True', 'true', '1', 'yes') -if six.PY3: +if six.PY2: + nested = contextlib.nested +else: @contextlib.contextmanager def nested(*contexts): with contextlib.ExitStack() as stack: yield [stack.enter_context(c) for c in contexts] -else: - nested = contextlib.nested class SampleNetworks(fixtures.Fixture): |