Created
September 28, 2020 12:24
-
-
Save gidgid/38fed64041c70817404a1f89bf478376 to your computer and use it in GitHub Desktop.
Copy with update doesn't 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') | |
assert pizza.toppings_count == 4 | |
new_pizza = pizza.copy(update={'toppings_count': 'not a number'}) | |
assert new_pizza.toppings_count == 'not a number' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment