How pytest-dev/pytest works
pytest is a Python testing framework: users invoke it to discover tests, configure collection and plugins, prepare fixtures, execute tests, and inspect reports. The graph emphasizes that runtime workflow while retaining documented capabilities such as assertion introspection, unittest support, and plugins. Edges use the README or SOURCE INDEX references in the supplied excerpts; unsampled modules are included where they represent major product capabilities, but their internal wiring is not inferred.
Main entry points: pytest/__init__.py Public API · main.py Session and collection · config/__init__.py Configuration · nodes.py Collection nodes
Components 19
Entry and configuration
- Public API
src/pytest/__init__.py - Configuration
src/_pytest/config/__init__.py - CLI options
src/_pytest/config/argparsing.py
Discovery and execution
- Session and collection
src/_pytest/main.py - Python collection
src/_pytest/python.py - Collection nodes
src/_pytest/nodes.py - Fixture management
src/_pytest/fixtures.py - Test runner
src/_pytest/runner.py - Marks and selection
src/_pytest/mark/structures.py
Test support
- Assert rewriting
src/_pytest/assertion/rewrite.py - Traceback inspection
src/_pytest/_code/code.py - Doctest support
src/_pytest/doctest.py - Unittest support
src/_pytest/unittest.py - Output capture
src/_pytest/capture.py
Results and diagnostics
- Test reports
src/_pytest/reports.py - Terminal reporting
src/_pytest/terminal.py - Warning handling
src/_pytest/warnings.py - Run cache
src/_pytest/cacheprovider.py
Other components
- Test author
Connections 23
- Test author → Session and collection: runs tests
- Public API → Configuration: exports API
src/pytest/__init__.py - Configuration → CLI options: configures options
src/_pytest/config/__init__.py - Session and collection → Configuration: uses settings
src/_pytest/main.py - Session and collection → Collection nodes: collects nodes
src/_pytest/main.py - Session and collection → Test runner: runs protocol
src/_pytest/main.py - Python collection → Collection nodes: creates nodes
src/_pytest/python.py - Python collection → Fixture management: resolves fixtures
src/_pytest/python.py - Python collection → Marks and selection: uses marks
src/_pytest/python.py - Fixture management → Collection nodes: binds to nodes
src/_pytest/fixtures.py - Collection nodes → Marks and selection: exposes marks
src/_pytest/nodes.py - Session and collection → Test reports: collects reports
src/_pytest/main.py - Public API → Assert rewriting: exports assertion support
src/pytest/__init__.py - Assert rewriting → Traceback inspection: uses traceback tools
src/_pytest/assertion/rewrite.py - Public API → Doctest support: exports doctest support
src/pytest/__init__.py - Public API → Unittest support: exports unittest support
src/pytest/__init__.py - Public API → Output capture: exports capture support
src/pytest/__init__.py - Public API → Run cache: exports cache support
src/pytest/__init__.py - Configuration → Run cache: loads plugin
src/_pytest/config/__init__.py - Test reports → Terminal reporting: renders reports
- Public API → Terminal reporting: exports reporter
src/pytest/__init__.py - Configuration → Warning handling: configures filters
src/_pytest/warnings.py - Test reports → Traceback inspection: formats failures