Skip to content

Commit efe323f

Browse files
authored
Merge pull request #1 from NeuroML/feat/plot-animated-test
test(plotting): add test for animated plots
2 parents c6b45a7 + cb5d3f9 commit efe323f

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/plot/test_plot.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Copyright 2023 NeuroML contributors
88
"""
99

10+
import random
11+
import pytest
1012
import unittest
1113
import logging
1214
import pathlib as pl
@@ -19,9 +21,42 @@
1921

2022

2123
class TestPlot(BaseTestCase):
22-
2324
"""Test Plot module"""
2425

26+
@pytest.mark.localonly
27+
def test_generate_plot_animated(self):
28+
"""Test generate_plot function."""
29+
filename = "tests/plot/test_generate_plot.gif"
30+
31+
# remove the file first
32+
try:
33+
pl.Path(filename).unlink()
34+
except FileNotFoundError:
35+
pass
36+
37+
numpoints = 1000
38+
xs = range(0, numpoints)
39+
ys = random.choices(list(range(0, 1000)), k=numpoints)
40+
ys2 = random.choices(list(range(0, 1500)), k=numpoints)
41+
42+
generate_plot(
43+
[xs, xs],
44+
[ys, ys2],
45+
"Test plot",
46+
xaxis="x",
47+
yaxis="y",
48+
grid=False,
49+
show_plot_already=True,
50+
animate=True,
51+
legend_position="right",
52+
)
53+
54+
"""
55+
TODO: used when testing file save
56+
self.assertIsFile(filename)
57+
pl.Path(filename).unlink()
58+
"""
59+
2560
def test_generate_plot(self):
2661
"""Test generate_plot function."""
2762
filename = "tests/plot/test_generate_plot.png"

0 commit comments

Comments
 (0)