Skip to content

Commit

Permalink
tests: fix ci with python < 3.8 without typing-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
PrettyWood committed Dec 23, 2020
1 parent c5e236a commit 0f5cb59
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/test_main.py
@@ -1,10 +1,19 @@
import sys
from collections import namedtuple
from enum import Enum
from typing import Any, Callable, ClassVar, Dict, List, Mapping, Optional, Type, get_type_hints
from typing import Any, Callable, ClassVar, Dict, List, Mapping, NamedTuple, Optional, Type, get_type_hints
from uuid import UUID, uuid4

import pytest

if sys.version_info < (3, 8):
try:
from typing import TypedDict
except ImportError:
TypedDict = None
else:
from typing import TypedDict

from pydantic import (
BaseModel,
ConfigError,
Expand Down Expand Up @@ -1428,9 +1437,6 @@ class M(BaseModel):


def test_named_tuple():
from collections import namedtuple
from typing import NamedTuple

Position = namedtuple('Pos', 'x y')

class Event(NamedTuple):
Expand Down Expand Up @@ -1462,9 +1468,8 @@ class Model(BaseModel):
]


@pytest.mark.skipif(not TypedDict, reason='typing_extensions not installed')
def test_typed_dict():
from typing import TypedDict

class TD(TypedDict):
a: int
b: int
Expand All @@ -1488,9 +1493,8 @@ class Model(BaseModel):
]


@pytest.mark.skipif(not TypedDict, reason='typing_extensions not installed')
def test_typed_dict_non_total():
from typing import TypedDict

class FullMovie(TypedDict, total=True):
name: str
year: int
Expand Down

0 comments on commit 0f5cb59

Please sign in to comment.