mirror of
https://github.com/davidhalter/parso.git
synced 2026-08-13 03:21:02 +08:00
Fixing a warning and moving some tests around.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import codecs
|
import codecs
|
||||||
|
import warnings
|
||||||
import re
|
import re
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
@@ -570,7 +571,10 @@ class ErrorFinder(Normalizer):
|
|||||||
func = codecs.unicode_escape_decode
|
func = codecs.unicode_escape_decode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
func(payload)
|
with warnings.catch_warnings():
|
||||||
|
# The warnings from parsing strings are not relevant.
|
||||||
|
warnings.filterwarnings('ignore')
|
||||||
|
func(payload)
|
||||||
except UnicodeDecodeError as e:
|
except UnicodeDecodeError as e:
|
||||||
self._add_syntax_error('(unicode error) ' + str(e), leaf)
|
self._add_syntax_error('(unicode error) ' + str(e), leaf)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
|||||||
@@ -241,6 +241,8 @@ GLOBAL_NONLOCAL_ERROR = [
|
|||||||
if sys.version_info >= (3, 6):
|
if sys.version_info >= (3, 6):
|
||||||
FAILING_EXAMPLES += GLOBAL_NONLOCAL_ERROR
|
FAILING_EXAMPLES += GLOBAL_NONLOCAL_ERROR
|
||||||
FAILING_EXAMPLES.append('(%s *d) = x' % ('a,' * 256))
|
FAILING_EXAMPLES.append('(%s *d) = x' % ('a,' * 256))
|
||||||
|
if sys.version_info >= (3, 5):
|
||||||
|
FAILING_EXAMPLES.append('[*[] for a in [1]]')
|
||||||
if sys.version_info >= (3, 4):
|
if sys.version_info >= (3, 4):
|
||||||
# Before that del None works like del list, it gives a NameError.
|
# Before that del None works like del list, it gives a NameError.
|
||||||
FAILING_EXAMPLES.append('del None')
|
FAILING_EXAMPLES.append('del None')
|
||||||
@@ -253,6 +255,8 @@ if sys.version_info >= (3,):
|
|||||||
# A symtable error that raises only a SyntaxWarning in Python 2.
|
# A symtable error that raises only a SyntaxWarning in Python 2.
|
||||||
'def x(): from math import *',
|
'def x(): from math import *',
|
||||||
'b"ä"',
|
'b"ä"',
|
||||||
|
'{**{} for a in [1]}',
|
||||||
|
'"s" b""',
|
||||||
]
|
]
|
||||||
if sys.version_info >= (2, 7):
|
if sys.version_info >= (2, 7):
|
||||||
# This is something that raises a different error in 2.6 than in the other
|
# This is something that raises a different error in 2.6 than in the other
|
||||||
@@ -381,9 +385,6 @@ def test_default_except_error_postition():
|
|||||||
('del *a, b', '3.5'),
|
('del *a, b', '3.5'),
|
||||||
('def x(*): pass', '3.5'),
|
('def x(*): pass', '3.5'),
|
||||||
('async def foo():\n def nofoo():[x async for x in []]', '3.6'),
|
('async def foo():\n def nofoo():[x async for x in []]', '3.6'),
|
||||||
('[*[] for a in [1]]', '3.5'),
|
|
||||||
('{**{} for a in [1]}', '3.5'),
|
|
||||||
('"s" b""', '3.5'),
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_python_exception_matches_version(code, version):
|
def test_python_exception_matches_version(code, version):
|
||||||
|
|||||||
Reference in New Issue
Block a user