diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_cmd_line_script.py | 10 | ||||
-rw-r--r-- | Lib/test/test_io.py | 4 | ||||
-rw-r--r-- | Lib/test/test_repl.py | 2 | ||||
-rw-r--r-- | Lib/test/test_subprocess.py | 4 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 8 | ||||
-rw-r--r-- | Lib/test/test_traceback.py | 2 | ||||
-rw-r--r-- | Lib/test/test_warnings/__init__.py | 4 |
7 files changed, 27 insertions, 7 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index e9405ff..48754d5 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -684,6 +684,16 @@ class CmdLineTest(unittest.TestCase): ] ) + def test_source_lines_are_shown_when_running_source(self): + _, _, stderr = assert_python_failure("-c", "1/0") + expected_lines = [ + b'Traceback (most recent call last):', + b' File "<string>", line 1, in <module>', + b' 1/0', + b' ~^~', + b'ZeroDivisionError: division by zero'] + self.assertEqual(stderr.splitlines(), expected_lines) + def test_syntaxerror_does_not_crash(self): script = "nonlocal x\n" with os_helper.temp_dir() as script_dir: diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 022cf21..4c80429 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -4396,11 +4396,11 @@ class MiscIOTest(unittest.TestCase): ''') proc = assert_python_ok('-X', 'warn_default_encoding', '-c', code) warnings = proc.err.splitlines() - self.assertEqual(len(warnings), 2) + self.assertEqual(len(warnings), 4) self.assertTrue( warnings[0].startswith(b"<string>:5: EncodingWarning: ")) self.assertTrue( - warnings[1].startswith(b"<string>:8: EncodingWarning: ")) + warnings[2].startswith(b"<string>:8: EncodingWarning: ")) def test_text_encoding(self): # PEP 597, bpo-47000. io.text_encoding() returns "locale" or "utf-8" diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py index 2ee5117..7533376 100644 --- a/Lib/test/test_repl.py +++ b/Lib/test/test_repl.py @@ -184,7 +184,7 @@ class TestInteractiveInterpreter(unittest.TestCase): p.stdin.write(user_input) user_input2 = dedent(""" import linecache - print(linecache.cache['<python-input-1>']) + print(linecache.cache['<stdin>-1']) """) p.stdin.write(user_input2) output = kill_python(p) diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index a865df1..fe1a367 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -1769,9 +1769,9 @@ class RunFuncTestCase(BaseTestCase): cp = subprocess.run([sys.executable, "-Xwarn_default_encoding", "-c", code], capture_output=True) lines = cp.stderr.splitlines() - self.assertEqual(len(lines), 2, lines) + self.assertEqual(len(lines), 4, lines) self.assertTrue(lines[0].startswith(b"<string>:2: EncodingWarning: ")) - self.assertTrue(lines[1].startswith(b"<string>:3: EncodingWarning: ")) + self.assertTrue(lines[2].startswith(b"<string>:3: EncodingWarning: ")) def _get_test_grp_name(): diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index da21350..b16e1e7 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -1114,14 +1114,18 @@ class SysModuleTest(unittest.TestCase): traceback = [ b'Traceback (most recent call last):', b' File "<string>", line 8, in <module>', + b' f2()', b' File "<string>", line 6, in f2', + b' f1()', b' File "<string>", line 4, in f1', + b' 1 / 0', + b' ~~^~~', b'ZeroDivisionError: division by zero' ] check(10, traceback) check(3, traceback) - check(2, traceback[:1] + traceback[2:]) - check(1, traceback[:1] + traceback[3:]) + check(2, traceback[:1] + traceback[3:]) + check(1, traceback[:1] + traceback[5:]) check(0, [traceback[-1]]) check(-1, [traceback[-1]]) check(1<<1000, traceback) diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index a0f7ad8..43f15ab 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -313,6 +313,8 @@ class TracebackCases(unittest.TestCase): rc, stdout, stderr = assert_python_ok('-c', code) expected = [b'Traceback (most recent call last):', b' File "<string>", line 8, in __init__', + b' x = 1 / 0', + b' ^^^^^', b'ZeroDivisionError: division by zero'] self.assertEqual(stderr.splitlines(), expected) diff --git a/Lib/test/test_warnings/__init__.py b/Lib/test/test_warnings/__init__.py index 83237f5..2c52323 100644 --- a/Lib/test/test_warnings/__init__.py +++ b/Lib/test/test_warnings/__init__.py @@ -1233,6 +1233,10 @@ class EnvironmentVariableTests(BaseTest): self.assertEqual(stderr.splitlines(), [b"Traceback (most recent call last):", b" File \"<string>\", line 1, in <module>", + b' import sys, warnings; sys.stdout.write(str(sys.warnoptions)); warnings.w' + b"arn('Message', DeprecationWarning)", + b' ^^^^^^^^^^' + b'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', b"DeprecationWarning: Message"]) def test_default_filter_configuration(self): |