diff options
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_grammar.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 9953363..32dc15e 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -125,6 +125,13 @@ the \'lazy\' dog.\n\ self.assertTrue(x is Ellipsis) self.assertRaises(SyntaxError, eval, ".. .") + def test_eof_error(self): + samples = ("def foo(", "\ndef foo(", "def foo(\n") + for s in samples: + with self.assertRaises(SyntaxError) as cm: + compile(s, "<test>", "exec") + self.assertIn("unexpected EOF", str(cm.exception)) + class GrammarTests(unittest.TestCase): # single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE |
