Please provide a way to match an iterable of matchees

Bug #615108 reported by James Westby
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Wishlist
Jonathan Lange

Bug Description

Hi,

I frequently want something similar to MatchesAll, but where it applies one
Matcher to an iterable of matchees, collecting all the mismatches (or perhaps
with an option to just return the first as it is hit.)

Shortly after writing a Matcher I will find that I want to test a list of things to
check that they all match, so having a generalised way of doing that would
be great.

results = [x for x in map(matcher.match, matchees) if x is not None]
if results:
    return MismatchesAll(results)

Thanks,

James

Tags: matchers

Related branches

Revision history for this message
Robert Collins (lifeless) wrote :

Somethinh like IterableOf ?

Revision history for this message
James Westby (james-w) wrote :

Sounds about right.

In the code I wrote that prompted this I wanted to support single values
and iterables, as the class name doesn't make it obvious which is wanted.
If this could do something similar to support that, it would be great.

Thanks,

James

Revision history for this message
Jonathan Lange (jml) wrote :

Perhaps Each or EachOf.

Changed in testtools:
status: New → Triaged
importance: Undecided → Low
Jonathan Lange (jml)
tags: added: matchers
Changed in testtools:
importance: Low → Wishlist
Jonathan Lange (jml)
Changed in testtools:
status: Triaged → In Progress
assignee: nobody → Jonathan Lange (jml)
milestone: none → next
Revision history for this message
Jonathan Lange (jml) wrote :

Have called it AllMatch rather than IterableOf.

Jonathan Lange (jml)
Changed in testtools:
status: In Progress → Fix Committed
Jonathan Lange (jml)
Changed in testtools:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.