Python: Add syntactic support for yield in contextlib.contextmanager

This commit is contained in:
Rasmus Wriedt Larsen
2023-10-17 09:51:20 +02:00
parent 2399793c8a
commit 2bf4c32433
3 changed files with 31 additions and 4 deletions

View File

@@ -223,8 +223,8 @@ def managed_resource():
yield x # $ tracked
def test_context_manager():
with managed_resource() as x: # $ MISSING: tracked
print(x) # $ MISSING: tracked
with managed_resource() as x: # $ tracked
print(x) # $ tracked
@contextlib.contextmanager
def managed_resource2():
@@ -232,5 +232,5 @@ def managed_resource2():
yield x # $ tracked
def test_context_manager2():
with managed_resource2() as x: # $ MISSING: tracked
print(x) # $ MISSING: tracked
with managed_resource2() as x: # $ tracked
print(x) # $ tracked