From bd61eadba21f1bc2bda7c43255c6865456326e80 Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 15 Jun 2018 14:24:13 +0100 Subject: [PATCH] Improve patching of sys.argv More in-depth type checking of args in Python 3.6 causes issues with the current approach to patching sys.argv for agent unit tests; Directly patch argv with the required test arguments rather than using return_value (which does not really do what the test assumes it does). Change-Id: I8966323e3f0853351fe27207ae63901c2f9f351a --- .../tests/unit/services/bgp/agent/test_bgp_dragent.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py b/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py index f10965c9..aa89a184 100644 --- a/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py +++ b/neutron_dynamic_routing/tests/unit/services/bgp/agent/test_bgp_dragent.py @@ -81,10 +81,11 @@ class TestBgpDrAgent(base.BaseTestCase): 'sync_state', autospec=True) as mock_sync_state: with mock.patch(state_rpc_str) as state_rpc: - with mock.patch.object(sys, 'argv') as sys_argv: - sys_argv.return_value = [ - 'bgp_dragent', '--config-file', - base.etcdir('neutron.conf')] + test_args = [ + 'bgp_dragent', '--config-file', + base.etcdir('neutron.conf') + ] + with mock.patch.object(sys, 'argv', test_args): config.register_agent_state_opts_helper(cfg.CONF) n_config.init(sys.argv[1:]) agent_mgr = bgp_dragent.BgpDrAgentWithStateReport(