Please allow Mismatches to add detail to the result
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testtools |
Fix Released
|
Wishlist
|
James Westby |
Bug Description
Hi,
addDetail is great!
Matchers are great!
If only I could use them together without extra code!
My proposal
class Mismatch(object):
details = []
def assertThat(matchee, matcher):
match = matcher.
if match is not None:
if getattr(match, details, None) is not None:
See what I mean?
That way as an author of a library of Matchers I can provide useful
detail to users without having to put it in to the result of describe().
In particular when a problem is found within a HTML page I want to provide
the user with a compact error message, but still provide them the source of
the page for investigation if they like.
Thanks,
James
P.S. does testr have a nice way to view attachments from the last run?
Changed in testtools: | |
status: | Triaged → In Progress |
assignee: | nobody → James Westby (james-w) |
Changed in testtools: | |
status: | In Progress → Fix Released |
milestone: | none → next |
Regarding the PS: testr failing will show all the attachments for failures, its the default serialisation to show everything.
The proposal is broadly ok. A few tweaks:
- a method please, not an attribute (allows lazy generation more obviously)
- no need to guard against old Mismatch objects, change the base class, this is marked experimental in our docs.
- perhaps a dict rather than tuples ?
- also, given the TestCase may already have the names used, it will need to append -1 -2 etc to names that are already used. Or something like that.
+1 on the overall concept though - I likes.