MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_script_as_dev_fd

Method test_script_as_dev_fd

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

Source from the content-addressed store, hash-verified

794 "Requires fdescfs mounted on /dev/fd on FreeBSD")
795 @unittest.skipIf(sys.platform.startswith("darwin"), "TODO: RUSTPYTHON Problems with Mac os descriptor")
796 def test_script_as_dev_fd(self):
797 # GH-87235: On macOS passing a non-trivial script to /dev/fd/N can cause
798 # problems because all open /dev/fd/N file descriptors share the same
799 # offset.
800 script = 'print("12345678912345678912345")'
801 with os_helper.temp_dir() as work_dir:
802 script_name = _make_test_script(work_dir, 'script.py', script)
803 with open(script_name, "r") as fp:
804 p = spawn_python(f"/dev/fd/{fp.fileno()}", close_fds=True, pass_fds=(0,1,2,fp.fileno()))
805 out, err = p.communicate()
806 self.assertEqual(out, b"12345678912345678912345\n")
807
808
809

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected