test_gflanguages_api.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright 2022 Google LLC All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS-IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. from pkg_resources import resource_filename
  18. from gflanguages import (LoadLanguages,
  19. LoadRegions,
  20. LoadScripts)
  21. DATA_DIR = resource_filename("gflanguages", "data")
  22. def test_LoadLanguages():
  23. for langs in [LoadLanguages(),
  24. LoadLanguages(None),
  25. LoadLanguages(DATA_DIR)]:
  26. numerals = langs["yi_Hebr"].exemplar_chars.numerals
  27. assert numerals == '- , . % + 0 1 2 3 4 5 6 7 8 9'
  28. def test_LoadScripts():
  29. for scripts in [LoadScripts(),
  30. LoadScripts(None),
  31. LoadScripts(DATA_DIR)]:
  32. scripts = LoadScripts()
  33. assert scripts["Tagb"].name == 'Tagbanwa'
  34. def test_LoadRegions():
  35. for regions in [LoadRegions(),
  36. LoadRegions(None),
  37. LoadRegions(DATA_DIR)]:
  38. regions = LoadRegions()
  39. br = regions["BR"]
  40. assert br.name == 'Brazil'
  41. assert br.region_group == ['Americas']