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

Florian Bruhin me at the-compiler.org
Wed Apr 5 11:58:28 EDT 2017


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

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20170405/6d69fbd9/attachment-0001.sig>


More information about the pytest-dev mailing list