Skip to content

Commit 35e920c

Browse files
committed
Add suppression context manager
1 parent 66e84d9 commit 35e920c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Lib/test/test_eof.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""test script for a few new invalid token catches"""
22

33
import sys
4+
import warnings
45
from test import support
56
from test.support import os_helper
67
from test.support import script_helper
@@ -38,12 +39,14 @@ def test_EOFS_with_file(self):
3839

3940
def test_eof_with_line_continuation(self):
4041
expect = "unexpected EOF while parsing (<string>, line 1)"
41-
try:
42-
compile('"\\Xhh" \\', '<string>', 'exec')
43-
except SyntaxError as msg:
44-
self.assertEqual(str(msg), expect)
45-
else:
46-
raise support.TestFailed
42+
with warnings.catch_warnings():
43+
warnings.simplefilter("ignore", SyntaxWarning)
44+
try:
45+
compile('"\\Xhh" \\', '<string>', 'exec')
46+
except SyntaxError as msg:
47+
self.assertEqual(str(msg), expect)
48+
else:
49+
raise support.TestFailed
4750

4851
def test_line_continuation_EOF(self):
4952
"""A continuation at the end of input must be an error; bpo2180."""

0 commit comments

Comments
 (0)