Debian Codegraph @

tests/test_gflanguages_api.py

raw symbols SCIP
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
18 import sys
19
20 if sys.version_info < (3, 10):
21 import importlib_resources as importlib_resources
22 else:
23 import importlib.resources as importlib_resources
24
25 from gflanguages import (LoadLanguages,
26 LoadRegions,
27 LoadScripts)
28
29 DATA_DIR = importlib_resources.files("gflanguages") / "data"
30
31
32 def test_LoadLanguages():
33 with importlib_resources.as_file(DATA_DIR) as data_path:
34 for langs in [LoadLanguages(),
35 LoadLanguages(None),
36 LoadLanguages(data_path)]:
37 numerals = langs["yi_Hebr"].exemplar_chars.numerals
38 assert numerals == '- , . % + 0 1 2 3 4 5 6 7 8 9'
39
40
41 def test_LoadScripts():
42 with importlib_resources.as_file(DATA_DIR) as data_path:
43 for scripts in [LoadScripts(),
44 LoadScripts(None),
45 LoadScripts(data_path)]:
46 scripts = LoadScripts()
47 assert scripts["Tagb"].name == 'Tagbanwa'
48
49
50 def test_LoadRegions():
51 with importlib_resources.as_file(DATA_DIR) as data_path:
52 for regions in [LoadRegions(),
53 LoadRegions(None),
54 LoadRegions(data_path)]:
55 regions = LoadRegions()
56 br = regions["BR"]
57 assert br.name == 'Brazil'
58 assert br.region_group == ['Americas']