Skip to content

Commit

Permalink
Move all literals test to test_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
DBCerigo committed May 23, 2020
1 parent e339856 commit 6949f5b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
17 changes: 0 additions & 17 deletions tests/test_typing.py

This file was deleted.

15 changes: 14 additions & 1 deletion tests/test_utils.py
Expand Up @@ -11,7 +11,7 @@
from pydantic.color import Color
from pydantic.dataclasses import dataclass
from pydantic.fields import Undefined
from pydantic.typing import display_as_type, is_new_type, new_type_supertype
from pydantic.typing import Literal, all_literal_values, display_as_type, is_new_type, new_type_supertype
from pydantic.utils import (
ClassAttribute,
ValueItems,
Expand Down Expand Up @@ -320,3 +320,16 @@ class Foo:
f = Foo()
f.attr = 'not foo'
assert f.attr == 'not foo'


@pytest.mark.skipif(not Literal, reason='typing_extensions not installed')
def test_all_literal_values():
L1 = Literal['1']
assert all_literal_values(L1) == ('1',)

L2 = Literal['2']
L12 = Literal[L1, L2]
assert sorted(all_literal_values(L12)) == sorted(('1', '2'))

L312 = Literal['3', Literal[L1, L2]]
assert sorted(all_literal_values(L312)) == sorted(('1', '2', '3'))

0 comments on commit 6949f5b

Please sign in to comment.