Run tests matching a pattern (uses pytest -k). Examples: * Run all tests with 'auth' in the name: tools ts pytest pattern auth * Run pattern in specific directory: tools ts pytest pattern loader --test-path tests/pytests/unit * Run pattern with verbose
(
ctx: Context,
pattern: str,
venv: str = None,
test_path: str = None,
args: list[str] = None,
)
| 169 | }, |
| 170 | ) |
| 171 | def run_pattern( |
| 172 | ctx: Context, |
| 173 | pattern: str, |
| 174 | venv: str = None, |
| 175 | test_path: str = None, |
| 176 | args: list[str] = None, |
| 177 | ): |
| 178 | """ |
| 179 | Run tests matching a pattern (uses pytest -k). |
| 180 | |
| 181 | Examples: |
| 182 | |
| 183 | * Run all tests with 'auth' in the name: |
| 184 | |
| 185 | tools ts pytest pattern auth |
| 186 | |
| 187 | * Run pattern in specific directory: |
| 188 | |
| 189 | tools ts pytest pattern loader --test-path tests/pytests/unit |
| 190 | |
| 191 | * Run pattern with verbose output: |
| 192 | |
| 193 | tools ts pytest pattern auth --args -v -x |
| 194 | """ |
| 195 | if TYPE_CHECKING: |
| 196 | assert pattern is not None |
| 197 | |
| 198 | pytest_bin = get_pytest_path(ctx, venv) |
| 199 | if pytest_bin is None: |
| 200 | ctx.exit(1) |
| 201 | |
| 202 | # Default to pytests directory if no path specified |
| 203 | if test_path is None: |
| 204 | test_path = "tests/pytests" |
| 205 | |
| 206 | cmd = [str(pytest_bin), test_path, "-k", pattern] |
| 207 | if args: |
| 208 | cmd.extend(args) |
| 209 | |
| 210 | ctx.info(f"Running: {' '.join(cmd)}") |
| 211 | ret = ctx.run(*cmd, check=False, cwd=tools.utils.REPO_ROOT) |
| 212 | ctx.exit(ret.returncode) |
| 213 | |
| 214 | |
| 215 | @pytest_cmd.command( |
nothing calls this directly
no test coverage detected