diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2021-01-19 23:59:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 23:59:33 +0000 |
commit | d6d6371447357c9c69b093657bbbb3977a3e60f2 (patch) | |
tree | a7676cfcf08746f0ca890f3b7d820a379e58f310 /Lib/test | |
parent | bpo-42923: _Py_DumpExtensionModules() ignores stdlib ext (GH-24254) (diff) | |
download | cpython-d6d6371447357c9c69b093657bbbb3977a3e60f2.tar.gz cpython-d6d6371447357c9c69b093657bbbb3977a3e60f2.tar.bz2 cpython-d6d6371447357c9c69b093657bbbb3977a3e60f2.zip |
bpo-42864: Improve error messages regarding unclosed parentheses (GH-24161)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_codeop.py | 1 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 2 | ||||
-rw-r--r-- | Lib/test/test_pdb.py | 4 | ||||
-rw-r--r-- | Lib/test/test_syntax.py | 8 |
4 files changed, 11 insertions, 4 deletions
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py index 45d0a7de9d9..1da6ca55c48 100644 --- a/Lib/test/test_codeop.py +++ b/Lib/test/test_codeop.py @@ -160,7 +160,6 @@ class CodeopTests(unittest.TestCase): ai("","eval") ai("\n","eval") ai("(","eval") - ai("(\n\n\n","eval") ai("(9+","eval") ai("9+ \\","eval") ai("lambda z: \\","eval") diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 2f6716dfc9a..0be869ef69b 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -260,7 +260,7 @@ the \'lazy\' dog.\n\ for s in samples: with self.assertRaises(SyntaxError) as cm: compile(s, "<test>", "exec") - self.assertIn("unexpected EOF", str(cm.exception)) + self.assertIn("was never closed", str(cm.exception)) var_annot_global: int # a global annotated is necessary for test_var_annot diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 4bb574fc5b7..93b61dcfbcd 100644 --- a/Lib/test/test_pdb.py +++ b/Lib/test/test_pdb.py @@ -1649,10 +1649,10 @@ def bœr(): self.assertEqual(stdout.splitlines()[1:], [ '-> pass', - '(Pdb) *** SyntaxError: unexpected EOF while parsing', + '(Pdb) *** SyntaxError: \'(\' was never closed', '(Pdb) ENTERING RECURSIVE DEBUGGER', - '*** SyntaxError: unexpected EOF while parsing', + '*** SyntaxError: \'(\' was never closed', 'LEAVING RECURSIVE DEBUGGER', '(Pdb) ENTERING RECURSIVE DEBUGGER', diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index d8255607dcf..c8d191df4cc 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -987,6 +987,14 @@ def func2(): self._check_error("A.\u03bc\\\n", "unexpected EOF while parsing") + def test_error_parenthesis(self): + for paren in "([{": + self._check_error(paren + "1 + 2", f"\\{paren}' was never closed") + + for paren in ")]}": + self._check_error(paren + "1 + 2", f"unmatched '\\{paren}'") + + def test_main(): support.run_unittest(SyntaxTestCase) from test import test_syntax |