]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Python 3: fix test_dhcp
authorCyril Roelandt <cyril@redhat.com>
Fri, 24 Jul 2015 13:52:42 +0000 (15:52 +0200)
committerCyril Roelandt <cyril@redhat.com>
Tue, 28 Jul 2015 15:02:44 +0000 (17:02 +0200)
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
tox.ini

index 8c5a5d19a997d4f5661150d93ad1e53145c12d55..9a6115df8e89bd9f29e1ebe49dd7dd0ac3ba7ad1 100644 (file)
@@ -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 e9223ef5f89b520005c2c4201d299d14e676eaf3..639ca8b864fd0772c47882c2ccd4316e68c9243d 100644 (file)
--- 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 \