Custom assertions

Writing custom assertion is as easy as extending a base matcher class
and adding two methods - matches for matching and failure_message for
the error notice:

classChain(Base):defmatches(self):expectation=self.actual(None)chain=getattr(expectation,self.expected)returnexpectationischaindeffailure_message(self):return'Expected "%s" to have chain "%s"'%(self.actual,self.expected)expect.register('chain',Chain)

After you register the new matcher, you can use it as expected:

expect(obj).to.have.chain('be')

Custom error messages

If you want to have custom failure messages, for assertion or group of
assertions, you can simply do:

fromrobberimportfailure_messagewithfailure_message('Something went wrong'):expect(1).to.eq(2)