From dc5265c4a9c753b064b1e824c41ebf148d9ef5be Mon Sep 17 00:00:00 2001 From: Pandede Date: Sat, 6 Apr 2024 00:53:17 +0800 Subject: [PATCH 1/3] seperate with space instead of dot --- faker/providers/currency/ru_RU/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faker/providers/currency/ru_RU/__init__.py b/faker/providers/currency/ru_RU/__init__.py index f6843c22bd..36d796ad10 100644 --- a/faker/providers/currency/ru_RU/__init__.py +++ b/faker/providers/currency/ru_RU/__init__.py @@ -171,7 +171,7 @@ class Provider(CurrencyProvider): ("ZWD", "Доллар Зимбабве"), ) - price_formats = ["#,##", "%#,##", "%##,##", "%.###,##", "%#.###,##"] + price_formats = ["#,##", "%#,##", "%##,##", "% ###,##", "%# ###,##"] def pricetag(self) -> str: return ( From 8e2dd349461c8f6d2bf616785ab7af7de702da24 Mon Sep 17 00:00:00 2001 From: Pandede Date: Sat, 6 Apr 2024 00:53:39 +0800 Subject: [PATCH 2/3] validate pricetag with `regex` --- tests/providers/test_currency.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/providers/test_currency.py b/tests/providers/test_currency.py index 862a508141..393fb4374c 100644 --- a/tests/providers/test_currency.py +++ b/tests/providers/test_currency.py @@ -1,3 +1,5 @@ +import re + from unittest.mock import patch import pytest @@ -131,6 +133,7 @@ def test_pricetag(self, faker, num_samples): for _ in range(num_samples): pricetag = faker.pricetag() assert isinstance(pricetag, str) + assert re.match(r"\d{1,3}(?:\s\d{3})*,\d{2}\sр\.", pricetag) class TestCsCz: From 9e8f38d49cb0ec86b979d8153f56ff1439a7a8c1 Mon Sep 17 00:00:00 2001 From: Pandede Date: Mon, 8 Apr 2024 23:23:59 +0800 Subject: [PATCH 3/3] follow codestyle in other tests --- tests/providers/test_currency.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/providers/test_currency.py b/tests/providers/test_currency.py index 393fb4374c..5161749de6 100644 --- a/tests/providers/test_currency.py +++ b/tests/providers/test_currency.py @@ -119,6 +119,8 @@ def setup_class(cls): cls.currencies = cls.provider.currencies cls.currency_codes, cls.currency_names = tuple(zip(*cls.currencies)) + cls.pricetag_pattern = re.compile(r"\d{1,3}(?:\s\d{3})*,\d{2}\sр\.") + def test_currency(self, faker, num_samples): for _ in range(num_samples): cur = faker.currency() @@ -133,7 +135,7 @@ def test_pricetag(self, faker, num_samples): for _ in range(num_samples): pricetag = faker.pricetag() assert isinstance(pricetag, str) - assert re.match(r"\d{1,3}(?:\s\d{3})*,\d{2}\sр\.", pricetag) + assert self.pricetag_pattern.fullmatch(pricetag) class TestCsCz: