Coverage for gws-app/gws/lib/inifile/_test.py: 0%
17 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
1"""Tests for the inifile module."""
2import os
4import gws
5import gws.test.util as u
6import gws.lib.inifile as inifile
9def test_from_paths():
10 with open('/tmp/myfile.ini', 'w') as f:
11 f.write('[mysection]\n'
12 'mykey = myval\n'
13 'morekeys = morevals\n'
14 '\n'
15 '[mysection.subsection]\n'
16 'anotherkey = 123\n')
17 f.close()
18 p1 = '/tmp/myfile.ini'
19 assert inifile.from_paths(p1) == {'mysection.mykey': 'myval',
20 'mysection.morekeys': 'morevals',
21 'mysection.subsection.anotherkey': '123'}
24def test_from_paths_empty():
25 assert inifile.from_paths() == {}
28def test_to_string_empty():
29 assert inifile.to_string({}) == ''
32def test_to_string():
33 d = {'de.modSidebarOpenButton': 'Menü öffnen',
34 'en.modSidebarOpenButton': 'open sidebar',
35 }
36 assert inifile.to_string(d).replace('\n', '') == ('[de]'
37 'modsidebaropenbutton=Menü öffnen'
38 '[en]'
39 'modsidebaropenbutton=open sidebar')