-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix unintended space after comma as a decimal separator #25226
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
Conversation
@rcomer Thanks for the suggestion! I have updated the PR. |
Thanks for the review! I have committed suggested changes. |
lib/matplotlib/tests/test_ticker.py
Outdated
@@ -1449,6 +1449,22 @@ def test_latex(self, is_latex, usetex, expected): | |||
assert fmt.format_pct(50, 100) == expected | |||
|
|||
|
|||
@pytest.mark.xfail(locale != "fy_DE.UTF-8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this condition; locale
is the imported module and can never equal a string.
Hi @QuLogic , I updated the test. |
lib/matplotlib/tests/test_ticker.py
Outdated
@@ -1449,6 +1449,23 @@ def test_latex(self, is_latex, usetex, expected): | |||
assert fmt.format_pct(50, 100) == expected | |||
|
|||
|
|||
@pytest.mark.xfail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm skeptical of adding an xfail test for this, it will likely go unnoticed if future changes affect this behavior.
Unfortunately, locale is very platform/install dependent behavior that makes this harder to work around.
My primary dev system, for instance (and seemingly our CI), does not have a fy_DE.UTF-8
.
I do have de_DE.UTF-8
, which I think has the same behavior regarding using commas as the decimal separator.
Even if we resort to xfail if the locale raises, I'd like to see something that at least passes on CI to prevent future regressions as best we can.
This could look something like:
try:
...
except locale.Error:
pytest.skip("Locale ... not supported on this machine")
finally:
locale.setlocale(locale.LC_ALL, currentLocale)
instead of using the pytest.mark.xfail
decorator.
(And then looking at the CI output to make sure that at least some of our CI (preferably all, but may not be easy) does not skip the test.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially wanted to add a pytest.warn
but that is being treated as a failure. I can see that pytest.skip
is also used in test_use_locale
. I'll update it according to your suggestion. Thanks for the review! @ksunden
If I've read all the CI logs correctly, it looks like most don't support that locale, but Windows on Azure is at least testing it? |
I think so, though I do wonder if something like |
Should I update the locale to |
I would prefer it, especially if it does have better coverage. Getting better coverage without having to deal with figuring out how to install locales on CI would be better for ensuring it doesn't break. One is significantly better than None, but if we can get the majority and especially more than one platform represented, that is even better. |
Unfortunately, it looks like we've only gained macOS on Azure from that locale. Based on actions/runner-images#762 (comment), it looks like we could perhaps add a locale on Linux with |
How should I update the changes? |
Probably just leave it as is for now, but you'll need to rebase to fix the failing tests. |
Is it possible for you to rebase instead of merging? https://matplotlib.org/devdocs/devel/development_workflow.html#rebasing-on-upstream-main |
Co-authored-by: Oscar Gustafsson <[email protected]>
Hi, @QuLogic Thanks for the ref. I rebased to the current main. |
Going to merge as is for now, it is at least testing on 2 platforms, but a follow-up that enables reliable testing on more CI (e.g. all the ghactions runs) would be welcome. If that is explicitly enabled, I think adding the exception to the skip for ghactions at least would be warranted, to guarantee we continue to actually test and see failures in CI. |
PR Summary
Fixes #23626
Closes #24079
Replace unintended space in locale.format_string function
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst