| 228 | |
| 229 | |
| 230 | def test_tracing(): |
| 231 | import sys |
| 232 | |
| 233 | def method(): |
| 234 | a = [1, 2, 3, 4, 5, 6] # line 1 |
| 235 | |
| 236 | # line 3 |
| 237 | def b(): # line 4 |
| 238 | yield from [j for j in a if j % 2 == 0] # line 5 |
| 239 | |
| 240 | # line 7 |
| 241 | for j in b(): # line 8 |
| 242 | print(j) # line 9 |
| 243 | |
| 244 | def tracefunc(frame, event, arg): |
| 245 | if "test_sys_monitoring.py" in frame.f_code.co_filename: |
| 246 | print(frame.f_code.co_name, event, frame.f_lineno - frame.f_code.co_firstlineno) |
| 247 | return tracefunc |
| 248 | |
| 249 | sys.settrace(tracefunc) |
| 250 | method() |
| 251 | sys.settrace(None) |
| 252 | |
| 253 | |
| 254 | def test_lines_with_yield(with_monitoring): |