New submission from Patrick Smith <pjs...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue14819> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com