]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Python 3: fix test_ovs_tunnel
authorCyril Roelandt <cyril@redhat.com>
Fri, 21 Aug 2015 10:19:30 +0000 (12:19 +0200)
committerCyril Roelandt <cyril@redhat.com>
Fri, 21 Aug 2015 10:19:30 +0000 (12:19 +0200)
In Python 3, __bool__ should be used instead of __nonzero__.

Change-Id: I04b688a6ac079a161bd888c53b8b98b574171ea9
Blueprint: neutron-python3

neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py
tox.ini

index 315360b8a7353d8b5dd304a300ad40ac8b33595f..3da5cb58f684cecfc828d0be1c324ce4c34d6b0e 100644 (file)
@@ -19,6 +19,7 @@ import time
 import mock
 from oslo_config import cfg
 from oslo_log import log
+import six
 
 from neutron.agent.common import ovs_lib
 from neutron.agent.linux import ip_lib
@@ -28,6 +29,12 @@ from neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent \
     import ovs_test_base
 
 
+def nonzero(f):
+    if six.PY3:
+        return f.__bool__()
+    else:
+        return f.__nonzero__()
+
 # Useful global dummy variables.
 NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7'
 LS_ID = 420
@@ -203,15 +210,15 @@ class TunnelTest(object):
         self.mock_tun_bridge_expected = [
             mock.call.set_agent_uuid_stamp(mock.ANY),
             mock.call.bridge_exists('br-tun'),
-            mock.call.bridge_exists().__nonzero__(),
+            nonzero(mock.call.bridge_exists()),
             mock.call.setup_controllers(mock.ANY),
             mock.call.port_exists('patch-int'),
-            mock.call.port_exists().__nonzero__(),
+            nonzero(mock.call.port_exists()),
             mock.call.add_patch_port('patch-int', 'patch-tun'),
         ]
         self.mock_int_bridge_expected += [
             mock.call.port_exists('patch-tun'),
-            mock.call.port_exists().__nonzero__(),
+            nonzero(mock.call.port_exists()),
             mock.call.add_patch_port('patch-tun', 'patch-int'),
         ]
         self.mock_int_bridge_expected += [
@@ -609,15 +616,15 @@ class TunnelTestUseVethInterco(TunnelTest):
         self.mock_tun_bridge_expected = [
             mock.call.set_agent_uuid_stamp(mock.ANY),
             mock.call.bridge_exists('br-tun'),
-            mock.call.bridge_exists().__nonzero__(),
+            nonzero(mock.call.bridge_exists()),
             mock.call.setup_controllers(mock.ANY),
             mock.call.port_exists('patch-int'),
-            mock.call.port_exists().__nonzero__(),
+            nonzero(mock.call.port_exists()),
             mock.call.add_patch_port('patch-int', 'patch-tun'),
         ]
         self.mock_int_bridge_expected += [
             mock.call.port_exists('patch-tun'),
-            mock.call.port_exists().__nonzero__(),
+            nonzero(mock.call.port_exists()),
             mock.call.add_patch_port('patch-tun', 'patch-int')
         ]
         self.mock_int_bridge_expected += [
diff --git a/tox.ini b/tox.ini
index 233f3fcfa924870c8c11f78041e233c79c19d847..6a6a6153b05c8e37345c02e1c630b2077bd9b5c3 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -115,6 +115,7 @@ commands = python -m testtools.run \
     neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.test_br_int \
     neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.test_br_tun \
     neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.test_agent_scheduler \
+    neutron.tests.unit.plugins.ml2.drivers.openvswitch.agent.test_ovs_tunnel \
     neutron.tests.unit.plugins.brocade.test_brocade_db \
     neutron.tests.unit.plugins.brocade.test_brocade_plugin \
     neutron.tests.unit.plugins.brocade.test_brocade_vlan \