[Python-Dev] Using more specific methods in Python unit tests

Stefan Behnel stefan_ml at behnel.de
Sun Feb 16 13:38:36 CET 2014

Jeff Allen, 16.02.2014 11:23:
> I spend a *lot* of time working with the Python test suite on behalf of
> Jython, so I appreciate the care CPython puts into its testing. To a large
> extent, tests written for CPython drive Jython development: I suspect I
> work with a lot more failing tests than anyone here.

Careful with such a bold statement. ;)

> What Nick says above is also not false, as general guidance, but taken as
> an iron rule seem to argue against concurrent development at all. Don't we
> manage this change pretty well already? I see little risk of problems 1-3
> in the actual proposal, as the changes themselves are 99% of the "drop-in
> replacement" type:
> -        self.assertTrue(isinstance(x, int))
> +        self.assertIsInstance(x, int)

While I generally second Nick's objections to this, I also agree that the
kind of change above is such an obvious and straight forward improvement
(since unittest doesn't have py.test's assert analysis) that I'm +1 on
applying them. I've been annoyed more than once by a test failure in
CPython's test suite (when compiled with Cython) that required me to look
up and read the test source and rerun it locally in order to actually
understand what was happening. Seeing a more informative error message
right on our CI server would certainly help, if only to get a quicker idea
if this failure is worth taking a closer look at.


More information about the Python-Dev mailing list