Skip to content

Commit b6ac303

Browse files
fix tests
1 parent fce0416 commit b6ac303

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

Lib/test/test_asyncio/test_events.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import unittest
2323
from unittest import mock
2424
import weakref
25-
25+
import warnings
2626
if sys.platform not in ('win32', 'vxworks'):
2727
import tty
2828

@@ -2055,7 +2055,9 @@ def test_remove_fds_after_closing(self):
20552055
class UnixEventLoopTestsMixin(EventLoopTestsMixin):
20562056
def setUp(self):
20572057
super().setUp()
2058-
watcher = asyncio.SafeChildWatcher()
2058+
with warnings.catch_warnings():
2059+
warnings.simplefilter('ignore', DeprecationWarning)
2060+
watcher = asyncio.SafeChildWatcher()
20592061
watcher.attach_loop(self.loop)
20602062
asyncio.set_child_watcher(watcher)
20612063

@@ -2652,7 +2654,9 @@ def setUp(self):
26522654
asyncio.set_event_loop(self.loop)
26532655

26542656
if sys.platform != 'win32':
2655-
watcher = asyncio.SafeChildWatcher()
2657+
with warnings.catch_warnings():
2658+
warnings.simplefilter('ignore', DeprecationWarning)
2659+
watcher = asyncio.SafeChildWatcher()
26562660
watcher.attach_loop(self.loop)
26572661
asyncio.set_child_watcher(watcher)
26582662

Lib/test/test_asyncio/test_streams.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import threading
1010
import unittest
1111
from unittest import mock
12+
import warnings
1213
from test.support import socket_helper
1314
try:
1415
import ssl
@@ -791,8 +792,9 @@ def test_read_all_from_pipe_reader(self):
791792
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
792793
transport, _ = self.loop.run_until_complete(
793794
self.loop.connect_read_pipe(lambda: protocol, pipe))
794-
795-
watcher = asyncio.SafeChildWatcher()
795+
with warnings.catch_warnings():
796+
warnings.simplefilter('ignore', DeprecationWarning)
797+
watcher = asyncio.SafeChildWatcher()
796798
watcher.attach_loop(self.loop)
797799
try:
798800
asyncio.set_child_watcher(watcher)

Lib/test/test_asyncio/test_unix_events.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import threading
1313
import unittest
1414
from unittest import mock
15+
import warnings
1516
from test.support import os_helper
1617
from test.support import socket_helper
1718

@@ -1686,12 +1687,16 @@ def test_close(self, m_waitpid):
16861687

16871688
class SafeChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):
16881689
def create_watcher(self):
1689-
return asyncio.SafeChildWatcher()
1690+
with warnings.catch_warnings():
1691+
warnings.simplefilter("ignore", DeprecationWarning)
1692+
return asyncio.SafeChildWatcher()
16901693

16911694

16921695
class FastChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):
16931696
def create_watcher(self):
1694-
return asyncio.FastChildWatcher()
1697+
with warnings.catch_warnings():
1698+
warnings.simplefilter("ignore", DeprecationWarning)
1699+
return asyncio.FastChildWatcher()
16951700

16961701

16971702
class PolicyTests(unittest.TestCase):
@@ -1724,7 +1729,9 @@ def test_get_default_child_watcher(self):
17241729

17251730
def test_get_child_watcher_after_set(self):
17261731
policy = self.create_policy()
1727-
watcher = asyncio.FastChildWatcher()
1732+
with warnings.catch_warnings():
1733+
warnings.simplefilter("ignore", DeprecationWarning)
1734+
watcher = asyncio.FastChildWatcher()
17281735

17291736
policy.set_child_watcher(watcher)
17301737
self.assertIs(policy._watcher, watcher)
@@ -1745,7 +1752,9 @@ def f():
17451752
policy.get_event_loop().close()
17461753

17471754
policy = self.create_policy()
1748-
policy.set_child_watcher(asyncio.SafeChildWatcher())
1755+
with warnings.catch_warnings():
1756+
warnings.simplefilter("ignore", DeprecationWarning)
1757+
policy.set_child_watcher(asyncio.SafeChildWatcher())
17491758

17501759
th = threading.Thread(target=f)
17511760
th.start()
@@ -1757,7 +1766,9 @@ def test_child_watcher_replace_mainloop_existing(self):
17571766

17581767
# Explicitly setup SafeChildWatcher,
17591768
# default ThreadedChildWatcher has no _loop property
1760-
watcher = asyncio.SafeChildWatcher()
1769+
with warnings.catch_warnings():
1770+
warnings.simplefilter("ignore", DeprecationWarning)
1771+
watcher = asyncio.SafeChildWatcher()
17611772
policy.set_child_watcher(watcher)
17621773
watcher.attach_loop(loop)
17631774

0 commit comments

Comments
 (0)