Public Elements

The Decorator

Module: pytest_csv_params.decorator

This module defines/publishes the main decorator.

pytest_csv_params.decorator.csv_params(data_file, base_dir=None, id_col=None, data_casts=None, dialect=CsvParamsDefaultDialect, header_renames=None)

Decorator @csv_params

For supported arguments, see add_parametrization().

Return type:

MarkDecorator

The CSV Dialect

Module: pytest_csv_params.dialect

Definition of CSV dialects (CSV file formats). At the moment, there is only the default dialect CsvParamsDefaultDialect.

class pytest_csv_params.dialect.CsvParamsDefaultDialect

This is the default dialect (or CSV file format) for parametrizing test. It is used when no other dialect is defined.

One can easily adapt it to match your own CSV files. Just use this or csv.Dialect as base class.

See csv.Dialect for configuration reference.

The Exceptions

Module: pytest_csv_params.exception

Collection of all plugin specific exceptions. All exceptions are derived from very common base types, such as FileNotFoundError, IOError or ValueError to ease the exception handling.

exception pytest_csv_params.exception.CsvHeaderNameInvalid

This exception is thrown when a CSV file contains an invalid header name that could not be replaced.

exception pytest_csv_params.exception.CsvParamsDataFileInaccessible

This exception is thrown when the CSV file is inaccessible.

exception pytest_csv_params.exception.CsvParamsDataFileInvalid

This exception is thrown when a CSV file contains invalid data.

See the exception message for more details.

exception pytest_csv_params.exception.CsvParamsDataFileNotFound

This exception is thrown when a CSV file was not found.

Plugin Code

Module: pytest_csv_params.plugin

Pytest Plugin Entrypoint: This module contains all the code to initialize the pytest plugin. This is the entrypoint configured in the pyproject.toml as pytest11.

pytest_csv_params.plugin.pytest_addoption(parser, plugin_name='csv-params')

Hook our _ptcsvp.cmdline.pytest_addoption() method to setup our command line arguments

Return type:

None

pytest_csv_params.plugin.pytest_configure(config, plugin_name='csv_params')

Hook our _ptcsvp.configure.pytest_configure() method to setup the plugin setup

Return type:

None

pytest_csv_params.plugin.pytest_unconfigure(config, plugin_name='csv_params')

Hook our _ptcsvp.configure.pytest_unconfigure() method to setup the plugin teardown

Return type:

None

Types

Module: pytest_csv_params.types

This module contains type definitions to ease the usage of the API and its documentation.

Some types are somewhat complex, and it is easier to use a single word/reference instead of a complex typing construct.

pytest_csv_params.types.BaseDir

The BaseDir describes the type of the base_dir parameter of the csv_params() decorator to search for non-absolute CSV files. It is simply an optional str.

alias of Optional[str]

pytest_csv_params.types.CsvDialect

The CsvDialect describes the type of the dialect parameter of the csv_params() decorator. It is required, but it has an default value in pytest_csv_params.dialect.CsvParamsDefaultDialect.

alias of Type[csv.Dialect]

pytest_csv_params.types.DataCast

A DataCast describes how a data casting callable must be implemented. It requires one parameter of the type str and can return anything that is required.

alias of Callable[[str], Any]

pytest_csv_params.types.DataCastDict

A DataCastDict describes how a dictionary of data casting callables must look like. The key is a str describing the column name, the value is a DataCast.

alias of Dict[str, Callable[[str], Any]]

pytest_csv_params.types.DataCasts

The DataCasts type describes the type of the data_casts parameter of the csv_params() decorator. An optional DataCastDict.

alias of Optional[Dict[str, Callable[[str], Any]]]

pytest_csv_params.types.DataFile

The DataFile describes the type if the data_file parameter of the csv_params() decorator to define the CSV file to use. It is an obligatory str.

pytest_csv_params.types.HeaderRenames

The HeaderRenames describes the type of the header_renames parameter of the csv_params() decorator. It is just an optional HeaderRenamesDict.

alias of Optional[Dict[str, str]]

pytest_csv_params.types.HeaderRenamesDict

The HeaderRenamesDict describes how a dictionary of header renames must look. Keys and values must both be of type str.

alias of Dict[str, str]

pytest_csv_params.types.IdColName

The IdColName describes the type of the id_col parameter of the csv_params() decorator to name the ID column from a CSV file. It is simply an optional str.

alias of Optional[str]