|
6 | 6 | from alive_progress.utils.cells import join_cells
|
7 | 7 |
|
8 | 8 |
|
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, '', ' '), |
27 | 33 | ])
|
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 |
31 | 37 |
|
32 | 38 |
|
33 | 39 | def test_gated_properties():
|
|
0 commit comments