[Libosinfo] [PATCH osinfo-db 3/3] tests: conftest: set locale in test code

Daniel P. Berrangé berrange at redhat.com
Fri Mar 29 09:49:49 UTC 2019


On Thu, Mar 28, 2019 at 04:55:34PM -0400, Cole Robinson wrote:
> This fixes the locale setup with direct pytest-3 invocations
> 
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
>  Makefile          | 2 +-
>  tests/conftest.py | 4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index b3e06d5..4f6f8d4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -121,4 +121,4 @@ update-po:
>          done
>  
>  check: $(DATA_FILES) $(SCHEMA_FILES)
> -	LC_ALL= LANG=C LC_CTYPE=en_US.UTF-8 $(PYTHON) -m pytest
> +	$(PYTHON) -m pytest
> diff --git a/tests/conftest.py b/tests/conftest.py
> index 4a16a04..ade36c5 100644
> --- a/tests/conftest.py
> +++ b/tests/conftest.py
> @@ -1,6 +1,7 @@
>  # This work is licensed under the GNU GPLv2 or later.
>  # See the COPYING file in the top-level directory.
>  
> +import locale
>  import os
>  
>  
> @@ -16,6 +17,9 @@ def pytest_configure(config):
>          os.environ[key] = os.path.realpath(os.path.join(
>              os.path.dirname(__file__), "..", "data"))
>  
> +    # Needed for test reproducibility on freebsd

This isn't a freebsd problem. It will hit any user who is not using a
UTF-8 locale.

> +    locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8')
> +
>      # Default to --log-level=info if not otherwise specified
>      if (hasattr(config.option, "log_level") and
>          config.option.log_level is None):

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the Libosinfo mailing list