Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 authored Oct 8, 2022
1 parent fce0416 commit b6ac303
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
10 changes: 7 additions & 3 deletions Lib/test/test_asyncio/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import unittest
from unittest import mock
import weakref

import warnings
if sys.platform not in ('win32', 'vxworks'):
import tty

Expand Down Expand Up @@ -2055,7 +2055,9 @@ def test_remove_fds_after_closing(self):
class UnixEventLoopTestsMixin(EventLoopTestsMixin):
def setUp(self):
super().setUp()
watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(self.loop)
asyncio.set_child_watcher(watcher)

Expand Down Expand Up @@ -2652,7 +2654,9 @@ def setUp(self):
asyncio.set_event_loop(self.loop)

if sys.platform != 'win32':
watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(self.loop)
asyncio.set_child_watcher(watcher)

Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import threading
import unittest
from unittest import mock
import warnings
from test.support import socket_helper
try:
import ssl
Expand Down Expand Up @@ -791,8 +792,9 @@ def test_read_all_from_pipe_reader(self):
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
transport, _ = self.loop.run_until_complete(
self.loop.connect_read_pipe(lambda: protocol, pipe))

watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
watcher.attach_loop(self.loop)
try:
asyncio.set_child_watcher(watcher)
Expand Down
21 changes: 16 additions & 5 deletions Lib/test/test_asyncio/test_unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import threading
import unittest
from unittest import mock
import warnings
from test.support import os_helper
from test.support import socket_helper

Expand Down Expand Up @@ -1686,12 +1687,16 @@ def test_close(self, m_waitpid):

class SafeChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):
def create_watcher(self):
return asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return asyncio.SafeChildWatcher()


class FastChildWatcherTests (ChildWatcherTestsMixin, test_utils.TestCase):
def create_watcher(self):
return asyncio.FastChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
return asyncio.FastChildWatcher()


class PolicyTests(unittest.TestCase):
Expand Down Expand Up @@ -1724,7 +1729,9 @@ def test_get_default_child_watcher(self):

def test_get_child_watcher_after_set(self):
policy = self.create_policy()
watcher = asyncio.FastChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
watcher = asyncio.FastChildWatcher()

policy.set_child_watcher(watcher)
self.assertIs(policy._watcher, watcher)
Expand All @@ -1745,7 +1752,9 @@ def f():
policy.get_event_loop().close()

policy = self.create_policy()
policy.set_child_watcher(asyncio.SafeChildWatcher())
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
policy.set_child_watcher(asyncio.SafeChildWatcher())

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

# Explicitly setup SafeChildWatcher,
# default ThreadedChildWatcher has no _loop property
watcher = asyncio.SafeChildWatcher()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
watcher = asyncio.SafeChildWatcher()
policy.set_child_watcher(watcher)
watcher.attach_loop(loop)

Expand Down

0 comments on commit b6ac303

Please sign in to comment.