markummitchell / engauge-digitizer

Extracts data points from images of graphs
GNU General Public License v2.0
1.24k stars 213 forks source link

Add python unit tests #330

Closed markummitchell closed 5 years ago

markummitchell commented 5 years ago

The python scripts have just gained several new features. Unit tests are needed to ensure these new features work correctly in a variety of test cases that they may encounter - linear/log, 0-4 axis points, well/malformed coordinates. Some possibilities for testing are at https://docs.python-guide.org/writing/tests/

kylesower commented 5 years ago

I should be able to work on this next week if it isn't too pressing. I still need to figure out log plots in the script (and eventually polar plots, though I've never had to use a polar plot in Engauge), but I did resolve my issue with the infinite slope. I have plenty of files to use for test cases.

markummitchell commented 5 years ago

I am thinking it may be easier for maintenance if a script generates the test input files, while still a giving very thorough test coverage. There can be 5 different numbers of axis points (0-4), 4 combinations of linear/log scales, 2 combinations of cartesian/polar coordinates ... I can work on setting that up. BTW I and others (200 downloads a day) appreciate your support, but please do not feel you have to handle every test case yourself

kylesower commented 5 years ago

It would certainly be better if a script generated the test files. I don't mind writing the test script; it's a fun little project to work on, and it'll give me experience testing code. I am unsure how to generate the input files, though, so that portion would be helpful. We appreciate all the work you do and your responsiveness, so it's nice to give back a bit.

markummitchell commented 5 years ago

Just playing I came up with contrib/python/test.py. I would say at this point it has a lot of potential, because in its current state it does not have much else going for it. Feel free to rescue it :-)

markummitchell commented 5 years ago

If you want to take a break, I'd be happy to jump in.

kylesower commented 5 years ago

Sure. Thank you. I created a pull request for the stuff I've done so far.

markummitchell commented 5 years ago

Thanks for all the great work.

markummitchell commented 5 years ago

Working, with one glitch. When callEngauge python function is called on Travis build system, the return value is -11 which means segfault. The code works fine, but probably something in the gui threads, or in the use of pip installed lxml,numpy and pandas libraries triggers a -11 return code. There is a chance that this is fixed by package installs of python3-lxml, python3-numpy and python3-pandas, but that is for another day.