forked from pyecharts/pyecharts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_table.py
More file actions
31 lines (22 loc) · 859 Bytes
/
test_table.py
File metadata and controls
31 lines (22 loc) · 859 Bytes
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
from unittest.mock import patch
from nose.tools import assert_in
from pyecharts.components import Table
from pyecharts.globals import CurrentConfig, NotebookType
def _gen_table() -> Table:
table = Table()
headers = ["City name", "Area", "Population", "Annual Rainfall"]
rows = [["Brisbane", 5905, 1857594, 1146.4], ["Perth", 5386, 1554769, 869.4]]
table.add(headers, rows)
return table
@patch("pyecharts.render.engine.write_utf8_html_file")
def test_table_base(fake_writer):
table = _gen_table()
table.render()
_, content = fake_writer.call_args[0]
assert_in("fl-table", content)
def test_table_render_notebook():
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_NOTEBOOK
table = _gen_table()
html = table.render_notebook().__html__()
assert_in("City name", html)
assert_in("Brisbane", html)