Skip to content

Commit ba532d9

Browse files
committed
Replace Exception with more specific FileNotFoundError
1 parent 3dca143 commit ba532d9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/humanize/i18n.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def activate(
7171
dict: Translations.
7272
7373
Raises:
74-
Exception: If humanize cannot find the locale folder.
74+
FileNotFoundError: If humanize cannot find the locale folder.
7575
"""
7676
if locale is None or locale.startswith("en"):
7777
_CURRENT.locale = None
@@ -85,7 +85,7 @@ def activate(
8585
"Humanize cannot determinate the default location of the 'locale' folder. "
8686
"You need to pass the path explicitly."
8787
)
88-
raise Exception(msg)
88+
raise FileNotFoundError(msg)
8989
if locale not in _TRANSLATIONS:
9090
translation = gettext_module.translation("humanize", path, [locale])
9191
_TRANSLATIONS[locale] = translation

tests/test_i18n.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_default_locale_path_null__spec__(
228228
i18n = importlib.import_module("humanize.i18n")
229229
monkeypatch.setattr(i18n, "__spec__", None)
230230

231-
with pytest.raises(Exception, match=self.expected_msg):
231+
with pytest.raises(FileNotFoundError, match=self.expected_msg):
232232
i18n.activate("ru_RU")
233233

234234
def test_default_locale_path_undefined__spec__(
@@ -237,7 +237,7 @@ def test_default_locale_path_undefined__spec__(
237237
i18n = importlib.import_module("humanize.i18n")
238238
monkeypatch.delattr(i18n, "__spec__")
239239

240-
with pytest.raises(Exception, match=self.expected_msg):
240+
with pytest.raises(FileNotFoundError, match=self.expected_msg):
241241
i18n.activate("ru_RU")
242242

243243
@freeze_time("2020-02-02")

0 commit comments

Comments
 (0)