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

Method test_nonexisting_script

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

Source from the content-addressed store, hash-verified

774 self.assertIn("No module named script_pkg", traceback_lines[-1])
775
776 def test_nonexisting_script(self):
777 # bpo-34783: "./python script.py" must not crash
778 # if the script file doesn't exist.
779 # (Skip test for macOS framework builds because sys.executable name
780 # is not the actual Python executable file name.
781 script = 'nonexistingscript.py'
782 self.assertFalse(os.path.exists(script))
783
784 proc = spawn_python(script, text=True,
785 stdout=subprocess.PIPE,
786 stderr=subprocess.PIPE)
787 out, err = proc.communicate()
788 self.assertIn(": can't open file ", err)
789 self.assertNotEqual(proc.returncode, 0)
790
791 @unittest.skipUnless(os.path.exists('/dev/fd/0'), 'requires /dev/fd platform')
792 @unittest.skipIf(sys.platform.startswith("freebsd") and

Callers

nothing calls this directly

Calls 6

spawn_pythonFunction · 0.90
assertFalseMethod · 0.80
assertInMethod · 0.80
assertNotEqualMethod · 0.80
existsMethod · 0.45
communicateMethod · 0.45

Tested by

no test coverage detected