mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix filter for SyntaxErrors
This commit is contained in:
parent
3da989c6bc
commit
150a6640f5
1 changed files with 4 additions and 4 deletions
|
@ -4,15 +4,15 @@ from test_support import check_syntax
|
|||
|
||||
import warnings
|
||||
|
||||
warnings.filterwarnings("error", category=SyntaxWarning, module=__name__)
|
||||
warnings.filterwarnings("error", module="<test code>")
|
||||
|
||||
def compile_and_catch_warning(text):
|
||||
try:
|
||||
compile(text, "<test code>", "exec")
|
||||
except SyntaxWarning, msg:
|
||||
print "got SyntaxWarning as expected"
|
||||
except SyntaxError, msg:
|
||||
print "got SyntaxError as expected"
|
||||
else:
|
||||
print "expected SyntaxWarning"
|
||||
print "expected SyntaxError"
|
||||
|
||||
prog_text_1 = """
|
||||
def wrong1():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue