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

Raises as a context manager: log failure when exception is not raised #84

Closed
alblasco opened this issue Jun 20, 2022 · 1 comment
Closed

Comments

@alblasco
Copy link
Contributor

Reference:

  • pytest 7.1.1
  • pytest_check 1.0.5
    In following example:
from pytest_check import raises


class CustomException(Exception):
    pass


def test_context_manager_not_raised_1():
    with raises(CustomException):
        print("Custom Exception is not raised")


def test_context_manager_not_raised_2():
    with raises(AssertionError):
        print("Assertion Exception is not raised")

I expected these tests pass both. But both fail. E.g: The first one:
image

Please let me know if my understanding is right.

@alblasco
Copy link
Contributor Author

I was looking for a way to have soft assertions, using a CustomException instead of AssertionException, but it seems this is not the intended use of raises.
Closing the issue

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

No branches or pull requests

1 participant