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")