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
This commit is contained in:
James Page 2018-06-15 14:24:13 +01:00
parent 26bfa08b23
commit bd61eadba2
1 changed files with 5 additions and 4 deletions

View File

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