Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuvalino/pytest-publish
Live publishing of pytest test results to REST API
https://github.com/yuvalino/pytest-publish
pytest pytest-plugin python python3 rest-api
Last synced: 16 days ago
JSON representation
Live publishing of pytest test results to REST API
- Host: GitHub
- URL: https://github.com/yuvalino/pytest-publish
- Owner: yuvalino
- Created: 2024-05-25T17:47:26.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-06-04T07:17:55.000Z (7 months ago)
- Last Synced: 2024-10-31T05:12:03.990Z (2 months ago)
- Topics: pytest, pytest-plugin, python, python3, rest-api
- Language: Python
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pytest-publish
pytest-publish is a simple pytest plugin for publishing test results mid-session.
Useful for live applications running on top of pytest (UI, logstash, etc).
## Usage
There are 2 switches which can be turned on, each run every time a test has finished running:
1. `--publish ` to publish JSON reports to REST API.
2. `--pubdir ` to write results to filesystem.### --publish
Run test like this:
```sh
$ pytest --publish http://localhost:7777/test-update
```On each test result, an HTTP POST request with the following JSON data will be submitted:
```python
# from pytest_publish.py
@dataclass_json
@dataclass
class TestResult:
@dataclass_json
@dataclass
class ExcInfo:
type: str
value: str
traceback: list[str]type: str
result: str # "pass", "skip", "fail"
nodeid: str
start_time: float
stop_time: float
duration: float
stdout: str
stderr: str
log: str
xdist_dist: str | None # only with xdist
xdist_worker: str | None # only with xdist
xdist_scope: str | None # only with xdist
excinfo: ExcInfo | None = None # only if "skip" or "fail"```
### --pubdir
Run test like this:
```sh
$ pytest --pubdir /tmp/a
```On each test result, the following directory tree will be created:
```sh
/tmp/a
/tmp/a/test_a
/tmp/a/test_a/.lock
/tmp/a/test_a/count
/tmp/a/test_a/0.pass # .
/tmp/a/test_a/0.pass/brief.txt # textual description of result
/tmp/a/test_a/0.pass/result.json # same data as --publish
/tmp/a/test_a/0.pass/exception.txt # only if "skip" or "fail"
/tmp/a/test_a/0.pass/stdout.txt # only if any stdout
/tmp/a/test_a/0.pass/stderr.txt # only if any stderr
/tmp/a/test_a/0.pass/log.txt # only if any logs
```**NOTE:** If xdist's `--dist loadgroup` is run with xdist, the directory tree will look like this:
```sh
/tmp/a/
/tmp/a//
/tmp/a///count
```
Notice the addition of the `` to the directory tree above.