Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib and unit tests [duplicate]

I have a GTK application that draws some plots of some live data. The code is split so that one method deals with creating the plots and another one with updating the data and re-drawing said plots.

Clearly running the application allows me to see if the plots are sensible and look how I want them to look. However, this is a mechanical and visual test.

Is there a way to unit test this?

I could set a test method and mock all the calls to matplotlib then check that said calls were made. However, this feels like testing the implementation and not behaviour.

like image 570
Sardathrion - against SE abuse Avatar asked Jun 20 '26 19:06

Sardathrion - against SE abuse


1 Answers

This is coming two years late, but Matplotlib (now?) seems to have a webpage that gives developer's tips for testing.

They also talk about how to write an image comparison test, for example, which might be what you're looking for.

like image 119
Praveen Avatar answered Jun 23 '26 16:06

Praveen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!