testing#

Classes#

CondaCLIFixture

PathFactoryFixture

TmpEnvFixture

Functions#

reset_context([search_path, argparse_args])

init_loggers()

encode_for_env_var(→ str)

Environment names and values need to be string.

conda_ensure_sys_python_is_base_env_python()

conda_move_to_front_of_PATH()

conda_check_versions_aligned()

conda_cli(→ CondaCLIFixture)

Fixture returning CondaCLIFixture instance.

path_factory(→ PathFactoryFixture)

Fixture returning PathFactoryFixture instance.

tmp_env(→ TmpEnvFixture)

Fixture returning TmpEnvFixture instance.

Attributes#

context

on_win

deprecated

context#
reset_context(search_path=SEARCH_PATH, argparse_args=None)#
init_loggers()#
on_win#
deprecated#
encode_for_env_var(value) str#

Environment names and values need to be string.

conda_ensure_sys_python_is_base_env_python()#
conda_move_to_front_of_PATH()#
conda_check_versions_aligned()#
class CondaCLIFixture#
capsys: pytest.CaptureFixture#
__call__(*argv: str) tuple[str, str, int]#

Test conda CLI. Mimic what is done in conda.cli.main.main.

conda ... == conda_cli(...)

Parameters:

argv -- Arguments to parse

Returns:

Command results

Return type:

tuple[stdout, stdout, exitcode]

conda_cli(capsys: pytest.CaptureFixture) CondaCLIFixture#

Fixture returning CondaCLIFixture instance.

class PathFactoryFixture#
tmp_path: pathlib.Path#
__call__(name: str | None = None, prefix: str | None = None, suffix: str | None = None) pathlib.Path#

Unique, non-existent path factory.

Extends pytest's tmp_path fixture with a new unique, non-existent path for usage in cases where we need a temporary path that doesn't exist yet.

Parameters:
  • name -- Path name to append to tmp_path

  • prefix -- Prefix to prepend to unique name generated

  • suffix -- Suffix to append to unique name generated

Returns:

A new unique path

path_factory(tmp_path: pathlib.Path) PathFactoryFixture#

Fixture returning PathFactoryFixture instance.

class TmpEnvFixture#
path_factory: PathFactoryFixture#
conda_cli: CondaCLIFixture#
__call__(*packages: str, prefix: str | os.PathLike | None = None) Iterator[pathlib.Path]#

Generate a conda environment with the provided packages.

Parameters:
  • packages -- The packages to install into environment

  • prefix -- The prefix at which to install the conda environment

Returns:

The conda environment's prefix

tmp_env(path_factory: PathFactoryFixture, conda_cli: CondaCLIFixture) TmpEnvFixture#

Fixture returning TmpEnvFixture instance.