'Fail unless the specified string matches the expected.
Fail the test unless ``want`` matches ``got``, as
determined by a ``doctest.OutputChecker`` instance. This
is not an equality check, but a pattern match according to
the ``OutputChecker`` rules.'

def failUnlessOutputCheckerMatch(self, want, got, msg=None):

    checker = doctest.OutputChecker()
    want = textwrap.dedent(want)
    source = ''
    example = doctest.Example(source, want)
    got = textwrap.dedent(got)
    checker_optionflags = reduce(operator.or_, [doctest.ELLIPSIS])
    if (not checker.check_output(want, got, checker_optionflags)):
        if (msg is None):
            diff = checker.output_difference(example, got, checker_optionflags)
            msg = ('\n'.join(['Output    received    did    not    match    expected    output', '%(diff)s']) % vars())
        raise self.failureException(msg)
