[issue14819] Add `assertIsSubclass` and `assertNotIsSubclass` to `unittest.TestCase`
Patrick Smith
report at bugs.python.org
Tue May 15 23:13:15 CEST 2012
New submission from Patrick Smith <pjs482 at gmail.com>:
The attached patch adds two helper methods to `unittest.TestCase`: `assertIsSubclass` and `assertIsNotSubclass`. These methods are similar to the `assertIsInstance` and `assertIsNotInstance` methods that are already part of `unittest.TestCase`. They allow one to test if a class is a subclass of another class using the `issubclass` builtin.
These methods can be used like:
self.assertIsSubclass(cls, parent_cls)
These new methods provide a nicer error message and more consistent interface over the alternatives:
self.assertTrue(issubclass(cls, parent_cls))
assert issubclass(cls, parent_cls)
----------
components: Library (Lib)
files: assertissubclass.patch
keywords: patch
messages: 160762
nosy: patricksmith
priority: normal
severity: normal
status: open
title: Add `assertIsSubclass` and `assertNotIsSubclass` to `unittest.TestCase`
type: enhancement
Added file: http://bugs.python.org/file25600/assertissubclass.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14819>
_______________________________________
More information about the Python-bugs-list
mailing list