Skip to content

Commit 22e7966

Browse files
committed
Use the warning suppression decorator
1 parent 35e920c commit 22e7966

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Lib/test/test_eof.py

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

33
import sys
4-
import warnings
54
from test import support
65
from test.support import os_helper
76
from test.support import script_helper
7+
from test.support import warnings_helper
88
import unittest
99

1010
class EOFTestCase(unittest.TestCase):
@@ -37,16 +37,15 @@ def test_EOFS_with_file(self):
3737
rc, out, err = script_helper.assert_python_failure(file_name)
3838
self.assertIn(b'unterminated triple-quoted string literal (detected at line 3)', err)
3939

40+
@warnings_helper.ignore_warnings(category=SyntaxWarning)
4041
def test_eof_with_line_continuation(self):
4142
expect = "unexpected EOF while parsing (<string>, line 1)"
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
43+
try:
44+
compile('"\\Xhh" \\', '<string>', 'exec')
45+
except SyntaxError as msg:
46+
self.assertEqual(str(msg), expect)
47+
else:
48+
raise support.TestFailed
5049

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

0 commit comments

Comments
 (0)