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

test_asyncio: test_debug_mode_interop() fails using -Werror #81504

Closed
vstinner opened this issue Jun 17, 2019 · 6 comments
Closed

test_asyncio: test_debug_mode_interop() fails using -Werror #81504

vstinner opened this issue Jun 17, 2019 · 6 comments
Labels
3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir topic-asyncio

Comments

@vstinner
Copy link
Member

BPO 37323
Nosy @vstinner, @asvetlov, @1st1, @miss-islington, @tirkarthi
PRs
  • bpo-37323: Suppress DeprecationWarning raised by @asyncio.coroutine #14293
  • [3.8] bpo-37323: Suppress DeprecationWarning raised by @asyncio.coroutine (GH-14293) #14305
  • 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 2019-06-22.11:16:48.992>
    created_at = <Date 2019-06-17.20:37:03.960>
    labels = ['3.8', 'tests', '3.9', 'expert-asyncio']
    title = 'test_asyncio: test_debug_mode_interop() fails using -Werror'
    updated_at = <Date 2019-06-22.11:16:48.992>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-06-22.11:16:48.992>
    actor = 'asvetlov'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-06-22.11:16:48.992>
    closer = 'asvetlov'
    components = ['Tests', 'asyncio']
    creation = <Date 2019-06-17.20:37:03.960>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37323
    keywords = ['patch']
    message_count = 6.0
    messages = ['345904', '345907', '345913', '345997', '346274', '346275']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'asvetlov', 'yselivanov', 'miss-islington', 'xtreak']
    pr_nums = ['14293', '14305']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37323'
    versions = ['Python 3.8', 'Python 3.9']

    @vstinner
    Copy link
    Member Author

    vstinner@apu$ PYTHONWARNINGS=error ./python -Werror -m test -v test_asyncio -m test_debug_mode_interop
    == CPython 3.9.0a0 (heads/master-dirty:00f6493084, Jun 17 2019, 21:50:32) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
    == Linux-5.1.6-300.fc30.x86_64-x86_64-with-glibc2.29 little-endian
    == cwd: /home/vstinner/prog/python/master/build/test_python_23510
    == CPU count: 8
    == encodings: locale=UTF-8, FS=utf-8
    Run tests sequentially
    0:00:00 load avg: 0.73 [1/1] test_asyncio
    test_debug_mode_interop (test.test_asyncio.test_tasks.CompatibilityTests) ... FAIL

    ======================================================================
    FAIL: test_debug_mode_interop (test.test_asyncio.test_tasks.CompatibilityTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/home/vstinner/prog/python/master/Lib/test/test_asyncio/test_tasks.py", line 3355, in test_debug_mode_interop
        assert_python_ok("-c", code, PYTHONASYNCIODEBUG="1")
      File "/home/vstinner/prog/python/master/Lib/test/support/script_helper.py", line 157, in assert_python_ok
        return _assert_python(True, *args, **env_vars)
      File "/home/vstinner/prog/python/master/Lib/test/support/script_helper.py", line 143, in _assert_python
        res.fail(cmd_line)
      File "/home/vstinner/prog/python/master/Lib/test/support/script_helper.py", line 70, in fail
        raise AssertionError("Process return code is %d\n"
    AssertionError: Process return code is 1
    command line: ['/home/vstinner/prog/python/master/python', '-X', 'faulthandler', '-c', '\nimport asyncio\n\nasync def native_coro():\n    pass\n\n@asyncio.coroutine\ndef old_style_coro():\n    yield from native_coro()\n\nasyncio.run(old_style_coro())\n']

    stdout:
    ---

    ---

    stderr:
    ---

    Traceback (most recent call last):
      File "<string>", line 8, in <module>
      File "/home/vstinner/prog/python/master/Lib/asyncio/coroutines.py", line 111, in coroutine
        warnings.warn('"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead',
    DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    ---
    
    

    Ran 1 test in 0.210s

    FAILED (failures=1)
    test test_asyncio failed
    test_asyncio failed

    == Tests result: FAILURE ==

    1 test failed:
    test_asyncio

    Total duration: 598 ms
    Tests result: FAILURE

    @vstinner vstinner added 3.9 only security fixes tests Tests in the Lib/test dir labels Jun 17, 2019
    @vstinner
    Copy link
    Member Author

    def test_debug_mode_interop(self):
            # https://bugs.python.org/issue32636
            code = textwrap.dedent("""
                import asyncio
    
                async def native_coro():
                    pass
    
                @asyncio.coroutine
                def old_style_coro():
                    yield from native_coro()
    
                asyncio.run(old_style_coro())
            """)
            assert_python_ok("-c", code, PYTHONASYNCIODEBUG="1")

    @tirkarthi
    Copy link
    Member

    It affects 3.8 as well since #13346 was merged and I guess the fix would be to wrap it with assertWarns(DeprecationWarning) context manager like other tests. Interesting, does PYTHONWARNINGS=error affects the interpreter spawn by assert_python_ok to change warnings level which -Werror doesn't do by itself?

    @tirkarthi tirkarthi added topic-asyncio 3.8 only security fixes labels Jun 17, 2019
    @tirkarthi
    Copy link
    Member

    Sorry, I was wrong PYTHONWARNINGS environment variable is still passed to subprocess created by assert_python_ok so using assertWarns doesn't suppress it. Perhaps the DeprecationWarning could be ignored in assert_python_ok like below with -W :

    diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
    index 22a49077d5..d5f44b8091 100644
    --- a/Lib/test/test_asyncio/test_tasks.py
    +++ b/Lib/test/test_asyncio/test_tasks.py
    @@ -3352,7 +3352,9 @@ class CompatibilityTests(test_utils.TestCase):

                 asyncio.run(old_style_coro())
             """)
    -        assert_python_ok("-c", code, PYTHONASYNCIODEBUG="1")
    +
    +        assert_python_ok("-Wignore::DeprecationWarning", "-c", code,
    +                         PYTHONASYNCIODEBUG="1")
     if __name__ == '__main__':

    @miss-islington
    Copy link
    Contributor

    New changeset 186f709 by Miss Islington (bot) (Xtreak) in branch 'master':
    bpo-37323: Suppress DeprecationWarning raised by @asyncio.coroutine (GH-14293)
    186f709

    @miss-islington
    Copy link
    Contributor

    New changeset 9b32b44 by Miss Islington (bot) in branch '3.8':
    bpo-37323: Suppress DeprecationWarning raised by @asyncio.coroutine (GH-14293)
    9b32b44

    @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 3.9 only security fixes tests Tests in the Lib/test dir topic-asyncio
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants