cpython: 32407a677215 (original) (raw)

Mercurial > cpython

changeset 89980:32407a677215 3.4

backport: #20145: assert[Raises|Warns]Regex now raise TypeError on bad regex. Previously a non-string, non-regex second argument and missing callable argument could cause the test to appear to always pass. Initial patch by Kamilla Holanda. [#20145]

R David Murray rdmurray@bitdance.com
date Tue, 25 Mar 2014 15:31:50 -0400
parents aa2a05fe46ae
children 8f72f8359987 31e42208eb99
files Lib/unittest/case.py Lib/unittest/test/test_case.py Misc/ACKS Misc/NEWS
diffstat 4 files changed, 17 insertions(+), 1 deletions(-)[+] [-] Lib/unittest/case.py 2 Lib/unittest/test/test_case.py 12 Misc/ACKS 1 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -143,7 +143,7 @@ class _AssertRaisesBaseContext(_BaseTest self.obj_name = str(callable_obj) else: self.obj_name = None

--- a/Lib/unittest/test/test_case.py +++ b/Lib/unittest/test/test_case.py @@ -1126,6 +1126,18 @@ test case self.assertRaisesRegex, Exception, 'x', lambda: None)

+

+ def testAssertRaisesRegexMismatch(self): def Stub(): raise Exception('Unexpected')

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -546,6 +546,7 @@ Stefan Hoffmeister Albert Hofkamp Tomas Hoger Jonathan Hogg +Kamilla Holanda Steve Holden Akintayo Holder Thomas Holenstein

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -24,6 +24,9 @@ Core and Builtins Library ------- +- Issue #20145: assertRaisesRegex and assertWarnsRegex now raise a