pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Let `OutcomeException` inherit from `Exception` instead of `BaseException`

Open JCZuurmond opened this issue 1 year ago • 3 comments

What's the problem this feature will solve?

This allows for the usual handling and follows the Python documentation.

Describe the solution you'd like

Replace inheritance of OutcomeException from BaseException with Exception

Alternative Solutions

I can rewrite the code to expect a BaseException, but it does not follow Pythons recommend practice of inheriting user defined exceptions from Exception

Additional context

I'm curious to learn what the motivation is for inheriting from BaseException instead of Exception.

JCZuurmond avatar Apr 22 '24 09:04 JCZuurmond

-10 on this

its a BaseException cause people like to catch `Exception without handling proper Passover for the outcomes a user is NOT supposed to catch those without re-raising

most users easily do so by accident thus breaking the intended function

RonnyPfannschmidt avatar Apr 22 '24 10:04 RonnyPfannschmidt

Hi @RonnyPfannschmidt , thank you for your answer.

If I understand correctly, usage has shown that people catch exceptions in their tests using the bare Exception?

In any case, could the docstring of the OutcomeException be updated explaining the choice for inheriting from the BaseException? The motivation is not clear for me when reading the code

JCZuurmond avatar Apr 22 '24 13:04 JCZuurmond

Added a clarifying note would be great

RonnyPfannschmidt avatar Apr 22 '24 15:04 RonnyPfannschmidt