This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Convert deprecated behavior of assertRaises() etc into errors
Type: enhancement Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-08-02 11:39 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8623 merged serhiy.storchaka, 2018-08-02 11:48
Messages (2)
msg322946 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-02 11:39
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.

msg323745 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-19 07:00
New changeset 77d5781835b6e0a132694ebadc22b1cbdb9913f8 by Serhiy Storchaka in branch 'master':
bpo-34318: Convert deprecation warnings to errors in assertRaises() etc. (GH-8623)
Date User Action Args
2022-04-11 14:59:04adminsetgithub: 78499
2018-08-19 07:49:21serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-08-19 07:00:15serhiy.storchakasetmessages: + msg323745
2018-08-02 11:48:50serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request8128
2018-08-02 11:40:18serhiy.storchakasetcomponents: + Library (Lib)
2018-08-02 11:39:54serhiy.storchakacreate