[Python-modules-commits] [python-mplexporter] 28/135: Added test_plotly.py which contains functions for nose tests.

Wolfgang Borgert debacle at moszumanska.debian.org
Tue Sep 23 21:19:00 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-mplexporter.

commit 107f69d6900eaf87ba4d5520a4d1a26c774d2712
Author: theengineear <andseier at gmail.com>
Date:   Thu Feb 20 19:41:00 2014 -0800

    Added test_plotly.py which contains functions for nose tests.
    
    To test these in command line, 'cd' into 'tests' dir and type:
    
    nosetests test_plotly.py
    
    Everything should pass.
---
 mplexporter/tests/test_plotly.py | 60 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/mplexporter/tests/test_plotly.py b/mplexporter/tests/test_plotly.py
new file mode 100644
index 0000000..c8c694d
--- /dev/null
+++ b/mplexporter/tests/test_plotly.py
@@ -0,0 +1,60 @@
+from ..exporter import Exporter
+from ..renderers import PlotlyRenderer
+
+import matplotlib
+matplotlib.use('Agg')
+import matplotlib.pyplot as plt
+
+
+T1_OUTPUT = """
+opening figure
+  opening axis 1
+    draw line with 20 points
+    draw 10 markers
+  closing axis 1
+closing figure
+"""
+
+T2_OUTPUT = """
+opening figure
+  opening axis 1
+    draw line with 20 points
+  closing axis 1
+  opening axis 2
+    draw 10 markers
+  closing axis 2
+closing figure
+"""
+
+
+def test_1():
+    fig, ax = plt.subplots()
+    ax.plot(range(20), '-k')
+    ax.plot(range(10), '.k')
+
+    renderer = PlotlyRenderer()
+    exporter = Exporter(renderer)
+    exporter.run(fig)
+
+    for line1, line2 in zip(renderer.output.strip().split(),
+                            T1_OUTPUT.strip().split()):
+        assert line1 == line2
+
+
+def test_2():
+    plt.figure(1)
+    plt.subplot(211)
+    plt.plot(range(20), '-k')
+    plt.subplot(212)
+    plt.plot(range(10), '.k')
+    fig = plt.gcf()
+
+    renderer = PlotlyRenderer()
+    exporter = Exporter(renderer)
+    exporter.run(fig)
+    plt.show()
+    print renderer.output
+
+    for line1, line2 in zip(renderer.output.strip().split(),
+                            T2_OUTPUT.strip().split()):
+        assert line1 == line2
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-mplexporter.git



More information about the Python-modules-commits mailing list