Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Aug 20, 2023
1 parent 6207cdb commit 56cb513
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apprise/AppriseLocale.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class AppriseLocale:

# Locale regular expression
_local_re = re.compile(
r'^\s*(?P<lang>[a-z]{2})([_:]((?P<country>[a-z]{2}))?'
r'(\.(?P<enc>[a-z0-9]+))?|.+)?', re.IGNORECASE)
r'^((?P<ansii>C)|(?P<lang>([a-z]{2}))([_:](?P<country>[a-z]{2}))?)'
r'(\.(?P<enc>[a-z0-9-]+))?$', re.IGNORECASE)

# Define our default encoding
_default_encoding = 'utf-8'
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions test/test_apprise_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def test_apprise_trans_gettext_lang_at(mock_getlocale):
# We can still perform simple lookups; they access a dummy wrapper:
assert al.gettext('test') == 'test'

with environ('LANGUAGE', 'LC_ALL', 'LC_CTYPE', LANG="en_CA"):
with environ('LANGUAGE', 'LC_CTYPE', LC_ALL='C.UTF-8', LANG="en_CA"):
# the UTF-8 entry is skipped over
AppriseLocale.AppriseLocale._default_language = 'fr'

# We will detect the english language (found in the LANG= environment
Expand Down Expand Up @@ -266,7 +267,7 @@ def test_detect_language_using_env(mock_getlocale):
AppriseLocale.AppriseLocale.detect_language(), str)

# Detect French language.
with environ('LANGUAGE', 'LC_ALL', 'LC_CTYPE', LANG="fr_CA"):
with environ('LANGUAGE', 'LC_ALL', LC_CTYPE="garbage", LANG="fr_CA"):
assert AppriseLocale.AppriseLocale.detect_language() == 'fr'

# The following unsets all environment variables and sets LC_CTYPE
Expand Down

0 comments on commit 56cb513

Please sign in to comment.