Skip to content

Commit c756f55

Browse files
authored
ci: Fix packit RPM build locale errors (#196)
Be more thorough trying to find a UTF-8 locale in minimal fedora buildroot Lifted from https://gitlab.com/libosinfo/osinfo-db Signed-off-by: Cole Robinson <[email protected]>
1 parent 182e0b0 commit c756f55

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

tests/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ def pytest_ignore_collect(path, config):
5252

5353

5454
def pytest_configure(config):
55-
try:
56-
# Needed for test reproducibility on systems not using a UTF-8 locale
57-
locale.setlocale(locale.LC_ALL, 'C')
58-
locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8')
59-
except Exception as e:
60-
print("Error setting locale: %s" % str(e))
55+
# Needed for test reproducibility on any system not using a UTF-8 locale
56+
locale.setlocale(locale.LC_ALL, "C")
57+
for loc in ["C.UTF-8", "C.utf8", "UTF-8", "en_US.UTF-8"]:
58+
try:
59+
locale.setlocale(locale.LC_CTYPE, loc)
60+
break
61+
except locale.Error:
62+
pass
63+
else:
64+
raise locale.Error("No UTF-8 locale found")
6165

6266
if config.getoption("--redhat-url"):
6367
tests.CLICONFIG.REDHAT_URL = config.getoption("--redhat-url")

0 commit comments

Comments
 (0)