Hello everyone!

Here is my 2 ,-.
What do you think about the following syntax?

with not pytest.raises():
    foo()

or

with not pytest.raises(BaseException):
    foo()

Is it possible to negate pytest.raises?
I'm not familiar with the implementation, but from user perspective it
seems more friendly to me.

Best regards,
Dmitry Dygalo

2017-04-05 18:19 GMT+02:00 Ronny Pfannschmidt <
[email protected]>:

> I just wanted to point out a quirk,
> that i stumbled upon while checking for symmetry with the python language
>
> -- Ronny
>
> On 05.04.2017 17:58, Florian Bruhin wrote:
> > On Wed, Apr 05, 2017 at 05:49:24PM +0200, Ronny Pfannschmidt wrote:
> >> i meant the except clause
> > I know, I was just pointing out that there's no valid use case for
> > pytest.raises(None) already, as None can never be raised.
> >
> > In fact, pytest.raises(None) already *does* error out, even on Python 2:
> >
> >   >>> pytest.raises(None)
> >   Traceback (most recent call last):
> >     File "<stdin>", line 1, in <module>
> >     File 
> > "/home/florian/tmp/.venv/lib/python2.7/site-packages/_pytest/python.py",
> line 1191, in raises
> >       raise TypeError(msg % type(expected_exception))
> >   TypeError: exceptions must be old-style classes or derived from
> BaseException, not <type 'NoneType'>
> >
> > You could as well argue that "except" not doing type checking is simply
> > a Python 2 bug, and the code in it will never be run anyways.
> >
> > Florian
> >
>
>
> _______________________________________________
> pytest-dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/pytest-dev
>
_______________________________________________
pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to