[issue14819] Add `assertIsSubclass` and `assertNotIsSubclass` to `unittest.TestCase`

Brian Jones report at bugs.python.org
Wed May 16 14:17:05 CEST 2012


Brian Jones <bkjones at gmail.com> added the comment:

I can't find a previous discussion of this topic. If you know the list it happened on, or the bug#, let me know as I'd be curious to see the discussion. 

While I could concede that checking type is arguably a more common case than checking ancestry, I think that checks like assertIsSubclass have a lot of value. 

First, if you view your collection of unit tests as pools of change detectors, this type of check is very valuable in order to detect changes in ancestry that result from a refactoring. 

Second, if you use a test-driven style of development, this is a very convenient method to have as your tests and code evolve, because the amount of code you have to write to create a failing test becomes a one-liner. 

As an aside, I *would* like to see the submitted patch provide more detail upon failure. Namely, if X is not a subclass of Y, it would be nice to know what it *is* a subclass of in the resulting output.

----------
nosy: +Brian.Jones
status: pending -> open

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


More information about the Python-bugs-list mailing list