Matcher

class aws_cdk.assertions.Matcher

Bases: object

Represents a matcher that can perform special data matching capabilities between a given pattern and a target.

ExampleMetadata:

infused

Example:

# Given a template -
# {
#   "Resources": {
#     "MyBar": {
#       "Type": "Foo::Bar",
#       "Properties": {
#         "Fred": ["Flob", "Cat"]
#       }
#     }
#   }
# }

# The following will NOT throw an assertion error
template.has_resource_properties("Foo::Bar", {
    "Fred": Match.array_with(["Flob"])
})

# The following will throw an assertion error
template.has_resource_properties("Foo::Bar", Match.object_like({
    "Fred": Match.array_with(["Wobble"])
}))

Methods

abstract test(actual)

Test whether a target matches the provided pattern.

Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.

Parameters:

actual (Any) – the target to match.

Return type:

MatchResult

Returns:

the list of match failures. An empty array denotes a successful match.

Attributes

name

A name for the matcher.

This is collected as part of the result and may be presented to the user.

Static Methods

classmethod is_matcher(x)

Check whether the provided object is a subtype of the IMatcher.

Parameters:

x (Any) –

Return type:

bool