Skip to content

Commit 36cbaad

Browse files
committed
new title tests
1 parent 88014b4 commit 36cbaad

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

tests/core/test_progress_util.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,34 @@
66
from alive_progress.utils.cells import join_cells
77

88

9-
@pytest.mark.parametrize('length, text, expected', [
10-
(0, None, ''),
11-
(0, '', ''),
12-
(0, 'c', 'c'),
13-
(0, 'cool bar title', 'cool bar title'),
14-
(1, None, ' '),
15-
(1, '', ' '),
16-
(1, 'c', 'c'),
17-
(1, 'cool bar title', '…'),
18-
(1, '😺', '…'),
19-
(2, '😺', '😺'),
20-
(5, 'cool bar title', 'cool…'),
21-
(14, 'cool bar title', 'cool bar title'),
22-
(20, 'cool bar title', 'cool bar title '),
23-
(15, 'cool bar title😺', 'cool bar title…'),
24-
(16, 'cool bar title😺', 'cool bar title😺'),
25-
(16, 'cool bar title😺a', 'cool bar title …'),
26-
(16, 'cool bar title😺😺', 'cool bar title …'),
9+
@pytest.mark.parametrize('config, length, title, expected', [
10+
(None, 0, None, ''),
11+
(None, 0, '', ''),
12+
(None, 0, 'c', 'c'),
13+
(None, 0, 'cool bar title', 'cool bar title'),
14+
(None, 1, None, ' '),
15+
(None, 1, '', ' '),
16+
(None, 1, 'c', 'c'),
17+
(None, 1, 'cool bar title', '…'),
18+
(None, 1, '😺', '…'),
19+
(None, 2, '😺', '😺'),
20+
(None, 5, 'cool bar title', 'cool…'),
21+
(None, 14, 'cool bar title', 'cool bar title'),
22+
(None, 20, 'cool bar title', 'cool bar title '),
23+
(None, 15, 'cool bar title😺', 'cool bar title…'),
24+
(None, 16, 'cool bar title😺', 'cool bar title😺'),
25+
(None, 16, 'cool bar title😺a', 'cool bar title …'),
26+
(None, 16, 'cool bar title😺😺', 'cool bar title …'),
27+
# a title in the config may override the passed title.
28+
('on config', 0, None, 'on config'),
29+
('on config', 0, '', ''),
30+
('on config', 0, 'cool bar title', 'cool bar title'),
31+
('on config', 1, None, '…'),
32+
('on config', 1, '', ' '),
2733
])
28-
def test_render_title(length, text, expected):
29-
local_config = mock.Mock(title=text, title_length=length)
30-
assert join_cells(_render_title(local_config)) == expected
34+
def test_render_title(config, length, title, expected):
35+
local_config = mock.Mock(title=config, title_length=length)
36+
assert join_cells(_render_title(local_config, title)) == expected
3137

3238

3339
def test_gated_properties():

0 commit comments

Comments
 (0)