MatchResult

class aws_cdk.assertions.MatchResult(target)

Bases: object

The result of Match.test().

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import assertions

# target: Any

match_result = assertions.MatchResult(target)
Parameters:

target (Any) –

Methods

compose(id, inner)

Compose the results of a previous match as a subtree.

Parameters:
  • id (str) – the id of the parent tree.

  • inner (MatchResult) –

Return type:

MatchResult

finished()

Prepare the result to be analyzed.

This API must be called prior to analyzing these results.

Return type:

MatchResult

has_failed()

Does the result contain any failures.

If not, the result is a success

Return type:

bool

push(matcher, path, message)

(deprecated) DEPRECATED.

Parameters:
  • matcher (Matcher) –

  • path (Sequence[str]) –

  • message (str) –

Deprecated:

use recordFailure()

Stability:

deprecated

Return type:

MatchResult

record_capture(*, capture, value)

Record a capture against in this match result.

Parameters:
  • capture (Capture) – The instance of Capture class to which this capture is associated with.

  • value (Any) – The value that was captured.

Return type:

None

record_failure(*, matcher, message, path, cost=None)

Record a new failure into this result at a specific path.

Parameters:
  • matcher (Matcher) – The matcher that had the failure.

  • message (str) – Failure message.

  • path (Sequence[str]) – The relative path in the target where the failure occurred. If the failure occurred at root of the match tree, set the path to an empty list. If it occurs in the 5th index of an array nested within the ‘foo’ key of an object, set the path as ['/foo', '[5]'].

  • cost (Union[int, float, None]) – The cost of this particular mismatch. Default: 1

Return type:

MatchResult

render_mismatch()

Do a deep render of the match result, showing the structure mismatches in context.

Return type:

str

to_human_strings()

Render the failed match in a presentable way.

Prefer using renderMismatch over this method. It is left for backwards compatibility for test suites that expect it, but renderMismatch() will produce better output.

Return type:

List[str]

Attributes

fail_cost

The cost of the failures so far.

fail_count

The number of failures.

is_success

Whether the match is a success.

target

The target for which this result was generated.