From: Ben Darnell Date: Thu, 20 Feb 2025 19:21:42 +0000 (-0500) Subject: test: Avoid IOLoop(make_current=True) X-Git-Tag: v6.5.0b1~26^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c8fc890018f14b41dc1bbe5e560f61af041fba4f;p=thirdparty%2Ftornado.git test: Avoid IOLoop(make_current=True) This causes deprecation warnings in Python 3.14 --- diff --git a/tornado/test/ioloop_test.py b/tornado/test/ioloop_test.py index e5814325..acd3ec86 100644 --- a/tornado/test/ioloop_test.py +++ b/tornado/test/ioloop_test.py @@ -132,7 +132,7 @@ class TestIOLoop(AsyncTestCase): # Very crude test, just to make sure that we cover this case. # This also happens to be the first test where we run an IOLoop in # a non-main thread. - other_ioloop = IOLoop() + other_ioloop = IOLoop(make_current=False) thread = threading.Thread(target=other_ioloop.start) thread.start() with ignore_deprecation(): @@ -152,7 +152,7 @@ class TestIOLoop(AsyncTestCase): closing.set() other_ioloop.close(all_fds=True) - other_ioloop = IOLoop() + other_ioloop = IOLoop(make_current=False) thread = threading.Thread(target=target) thread.start() closing.wait() @@ -276,8 +276,12 @@ class TestIOLoop(AsyncTestCase): sockobj, port = bind_unused_port() socket_wrapper = SocketWrapper(sockobj) - io_loop = IOLoop() - io_loop.add_handler(socket_wrapper, lambda fd, events: None, IOLoop.READ) + io_loop = IOLoop(make_current=False) + io_loop.run_sync( + lambda: io_loop.add_handler( + socket_wrapper, lambda fd, events: None, IOLoop.READ + ) + ) io_loop.close(all_fds=True) self.assertTrue(socket_wrapper.closed) diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index c1cff83c..a40435e8 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -210,7 +210,7 @@ class SimpleHTTPClientTestMixin(AsyncTestCase): SimpleAsyncHTTPClient(), SimpleAsyncHTTPClient(force_instance=True) ) # different IOLoops use different objects - with closing(IOLoop()) as io_loop2: + with closing(IOLoop(make_current=False)) as io_loop2: async def make_client(): await gen.sleep(0)