From 1f76a9061db2fe096db3c4f15738549e284c9a61 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Fri, 24 Jul 2015 15:52:42 +0200 Subject: [PATCH] Python 3: fix test_dhcp In Python 3, dhcp.LOG.process is not called when calling dhcp.LOG.debug. Since what we really want to know is whether dhcp.LOG.debug is called, tweak the test a little. Change-Id: I9c9d9a6162181d6e518a603193013c28e218cdee Blueprint: neutron-python3 --- neutron/tests/unit/agent/linux/test_dhcp.py | 6 +++--- tox.ini | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py index 8c5a5d19a..9a6115df8 100644 --- a/neutron/tests/unit/agent/linux/test_dhcp.py +++ b/neutron/tests/unit/agent/linux/test_dhcp.py @@ -1652,13 +1652,13 @@ class TestDnsmasq(TestBase): def test__output_hosts_file_log_only_twice(self): dm = self._get_dnsmasq(FakeDualStackNetworkSingleDHCP()) - with mock.patch.object(dhcp.LOG, 'process') as process: - process.return_value = ('fake_message', {}) + with mock.patch.object(dhcp, 'LOG') as logger: + logger.process.return_value = ('fake_message', {}) dm._output_hosts_file() # The method logs twice, at the start of and the end. There should be # no other logs, no matter how many hosts there are to dump in the # file. - self.assertEqual(2, process.call_count) + self.assertEqual(2, len(logger.method_calls)) def test_only_populates_dhcp_enabled_subnets(self): exp_host_name = '/dhcp/eeeeeeee-eeee-eeee-eeee-eeeeeeeeeeee/host' diff --git a/tox.ini b/tox.ini index e9223ef5f..639ca8b86 100644 --- a/tox.ini +++ b/tox.ini @@ -201,6 +201,7 @@ commands = python -m testtools.run \ neutron.tests.unit.agent.linux.test_ip_monitor \ neutron.tests.unit.agent.linux.test_iptables_manager \ neutron.tests.unit.agent.linux.test_external_process \ + neutron.tests.unit.agent.linux.test_dhcp \ neutron.tests.unit.agent.linux.test_async_process \ neutron.tests.unit.agent.linux.test_ovsdb_monitor \ neutron.tests.unit.agent.linux.test_bridge_lib \ -- 2.45.2