mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #33670 from rallytime/fix-33605
Handle non-ascii package names in state.format_log
This commit is contained in:
commit
a5684ed123
2 changed files with 49 additions and 2 deletions
|
@ -233,8 +233,9 @@ def format_log(ret):
|
|||
new = chg[pkg]['new']
|
||||
if not new and new not in (False, None):
|
||||
new = 'absent'
|
||||
msg += '\'{0}\' changed from \'{1}\' to ' \
|
||||
'\'{2}\'\n'.format(pkg, old, new)
|
||||
# This must be able to handle unicode as some package names contain
|
||||
# non-ascii characters like "Français" or "Español". See Issue #33605.
|
||||
msg += u'\'{0}\' changed from \'{1}\' to \'{2}\'\n'.format(pkg, old, new)
|
||||
if not msg:
|
||||
msg = str(ret['changes'])
|
||||
if ret['result'] is True or ret['result'] is None:
|
||||
|
|
46
tests/unit/state_test.py
Normal file
46
tests/unit/state_test.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
:codeauthor: :email:`Nicole Thomas <nicole@saltstack.com>`
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting import TestCase, skipIf
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
from salttesting.mock import (
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON,
|
||||
)
|
||||
|
||||
ensure_in_syspath('../')
|
||||
|
||||
# Import Salt libs
|
||||
from salt import state
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class StateCompilerTestCase(TestCase):
|
||||
'''
|
||||
TestCase for the state compiler.
|
||||
'''
|
||||
|
||||
def test_format_log_non_ascii_character(self):
|
||||
'''
|
||||
Tests running a non-ascii character through the state.format_log
|
||||
function. See Issue #33605.
|
||||
'''
|
||||
# There is no return to test against as the format_log
|
||||
# function doesn't return anything. However, we do want
|
||||
# to make sure that the function doesn't stacktrace when
|
||||
# called.
|
||||
ret = {'changes': {u'Français': {'old': 'something old',
|
||||
'new': 'something new'}},
|
||||
'result': True}
|
||||
state.format_log(ret)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(StateCompilerTestCase, needs_daemon=False)
|
Loading…
Add table
Reference in a new issue