Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 518050c

Browse filesBrowse files
authored
gh-103780: Use patch instead of mock in asyncio unix events test (#103782)
1 parent 04ea048 commit 518050c
Copy full SHA for 518050c

File tree

1 file changed

+4
-5
lines changed
Filter options

1 file changed

+4
-5
lines changed

‎Lib/test/test_asyncio/test_unix_events.py

Copy file name to clipboardExpand all lines: Lib/test/test_asyncio/test_unix_events.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,11 +1712,11 @@ class PolicyTests(unittest.TestCase):
17121712
def create_policy(self):
17131713
return asyncio.DefaultEventLoopPolicy()
17141714

1715-
def test_get_default_child_watcher(self):
1715+
@mock.patch('asyncio.unix_events.can_use_pidfd')
1716+
def test_get_default_child_watcher(self, m_can_use_pidfd):
1717+
m_can_use_pidfd.return_value = False
17161718
policy = self.create_policy()
17171719
self.assertIsNone(policy._watcher)
1718-
unix_events.can_use_pidfd = mock.Mock()
1719-
unix_events.can_use_pidfd.return_value = False
17201720
with self.assertWarns(DeprecationWarning):
17211721
watcher = policy.get_child_watcher()
17221722
self.assertIsInstance(watcher, asyncio.ThreadedChildWatcher)
@@ -1725,10 +1725,9 @@ def test_get_default_child_watcher(self):
17251725
with self.assertWarns(DeprecationWarning):
17261726
self.assertIs(watcher, policy.get_child_watcher())
17271727

1728+
m_can_use_pidfd.return_value = True
17281729
policy = self.create_policy()
17291730
self.assertIsNone(policy._watcher)
1730-
unix_events.can_use_pidfd = mock.Mock()
1731-
unix_events.can_use_pidfd.return_value = True
17321731
with self.assertWarns(DeprecationWarning):
17331732
watcher = policy.get_child_watcher()
17341733
self.assertIsInstance(watcher, asyncio.PidfdChildWatcher)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.