/
test_interactive.py
93 lines (81 loc) · 1.65 KB
/
test_interactive.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
from __future__ import absolute_import, print_function, division
import petl as etl
from petl.test.helpers import eq_
def test_repr():
table = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 2))
expect = str(etl.look(table))
actual = repr(etl.wrap(table))
eq_(expect, actual)
def test_str():
table = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 2))
expect = str(etl.look(table, vrepr=str))
actual = str(etl.wrap(table))
eq_(expect, actual)
def test_repr_html():
table = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 2))
expect = """<table class='petl'>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td style='text-align: right'>1</td>
</tr>
<tr>
<td>b</td>
<td style='text-align: right'>2</td>
</tr>
<tr>
<td>c</td>
<td style='text-align: right'>2</td>
</tr>
</tbody>
</table>
"""
actual = etl.wrap(table)._repr_html_()
for l1, l2 in zip(expect.split('\n'), actual.split('\n')):
eq_(l1, l2)
def test_repr_html_limit():
table = (('foo', 'bar'),
('a', 1),
('b', 2),
('c', 2))
# lower limit
etl.config.display_limit = 2
expect = """<table class='petl'>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>a</td>
<td style='text-align: right'>1</td>
</tr>
<tr>
<td>b</td>
<td style='text-align: right'>2</td>
</tr>
</tbody>
</table>
<p><strong>...</strong></p>
"""
actual = etl.wrap(table)._repr_html_()
print(actual)
for l1, l2 in zip(expect.split('\n'), actual.split('\n')):
eq_(l1, l2)