Python: Expand contextmanager test even more

This commit is contained in:
Rasmus Wriedt Larsen
2023-10-17 09:41:30 +02:00
parent 883bd9f3b3
commit 2399793c8a

View File

@@ -215,6 +215,7 @@ def test_yield():
# see https://docs.python.org/3.11/library/contextlib.html#contextlib.contextmanager
from contextlib import contextmanager
import contextlib
@contextmanager
def managed_resource():
@@ -224,3 +225,12 @@ def managed_resource():
def test_context_manager():
with managed_resource() as x: # $ MISSING: tracked
print(x) # $ MISSING: tracked
@contextlib.contextmanager
def managed_resource2():
x = tracked # $ tracked
yield x # $ tracked
def test_context_manager2():
with managed_resource2() as x: # $ MISSING: tracked
print(x) # $ MISSING: tracked