wip
This commit is contained in:
parent
fec28df75f
commit
5ae6b86712
10 changed files with 312 additions and 39 deletions
43
tests/test_person.py
Normal file
43
tests/test_person.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""Example usage of expand_pydantic_args with the Person model.
|
||||
|
||||
SPDX-FileCopyrightText: 2023-present Waylon S. Walker <waylon@waylonwalker.com>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
"""
|
||||
|
||||
import inspect
|
||||
|
||||
from pydantic_typer import expand_pydantic_args
|
||||
|
||||
from . import models
|
||||
|
||||
# this one is broken
|
||||
# def test_no_pydantic() -> None:
|
||||
# @expand_pydantic_args()
|
||||
# def get_person(alpha) -> None:
|
||||
# """Mydocstring."""
|
||||
# from rich import print
|
||||
|
||||
# print(str(thing))
|
||||
# print(person)
|
||||
|
||||
# sig = inspect.signature(get_person)
|
||||
# params = sig.parameters
|
||||
|
||||
# for field in models.Alpha.__fields__.values():
|
||||
# assert field.name in params
|
||||
|
||||
|
||||
def test_single_signature() -> None:
|
||||
@expand_pydantic_args()
|
||||
def get_person(alpha: models.Alpha) -> None:
|
||||
"""Mydocstring."""
|
||||
return alpha
|
||||
|
||||
sig = inspect.signature(get_person)
|
||||
params = sig.parameters
|
||||
|
||||
for field in models.Alpha.__fields__.values():
|
||||
assert field.name in params
|
||||
|
||||
assert get_person(a=1) == models.Alpha(a=1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue