← Back to team overview

testtools-dev team mailing list archive

Re: [Bug 704219] Re: wish for invertible matchers

 

One idea on this:

Perhaps what I want is assertThat() to be a HOF that takes an
expression and evaluates it.  If it evaluates to False, it will
display as much information is as is possible/useful about the
expression and its evaluation, so that we can understand the failure
without having to reproduce it or break into it with a debugger.

The problem with a crude Not that is simply given the evaluated value
of the inner expression is that it cannot say anything more about that
expression if it fails.  However, if we instead printed the inner
expression including the variable bindings, then it would probably be
clear why there was a problem.

-- 
You received this bug notification because you are a member of testtools
developers, which is subscribed to testtools.
https://bugs.launchpad.net/bugs/704219

Title:
  wish for invertible matchers

Status in testtools:
  Triaged

Bug description:
  I can define ContainsRegexp(r'\d+') and match against it, and then
  also say Not(ContainsRegexp(r'\d+')) and this works. However, in the
  latter case, what I'd really like to get is something like

    "unexpectedly matched '\\d+' in 'route66' at '66'"

  rather than just being told the matcher passed successfully.

  I can just define NotContainsRegexp that has the same behavior but
  gives better mismatches.  But I wonder if this should fall out in a
  cleaner way.





References