|
1 | 1 | """test script for a few new invalid token catches""" |
2 | 2 |
|
3 | 3 | import sys |
4 | | -import warnings |
5 | 4 | from test import support |
6 | 5 | from test.support import os_helper |
7 | 6 | from test.support import script_helper |
| 7 | +from test.support import warnings_helper |
8 | 8 | import unittest |
9 | 9 |
|
10 | 10 | class EOFTestCase(unittest.TestCase): |
@@ -37,16 +37,15 @@ def test_EOFS_with_file(self): |
37 | 37 | rc, out, err = script_helper.assert_python_failure(file_name) |
38 | 38 | self.assertIn(b'unterminated triple-quoted string literal (detected at line 3)', err) |
39 | 39 |
|
| 40 | + @warnings_helper.ignore_warnings(category=SyntaxWarning) |
40 | 41 | def test_eof_with_line_continuation(self): |
41 | 42 | 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 |
50 | 49 |
|
51 | 50 | def test_line_continuation_EOF(self): |
52 | 51 | """A continuation at the end of input must be an error; bpo2180.""" |
|
0 commit comments