mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
gh-126139: Improve error message location for future statement with unknown feature (#126140)
This commit is contained in:
parent
9dfef4e5f4
commit
224c370a36
4 changed files with 18 additions and 8 deletions
|
@ -88,7 +88,7 @@ class FutureTest(unittest.TestCase):
|
|||
"""
|
||||
self.assertSyntaxError(
|
||||
code, lineno=2,
|
||||
message='future feature rested_snopes is not defined',
|
||||
message='future feature rested_snopes is not defined', offset=24,
|
||||
)
|
||||
|
||||
def test_future_import_not_on_top(self):
|
||||
|
@ -137,19 +137,19 @@ class FutureTest(unittest.TestCase):
|
|||
code = """
|
||||
from __future__ import *
|
||||
"""
|
||||
self.assertSyntaxError(code, message='future feature * is not defined')
|
||||
self.assertSyntaxError(code, message='future feature * is not defined', offset=24)
|
||||
|
||||
def test_future_import_braces(self):
|
||||
code = """
|
||||
from __future__ import braces
|
||||
"""
|
||||
# Congrats, you found an easter egg!
|
||||
self.assertSyntaxError(code, message='not a chance')
|
||||
self.assertSyntaxError(code, message='not a chance', offset=24)
|
||||
|
||||
code = """
|
||||
from __future__ import nested_scopes, braces
|
||||
"""
|
||||
self.assertSyntaxError(code, message='not a chance')
|
||||
self.assertSyntaxError(code, message='not a chance', offset=39)
|
||||
|
||||
def test_module_with_future_import_not_on_top(self):
|
||||
with self.assertRaises(SyntaxError) as cm:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue