Skip to main content

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 <url> to publish JSON reports to REST API.
  2. --pubdir <path> to write results to filesystem.

--publish

Run test like this:

$ pytest --publish http://localhost:7777/test-update

On each test result, an HTTP POST request with the following JSON data will be submitted:

# 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:

$ pytest --pubdir /tmp/a

On each test result, the following directory tree will be created:

/tmp/a
/tmp/a/test_a
/tmp/a/test_a/.lock
/tmp/a/test_a/count
/tmp/a/test_a/0.pass               # <index>.<result> 
/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:

/tmp/a/<scope>
/tmp/a/<scope>/<test_name>
/tmp/a/<scope>/<test_name>/count

Notice the addition of the <scope> to the directory tree above.

Release files for pytest-publish 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-publish 1.2.0
File Size Uploaded
pytest_publish-1.2.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-publish 1.2.0
File Interpreter ABI Platform
pytest_publish-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / pytest_publish-1.2.0.tar.gz

Download URL pytest_publish-1.2.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2786338d7864d85548b00da57ec113ca90cb7cd6d7836d0a6d6180a83bbbf53e
BLAKE2b-256 checksum
How to use checksums
1e558a774fecce4ceb39a0f9323e301ac7ec76519c78cab545c7dbb68585e068
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/20.6.0

Release files / pytest_publish-1.2.0-py3-none-any.whl

Download URL pytest_publish-1.2.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7a86b0912b038fa470abf006ad3655f134bb0244097c2ff0d25ba65df5b9d1a
BLAKE2b-256 checksum
How to use checksums
edb5241ac7c5ec5297ac388648c276054f33e3ba95367338510569a8323a6288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.2 Darwin/20.6.0

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page