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 3/29/19 11:48 AM, Cole Robinson wrote:
> On 3/29/19 5:52 AM, Daniel P. Berrangé wrote:
>> 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.
>>
> 
> Okay I think prepending locale.setlocale(locale.LC_ALL, 'C') will
> accomplish the same though I don't really know the details of how it
> propagates through the stack. Does that sound okay + fixing the comment?
> Fabiano pushed the patch so I can send a follow up
> 
> The main goal is to avoid the need to run with an environment variable
> so direct pytest invocation is as valid as 'make check'. The former
> gives much more flexibility
> 

Nevermind I should have checked my libosinfo folder, fabiano sent that
exact followup

- Cole

_______________________________________________
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