New submission from Daniel Wagner-Hall: The following code in a unittest test is a no-op:
self.assertRaises(lambda: 1) I would expect this to fail the test, because I naively assumed omitting the exception class would act as: self.assertRaises(BaseException, lambda: 1) verifying that *any* Exception is raised. I believe the correct behaviour is to raise a TypeError if excClass is not a BaseException-derived type, similar to if a non-type is passed as the first arg to issubclass. Attached is a patch to do so. It also removes a no-op self.assertRaises from libimport's tests (because it started failing when I ran the tests with the patch). That assertion is redundant, because the two lines above perform the assertion being attempted. ---------- components: Tests files: assertRaises.patch keywords: patch messages: 169596 nosy: illicitonion priority: normal severity: normal status: open title: unittest assertRaises should verify excClass is actually a BaseException class type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file27079/assertRaises.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15836> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com