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

Method test_script_as_dev_fd

Lib/test/test_cmd_line_script.py:795–805  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

793 os.stat("/dev").st_dev == os.stat("/dev/fd").st_dev,
794 "Requires fdescfs mounted on /dev/fd on FreeBSD")
795 def test_script_as_dev_fd(self):
796 # GH-87235: On macOS passing a non-trivial script to /dev/fd/N can cause
797 # problems because all open /dev/fd/N file descriptors share the same
798 # offset.
799 script = 'print("12345678912345678912345")'
800 with os_helper.temp_dir() as work_dir:
801 script_name = _make_test_script(work_dir, 'script.py', script)
802 with open(script_name, "r") as fp:
803 p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=True, pass_fds=(0,1,2,fp.fileno()))
804 out, err = p.communicate()
805 self.assertEqual(out, b"12345678912345678912345\n")
806
807 def test_filter_syntax_warnings_by_module(self):
808 filename = support.findfile('test_import/data/syntax_warnings.py')

Callers

nothing calls this directly

Calls 7

spawn_pythonFunction · 0.90
temp_dirMethod · 0.80
_make_test_scriptFunction · 0.70
openFunction · 0.50
filenoMethod · 0.45
communicateMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected