Skip to content

Commit d4b6b67

Browse files
committed
tests: Don't fail if we can't set locale
Instead just print an error. This can happen in Fedora buildroots Signed-off-by: Cole Robinson <[email protected]>
1 parent 0fa3c5d commit d4b6b67

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/conftest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
import bugzilla
1414

1515

16-
# Use consistent locale for tests
17-
locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8')
18-
19-
2016
# pytest plugin adding custom options. Hooks are documented here:
2117
# https://docs.pytest.org/en/latest/writing_plugins.html
2218

@@ -61,6 +57,13 @@ def pytest_ignore_collect(path, config):
6157

6258

6359
def pytest_configure(config):
60+
try:
61+
# Needed for test reproducibility on systems not using a UTF-8 locale
62+
locale.setlocale(locale.LC_ALL, 'C')
63+
locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8')
64+
except Exception as e:
65+
print("Error setting locale: %s" % str(e))
66+
6467
if config.getoption("--redhat-url"):
6568
tests.CLICONFIG.REDHAT_URL = config.getoption("--redhat-url")
6669
if config.getoption("--pybz-debug"):

0 commit comments

Comments
 (0)