summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2019-05-27 14:32:48 +0300
committerAarni Koskela <akx@iki.fi>2019-05-27 14:42:00 +0300
commit4b6cd34c5c4436c60747a30d15a915cb2702ca0b (patch)
tree9eac7859ee4471be8feef949027c3f24e1587dbf /tests
parentd7f2e84dedcce223d73229c79f0f1085d4dc84be (diff)
downloadbabel-4b6cd34c5c4436c60747a30d15a915cb2702ca0b.tar.gz
parse_decimal(): assume spaces are equivalent to non-breaking spaces when not in strict mode
Fixes #637
Diffstat (limited to 'tests')
-rw-r--r--tests/test_numbers.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_numbers.py b/tests/test_numbers.py
index 99aa96b..27649f8 100644
--- a/tests/test_numbers.py
+++ b/tests/test_numbers.py
@@ -679,3 +679,14 @@ def test_numberpattern_repr():
def test_parse_static_pattern():
assert numbers.parse_pattern('Kun') # in the So locale in CLDR 30
# TODO: static patterns might not be correctly `apply()`ed at present
+
+
+def test_parse_decimal_nbsp_heuristics():
+ # Re https://github.com/python-babel/babel/issues/637 –
+ # for locales (of which there are many) that use U+00A0 as the group
+ # separator in numbers, it's reasonable to assume that input strings
+ # with plain spaces actually should have U+00A0s instead.
+ # This heuristic is only applied when strict=False.
+ n = decimal.Decimal("12345.123")
+ assert numbers.parse_decimal("12 345.123", locale="fi") == n
+ assert numbers.parse_decimal(numbers.format_decimal(n, locale="fi"), locale="fi") == n