[pytest-dev] [3.1 feature] "assert not raise exception" helper: opinions about the name

Ronny Pfannschmidt opensource at ronnypfannschmidt.de
Wed Apr 5 12:19:15 EDT 2017


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
>




More information about the pytest-dev mailing list