summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-04 21:50:56 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-04 21:50:56 (GMT)
commitf0cbd821b9e5d0104755906fa0085bac87737e78 (patch)
tree004a246ea5b310e23fae987c89e6ab17c766d05a /Lib/test
parent9ed34bea3e3bf4e33e31d4a8d65b4778f0e5a50c (diff)
downloadcpython-f0cbd821b9e5d0104755906fa0085bac87737e78.zip
cpython-f0cbd821b9e5d0104755906fa0085bac87737e78.tar.gz
cpython-f0cbd821b9e5d0104755906fa0085bac87737e78.tar.bz2
Merged revisions 78661-78662 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78661 | florent.xicluna | 2010-03-04 20:40:48 +0100 (jeu, 04 mar 2010) | 2 lines Cleanup. ........ r78662 | florent.xicluna | 2010-03-04 22:31:58 +0100 (jeu, 04 mar 2010) | 2 lines #2777: Enable test_send_signal, test_kill and test_terminate on all platforms. ........ And fix an oversight of changeset 78510.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_subprocess.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 3229a8c..3de46c6 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -39,6 +39,12 @@ class ProcessTestCase(unittest.TestCase):
# doesn't crash on some buildbots (Alphas in particular).
support.reap_children()
+ def tearDown(self):
+ for inst in subprocess._active:
+ inst.wait()
+ subprocess._cleanup()
+ self.assertFalse(subprocess._active, "subprocess._active not empty")
+
def assertStderrEqual(self, stderr, expected, msg=None):
# In a debug build, stuff like "[6580 refs]" is printed to stderr at
# shutdown time. That frustrates tests trying to check stderr produced
@@ -548,13 +554,19 @@ class _SuppressCoreFiles(object):
pass
-@unittest.skipIf(sys.platform == "win32", "POSIX specific tests")
+@unittest.skipIf(mswindows, "POSIX specific tests")
class POSIXProcessTestCase(unittest.TestCase):
def setUp(self):
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
support.reap_children()
+ def tearDown(self):
+ for inst in subprocess._active:
+ inst.wait()
+ subprocess._cleanup()
+ self.assertFalse(subprocess._active, "subprocess._active not empty")
+
def test_exceptions(self):
# caught & re-raised exceptions
with self.assertRaises(OSError) as c:
@@ -636,15 +648,15 @@ class POSIXProcessTestCase(unittest.TestCase):
os.remove(fname)
self.assertEqual(rc, 47)
- @unittest.skip("See issue #2777")
def test_send_signal(self):
p = subprocess.Popen([sys.executable, "-c", "input()"])
+ # Let the process initialize correctly (Issue #3137)
+ time.sleep(.1)
self.assertIs(p.poll(), None)
p.send_signal(signal.SIGINT)
- self.assertIsNot(p.wait(), None)
+ self.assertNotEqual(p.wait(), 0)
- @unittest.skip("See issue #2777")
def test_kill(self):
p = subprocess.Popen([sys.executable, "-c", "input()"])
@@ -652,7 +664,6 @@ class POSIXProcessTestCase(unittest.TestCase):
p.kill()
self.assertEqual(p.wait(), -signal.SIGKILL)
- @unittest.skip("See issue #2777")
def test_terminate(self):
p = subprocess.Popen([sys.executable, "-c", "input()"])
@@ -661,13 +672,19 @@ class POSIXProcessTestCase(unittest.TestCase):
self.assertEqual(p.wait(), -signal.SIGTERM)
-@unittest.skipUnless(sys.platform == "win32", "Windows specific tests")
+@unittest.skipUnless(mswindows, "Windows specific tests")
class Win32ProcessTestCase(unittest.TestCase):
def setUp(self):
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
support.reap_children()
+ def tearDown(self):
+ for inst in subprocess._active:
+ inst.wait()
+ subprocess._cleanup()
+ self.assertFalse(subprocess._active, "subprocess._active not empty")
+
def test_startupinfo(self):
# startupinfo argument
# We uses hardcoded constants, because we do not want to
@@ -734,7 +751,6 @@ class Win32ProcessTestCase(unittest.TestCase):
' -c "import sys; sys.exit(47)"')
self.assertEqual(rc, 47)
- @unittest.skip("See issue #2777")
def test_send_signal(self):
p = subprocess.Popen([sys.executable, "-c", "input()"])
@@ -742,7 +758,6 @@ class Win32ProcessTestCase(unittest.TestCase):
p.send_signal(signal.SIGTERM)
self.assertNotEqual(p.wait(), 0)
- @unittest.skip("See issue #2777")
def test_kill(self):
p = subprocess.Popen([sys.executable, "-c", "input()"])
@@ -750,7 +765,6 @@ class Win32ProcessTestCase(unittest.TestCase):
p.kill()
self.assertNotEqual(p.wait(), 0)
- @unittest.skip("See issue #2777")
def test_terminate(self):
p = subprocess.Popen([sys.executable, "-c", "input()"])
@@ -764,7 +778,7 @@ class Win32ProcessTestCase(unittest.TestCase):
#
# Actually, getoutput should work on any platform with an os.popen, but
# I'll take the comment as given, and skip this suite.
-@unittest.skipUnless(os.name != 'posix', "only relevant for UNIX")
+@unittest.skipUnless(os.name == 'posix', "only relevant for UNIX")
class CommandTests(unittest.TestCase):
def test_getoutput(self):
self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy')