Author rbcollins
Recipients Gregory.Salvan, Julian, eric.araujo, martin.panter, michael.foord, ncoghlan, pakal, r.david.murray, rbcollins, serhiy.storchaka
Date 2019-07-10.01:00:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1562720423.91.0.0158681917882.issue19645@roundup.psfhosted.org>
In-reply-to
Content
Ok so design wise - there is state on the TestCase that influences assertions; in potentially two ways.

The first way is formatting - the amount of detail shown in long list comparisons etc.

The second way I don't think we have at the moment, but potentially it could influence the fidelity of comparisons for NearlyEquals and the like - generally though we tend to pass those in as parameters.

So just ripping everything off into standalone functions loses the home for that state. It either becomes global (ugh), or a new object that isn't a test case but is basically the same magic object that has to be known is carried around, or we find some other way of delegating the formatting choice and controls.

hamcrest has some prior art in this space, and testtools experimented with that too. wordpress has managed to naff up the formatting on my old blog post about this https://rbtcollins.wordpress.com/2010/05/10/maintainable-pyunit-test-suites/ and https://testtools.readthedocs.io/en/latest/for-test-authors.html#matchers

Its been on my TODO for a very long time to put together a PEP for adding matchers to the stdlib; I find the full system we did in testtools very useful because it can represent everything from a trivial in-memory string error through to a disk image for a broken postgresql database, without running out of memory or generating mojibake.... but if we wanted to do something smaller that didn't prejuidice extensions like testtools still doing more that would be fine too.

The core idea of matchers is that rather than a standalone function f() -> nil/raise, you build a callable object f() -> Option(Mismatch), and a Mismatch can be shown to users, combined with other mismatches to form composites or sequences and so forth. So this would give room for the state around object formatting and the like too.
History
Date User Action Args
2019-07-10 01:00:23rbcollinssetrecipients: + rbcollins, ncoghlan, eric.araujo, pakal, r.david.murray, michael.foord, Julian, martin.panter, serhiy.storchaka, Gregory.Salvan
2019-07-10 01:00:23rbcollinssetmessageid: <1562720423.91.0.0158681917882.issue19645@roundup.psfhosted.org>
2019-07-10 01:00:23rbcollinslinkissue19645 messages
2019-07-10 01:00:23rbcollinscreate