| 1 |
# don't remove the brackets here, it changes the meaning of the code. |
| 2 |
# even though the code will always trigger a runtime error |
| 3 |
with (name_5, name_4), name_5: |
| 4 |
pass |
| 5 |
|
| 6 |
|
| 7 |
with c, (a, b): |
| 8 |
pass |
| 9 |
|
| 10 |
|
| 11 |
with c, (a, b), d: |
| 12 |
pass |
| 13 |
|
| 14 |
|
| 15 |
with c, (a, b, e, f, g), d: |
| 16 |
pass |
| 17 |
|
| 18 |
|
| 19 |
def test_tuple_as_contextmanager(): |
| 20 |
from contextlib import nullcontext |
| 21 |
|
| 22 |
try: |
| 23 |
with (nullcontext(), nullcontext()), nullcontext(): |
| 24 |
pass |
| 25 |
except TypeError: |
| 26 |
# test passed |
| 27 |
pass |
| 28 |
else: |
| 29 |
# this should be a type error |
| 30 |
assert False |