File: test_dependencies_not_imported.py

package info (click to toggle)
plotly 5.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 90,200 kB
  • sloc: python: 368,793; javascript: 213,159; sh: 49; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 985 bytes parent folder | download
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
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