summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 97d2190..6b8acb2 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -59,10 +59,14 @@ class BaseTestCase(unittest.TestCase):
support.reap_children()
def tearDown(self):
- for inst in subprocess._active:
- inst.wait()
- subprocess._cleanup()
- self.assertFalse(subprocess._active, "subprocess._active not empty")
+ if not mswindows:
+ # subprocess._active is not used on Windows and is set to None.
+ for inst in subprocess._active:
+ inst.wait()
+ subprocess._cleanup()
+ self.assertFalse(
+ subprocess._active, "subprocess._active not empty"
+ )
self.doCleanups()
support.reap_children()
@@ -2679,8 +2683,12 @@ class POSIXProcessTestCase(BaseTestCase):
with support.check_warnings(('', ResourceWarning)):
p = None
- # check that p is in the active processes list
- self.assertIn(ident, [id(o) for o in subprocess._active])
+ if mswindows:
+ # subprocess._active is not used on Windows and is set to None.
+ self.assertIsNone(subprocess._active)
+ else:
+ # check that p is in the active processes list
+ self.assertIn(ident, [id(o) for o in subprocess._active])
def test_leak_fast_process_del_killed(self):
# Issue #12650: on Unix, if Popen.__del__() was called before the
@@ -2701,8 +2709,12 @@ class POSIXProcessTestCase(BaseTestCase):
p = None
os.kill(pid, signal.SIGKILL)
- # check that p is in the active processes list
- self.assertIn(ident, [id(o) for o in subprocess._active])
+ if mswindows:
+ # subprocess._active is not used on Windows and is set to None.
+ self.assertIsNone(subprocess._active)
+ else:
+ # check that p is in the active processes list
+ self.assertIn(ident, [id(o) for o in subprocess._active])
# let some time for the process to exit, and create a new Popen: this
# should trigger the wait() of p
@@ -2714,7 +2726,11 @@ class POSIXProcessTestCase(BaseTestCase):
pass
# p should have been wait()ed on, and removed from the _active list
self.assertRaises(OSError, os.waitpid, pid, 0)
- self.assertNotIn(ident, [id(o) for o in subprocess._active])
+ if mswindows:
+ # subprocess._active is not used on Windows and is set to None.
+ self.assertIsNone(subprocess._active)
+ else:
+ self.assertNotIn(ident, [id(o) for o in subprocess._active])
def test_close_fds_after_preexec(self):
fd_status = support.findfile("fd_status.py", subdir="subprocessdata")