Registry / testing / pytest-clarity

pytest-clarity

JSON →
library1.0.1pypypiunverified

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.

pip install pytest-clarity
INSTALL
IMPORT
SIG · PYTEST-CLARITY
P
pytest-clarity
testingpythonv1.0.1
Install
4.0s avg
Import
Disk
34MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 35.9MB
glibc
py 3.103.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.
fix
Always 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.
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.
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.
fix
Ensure 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.
Agent activity
5 hits · last 30 days
node
4
Resources
pytest-clarity — pip install pytest-clarity · libregistry