Zim

Comment 6 for bug 794476

Revision history for this message
Jaap Karssenberg (jaap.karssenberg) wrote : Re: [Bug 794476] Re: Unable to run test case with Python 2.6

2011/6/9 Jiří Janoušek <email address hidden>

> $ PYTHONPATH='.' python ./tests/applications.py
> Traceback (most recent call last):
> File "./tests/applications.py", line 8, in <module>
> import gtk
> ImportError: No module named gtk
>
>
> Yeah, tests/__init__.py seems to be unable to import this test case because
> of GTK import error. Is there any way to make tests/__init__.py skip test
> cases with import error? I guess I can run non-GTK tests manually one after
> one, but it is uncomfortable.
>

Best way to handle it low level would be to wrap the imports in the test in
a try block and than put a decorator on the test class to skip if the import
failed. (See python 2.7 unittest documentation for facilities to skip
tests.) This would require tracking down all tests that directly or
indirectly require gtk. Bit of work, but a patch for this would be very
welcome.

Alternative would be to hard code a list of test modules that require gtk in
tests/__init__.py and have them removed from __all__ when gtk can not be
imported. Less clean solution but less work and still acceptable to me.
(Although I would like to see a warning when gtk tests are skipped - or
signal the test manager that the test is skipped.)

-- Jaap