-
Notifications
You must be signed in to change notification settings - Fork 68
/
test_locale.py
41 lines (29 loc) · 1 KB
/
test_locale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'''
locale test
Uses locale .kll files to check locale alias name lookup handling
'''
### Imports ##
import os
import pytest
import tempfile
from tests.klltest import kll_run, header_test
### Variables ###
test_files = [
['kll/examples/locale/base.locale-test.kll', 'kll/examples/locale/de_DE.locale-test.kll'],
]
### Tests ###
@pytest.mark.parametrize('input_files', test_files)
def test_locale(input_files):
'''
Runs locale test on each of the specified file sets
'''
# Prepare tmp directory
sanitized_input_file = "_".join(input_files).replace('/', '-')
tmp_dir = os.path.join(tempfile.gettempdir(), 'kll_pytest')
os.makedirs(tmp_dir, exist_ok=True)
target_dir = tempfile.mkdtemp(suffix='-{}'.format(sanitized_input_file), prefix='locale-', dir=tmp_dir)
# Run test
args = ['--emitter', 'kll', '--output-debug', '--target-dir', target_dir] + input_files
header_test('{} {}'.format(" ".join(input_files), target_dir), args)
ret = kll_run(args)
assert ret == 0