Wrappers

In order to get going with the toolbox easily, it is important to be able to use your existing matchers with it. To that end, we have created a wrapper that turns your existing matchers to plugins.

MatcherPluginWrapper

class pyhamcrest_toolbox.wrapper_base.MatcherPluginWrapper(*args, **kwargs)[source]

This class allows turning good old matchers into matcher plugins that can be used in MulticomponentMatchers.

matcher_class

MatcherPluginWrapper.matcher_class = <class 'hamcrest.core.core.isequal.IsEqual'>

Set this variable to the class of the matcher you want to wrap. If you don’t, it IsEqual will be used (which is returned by the equal_to) function. Note, that you have to specify a class, not a function.

description_prefix

MatcherPluginWrapper.description_prefix = ''

The prefix that will be added to the description of the wrapped matcher

mismatch_description_prefix

MatcherPluginWrapper.mismatch_description_prefix = ''

The prefix to be added to the mismatch_description

convert_item

MatcherPluginWrapper.convert_item(item)[source]

Convert the item that the MulticomponentMatcher deals with into the item that your component plugin is responsible for.

The multicomponent matcher will pass the item that it has received, and it is up to your matcher plugin to get the object that it works with from that object. By default, returns the item itself.