Skip to content

Instantly share code, notes, and snippets.

@gidgid
Created September 28, 2020 12:24
Show Gist options
  • Save gidgid/38fed64041c70817404a1f89bf478376 to your computer and use it in GitHub Desktop.
Save gidgid/38fed64041c70817404a1f89bf478376 to your computer and use it in GitHub Desktop.
Copy with update doesn't perform type coercion
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