Skip to content

Commit 5954463

Browse files
committed
📝 Refactor tests in test_field_sa_type.py for Python 3.12 compatibility
1 parent 9d63657 commit 5954463

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

tests/test_field_sa_type.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from typing import Annotated, TypeAlias
23

34
from sqlmodel import Field, SQLModel
@@ -43,19 +44,20 @@ class Hero(SQLModel, table=True):
4344
weapon: Type4 = "sword"
4445

4546

46-
@needs_py312
47-
def test_sa_type_5() -> None:
48-
type Type5 = str
47+
if sys.version_info >= (3, 12):
4948

50-
class Hero(SQLModel, table=True):
51-
pk: int = Field(primary_key=True)
52-
weapon: Type5 = "sword"
49+
@needs_py312
50+
def test_sa_type_5() -> None:
51+
type Type5 = str
5352

53+
class Hero(SQLModel, table=True):
54+
pk: int = Field(primary_key=True)
55+
weapon: Type5 = "sword"
5456

55-
@needs_py312
56-
def test_sa_type_6() -> None:
57-
type Type6 = Annotated[str, "Just a comment"]
57+
@needs_py312
58+
def test_sa_type_6() -> None:
59+
type Type6 = Annotated[str, "Just a comment"]
5860

59-
class Hero(SQLModel, table=True):
60-
pk: int = Field(primary_key=True)
61-
weapon: Type6 = "sword"
61+
class Hero(SQLModel, table=True):
62+
pk: int = Field(primary_key=True)
63+
weapon: Type6 = "sword"

0 commit comments

Comments
 (0)