-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hello!
I am using your library to parametrize my tests! I am using Pydantic in my project and would like to use it to (de)serialize the input objects with it. My test case looks as follows:
test_object:
- person:
first_name: "John"
last_name: "Doe"
len: 4class Person(BaseModel):
first_name: str
last_name: str
@pff.parametrize(schema=[pff.cast(person=Person)])
def test_object(person: Person, len: int):
assert person.first_name == "John"
assert len(person.first_name) == lenI don't know if I am using the schema and the cast correctly in this context, but I would like to convert the complex object into a base model. Alternatively, I can do this:
class Person(BaseModel):
first_name: str
last_name: str
@pff.parametrize
def test_object(person: dict, len: int):
person_obj = Person(**person)
assert person_obj.first_name == "John"
assert len(person_obj.first_name) == lenwhich works, but it would be nice if the library could do the conversion on its own! Is there a way of doing this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels