Skip to content

Commit 9249dd8

Browse files
fixup tests
1 parent 45c43bc commit 9249dd8

File tree

4 files changed

+1
-127
lines changed

4 files changed

+1
-127
lines changed

Lib/test/test_asyncio/test_events.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ def setUp(self):
22142214
super().setUp()
22152215
with warnings.catch_warnings():
22162216
warnings.simplefilter('ignore', DeprecationWarning)
2217-
watcher = asyncio.SafeChildWatcher()
2217+
watcher = asyncio.ThreadedChildWatcher()
22182218
watcher.attach_loop(self.loop)
22192219
asyncio.set_child_watcher(watcher)
22202220

@@ -2833,13 +2833,6 @@ def setUp(self):
28332833
self.loop = asyncio.new_event_loop()
28342834
asyncio.set_event_loop(self.loop)
28352835

2836-
if sys.platform != 'win32':
2837-
with warnings.catch_warnings():
2838-
warnings.simplefilter('ignore', DeprecationWarning)
2839-
watcher = asyncio.SafeChildWatcher()
2840-
watcher.attach_loop(self.loop)
2841-
asyncio.set_child_watcher(watcher)
2842-
28432836
def tearDown(self):
28442837
try:
28452838
if sys.platform != 'win32':

Lib/test/test_asyncio/test_streams.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -822,52 +822,6 @@ async def client(addr):
822822
self.assertEqual(msg1, b"hello world 1!\n")
823823
self.assertEqual(msg2, b"hello world 2!\n")
824824

825-
@unittest.skipIf(sys.platform == 'win32', "Don't have pipes")
826-
@requires_subprocess()
827-
def test_read_all_from_pipe_reader(self):
828-
# See asyncio issue 168. This test is derived from the example
829-
# subprocess_attach_read_pipe.py, but we configure the
830-
# StreamReader's limit so that twice it is less than the size
831-
# of the data writer. Also we must explicitly attach a child
832-
# watcher to the event loop.
833-
834-
code = """\
835-
import os, sys
836-
fd = int(sys.argv[1])
837-
os.write(fd, b'data')
838-
os.close(fd)
839-
"""
840-
rfd, wfd = os.pipe()
841-
args = [sys.executable, '-c', code, str(wfd)]
842-
843-
pipe = open(rfd, 'rb', 0)
844-
reader = asyncio.StreamReader(loop=self.loop, limit=1)
845-
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
846-
transport, _ = self.loop.run_until_complete(
847-
self.loop.connect_read_pipe(lambda: protocol, pipe))
848-
with warnings.catch_warnings():
849-
warnings.simplefilter('ignore', DeprecationWarning)
850-
watcher = asyncio.SafeChildWatcher()
851-
watcher.attach_loop(self.loop)
852-
try:
853-
with warnings.catch_warnings():
854-
warnings.simplefilter('ignore', DeprecationWarning)
855-
asyncio.set_child_watcher(watcher)
856-
create = asyncio.create_subprocess_exec(
857-
*args,
858-
pass_fds={wfd},
859-
)
860-
proc = self.loop.run_until_complete(create)
861-
self.loop.run_until_complete(proc.wait())
862-
finally:
863-
with warnings.catch_warnings():
864-
warnings.simplefilter('ignore', DeprecationWarning)
865-
asyncio.set_child_watcher(None)
866-
867-
os.close(wfd)
868-
data = self.loop.run_until_complete(reader.read(-1))
869-
self.assertEqual(data, b'data')
870-
871825
def test_streamreader_constructor_without_loop(self):
872826
with self.assertRaisesRegex(RuntimeError, 'no current event loop'):
873827
asyncio.StreamReader()

Lib/test/test_asyncio/test_subprocess.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,15 +631,6 @@ async def kill_running():
631631
# the transport was not notified yet
632632
self.assertFalse(killed)
633633

634-
# Unlike SafeChildWatcher, FastChildWatcher does not pop the
635-
# callbacks if waitpid() is called elsewhere. Let's clear them
636-
# manually to avoid a warning when the watcher is detached.
637-
if (sys.platform != 'win32' and
638-
isinstance(self, SubprocessFastWatcherTests)):
639-
with warnings.catch_warnings():
640-
warnings.simplefilter('ignore', DeprecationWarning)
641-
asyncio.get_child_watcher()._callbacks.clear()
642-
643634
async def _test_popen_error(self, stdin):
644635
if sys.platform == 'win32':
645636
target = 'asyncio.windows_utils.Popen'

Lib/test/test_asyncio/test_unix_events.py

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,70 +1167,6 @@ def test_get_default_child_watcher(self, m_can_use_pidfd):
11671167
with self.assertWarns(DeprecationWarning):
11681168
self.assertIs(watcher, policy.get_child_watcher())
11691169

1170-
def test_get_child_watcher_after_set(self):
1171-
policy = self.create_policy()
1172-
with warnings.catch_warnings():
1173-
warnings.simplefilter("ignore", DeprecationWarning)
1174-
watcher = asyncio.FastChildWatcher()
1175-
policy.set_child_watcher(watcher)
1176-
1177-
self.assertIs(policy._watcher, watcher)
1178-
with self.assertWarns(DeprecationWarning):
1179-
self.assertIs(watcher, policy.get_child_watcher())
1180-
1181-
def test_get_child_watcher_thread(self):
1182-
1183-
def f():
1184-
policy.set_event_loop(policy.new_event_loop())
1185-
1186-
self.assertIsInstance(policy.get_event_loop(),
1187-
asyncio.AbstractEventLoop)
1188-
with warnings.catch_warnings():
1189-
warnings.simplefilter("ignore", DeprecationWarning)
1190-
watcher = policy.get_child_watcher()
1191-
1192-
self.assertIsInstance(watcher, asyncio.SafeChildWatcher)
1193-
self.assertIsNone(watcher._loop)
1194-
1195-
policy.get_event_loop().close()
1196-
1197-
policy = self.create_policy()
1198-
with warnings.catch_warnings():
1199-
warnings.simplefilter("ignore", DeprecationWarning)
1200-
policy.set_child_watcher(asyncio.SafeChildWatcher())
1201-
1202-
th = threading.Thread(target=f)
1203-
th.start()
1204-
th.join()
1205-
1206-
def test_child_watcher_replace_mainloop_existing(self):
1207-
policy = self.create_policy()
1208-
loop = policy.new_event_loop()
1209-
policy.set_event_loop(loop)
1210-
1211-
# Explicitly setup SafeChildWatcher,
1212-
# default ThreadedChildWatcher has no _loop property
1213-
with warnings.catch_warnings():
1214-
warnings.simplefilter("ignore", DeprecationWarning)
1215-
watcher = asyncio.SafeChildWatcher()
1216-
policy.set_child_watcher(watcher)
1217-
watcher.attach_loop(loop)
1218-
1219-
self.assertIs(watcher._loop, loop)
1220-
1221-
new_loop = policy.new_event_loop()
1222-
policy.set_event_loop(new_loop)
1223-
1224-
self.assertIs(watcher._loop, new_loop)
1225-
1226-
policy.set_event_loop(None)
1227-
1228-
self.assertIs(watcher._loop, None)
1229-
1230-
loop.close()
1231-
new_loop.close()
1232-
1233-
12341170
class TestFunctional(unittest.TestCase):
12351171

12361172
def setUp(self):

0 commit comments

Comments
 (0)