File: test_plugin.py

package info (click to toggle)
python-mpld3 0.3git%2B20140910dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,808 kB
  • ctags: 1,095
  • sloc: python: 3,595; makefile: 187
file content (29 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (2)
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
"""
Test plugins
"""
import numpy as np
import matplotlib.pyplot as plt
from .. import fig_to_html, plugins
from numpy.testing import assert_equal


class FakePlugin(plugins.PluginBase):
    JAVASCRIPT = """TEST--this is the javascript--TEST"""

    def __init__(self, fig):
        self.fig = fig
        self.dict_ = {}
        self.css_ = """TEST--this is the css--TEST"""


def test_plugins():
    fig, ax = plt.subplots()
    ax.plot(np.arange(10), np.random.random(10),
            '--ok', alpha=0.3, zorder=10, lw=2)
    plug = FakePlugin(fig)
    plugins.connect(fig, plug)

    for template_type in ["simple", "notebook", "general"]:
        html = fig_to_html(fig, template_type=template_type)
        assert plug.JAVASCRIPT in html
        assert plug.css_ in html