コード例 #1
0
def test_no_bt_all(testdir_setup):
    testdir_setup.makepyfile(test_file="""
        def test_foo():
            assert True
    """)
    pe = testdir_setup.spawn_pytest("--break=test_file.py:2")
    pe.expect(prompt_re)
    befs = LineMatcher(unansi(pe.before))
    befs.fnmatch_lines("*>*/test_file.py(2)test_foo()")
    pe.sendline("w")
    pe.expect(prompt_re)
    befs = LineMatcher(unansi(pe.before))
    assert "runcall_until" not in befs.str()
    befs.fnmatch_lines("*>*/test_file.py(2)test_foo()")
    pe.sendline("c")
    pe.expect(EOF)
コード例 #2
0
def test_inner_simple(testdir_setup, bt_all):
    testdir_setup.makepyfile(test_file="""
        def test_foo():

            def inner(x):
                print("inner")  # <- line 4
                return x + 1

            assert inner(1)     # <- line 7
            assert True
    """)
    opts = "--break=test_file.py:4"
    if bt_all:
        opts += " --bt-all"
    pe = testdir_setup.spawn_pytest(opts)
    pe.expect(prompt_re)
    befs = LineMatcher(unansi(pe.before))
    befs.fnmatch_lines(["*>*/test_file.py(4)inner()", "->*# <- line 4"])

    # Stack
    pe.sendline("w")
    pe.expect(prompt_re)
    befs = LineMatcher(unansi(pe.before))
    if bt_all:
        befs.fnmatch_lines([
            "*/_pytest/config/__init__.py(*)main()",
            "*/pytest_pdb_break.py(*)runcall_until()",
            "*/test_file.py(7)test_foo()", "*assert inner(1)*line 7"
        ])
    else:
        assert "runcall_until" not in befs.str()
        befs.fnmatch_lines(
            ["*/test_file.py(7)test_foo()", "*assert inner(1)*line 7"])

    pe.sendline("c")
    pe.expect(EOF)
    befs = LineMatcher(unansi(pe.before))
    befs.fnmatch_lines("*1 passed*")