testing
#
Classes#
Extensible JSON <https://json.org> encoder for Python data structures. |
|
Functions#
|
|
|
Entrypoint for the "subshell" invocation of CLI interface. E.g. conda create. |
|
|
|
Fixture returning CondaCLIFixture instance. |
|
Fixture returning PathFactoryFixture instance. |
|
Fixture returning TmpEnvFixture instance. |
|
Fixture returning TmpChannelFixture instance. |
|
A monkeypatch fixture that resets context after each test |
|
|
|
Attributes#
- class EntityEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)#
Bases:
json.JSONEncoder
Extensible JSON <https://json.org> encoder for Python data structures.
Supports the following objects and types by default:
Python
JSON
dict
object
list, tuple
array
str
string
int, float
number
True
true
False
false
None
null
To extend this to recognize other objects, subclass and implement a
.default()
method with another method that returns a serializable object foro
if possible, otherwise it should call the superclass implementation (to raiseTypeError
).- default(obj)#
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- 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#
- path_to_url(path)#
- 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#
- exception CondaExitZero(message, caused_by=None, **kwargs)#
Bases:
CondaError
Common base class for all non-exit exceptions.
- return_code = 0#
- class PackageRecord(*args, **kwargs)#
Bases:
conda.auxlib.entity.DictSafeMixin
,conda.auxlib.entity.Entity
- property schannel#
- property _pkey#
- property is_unmanageable#
- property combined_depends#
- property namekey#
- name#
- version#
- build#
- build_number#
- channel#
- subdir#
- fn#
- md5#
- legacy_bz2_md5#
- legacy_bz2_size#
- url#
- sha256#
- arch#
- platform#
- depends#
- constrains#
- track_features#
- features#
- noarch#
- preferred_env#
- license#
- license_family#
- package_type#
- timestamp#
- date#
- size#
- __hash__()#
Return hash(self).
- __eq__(other)#
Return self==value.
- dist_str()#
- dist_fields_dump()#
- __str__()#
Return str(self).
- to_match_spec()#
- to_simple_match_spec()#
- record_id()#
- conda_ensure_sys_python_is_base_env_python()#
- conda_move_to_front_of_PATH()#
- 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) Iterator[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) Iterator[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) Iterator[TmpEnvFixture] #
Fixture returning TmpEnvFixture instance.
- class TmpChannelFixture#
- path_factory: PathFactoryFixture#
- conda_cli: CondaCLIFixture#
- __call__(*packages: str) Iterator[tuple[pathlib.Path, str]] #
- tmp_channel(path_factory: PathFactoryFixture, conda_cli: CondaCLIFixture) Iterator[TmpChannelFixture] #
Fixture returning TmpChannelFixture 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) Iterator[pathlib.Path] #
- tmp_envs_dir(path_factory: PathFactoryFixture, mocker: pytest_mock.MockerFixture) Iterator[pathlib.Path] #