Registry / testing / pytest-excel

pytest-excel

JSON →
library1.8.1pypypiunverified

pytest-excel is a plugin for pytest that enables the generation of detailed Excel reports from test results. Currently at version 1.8.1, the library maintains an active development status with regular updates, including recent support for Python 3.11+.

pip install pytest-excel openpyxl
INSTALL
IMPORT
SIG · PYTEST-EXCEL
P
pytest-excel
testingpythonv1.8.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Install the plugin, then run your pytest tests from the command line, specifying the `--excelreport` option with a desired filename. The plugin automatically integrates with pytest's test discovery and execution. Use `--collect-only` to generate a report with test names and docstrings without actual execution.

# 1. Create a simple test file (e.g., test_example.py) # def test_addition(): # assert 1 + 1 == 2 # 2. Run pytest with the --excelreport option # The report will be generated as 'report.xls' or specified name. # Use %Y-%M-dT%H% for a timestamped filename. # To run all tests and generate a report: # pytest --excelreport=report.xls # To get a verbose output and generate a report: # pytest -v --excelreport=report.xls # To collect tests without execution and generate a report showing docstrings: # pytest --excelreport=report.xls --collect-only # Example with timestamped filename: pytest --excelreport=report_%Y-%m-%dT%H%M.xls
Debug
Known issues
breakingVersion 1.8.0 and above explicitly require Python 3.11 or higher. Older Python versions are no longer supported.
fix
Upgrade your Python environment to 3.11+ or pin `pytest-excel` to a version <1.8.0 if you need to support older Python.
affects: >=1.8.0
gotchaThe filename for the Excel report can be specified via the command line or a pytest configuration file. The command-line option (`--excelreport`) will override any filename set in the configuration.
fix
Be aware of configuration precedence. If your report name isn't as expected, check if a CLI argument is overriding your `pytest.ini` or `pyproject.toml` setting.
affects: All
breakingMarker handling and deprecated hook annotations have been refactored for compatibility with newer pytest versions. This may affect custom plugins or advanced usages relying on specific hook or marker behaviors.
fix
Review your `conftest.py` files and any custom plugins for deprecated `pytest` hook annotations or reliance on older marker parsing. Consult `pytest` and `pytest-excel` documentation for updated patterns.
affects: >=1.8.0
Errors
Common errors & fixes
pytest command line usage error. Exit code 5. No tests were collected.
pytest could not find any test files or functions, often due to incorrect naming conventions (e.g., test files not starting with `test_` or ending with `_test.py`, or test functions not starting with `test_`).
fix
Ensure your test files and functions follow pytest's naming conventions. For example, `test_my_module.py` containing `def test_feature():`.
No Excel report file created or report is empty.
The `--excelreport` option was not correctly used, or no tests were successfully executed/collected by pytest to populate the report. This can also happen if there are permissions issues in the output directory.
fix
Verify that you are passing the `--excelreport=your_report_name.xls` argument when running pytest. Ensure tests are collected and passing, and check file write permissions in the target directory. Use `-v` for verbose output to confirm test collection and execution.
INTERNALERROR> AttributeError: 'ExcelTestItem' object has no attribute 'funcargs'
This error can occur in advanced scenarios, particularly when dynamically collecting tests (e.g., from Excel files using custom collection hooks) and attempting to access `funcargs` on an `ExcelTestItem` within `pytest_runtest_makereport` hook, suggesting an incompatibility in the item's attributes or the way it's being handled by the `pytest-excel` plugin.
fix
This is often a conflict with custom `pytest` collection or reporting hooks. Review your `conftest.py` for custom `pytest_collect_file` or `pytest_runtest_makereport` implementations that might not be fully compatible with `pytest-excel`'s internal item structure. Simplification of custom hooks or adapting them to `pytest-excel`'s item types might be necessary. (Specific to highly customized setups).
Upgrade
Version history
1.8.1latest on PyPI · released Jul 22, 2025
Audit
Dependencies
pytestrequiredCore testing framework that pytest-excel extends.
pandasrequiredRequired for data handling within the report generation process.
openpyxlrequiredRequired for reading and writing Excel (.xlsx) files.
pythonrequiredRequires Python 3.11 and above for version 1.8.0+.
Agent activity
12 hits · last 30 days
node
12
Resources
pytest-excel — pip install pytest-excel · libregistry