Hi Rob, On Sat, Nov 30, 2013 at 10:38:31PM +1300, Robert Collins wrote:
Have you seen Matchers? Inspired by hamcrest, these also move assertions out of unittest.TestCase, but are much more composable than assertions, and can give significantly richer errors.
http://testtools.readthedocs.org/en/latest/for-test-authors.html#matchers
I hadn't given it a proper look. Very cool! This looks like a much more adaptable solution than mine.
There is an open ticket in the Python bug tracker for getting something like this into the stdlib. I've been meaning to port them and get a review up for a bit :(.
Great! Two things that (at a glance) testtools is missing are diffs to describe mis-matches and support for the existing attributes (longMessage, maxDiff, failureException, _diffThreshold) that unittest.TestCase uses to manage output (though, obviously, at least two of these are diff-related). Are there any thoughts as to how to address this? Is there anything I can do to help push matchers in to the stdlib? Cheers, Dan