Remove sys.version_info usages that are no longer necessary

This commit is contained in:
Dave Halter
2020-07-25 01:53:51 +02:00
parent 22fb62336e
commit 86d53add2d
4 changed files with 12 additions and 23 deletions

View File

@@ -171,7 +171,7 @@ class PythonVersionInfo(namedtuple('Version', 'major, minor')):
def parse_version_string(version=None): 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 returns a corresponding version info that is always two characters long in
decimal. decimal.
""" """

View File

@@ -934,7 +934,6 @@ def test_many_nested_ifs(differ):
differ.parse(code1, parsers=1, copies=1) 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 ']) @pytest.mark.parametrize('prefix', ['', 'async '])
def test_with_and_funcdef_in_call(differ, prefix): def test_with_and_funcdef_in_call(differ, prefix):
code1 = prefix + dedent('''\ code1 = prefix + dedent('''\
@@ -977,8 +976,7 @@ def test_random_unicode_characters(differ):
expect_error_leaves=True) expect_error_leaves=True)
differ.parse('\r\r', parsers=1) differ.parse('\r\r', parsers=1)
differ.parse("˟Ę\x05À\r rúƣ@\x8a\x15r()\n", parsers=1, expect_error_leaves=True) differ.parse("˟Ę\x05À\r rúƣ@\x8a\x15r()\n", parsers=1, expect_error_leaves=True)
differ.parse('a\ntaǁ\rGĒōns__\n\nb', parsers=1, differ.parse('a\ntaǁ\rGĒōns__\n\nb', parsers=1)
expect_error_leaves=sys.version_info[0] == 2)
s = ' if not (self, "_fi\x02\x0e\x08\n\nle"):' s = ' if not (self, "_fi\x02\x0e\x08\n\nle"):'
differ.parse(s, parsers=1, expect_error_leaves=True) differ.parse(s, parsers=1, expect_error_leaves=True)
differ.parse('') differ.parse('')

View File

@@ -48,10 +48,7 @@ def test_non_async_in_async():
This example doesn't work with FAILING_EXAMPLES, because the line numbers This example doesn't work with FAILING_EXAMPLES, because the line numbers
are not always the same / incorrect in Python 3.8. are not always the same / incorrect in Python 3.8.
""" """
if sys.version_info[:2] < (3, 5): # Raises multiple errors in previous versions.
pytest.skip()
# Raises multiple errors in previous versions.
code = 'async def foo():\n def nofoo():[x async for x in []]' code = 'async def foo():\n def nofoo():[x async for x in []]'
wanted, line_nr = _get_actual_exception(code) wanted, line_nr = _get_actual_exception(code)
@@ -259,10 +256,7 @@ def test_escape_decode_literals(each_version):
# Finally bytes. # Finally bytes.
error, = _get_error_list(r'b"\x"', version=each_version) error, = _get_error_list(r'b"\x"', version=each_version)
wanted = r'SyntaxError: (value error) invalid \x escape' wanted = r'SyntaxError: (value error) invalid \x escape at position 0'
if sys.version_info >= (3, 0):
# The positioning information is only available in Python 3.
wanted += ' at position 0'
assert error.message == wanted assert error.message == wanted

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 # This file contains Unicode characters. # -*- coding: utf-8 # This file contains Unicode characters.
import sys
from textwrap import dedent from textwrap import dedent
import pytest import pytest
@@ -179,19 +178,17 @@ def test_ur_literals():
assert typ == NAME assert typ == NAME
check('u""') check('u""')
check('ur""', is_literal=not sys.version_info.major >= 3) check('ur""', is_literal=False)
check('Ur""', is_literal=not sys.version_info.major >= 3) check('Ur""', is_literal=False)
check('UR""', is_literal=not sys.version_info.major >= 3) check('UR""', is_literal=False)
check('bR""') check('bR""')
# Starting with Python 3.3 this ordering is also possible. check('Rb""')
if sys.version_info.major >= 3:
check('Rb""')
# Starting with Python 3.6 format strings where introduced. # Starting with Python 3.6 format strings where introduced.
check('fr""', is_literal=sys.version_info >= (3, 6)) check('fr""')
check('rF""', is_literal=sys.version_info >= (3, 6)) check('rF""')
check('f""', is_literal=sys.version_info >= (3, 6)) check('f""')
check('F""', is_literal=sys.version_info >= (3, 6)) check('F""')
def test_error_literal(): def test_error_literal():