{"id":5813,"library":"pytest-csv","title":"pytest-csv","description":"pytest-csv is a pytest plugin that generates test reports in CSV format. It allows users to customize the output columns and delimiters for detailed analysis of test results. The current version is 3.0.0, released in April 2021, and it maintains an infrequent release cadence.","status":"active","version":"3.0.0","language":"en","source_language":"en","source_url":"https://github.com/nicoulaj/pytest-csv","tags":["pytest","testing","report","csv"],"install":[{"cmd":"pip install pytest-csv","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core testing framework that pytest-csv extends. Requires pytest>=6.0.0.","package":"pytest","optional":false}],"imports":[{"note":"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.","symbol":"pytest-csv plugin functionality","correct":"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`)."}],"quickstart":{"code":"import pytest\nimport os\n\ndef test_example_passed():\n    assert True\n\ndef test_example_failed():\n    assert False\n\ndef test_example_skipped():\n    pytest.skip(\"Demonstrating skip\")\n\n# To run and generate a CSV report, save this as `test_report.py`\n# then run from your terminal: `pytest --csv report.csv test_report.py`\n# Optionally, customize columns: `pytest --csv report.csv --csv-columns id,status,duration`\n","lang":"python","description":"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."},"warnings":[{"fix":"Check 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.","message":"pytest-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.","severity":"breaking","affected_versions":"pytest > 6.x, pytest-csv 3.0.0"},{"fix":"Verify the plugin name and its purpose. Use `pytest-csv` for generating reports and `pytest-csv-params` for data-driven parametrization.","message":"This 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer 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.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Place all custom column definitions within a `pytest_csv_register_columns` function in your project's `conftest.py` file.","message":"Defining 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}