{"id":9247,"library":"pytest-excel","title":"pytest-excel","description":"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+.","status":"active","version":"1.8.1","language":"en","source_language":"en","source_url":"https://github.com/ssrikanta/pytest-excel","tags":["pytest","testing","reporting","excel","xlsx"],"install":[{"cmd":"pip install pytest-excel openpyxl","lang":"bash","label":"Install pytest-excel and required dependencies"}],"dependencies":[{"reason":"Core testing framework that pytest-excel extends.","package":"pytest"},{"reason":"Required for data handling within the report generation process.","package":"pandas","optional":false},{"reason":"Required for reading and writing Excel (.xlsx) files.","package":"openpyxl","optional":false},{"reason":"Requires Python 3.11 and above for version 1.8.0+.","package":"python","optional":false}],"imports":[],"quickstart":{"code":"# 1. Create a simple test file (e.g., test_example.py)\n# def test_addition():\n#     assert 1 + 1 == 2\n\n# 2. Run pytest with the --excelreport option\n#    The report will be generated as 'report.xls' or specified name.\n#    Use %Y-%M-dT%H% for a timestamped filename.\n\n# To run all tests and generate a report:\n# pytest --excelreport=report.xls\n\n# To get a verbose output and generate a report:\n# pytest -v --excelreport=report.xls\n\n# To collect tests without execution and generate a report showing docstrings:\n# pytest --excelreport=report.xls --collect-only\n\n# Example with timestamped filename:\npytest --excelreport=report_%Y-%m-%dT%H%M.xls","lang":"bash","description":"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."},"warnings":[{"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.","message":"Version 1.8.0 and above explicitly require Python 3.11 or higher. Older Python versions are no longer supported.","severity":"breaking","affected_versions":">=1.8.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All"},{"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.","message":"Marker 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.","severity":"breaking","affected_versions":">=1.8.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure your test files and functions follow pytest's naming conventions. For example, `test_my_module.py` containing `def test_feature():`.","cause":"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_`).","error":"pytest command line usage error. Exit code 5. No tests were collected."},{"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.","cause":"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.","error":"No Excel report file created or report is empty."},{"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).","cause":"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.","error":"INTERNALERROR> AttributeError: 'ExcelTestItem' object has no attribute 'funcargs'"}]}