MCPcopy Index your code
hub / github.com/ipython/ipython / test_decorator_skip_with_breakpoint

Function test_decorator_skip_with_breakpoint

tests/test_debugger.py:534–603  ·  view source on GitHub ↗

test that decorator frame skipping can be disabled

()

Source from the content-addressed store, hash-verified

532@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="issues on PyPy")
533@skip_win32
534def test_decorator_skip_with_breakpoint():
535 """test that decorator frame skipping can be disabled"""
536
537 import pexpect
538
539 env = os.environ.copy()
540 env["IPY_TEST_SIMPLE_PROMPT"] = "1"
541 env["PROMPT_TOOLKIT_NO_CPR"] = "1"
542
543 child = pexpect.spawn(
544 sys.executable, ["-m", "IPython", "--colors=nocolor"], env=env
545 )
546 child.timeout = 15 * IPYTHON_TESTING_TIMEOUT_SCALE
547 child.str_last_chars = 500
548
549 child.expect("IPython")
550 child.expect("\n")
551
552 child.timeout = 5 * IPYTHON_TESTING_TIMEOUT_SCALE
553
554 ### we need a filename, so we need to exec the full block with a filename
555 with NamedTemporaryFile(suffix=".py", dir=".", delete=True) as tf:
556 name = tf.name[:-3].split("/")[-1]
557 tf.write("\n".join([dedent(x) for x in skip_decorators_blocks[:-1]]).encode())
558 tf.flush()
559 codeblock = f"from {name} import f"
560
561 dedented_blocks = [
562 codeblock,
563 "f()",
564 ]
565
566 in_prompt_number = 1
567 for cblock in dedented_blocks:
568 child.expect_exact(f"In [{in_prompt_number}]:")
569 in_prompt_number += 1
570 for line in cblock.splitlines():
571 child.sendline(line)
572 child.expect_exact(line)
573 child.sendline("")
574
575 # From 3.13, set_trace()/breakpoint() stop on the line where they're
576 # called, instead of the next line.
577 if sys.version_info >= (3, 14):
578 child.expect_exact(" 46 ipdb.set_trace()")
579 extra_step = [("step", "--> 47 bar(3, 4)")]
580 elif sys.version_info >= (3, 13):
581 child.expect_exact("--> 46 ipdb.set_trace()")
582 extra_step = [("step", "--> 47 bar(3, 4)")]
583 else:
584 child.expect_exact("--> 47 bar(3, 4)")
585 extra_step = []
586
587 for input_, expected in (
588 [
589 (f"b {name}.py:3", ""),
590 ]
591 + extra_step

Callers

nothing calls this directly

Calls 5

dedentFunction · 0.85
copyMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…