forked from wolph/python-progressbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_color.py
More file actions
42 lines (32 loc) · 996 Bytes
/
test_color.py
File metadata and controls
42 lines (32 loc) · 996 Bytes
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
41
42
import pytest
import progressbar
from progressbar import terminal
@pytest.mark.parametrize(
'variable', [
'PROGRESSBAR_ENABLE_COLORS',
'FORCE_COLOR',
]
)
def test_color_environment_variables(monkeypatch, variable):
monkeypatch.setattr(
terminal,
'color_support',
terminal.ColorSupport.XTERM_256,
)
monkeypatch.setenv(variable, '1')
bar = progressbar.ProgressBar()
assert bar.enable_colors
monkeypatch.setenv(variable, '0')
bar = progressbar.ProgressBar()
assert not bar.enable_colors
def test_enable_colors_flags():
bar = progressbar.ProgressBar(enable_colors=True)
assert bar.enable_colors
bar = progressbar.ProgressBar(enable_colors=False)
assert not bar.enable_colors
bar = progressbar.ProgressBar(
enable_colors=terminal.ColorSupport.XTERM_TRUECOLOR
)
assert bar.enable_colors
with pytest.raises(ValueError):
progressbar.ProgressBar(enable_colors=12345)