diff --git a/tornado/test/asyncio_test.py b/tornado/test/asyncio_test.py index 3a08ea494a..348c0cebb1 100644 --- a/tornado/test/asyncio_test.py +++ b/tornado/test/asyncio_test.py @@ -26,10 +26,6 @@ class AsyncIOLoopTest(AsyncTestCase): - def get_new_ioloop(self): - io_loop = AsyncIOLoop(make_current=False) - return io_loop - @property def asyncio_loop(self): return self.io_loop.asyncio_loop # type: ignore diff --git a/tornado/testing.py b/tornado/testing.py index 68459f297a..bef04ca780 100644 --- a/tornado/testing.py +++ b/tornado/testing.py @@ -135,7 +135,8 @@ class AsyncTestCase(unittest.TestCase): By default, a new `.IOLoop` is constructed for each test and is available as ``self.io_loop``. If the code being tested requires a - global `.IOLoop`, subclasses should override `get_new_ioloop` to return it. + reused global `.IOLoop`, subclasses should override `get_new_ioloop` to return it, + although this is deprecated as of Tornado 6.3. The `.IOLoop`'s ``start`` and ``stop`` methods should not be called directly. Instead, use `self.stop ` and `self.wait @@ -182,14 +183,9 @@ def __init__(self, methodName: str = "runTest") -> None: self._test_generator = None # type: Optional[Union[Generator, Coroutine]] def setUp(self) -> None: - setup_with_context_manager(self, warnings.catch_warnings()) - warnings.filterwarnings( - "ignore", - message="There is no current event loop", - category=DeprecationWarning, - module=r"tornado\..*", - ) super().setUp() + if type(self).get_new_ioloop is not AsyncTestCase.get_new_ioloop: + warnings.warn("get_new_ioloop is deprecated", DeprecationWarning) self.io_loop = self.get_new_ioloop() asyncio.set_event_loop(self.io_loop.asyncio_loop) # type: ignore[attr-defined] @@ -250,6 +246,9 @@ def get_new_ioloop(self) -> IOLoop: singletons using the default `.IOLoop`) or if a per-test event loop is being provided by another system (such as ``pytest-asyncio``). + + .. deprecated:: 6.3 + This method will be removed in Tornado 7.0. """ return IOLoop(make_current=False)