Last active
November 20, 2020 13:37
-
-
Save gidgid/ce7b7a13d91cd9424cb1e18e0f9fcd25 to your computer and use it in GitHub Desktop.
Pydantic copy doesnt perform type coercion
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
from pydantic import BaseModel | |
class Pizza(BaseModel): | |
toppings_count: int | |
size: str | |
def test_copy_with_update_doesnt_perform_conversion(): | |
pizza = Pizza(toppings_count='4', size='XL') # 1 | |
assert pizza.toppings_count == 4 | |
new_pizza = pizza.copy(update={'toppings_count': 'not a number'}) # 2 | |
assert new_pizza.toppings_count == 'not a number' # 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment