summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2010-12-01 02:32:32 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2010-12-01 02:32:32 (GMT)
commited3a7d2d601ce1e65b0bacf24676440631158ec8 (patch)
treed8e7df73bc7d9aa2c3cfafd4adb9838dffcea230 /Lib/test
parentf10c400b91e44c5c744f4ddc05d90933cba3a56b (diff)
downloadcpython-ed3a7d2d601ce1e65b0bacf24676440631158ec8.zip
cpython-ed3a7d2d601ce1e65b0bacf24676440631158ec8.tar.gz
cpython-ed3a7d2d601ce1e65b0bacf24676440631158ec8.tar.bz2
#10273: Rename assertRegexpMatches and assertRaisesRegexp to assertRegex and assertRaisesRegex.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_abc.py4
-rw-r--r--Lib/test/test_asyncore.py4
-rw-r--r--Lib/test/test_concurrent_futures.py20
-rw-r--r--Lib/test/test_contextlib.py4
-rw-r--r--Lib/test/test_dis.py4
-rw-r--r--Lib/test/test_memoryview.py2
-rw-r--r--Lib/test/test_runpy.py4
-rw-r--r--Lib/test/test_smtplib.py8
-rw-r--r--Lib/test/test_ssl.py40
-rw-r--r--Lib/test/test_unicode.py2
-rw-r--r--Lib/test/test_urlparse.py20
-rw-r--r--Lib/test/test_xmlrpc.py4
-rw-r--r--Lib/test/test_zlib.py2
13 files changed, 59 insertions, 59 deletions
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index 1b51644..52d2187 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -192,8 +192,8 @@ class TestABC(unittest.TestCase):
def test_register_non_class(self):
class A(metaclass=abc.ABCMeta):
pass
- self.assertRaisesRegexp(TypeError, "Can only register classes",
- A.register, 4)
+ self.assertRaisesRegex(TypeError, "Can only register classes",
+ A.register, 4)
def test_registration_transitiveness(self):
class A(metaclass=abc.ABCMeta):
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index 57e759d..7b84ba2 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -312,8 +312,8 @@ class DispatcherTests(unittest.TestCase):
d = asyncore.dispatcher(socket.socket())
# make sure the error message no longer refers to the socket
# object but the dispatcher instance instead
- self.assertRaisesRegexp(AttributeError, 'dispatcher instance',
- getattr, d, 'foo')
+ self.assertRaisesRegex(AttributeError, 'dispatcher instance',
+ getattr, d, 'foo')
# cheap inheritance with the underlying socket is supposed
# to still work but a DeprecationWarning is expected
with warnings.catch_warnings(record=True) as w:
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index 430a9be..e4e38ec 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -682,18 +682,18 @@ class FutureTests(unittest.TestCase):
self.assertTrue(was_cancelled)
def test_repr(self):
- self.assertRegexpMatches(repr(PENDING_FUTURE),
- '<Future at 0x[0-9a-f]+ state=pending>')
- self.assertRegexpMatches(repr(RUNNING_FUTURE),
- '<Future at 0x[0-9a-f]+ state=running>')
- self.assertRegexpMatches(repr(CANCELLED_FUTURE),
- '<Future at 0x[0-9a-f]+ state=cancelled>')
- self.assertRegexpMatches(repr(CANCELLED_AND_NOTIFIED_FUTURE),
- '<Future at 0x[0-9a-f]+ state=cancelled>')
- self.assertRegexpMatches(
+ self.assertRegex(repr(PENDING_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=pending>')
+ self.assertRegex(repr(RUNNING_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=running>')
+ self.assertRegex(repr(CANCELLED_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=cancelled>')
+ self.assertRegex(repr(CANCELLED_AND_NOTIFIED_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=cancelled>')
+ self.assertRegex(
repr(EXCEPTION_FUTURE),
'<Future at 0x[0-9a-f]+ state=finished raised IOError>')
- self.assertRegexpMatches(
+ self.assertRegex(
repr(SUCCESSFUL_FUTURE),
'<Future at 0x[0-9a-f]+ state=finished returned int>')
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index a3e9b07..d6bb5b8 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -231,7 +231,7 @@ class TestContextDecorator(unittest.TestCase):
def test_contextdecorator_with_exception(self):
context = mycontext()
- with self.assertRaisesRegexp(NameError, 'foo'):
+ with self.assertRaisesRegex(NameError, 'foo'):
with context:
raise NameError('foo')
self.assertIsNotNone(context.exc)
@@ -265,7 +265,7 @@ class TestContextDecorator(unittest.TestCase):
self.assertTrue(context.started)
raise NameError('foo')
- with self.assertRaisesRegexp(NameError, 'foo'):
+ with self.assertRaisesRegex(NameError, 'foo'):
test()
self.assertIsNotNone(context.exc)
self.assertIs(context.exc[0], NameError)
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index d12bcda..7a61493 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -354,14 +354,14 @@ class CodeInfoTests(unittest.TestCase):
def test_code_info(self):
self.maxDiff = 1000
for x, expected in self.test_pairs:
- self.assertRegexpMatches(dis.code_info(x), expected)
+ self.assertRegex(dis.code_info(x), expected)
def test_show_code(self):
self.maxDiff = 1000
for x, expected in self.test_pairs:
with captured_stdout() as output:
dis.show_code(x)
- self.assertRegexpMatches(output.getvalue(), expected+"\n")
+ self.assertRegex(output.getvalue(), expected+"\n")
def test_main():
run_unittest(DisTests, CodeInfoTests)
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index 7bccf8b..9a52fe90 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -226,7 +226,7 @@ class AbstractMemoryTests:
self.assertTrue(wr() is None, wr())
def _check_released(self, m, tp):
- check = self.assertRaisesRegexp(ValueError, "released")
+ check = self.assertRaisesRegex(ValueError, "released")
with check: bytes(m)
with check: m.tobytes()
with check: m.tolist()
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index 94e47d6..ad3ab39 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -329,7 +329,7 @@ argv0 = sys.argv[0]
def _check_import_error(self, script_name, msg):
msg = re.escape(msg)
- self.assertRaisesRegexp(ImportError, msg, run_path, script_name)
+ self.assertRaisesRegex(ImportError, msg, run_path, script_name)
def test_basic_script(self):
with temp_dir() as script_dir:
@@ -403,7 +403,7 @@ argv0 = sys.argv[0]
script_name = self._make_test_script(script_dir, mod_name, source)
zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
msg = "recursion depth exceeded"
- self.assertRaisesRegexp(RuntimeError, msg, run_path, zip_name)
+ self.assertRaisesRegex(RuntimeError, msg, run_path, zip_name)
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 795586a..4651f37 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -319,12 +319,12 @@ class DebuggingServerTests(unittest.TestCase):
self.assertEqual(self.output.getvalue(), mexpect)
debugout = smtpd.DEBUGSTREAM.getvalue()
sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
- self.assertRegexpMatches(debugout, sender)
+ self.assertRegex(debugout, sender)
for addr in ('John', 'Sally', 'Fred', 'root@localhost',
'warped@silly.walks.com'):
to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
re.MULTILINE)
- self.assertRegexpMatches(debugout, to_addr)
+ self.assertRegex(debugout, to_addr)
def testSendMessageWithSomeAddresses(self):
# Make sure nothing breaks if not all of the three 'to' headers exist
@@ -347,11 +347,11 @@ class DebuggingServerTests(unittest.TestCase):
self.assertEqual(self.output.getvalue(), mexpect)
debugout = smtpd.DEBUGSTREAM.getvalue()
sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
- self.assertRegexpMatches(debugout, sender)
+ self.assertRegex(debugout, sender)
for addr in ('John', 'Dinsdale'):
to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
re.MULTILINE)
- self.assertRegexpMatches(debugout, to_addr)
+ self.assertRegex(debugout, to_addr)
class NonConnectingTests(unittest.TestCase):
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 087f964..c9f03c7 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -185,17 +185,17 @@ class BasicSocketTests(unittest.TestCase):
def test_errors(self):
sock = socket.socket()
- self.assertRaisesRegexp(ValueError,
+ self.assertRaisesRegex(ValueError,
"certfile must be specified",
ssl.wrap_socket, sock, keyfile=CERTFILE)
- self.assertRaisesRegexp(ValueError,
+ self.assertRaisesRegex(ValueError,
"certfile must be specified for server-side operations",
ssl.wrap_socket, sock, server_side=True)
- self.assertRaisesRegexp(ValueError,
+ self.assertRaisesRegex(ValueError,
"certfile must be specified for server-side operations",
ssl.wrap_socket, sock, server_side=True, certfile="")
s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)
- self.assertRaisesRegexp(ValueError, "can't connect in server-side mode",
+ self.assertRaisesRegex(ValueError, "can't connect in server-side mode",
s.connect, (HOST, 8080))
with self.assertRaises(IOError) as cm:
with socket.socket() as sock:
@@ -310,7 +310,7 @@ class ContextTests(unittest.TestCase):
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
ctx.set_ciphers("ALL")
ctx.set_ciphers("DEFAULT")
- with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
ctx.set_ciphers("^$:,;?*'dorothyx")
@skip_if_broken_ubuntu_ssl
@@ -358,24 +358,24 @@ class ContextTests(unittest.TestCase):
with self.assertRaises(IOError) as cm:
ctx.load_cert_chain(WRONGCERT)
self.assertEqual(cm.exception.errno, errno.ENOENT)
- with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
ctx.load_cert_chain(BADCERT)
- with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
ctx.load_cert_chain(EMPTYCERT)
# Separate key and cert
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
ctx.load_cert_chain(ONLYCERT, ONLYKEY)
ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY)
ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY)
- with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
ctx.load_cert_chain(ONLYCERT)
- with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
ctx.load_cert_chain(ONLYKEY)
- with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT)
# Mismatching key and cert
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- with self.assertRaisesRegexp(ssl.SSLError, "key values mismatch"):
+ with self.assertRaisesRegex(ssl.SSLError, "key values mismatch"):
ctx.load_cert_chain(SVN_PYTHON_ORG_ROOT_CERT, ONLYKEY)
def test_load_verify_locations(self):
@@ -389,7 +389,7 @@ class ContextTests(unittest.TestCase):
with self.assertRaises(IOError) as cm:
ctx.load_verify_locations(WRONGCERT)
self.assertEqual(cm.exception.errno, errno.ENOENT)
- with self.assertRaisesRegexp(ssl.SSLError, "PEM lib"):
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
ctx.load_verify_locations(BADCERT)
ctx.load_verify_locations(CERTFILE, CAPATH)
ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH)
@@ -434,8 +434,8 @@ class NetworkedTests(unittest.TestCase):
# this should fail because we have no verification certs
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED)
- self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed",
- s.connect, ("svn.python.org", 443))
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, ("svn.python.org", 443))
s.close()
# this should succeed because we specify the root cert
@@ -469,7 +469,7 @@ class NetworkedTests(unittest.TestCase):
# This should fail because we have no verification certs
ctx.verify_mode = ssl.CERT_REQUIRED
s = ctx.wrap_socket(socket.socket(socket.AF_INET))
- self.assertRaisesRegexp(ssl.SSLError, "certificate verify failed",
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
s.connect, ("svn.python.org", 443))
s.close()
# This should succeed because we specify the root cert
@@ -587,7 +587,7 @@ class NetworkedTests(unittest.TestCase):
cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")
s.connect(remote)
# Error checking can happen at instantiation or when connecting
- with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
with socket.socket(socket.AF_INET) as sock:
s = ssl.wrap_socket(sock,
cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
@@ -1499,8 +1499,8 @@ else:
c.settimeout(0.2)
c.connect((host, port))
# Will attempt handshake and time out
- self.assertRaisesRegexp(ssl.SSLError, "timed out",
- ssl.wrap_socket, c)
+ self.assertRaisesRegex(ssl.SSLError, "timed out",
+ ssl.wrap_socket, c)
finally:
c.close()
try:
@@ -1508,8 +1508,8 @@ else:
c = ssl.wrap_socket(c)
c.settimeout(0.2)
# Will attempt handshake and time out
- self.assertRaisesRegexp(ssl.SSLError, "timed out",
- c.connect, (host, port))
+ self.assertRaisesRegex(ssl.SSLError, "timed out",
+ c.connect, (host, port))
finally:
c.close()
finally:
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index ddbeac2..c5a0f80 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1427,7 +1427,7 @@ class UnicodeTest(string_tests.CommonTest,
# non-ascii format, ascii argument: ensure that PyUnicode_FromFormat()
# raises an error for a non-ascii format string.
- self.assertRaisesRegexp(ValueError,
+ self.assertRaisesRegex(ValueError,
'^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format '
'string, got a non-ASCII byte: 0xe9$',
format_unicode, b'unicode\xe9=%s', 'ascii')
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index e67c2b6..73e4de5 100644
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -629,25 +629,25 @@ class UrlParseTestCase(unittest.TestCase):
def test_mixed_types_rejected(self):
# Several functions that process either strings or ASCII encoded bytes
# accept multiple arguments. Check they reject mixed type input
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlparse("www.python.org", b"http")
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlparse(b"www.python.org", "http")
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlsplit("www.python.org", b"http")
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlsplit(b"www.python.org", "http")
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlunparse(( b"http", "www.python.org","","","",""))
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlunparse(("http", b"www.python.org","","","",""))
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlunsplit((b"http", "www.python.org","","",""))
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urlunsplit(("http", b"www.python.org","","",""))
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urljoin("http://python.org", b"http://python.org")
- with self.assertRaisesRegexp(TypeError, "Cannot mix str"):
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
urllib.parse.urljoin(b"http://python.org", "http://python.org")
def _check_result_type(self, str_type):
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index ca8db86..6117aab 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -715,8 +715,8 @@ class GzipServerTestCase(BaseServerTestCase):
t.encode_threshold = None
t.fake_gzip = True
p = xmlrpclib.ServerProxy(URL, transport=t)
- cm = self.assertRaisesRegexp(xmlrpclib.ProtocolError,
- re.compile(r"\b400\b"))
+ cm = self.assertRaisesRegex(xmlrpclib.ProtocolError,
+ re.compile(r"\b400\b"))
with cm:
p.pow(6, 8)
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 05adde4..0f5a1ca 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -143,7 +143,7 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
def test_incomplete_stream(self):
# An useful error message is given
x = zlib.compress(HAMLET_SCENE)
- self.assertRaisesRegexp(zlib.error,
+ self.assertRaisesRegex(zlib.error,
"Error -5 while decompressing data: incomplete or truncated stream",
zlib.decompress, x[:-1])