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
|