[New-bugs-announce] [issue42224] test_format:test_locale fails when locale does not set grouping in thousands

Lysandros Nikolaou report at bugs.python.org
Sat Oct 31 18:39:36 EDT 2020


New submission from Lysandros Nikolaou <lisandrosnik at gmail.com>:

test_format:test_locale tests for the existence of the thousands separator in a formatted number.

However, my locale does not expect/enforce (not sure what the correct term is) grouping the number in thousands, which leads to the test (and consequently the whole test suite) failing:

➜  cpython git:(test-format-locale-fix) ./python                  
Python 3.10.0a1+ (heads/master:3bf0d02f28, Oct 31 2020, 22:42:09) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'LC_CTYPE=en_US.UTF-8;LC_NUMERIC=el_GR.UTF-8;LC_TIME=el_GR.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=el_GR.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=el_GR.UTF-8;LC_NAME=el_GR.UTF-8;LC_ADDRESS=el_GR.UTF-8;LC_TELEPHONE=el_GR.UTF-8;LC_MEASUREMENT=el_GR.UTF-8;LC_IDENTIFICATION=el_GR.UTF-8'
>>> format(123456789, 'n')
'123456789'
>>> locale.localeconv()['grouping']
[]

I guess the fix here is to check whether grouping is empty or not in test_locale.

----------
components: Tests
messages: 380104
nosy: lys.nikolaou
priority: normal
severity: normal
status: open
title: test_format:test_locale fails when locale does not set grouping in thousands
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42224>
_______________________________________


More information about the New-bugs-announce mailing list