[vtk-developers] VTK-Python test interface: alive and kicking!
Prabhu Ramachandran
prabhu at aero.iitm.ernet.in
Sun Sep 15 05:24:30 EDT 2002
hi,
At last I've completed the VTK-Python unittest interface that I've
been promising for so long. Here is what is available.
What?
As I'd elaborated earlier this adds a unittest framework for
VTK-Python. Look at the features section for more information.
Where is it?
I've added a new directory Wrapping/Python/vtk/test/ which contains
two modules -- Testing.py and BlackBox.py. Don't worry about
BlackBox.py for now. It is used internally by Testing.py.
Features:
(+) Simple and well documented.
(+) Uses unittest Test cases so all of its conveniences are
available.
(+) Minimally intrusive. Hopefully the interface is sufficiently
easy that you dont need to worry about many things. You just
concentrate on writing the test cases.
(+) Supports multiple images per test file, i.e. you can
generate/test 10 different images from one file. There is no magic
script that parses this test and grabs the image as is done in
rtImageTest.tcl.
(+) Supports multiple valid images per image test, i.e. you can have
Cone.png, Cone_1.png, ..., Cone_n.png and the helper function will
find the best matching interface. (BTW, I've tested this with a
couple of images and it works well).
(+) Prints out XML information suitable for Dart. I hope I've done
this right. The unittest itself will print a short message as can
be seen in my example test run at the end of this message.
(+) Allows for arbitrary BlackBox tests to be performed. Currently
this only does the following:
(-) Tests if the class is parseable by vtk.util.vtkMethodParser.
(-) Rudimentary tests for Get/Set and Boolean methods.
(+) Support for various command line arguments including --help
(-h), --data-dir (-D) , --baseline-root (-B), --no-image(-n),
--interact(-I), --verbose(-v). All these are done in one place and
the test writer never has to bother with all these.
Examples:
The vtk/test/Testing.py has a sample test that only does blackbox
testing. This is a trivial case.
I've also added two slightly more involved test cases.
Rendering/Testing/Python/TestTkRenderWidget.py
Rendering/Testing/Python/TestTkRenderWindowInteractor.py
I haven't create a CMakeLists.txt file or anything since I will not
be able to test it right now (I dont run dart either). I hope
someone can help me with that. Anyway, to run one of the tests do
this:
$ cd Rendering/Testing/Python
$ python TestTkRenderWidget.py -B ../../../../VTKData/Baseline/
<DartMeasurement name="ImageError" type="numeric/double"> 0.000000 </DartMeasurement>
----------------------------------------------------------------------
Ran 4 tests in 0.259s
OK
<DartMeasurement name="BaselineImage" type="text/string">Standard</DartMeasurement> <DartMeasurement name="WallTime" type="numeric/double"> 0.261686 </DartMeasurement>
<DartMeasurement name="CPUTime" type="numeric/double"> 0.260000 </DartMeasurement>
In this case the test uses Graphics/Cone.png to test. Maybe thats
wrong? I've let this be for now and don't want to commit new test
images.
If the non-dart lines are a problem let me know and I can remove
them. I'm talking of these:
-----------------------------------------------------------------
Ran 4 tests in 0.259s
OK
Also, to check out the various options the scripts provide, try this:
$ python TestTkRenderWidget.py -h
...
$
Read the examples for more details.
So thats about it. Let me know what you folks think.
Have fun!
prabhu
More information about the vtk-developers
mailing list