|
1
|
|
|
#!/usr/bin/env python3 |
|
2
|
|
|
""" |
|
3
|
|
|
""" |
|
4
|
|
|
from .context import init_table_options, parse_table_options |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
def test_parse_table_options(): |
|
8
|
|
|
init_options = {} |
|
9
|
|
|
init_table_options(init_options) |
|
10
|
|
|
options = init_options.copy() |
|
11
|
|
|
raw_table_list = [['1', '2', '3', '4'], ['5', '6', '7', '8']] |
|
12
|
|
|
# check init is preserved |
|
13
|
|
|
parse_table_options(options, raw_table_list) |
|
14
|
|
|
assert options == options |
|
15
|
|
|
# check caption |
|
16
|
|
|
options['caption'] = '**sad**' |
|
17
|
|
|
parse_table_options(options, raw_table_list) |
|
18
|
|
|
assert str(options['caption'][0]) == 'Strong(Str(sad))' |
|
19
|
|
|
# check alignment |
|
20
|
|
|
options['alignment'] = 'LRC' |
|
21
|
|
|
parse_table_options(options, raw_table_list) |
|
22
|
|
|
assert options['alignment'] == [ |
|
23
|
|
|
'AlignLeft', |
|
24
|
|
|
'AlignRight', |
|
25
|
|
|
'AlignCenter', |
|
26
|
|
|
'AlignDefault' |
|
27
|
|
|
] |
|
28
|
|
|
# check width |
|
29
|
|
|
options['width'] = [0.1, 0.2, 0.3, 0.4] |
|
30
|
|
|
parse_table_options(options, raw_table_list) |
|
31
|
|
|
assert options['width'] == [0.1, 0.2, 0.3, 0.4] |
|
32
|
|
|
# auto-width |
|
33
|
|
|
raw_table_list = [ |
|
34
|
|
|
['asdfdfdfguhfdhghfdgkla', '334\n2', '**la**', '4'], |
|
35
|
|
|
['5', '6', '7', '8'] |
|
36
|
|
|
] |
|
37
|
|
|
options['width'] = None |
|
38
|
|
|
options['table-width'] = 1.2 |
|
39
|
|
|
parse_table_options(options, raw_table_list) |
|
40
|
|
|
assert options['width'] == [22 / 32 * 1.2, |
|
41
|
|
|
3 / 32 * 1.2, 6 / 32 * 1.2, 1 / 32 * 1.2] |
|
42
|
|
|
return |
|
43
|
|
|
|