Skip to main content

Multi-process logs handling and other helpers for pytest

Project description

pytest-multilog

A pytest plugin to persist logs from parallel test processes (and other helpers)

Usage

To use the multilog feature, a test class just needs to inherit from the TestHelper class:

from pytest_multilog import TestHelper

class TestCustom(TestHelper):
    def test_custom(self):
        # Custom test implementation
        ...

The TestHelper class declares a logs fixture which will be automatically used by its children classes.

Behavior and attributes

Root folder

The TestHelper class provider a root_folder property, matching with the pytest root folder.

Output folder

The TestHelper class provider a output_folder property, where all files will be written. It's set to output_folder / "out" / "tests"

Test name

Each test is associated to a name (provided in TestHelper.test_name), computed from the file name, the class name and the method name.

E.g. for the snippet above, if stored in a test_custom.py file, the test name will be: test_custom_TestCustom_test_custom.

Current worker

In multi-process environment (pytest was invoked with -n X argument), the current worker name is provided in TestHelper.worker attribute. It's set to "master" in single-process environment.

Test folder

Test logs will be written in a pytest.log file, stored in each test folder (provided in TestHelper.test_folder attribute):

  • While the test is running, it's set to TestHelper.output_root / "__running__" / TestHelper.worker / TestHelper.test_name
  • Once the test is terminated, the folder is moved directly under the output root one.

It means that during the test execution, it's possible to check which test is running on which worker (easing troubleshooting situations where a given worker is blocked)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-multilog-1.0.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file pytest-multilog-1.0.tar.gz.

File metadata

  • Download URL: pytest-multilog-1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for pytest-multilog-1.0.tar.gz
Algorithm Hash digest
SHA256 cedd53afc9cdb5a3faaee64279f47eed9bf9b4efeeaf7c45f367815931853142
MD5 80011bca4e9eee7f55fc2e2690b0c281
BLAKE2b-256 90f1797c35aec08dc3a34e854c888d097e29dc7cc6a60d257c6aafdd2c9cee8f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page