Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set fixed locale in tests #12

Merged
merged 2 commits into from Aug 26, 2022
Merged

Set fixed locale in tests #12

merged 2 commits into from Aug 26, 2022

Conversation

LEdoian
Copy link

@LEdoian LEdoian commented Jun 4, 2022

Test used local names of months, causing a fail.

To reproduce original issue, run LC_TIME=ja_JP.UTF-8 pytest on branch main. Fails with

>       assert "Released 24-Feb" in result
E       AssertionError: assert 'Released 24-Feb' in '\n\n1.0\n---\n\nCopyright 2015\nReleased 24- 2月\n\nSome details\n'

test_all.py:115: AssertionError

Does not happen anymore with this fix.

An alternative would be to only set the locale in the specific test or only set LC_TIME, but I believe this creates more stable testing environment overall.

@jaraco
Copy link
Owner

jaraco commented Aug 26, 2022

I tried replicating the issue, but was unable to, either on my mac or on Ubuntu 22.04:

<user>@8ad8585efe82 /src main [1] # env LC_TIME=ja_JP.UTF-8 /tox/python/bin/pytest
=============================================================== test session starts ================================================================
platform linux -- Python 3.11.0rc1, pytest-7.1.2, pluggy-1.0.0
rootdir: /src, configfile: pytest.ini
plugins: black-0.3.12, mypy-0.9.1, flake8-1.1.1, cov-3.0.0, enabler-1.3.0, checkdocs-2.7.1
collected 21 items                                                                                                                                 

. .                                                                                                                                          [  5%]
test_all.py ..........                                                                                                                       [ 55%]
docs/conf.py ...                                                                                                                             [ 70%]
rst/__init__.py ...                                                                                                                          [ 85%]
rst/linker.py ...                                                                                                                            [100%]

-------- coverage: platform linux, python 3.11.0-candidate-1 ---------
Name                               Stmts   Miss  Cover   Missing
----------------------------------------------------------------
/etc/python3.11/sitecustomize.py       0      0   100%
docs/conf.py                           6      0   100%
rst/__init__.py                        1      0   100%
rst/linker.py                        107     27    75%   14-15, 34, 100, 128-129, 138-141, 176-178, 184-185, 193, 201, 205-213, 217
test_all.py                           56      1    98%   71
----------------------------------------------------------------
TOTAL                                170     28    84%

======================================================================= mypy =======================================================================

Success: no issues found in 4 source files
=============================================================== 20 passed in 11.01s ================================================================

@jaraco jaraco merged commit 973176c into jaraco:main Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants