Skip to content

Commit 2399793

Browse files
committed
Python: Expand contextmanager test even more
1 parent 883bd9f commit 2399793

File tree

1 file changed

+10
-0
lines changed
  • python/ql/test/experimental/dataflow/typetracking

1 file changed

+10
-0
lines changed

python/ql/test/experimental/dataflow/typetracking/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ def test_yield():
215215

216216
# see https://docs.python.org/3.11/library/contextlib.html#contextlib.contextmanager
217217
from contextlib import contextmanager
218+
import contextlib
218219

219220
@contextmanager
220221
def managed_resource():
@@ -224,3 +225,12 @@ def managed_resource():
224225
def test_context_manager():
225226
with managed_resource() as x: # $ MISSING: tracked
226227
print(x) # $ MISSING: tracked
228+
229+
@contextlib.contextmanager
230+
def managed_resource2():
231+
x = tracked # $ tracked
232+
yield x # $ tracked
233+
234+
def test_context_manager2():
235+
with managed_resource2() as x: # $ MISSING: tracked
236+
print(x) # $ MISSING: tracked

0 commit comments

Comments
 (0)