mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Remove sys.version_info usages that are no longer necessary
This commit is contained in:
@@ -171,7 +171,7 @@ class PythonVersionInfo(namedtuple('Version', 'major, minor')):
|
||||
|
||||
def parse_version_string(version=None):
|
||||
"""
|
||||
Checks for a valid version number (e.g. `3.8` or `2.7.1` or `3`) and
|
||||
Checks for a valid version number (e.g. `3.8` or `3.10.1` or `3`) and
|
||||
returns a corresponding version info that is always two characters long in
|
||||
decimal.
|
||||
"""
|
||||
|
||||
@@ -934,7 +934,6 @@ def test_many_nested_ifs(differ):
|
||||
differ.parse(code1, parsers=1, copies=1)
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info < (3, 5), reason="Async starts working in 3.5")
|
||||
@pytest.mark.parametrize('prefix', ['', 'async '])
|
||||
def test_with_and_funcdef_in_call(differ, prefix):
|
||||
code1 = prefix + dedent('''\
|
||||
@@ -977,8 +976,7 @@ def test_random_unicode_characters(differ):
|
||||
expect_error_leaves=True)
|
||||
differ.parse('\r\r', parsers=1)
|
||||
differ.parse("˟Ę\x05À\r rúƣ@\x8a\x15r()\n", parsers=1, expect_error_leaves=True)
|
||||
differ.parse('a\ntaǁ\rGĒōns__\n\nb', parsers=1,
|
||||
expect_error_leaves=sys.version_info[0] == 2)
|
||||
differ.parse('a\ntaǁ\rGĒōns__\n\nb', parsers=1)
|
||||
s = ' if not (self, "_fi\x02\x0e\x08\n\nle"):'
|
||||
differ.parse(s, parsers=1, expect_error_leaves=True)
|
||||
differ.parse('')
|
||||
|
||||
@@ -48,10 +48,7 @@ def test_non_async_in_async():
|
||||
This example doesn't work with FAILING_EXAMPLES, because the line numbers
|
||||
are not always the same / incorrect in Python 3.8.
|
||||
"""
|
||||
if sys.version_info[:2] < (3, 5):
|
||||
pytest.skip()
|
||||
|
||||
# Raises multiple errors in previous versions.
|
||||
# Raises multiple errors in previous versions.
|
||||
code = 'async def foo():\n def nofoo():[x async for x in []]'
|
||||
wanted, line_nr = _get_actual_exception(code)
|
||||
|
||||
@@ -259,10 +256,7 @@ def test_escape_decode_literals(each_version):
|
||||
|
||||
# Finally bytes.
|
||||
error, = _get_error_list(r'b"\x"', version=each_version)
|
||||
wanted = r'SyntaxError: (value error) invalid \x escape'
|
||||
if sys.version_info >= (3, 0):
|
||||
# The positioning information is only available in Python 3.
|
||||
wanted += ' at position 0'
|
||||
wanted = r'SyntaxError: (value error) invalid \x escape at position 0'
|
||||
assert error.message == wanted
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
# -*- coding: utf-8 # This file contains Unicode characters.
|
||||
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
@@ -179,19 +178,17 @@ def test_ur_literals():
|
||||
assert typ == NAME
|
||||
|
||||
check('u""')
|
||||
check('ur""', is_literal=not sys.version_info.major >= 3)
|
||||
check('Ur""', is_literal=not sys.version_info.major >= 3)
|
||||
check('UR""', is_literal=not sys.version_info.major >= 3)
|
||||
check('ur""', is_literal=False)
|
||||
check('Ur""', is_literal=False)
|
||||
check('UR""', is_literal=False)
|
||||
check('bR""')
|
||||
# Starting with Python 3.3 this ordering is also possible.
|
||||
if sys.version_info.major >= 3:
|
||||
check('Rb""')
|
||||
check('Rb""')
|
||||
|
||||
# Starting with Python 3.6 format strings where introduced.
|
||||
check('fr""', is_literal=sys.version_info >= (3, 6))
|
||||
check('rF""', is_literal=sys.version_info >= (3, 6))
|
||||
check('f""', is_literal=sys.version_info >= (3, 6))
|
||||
check('F""', is_literal=sys.version_info >= (3, 6))
|
||||
check('fr""')
|
||||
check('rF""')
|
||||
check('f""')
|
||||
check('F""')
|
||||
|
||||
|
||||
def test_error_literal():
|
||||
|
||||
Reference in New Issue
Block a user