From 5c16457c6c460ef25b52c467ad50895a94335b20 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 19 Aug 2021 13:21:09 +0300 Subject: [PATCH] Replace deprecated unittest aliases --- tornado/test/concurrent_test.py | 4 ++-- tornado/test/httpclient_test.py | 2 +- tornado/test/iostream_test.py | 2 +- tornado/test/log_test.py | 6 +++--- tornado/test/options_test.py | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tornado/test/concurrent_test.py b/tornado/test/concurrent_test.py index b121c6971..33fcb6505 100644 --- a/tornado/test/concurrent_test.py +++ b/tornado/test/concurrent_test.py @@ -122,7 +122,7 @@ class ClientTestMixin(object): future = self.client.capitalize("HELLO") self.io_loop.add_future(future, self.stop) self.wait() - self.assertRaisesRegexp(CapError, "already capitalized", future.result) # type: ignore + self.assertRaisesRegex(CapError, "already capitalized", future.result) # type: ignore def test_generator(self: typing.Any): @gen.coroutine @@ -135,7 +135,7 @@ class ClientTestMixin(object): def test_generator_error(self: typing.Any): @gen.coroutine def f(): - with self.assertRaisesRegexp(CapError, "already capitalized"): + with self.assertRaisesRegex(CapError, "already capitalized"): yield self.client.capitalize("HELLO") self.io_loop.run_sync(f) diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index fd9a97864..6021d6759 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -474,7 +474,7 @@ Transfer-Encoding: chunked streaming_callback=streaming_callback, ) self.assertEqual(len(first_line), 1, first_line) - self.assertRegexpMatches(first_line[0], "HTTP/[0-9]\\.[0-9] 200.*\r\n") + self.assertRegex(first_line[0], "HTTP/[0-9]\\.[0-9] 200.*\r\n") self.assertEqual(chunks, [b"asdf", b"qwer"]) @gen_test diff --git a/tornado/test/iostream_test.py b/tornado/test/iostream_test.py index 797a2dfc1..8e8e9f477 100644 --- a/tornado/test/iostream_test.py +++ b/tornado/test/iostream_test.py @@ -784,7 +784,7 @@ class TestIOStreamMixin(TestReadWriteMixin): "tornado.iostream.BaseIOStream._try_inline_read", side_effect=IOError("boom"), ): - with self.assertRaisesRegexp(IOError, "boom"): + with self.assertRaisesRegex(IOError, "boom"): client.read_until_close() finally: server.close() diff --git a/tornado/test/log_test.py b/tornado/test/log_test.py index 8450e50b9..77a0e5946 100644 --- a/tornado/test/log_test.py +++ b/tornado/test/log_test.py @@ -112,7 +112,7 @@ class LogFormatterTest(unittest.TestCase): # This will be "Exception: \xe9" on python 2 or # "Exception: b'\xe9'" on python 3. output = self.get_output() - self.assertRegexpMatches(output, br"Exception.*\\xe9") + self.assertRegex(output, br"Exception.*\\xe9") # The traceback contains newlines, which should not have been escaped. self.assertNotIn(br"\n", output) @@ -148,7 +148,7 @@ class EnablePrettyLoggingTest(unittest.TestCase): filenames = glob.glob(tmpdir + "/test_log*") self.assertEqual(1, len(filenames)) with open(filenames[0]) as f: - self.assertRegexpMatches(f.read(), r"^\[E [^]]*\] hello$") + self.assertRegex(f.read(), r"^\[E [^]]*\] hello$") finally: for handler in self.logger.handlers: handler.flush() @@ -168,7 +168,7 @@ class EnablePrettyLoggingTest(unittest.TestCase): filenames = glob.glob(tmpdir + "/test_log*") self.assertEqual(1, len(filenames)) with open(filenames[0]) as f: - self.assertRegexpMatches(f.read(), r"^\[E [^]]*\] hello$") + self.assertRegex(f.read(), r"^\[E [^]]*\] hello$") finally: for handler in self.logger.handlers: handler.flush() diff --git a/tornado/test/options_test.py b/tornado/test/options_test.py index 6aedbec32..633703dc8 100644 --- a/tornado/test/options_test.py +++ b/tornado/test/options_test.py @@ -262,7 +262,7 @@ class OptionsTest(unittest.TestCase): options.define("foo") with self.assertRaises(Error) as cm: options.define("foo") - self.assertRegexpMatches(str(cm.exception), "Option.*foo.*already defined") + self.assertRegex(str(cm.exception), "Option.*foo.*already defined") def test_error_redefine_underscore(self): # Ensure that the dash/underscore normalization doesn't @@ -279,7 +279,7 @@ class OptionsTest(unittest.TestCase): options.define(a) with self.assertRaises(Error) as cm: options.define(b) - self.assertRegexpMatches( + self.assertRegex( str(cm.exception), "Option.*foo.bar.*already defined" ) -- 2.47.2