summaryrefslogtreecommitdiffstats
path: root/test/units/utils
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2022-07-11 16:22:27 +0200
committerGitHub <noreply@github.com>2022-07-11 16:22:27 +0200
commitb1dd2af4cac9df517ce8216eaa97e66c0b15d90a (patch)
treea1c4a1e11675aa9c73c74f91bc00ea108152fa35 /test/units/utils
parentRemove unnecessary special case in Role.load_data (#78181) (diff)
downloadansible-b1dd2af4cac9df517ce8216eaa97e66c0b15d90a.tar.xz
ansible-b1dd2af4cac9df517ce8216eaa97e66c0b15d90a.zip
Preflight utf8 encodings check (#78175)
Diffstat (limited to 'test/units/utils')
-rw-r--r--test/units/utils/test_display.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/units/utils/test_display.py b/test/units/utils/test_display.py
index f0a6b6eefb..34e39b6f61 100644
--- a/test/units/utils/test_display.py
+++ b/test/units/utils/test_display.py
@@ -5,17 +5,17 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
+import locale
from unittest.mock import MagicMock
import pytest
-from ansible.module_utils.six import PY3
-from ansible.utils.display import Display, get_text_width, initialize_locale
+from ansible.utils.display import Display, get_text_width
from ansible.utils.multiprocessing import context as multiprocessing_context
def test_get_text_width():
- initialize_locale()
+ locale.setlocale(locale.LC_ALL, '')
assert get_text_width(u'コンニチハ') == 10
assert get_text_width(u'abコcd') == 6
assert get_text_width(u'café') == 4
@@ -35,13 +35,13 @@ def test_get_text_width():
pytest.raises(TypeError, get_text_width, b'four')
-@pytest.mark.skipif(PY3, reason='Fallback only happens reliably on py2')
def test_get_text_width_no_locale():
- pytest.raises(EnvironmentError, get_text_width, u'🚀🐮')
+ locale.setlocale(locale.LC_ALL, 'C.UTF-8')
+ pytest.raises(EnvironmentError, get_text_width, '\U000110cd')
def test_Display_banner_get_text_width(monkeypatch):
- initialize_locale()
+ locale.setlocale(locale.LC_ALL, '')
display = Display()
display_mock = MagicMock()
monkeypatch.setattr(display, 'display', display_mock)
@@ -53,16 +53,16 @@ def test_Display_banner_get_text_width(monkeypatch):
assert msg.endswith(stars)
-@pytest.mark.skipif(PY3, reason='Fallback only happens reliably on py2')
def test_Display_banner_get_text_width_fallback(monkeypatch):
+ locale.setlocale(locale.LC_ALL, 'C.UTF-8')
display = Display()
display_mock = MagicMock()
monkeypatch.setattr(display, 'display', display_mock)
- display.banner(u'🚀🐮', color=False, cows=False)
+ display.banner(u'\U000110cd', color=False, cows=False)
args, kwargs = display_mock.call_args
msg = args[0]
- stars = u' %s' % (77 * u'*')
+ stars = u' %s' % (78 * u'*')
assert msg.endswith(stars)