Created
October 4, 2020 14:16
-
-
Save gidgid/b4ee87310daee9ae16dc36a0537206c5 to your computer and use it in GitHub Desktop.
Models that are not made of key-value pairs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytest | |
from typing import List | |
from pydantic import BaseModel | |
class Names(BaseModel): | |
values: List[str] | |
def test_values_is_not_part_of_the_input_data(): | |
with pytest.raises(TypeError): # 1 | |
Names(['name1', 'name2', 'name3']) # 1 | |
class Name(BaseModel): | |
value: str | |
def test_name_isnt_a_primitive_string(): | |
with pytest.raises(TypeError): # 2 | |
Name('42 is the answer') # 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment