From 7330297a83c6b45fc520fa706c33374db4b148d9 Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Wed, 7 Oct 2020 22:46:58 -0700 Subject: [PATCH] Fixed tests on Python <3.8 --- tests/test_astroid_utils.py | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/tests/test_astroid_utils.py b/tests/test_astroid_utils.py index cf95f9e..6de7596 100644 --- a/tests/test_astroid_utils.py +++ b/tests/test_astroid_utils.py @@ -1,3 +1,5 @@ +import sys + import astroid from autoapi.mappers.python import astroid_utils import pytest @@ -104,12 +106,27 @@ class TestAstroidUtils(object): "signature,expected", [ ("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", "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): @@ -129,10 +146,19 @@ class TestAstroidUtils(object): "signature,expected", [ ("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", + 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: 'A'", "a: A"),