pytest_copie.plugin

A pytest plugin to build copier project from a template.

Module Contents

Classes

Copie

Class to provide convenient access to the copier API.

Result

Holds the captured result of the copier project generation.

Functions

copie(request, tmp_path, _copier_config_file)

Yield an instance of the Copie helper class.

pytest_addoption(parser)

Add option to the pytest command.

pytest_configure(config)

Force the template path to be absolute to protect ourselves from fixtures that changes path.

class pytest_copie.plugin.Copie[source]

Class to provide convenient access to the copier API.

config_file : pathlib.Path[source]

The path to the copier config file.

counter : int = 0[source]

A counter to keep track of the number of projects created.

default_template_dir : pathlib.Path[source]

The path to the default template to use to create the project.

test_dir : pathlib.Path[source]

The directory where the project will be created.

copy(extra_answers={}, template_dir=None)[source]

Create a copier Project from the template and return the associated Result object.

Parameters:
extra_answers : dict

extra answers to pass to the Copie object and overwrite the default ones

template_dir : Optional[pathlib.Path]

the path to the template to use to create the project instead of the default “.”.

Returns:

the result of the copier project generation

Return type:

Result

class pytest_copie.plugin.Result[source]

Holds the captured result of the copier project generation.

answers : dict[source]

The answers used to generate the project.

exception : Exception | SystemExit | None[source]

The exception raised during the copier project generation.

exit_code : str | int | None = 0[source]

The exit code of the copier project generation.

project_dir : pathlib.Path | None[source]

The path to the generated project.

pytest_copie.plugin.copie(request, tmp_path, _copier_config_file)[source]

Yield an instance of the Copie helper class.

The class can then be used to generate a project from a template.

Parameters:
request

the pytest request object

tmp_path : pathlib.Path

the temporary directory

_copier_config_file : pathlib.Path

the temporary copier config file

Returns:

the object instance, ready to copy !

Return type:

Generator

pytest_copie.plugin.pytest_addoption(parser)[source]

Add option to the pytest command.

pytest_copie.plugin.pytest_configure(config)[source]

Force the template path to be absolute to protect ourselves from fixtures that changes path.