Run pytest directly with the specified test path. Examples: * Run a specific test file: tools ts pytest run tests/pytests/unit/test_loader.py * Run a specific test with verbose output: tools ts pytest run tests/pytests/unit/test_loader.py::test_load_modules
(
ctx: Context,
test_path: str,
venv: str = None,
args: list[str] = None,
)
| 68 | }, |
| 69 | ) |
| 70 | def run_pytest( |
| 71 | ctx: Context, |
| 72 | test_path: str, |
| 73 | venv: str = None, |
| 74 | args: list[str] = None, |
| 75 | ): |
| 76 | """ |
| 77 | Run pytest directly with the specified test path. |
| 78 | |
| 79 | Examples: |
| 80 | |
| 81 | * Run a specific test file: |
| 82 | |
| 83 | tools ts pytest run tests/pytests/unit/test_loader.py |
| 84 | |
| 85 | * Run a specific test with verbose output: |
| 86 | |
| 87 | tools ts pytest run tests/pytests/unit/test_loader.py::test_load_modules --args -v -x |
| 88 | |
| 89 | * Run using a custom venv: |
| 90 | |
| 91 | tools ts pytest run tests/pytests/unit/test_loader.py --venv ./my_venv |
| 92 | """ |
| 93 | if TYPE_CHECKING: |
| 94 | assert test_path is not None |
| 95 | |
| 96 | pytest_bin = get_pytest_path(ctx, venv) |
| 97 | if pytest_bin is None: |
| 98 | ctx.exit(1) |
| 99 | |
| 100 | # Build pytest command |
| 101 | cmd = [str(pytest_bin), test_path] |
| 102 | if args: |
| 103 | cmd.extend(args) |
| 104 | |
| 105 | ctx.info(f"Running: {' '.join(cmd)}") |
| 106 | ret = ctx.run(*cmd, check=False, cwd=tools.utils.REPO_ROOT) |
| 107 | ctx.exit(ret.returncode) |
| 108 | |
| 109 | |
| 110 | @pytest_cmd.command( |
nothing calls this directly
no test coverage detected