forked from ionelmc/python-hunter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_config.py
More file actions
39 lines (35 loc) · 1.97 KB
/
test_config.py
File metadata and controls
39 lines (35 loc) · 1.97 KB
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
import os
import pytest
from hunter.config import DEFAULTS
from hunter.config import load_config
@pytest.mark.parametrize('config', [
('foobar', (('x',), {'y': 1}), {},
'''Failed to load hunter config from PYTHONHUNTERCONFIG 'foobar': NameError'''),
('foobar=1', (('x',), {'y': 1}), {}, '''Discarded config from PYTHONHUNTERCONFIG foobar=1: '''),
('foobar=1, force_colors=1', (('x',), {'y': 1}), {'force_colors': 1},
'''Discarded config from PYTHONHUNTERCONFIG foobar=1: '''),
('klass=123', (('x',), {'y': 1}), {'klass': 123}, ''),
('stream=123', (('x',), {'y': 1}), {'stream': 123}, ''),
('force_colors=123', (('x',), {'y': 1}), {'force_colors': 123}, ''),
('filename_alignment=123', (('x',), {'y': 1}), {'filename_alignment': 123}, ''),
('thread_alignment=123', (('x',), {'y': 1}), {'thread_alignment': 123}, ''),
('repr_limit=123', (('x',), {'y': 1}), {'repr_limit': 123}, ''),
('stdlib=0', (('x',), {'y': 1, 'stdlib': 0}), {}, ''),
('clear_env_var=1', (('x',), {'y': 1, 'clear_env_var': 1}), {}, ''),
('threading_support=1', (('x',), {'y': 1, 'threading_support': 1}), {}, ''),
('threads_support=1', (('x',), {'y': 1, 'threads_support': 1}), {}, ''),
('thread_support=1', (('x',), {'y': 1, 'thread_support': 1}), {}, ''),
('threadingsupport=1', (('x',), {'y': 1, 'threadingsupport': 1}), {}, ''),
('threadssupport=1', (('x',), {'y': 1, 'threadssupport': 1}), {}, ''),
('threadsupport=1', (('x',), {'y': 1, 'threadsupport': 1}), {}, ''),
('threading=1', (('x',), {'y': 1, 'threading': 1}), {}, ''),
('threads=1', (('x',), {'y': 1, 'threads': 1}), {}, ''),
('thread=1', (('x',), {'y': 1, 'thread': 1}), {}, ''),
])
def test_config(monkeypatch, config, capsys):
env, result, defaults, stderr = config
monkeypatch.setitem(os.environ, 'PYTHONHUNTERCONFIG', env)
assert load_config(('x',), {'y': 1}) == result
assert DEFAULTS == defaults
output = capsys.readouterr()
assert output.err.startswith(stderr)