Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert deprecated behavior of assertRaises() etc into errors #78499

Closed
serhiy-storchaka opened this issue Aug 2, 2018 · 2 comments
Closed
Labels
3.8 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 34318
Nosy @rbtcollins, @ezio-melotti, @voidspace, @serhiy-storchaka
PRs
  • bpo-34318: Convert deprecation warnings to errors in assertRaises() etc. #8623
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-08-19.07:49:21.709>
    created_at = <Date 2018-08-02.11:39:54.574>
    labels = ['tests', '3.8', 'type-feature', 'library']
    title = 'Convert deprecated behavior of assertRaises() etc into errors'
    updated_at = <Date 2018-08-19.07:49:21.708>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-08-19.07:49:21.708>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-08-19.07:49:21.709>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2018-08-02.11:39:54.574>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34318
    keywords = ['patch']
    message_count = 2.0
    messages = ['322946', '323745']
    nosy_count = 4.0
    nosy_names = ['rbcollins', 'ezio.melotti', 'michael.foord', 'serhiy.storchaka']
    pr_nums = ['8623']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue34318'
    versions = ['Python 3.8']

    @serhiy-storchaka
    Copy link
    Member Author

    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 (bpo-24134), and it is time to make them errors.

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

    @serhiy-storchaka serhiy-storchaka added 3.8 only security fixes tests Tests in the Lib/test dir type-feature A feature request or enhancement stdlib Python modules in the Lib dir labels Aug 2, 2018
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 77d5781 by Serhiy Storchaka in branch 'master':
    bpo-34318: Convert deprecation warnings to errors in assertRaises() etc. (GH-8623)
    77d5781

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant