truptivala / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

RFE: Allow assertions on multiple objects to behave as one. #183

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Something like:

def assert_all(*assertions):
    assertion_failed = False
    assertion_message = []

    for (actual, matcher) in assertions:
        try:
            hamcrest.assert_that(actual, matcher)
        except AssertionError as e:
            assertion_failed = True

            assertion_message.append(e.message)

    if assertion_failed:
        raise AssertionError(''.join(assertion_message))

would be great. It performs all assertions before failing so it can report on 
all violations. It also allows verifying different objects (eg ensure different 
files have different characteristics) and keeps the SUT and its matchers paired 
for better readability.

Original issue reported on code.google.com by noel....@gmail.com on 14 May 2012 at 5:22

GoogleCodeExporter commented 8 years ago
tag as Python

Original comment by t.denley on 20 May 2012 at 11:19