]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
test: Avoid IOLoop(make_current=True)
authorBen Darnell <ben@bendarnell.com>
Thu, 20 Feb 2025 19:21:42 +0000 (14:21 -0500)
committerBen Darnell <ben@bendarnell.com>
Thu, 20 Feb 2025 19:21:42 +0000 (14:21 -0500)
This causes deprecation warnings in Python 3.14

tornado/test/ioloop_test.py
tornado/test/simple_httpclient_test.py

index e5814325c1e99fb653d2d16bae63c9b94cf1b51d..acd3ec868b99379c0d82d2c723509000758f15ca 100644 (file)
@@ -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)
 
index c1cff83c9ad6d7f9be31ff8ae71543ec2f3dcf8b..a40435e812d280d7cbcc1c97909af6c8b38d868c 100644 (file)
@@ -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)