{"id":6199,"library":"pytest-clarity","title":"pytest-clarity","description":"pytest-clarity is a pytest plugin that provides an alternative, colourful diff output for failing assertions. Inspired by the Ward test framework, it aims to significantly improve the readability of assertion errors by showing clear, unified, coloured diffs. The current version is 1.0.1, last released in June 2021. It is a stable plugin with infrequent updates as its core functionality is well-defined and stable.","status":"active","version":"1.0.1","language":"en","source_language":"en","source_url":"https://github.com/darrenburns/pytest-clarity","tags":["pytest-plugin","testing","developer-experience","diff","assertion"],"install":[{"cmd":"pip install pytest-clarity","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"pytest-clarity is a plugin for the pytest testing framework and requires pytest to function.","package":"pytest"}],"imports":[{"note":"Users do not typically import pytest-clarity in their test files or conftest.py; its functionality is enabled via command-line flags.","symbol":"pytest-clarity","correct":"No direct import needed. pytest-clarity is a pytest plugin and is automatically discovered and loaded by pytest upon installation."}],"quickstart":{"code":"# Save this to a file, e.g., test_example.py\ndef test_dict_failure():\n    expected = {'a': 1, 'b': 2, 'c': 3}\n    actual = {'a': 1, 'b': 99, 'd': 4}\n    assert expected == actual\n\n# Run pytest with verbose output to enable pytest-clarity\n# In your terminal:\n# pytest -vv","lang":"python","description":"Install the plugin, then run your pytest tests with the `-vv` (very verbose) option. pytest-clarity will automatically enhance the output of failing assertions with colourful diffs. You can also customize diff width and symbolism."},"warnings":[{"fix":"Always run pytest with `pytest -vv` to see the colourful diffs.","message":"pytest-clarity's enhanced diff output is only activated when running pytest with the `-vv` (very verbose) flag. Without this flag, you will see the default pytest assertion output.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that complex assertion failures involving mocked objects might not get the full `pytest-clarity` treatment. Consider alternative assertion methods or simpler comparisons when dealing with mocks if clarity is critical.","message":"The plugin may not provide detailed diffs for objects compared using `unittest.mock` (e.g., `mock.MagicMock`). When comparing mocked objects, the output might revert to a less granular default.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are running pytest-clarity with Python 3.6+ (preferably a currently supported Python version like 3.8+).","message":"While PyPI metadata lists broader Python compatibility (`>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*`), the GitHub README explicitly states 'Supports Python 3.6+'. Given the last release date (June 2021) and the end-of-life for older Python versions, practical and tested support is primarily for Python 3.6 and newer. Using it with Python 2.x or very old Python 3.x versions is not recommended and unsupported.","severity":"gotcha","affected_versions":"<=1.0.1 (applies to older Python versions)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}