Problem Description
Currently, the project's pytest configuration is managed primarily through pyproject.toml. While this is effective for basic settings, it lacks the flexibility to properly register custom command-line options or implement more advanced fixtures and hooks.
This was highlighted during a recent debugging session where an attempt to use a --timeout flag failed because it was not a registered option, complicating the process of diagnosing performance issues.
Proposed Solution
Establish a centralized conftest.py file in the tests/ directory to serve as the canonical location for advanced pytest configuration. This aligns with pytest best practices and provides a powerful mechanism for customizing test behavior.
This improvement will make the testing framework more robust, maintainable, and easier to debug. Key implementations would include:
- A
pytest_addoption hook to formally register useful command-line options like --timeout.
- A central location for any fixtures that are shared across multiple test files.
Alternative Solutions
- Continue using only
pyproject.toml: This is limiting. pyproject.toml is suitable for static configuration but cannot handle dynamic fixtures or programmatic hooks.
- Add
conftest.py files to subdirectories: A single top-level conftest.py in the tests/ directory is cleaner for sharing fixtures and hooks across the entire project.
Additional Context
This is a non-breaking improvement to the development and testing workflow. It will make it easier to add features like test timeouts, custom markers, and complex fixtures in the future.
Implementation Details
This is a non-breaking improvement to the development and testing workflow. It will make it easier to add features like test timeouts, custom markers, and complex fixtures in the future.
Guidelines
Problem Description
Currently, the project's
pytestconfiguration is managed primarily throughpyproject.toml. While this is effective for basic settings, it lacks the flexibility to properly register custom command-line options or implement more advanced fixtures and hooks.This was highlighted during a recent debugging session where an attempt to use a
--timeoutflag failed because it was not a registered option, complicating the process of diagnosing performance issues.Proposed Solution
Establish a centralized
conftest.pyfile in thetests/directory to serve as the canonical location for advancedpytestconfiguration. This aligns withpytestbest practices and provides a powerful mechanism for customizing test behavior.This improvement will make the testing framework more robust, maintainable, and easier to debug. Key implementations would include:
pytest_addoptionhook to formally register useful command-line options like--timeout.Alternative Solutions
pyproject.toml: This is limiting.pyproject.tomlis suitable for static configuration but cannot handle dynamic fixtures or programmatic hooks.conftest.pyfiles to subdirectories: A single top-levelconftest.pyin thetests/directory is cleaner for sharing fixtures and hooks across the entire project.Additional Context
This is a non-breaking improvement to the development and testing workflow. It will make it easier to add features like test timeouts, custom markers, and complex fixtures in the future.
Implementation Details
This is a non-breaking improvement to the development and testing workflow. It will make it easier to add features like test timeouts, custom markers, and complex fixtures in the future.
Guidelines