Skip to content

Commit

Permalink
🔧 Skip tests for discriminator param (needs Python 3.8+)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-berg committed Sep 7, 2022
1 parent 6728c25 commit 57e05ab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/test_pydantic/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Tests to ensure that the SQLModel `Field` constructor works as
expected from the Pydantic `Field` function.
"""
import sys
from decimal import Decimal
from typing import List, Literal, Optional, Union
from typing import List, Optional, Union

import pytest
from pydantic import ValidationError
Expand Down Expand Up @@ -35,9 +36,15 @@ class Model(SQLModel):
Model(unique_strings=["x", "y", "x"])


@pytest.mark.skipif(
sys.version_info < (3, 8), reason="requires Python 3.8+ (for `typing.Literal`)"
)
def test_discriminator():
from typing import Literal

# Example adapted from
# [Pydantic docs](https://pydantic-docs.helpmanual.io/usage/types/#discriminated-unions-aka-tagged-unions):

class Cat(SQLModel):
pet_type: Literal["cat"]
meows: int
Expand Down

0 comments on commit 57e05ab

Please sign in to comment.