pytest-live-pause 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytest_live_pause-0.1.0/.github/workflows/python-publish.yml +52 -0
- pytest_live_pause-0.1.0/.gitignore +218 -0
- pytest_live_pause-0.1.0/LICENSE +21 -0
- pytest_live_pause-0.1.0/PKG-INFO +204 -0
- pytest_live_pause-0.1.0/README.md +195 -0
- pytest_live_pause-0.1.0/pyproject.toml +22 -0
- pytest_live_pause-0.1.0/src/pytest_live_pause/__init__.py +3 -0
- pytest_live_pause-0.1.0/src/pytest_live_pause/cli.py +234 -0
- pytest_live_pause-0.1.0/src/pytest_live_pause/plugin.py +175 -0
- pytest_live_pause-0.1.0/src/pytest_live_pause/runtime.py +288 -0
- pytest_live_pause-0.1.0/tests/conftest.py +1 -0
- pytest_live_pause-0.1.0/tests/test_pause_on_failure.py +925 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# This workflow will upload a Python Package to PyPI when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
tags: [ 'v*.*.*' ]
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
release-build-and-publish-pypi:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
|
|
23
|
+
environment:
|
|
24
|
+
name: pypi
|
|
25
|
+
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v6
|
|
28
|
+
|
|
29
|
+
- name: Install uv
|
|
30
|
+
uses: astral-sh/setup-uv@v7
|
|
31
|
+
|
|
32
|
+
- name: "Set up Python"
|
|
33
|
+
uses: actions/setup-python@v6
|
|
34
|
+
with:
|
|
35
|
+
python-version-file: "pyproject.toml"
|
|
36
|
+
|
|
37
|
+
- name: Install the project
|
|
38
|
+
run: uv sync --all-groups
|
|
39
|
+
|
|
40
|
+
- name: Build release distributions
|
|
41
|
+
run: uv build
|
|
42
|
+
|
|
43
|
+
- name: Upload distributions
|
|
44
|
+
uses: actions/upload-artifact@v7
|
|
45
|
+
with:
|
|
46
|
+
name: release-dists
|
|
47
|
+
path: dist/
|
|
48
|
+
|
|
49
|
+
- name: Publish PyPI
|
|
50
|
+
env:
|
|
51
|
+
UV_PUBLISH_TOKEN: ${{ secrets.UV_PUBLISH_TOKEN }}
|
|
52
|
+
run: uv publish
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lanbao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytest-live-pause
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pytest plugin and protocol for pausing live test execution and resuming in-process
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: pytest>=9.0.3
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
## pytest-live-pause
|
|
11
|
+
|
|
12
|
+
`pytest-live-pause` is intended to be a standalone pytest plugin and runtime protocol for pausing a live test process, inspecting state before teardown, and resuming the same process through a structured control channel.
|
|
13
|
+
|
|
14
|
+
The repository is currently in bootstrap stage. The design target is:
|
|
15
|
+
|
|
16
|
+
- a transport-neutral pause runtime
|
|
17
|
+
- a thin pytest plugin adapter
|
|
18
|
+
- structured stdout and JSONL events
|
|
19
|
+
- packaged CLI commands for monitoring and resuming paused runs
|
|
20
|
+
- a compatibility layer for existing QAMule-style workflows
|
|
21
|
+
|
|
22
|
+
The current design scope lives in `CURRENT_SCOPE.md`.
|
|
23
|
+
|
|
24
|
+
## Current Status
|
|
25
|
+
|
|
26
|
+
The first working slice is `--pause-on-failure` using a file-backed control channel.
|
|
27
|
+
|
|
28
|
+
Checkpoint pauses are also supported through `pytest_live_pause.checkpoint(...)`.
|
|
29
|
+
|
|
30
|
+
The plugin also auto-registers `live_pause` and `pause_run_id` fixtures for direct injection into test function arguments.
|
|
31
|
+
|
|
32
|
+
When a test fails in the `call` phase and `--pause-on-failure` is enabled, the plugin:
|
|
33
|
+
|
|
34
|
+
- writes a pause request JSON file
|
|
35
|
+
- waits for an external resume command file or timeout
|
|
36
|
+
- resumes the same pytest process before teardown starts
|
|
37
|
+
- appends any externally supplied failure reason to the pytest report
|
|
38
|
+
|
|
39
|
+
Tests can also pause explicitly:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from pytest_live_pause import checkpoint
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def test_example():
|
|
46
|
+
decision = checkpoint(task="Approve the external step", timeout=300)
|
|
47
|
+
if decision.result is False:
|
|
48
|
+
raise AssertionError(decision.reason or "checkpoint failed")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or through the auto-registered fixture:
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
def test_example(live_pause, pause_run_id):
|
|
55
|
+
assert live_pause.run_id == pause_run_id
|
|
56
|
+
decision = live_pause.checkpoint(task="Approve the external step", timeout=300)
|
|
57
|
+
assert decision.result is True
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Checkpoint resumes use `--result` and `--reason`:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pytest-live-pause resume <pause_id> --result true --reason "approved"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Checkpoint behavior can also be mocked during pytest startup:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pytest --pause-checkpoint-mock false
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
Run pytest with pause-on-failure enabled:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pytest --pause-on-failure --pause-timeout 300
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
By default, pause state is written under `/tmp/pytest-live-pause`.
|
|
81
|
+
|
|
82
|
+
You can still override it explicitly:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pytest --pause-on-failure --pause-dir /some/other/path --pause-timeout 300
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
When a test fails, a pause file appears under the run directory:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
|
|
92
|
+
/tmp/pytest-live-pause/
|
|
93
|
+
runs/<run_id>/
|
|
94
|
+
events.jsonl
|
|
95
|
+
run.json
|
|
96
|
+
pauses/<pause_id>.json
|
|
97
|
+
commands/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Resume the paused failure by pointing the CLI at the pause file:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pytest-live-pause resume \
|
|
104
|
+
/tmp/pytest-live-pause/runs/<run_id>/pauses/<pause_id>.json \
|
|
105
|
+
--failure-reason "manually confirmed"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
You can also resume directly by `pause_id`, which is more convenient when multiple pytest processes share the same pause directory:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
pytest-live-pause resume <pause_id> --failure-reason "manually confirmed"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
If you are using a non-default pause directory, pass it explicitly:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pytest-live-pause resume <pause_id> --pause-dir /some/other/path --failure-reason "manually confirmed"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For failure pauses, `--failure-reason` appends an extra explanation to the pytest failure report. Non-failure pauses must not receive `--failure-reason`; the CLI will reject that combination.
|
|
121
|
+
|
|
122
|
+
For checkpoint pauses, use `--result true|false|none` and optional `--reason`.
|
|
123
|
+
|
|
124
|
+
For mocked checkpoint pauses, `reason` is fixed to `Mock`.
|
|
125
|
+
|
|
126
|
+
The CLI writes the matching command file into `commands/`. The pytest process polls for that command and then continues into teardown.
|
|
127
|
+
|
|
128
|
+
When multiple pytest processes share the same pause directory, each process gets its own `runs/<run_id>/` directory. `run.json` and each pause file also record `pid`, `hostname`, `cwd`, and optional `worker_id` metadata.
|
|
129
|
+
|
|
130
|
+
You can inspect currently pending pauses across all runs with:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pytest-live-pause ls
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
You can also watch for newly paused tests in real time:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
pytest-live-pause watch --run-id <run_id>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`watch` requires a specific pytest `run_id`:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
pytest-live-pause watch --run-id <run_id>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
For bounded monitoring, pass a timeout:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pytest-live-pause watch --run-id <run_id> --timeout 30
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`watch` waits until the latest matching pending pause appears, prints the pause details, and then exits.
|
|
155
|
+
|
|
156
|
+
By default, `ls` only shows currently resumable `pending` pauses. To include `stale`, `resumed`, and `timed_out` entries, use:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
pytest-live-pause ls -a
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
If a pytest process is killed while paused, its pause file remains on disk. The CLI treats that as `stale` when the recorded `pid` is no longer alive on the current host. `ls -a` will show the stale state, and `resume` will refuse to write a command for it.
|
|
163
|
+
|
|
164
|
+
If no command arrives before `--pause-timeout`, the test resumes automatically without adding an external failure reason.
|
|
165
|
+
|
|
166
|
+
When pytest starts, it prints the current `run_id`, so you can monitor that specific pytest process with `pytest-live-pause watch --run-id <run_id>`.
|
|
167
|
+
|
|
168
|
+
## File Protocol
|
|
169
|
+
|
|
170
|
+
`pauses/<pause_id>.json` currently contains:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"pause_id": "...",
|
|
175
|
+
"run_id": "...",
|
|
176
|
+
"nodeid": "tests/test_sample.py::test_failure",
|
|
177
|
+
"timeout": 300.0,
|
|
178
|
+
"original_failure": "AssertionError: boom",
|
|
179
|
+
"status": "pending",
|
|
180
|
+
"created_at": 1710000000.0,
|
|
181
|
+
"pid": 12345,
|
|
182
|
+
"hostname": "host.local",
|
|
183
|
+
"cwd": "/repo"
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
`commands/<pause_id>.resume.json` currently contains:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"failure_reason": "manually confirmed"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Or for a checkpoint pause:
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{
|
|
199
|
+
"result": true,
|
|
200
|
+
"reason": "approved"
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
This file transport is only the first implementation. The runtime can be split from the transport later if you want to add sockets or HTTP.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
## pytest-live-pause
|
|
2
|
+
|
|
3
|
+
`pytest-live-pause` is intended to be a standalone pytest plugin and runtime protocol for pausing a live test process, inspecting state before teardown, and resuming the same process through a structured control channel.
|
|
4
|
+
|
|
5
|
+
The repository is currently in bootstrap stage. The design target is:
|
|
6
|
+
|
|
7
|
+
- a transport-neutral pause runtime
|
|
8
|
+
- a thin pytest plugin adapter
|
|
9
|
+
- structured stdout and JSONL events
|
|
10
|
+
- packaged CLI commands for monitoring and resuming paused runs
|
|
11
|
+
- a compatibility layer for existing QAMule-style workflows
|
|
12
|
+
|
|
13
|
+
The current design scope lives in `CURRENT_SCOPE.md`.
|
|
14
|
+
|
|
15
|
+
## Current Status
|
|
16
|
+
|
|
17
|
+
The first working slice is `--pause-on-failure` using a file-backed control channel.
|
|
18
|
+
|
|
19
|
+
Checkpoint pauses are also supported through `pytest_live_pause.checkpoint(...)`.
|
|
20
|
+
|
|
21
|
+
The plugin also auto-registers `live_pause` and `pause_run_id` fixtures for direct injection into test function arguments.
|
|
22
|
+
|
|
23
|
+
When a test fails in the `call` phase and `--pause-on-failure` is enabled, the plugin:
|
|
24
|
+
|
|
25
|
+
- writes a pause request JSON file
|
|
26
|
+
- waits for an external resume command file or timeout
|
|
27
|
+
- resumes the same pytest process before teardown starts
|
|
28
|
+
- appends any externally supplied failure reason to the pytest report
|
|
29
|
+
|
|
30
|
+
Tests can also pause explicitly:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from pytest_live_pause import checkpoint
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_example():
|
|
37
|
+
decision = checkpoint(task="Approve the external step", timeout=300)
|
|
38
|
+
if decision.result is False:
|
|
39
|
+
raise AssertionError(decision.reason or "checkpoint failed")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or through the auto-registered fixture:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
def test_example(live_pause, pause_run_id):
|
|
46
|
+
assert live_pause.run_id == pause_run_id
|
|
47
|
+
decision = live_pause.checkpoint(task="Approve the external step", timeout=300)
|
|
48
|
+
assert decision.result is True
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Checkpoint resumes use `--result` and `--reason`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pytest-live-pause resume <pause_id> --result true --reason "approved"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Checkpoint behavior can also be mocked during pytest startup:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pytest --pause-checkpoint-mock false
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
Run pytest with pause-on-failure enabled:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pytest --pause-on-failure --pause-timeout 300
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
By default, pause state is written under `/tmp/pytest-live-pause`.
|
|
72
|
+
|
|
73
|
+
You can still override it explicitly:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pytest --pause-on-failure --pause-dir /some/other/path --pause-timeout 300
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
When a test fails, a pause file appears under the run directory:
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
|
|
83
|
+
/tmp/pytest-live-pause/
|
|
84
|
+
runs/<run_id>/
|
|
85
|
+
events.jsonl
|
|
86
|
+
run.json
|
|
87
|
+
pauses/<pause_id>.json
|
|
88
|
+
commands/
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Resume the paused failure by pointing the CLI at the pause file:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
pytest-live-pause resume \
|
|
95
|
+
/tmp/pytest-live-pause/runs/<run_id>/pauses/<pause_id>.json \
|
|
96
|
+
--failure-reason "manually confirmed"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
You can also resume directly by `pause_id`, which is more convenient when multiple pytest processes share the same pause directory:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pytest-live-pause resume <pause_id> --failure-reason "manually confirmed"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
If you are using a non-default pause directory, pass it explicitly:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pytest-live-pause resume <pause_id> --pause-dir /some/other/path --failure-reason "manually confirmed"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For failure pauses, `--failure-reason` appends an extra explanation to the pytest failure report. Non-failure pauses must not receive `--failure-reason`; the CLI will reject that combination.
|
|
112
|
+
|
|
113
|
+
For checkpoint pauses, use `--result true|false|none` and optional `--reason`.
|
|
114
|
+
|
|
115
|
+
For mocked checkpoint pauses, `reason` is fixed to `Mock`.
|
|
116
|
+
|
|
117
|
+
The CLI writes the matching command file into `commands/`. The pytest process polls for that command and then continues into teardown.
|
|
118
|
+
|
|
119
|
+
When multiple pytest processes share the same pause directory, each process gets its own `runs/<run_id>/` directory. `run.json` and each pause file also record `pid`, `hostname`, `cwd`, and optional `worker_id` metadata.
|
|
120
|
+
|
|
121
|
+
You can inspect currently pending pauses across all runs with:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pytest-live-pause ls
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
You can also watch for newly paused tests in real time:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
pytest-live-pause watch --run-id <run_id>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`watch` requires a specific pytest `run_id`:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
pytest-live-pause watch --run-id <run_id>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For bounded monitoring, pass a timeout:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pytest-live-pause watch --run-id <run_id> --timeout 30
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`watch` waits until the latest matching pending pause appears, prints the pause details, and then exits.
|
|
146
|
+
|
|
147
|
+
By default, `ls` only shows currently resumable `pending` pauses. To include `stale`, `resumed`, and `timed_out` entries, use:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
pytest-live-pause ls -a
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If a pytest process is killed while paused, its pause file remains on disk. The CLI treats that as `stale` when the recorded `pid` is no longer alive on the current host. `ls -a` will show the stale state, and `resume` will refuse to write a command for it.
|
|
154
|
+
|
|
155
|
+
If no command arrives before `--pause-timeout`, the test resumes automatically without adding an external failure reason.
|
|
156
|
+
|
|
157
|
+
When pytest starts, it prints the current `run_id`, so you can monitor that specific pytest process with `pytest-live-pause watch --run-id <run_id>`.
|
|
158
|
+
|
|
159
|
+
## File Protocol
|
|
160
|
+
|
|
161
|
+
`pauses/<pause_id>.json` currently contains:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"pause_id": "...",
|
|
166
|
+
"run_id": "...",
|
|
167
|
+
"nodeid": "tests/test_sample.py::test_failure",
|
|
168
|
+
"timeout": 300.0,
|
|
169
|
+
"original_failure": "AssertionError: boom",
|
|
170
|
+
"status": "pending",
|
|
171
|
+
"created_at": 1710000000.0,
|
|
172
|
+
"pid": 12345,
|
|
173
|
+
"hostname": "host.local",
|
|
174
|
+
"cwd": "/repo"
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`commands/<pause_id>.resume.json` currently contains:
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{
|
|
182
|
+
"failure_reason": "manually confirmed"
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Or for a checkpoint pause:
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"result": true,
|
|
191
|
+
"reason": "approved"
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
This file transport is only the first implementation. The runtime can be split from the transport later if you want to add sockets or HTTP.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pytest-live-pause"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Pytest plugin and protocol for pausing live test execution and resuming in-process"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"pytest>=9.0.3",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
pytest-live-pause = "pytest_live_pause.cli:main"
|
|
17
|
+
|
|
18
|
+
[project.entry-points.pytest11]
|
|
19
|
+
pytest_live_pause = "pytest_live_pause.plugin"
|
|
20
|
+
|
|
21
|
+
[tool.hatch.build.targets.wheel]
|
|
22
|
+
packages = ["src/pytest_live_pause"]
|