-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathtest_dependencies_not_imported.py
More file actions
35 lines (26 loc) · 984 Bytes
/
test_dependencies_not_imported.py
File metadata and controls
35 lines (26 loc) · 984 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
32
33
34
35
import sys
from . import version_skip
@version_skip
def test_dependencies_not_imported():
# Check that creating a figure without using numpy and pandas does not result in
# the import of numpy and pandas, even if they are installed.
assert "plotly" not in sys.modules
assert "numpy" not in sys.modules
assert "pandas" not in sys.modules
import plotly.graph_objects as go
fig = go.Figure().add_scatter(x=[0], y=[1])
fig.to_json()
assert "plotly" in sys.modules
assert "numpy" not in sys.modules
assert "pandas" not in sys.modules
# check that numpy is installed
import numpy as np
fig = go.Figure().add_scatter(x=np.array([0]), y=np.array([1]))
fig.to_json()
assert "numpy" in sys.modules
assert "pandas" not in sys.modules
# check that pandas is installed
import pandas as pd
fig = go.Figure().add_scatter(x=pd.Series([0]), y=pd.Series([1]))
fig.to_json()
assert "pandas" in sys.modules