Fixed tests on Python <3.8

This commit is contained in:
Ashley Whetter 2020-10-07 22:46:58 -07:00
parent 31d4beb959
commit 7330297a83

View File

@ -1,3 +1,5 @@
import sys
import astroid import astroid
from autoapi.mappers.python import astroid_utils from autoapi.mappers.python import astroid_utils
import pytest import pytest
@ -104,12 +106,27 @@ class TestAstroidUtils(object):
"signature,expected", "signature,expected",
[ [
("a: bool, b: int = 5", {"a": "bool", "b": "int"}), ("a: bool, b: int = 5", {"a": "bool", "b": "int"}),
("a: bool, /, b: int, *, c: str", {"a": "bool", "b": "int", "c": "str"}), pytest.param(
( "a: bool, /, b: int, *, c: str",
{"a": "bool", "b": "int", "c": "str"},
marks=pytest.mark.skipif(
sys.version_info[:2] < (3, 8), reason="Uses Python 3.8+ syntax"
),
),
pytest.param(
"a: bool, /, b: int, *args, c: str, **kwargs", "a: bool, /, b: int, *args, c: str, **kwargs",
{"a": "bool", "b": "int", "c": "str"}, {"a": "bool", "b": "int", "c": "str"},
marks=pytest.mark.skipif(
sys.version_info[:2] < (3, 8), reason="Uses Python 3.8+ syntax"
),
),
pytest.param(
"a: int, *args, b: str, **kwargs",
{"a": "int", "b": "str"},
marks=pytest.mark.skipif(
sys.version_info[:2] < (3, 8), reason="Uses Python 3.8+ syntax"
),
), ),
("a: int, *args, b: str, **kwargs", {"a": "int", "b": "str"}),
], ],
) )
def test_parse_annotations(self, signature, expected): def test_parse_annotations(self, signature, expected):
@ -129,10 +146,19 @@ class TestAstroidUtils(object):
"signature,expected", "signature,expected",
[ [
("a: bool, b: int = 5, c='hi'", "a: bool, b: int = 5, c='hi'"), ("a: bool, b: int = 5, c='hi'", "a: bool, b: int = 5, c='hi'"),
("a: bool, /, b: int, *, c: str", "a: bool, /, b: int, *, c: str"), pytest.param(
( "a: bool, /, b: int, *, c: str",
"a: bool, /, b: int, *, c: str",
marks=pytest.mark.skipif(
sys.version_info[:2] < (3, 8), reason="Uses Python 3.8+ syntax"
),
),
pytest.param(
"a: bool, /, b: int, *args, c: str, **kwargs", "a: bool, /, b: int, *args, c: str, **kwargs",
"a: bool, /, b: int, *args, c: str, **kwargs", "a: bool, /, b: int, *args, c: str, **kwargs",
marks=pytest.mark.skipif(
sys.version_info[:2] < (3, 8), reason="Uses Python 3.8+ syntax"
),
), ),
("a: int, *args, b: str, **kwargs", "a: int, *args, b: str, **kwargs"), ("a: int, *args, b: str, **kwargs", "a: int, *args, b: str, **kwargs"),
("a: 'A'", "a: A"), ("a: 'A'", "a: A"),