Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context manager and utilities to collect/combine results of multiple assertions #34

Open
benoitbryon opened this issue Feb 14, 2014 · 1 comment

Comments

@benoitbryon
Copy link
Member

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 benoitbryon added this to the Later milestone Feb 14, 2014
@benoitbryon
Copy link
Member Author

Ideas:

  • assert_multiple() context manager automatically raises MultipleAssertionsError on exit.
  • with assert_multiple(collect_only=True) as assertions does not raise on exit but has a errors attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant