We start to setup the regression testing infrastructure for our data processing pipeline by writting a test for the EyeSize class.
Consider reading Testing Your Code — The Hitchhiker's Guide to Python
Let's have a look at a first implementation of function named eye_test that simply:
1066744) and save it to disk as TralitusSaltrator.jpgestimate and get back the segmented eye and estimated radius
In [106]:
%cd
%cd dexy/test
In [107]:
%more eyesize_0_basic_test.py
%run eyesize_0_basic_test.py
eyesize_basic_test()
Output information providing context, for example the current and expected value.
Note that logging information when functions and tests work as expected is not recommended, it will pollute the output and may prevent the developer from having his attention dran on real issue.
In [108]:
%more eyesize_1_noisy_test.py
%run eyesize_1_noisy_test.py
eyesize_noisy_test()
In [109]:
! rm TralitusSaltrator.jpg
! rm SegmentedEye.png
In [110]:
%more eyesize_2_cleanplate_test.py
%run eyesize_2_cleanplate_test.py
eyesize_cleanplate_test()
Having a way to know the origin of your data or how they have been created can be very helpful. Especially when providing sscce
Doing this could be as simple as appending an id to an input name, and appending either a value or an experiment name to an output name.
In [112]:
%more eyesize_3_withorigin_test.py
%run eyesize_3_withorigin_test.py
eyesize_withorigin_test()
In [114]:
ls inputs
In [115]:
ls outputs
In [117]:
!nosetests --nocapture -v