(self)
| 325 | self.assertEqual(p.stdin, None) |
| 326 | |
| 327 | def test_stdout_none(self): |
| 328 | # .stdout is None when not redirected, and the child's stdout will |
| 329 | # be inherited from the parent. In order to test this we run a |
| 330 | # subprocess in a subprocess: |
| 331 | # this_test |
| 332 | # \-- subprocess created by this test (parent) |
| 333 | # \-- subprocess created by the parent subprocess (child) |
| 334 | # The parent doesn't specify stdout, so the child will use the |
| 335 | # parent's stdout. This test checks that the message printed by the |
| 336 | # child goes to the parent stdout. The parent also checks that the |
| 337 | # child's stdout is None. See #11963. |
| 338 | code = ('import sys; from subprocess import Popen, PIPE;' |
| 339 | 'p = Popen([sys.executable, "-c", "print(\'test_stdout_none\')"],' |
| 340 | ' stdin=PIPE, stderr=PIPE);' |
| 341 | 'p.wait(); assert p.stdout is None;') |
| 342 | p = subprocess.Popen([sys.executable, "-c", code], |
| 343 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 344 | self.addCleanup(p.stdout.close) |
| 345 | self.addCleanup(p.stderr.close) |
| 346 | out, err = p.communicate() |
| 347 | self.assertEqual(p.returncode, 0, err) |
| 348 | self.assertEqual(out.rstrip(), b'test_stdout_none') |
| 349 | |
| 350 | def test_stderr_none(self): |
| 351 | # .stderr is None when not redirected |
nothing calls this directly
no test coverage detected