CSV output for pytest.
Install using pip:
pip install pytest-csv
To enable the CSV report:
py.test --csv tests.csv
To customize the CSV delimiter/quoting characters:
py.test --csv tests.csv --csv-delimiter ';' --csv-quote-char '"'
To customize the columns:
py.test --csv tests.csv --csv-columns host,function,status,duration,parameters_as_columns
This is the reference of all available columns:
Column
Description
idpytest test identifier
moduletest module name
classtest class
functiontest function name
nametest name, with arguments
filetest module file
doctest function docstring
statustest status (passed, failed, error, skipped, xpassed or xfailed)
successtest status, as a boolean
durationtest duration, in seconds
duration_formattedtest duration, human readable
messageerror message, if any
markerstest markers, as a comma-separated list
markers_with_argstest markers with their arguments, as a comma-separated list
markers_as_columnstest markers, each as a separate column
markers_args_as_columnstest markers with their arguments, each as a separate column
parameterstest parameters, as a comma-separated list
parameters_as_columnstest parameters, each as a separate column
propertiesproperties recorded using
record_property, as a comma-separated listproperties_as_columnsproperties recorded using
record_property, each as a separate columnusercurrent user name
hostcurrent host (from
platformmodule)systemcurrent system name (from
platformmodule)system_releasecurrent system release info (from
platformmodule)system_versioncurrent system version info (from
platformmodule)python_implementationcurrent python implementation (from
platformmodule)python_versioncurrent python version (from
platformmodule)working_directorycurrent working directory
To add some data directly from a test function, enable properties_as_columns and use:
def test_01(record_property): record_property('my column 1', 42) record_property('my column 2', 'foo bar')To define new column types, in
conftest.py(more examples here):def pytest_csv_register_columns(columns): columns['my_simple_column'] = lambda item, report: {'my column': report.nodeid}
Please report issues here.
This software is released under the GNU General Public License v3.0, see COPYING for details.