summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py48
1 files changed, 20 insertions, 28 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index 6ba8894..915ad55 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -4,7 +4,6 @@ import signal
import sys
import unittest
import warnings
-import functools
from unittest import mock
import asyncio
@@ -31,19 +30,6 @@ PROGRAM_CAT = [
'sys.stdout.buffer.write(data)'))]
-@functools.cache
-def _has_pidfd_support():
- if not hasattr(os, 'pidfd_open'):
- return False
-
- try:
- os.close(os.pidfd_open(os.getpid()))
- except OSError:
- return False
-
- return True
-
-
def tearDownModule():
asyncio.set_event_loop_policy(None)
@@ -688,7 +674,7 @@ if sys.platform != 'win32':
self.loop = policy.new_event_loop()
self.set_event_loop(self.loop)
- watcher = self.Watcher()
+ watcher = self._get_watcher()
watcher.attach_loop(self.loop)
policy.set_child_watcher(watcher)
@@ -703,32 +689,38 @@ if sys.platform != 'win32':
class SubprocessThreadedWatcherTests(SubprocessWatcherMixin,
test_utils.TestCase):
- Watcher = unix_events.ThreadedChildWatcher
-
- @unittest.skip("bpo-38323: MultiLoopChildWatcher has a race condition \
- and these tests can hang the test suite")
- class SubprocessMultiLoopWatcherTests(SubprocessWatcherMixin,
- test_utils.TestCase):
-
- Watcher = unix_events.MultiLoopChildWatcher
+ def _get_watcher(self):
+ return unix_events.ThreadedChildWatcher()
class SubprocessSafeWatcherTests(SubprocessWatcherMixin,
test_utils.TestCase):
- Watcher = unix_events.SafeChildWatcher
+ def _get_watcher(self):
+ with self.assertWarns(DeprecationWarning):
+ return unix_events.SafeChildWatcher()
+
+ class MultiLoopChildWatcherTests(test_utils.TestCase):
+
+ def test_warns(self):
+ with self.assertWarns(DeprecationWarning):
+ unix_events.MultiLoopChildWatcher()
class SubprocessFastWatcherTests(SubprocessWatcherMixin,
test_utils.TestCase):
- Watcher = unix_events.FastChildWatcher
+ def _get_watcher(self):
+ with self.assertWarns(DeprecationWarning):
+ return unix_events.FastChildWatcher()
@unittest.skipUnless(
- _has_pidfd_support(),
+ unix_events.can_use_pidfd(),
"operating system does not support pidfds",
)
class SubprocessPidfdWatcherTests(SubprocessWatcherMixin,
test_utils.TestCase):
- Watcher = unix_events.PidfdChildWatcher
+
+ def _get_watcher(self):
+ return unix_events.PidfdChildWatcher()
class GenericWatcherTests(test_utils.TestCase):
@@ -758,7 +750,7 @@ if sys.platform != 'win32':
@unittest.skipUnless(
- _has_pidfd_support(),
+ unix_events.can_use_pidfd(),
"operating system does not support pidfds",
)
def test_create_subprocess_with_pidfd(self):