Skip to content

Commit 651f107

Browse files
committed
fix #142570: add test_skip_source_first_line test
1 parent 177bf5e commit 651f107

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Lib/test/test_cmd_line_script.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,23 @@ def test_non_ascii(self):
583583
'stdout=%r stderr=%r' % (stdout, stderr))
584584
self.assertEqual(0, rc)
585585

586+
def test_skip_source_first_line(self):
587+
script = textwrap.dedent("""\
588+
print("First line")
589+
print("Second line")
590+
""")
591+
with os_helper.temp_dir() as script_dir:
592+
script_name = _make_test_script(script_dir, 'script', script)
593+
exitcode, stdout, stderr = assert_python_ok(script_name)
594+
text = stdout.decode('ascii')
595+
self.assertIn("First line", text)
596+
self.assertIn("Second line", text)
597+
598+
exitcode, stdout, stderr = assert_python_ok('-x', script_name)
599+
text = stdout.decode('ascii')
600+
self.assertNotIn("First line", text)
601+
self.assertIn("Second line", text)
602+
586603
def test_issue20500_exit_with_exception_value(self):
587604
script = textwrap.dedent("""\
588605
import sys

0 commit comments

Comments
 (0)