Skip to main content

A pytest plugin that limits the output to just the things you need.

Project description

PyPI version Python versions License Build Status

A pytest plugin that limits the output of pytest to just the things you need to see.

One of my biggest personal complaints about pytest is that its console output is very, very chatty. It tells you it’s starting. It tells you it’s working. It tells you it’s done. And if a test fails, it doesn’t just tell you which test failed. It dumps pages and pages of code onto your console.

And it does all this in Glorious Technicolor. Better hope you have perfect color vision, and your console color choices are contrast compatible.

Yes: pytest has many, many command line options. And some of these behaviors can be configured or turned off with feature flags. But there are some people (presumably, at the very least, the pytest core team) who like pytest’s output format. So if you’re the odd-one-out on a team who doesn’t like pytest’s output, you can’t commit “better” options into a default configuration - you have to manually specify your options every time you run the test suite.

Luckily, pytest also has a plugin system, so we can fix this.

pytest-tldr is plugin that gives you minimalist output, in monochrome, while still giving an indication of test suite progress.

Installation

You can install “pytest-tldr” via pip from PyPI:

$ pip install pytest-tldr

Then you can just run your test suite as normal:

$ pytest tests
EF..s..........ux
======================================================================
ERROR: tests/test_things.py::TestTests::test_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rkm/projects/sample/tests/test_things.py", line 182, in test_error
    raise Exception("this is really bad")
Exception: this is really bad

======================================================================
FAIL: tests/test_things.py::TestTests::test_failed
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rkm/projects/sample/tests/test_things.py", line 179, in test_failed
    self.fail('failed!')
  File "/Users/rkm/.pyenv/versions/3.6.2/lib/python3.6/unittest/case.py", line 670, in fail
    raise self.failureException(msg)
AssertionError: failed!

======================================================================
UNEXPECTED SUCCESS: tests/test_things.py::TestTests::test_upassed

----------------------------------------------------------------------
Ran 17 tests in 2.11s

FAILED (errors=1, failures=1, skipped=1, expected failures=1, unexpected successes=1)

Or, if you need a little more detail, use the verbosity option:

$ pytest tests -v
platform darwin -- Python 3.6.2
pytest==3.6.1
py==1.5.2
pluggy==0.6.0
rootdir: /Users/rkm/projects/sample
plugins: xdist-1.22.0, forked-0.2, tldr-0.1.0
cachedir: .pytest_cache

----------------------------------------------------------------------
tests/test_things.py::TestTests::test_error ... ERROR
tests/test_things.py::TestTests::test_failed ... FAIL
tests/test_things.py::TestTests::test_output ... ok
tests/test_things.py::TestTests::test_passed ... ok
tests/test_things.py::TestTests::test_skipped ... Skipped: tra-la-la
tests/test_things.py::TestTests::test_thing_0 ... ok
tests/test_things.py::TestTests::test_thing_1 ... ok
tests/test_things.py::TestTests::test_thing_2 ... ok
tests/test_things.py::TestTests::test_thing_3 ... ok
tests/test_things.py::TestTests::test_thing_4 ... ok
tests/test_things.py::TestTests::test_thing_5 ... ok
tests/test_things.py::TestTests::test_thing_6 ... ok
tests/test_things.py::TestTests::test_thing_7 ... ok
tests/test_things.py::TestTests::test_thing_8 ... ok
tests/test_things.py::TestTests::test_thing_9 ... ok
tests/test_things.py::TestTests::test_upassed ... unexpected success
tests/test_things.py::TestTests::test_xfailed ... expected failure

======================================================================
ERROR: tests/test_things.py::TestTests::test_error
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rkm/projects/sample/tests/test_things.py", line 182, in test_error
    raise Exception("this is really bad")
Exception: this is really bad

======================================================================
FAIL: tests/test_things.py::TestTests::test_failed
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rkm/projects/sample/tests/test_things.py", line 179, in test_failed
    self.fail('failed!')
  File "/Users/rkm/.pyenv/versions/3.6.2/lib/python3.6/unittest/case.py", line 670, in fail
    raise self.failureException(msg)
AssertionError: failed!

======================================================================
UNEXPECTED SUCCESS: tests/test_things.py::TestTests::test_upassed

----------------------------------------------------------------------
Ran 17 tests in 2.07s

FAILED (errors=1, failures=1, skipped=1, expected failures=1, unexpected successes=1)

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_tldr-0.2.6.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

pytest_tldr-0.2.6-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_tldr-0.2.6.tar.gz.

File metadata

  • Download URL: pytest_tldr-0.2.6.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pytest_tldr-0.2.6.tar.gz
Algorithm Hash digest
SHA256 5c0ccc6991276c8489ff1720f1498d5130690bb8504aaf8c7bd115bf91abc035
MD5 3bd149a4aef2ec30a2e3fc193a9f34f7
BLAKE2b-256 da69b5c36feca4b6ab19b40d023bfbe470e7d85b3134e3f29b276cd81dafc901

See more details on using hashes here.

File details

Details for the file pytest_tldr-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: pytest_tldr-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pytest_tldr-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6ade770db16dce93d32b830ebe705e84ce0e1b2e3265a47d90e04d818cefcdc6
MD5 523f6a8976b6f4bcddad108a9d6fe453
BLAKE2b-256 79bed1bd9adc2d560faa02391f33166e2aab20c3dae255528f446a9a4c4607e2

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