Skip to content
Newer
Older
100644 55 lines (38 sloc) 1.25 KB
3f655c0 @baverman restore last window position
authored
1 from snaked.core.prefs import PySettings
2
1caac83 @baverman use uxie.idle and Co. New configs
authored
3 def make_settings(**kwargs):
4 return PySettings(dict((k, (v, '')) for k,v in kwargs.items()))
3f655c0 @baverman restore last window position
authored
5
1caac83 @baverman use uxie.idle and Co. New configs
authored
6 def test_prefs_must_return_default_values():
7 p = make_settings(key1='key1', key2='key2')
3f655c0 @baverman restore last window position
authored
8 assert p['key1'] == 'key1'
9 assert p['key2'] == 'key2'
10
1caac83 @baverman use uxie.idle and Co. New configs
authored
11 def test_prefs_must_return_parent_values():
12 p = make_settings(key1='key1', key2='key2')
13 pp = PySettings(parent=p)
3f655c0 @baverman restore last window position
authored
14
1caac83 @baverman use uxie.idle and Co. New configs
authored
15 p['key1'] = 20
16
17 assert pp['key1'] == 20
18 assert pp['key2'] == 'key2'
19
20 def test_prefs_must_return_assigned_values():
21 p = make_settings(key1='key1', key2='key2')
3f655c0 @baverman restore last window position
authored
22 p['key1'] = 'key11'
23 p['key2'] = None
24
25 assert p['key1'] == 'key11'
26 assert p['key2'] == None
27
1caac83 @baverman use uxie.idle and Co. New configs
authored
28 def test_prefs_must_provide_its_source():
29 p = make_settings(a=True, b=10, c=False)
3f655c0 @baverman restore last window position
authored
30
1caac83 @baverman use uxie.idle and Co. New configs
authored
31 p['a'] = False
32 p['b'] = 10
3f655c0 @baverman restore last window position
authored
33
1caac83 @baverman use uxie.idle and Co. New configs
authored
34 result = p.get_config()
3f655c0 @baverman restore last window position
authored
35
1caac83 @baverman use uxie.idle and Co. New configs
authored
36 assert 'a = False' in result
37 assert '# b = 10' in result
38 assert '# c = False' in result
9b1b7bc @baverman keep midified file content on editor close
authored
39
1caac83 @baverman use uxie.idle and Co. New configs
authored
40 def test_prefs_parent_config_override():
41 p1 = make_settings(a=True, b=10, c=False)
42 p2 = PySettings(parent=p1)
8db9bec @baverman write commented option values from parent config instead default once
authored
43
1caac83 @baverman use uxie.idle and Co. New configs
authored
44 p1['a'] = False
3f655c0 @baverman restore last window position
authored
45
1caac83 @baverman use uxie.idle and Co. New configs
authored
46 p1['b'] = 1
47 p2['b'] = 10
3f655c0 @baverman restore last window position
authored
48
1caac83 @baverman use uxie.idle and Co. New configs
authored
49 p2['c'] = False
5936d42 @baverman install instructions update
authored
50
1caac83 @baverman use uxie.idle and Co. New configs
authored
51 result = p2.get_config()
9b1b7bc @baverman keep midified file content on editor close
authored
52
1caac83 @baverman use uxie.idle and Co. New configs
authored
53 assert 'a = False' in result
54 assert 'b = 10' in result
55 assert '# c = False' in result
Something went wrong with that request. Please try again.