Skip to content

Commit ad70f51

Browse files
committed
Update tests
Signed-off-by: paulober <[email protected]>
1 parent 185bd6e commit ad70f51

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cloudinit/distros/debian.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def apply_locale(self, locale, out_fn=None, keyname="LANG"):
8787

8888
if not locale:
8989
raise ValueError("Failed to provide locale value.")
90-
90+
9191
# Make sure it has a charset for system commands to work
9292
locale = _normalize_locale(locale)
9393

@@ -302,7 +302,9 @@ def _normalize_locale(requested: str) -> str:
302302

303303
# Accept canonical “no-regeneration” values as-is
304304
if req.lower() in ("c", "posix", "c.utf-8", "c.utf8"):
305-
return "C.UTF-8" if req.lower() != "c" and "utf" in req.lower() else "C"
305+
return (
306+
"C.UTF-8" if req.lower() != "c" and "utf" in req.lower() else "C"
307+
)
306308

307309
# If no charset specified, default to UTF-8
308310
if "." not in req and "@" not in req:

tests/unittests/config/test_cc_locale.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
2+
# Copyright (C) 2025 Raspberry Pi Ltd.
23
#
34
# Author: Juerg Haefliger <[email protected]>
5+
# Author: Paul Oberosler <[email protected]>
46
#
57
# This file is part of cloud-init. See LICENSE file for license information.
68
import logging
@@ -48,7 +50,13 @@ def test_set_locale_arch(self):
4850
contents = util.load_text_file(cc.distro.locale_gen_fn)
4951
assert "%s UTF-8" % locale in contents
5052
m_subp.assert_called_with(
51-
["localectl", "set-locale", locale], capture=False
53+
["localectl", "set-locale", locale],
54+
update_env={
55+
"LANG": "C.UTF-8",
56+
"LANGUAGE": "C.UTF-8",
57+
"LC_ALL": "C.UTF-8",
58+
},
59+
capture=False,
5260
)
5361

5462
@pytest.mark.parametrize(
@@ -122,6 +130,11 @@ def test_locale_update_config_if_different_than_default(self, tmpdir):
122130
"--locale-file=%s" % locale_conf.strpath,
123131
"LANG=C.UTF-8",
124132
],
133+
update_env={
134+
"LANG": "C.UTF-8",
135+
"LANGUAGE": "C.UTF-8",
136+
"LC_ALL": "C.UTF-8",
137+
},
125138
capture=False,
126139
)
127140
m_which.assert_called_once_with("update-locale")

0 commit comments

Comments
 (0)