Closed nitsujri closed 1 year ago
Patch coverage: 100.00
% and project coverage change: +0.02
:tada:
Comparison is base (
b9a4b65
) 92.42% compared to head (d77c009
) 92.45%.
:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
@PetrDlouhy I thought about the specs and my recommendations are either:
babel.numbers.format_currency
The goal of these specs is to test the __str__()
while the job of testing format_currency
is left to babel themselves. Making all specs locale agnostic I don't think is realistic since there's just too many different formats and thusly we should leave that to babel's team.
I believe either option is valid, removing the unicode still allows the decimal
digit to come through (and thusly be tested) or mocking format_currency
to ignore the problem all together.
Thoughts?
After some experimenting and thinking about this I think the best solution would be to introduce some new settings that would allow to define the django-hordak
's locale. Something like HORDAK_LOCALE
variable that would be passed to babel.numbers.format_currency
as locale parameter (if set).
Then we would be able to run the tests simply with
@override_settings(HORDAK_LOCALE=`en_US`)
to unify the output of format_currency.
This would not only fix the tests but also allow users to better control the outputs (not only for __str__
, but also for currency
templatetag filter).
new settings that would allow to define the django-hordak's locale. Something like HORDAK_LOCALE variable
For Django, locale is commonly set on a per-request level, so a project level setting wouldn't be helpful. Our project serves 4 asian based locales.
But, I mocked up a quick/janky example of how it could work for Hordak.
It works locally in OSX and on the server. If I'm on the right track, I can clean it up.
Yeah, I think solution is superb.
I am only thinking if this can't cause some compatibility issues, but I think the change is not so big so just a note to CHANGES.txt could be enough.
I would also apply similar solution to the templatetag.
@PetrDlouhy done!
Let me know if there's anything else.
I think it is very good job. Thank you.
There is another occurrence of format_currency
and also format_decimal
in hordak/templatetags/hordak.py
in currency
filter.
I would expect that we need to change those to make the behavior coherent, what do you think?
If you do that, please add also few simple tests for the currency
filter (direct call of that function would be enough) to ensure the new behavior.
@PetrDlouhy This is done.
@nitsujri Thans. This is great.
Currently these specs fail on OSX (possibly others) due to
babel
's machine dependent output of spaces as unicode\xa0
.Original discussion points: