{"id":3776,"library":"pytest-pretty","title":"pytest-pretty","description":"pytest-pretty is an opinionated pytest plugin designed to enhance the readability of test output and simplify the process of identifying and resolving errors. It provides features such as a real-time error summary, a rich, tabulated display of failures, and a more visually appealing overall summary of the test run. The current version is 1.3.0, and while its release cadence is irregular, the project is actively maintained.","status":"active","version":"1.3.0","language":"en","source_language":"en","source_url":"https://github.com/samuelcolvin/pytest-pretty","tags":["pytest","testing","plugin","output","summary","pretty print","developer experience"],"install":[{"cmd":"pip install -U pytest-pretty","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Core testing framework, pytest-pretty is a plugin for it.","package":"pytest","optional":false},{"reason":"Used for rich console formatting and pretty printing.","package":"rich","optional":false}],"imports":[{"note":"As a pytest plugin, pytest-pretty automatically integrates upon installation. Direct imports are typically not required for its core functionality.","symbol":"pytest-pretty (plugin)","correct":"No explicit import usually needed, automatically activated by pytest."},{"note":"While pytest_pretty provides a pytester_pretty fixture, it is typically made available by setting pytest_plugins = \"pytester\" in conftest.py, allowing it to be used directly in tests without explicit import statements in test files.","symbol":"pytester_pretty (fixture)","correct":"from pytest_pretty import pytester_pretty"}],"quickstart":{"code":"# test_example.py\n\ndef test_passing_example():\n    assert 1 + 1 == 2\n\ndef test_failing_example():\n    # This assertion will fail to demonstrate the pretty failure output\n    assert {\"a\": 1, \"b\": 2} == {\"a\": 1, \"b\": 3}\n\n# To run the tests, navigate to the directory containing test_example.py\n# and run the following command in your terminal:\n# pytest\n\n# For GitHub Actions, consider adding:\n# env:\n#   COLUMNS: 120\n# to your workflow .yml file for better output formatting.","lang":"python","description":"After installing `pytest-pretty`, simply run `pytest` from your terminal in a directory containing your test files (e.g., `test_example.py`). The plugin will automatically enhance the test summary, error reporting, and overall output. For optimal display in CI/CD environments like GitHub Actions, it's recommended to set the `COLUMNS` environment variable to a sufficient width."},"warnings":[{"fix":"Set the `COLUMNS` environment variable in your CI/CD workflow file to a larger value (e.g., `COLUMNS: 120`) to ensure the output is displayed fully.","message":"When running pytest-pretty in CI/CD environments such as GitHub Actions, the default terminal width might truncate the rich output. This can make the enhanced summary tables and error details less readable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Add `pytest_plugins = \"pytester\"` to your `conftest.py` file to make the `pytester_pretty` fixture available to your tests.","message":"If you intend to use the `pytester_pretty` fixture (which replaces pytest's built-in `pytester` for interacting with `pytest-pretty`'s modified output), you must explicitly enable the `pytester` plugin.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always consult the `pytest` changelog (e.g., for `pytest 8.0.0` and subsequent versions) for breaking changes, especially concerning test collection, hooks, and plugin APIs. Test your suite thoroughly after upgrading `pytest`.","message":"As a pytest plugin, `pytest-pretty`'s compatibility and behavior can be indirectly affected by breaking changes in the core `pytest` framework, particularly with major `pytest` version upgrades.","severity":"breaking","affected_versions":"All versions of pytest-pretty when used with major pytest updates (e.g., pytest 8.x and later)."}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}