classification
Title: Fix tests for "async with"
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2021-06-21 05:38 by serhiy.storchaka, last changed 2021-06-21 07:58 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 26817 merged serhiy.storchaka, 2021-06-21 05:43
PR 26818 merged miss-islington, 2021-06-21 07:22
PR 26819 merged miss-islington, 2021-06-21 07:22
Messages (4)
msg396206 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-06-21 05:38
In Lib/test/test_coroutines.py some tests test that the body of the "asyn with" statement with bad context manager was not executed by setting a value of a variable in the body and checking its value after executing.

        body_executed = False
        async def foo():
            async with CM():
                body_executed = True

        with self.assertRaisesRegex(AttributeError, '__aexit__'):
            run_async(foo())
        self.assertFalse(body_executed)

The problem is that it sets the value of local variable of the inner function, and does not affect the outer variable. The test would pass even if the body was executed.
msg396208 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-06-21 07:22
New changeset 5d2b3a0d688cf8a33db3d266c9e7049c13766a4c by Serhiy Storchaka in branch 'main':
bpo-44469: Fix tests for "async with" with bad object (GH-26817)
https://github.com/python/cpython/commit/5d2b3a0d688cf8a33db3d266c9e7049c13766a4c
msg396210 - (view) Author: miss-islington (miss-islington) Date: 2021-06-21 07:54
New changeset 175e264d363164c905b08688bbda751c9ff26342 by Miss Islington (bot) in branch '3.9':
bpo-44469: Fix tests for "async with" with bad object (GH-26817)
https://github.com/python/cpython/commit/175e264d363164c905b08688bbda751c9ff26342
msg396211 - (view) Author: miss-islington (miss-islington) Date: 2021-06-21 07:57
New changeset 553e10498ac2020e9abdb5302c91bfb235925cef by Miss Islington (bot) in branch '3.10':
bpo-44469: Fix tests for "async with" with bad object (GH-26817)
https://github.com/python/cpython/commit/553e10498ac2020e9abdb5302c91bfb235925cef
History
Date User Action Args
2021-06-21 07:58:34serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-06-21 07:57:11miss-islingtonsetmessages: + msg396211
2021-06-21 07:54:11miss-islingtonsetmessages: + msg396210
2021-06-21 07:22:20miss-islingtonsetpull_requests: + pull_request25400
2021-06-21 07:22:15miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request25399
2021-06-21 07:22:07serhiy.storchakasetmessages: + msg396208
2021-06-21 05:43:11serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request25398
2021-06-21 05:38:29serhiy.storchakacreate