{"id":10149,"library":"pytest-rich","title":"pytest-rich","description":"pytest-rich is a pytest plugin that integrates the rich library to provide enhanced, colorful, and highly readable output for test sessions. It improves the default pytest terminal output with features like better traceback formatting, progress bars, and syntax highlighting. As of version 0.2.0, it is actively maintained with a relatively stable release cadence, primarily focusing on bug fixes and compatibility updates.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/nicoddemus/pytest-rich","tags":["pytest","rich","testing","cli","output","plugins"],"install":[{"cmd":"pip install pytest-rich","lang":"bash","label":"Install plugin"}],"dependencies":[{"reason":"Peer dependency; pytest-rich is a plugin for pytest.","package":"pytest","optional":false},{"reason":"Core dependency for rich terminal output.","package":"rich","optional":false}],"imports":[],"quickstart":{"code":"import pytest\nimport os\n\n# Create a dummy test file\nwith open(\"test_example.py\", \"w\") as f:\n    f.write(\n\"\"\"import pytest\n\ndef test_success():\n    assert True\n\ndef test_failure():\n    assert False\n\ndef test_error_division_by_zero():\n    1 / 0\n\n@pytest.mark.skip(reason=\"demonstrate skip\")\ndef test_skipped():\n    pass\n\ndef test_warning():\n    pytest.warn(\"This is a test warning.\")\n\n\"\"\"\n    )\n\n# Create a pyproject.toml to enable rich output\nwith open(\"pyproject.toml\", \"w\") as f:\n    f.write(\n\"\"\"[tool.pytest.ini_options]\naddopts = [\n    \"--rich\",\n    \"--rich-tracebacks\",\n    \"--rich-help\",\n    \"--strict-markers\",\n]\n\"\"\"\n    )\n\nprint(\"Created test_example.py and pyproject.toml\")\nprint(\"To run, navigate to this directory in your terminal and execute: pytest\")\n","lang":"python","description":"This quickstart demonstrates basic usage of `pytest-rich` by creating a few simple tests (success, failure, error, skipped, warning) and configuring `pytest` via `pyproject.toml` to enable rich output, tracebacks, and help messages. Run `pytest` in the terminal to see the enhanced output."},"warnings":[{"fix":"If experiencing garbled output, try disabling other output-modifying plugins (e.g., `pytest-xdist`, `pytest-html`) one by one, or run `pytest --disable-rich` to confirm `pytest-rich` is the cause. Review plugin documentation for compatibility notes.","message":"pytest-rich extensively modifies `sys.stdout` and `sys.stderr`. If other pytest plugins or custom test code also heavily manipulate terminal output, conflicts can occur, leading to malformed or incomplete rich output.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure both `pytest-rich` and `rich` are updated to recent, compatible versions (`pip install --upgrade pytest-rich rich`). Check the `pytest-rich` GitHub repository for known compatibility issues with specific `rich` versions.","message":"While `pytest-rich` specifies a minimum `rich` version, using significantly older or very bleeding-edge `rich` versions not fully tested with `pytest-rich` might lead to unexpected rendering issues or visual glitches.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install both libraries: `pip install pytest-rich rich`.","cause":"`rich` or `pytest-rich` is not installed in the Python environment currently being used by `pytest`.","error":"ModuleNotFoundError: No module named 'rich' (or 'pytest_rich')"},{"fix":"Ensure `pytest-rich` is installed in the active virtual environment. Try running `python -m pytest` instead of just `pytest` to ensure you're using the `pytest` executable associated with your current Python environment.","cause":"`pytest-rich` is not being loaded by `pytest`. This usually happens if `pytest` is running from a different virtual environment than where `pytest-rich` was installed, or the plugin isn't properly discovered.","error":"Error: unknown option: --rich"},{"fix":"Update `rich` (`pip install --upgrade rich`), try a different terminal emulator, or temporarily disable other `pytest` plugins (`pytest -p no:xdist --rich`) to identify conflicts. Check the `pytest-rich` documentation for known terminal or plugin incompatibilities.","cause":"This can be caused by terminal emulator incompatibilities, conflicting `pytest` plugins, or an outdated `rich` library version.","error":"Visual glitches or unformatted output when --rich is enabled"}]}