Refactor the version info to use a tuple, always.

This commit is contained in:
Dave Halter
2017-07-19 09:09:33 +02:00
parent dc3b3158eb
commit 78c371f73a
7 changed files with 74 additions and 45 deletions

View File

@@ -14,7 +14,7 @@ def test_load_inexisting_grammar():
@pytest.mark.parametrize(('string', 'result'), [
('2', 27), ('3', 36), ('1.1', 11), ('1.1.1', 11), ('300.1.31', 3001)
('2', (2, 7)), ('3', (3, 6)), ('1.1', (1, 1)), ('1.1.1', (1, 1)), ('300.1.31', (300, 1))
])
def test_parse_version(string, result):
assert utils._parse_version(string) == result

View File

@@ -10,10 +10,9 @@ from textwrap import dedent
import pytest
from parso._compatibility import py_version
from parso import load_grammar
from parso import ParserSyntaxError
from parso.utils import version_string_to_int
from parso.utils import parse_version_string
class Checker():
@@ -32,8 +31,8 @@ def works_in_py2(each_version):
@pytest.fixture
def works_ge_py3(each_version):
version_int = version_string_to_int(each_version)
return Checker(each_version, version_int >= 30)
version_info = parse_version_string(each_version)
return Checker(each_version, version_info >= (3, 0))
@pytest.fixture
@@ -41,8 +40,8 @@ def works_ge_py35(each_version):
"""
Works only greater equal Python 3.3.
"""
version_int = version_string_to_int(each_version)
return Checker(each_version, version_int >= 35)
version_info = parse_version_string(each_version)
return Checker(each_version, version_info >= (3, 5))
def _parse(code, version=None):

View File

@@ -5,7 +5,7 @@ from textwrap import dedent
import pytest
from parso._compatibility import py_version
from parso.utils import splitlines, version_string_to_int
from parso.utils import splitlines, parse_version_string
from parso.python.token import (
NAME, NEWLINE, STRING, INDENT, DEDENT, ERRORTOKEN, ENDMARKER)
from parso.python import tokenize
@@ -15,8 +15,8 @@ from parso.python.tokenize import TokenInfo
def _get_token_list(string):
# Load the current version.
version_int = version_string_to_int()
return list(tokenize.tokenize(string, version_int))
version_info = parse_version_string()
return list(tokenize.tokenize(string, version_info))
def test_end_pos_one_line():