Python 3: fix test_ovs_tunnel

In Python 3, __bool__ should be used instead of __nonzero__.

Change-Id: I04b688a6ac079a161bd888c53b8b98b574171ea9
Blueprint: neutron-python3
This commit is contained in:
Cyril Roelandt 2015-08-21 12:19:30 +02:00
parent 40576ae09c
commit 6f76ca6b90
2 changed files with 14 additions and 6 deletions

View 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 += [

View File

@ -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 \