testing#

Classes#

PackageCacheData

CondaCLIFixture

PathFactoryFixture

TmpEnvFixture

Functions#

reset_context([search_path, argparse_args])

main_subshell(*args[, post_parse_hook])

Entrypoint for the "subshell" invocation of CLI interface. E.g. conda create.

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.

context_aware_monkeypatch(→ pytest.MonkeyPatch)

A monkeypatch fixture that resets context after each test

tmp_pkgs_dir(→ pathlib.Path)

Attributes#

PACKAGE_CACHE_MAGIC_FILE

context

on_win

deprecated

PACKAGE_CACHE_MAGIC_FILE = 'urls.txt'#
context#
reset_context(search_path=SEARCH_PATH, argparse_args=None)#
main_subshell(*args, post_parse_hook=None, **kwargs)#

Entrypoint for the "subshell" invocation of CLI interface. E.g. conda create.

on_win#
class PackageCacheData(pkgs_dir)#
property _package_cache_records#
property is_writable#
_cache_: dict[str, PackageCacheData]#
insert(package_cache_record)#
load()#
reload()#
get(package_ref, default=NULL)#
remove(package_ref, default=NULL)#
query(package_ref_or_match_spec)#
iter_records()#
classmethod query_all(package_ref_or_match_spec, pkgs_dirs=None)#
classmethod first_writable(pkgs_dirs=None)#
classmethod writable_caches(pkgs_dirs=None)#
classmethod read_only_caches(pkgs_dirs=None)#
classmethod all_caches_writable_first(pkgs_dirs=None)#
classmethod get_all_extracted_entries()#
classmethod get_entry_to_link(package_ref)#
classmethod tarball_file_in_cache(tarball_path, md5sum=None, exclude_caches=())#
classmethod clear()#
tarball_file_in_this_cache(tarball_path, md5sum=None)#
_check_writable()#
static _clean_tarball_path_and_get_md5sum(tarball_path, md5sum=None)#
_scan_for_dist_no_channel(dist_str)#
itervalues()#
values()#
__repr__()#

Return repr(self).

_make_single_record(package_filename)#
static _dedupe_pkgs_dir_contents(pkgs_dir_contents)#
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 | 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).

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) Iterable[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.

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

A monkeypatch fixture that resets context after each test

tmp_pkgs_dir(path_factory: PathFactoryFixture, mocker: pytest_mock.MockerFixture) pathlib.Path#