diff -r 815b88454e3e Lib/test/test_importlib/builtin/test_loader.py --- a/Lib/test/test_importlib/builtin/test_loader.py Fri Aug 31 17:14:31 2012 -0400 +++ b/Lib/test/test_importlib/builtin/test_loader.py Sat Sep 01 02:29:00 2012 +0100 @@ -92,7 +92,6 @@ method = getattr(machinery.BuiltinImporter, meth_name) with self.assertRaises(ImportError) as cm: method(builtin_util.BAD_NAME) - self.assertRaises(builtin_util.BAD_NAME) diff -r 815b88454e3e Lib/unittest/case.py --- a/Lib/unittest/case.py Fri Aug 31 17:14:31 2012 -0400 +++ b/Lib/unittest/case.py Sat Sep 01 02:29:00 2012 +0100 @@ -99,12 +99,24 @@ raise _UnexpectedSuccess return wrapper +def _ensure_is_exception_type(e): + if not isinstance(e, type) or not issubclass(e, BaseException): + raise TypeError('assertRaises arg 1 must be an exception type ' + 'or tuple of exception types') + class _AssertRaisesBaseContext(object): def __init__(self, expected, test_case, callable_obj=None, expected_regex=None): self.expected = expected + + if type(expected) is tuple: + for e in expected: + _ensure_is_exception_type(e) + else: + _ensure_is_exception_type(expected) + self.test_case = test_case if callable_obj is not None: try: diff -r 815b88454e3e Lib/unittest/test/test_case.py --- a/Lib/unittest/test/test_case.py Fri Aug 31 17:14:31 2012 -0400 +++ b/Lib/unittest/test/test_case.py Sat Sep 01 02:29:00 2012 +0100 @@ -1027,6 +1027,31 @@ self.assertIsInstance(e, ExceptionMock) self.assertEqual(e.args[0], v) + def testAssertRaisesNoExceptionType(self): + try: + self.assertRaises(1) + self.fail("Expected TypeError") + except TypeError: + pass + + try: + self.assertRaises(object) + self.fail("Expected TypeError") + except TypeError: + pass + + try: + self.assertRaises((TypeError, 1)) + self.fail("Expected TypeError") + except TypeError: + pass + + try: + self.assertRaises((object, 1)) + self.fail("Expected TypeError") + except TypeError: + pass + def testAssertWarnsCallable(self): def _runtime_warn(): warnings.warn("foo", RuntimeWarning) diff -r 815b88454e3e Misc/ACKS --- a/Misc/ACKS Fri Aug 31 17:14:31 2012 -0400 +++ b/Misc/ACKS Sat Sep 01 02:29:00 2012 +0100 @@ -1102,6 +1102,7 @@ Frank Visser Johannes Vogel Sjoerd de Vries +Daniel Wagner-Hall Niki W. Waibel Wojtek Walczak Charles Waldman