[New-bugs-announce] [issue34318] Convert deprecated behavior of assertRaises() etc into errors

Serhiy Storchaka report at bugs.python.org
Thu Aug 2 07:39:54 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

Currently assertRaises(), assertRaisesRegex(), assertWarns() and assertWarnsRegex() have some weird behavior.

    # always success if the callable is None
    self.assertRaises(SomeException, None)

    # keyword arguments except "msg" are ignored
    with self.assertRaises(SomeException, foobar=123):
        ...

    # always success because keyword arguments are ignored
    self.assertRaises(SomeException, callable=func)

Hardly any user code uses these "features" intentionally. More likely such examples are hidden bugs (see for example [1]). A DeprecationWarning is raised in these cases since 3.5 (issue24134), and it is time to make them errors.

[1] https://mail.python.org/pipermail/python-list/2018-July/736363.html

----------
components: Tests
messages: 322946
nosy: ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Convert deprecated behavior of assertRaises() etc into errors
type: enhancement
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34318>
_______________________________________


More information about the New-bugs-announce mailing list