testing#

Classes#

Functions#

conda_cli(→ collections.abc.Iterator[CondaCLIFixture])

A function scoped fixture returning CondaCLIFixture instance.

context_aware_monkeypatch(→ pytest.MonkeyPatch)

A monkeypatch fixture that resets context after each test.

path_factory(...)

A function scoped fixture returning PathFactoryFixture instance.

tmp_channel(→ collections.abc.Iterator[TmpChannelFixture])

A function scoped fixture returning TmpChannelFixture instance.

tmp_env(→ collections.abc.Iterator[TmpEnvFixture])

A function scoped fixture returning TmpEnvFixture instance.

tmp_envs_dir(→ collections.abc.Iterator[pathlib.Path])

A function scoped fixture returning a temporary environment directory.

tmp_pkgs_dir(→ collections.abc.Iterator[pathlib.Path])

A function scoped fixture returning a temporary package cache directory.

conda_ensure_sys_python_is_base_env_python()

conda_move_to_front_of_PATH()

Attributes#

on_win#
deprecated#
class CondaCLIFixture#
capsys: pytest.CaptureFixture | _pytest.capture.MultiCapture#
__call__(*argv: str | os.PathLike | pathlib.Path, raises: type[Exception] | tuple[type[Exception], Ellipsis]) tuple[str, str, pytest.ExceptionInfo]#
__call__(*argv: str | os.PathLike | pathlib.Path) tuple[str, str, int]

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

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

Parameters:
  • argv -- Arguments to parse.

  • raises -- Expected exception to intercept. If provided, the raised exception will be returned instead of exit code (see pytest.raises and pytest.ExceptionInfo).

Returns:

Command results (stdout, stderr, exit code or pytest.ExceptionInfo).

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

class TmpChannelFixture#
path_factory: PathFactoryFixture#
conda_cli: CondaCLIFixture#
__call__(*packages: str) collections.abc.Iterator[tuple[pathlib.Path, str]]#
class TmpEnvFixture#
path_factory: PathFactoryFixture | pytest.TempPathFactory#
conda_cli: CondaCLIFixture#
get_path() pathlib.Path#
__call__(*packages: str, prefix: str | os.PathLike | None = None) collections.abc.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

conda_cli(capsys: pytest.CaptureFixture) collections.abc.Iterator[CondaCLIFixture]#

A function scoped fixture returning CondaCLIFixture instance.

Use this for any commands that are local to the current test (e.g., creating a conda environment only used in the test).

context_aware_monkeypatch(monkeypatch: pytest.MonkeyPatch) pytest.MonkeyPatch#

A monkeypatch fixture that resets context after each test.

path_factory(tmp_path: pathlib.Path) collections.abc.Iterator[PathFactoryFixture]#

A function scoped fixture returning PathFactoryFixture instance.

Use this to generate any number of temporary paths for the test that are unique and do not exist yet.

tmp_channel(path_factory: PathFactoryFixture, conda_cli: CondaCLIFixture) collections.abc.Iterator[TmpChannelFixture]#

A function scoped fixture returning TmpChannelFixture instance.

tmp_env(path_factory: PathFactoryFixture, conda_cli: CondaCLIFixture) collections.abc.Iterator[TmpEnvFixture]#

A function scoped fixture returning TmpEnvFixture instance.

Use this when creating a conda environment that is local to the current test.

tmp_envs_dir(path_factory: PathFactoryFixture, mocker: pytest_mock.MockerFixture) collections.abc.Iterator[pathlib.Path]#

A function scoped fixture returning a temporary environment directory.

tmp_pkgs_dir(path_factory: PathFactoryFixture, mocker: pytest_mock.MockerFixture) collections.abc.Iterator[pathlib.Path]#

A function scoped fixture returning a temporary package cache directory.

conda_ensure_sys_python_is_base_env_python()#
conda_move_to_front_of_PATH()#