Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 35.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.0s · import 0.000s · 36MB
34MB installed
● package 34MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pytest-clarity
✓ No direct import needed. pytest-clarity is a pytest plugin and is automatically discovered and loaded by pytest upon installation.
Users do not typically import pytest-clarity in their test files or conftest.py; its functionality is enabled via command-line flags.
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.
# Save this to a file, e.g., test_example.py
def test_dict_failure():
expected = {'a': 1, 'b': 2, 'c': 3}
actual = {'a': 1, 'b': 99, 'd': 4}
assert expected == actual
# Run pytest with verbose output to enable pytest-clarity
# In your terminal:
# pytest -vv
pytest --version
Debug
Known issues
gotchapytest-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.fixAlways run pytest with `pytest -vv` to see the colourful diffs.
affects: All versions
gotchaThe 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.fixBe 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.
affects: All versions
gotchaWhile 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.fixEnsure you are running pytest-clarity with Python 3.6+ (preferably a currently supported Python version like 3.8+).
affects: <=1.0.1 (applies to older Python versions)
Upgrade
Version history
1.0.1latest on PyPI · released Jun 11, 2021
Audit
Dependencies
pytestrequiredpytest-clarity is a plugin for the pytest testing framework and requires pytest to function.