Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.core
Commits
17bf3313
Commit
17bf3313
authored
Mar 14, 2019
by
Samuel GAIST
Browse files
[test][test_plotter] Code cleanup
parent
99757b29
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/core/test/test_plotter.py
View file @
17bf3313
...
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment