New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

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.

----------
components: Tests
messages: 396206
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Fix tests for "async with"
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44469>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to