From d94b9c16ab6f3d30f3f3cff800a739091405fd4f Mon Sep 17 00:00:00 2001 From: deadzilla Date: Sun, 12 Jul 2026 00:02:13 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20translate=5Fweather=20=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B5=D0=B7=D0=B0=D0=B5=D1=82=20=D0=BF=D1=80=D0=BE=D0=B1=D0=B5?= =?UTF-8?q?=D0=BB=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=BE=D0=B9=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D1=83=D1=81=D1=82=D0=BE=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_pogoda.py | 4 ++-- utils/pogoda.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_pogoda.py b/tests/test_pogoda.py index d6486ab..41c916e 100644 --- a/tests/test_pogoda.py +++ b/tests/test_pogoda.py @@ -163,11 +163,11 @@ class TestTranslateWeather: [ ("", "—"), (None, "—"), - (" ", " "), # пробелы не считаются пустыми + (" ", "—"), # строка из пробелов тоже считается пустой ], ) def test_translate_empty(self, input_value, expected) -> None: - """Пустой или None ввод должен возвращать '—'.""" + """Пустой, None или только пробелы должен возвращать '—'.""" assert translate_weather(input_value) == expected def test_translate_unknown_returns_original(self) -> None: diff --git a/utils/pogoda.py b/utils/pogoda.py index 1a5fc93..6734590 100644 --- a/utils/pogoda.py +++ b/utils/pogoda.py @@ -172,9 +172,9 @@ _WEATHER_MAPPING = [ def translate_weather(en: Optional[str]) -> str: - if not en: + if not en or not en.strip(): return "—" - en_lower = en.lower() + en_lower = en.strip().lower() for key, value in _WEATHER_MAPPING: if key.lower() in en_lower: return value