1# Copyright (c) 2008-2017 testtools developers. See LICENSE for details. 2 3"""Assertion helpers.""" 4 5from testtools.matchers import ( 6 Annotate, 7 MismatchError, 8 ) 9 10 11def assert_that(matchee, matcher, message='', verbose=False): 12 """Assert that matchee is matched by matcher. 13 14 This should only be used when you need to use a function based 15 matcher, assertThat in Testtools.Testcase is preferred and has more 16 features 17 18 :param matchee: An object to match with matcher. 19 :param matcher: An object meeting the testtools.Matcher protocol. 20 :raises MismatchError: When matcher does not match thing. 21 """ 22 matcher = Annotate.if_message(message, matcher) 23 mismatch = matcher.match(matchee) 24 if not mismatch: 25 return 26 raise MismatchError(matchee, matcher, mismatch, verbose) 27