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

[EASY] test_warnings: test_exec_filename() fails when run with -Werror #78093

Closed
vstinner opened this issue Jun 20, 2018 · 5 comments
Closed
Labels
3.8 only security fixes easy tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 33912
Nosy @brettcannon, @vstinner, @takluyver
PRs
  • bpo-33912: Add missing warning filter to test_exec_filename() #7839
  • 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-06-21.16:14:30.266>
    created_at = <Date 2018-06-20.09:59:24.968>
    labels = ['easy', '3.8', 'tests']
    title = '[EASY] test_warnings: test_exec_filename() fails when run with -Werror'
    updated_at = <Date 2018-06-21.16:14:30.265>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2018-06-21.16:14:30.265>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-06-21.16:14:30.266>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2018-06-20.09:59:24.968>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 33912
    keywords = ['patch', 'easy']
    message_count = 5.0
    messages = ['320044', '320046', '320050', '320194', '320195']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'vstinner', 'takluyver']
    pr_nums = ['7839']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue33912'
    versions = ['Python 3.8']

    @vstinner
    Copy link
    Member Author

    vstinner@apu$ ./python -W error -m test -v test_warnings

    ======================================================================
    ERROR: test_exec_filename (test.test_warnings.CWarnTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/vstinner/prog/python/master/Lib/test/test_warnings/__init__.py", line 450, in test_exec_filename
        exec(codeobj)
      File "<warnings-test>", line 2, in <module>
    UserWarning: hello

    ======================================================================
    ERROR: test_exec_filename (test.test_warnings.PyWarnTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/vstinner/prog/python/master/Lib/test/test_warnings/__init__.py", line 450, in test_exec_filename
        exec(codeobj)
      File "<warnings-test>", line 2, in <module>
      File "/home/vstinner/prog/python/master/Lib/warnings.py", line 318, in warn
        globals, source)
      File "/home/vstinner/prog/python/master/Lib/warnings.py", line 363, in warn_explicit
        raise message
    UserWarning: hello

    It seems to be a regression introduced by bpo-33375: commit 11a8966.

    @vstinner vstinner added 3.8 only security fixes tests Tests in the Lib/test dir easy labels Jun 20, 2018
    @vstinner
    Copy link
    Member Author

    I consider that this issue is easy, core developers/long time contriubtors: please don't fix it, but explain how to fix it and let a newcomer to fix it!
    https://mail.python.org/pipermail/python-committers/2017-June/004564.html

    @takluyver
    Copy link
    Mannequin

    takluyver mannequin commented Jun 20, 2018

    Yes, this should be easy. I misunderstood how to use the catch_warnings context manager. I thought that catch_warnings itself set up the warnings filters you need. You actually need to do that with a separate call inside the with block, as shown here:

    https://docs.python.org/3/library/warnings.html#testing-warnings

    @vstinner
    Copy link
    Member Author

    New changeset 419e88d by Victor Stinner (Christopher Frederickson) in branch 'master':
    bpo-33912: Fix test_warnings when run with -Werror (GH-7839)
    419e88d

    @vstinner
    Copy link
    Member Author

    Thank you Christopher Frederickson for your contribution! I merged your PR. I confirm that it fixes the issue.

    Thanks Thomas Kluyver for the hints ;-)

    @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 easy tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant