that xmode skip frames Not as a doctest as pytest does not run doctests.
()
| 261 | |
| 262 | @skip_win32 |
| 263 | def test_xmode_skip(): |
| 264 | """that xmode skip frames |
| 265 | |
| 266 | Not as a doctest as pytest does not run doctests. |
| 267 | """ |
| 268 | import pexpect |
| 269 | env = os.environ.copy() |
| 270 | env["IPY_TEST_SIMPLE_PROMPT"] = "1" |
| 271 | |
| 272 | child = pexpect.spawn( |
| 273 | sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env |
| 274 | ) |
| 275 | child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE |
| 276 | |
| 277 | child.expect("IPython") |
| 278 | child.expect("\n") |
| 279 | child.expect_exact("In [1]") |
| 280 | |
| 281 | block = dedent( |
| 282 | """ |
| 283 | def f(): |
| 284 | __tracebackhide__ = True |
| 285 | g() |
| 286 | |
| 287 | def g(): |
| 288 | raise ValueError |
| 289 | |
| 290 | f() |
| 291 | """ |
| 292 | ) |
| 293 | |
| 294 | for line in block.splitlines(): |
| 295 | child.sendline(line) |
| 296 | child.expect_exact(line) |
| 297 | child.expect_exact("skipping") |
| 298 | |
| 299 | block = dedent( |
| 300 | """ |
| 301 | def f(): |
| 302 | __tracebackhide__ = True |
| 303 | g() |
| 304 | |
| 305 | def g(): |
| 306 | from IPython.core.debugger import set_trace |
| 307 | set_trace() |
| 308 | |
| 309 | f() |
| 310 | """ |
| 311 | ) |
| 312 | |
| 313 | for line in block.splitlines(): |
| 314 | child.sendline(line) |
| 315 | child.expect_exact(line) |
| 316 | |
| 317 | child.expect("ipdb>") |
| 318 | child.sendline("w") |
| 319 | child.expect("hidden") |
| 320 | child.expect("ipdb>") |