-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathtest_html.py
47 lines (35 loc) · 965 Bytes
/
test_html.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
import sys
import pytest
import numpy as np
import plotly.graph_objs as go
import plotly.io as pio
from plotly.io._utils import plotly_cdn_url
if sys.version_info >= (3, 3):
import unittest.mock as mock
from unittest.mock import MagicMock
else:
import mock
from mock import MagicMock
# fixtures
# --------
@pytest.fixture
def fig1(request):
return go.Figure(
data=[
{
"type": "scatter",
"y": np.array([2, 1, 3, 2, 4, 2]),
"marker": {"color": "green"},
}
],
layout={"title": {"text": "Figure title"}},
)
# HTML
# ----
def test_versioned_cdn_included(fig1):
assert plotly_cdn_url() in pio.to_html(fig1, include_plotlyjs="cdn")
def test_html_deterministic(fig1):
div_id = "plotly-root"
assert pio.to_html(fig1, include_plotlyjs="cdn", div_id=div_id) == pio.to_html(
fig1, include_plotlyjs="cdn", div_id=div_id
)