mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Make sure we're using the opts dict mocking in parsers_test
The additional call to parser.parse_args(args) negates the first patch to running self.config_func. We want the opts that we set up in the above test to patch the setup args when the parse_args func is called. This updates the mock to work with better with patch and removes the additional parser.parse_args call.
This commit is contained in:
parent
315b2c8712
commit
ce6d1b103d
1 changed files with 7 additions and 5 deletions
|
@ -700,15 +700,17 @@ class SaltKeyOptionParserTestCase(LogSettingsParserTests):
|
|||
log_level = 'info'
|
||||
args = self.args
|
||||
|
||||
# Set log level in config
|
||||
opts = {self.loglevel_config_setting_name: log_level}
|
||||
# Set log level in config and set additional mocked opts keys
|
||||
opts = {self.loglevel_config_setting_name: log_level,
|
||||
self.logfile_config_setting_name: 'key_logfile',
|
||||
'log_fmt_logfile': None,
|
||||
'log_datefmt_logfile': None}
|
||||
|
||||
parser = self.parser()
|
||||
with patch(self.config_func, MagicMock(return_value=opts)):
|
||||
parser.parse_args(args)
|
||||
with patch('salt.utils.parsers.is_writeable', MagicMock(return_value=True)):
|
||||
parser.parse_args(args)
|
||||
parser.setup_logfile_logger()
|
||||
with patch('salt.utils.parsers.is_writeable', MagicMock(return_value=True)):
|
||||
parser.setup_logfile_logger()
|
||||
|
||||
# Check config name absence in options
|
||||
self.assertNotIn(self.loglevel_config_setting_name, parser.options.__dict__)
|
||||
|
|
Loading…
Add table
Reference in a new issue