Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pytest-csv plugin functionality
✓ Functionality is typically invoked via command-line options (e.g., `pytest --csv output.csv`) or by defining pytest hooks in `conftest.py` (e.g., `pytest_csv_register_columns`).
pytest-csv operates as a plugin and does not expose Python symbols for direct import into test files or application code. Interaction is primarily through pytest's command-line interface or its hook system.
Create a Python file with some pytest tests. Then, run pytest from the command line, specifying the `--csv` option followed by the desired output filename. The plugin will automatically generate a CSV report with test results.
import pytest
import os
def test_example_passed():
assert True
def test_example_failed():
assert False
def test_example_skipped():
pytest.skip("Demonstrating skip")
# To run and generate a CSV report, save this as `test_report.py`
# then run from your terminal: `pytest --csv report.csv test_report.py`
# Optionally, customize columns: `pytest --csv report.csv --csv-columns id,status,duration`
Debug
Known issues
breakingpytest-csv 3.0.0 was released when pytest 6.x was current. Subsequent major versions of pytest (7.x, 8.x, 9.x) have introduced breaking changes to internal plugin APIs, particularly around collection and reporting hooks. pytest-csv may not be fully compatible with newer pytest versions without updates.fixCheck the pytest-csv GitHub repository for any compatibility updates or issues when using with recent pytest versions. Consider pinning your `pytest` dependency to `pytest<7` if encountering unexpected behavior.
affects: pytest > 6.x, pytest-csv 3.0.0
gotchaThis plugin generates CSV *reports*. It is often confused with `pytest-csv-params`, a different plugin used for *parametrizing* tests from data in CSV files. Ensure you are using the correct plugin for your desired functionality.fixVerify the plugin name and its purpose. Use `pytest-csv` for generating reports and `pytest-csv-params` for data-driven parametrization.
affects: All versions
gotchaWhen customizing CSV columns using `--csv-columns`, providing unrecognized or improperly formatted column names can lead to `KeyError` exceptions or incomplete reports. Special characters or non-standard column definitions might not be handled gracefully.fixRefer to the official documentation for a list of supported column identifiers. If defining custom columns via `pytest_csv_register_columns` hook in `conftest.py`, ensure the implementation is robust and handles all expected scenarios for test items and reports.
affects: All versions
gotchaDefining custom columns with `pytest_csv_register_columns` must be done in your `conftest.py` file. Attempting to define or import custom column logic directly within test files will not be recognized by the plugin's hook system.fixPlace all custom column definitions within a `pytest_csv_register_columns` function in your project's `conftest.py` file.
affects: All versions
Upgrade
Version history
3.0.0latest on PyPI · released Apr 22, 2021
Audit
Dependencies
pytestrequiredCore testing framework that pytest-csv extends. Requires pytest>=6.0.0.