summaryrefslogtreecommitdiffstats
path: root/test/lib/ansible_test/_internal/util.py
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-08-03 01:59:14 +0200
committerGitHub <noreply@github.com>2022-08-03 01:59:14 +0200
commitd8fefba20e8023822749d538db7e69f0fc86710e (patch)
treee368f320dbfb27bbd8ee70228624dbff17e2e914 /test/lib/ansible_test/_internal/util.py
parentAnsible 6.2.0: porting_guide changes (#78408) (diff)
downloadansible-d8fefba20e8023822749d538db7e69f0fc86710e.tar.xz
ansible-d8fefba20e8023822749d538db7e69f0fc86710e.zip
ansible-test - Update locale logic to match core. (#78389)
Now that core requires UTF-8 filesystem encoding, ansible-test does as well. Additionally, the `en_US.UTF-8` or `C.UTF-8` encoding must be available. Previously the `en_US.UTF-8` encoding was requested, but its availability was never verified. The fallback to `C.UTF-8` maintains UTF-8 encoding while allowing more flexibility in the running environment.
Diffstat (limited to 'test/lib/ansible_test/_internal/util.py')
-rw-r--r--test/lib/ansible_test/_internal/util.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/lib/ansible_test/_internal/util.py b/test/lib/ansible_test/_internal/util.py
index 17a88adb98..ec03c0cc6e 100644
--- a/test/lib/ansible_test/_internal/util.py
+++ b/test/lib/ansible_test/_internal/util.py
@@ -32,6 +32,11 @@ try:
except ImportError:
TypeGuard = None
+from .locale_util import (
+ LOCALE_WARNING,
+ CONFIGURED_LOCALE,
+)
+
from .encoding import (
to_bytes,
to_optional_bytes,
@@ -611,7 +616,7 @@ class OutputThread(ReaderThread):
def common_environment():
"""Common environment used for executing all programs."""
env = dict(
- LC_ALL='en_US.UTF-8',
+ LC_ALL=CONFIGURED_LOCALE,
PATH=os.environ.get('PATH', os.path.defpath),
)
@@ -651,6 +656,15 @@ def common_environment():
return env
+def report_locale() -> None:
+ """Report the configured locale and the locale warning, if applicable."""
+
+ display.info(f'Configured locale: {CONFIGURED_LOCALE}', verbosity=1)
+
+ if LOCALE_WARNING:
+ display.warning(LOCALE_WARNING)
+
+
def pass_vars(required, optional): # type: (t.Collection[str], t.Collection[str]) -> t.Dict[str, str]
"""Return a filtered dictionary of environment variables based on the current environment."""
env = {}