[vtk-developers] Update: Making Tests Python 3/2 compatible.

David Gobbi david.gobbi at gmail.com
Mon Aug 10 10:01:44 EDT 2015


Very nice.  On my machine I see only six failures.  This is with Python
3.2, and apparently no NetCDF.

The following tests FAILED:
354 - vtkCommonDataModelPython-TestTemplates (Failed)
969 - vtkFiltersSourcesPython-squadViewer (Failed)
1944 - vtkRenderingTkPython-cursor3D (Failed)
1945 - vtkRenderingTkPython-TestTextActor3D (Failed)
1946 - vtkRenderingTkPython-TestTkRenderWidget (Failed)
1947 - vtkRenderingTkPython-TestTkRenderWindowInteractor (Failed)

The TestTemplates seems to be a simple syntax error, the "u" string prefix
is not allowed in python 3.2.
    354:   File "Common/DataModel/Testing/Python/TestTemplates.py", line 56
    354:     value = u"hello"

The squadViewer test is failing because it is still trying to import
Tkinter.

There were no changes with respect to floats, and the only really
suspicious int related change is the change in the division operator.

It looks like this is very close to prime time.  After this, it's only the
examples that need to be converted (and of course the Paraview and Slicer
teams have a lot of work ahead of them, but our experience here should give
them confidence!)

 - David



On Mon, Aug 10, 2015 at 3:00 AM, Andrew Maclean <andrew.amaclean at gmail.com>
wrote:

> So far so good,(2to3 has been very helpful).
> ---------------------------------------------------------------
> 98% tests passed, 12 tests failed out of 489
>
> Total Test time (real) = 1046.22 sec
>
> The following tests FAILED:
>         655 - vtkFiltersGeneralPython-TestMultiBlockStreamer (Failed)
>         676 - vtkFiltersGeneralPython-splitVectors (Failed)
>         677 - vtkFiltersGeneralPython-streamTracer (Failed)
>         1263 - vtkIONetCDFPython-NetCDFCF2DBounds (Failed)
>         1264 - vtkIONetCDFPython-NetCDFCFSetOutputType (Failed)
>         1265 - vtkIONetCDFPython-NetCDFCFSphericalCoords (Failed)
>         1266 - vtkIONetCDFPython-NetCDFCFUnstructured (Failed)
>         1267 - vtkIONetCDFPython-NetCDFReader (Failed)
>         1935 - vtkRenderingTkPython-cursor3D (Failed)
>         1936 - vtkRenderingTkPython-TestTextActor3D (Failed)
>         1937 - vtkRenderingTkPythvtkIONetCDFPythonon-TestTkRenderWidget
> (Failed)
>         1938 - vtkRenderingTkPython-TestTkRenderWindowInteractor (Failed)
>
> See: https://gitlab.kitware.com/vtk/vtk/merge_requests/514#note_26500
> currently marked as WIP.
> ---------------------------------------------------------------
>
> David, one interesting thing that I am seeing is that the above
> vtkFiltersGeneralPython and vtkIONetCDFPython tests that fail actually pass
> in Python 2 but the image generated is different in Python 3. Could there
> some slight difference in the wrapping e.g the treatment of floats or ints?
>
> I may be able to get the vtkIONetCDFPython working. I suspect cursor3D.py
> may now be Ok.
>
> Once I fix errors in vtkRenderingTkPython I will remove the WIP:
> appellation.
>
>
> Regards
>    Andrew
>
>
> On Sun, Aug 9, 2015 at 11:50 AM, Andrew Maclean <andrew.amaclean at gmail.com
> > wrote:
>
>> Thanks for that.
>> I rebased against the master and picked up those changes.
>>
>> Andrew
>>
>> On Sat, Aug 8, 2015 at 10:48 PM, David Gobbi <david.gobbi at gmail.com>
>> wrote:
>>
>>> Wow, I didn't expect so many of the tests to be passing so soon. Thanks
>>> for looking into these so quickly!
>>>
>>> I just merged some fixes to my own 2 to 3 changes for
>>> Common/Core/Testing/Python and Wrapping/Python/vtk.  These are mainly fixes
>>> to "print" calls that I'd been lazy with the first time.
>>>
>>> So please rebase either onto the current master or onto this commit:
>>> https://gitlab.kitware.com/dgobbi/vtk/commit/26ad0555
>>>
>>> Cheers,
>>>
>>>  - David
>>>
>>> On Fri, Aug 7, 2015 at 10:51 PM, Andrew Maclean <
>>> andrew.amaclean at gmail.com> wrote:
>>>
>>>> David you have done a fantastic job!
>>>>
>>>>
>>>> Just letting you know that by making python 3 changes to
>>>> rtImageTest.py, info.py, catch.py and expr.py,
>>>>
>>>> I am now getting 89% tests passed, 54 tests failed out of 481!
>>>>
>>>> In rtImageTest.py, Tkinter is now tkinter in Python 3.
>>>> For handling renamed libraries is code like this acceptable (it works
>>>> in Python 2 and 3):
>>>> ##################
>>>> try:
>>>>     # for Python2
>>>>     print('Trying Python2')
>>>>     import Tkinter as tk
>>>>     print('Python2 Ok')
>>>> except ImportError:
>>>>     # for Python3
>>>>     print('Trying Python3')
>>>>     import tkinter as tk
>>>>     print('Python3 Ok')
>>>> pythonTk = tk.Tk()
>>>> ##################
>>>>
>>>> The remaining failing tests are mainly related to the print statement,
>>>> failures relating to string.find [in vtkMethodParser.py], no module named
>>>> exceptions etc.
>>>>
>>>> I need to do some thorough testing on  rtImageTest.py, info.py,
>>>> catch.py, expr.py, vtkMethodParser.py for both Python 2.7 and Python 3.4
>>>>
>>>> I am so impressed that these few changes have worked.
>>>>
>>>> I'll try and get all the tests passing for Python 2 and Python 3 in the
>>>> next week or so and create a merge request for review.
>>>>
>>>> Regards
>>>>     Andrew
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20150810/86b1d41a/attachment-0001.html>


More information about the vtk-developers mailing list