Skip to main content

Capture Pytest output and when test run is complete, drop user into interactive text user interface

Project description

pytest-fold

A Pytest plugin to make console output more manageable

Using PyTermTk:

output2

...using Textual TUI:

ezgif com-gif-maker

Introduction

Do you run long Pytest campaigns and get lots of failures? And then spend the next 10 minutes scrolling back in your console to find the one traceback that you're interested in drilling down into? Well, maybe pytest-fold can help. pytest-fold is a plugin that captures the output from your Pytest test runs, then automatically launches an interactive Text User Interface (TUI) where all your test results are categorized by (a) outcome [Pass|Fail|Error|Skipped|Xpass|Xfail], and (b) output section [Summary|Full|Errors|Passes|Failures|Warnings]. The intent it to make it easier for you to find the specific result you want so you can examine it without all the other results to get in your way.

Features

  • Choice of two TUIs: Textual and PyTermTk
  • Ability to immediately launch TUIs with existing data using console scripts
  • ANSI text markup support - whatever the output on your console looks like is how things are going to show up in the TUI
  • Mouse and keyboard support (including scrolling)
  • Support for all output formats/modes:
    • -v, -vv, -no-header, --showlocals, --color=<yes|no|auto>
    • all variants of --tb except "native"
  • Support for other, simple output-manipulating plugins:
    • pytest-clarity
    • pytest-emoji
    • pytest-icdiff
    • etc.
  • Not supported: plugins that take over the console in other ways, like
    • pytest-sugar
    • pytest-emoji-output

Requirements

  • Pytest >= 6.2.5
  • Python >= 3.8

Installation

pip install pytest-fold

Usage

From top-level directory:

  • pytest --fold [--fold-tui textual|pytermtk|none] <other-pytest-options>

To quit the Textual TUI, either click the Quit button, or press Q. To quit the PyTermTk TUI, click the Quit button in the upper right.

If you have already exited the TUI and would like to re-enter it with the same data generated from the last Pytest run, simply type:

  • termtxt (to launch Textual)
  • termtk (to launch PyTermTk)

You can also run with the --fold option enabled but bypass auto-launch of the TUI with the --ft=n option.

Known Limitations / Issues

  • Rudimentary user interfaces that need a lot of love:
    • Textual interface shows incomplete information (will be fixed very soon); can be slow, esp. if run within an IDE
    • PyTermTk interface does not yet show expanded individual test results (second on my list to fix, but will require writing some custom widget code)
    • There is an Asciimatics interface as well, but it lacks mouse support on Mac, which is a dealbreaker for me (may not ever fix)
  • Not fully tested with all combinations of output formats. Probably some use-cases where things won't work 100% right.
  • pytest-fold does not mark stderr or stdout sections for folding. It is assumed that the tester is interested in seeing such output.
  • pytest-fold is currently incompatible with --tb=native and will cause an INTERNALERROR if run together. (TODO: Fix this.)
  • pytest-fold may crash in the Asciimatics TUI if the console is resized.

Contributing

Contributions are very welcome. If you are slick with user interfaces, I would love some help there. Please run pyflakes and black on any code before submitting a PR.

License

Distributed under the terms of the MIT_ license, "pytest-fold" is free and open source software.

Issues

If you encounter any problems, have feedback or requests, or anything else, please file an issue, along with a detailed description.

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-fold-0.8.3.tar.gz (124.6 kB view hashes)

Uploaded Source

Built Distribution

pytest_fold-0.8.3-py2.py3-none-any.whl (221.4 kB view hashes)

Uploaded Python 2 Python 3

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