1
|
|
|
#!/usr/bin/env python3 |
2
|
|
|
""" |
3
|
|
|
`header` and `markdown` is checked by `test_to_bool` instead |
4
|
|
|
""" |
5
|
|
|
from .context import init_table_options, check_table_options |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
def test_check_table_options(): |
9
|
|
|
init_options = {} |
10
|
|
|
init_table_options(init_options) |
11
|
|
|
options = init_options.copy() |
12
|
|
|
# check init is preserved |
13
|
|
|
check_table_options(options) |
14
|
|
|
assert options == init_options |
15
|
|
|
# check width |
16
|
|
|
# negative width |
17
|
|
|
options['width'] = [0.1, -0.2] |
18
|
|
|
check_table_options(options) |
19
|
|
|
assert options['width'] is None |
20
|
|
|
# invalid width |
21
|
|
|
options['width'] = "happy" |
22
|
|
|
check_table_options(options) |
23
|
|
|
assert options['width'] is None |
24
|
|
|
# invalid width 2 |
25
|
|
|
options['width'] = ["happy", "birthday"] |
26
|
|
|
check_table_options(options) |
27
|
|
|
assert options['width'] is None |
28
|
|
|
# check table-width |
29
|
|
|
# negative table-width |
30
|
|
|
options['table-width'] = -1 |
31
|
|
|
check_table_options(options) |
32
|
|
|
assert options['table-width'] == 1.0 |
33
|
|
|
# invalid table-width |
34
|
|
|
options['table-width'] = "happy" |
35
|
|
|
check_table_options(options) |
36
|
|
|
assert options['table-width'] == 1.0 |
37
|
|
|
# check include |
38
|
|
|
# invalid include: file doesn't exist |
39
|
|
|
options['include'] = 'abc.xyz' |
40
|
|
|
check_table_options(options) |
41
|
|
|
assert options['include'] is None |
42
|
|
|
# invalid include: wrong type |
43
|
|
|
options['include'] = True |
44
|
|
|
check_table_options(options) |
45
|
|
|
assert options['include'] is None |
46
|
|
|
# valid include |
47
|
|
|
options['include'] = 'tests/csv_tables.csv' |
48
|
|
|
check_table_options(options) |
49
|
|
|
assert options['include'] == 'tests/csv_tables.csv' |
50
|
|
|
return |
51
|
|
|
|