From ba532d9ae45d1da89f3687259324365dc187ebca Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 20 Dec 2025 17:37:18 +0200 Subject: [PATCH] Replace Exception with more specific FileNotFoundError --- src/humanize/i18n.py | 4 ++-- tests/test_i18n.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/humanize/i18n.py b/src/humanize/i18n.py index 1d30d50..5308a13 100644 --- a/src/humanize/i18n.py +++ b/src/humanize/i18n.py @@ -71,7 +71,7 @@ def activate( dict: Translations. Raises: - Exception: If humanize cannot find the locale folder. + FileNotFoundError: If humanize cannot find the locale folder. """ if locale is None or locale.startswith("en"): _CURRENT.locale = None @@ -85,7 +85,7 @@ def activate( "Humanize cannot determinate the default location of the 'locale' folder. " "You need to pass the path explicitly." ) - raise Exception(msg) + raise FileNotFoundError(msg) if locale not in _TRANSLATIONS: translation = gettext_module.translation("humanize", path, [locale]) _TRANSLATIONS[locale] = translation diff --git a/tests/test_i18n.py b/tests/test_i18n.py index 6c16c94..278ef3f 100644 --- a/tests/test_i18n.py +++ b/tests/test_i18n.py @@ -228,7 +228,7 @@ def test_default_locale_path_null__spec__( i18n = importlib.import_module("humanize.i18n") monkeypatch.setattr(i18n, "__spec__", None) - with pytest.raises(Exception, match=self.expected_msg): + with pytest.raises(FileNotFoundError, match=self.expected_msg): i18n.activate("ru_RU") def test_default_locale_path_undefined__spec__( @@ -237,7 +237,7 @@ def test_default_locale_path_undefined__spec__( i18n = importlib.import_module("humanize.i18n") monkeypatch.delattr(i18n, "__spec__") - with pytest.raises(Exception, match=self.expected_msg): + with pytest.raises(FileNotFoundError, match=self.expected_msg): i18n.activate("ru_RU") @freeze_time("2020-02-02")