@@ -1712,11 +1712,11 @@ class PolicyTests(unittest.TestCase):
1712
1712
def create_policy (self ):
1713
1713
return asyncio .DefaultEventLoopPolicy ()
1714
1714
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
1716
1718
policy = self .create_policy ()
1717
1719
self .assertIsNone (policy ._watcher )
1718
- unix_events .can_use_pidfd = mock .Mock ()
1719
- unix_events .can_use_pidfd .return_value = False
1720
1720
with self .assertWarns (DeprecationWarning ):
1721
1721
watcher = policy .get_child_watcher ()
1722
1722
self .assertIsInstance (watcher , asyncio .ThreadedChildWatcher )
@@ -1725,10 +1725,9 @@ def test_get_default_child_watcher(self):
1725
1725
with self .assertWarns (DeprecationWarning ):
1726
1726
self .assertIs (watcher , policy .get_child_watcher ())
1727
1727
1728
+ m_can_use_pidfd .return_value = True
1728
1729
policy = self .create_policy ()
1729
1730
self .assertIsNone (policy ._watcher )
1730
- unix_events .can_use_pidfd = mock .Mock ()
1731
- unix_events .can_use_pidfd .return_value = True
1732
1731
with self .assertWarns (DeprecationWarning ):
1733
1732
watcher = policy .get_child_watcher ()
1734
1733
self .assertIsInstance (watcher , asyncio .PidfdChildWatcher )
0 commit comments