rows
rows copied to clipboard
WIP locale fix
Hello, @turicas.
This is not a final PR, it is still a work in progress.
So, the thing is that I get some errors when running the tests on my machine and it looks like it is because I'm missing the pt_BR.UTF-8 locale.
As you can see in tests/tests_fields.py
I am importing the locale module to find out the current locale and the decimal point and thousand separator. Then I'm using those values to format the numbers for the tests.
I also had to add the locale to the DecimalField
class, because it was looking for thousand separator considering only dots, not commas.
Still, my tests are not passing because of those small differences when formatting numbers.
Oh, I also added one missing requirement to the development requirements: openpyxl
Can you please have a look and tell if I'm going in the right direction here? Maybe you have some concerns about the way I'm getting the current locale or something. I'm not a Python developer all the time, so I may be missing something :|
Thanks!
Hey, @turicas, any news here? Do you think I should go this way?
@InFog, thanks for your PR and sorry for the delay to answer!
I'd prefer to do not use localeconv()
directly because of the rows.locale_context
context manager.
The tests really need pt_BR
locale to run and I don't think there's another way to change it (unless we don't use locale
at all). I think we need to discuss more the problem of using locale
(the babel may help here).
In which direction are you feeling to go to? Do you have any ideas on this?
I think a good way to solve this issue would be checking what other projects are doing to handle locales. Having the tests depending on one specific locale is not a good idea, in my opinion.
Maybe we could abstract the locale detection and try to use some different locale detection approaches.
Still, the first step would be to get rid of locale dependency to run the tests ;)