1import os
 2import sys
 3
 4import click
 5
 6from plain.cli import register_cli
 7from plain.cli.runtime import common_command
 8
 9
10@common_command
11@register_cli("test")
12@click.command(
13    context_settings={
14        "ignore_unknown_options": True,
15    }
16)
17@click.argument("pytest_args", nargs=-1, type=click.UNPROCESSED)
18def cli(pytest_args: tuple[str, ...]) -> None:
19    """Test suite with pytest"""
20    # .env.test loading is handled by the pytest plugin in plugin.py
21
22    cmd = [
23        sys.executable,
24        "-m",
25        "pytest",
26        *pytest_args,
27    ]
28
29    # Replace current process with pytest
30    os.execvp(cmd[0], cmd)