Re-run only the tests that failed in the last pytest run. Examples: * Re-run last failed tests: tools ts pytest last-failed * Re-run last failed with verbose output: tools ts pytest last-failed --args -v
(
ctx: Context,
venv: str = None,
args: list[str] = None,
)
| 120 | }, |
| 121 | ) |
| 122 | def last_failed( |
| 123 | ctx: Context, |
| 124 | venv: str = None, |
| 125 | args: list[str] = None, |
| 126 | ): |
| 127 | """ |
| 128 | Re-run only the tests that failed in the last pytest run. |
| 129 | |
| 130 | Examples: |
| 131 | |
| 132 | * Re-run last failed tests: |
| 133 | |
| 134 | tools ts pytest last-failed |
| 135 | |
| 136 | * Re-run last failed with verbose output: |
| 137 | |
| 138 | tools ts pytest last-failed --args -v |
| 139 | """ |
| 140 | pytest_bin = get_pytest_path(ctx, venv) |
| 141 | if pytest_bin is None: |
| 142 | ctx.exit(1) |
| 143 | |
| 144 | cmd = [str(pytest_bin), "--lf"] |
| 145 | if args: |
| 146 | cmd.extend(args) |
| 147 | |
| 148 | ctx.info(f"Running: {' '.join(cmd)}") |
| 149 | ret = ctx.run(*cmd, check=False, cwd=tools.utils.REPO_ROOT) |
| 150 | ctx.exit(ret.returncode) |
| 151 | |
| 152 | |
| 153 | @pytest_cmd.command( |
nothing calls this directly
no test coverage detected