Testing your cli app.#
The general idea behind Clipstick is populating a pydantic model based on arguments provided by the user of your cli tool.
If you want to test your cli you can do just that: provide arguments and validate whether your model is populated correctly:
import pytest
from clipstick._clipstick import parse
from pydantic import BaseModel
class StrPositional(BaseModel):
my_value: str
"""A string positional."""
class IntPositional(BaseModel):
my_value: int
def test_parse_simple_positional_only():
model = parse(StrPositional, ["Adam"])
assert model == StrPositional(my_value="Adam")
def test_too_much_positionals_must_raise(capture_output):