Skip to main content

pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout)

Project description

pytest-print

PyPI PyPI - Implementation PyPI - Python Version Downloads PyPI - License check

Allows to print extra content onto the PyTest reporting. This can be used for example to report sub-steps for long running tests, or to print debug information in your tests when you cannot debug the code.

install

pip install pytest-print

The plugin provides ability to print information during the tests runs.

flags

  • --print by default the module activates print when pytest verbosity is greater than zero, this allows to bypass this and force print irrespective of the verbosity
  • --print-relative-time will print the relative time since the start of the test (display how long it takes to reach prints)

use cases

sub-step reporting

For tests that are long running this can provide feedback to the end-user that what is just happening in the background.

def test_server_parallel_requests(printer, tmpdir):
    printer("create virtual environment into {}".format(tmpdir))
    create_virtual_environment(tmpdir)

    printer("start server from virtual env")
    start_server(tmpdir)

    printer("do the parallel request test")
    parallel_requests()
$ py.test --vv
============================= test session starts ==============================
platform linux -- Python 3.6.4, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
collecting ... collected 1 item

test_printer_progress.py::test_server_parallel_requests
    create virtual environment
    start server from virtual env
    do the parallel request test
PASSED                                                                   [100%]

=========================== 1 passed in 0.02 seconds ===========================

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_print-1.0.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

pytest_print-1.0.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest_print-1.0.2.tar.gz.

File metadata

  • Download URL: pytest_print-1.0.2.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pytest_print-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2780350a7bbe7117f99c5d708dc7b0431beceda021b1fd3f11200670d7f33679
MD5 c9f0426d05603c13ee2a3ec7ecbd43a2
BLAKE2b-256 e61c4abdccb6e94990555da42cd06ae65bb651845e6131db92237141e5f1c0f3

See more details on using hashes here.

File details

Details for the file pytest_print-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pytest_print-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pytest_print-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3ae7891085dddc3cd697bd6956787240107fe76d6b5cdcfcd782e33ca6543de9
MD5 853d33e576dfafa822ae6c43e8dd8ad4
BLAKE2b-256 9b339f5b6b83bddc355adf42eddfbf8925e6a1cc4cb32108b19792dafc32a4d9

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