From 23348a2ccb761b285386c01e7d9e162f05b0d5f4 Mon Sep 17 00:00:00 2001 From: David Cain Date: Sat, 8 Jun 2024 10:25:29 -0600 Subject: [PATCH] Oops, make the test only run on Python 3.9+ --- tests/test_core.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 4d636301..9d3ba1e2 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,28 +1,33 @@ from dataclasses import dataclass import pytest -from typing import Optional, Set +from typing import Optional, Set, List from dataclasses_json import dataclass_json +import sys -@dataclass_json -@dataclass -class Config: - options: list["Option"] +# This test exists *only* to demonstrate a bug on Python 3.9+ +# It uses syntax that is not valid on earlier versions of Python! +if sys.version_info >= (3, 9): + @dataclass_json + @dataclass + class Config: + options: list["Option"] -@dataclass_json -@dataclass -class Option: - label: str + @dataclass_json + @dataclass + class Option: + label: str -@dataclass_json -@dataclass -class ConfigWithoutStringOptions: - options: list[Option] + @dataclass_json + @dataclass + class ConfigWithoutStringOptions: + options: list[Option] +@pytest.mark.skipif(sys.version_info < (3, 9), reason="requires generic types for bug") class TestWarning: def test_warns_about_nondeterministic_resolution(self): with pytest.warns(UserWarning, match="Assuming hint Option resolves to .*"):