RunfilesSubject

RunfilesSubject.new

RunfilesSubject.new(runfiles, meta, kind=None)

Creates a “RunfilesSubject” struct.

Method: RunfilesSubject.new

PARAMETERS

runfiles:

([runfiles]) the runfiles to check against.

meta:

(ExpectMeta) the metadata about the call chain.

kind:

(default None) (optional str) what type of runfiles they are, usually “data” or “default”. If not known or not applicable, use None.

RETURNS

RunfilesSubject object.

RunfilesSubject.contains

RunfilesSubject.contains(expected)

Assert that the runfiles contains the provided path.

Method: RunfilesSubject.contains

PARAMETERS

expected:

(str) the path to check is present. This will be formatted using ExpectMeta.format_str and its current contextual keywords. Note that paths are runfiles-root relative (i.e. you likely need to include the workspace name.)

RunfilesSubject.contains_at_least

RunfilesSubject.contains_at_least(paths)

Assert that the runfiles contains at least all of the provided paths.

Method: RunfilesSubject.contains_at_least

All the paths must exist, but extra paths are allowed. Order is not checked. Multiplicity is respected.

PARAMETERS

paths:

((collection of str) | [runfiles]) the paths that must exist. If a collection of strings is provided, they will be formatted using [ExpectMeta.format_str], so its template keywords can be directly passed. If a runfiles object is passed, it is converted to a set of path strings.

RunfilesSubject.contains_predicate

RunfilesSubject.contains_predicate(matcher)

Asserts that matcher matches at least one value.

Method: RunfilesSubject.contains_predicate

PARAMETERS

matcher:

callable that takes 1 positional arg (str path) and returns boolean.

RunfilesSubject.contains_exactly

RunfilesSubject.contains_exactly(paths)

Asserts that the runfiles contains_exactly the set of paths

Method: RunfilesSubject.contains_exactly

PARAMETERS

paths:

([collection] of str) the paths to check. These will be formatted using meta.format_str, so its template keywords can be directly passed. All the paths must exist in the runfiles exactly as provided, and no extra paths may exist.

RunfilesSubject.contains_none_of

RunfilesSubject.contains_none_of(paths, require_workspace_prefix=True)

Asserts the runfiles contain none of paths.

Method: RunfilesSubject.contains_none_of

PARAMETERS

paths:

([collection] of str) the paths that should not exist. They should be runfiles root-relative paths (not workspace relative). The value is formatted using ExpectMeta.format_str and the current contextual keywords.

require_workspace_prefix:

(default True) (bool) True to check that the path includes the workspace prefix. This is to guard against accidentallly passing a workspace relative path, which will (almost) never exist, and cause the test to always pass. Specify False if the file being checked for is actually a runfiles-root relative path that isn’t under the workspace itself.

RunfilesSubject.not_contains

RunfilesSubject.not_contains(path, require_workspace_prefix=True)

Assert that the runfiles does not contain the given path.

Method: RunfilesSubject.not_contains

PARAMETERS

path:

(str) the path that should not exist. It should be a runfiles root-relative path (not workspace relative). The value is formatted using format_str, so its template keywords can be directly passed.

require_workspace_prefix:

(default True) (bool) True to check that the path includes the workspace prefix. This is to guard against accidentallly passing a workspace relative path, which will (almost) never exist, and cause the test to always pass. Specify False if the file being checked for is actually a runfiles-root relative path that isn’t under the workspace itself.

RunfilesSubject.not_contains_predicate

RunfilesSubject.not_contains_predicate(matcher)

Asserts that none of the runfiles match matcher.

Method: RunfilesSubject.not_contains_predicate

PARAMETERS

matcher:

[Matcher] that accepts a string (runfiles root-relative path).

RunfilesSubject.check_workspace_prefix

RunfilesSubject.check_workspace_prefix(path)

PARAMETERS

path:

undocumented