From 86d53add2d087d1ee17d835564eb9663f7403852 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 25 Jul 2020 01:53:51 +0200 Subject: [PATCH] Remove sys.version_info usages that are no longer necessary --- parso/utils.py | 2 +- test/test_diff_parser.py | 4 +--- test/test_python_errors.py | 10 ++-------- test/test_tokenize.py | 19 ++++++++----------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/parso/utils.py b/parso/utils.py index 6751bfe..c024316 100644 --- a/parso/utils.py +++ b/parso/utils.py @@ -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. """ diff --git a/test/test_diff_parser.py b/test/test_diff_parser.py index bec97ae..6f71e29 100644 --- a/test/test_diff_parser.py +++ b/test/test_diff_parser.py @@ -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('') diff --git a/test/test_python_errors.py b/test/test_python_errors.py index 8c89d5d..4b57f7c 100644 --- a/test/test_python_errors.py +++ b/test/test_python_errors.py @@ -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 diff --git a/test/test_tokenize.py b/test/test_tokenize.py index c0183e5..1ae9066 100644 --- a/test/test_tokenize.py +++ b/test/test_tokenize.py @@ -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():