Skip to content

Commit 2ddb590

Browse files
authored
Replace Exception with more specific FileNotFoundError (#286)
2 parents e87f2e2 + ba532d9 commit 2ddb590

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
@@ -234,7 +234,7 @@ def test_default_locale_path_null__spec__(
234234
i18n = importlib.import_module("humanize.i18n")
235235
monkeypatch.setattr(i18n, "__spec__", None)
236236

237-
with pytest.raises(Exception, match=self.expected_msg):
237+
with pytest.raises(FileNotFoundError, match=self.expected_msg):
238238
i18n.activate("ru_RU")
239239

240240
def test_default_locale_path_undefined__spec__(
@@ -243,7 +243,7 @@ def test_default_locale_path_undefined__spec__(
243243
i18n = importlib.import_module("humanize.i18n")
244244
monkeypatch.delattr(i18n, "__spec__")
245245

246-
with pytest.raises(Exception, match=self.expected_msg):
246+
with pytest.raises(FileNotFoundError, match=self.expected_msg):
247247
i18n.activate("ru_RU")
248248

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

0 commit comments

Comments
 (0)