bpo-30397: Add re.Pattern and re.Match. (#1646)

This commit is contained in:
Serhiy Storchaka 2017-10-04 20:09:49 +03:00 committed by GitHub
parent 8d5a3aad2f
commit 0b5e61ddca
13 changed files with 120 additions and 107 deletions

View file

@ -24,8 +24,6 @@ from optparse import make_option, Option, \
from optparse import _match_abbrev
from optparse import _parse_num
retype = type(re.compile(''))
class InterceptedError(Exception):
def __init__(self,
error_message=None,
@ -107,7 +105,7 @@ Args were %(args)s.""" % locals ())
func(*args, **kwargs)
except expected_exception as err:
actual_message = str(err)
if isinstance(expected_message, retype):
if isinstance(expected_message, re.Pattern):
self.assertTrue(expected_message.search(actual_message),
"""\
expected exception message pattern: