Commit 17bf3313 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[test][test_plotter] Code cleanup

parent 99757b29
......@@ -36,9 +36,6 @@
import imghdr
import numpy
import six
import nose.tools
from ..plotter import Plotter
......@@ -49,22 +46,22 @@ from . import prefix
def test_default():
p = Plotter(prefix, data=None)
assert not p.valid
nose.tools.assert_false(p.valid)
def test_scatter():
p = Plotter(prefix, "user/scatter/1")
assert p.valid, "\n * %s" % "\n * ".join(p.errors)
nose.tools.assert_true(p.valid, "\n * %s" % "\n * ".join(p.errors))
def do_plot(mimetype):
p = Plotter(prefix, "user/scatter/1")
assert p.valid
nose.tools.assert_true(p.valid)
runnable = p.runner()
assert runnable.ready is False
nose.tools.assert_false(runnable.ready)
runnable.setup(
{
"xlabel": "Temperature in C",
......@@ -73,7 +70,7 @@ def do_plot(mimetype):
"mimetype": mimetype,
}
)
assert runnable.ready
nose.tools.assert_true(runnable.ready)
# now produce the plot
data = p.dataformat.type(
......@@ -111,18 +108,14 @@ def test_plot_jpeg():
def test_plot_pdf():
fig = do_plot("application/pdf")
if six.PY2:
assert fig.startswith("%PDF")
else:
assert fig.startswith(b"%PDF")
nose.tools.assert_true(fig.startswith(b"%PDF"))
# with open('test.pdf', 'wb') as f: f.write(fig)
def test_plot_many_lines():
p = Plotter(prefix, "user/scatter/1")
assert p.valid
nose.tools.assert_true(p.valid)
data1 = p.dataformat.type(
data=[
......@@ -157,7 +150,7 @@ def test_plot_many_lines():
)
runnable = p.runner()
assert runnable.ready is False
nose.tools.assert_false(runnable.ready)
runnable.setup(
{
"title": "Test plot",
......@@ -169,7 +162,7 @@ def test_plot_many_lines():
"mimetype": "image/png",
}
)
assert runnable.ready
nose.tools.assert_true(runnable.ready)
fig = runnable.process([data1, data2])
nose.tools.eq_(imghdr.what("test.png", fig), "png")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment