File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
python/ql/test/experimental/dataflow/typetracking Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -195,3 +195,32 @@ def other_name(self):
195195 def with_global_modifier (self ):
196196 global some_value
197197 print (some_value ) # $ tracked
198+
199+ # ------------------------------------------------------------------------------
200+ # yield
201+ # ------------------------------------------------------------------------------
202+
203+ def yielding_function ():
204+ x = tracked # $ tracked
205+ yield x # $ tracked
206+
207+ def test_yield ():
208+ for x in yielding_function (): # $ MISSING: tracked
209+ print (x ) # $ MISSING: tracked
210+
211+ gen = yielding_function ()
212+ y = next (gen ) # $ MISSING: tracked
213+ print (y ) # $ MISSING: tracked
214+
215+
216+ # see https://docs.python.org/3.11/library/contextlib.html#contextlib.contextmanager
217+ from contextlib import contextmanager
218+
219+ @contextmanager
220+ def managed_resource ():
221+ x = tracked # $ tracked
222+ yield x # $ tracked
223+
224+ def test_context_manager ():
225+ with managed_resource () as x : # $ MISSING: tracked
226+ print (x ) # $ MISSING: tracked
You can’t perform that action at this time.
0 commit comments