Skip to content

Commit

Permalink
Added test with Annotated
Browse files Browse the repository at this point in the history
  • Loading branch information
maurosilber committed Aug 18, 2020
1 parent 4c21e8d commit 53d5b1a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions datastruct/test/test_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import typing

try:
from typing import Annotated
except ImportError:
from typing_extensions import Annotated

from datastruct import INVALID, DataStruct, KeyDefinedValue, exceptions, validators


Expand Down Expand Up @@ -100,6 +105,16 @@ def test_example_default():
assert o.b == "h"


def test_example_annotated():
class ExampleWithAnnotations(DataStruct):
a: int
b: Annotated[float, "metadata"] # noqa: F821

o = ExampleWithAnnotations(dict(a=1, b=1.0))
assert o.a == 1
assert o.b == 1.0


def test_validators():
assert validators.Email.validate("test@gmail.com")
assert not validators.Email.validate("test@gmail")
Expand Down

0 comments on commit 53d5b1a

Please sign in to comment.