mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #53680 from Ch3LL/pytest_5_changes
Pytest 5.0 contextmanager str: call value on ExceptionInfo objects
This commit is contained in:
commit
f5c5da4ed9
2 changed files with 11 additions and 11 deletions
|
@ -1310,7 +1310,7 @@ class FilemodLineTests(TestCase, LoaderModuleMockMixin):
|
|||
for mode, err_msg in [(None, 'How to process the file'), ('nonsense', 'Unknown mode')]:
|
||||
with pytest.raises(CommandExecutionError) as cmd_err:
|
||||
filemod.line('foo', mode=mode)
|
||||
self.assertIn(err_msg, six.text_type(cmd_err))
|
||||
self.assertIn(err_msg, six.text_type(cmd_err.value))
|
||||
|
||||
@patch('os.path.realpath', MagicMock(wraps=lambda x: x))
|
||||
@patch('os.path.isfile', MagicMock(return_value=True))
|
||||
|
@ -1323,7 +1323,7 @@ class FilemodLineTests(TestCase, LoaderModuleMockMixin):
|
|||
with pytest.raises(CommandExecutionError) as cmd_err:
|
||||
filemod.line('foo', mode=mode)
|
||||
self.assertIn('Content can only be empty if mode is "delete"',
|
||||
six.text_type(cmd_err))
|
||||
six.text_type(cmd_err.value))
|
||||
|
||||
@patch('os.path.realpath', MagicMock(wraps=lambda x: x))
|
||||
@patch('os.path.isfile', MagicMock(return_value=True))
|
||||
|
@ -1338,7 +1338,7 @@ class FilemodLineTests(TestCase, LoaderModuleMockMixin):
|
|||
with pytest.raises(CommandExecutionError) as cmd_err:
|
||||
filemod.line('foo', content='test content', mode='insert')
|
||||
self.assertIn('"location" or "before/after"',
|
||||
six.text_type(cmd_err))
|
||||
six.text_type(cmd_err.value))
|
||||
|
||||
def test_util_starts_till(self):
|
||||
'''
|
||||
|
@ -1948,7 +1948,7 @@ class FilemodLineTests(TestCase, LoaderModuleMockMixin):
|
|||
filemod.line('foo', content=cfg_content, after=_after, before=_before, mode='ensure')
|
||||
self.assertIn(
|
||||
'Found more than one line between boundaries "before" and "after"',
|
||||
six.text_type(cmd_err))
|
||||
six.text_type(cmd_err.value))
|
||||
|
||||
@with_tempfile()
|
||||
def test_line_delete(self, name):
|
||||
|
|
|
@ -162,7 +162,7 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod._localectl_status()
|
||||
assert 'Unable to find "localectl"' in six.text_type(err)
|
||||
assert 'Unable to find "localectl"' in six.text_type(err.value)
|
||||
assert not localemod.log.debug.called
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/localctl"))
|
||||
|
@ -170,14 +170,14 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
def test_localectl_status_parser_empty(self):
|
||||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod._localectl_status()
|
||||
assert 'Unable to parse result of "localectl"' in six.text_type(err)
|
||||
assert 'Unable to parse result of "localectl"' in six.text_type(err.value)
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/localctl"))
|
||||
@patch('salt.modules.localemod.__salt__', {'cmd.run': MagicMock(return_value=locale_ctl_out_broken)})
|
||||
def test_localectl_status_parser_broken(self):
|
||||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod._localectl_status()
|
||||
assert 'Unable to parse result of "localectl"' in six.text_type(err)
|
||||
assert 'Unable to parse result of "localectl"' in six.text_type(err.value)
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/localctl"))
|
||||
@patch('salt.modules.localemod.__salt__', {'cmd.run': MagicMock(return_value=locale_ctl_out_structure)})
|
||||
|
@ -295,7 +295,7 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod.get_locale()
|
||||
assert '"DrunkDragon" is unsupported' in six.text_type(err)
|
||||
assert '"DrunkDragon" is unsupported' in six.text_type(err.value)
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value="/usr/bin/localctl"))
|
||||
@patch('salt.modules.localemod.__grains__', {'os_family': 'Ubuntu', 'osmajorrelease': 42})
|
||||
|
@ -398,7 +398,7 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod.set_locale(loc)
|
||||
assert not localemod._localectl_set.called
|
||||
assert 'Cannot set locale: "update-locale" was not found.' in six.text_type(err)
|
||||
assert 'Cannot set locale: "update-locale" was not found.' in six.text_type(err.value)
|
||||
|
||||
@patch('salt.utils.path.which', MagicMock(return_value=None))
|
||||
@patch('salt.modules.localemod.__grains__', {'os_family': 'Gentoo', 'osmajorrelease': 42})
|
||||
|
@ -469,7 +469,7 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod.set_locale('de_DE.utf8')
|
||||
assert 'Unsupported platform' in six.text_type(err)
|
||||
assert 'Unsupported platform' in six.text_type(err.value)
|
||||
|
||||
@patch('salt.utils.locales.normalize_locale', MagicMock(return_value='en_US.UTF-8 UTF-8'))
|
||||
@patch('salt.modules.localemod.__salt__', {'locale.list_avail': MagicMock(return_value=['A', 'B'])})
|
||||
|
@ -539,7 +539,7 @@ class LocalemodTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
with pytest.raises(CommandExecutionError) as err:
|
||||
localemod.gen_locale('de_DE.utf8')
|
||||
assert 'Command "locale-gen" or "localedef" was not found on this system.' in six.text_type(err)
|
||||
assert 'Command "locale-gen" or "localedef" was not found on this system.' in six.text_type(err.value)
|
||||
|
||||
def test_gen_locale_debian(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue