-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Problem Statement
Currently, the scanner uses a hardcoded list of known pytest plugin package names (e.g., pytest_mock, pytest_asyncio, pytest_django, etc.) to identify which packages to scan for fixtures. This approach has several limitations:
- New or custom plugins are not discovered
- The list requires manual maintenance
- Some plugins may be missed if they don't follow naming conventions
Proposed Solution
Replace the hardcoded pytest plugin package names with dynamic discovery via pytest11 entry points in .dist-info/entry_points.txt. This is the standard mechanism pytest itself uses to discover plugins.
Background
The entry_points.txt file in a .dist-info directory looks like:
[pytest11]
plugin_name = package.module:optional_attr
mock = pytest_mock
asyncio = pytest_asyncio.pluginEach entry in the [pytest11] section registers a pytest plugin module that should be loaded.
Implementation Requirements
Scanner Changes (src/fixtures/scanner.rs)
-
Add
load_plugin_from_entry_point()method to:- Read
entry_points.txtfrom.dist-infodirectories - Parse the
[pytest11]section - Resolve module paths to file paths within site-packages
- Scan discovered plugin modules for fixtures
- Read
-
Modify
scan_pytest_plugins()to:- Iterate over ALL
.dist-infodirectories instead of filtering by package name - Call
load_plugin_from_entry_point()for each dist-info directory - Remove or deprecate the hardcoded
pytest_packageslist
- Iterate over ALL
Scope
This issue focuses on discovering plugins installed normally in site-packages. Editable installs (pip install -e) are out of scope and will be addressed in a follow up issue.
Expected Benefits
- Automatic discovery: Any properly registered pytest plugin will be discovered
- No maintenance: No need to update a hardcoded list when new plugins are released
- Custom plugins: User's own pytest plugins are discovered if properly packaged
Testing Requirements
Tests should verify:
- Entry point parsing and module resolution
- Fixture discovery from dynamically discovered plugins
- Handling of malformed or missing entry_points.txt files
- Packages without pytest11 entry points are not scanned