mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Merged revisions 79344,79346,79350 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79344 | florent.xicluna | 2010-03-23 15:36:45 +0100 (mar, 23 mar 2010) | 2 lines Silence test_subprocess. ........ r79346 | florent.xicluna | 2010-03-23 16:05:30 +0100 (mar, 23 mar 2010) | 2 lines The standard error should be empty when the signal is killed, except on SIGINT. ........ r79350 | florent.xicluna | 2010-03-23 20:19:16 +0100 (mar, 23 mar 2010) | 2 lines The SIGINT signal may happen earlier, during site.py initialization. ........
This commit is contained in:
parent
d35f117192
commit
c049d870b5
1 changed files with 16 additions and 25 deletions
|
|
@ -37,7 +37,7 @@ except AttributeError:
|
||||||
return os.open(fname, os.O_RDWR|os.O_CREAT), fname
|
return os.open(fname, os.O_RDWR|os.O_CREAT), fname
|
||||||
|
|
||||||
|
|
||||||
class ProcessTestCase(unittest.TestCase):
|
class BaseTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Try to minimize the number of children we have so this test
|
# Try to minimize the number of children we have so this test
|
||||||
# doesn't crash on some buildbots (Alphas in particular).
|
# doesn't crash on some buildbots (Alphas in particular).
|
||||||
|
|
@ -56,6 +56,9 @@ class ProcessTestCase(unittest.TestCase):
|
||||||
actual = re.sub("\[\d+ refs\]\r?\n?$", "", stderr.decode()).encode()
|
actual = re.sub("\[\d+ refs\]\r?\n?$", "", stderr.decode()).encode()
|
||||||
self.assertEqual(actual, expected, msg)
|
self.assertEqual(actual, expected, msg)
|
||||||
|
|
||||||
|
|
||||||
|
class ProcessTestCase(BaseTestCase):
|
||||||
|
|
||||||
def test_call_seq(self):
|
def test_call_seq(self):
|
||||||
# call() function with sequence argument
|
# call() function with sequence argument
|
||||||
rc = subprocess.call([sys.executable, "-c",
|
rc = subprocess.call([sys.executable, "-c",
|
||||||
|
|
@ -559,17 +562,7 @@ class _SuppressCoreFiles(object):
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(mswindows, "POSIX specific tests")
|
@unittest.skipIf(mswindows, "POSIX specific tests")
|
||||||
class POSIXProcessTestCase(unittest.TestCase):
|
class POSIXProcessTestCase(BaseTestCase):
|
||||||
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):
|
def test_exceptions(self):
|
||||||
nonexistent_dir = "/_this/pa.th/does/not/exist"
|
nonexistent_dir = "/_this/pa.th/does/not/exist"
|
||||||
|
|
@ -752,7 +745,7 @@ class POSIXProcessTestCase(unittest.TestCase):
|
||||||
# Do not inherit file handles from the parent.
|
# Do not inherit file handles from the parent.
|
||||||
# It should fix failures on some platforms.
|
# It should fix failures on some platforms.
|
||||||
p = subprocess.Popen([sys.executable, "-c", "input()"], close_fds=True,
|
p = subprocess.Popen([sys.executable, "-c", "input()"], close_fds=True,
|
||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
# Let the process initialize (Issue #3137)
|
# Let the process initialize (Issue #3137)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
@ -773,29 +766,25 @@ class POSIXProcessTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def test_send_signal(self):
|
def test_send_signal(self):
|
||||||
p = self._kill_process('send_signal', signal.SIGINT)
|
p = self._kill_process('send_signal', signal.SIGINT)
|
||||||
|
_, stderr = p.communicate()
|
||||||
|
self.assertIn(b'KeyboardInterrupt', stderr)
|
||||||
self.assertNotEqual(p.wait(), 0)
|
self.assertNotEqual(p.wait(), 0)
|
||||||
|
|
||||||
def test_kill(self):
|
def test_kill(self):
|
||||||
p = self._kill_process('kill')
|
p = self._kill_process('kill')
|
||||||
|
_, stderr = p.communicate()
|
||||||
|
self.assertStderrEqual(stderr, b'')
|
||||||
self.assertEqual(p.wait(), -signal.SIGKILL)
|
self.assertEqual(p.wait(), -signal.SIGKILL)
|
||||||
|
|
||||||
def test_terminate(self):
|
def test_terminate(self):
|
||||||
p = self._kill_process('terminate')
|
p = self._kill_process('terminate')
|
||||||
|
_, stderr = p.communicate()
|
||||||
|
self.assertStderrEqual(stderr, b'')
|
||||||
self.assertEqual(p.wait(), -signal.SIGTERM)
|
self.assertEqual(p.wait(), -signal.SIGTERM)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(mswindows, "Windows specific tests")
|
@unittest.skipUnless(mswindows, "Windows specific tests")
|
||||||
class Win32ProcessTestCase(unittest.TestCase):
|
class Win32ProcessTestCase(BaseTestCase):
|
||||||
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):
|
def test_startupinfo(self):
|
||||||
# startupinfo argument
|
# startupinfo argument
|
||||||
|
|
@ -866,7 +855,7 @@ class Win32ProcessTestCase(unittest.TestCase):
|
||||||
def _kill_process(self, method, *args):
|
def _kill_process(self, method, *args):
|
||||||
# Some win32 buildbot raises EOFError if stdin is inherited
|
# Some win32 buildbot raises EOFError if stdin is inherited
|
||||||
p = subprocess.Popen([sys.executable, "-c", "input()"],
|
p = subprocess.Popen([sys.executable, "-c", "input()"],
|
||||||
stdin=subprocess.PIPE)
|
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
|
||||||
# Let the process initialize (Issue #3137)
|
# Let the process initialize (Issue #3137)
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
@ -884,6 +873,8 @@ class Win32ProcessTestCase(unittest.TestCase):
|
||||||
if count > 1:
|
if count > 1:
|
||||||
print("p.{}{} succeeded after "
|
print("p.{}{} succeeded after "
|
||||||
"{} attempts".format(method, args, count), file=sys.stderr)
|
"{} attempts".format(method, args, count), file=sys.stderr)
|
||||||
|
_, stderr = p.communicate()
|
||||||
|
self.assertStderrEqual(stderr, b'')
|
||||||
self.assertEqual(p.wait(), returncode)
|
self.assertEqual(p.wait(), returncode)
|
||||||
self.assertNotEqual(returncode, 0)
|
self.assertNotEqual(returncode, 0)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue