Skip to content

Commit

Permalink
Oops, make the test only run on Python 3.9+
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCain committed Jun 8, 2024
1 parent b0f2f0f commit 23348a2
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -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 .*"):
Expand Down

0 comments on commit 23348a2

Please sign in to comment.