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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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
> +    locale.setlocale(locale.LC_CTYPE, 'en_US.UTF-8')

This doesn't actually do the same as the makefile code. This still uses
the user's own locale for everything that isn't LC_CTYPE. The make code
explicitly forced C locale to ensure reproducable environment that does
not vary per user locale.

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 :|

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux