ya2 · news · projects · code · about

1416e015a193d1fcfbf7871ab9528451c783fd3e
[pmachines.git] / tests / ya2 / build / test_lang.py
1 from pathlib import Path
2 import sys
3 if '' in sys.path: sys.path.remove('')
4 sys.path.append(str(Path(__file__).parent.parent.parent))
5 from os import makedirs
6 from os.path import exists
7 from shutil import rmtree, copy
8 from unittest import TestCase
9 from ya2.build.lang import LanguageBuilder
10
11
12 class LangTests(TestCase):
13
14 def setUp(self):
15 for dirname in ['locale', 'po']:
16 rmtree('./tests/' + dirname, ignore_errors=True)
17 makedirs('./tests/' + dirname, exist_ok=True)
18 copy('assets/locale/po/it_IT.po', './tests/po/')
19
20 def tearDown(self):
21 for dirname in ['locale', 'po']:
22 rmtree('./tests/' + dirname, ignore_errors=True)
23
24 def test_lang(self):
25 LanguageBuilder.build_pot('test_pmachines', './tests/po/')
26 self.assertTrue(exists('./tests/po/test_pmachines.pot'))
27 LanguageBuilder.merge('it_IT', './tests/po/', './tests/locale/', 'test_pmachines')
28 LanguageBuilder.build_mo('./tests/locale/it_IT/LC_MESSAGES/test_pmachines.mo',
29 './tests/locale/', 'test_pmachines')
30 self.assertTrue(exists('./tests/locale/it_IT/LC_MESSAGES/test_pmachines.mo'))