Skip to content

Commit

Permalink
Fix formatting for "Empty locale identifier" exception added in #1164 (
Browse files Browse the repository at this point in the history
  • Loading branch information
akx authored Feb 3, 2025
1 parent b50a1d2 commit 27e7303
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion babel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def parse(
f"Empty locale identifier value: {identifier!r}\n\n"
f"If you didn't explicitly pass an empty value to a Babel function, "
f"this could be caused by there being no suitable locale environment "
f"variables for the API you tried to use.",
f"variables for the API you tried to use."
)
if isinstance(identifier, str):
raise ValueError(msg) # `parse_locale` would raise a ValueError, so let's do that here
Expand Down
3 changes: 2 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ def test_language_alt_official_not_used():


def test_locale_parse_empty():
with pytest.raises(ValueError, match="Empty"):
with pytest.raises(ValueError, match="Empty") as ei:
Locale.parse("")
assert isinstance(ei.value.args[0], str)
with pytest.raises(TypeError, match="Empty"):
Locale.parse(None)
with pytest.raises(TypeError, match="Empty"):
Expand Down

0 comments on commit 27e7303

Please sign in to comment.