Context manager and utilities to collect/combine results of multiple assertions
Opened this issue · 1 comments
benoitbryon commented
In order to replace things like:
@hospital.healthcheck
def test_multiple():
errors = []
for domain in 'example.com', 'www.example.com':
try:
hospital.assert_ping(domain)
except AssertionError, e:
errors.append(e)
if errors:
raise AssertionError('\n'.join(errors))
With something like:
@hospital.healthcheck
def test_multiple():
with hospital.multiple_assertions:
for domain in 'example.com', 'www.example.com':
hospital.assert_ping(domain)
benoitbryon commented
Ideas:
assert_multiple()
context manager automatically raisesMultipleAssertionsError
on exit.with assert_multiple(collect_only=True) as assertions
does not raise on exit but has aerrors
attribute.