Skip to content

Commit

Permalink
fix: add module test using doctest and fix usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
zobweyt committed Oct 22, 2024
1 parent 86b0c7f commit 5a6281d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/i18n/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def get_preferred_iso_639(accept_language: str) -> str:
Examples:
>>> get_preferred_iso_639("fr-CH, en;q=0.4, de;q=0.9, ru, *;q=0.5")
'ru'
>>> get_preferred_iso_639("es;q=0.5, fr;q=0.6")
'en' # Default language since 'es' and 'fr' are not supported
>>> get_preferred_iso_639("es;q=0.5, fr;q=0.6") # NOTE: 'es' and 'fr' are not supported. 'en' is default.
'en'
"""

preferences = [LanguagePreference(raw=preference) for preference in accept_language.split(ACCEPT_LANGUAGE_SEP)]
Expand All @@ -153,3 +153,9 @@ def get_preferred_iso_639(accept_language: str) -> str:
"LanguagePreference",
"get_preferred_iso_639",
]


if __name__ == "__main__":
import doctest

doctest.testmod(verbose=True)

0 comments on commit 5a6281d

Please sign in to comment.