pytest-item-dict
Get a hierarchical dict of session.items
What it is and what it does
pytest-item-dict is a pytest plugin that transforms flat test collections into hierarchical dictionaries reflecting the directory, module, class, and function structure of your test suite. It provides two main dictionaries: collect_dict (populated after collection with test counts) and test_dict (populated during the run with outcomes, durations, and aggregated result counts). Every parent node automatically receives a @counts dict summing the outcomes of all leaf tests beneath it (passed, failed, skipped, executed, unexecuted, total) and optional @total_duration aggregates.
The plugin self-registers via the pytest11 entry point and requires no conftest changes for basic use. Access the hierarchies from any pytest hook via the plugin manager. Configuration options in pytest.ini or pyproject.toml let you control marker annotation, outcome recording, duration tracking, setup/teardown phase recording, and whether counts and durations bubble up through parent nodes. It is designed for test reporting, JSON export, and introspection of test structure and results during or after a run.
Use it for:
- Export test results as hierarchical JSON for custom reporting or CI/CD integration
- Aggregate pass/fail/skip counts at the suite, module, or class level for summary dashboards
- Track per-test and per-node execution time to identify slow test suites or bottlenecks
- Inspect test collection structure programmatically from pytest hooks to validate test organization
- Generate HTML or XML reports that preserve the hierarchical structure of your test suite
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A pytest plugin that builds hierarchical dictionaries mirroring the test collection tree, tracking test outcomes, durations, and aggregated counts across directory, module, class, and function levels.
Yes. This is a focused, low-friction pytest plugin with active maintenance, no security vulnerabilities, and a dual permissive license. Install it if you need hierarchical test result aggregation, JSON export of test structure, or programmatic access to test outcomes grouped by suite/module/class. The Python >= 3.11 requirement is the only real constraint; if your project targets older Python, it won't work.
Install
pytest-item-dict on PyPI
pip
pip install pytest-item-dictuv
uv add pytest-item-dictpoetry
poetry add pytest-item-dictInstalling pytest-item-dict
Before you install
Low friction install with a single runtime dependency on pytest. Active maintenance with a recent release; repository is not archived and receives commits.
License in practice
Dual-licensed under BSD-3-Clause and Mozilla Public License 2.0. Both are permissive open-source licenses; you may use, modify, and distribute under either license's terms.
Quickstart
pip install pytest-item-dict
# conftest.py
from pytest_item_dict.plugin import ItemDictPlugin, ITEM_DICT_PLUGIN_NAME
def pytest_collection_finish(session):
plugin = session.config.pluginmanager.get_plugin(name=ITEM_DICT_PLUGIN_NAME)
if plugin:
collect_hierarchy = plugin.collect_dict.hierarchy
Requires Python >= 3.11 and pytest >= 8.3.0
Verify before relying
- Whether the plugin's performance impact is acceptable for large test suites with thousands of tests
- Real-world usage patterns and adoption beyond the top-15000 PyPI tier
Package facts
| License | Dual License: All software and documentation is distributed under "BSD 3-Clause License" AND "Mozilla Public License Version 2.0" ================================== Copyright (c) 2024, Adam Nogowski… (full text in the JSON record) (unclear) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — pytest |
| Maintenance | actively maintained — 84 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 177,248/month — #10,217 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_item_dict-1.3.7-py3-none-any.whl
Keywords: collection, dict, hierarchical, hierarchy, items, json, outcomes, plugin, pytest, report, reporting, session.items, session, test-results, tree, xml
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytest-subtestsAdds subTest() support to pytest, allowing…
permissive · top 5,000 on PyPI
pytest-xmlA pytest plugin that generates XML output from…
unclear · top 15,000 on PyPI
pytest-durationsA pytest plugin that measures and reports…
permissive · top 5,000 on PyPI
pytest-jsonA pytest plugin that generates JSON reports of…
permissive · top 15,000 on PyPI
pytest-splitA pytest plugin that divides a test suite into…
permissive · top 5,000 on PyPI
pytest-regressionsProvides pytest fixtures for writing regression…
permissive · top 5,000 on PyPI
pytest-richA pytest plugin that uses rich to format and…
permissive · top 15,000 on PyPI
pytest-loggingA pytest plugin that configures Python logging…
permissive · top 15,000 on PyPI
pytest-seleniumpytest-selenium is a pytest plugin that…
copyleft · top 15,000 on PyPI
pytest-beartype-testsA pytest plugin that automatically applies…
permissive · top 15,000 on PyPI