[issue11910] test_heapq C tests are not skipped when _heapq is missing

Ezio Melotti report at bugs.python.org
Sat May 7 23:48:10 CEST 2011


Ezio Melotti <ezio.melotti at gmail.com> added the comment:

Thanks (for the record the changeset is a8b82c283524).

> Overall, I don't think the current approach to testing both paths
> is elegant.
That's the most elegant way we have now.  If all the Python tests pass for the C version too, a base class could be avoided and the C tests could inherit directly from the Python ones (possibly adding additional C-specific tests).  I actually prefer this way because the Python tests should be an invariant of all the Python implementations and additional tests for the accelerations can be created from them with appropriate skip decorators, e.g.:
class PythonFooTests(TestCase):
    ...

@skipUnless(is_cypthon and c_foo)
class CFooTests(PythonTest):
   ...

@skipUnless(is_jython and j_foo)
class JFooTests(PythonTest):
   ...

This also avoid to list the tests explicitly at the end to exclude the base class (e.g. currently we have to exclude TestHeap, and list TestHeapC and TestHeapPy).


We could come up with some smart class decorator that runs a set of tests with and without accelerations, but it will make more difficult to add tests specific to the C or Python versions.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11910>
_______________________________________


More information about the Python-bugs-list mailing list