diff options
author | Gregory P. Smith <greg@krypto.org> | 2018-06-05 19:00:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-05 19:00:57 (GMT) |
commit | 5f3d04fa4e9b3c3b0e4807f8516de9365bfed467 (patch) | |
tree | 8988af91b74b2799dd4022f5621456e609ba4e7b /Lib/test/test_subprocess.py | |
parent | c56b17bd8c7a3fd03859822246633d2c9586f8bd (diff) | |
download | cpython-5f3d04fa4e9b3c3b0e4807f8516de9365bfed467.zip cpython-5f3d04fa4e9b3c3b0e4807f8516de9365bfed467.tar.gz cpython-5f3d04fa4e9b3c3b0e4807f8516de9365bfed467.tar.bz2 |
Improve the subprocess restore_signals=True test. (GH-7414)
It wasn't testing functionality. Now it is (on Linux anyways).
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r-- | Lib/test/test_subprocess.py | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 2a766d7..4b089f5 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1617,13 +1617,29 @@ class POSIXProcessTestCase(BaseTestCase): self.assertIn(repr(error_data), str(e.exception)) - + @unittest.skipIf(not os.path.exists('/proc/self/status'), + "need /proc/self/status") def test_restore_signals(self): - # Code coverage for both values of restore_signals to make sure it - # at least does not blow up. - # A test for behavior would be complex. Contributions welcome. - subprocess.call([sys.executable, "-c", ""], restore_signals=True) - subprocess.call([sys.executable, "-c", ""], restore_signals=False) + # Blindly assume that cat exists on systems with /proc/self/status... + default_proc_status = subprocess.check_output( + ['cat', '/proc/self/status'], + restore_signals=False) + for line in default_proc_status.splitlines(): + if line.startswith(b'SigIgn'): + default_sig_ign_mask = line + break + else: + self.skipTest("SigIgn not found in /proc/self/status.") + restored_proc_status = subprocess.check_output( + ['cat', '/proc/self/status'], + restore_signals=True) + for line in restored_proc_status.splitlines(): + if line.startswith(b'SigIgn'): + restored_sig_ign_mask = line + break + self.assertNotEqual(default_sig_ign_mask, restored_sig_ign_mask, + msg="restore_signals=True should've unblocked " + "SIGPIPE and friends.") def test_start_new_session(self): # For code coverage of calling setsid(). We don't care if we get an |