diff options
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r-- | Lib/test/test_grammar.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 9dd42b4f5d..3d8b1514f0 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -5,6 +5,7 @@ from test.support import check_syntax_error import inspect import unittest import sys +import warnings # testing import * from sys import * @@ -1099,6 +1100,14 @@ class GrammarTests(unittest.TestCase): else: self.fail("AssertionError not raised by 'assert False'") + with self.assertWarnsRegex(SyntaxWarning, 'assertion is always true'): + compile('assert(x, "msg")', '<testcase>', 'exec') + with warnings.catch_warnings(): + warnings.filterwarnings('error', category=SyntaxWarning) + with self.assertRaisesRegex(SyntaxError, 'assertion is always true'): + compile('assert(x, "msg")', '<testcase>', 'exec') + compile('assert x, "msg"', '<testcase>', 'exec') + ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef # Tested below |