From c3fcc784dbd874aef3034395921015bf8379427c Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Fri, 19 Nov 2021 13:40:11 -0700 Subject: [PATCH 1/2] Fix mock in broken test --- tests/unittests/test_distros/test_netconfig.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index d09e46af71d..535f83ece24 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -767,7 +767,9 @@ def test_apply_network_config_v1_without_netplan(self): expected_cfgs=expected_cfgs.copy(), with_netplan=False) - def test_apply_network_config_v1_with_netplan(self): + @mock.patch('cloudinit.util.is_DragonFlyBSD', return_value=False) + @mock.patch('cloudinit.util.is_FreeBSD', return_value=False) + def test_apply_network_config_v1_with_netplan(self, *args): expected_cfgs = { self.netplan_path(): dedent("""\ # generated by cloud-init @@ -782,12 +784,10 @@ def test_apply_network_config_v1_with_netplan(self): dhcp4: true """), } - - with mock.patch('cloudinit.util.is_FreeBSD', return_value=False): - self._apply_and_verify(self.distro.apply_network_config, - V1_NET_CFG, - expected_cfgs=expected_cfgs.copy(), - with_netplan=True) + self._apply_and_verify(self.distro.apply_network_config, + V1_NET_CFG, + expected_cfgs=expected_cfgs.copy(), + with_netplan=True) class TestNetCfgDistroPhoton(TestNetCfgDistroBase): From 3959752a4072f7626aeec73ca16a69900b61b4e5 Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Fri, 19 Nov 2021 13:51:39 -0700 Subject: [PATCH 2/2] future-proof this fix --- tests/unittests/test_distros/test_netconfig.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index 535f83ece24..88f2697785b 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -767,8 +767,7 @@ def test_apply_network_config_v1_without_netplan(self): expected_cfgs=expected_cfgs.copy(), with_netplan=False) - @mock.patch('cloudinit.util.is_DragonFlyBSD', return_value=False) - @mock.patch('cloudinit.util.is_FreeBSD', return_value=False) + @mock.patch('cloudinit.util.system_info', return_value={'variant': 'bsd'}) def test_apply_network_config_v1_with_netplan(self, *args): expected_cfgs = { self.netplan_path(): dedent("""\