TargetSubject

TargetSubject wraps a Target object and provides method for asserting its state.

TargetSubject.new

TargetSubject.new(target, meta)

Creates a subject for asserting Targets.

Method: TargetSubject.new

Public attributes:

  • actual: The wrapped Target object.

PARAMETERS

target:

(Target) the target to check against.

meta:

(ExpectMeta) metadata about the call chain.

RETURNS

TargetSubject object

TargetSubject.runfiles

TargetSubject.runfiles()

Creates a subject asserting on the target’s default runfiles.

Method: TargetSubject.runfiles

RETURNS

RunfilesSubject object.

TargetSubject.tags

TargetSubject.tags()

Gets the target’s tags as a CollectionSubject

Method: TargetSubject.tags

RETURNS

CollectionSubject asserting the target’s tags.

TargetSubject.get_attr

TargetSubject.get_attr(name)

PARAMETERS

name:

undocumented

TargetSubject.data_runfiles

TargetSubject.data_runfiles()

Creates a subject asserting on the target’s data runfiles.

Method: TargetSubject.data_runfiles

RETURNS

RunfilesSubject object

TargetSubject.default_outputs

TargetSubject.default_outputs()

Creates a subject asserting on the target’s default outputs.

Method: TargetSubject.default_outputs

RETURNS

DepsetFileSubject object.

TargetSubject.executable

TargetSubject.executable()

Creates a subject asesrting on the target’s executable File.

Method: TargetSubject.executable

RETURNS

FileSubject object.

TargetSubject.failures

TargetSubject.failures()

Creates a subject asserting on the target’s failure message strings.

Method: TargetSubject.failures

RETURNS

CollectionSubject of str.

TargetSubject.has_provider

TargetSubject.has_provider(provider)

Asserts that the target as provider provider.

Method: TargetSubject.has_provider

PARAMETERS

provider:

The provider object to check for.

TargetSubject.label

TargetSubject.label()

Returns a LabelSubject for the target’s label value.

Method: TargetSubject.label

TargetSubject.output_group

TargetSubject.output_group(name)

Returns a DepsetFileSubject of the files in the named output group.

Method: TargetSubject.output_group

PARAMETERS

name:

(str) an output group name. If it isn’t present, an error is raised.

RETURNS

DepsetFileSubject of the named output group.

TargetSubject.provider

TargetSubject.provider(provider_key, factory=None)

Returns a subject for a provider in the target.

Method: TargetSubject.provider

PARAMETERS

provider_key:

The provider key to create a subject for

factory:

(default None) optional callable. The factory function to use to create the subject for the found provider. Required if the provider key is not an inherently supported provider. It must have the following signature: def factory(value, /, *, meta). Additional types of providers can be pre-registered by using the provider_subject_factories arg of analysis_test.

RETURNS

A subject wrapper of the provider value.

TargetSubject.action_generating

TargetSubject.action_generating(short_path)

Get the single action generating the given path.

Method: TargetSubject.action_generating

NOTE: in order to use this method, the target must have the TestingAspectInfo provider (added by the testing_aspect aspect.)

PARAMETERS

short_path:

(str) the output’s short_path to match. The value is formatted using format_str, so its template keywords can be directly passed.

RETURNS

ActionSubject for the matching action. If no action is found, or more than one action matches, then an error is raised.

TargetSubject.action_named

TargetSubject.action_named(mnemonic)

Get the single action with the matching mnemonic.

Method: TargetSubject.action_named

NOTE: in order to use this method, the target must have the [TestingAspectInfo] provider (added by the [testing_aspect] aspect.)

PARAMETERS

mnemonic:

(str) the mnemonic to match

RETURNS

ActionSubject. If no action matches, or more than one action matches, an error is raised.

TargetSubject.attr

TargetSubject.attr(name, factory=None)

Gets a subject-wrapped value for the named attribute.

Method: TargetSubject.attr

NOTE: in order to use this method, the target must have the TestingAspectInfo provider (added by the testing_aspect aspect.)

PARAMETERS

name:

(str) the attribute to get. If it’s an unsupported attribute, and no explicit factory was provided, an error will be raised.

factory:

(default None) (callable) function to create the returned subject based on the attribute value. If specified, it takes precedence over the attributes that are inherently understood. It must have the following signature: def factory(value, *, meta), where value is the value of the attribute, and meta is the call chain metadata.

RETURNS

A Subject-like object for the given attribute. The particular subject type returned depends on attribute and factory arg. If it isn’t know what type of subject to use for the attribute, an error is raised.