diff options
author | Itamar Ostricher <itamarost@gmail.com> | 2023-04-24 20:12:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-24 20:12:48 (GMT) |
commit | 518050ced18422fd00fadc1a81b0d942b98e2e5b (patch) | |
tree | 68a645b8b5451622efb2a3c625e606d980e73d05 | |
parent | 04ea04807dc76955f56ad25a81a0947536343c09 (diff) | |
download | cpython-518050ced18422fd00fadc1a81b0d942b98e2e5b.zip cpython-518050ced18422fd00fadc1a81b0d942b98e2e5b.tar.gz cpython-518050ced18422fd00fadc1a81b0d942b98e2e5b.tar.bz2 |
gh-103780: Use patch instead of mock in asyncio unix events test (#103782)
-rw-r--r-- | Lib/test/test_asyncio/test_unix_events.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 9699947..cdf3eaa 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -1712,11 +1712,11 @@ class PolicyTests(unittest.TestCase): def create_policy(self): return asyncio.DefaultEventLoopPolicy() - def test_get_default_child_watcher(self): + @mock.patch('asyncio.unix_events.can_use_pidfd') + def test_get_default_child_watcher(self, m_can_use_pidfd): + m_can_use_pidfd.return_value = False policy = self.create_policy() self.assertIsNone(policy._watcher) - unix_events.can_use_pidfd = mock.Mock() - unix_events.can_use_pidfd.return_value = False with self.assertWarns(DeprecationWarning): watcher = policy.get_child_watcher() self.assertIsInstance(watcher, asyncio.ThreadedChildWatcher) @@ -1725,10 +1725,9 @@ class PolicyTests(unittest.TestCase): with self.assertWarns(DeprecationWarning): self.assertIs(watcher, policy.get_child_watcher()) + m_can_use_pidfd.return_value = True policy = self.create_policy() self.assertIsNone(policy._watcher) - unix_events.can_use_pidfd = mock.Mock() - unix_events.can_use_pidfd.return_value = True with self.assertWarns(DeprecationWarning): watcher = policy.get_child_watcher() self.assertIsInstance(watcher, asyncio.PidfdChildWatcher) |