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 PyPI - Downloads PyPI - License check codecov Code style: black

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 a feedback ot 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-0.3.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_print-0.3.0-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: pytest_print-0.3.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pytest_print-0.3.0.tar.gz
Algorithm Hash digest
SHA256 769f1b1b0943b2941dbeeaac6985766e76b341130ed538f88c23ebcd7087b90d
MD5 adfc9800c8f5259a0a14e97619479c71
BLAKE2b-256 b514bb6d992b5e93e2c823950c027aae1681039182e5f957492db52a1f054862

See more details on using hashes here.

File details

Details for the file pytest_print-0.3.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_print-0.3.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.5

File hashes

Hashes for pytest_print-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 53fb0f71d371f137ac2e7171d92f204eb45055580e8c7920df619d9b2ee45359
MD5 f212742a2549357cd7dad0dedb388c30
BLAKE2b-256 51818cd5bafdbba210269e63c217db8d7a8d72bee7b92ba575e7ce224acbb516

See more details on using hashes here.

Supported by

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