MCPcopy Index your code
hub / github.com/python/cpython / test_stdout_filedes_of_stdout

Method test_stdout_filedes_of_stdout

Lib/test/test_subprocess.py:678–695  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

676 self.assertEqual(tf.read(), b"appleorange")
677
678 def test_stdout_filedes_of_stdout(self):
679 # stdout is set to 1 (#1531862).
680 # To avoid printing the text on stdout, we do something similar to
681 # test_stdout_none (see above). The parent subprocess calls the child
682 # subprocess passing stdout=1, and this test uses stdout=PIPE in
683 # order to capture and check the output of the parent. See #11963.
684 code = ('import sys, subprocess; '
685 'rc = subprocess.call([sys.executable, "-c", '
686 ' "import os, sys; sys.exit(os.write(sys.stdout.fileno(), '
687 'b\'test with stdout=1\'))"], stdout=1); '
688 'assert rc == 18')
689 p = subprocess.Popen([sys.executable, "-c", code],
690 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
691 self.addCleanup(p.stdout.close)
692 self.addCleanup(p.stderr.close)
693 out, err = p.communicate()
694 self.assertEqual(p.returncode, 0, err)
695 self.assertEqual(out.rstrip(), b'test with stdout=1')
696
697 def test_stdout_devnull(self):
698 p = subprocess.Popen([sys.executable, "-c",

Callers

nothing calls this directly

Calls 4

communicateMethod · 0.95
addCleanupMethod · 0.80
assertEqualMethod · 0.45
rstripMethod · 0.45

Tested by

no test coverage detected