当前位置: 首页>>代码示例>>Python>>正文


Python pytest.set_trace方法代码示例

本文整理汇总了Python中pytest.set_trace方法的典型用法代码示例。如果您正苦于以下问题:Python pytest.set_trace方法的具体用法?Python pytest.set_trace怎么用?Python pytest.set_trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytest的用法示例。


在下文中一共展示了pytest.set_trace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_bool

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_bool(self, model, index, value, qtbool):
        dataFrame = pandas.DataFrame([value], columns=['A'])
        dataFrame['A'] = dataFrame['A'].astype(numpy.bool_)
        model.setDataFrame(dataFrame)
        assert not model.dataFrame().empty
        assert model.dataFrame() is dataFrame

        assert index.isValid()
        model.enableEditing(True)
        # pytest.set_trace()
        # everything is already set as false and since Qt.Unchecked = 0, 0 == False
        # therefore the assert will fail without further constraints
        assert model.setData(index, qtbool) == value
        assert model.data(index, role=Qt.DisplayRole) == value
        assert model.data(index, role=Qt.EditRole) == value
        assert model.data(index, role=Qt.CheckStateRole) == qtbool
        assert model.data(index, role=DATAFRAME_ROLE) == value
        assert isinstance(model.data(index, role=DATAFRAME_ROLE), numpy.bool_) 
开发者ID:datalyze-solutions,项目名称:pandas-qt,代码行数:20,代码来源:test_DataFrameModel.py

示例2: custom_debugger_hook

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def custom_debugger_hook():
    called = []

    # install dummy debugger class and track which methods were called on it
    class _CustomDebugger:
        def __init__(self, *args, **kwargs):
            called.append("init")

        def reset(self):
            called.append("reset")

        def interaction(self, *args):
            called.append("interaction")

        def set_trace(self, frame):
            print("**CustomDebugger**")
            called.append("set_trace")

    _pytest._CustomDebugger = _CustomDebugger  # type: ignore
    yield called
    del _pytest._CustomDebugger  # type: ignore 
开发者ID:pytest-dev,项目名称:pytest,代码行数:23,代码来源:test_debugging.py

示例3: test_pdb_interaction_capturing_simple

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_interaction_capturing_simple(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def test_1():
                i = 0
                print("hello17")
                pytest.set_trace()
                i == 1
                assert 0
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect(r"test_1\(\)")
        child.expect("i == 1")
        child.expect("Pdb")
        child.sendline("c")
        rest = child.read().decode("utf-8")
        assert "AssertionError" in rest
        assert "1 failed" in rest
        assert "def test_1" in rest
        assert "hello17" in rest  # out is captured
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:25,代码来源:test_debugging.py

示例4: test_pdb_set_trace_kwargs

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_set_trace_kwargs(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def test_1():
                i = 0
                print("hello17")
                pytest.set_trace(header="== my_header ==")
                x = 3
                assert 0
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect("== my_header ==")
        assert "PDB set_trace" not in child.before.decode()
        child.expect("Pdb")
        child.sendline("c")
        rest = child.read().decode("utf-8")
        assert "1 failed" in rest
        assert "def test_1" in rest
        assert "hello17" in rest  # out is captured
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:24,代码来源:test_debugging.py

示例5: test_pdb_set_trace_interception

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_set_trace_interception(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pdb
            def test_1():
                pdb.set_trace()
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.expect("Pdb")
        child.sendline("q")
        rest = child.read().decode("utf8")
        assert "no tests ran" in rest
        assert "reading from stdin while output" not in rest
        assert "BdbQuit" not in rest
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:19,代码来源:test_debugging.py

示例6: test_pdb_and_capsys

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_and_capsys(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def test_1(capsys):
                print("hello1")
                pytest.set_trace()
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.send("capsys.readouterr()\n")
        child.expect("hello1")
        child.sendeof()
        child.read()
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:18,代码来源:test_debugging.py

示例7: test_doctest_set_trace_quit

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_doctest_set_trace_quit(self, testdir):
        p1 = testdir.makepyfile(
            """
            def function_1():
                '''
                >>> __import__('pdb').set_trace()
                '''
        """
        )
        # NOTE: does not use pytest.set_trace, but Python's patched pdb,
        #       therefore "-s" is required.
        child = testdir.spawn_pytest("--doctest-modules --pdb -s %s" % p1)
        child.expect("Pdb")
        child.sendline("q")
        rest = child.read().decode("utf8")

        assert "! _pytest.outcomes.Exit: Quitting debugger !" in rest
        assert "= no tests ran in" in rest
        assert "BdbQuit" not in rest
        assert "UNEXPECTED EXCEPTION" not in rest 
开发者ID:pytest-dev,项目名称:pytest,代码行数:22,代码来源:test_debugging.py

示例8: test_pdb_used_in_generate_tests

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_used_in_generate_tests(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def pytest_generate_tests(metafunc):
                pytest.set_trace()
                x = 5
            def test_foo(a):
                pass
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect("x = 5")
        child.expect("Pdb")
        child.sendeof()
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:18,代码来源:test_debugging.py

示例9: test_pdb_not_altered

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_not_altered(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pdb
            def test_1():
                pdb.set_trace()
                assert 0
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.expect("Pdb")
        child.sendline("c")
        rest = child.read().decode("utf8")
        assert "1 failed" in rest
        assert "reading from stdin while output" not in rest
        TestPDB.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:19,代码来源:test_debugging.py

示例10: test_raises_bdbquit_with_eoferror

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_raises_bdbquit_with_eoferror(testdir):
    """It is not guaranteed that DontReadFromInput's read is called."""

    p1 = testdir.makepyfile(
        """
        def input_without_read(*args, **kwargs):
            raise EOFError()

        def test(monkeypatch):
            import builtins
            monkeypatch.setattr(builtins, "input", input_without_read)
            __import__('pdb').set_trace()
        """
    )
    result = testdir.runpytest(str(p1))
    result.stdout.fnmatch_lines(["E *BdbQuit", "*= 1 failed in*"])
    assert result.ret == 1 
开发者ID:pytest-dev,项目名称:pytest,代码行数:19,代码来源:test_debugging.py

示例11: put_data

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def put_data(request):
    put_data.key = None
    put_data.keys = []
    put_data.client = None

    def put_key(client, _key, _record, _meta=None, _policy=None):
        put_data.key = _key
        put_data.client = client
        try:
            client.remove(_key)
        except:
            pass
        put_data.keys.append(put_data.key)
        return client.put(_key, _record, _meta, _policy)

    def remove_key():
        try:
            # pytest.set_trace()
            for key in put_data.keys:
                put_data.client.remove(key)
        except:
            pass

    request.addfinalizer(remove_key)
    return put_key 
开发者ID:aerospike,项目名称:aerospike-client-python,代码行数:27,代码来源:conftest.py

示例12: test_view_definition

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_view_definition(executor):
    run(executor, "create table tbl1 (a text, b numeric)")
    run(executor, "create view vw1 AS SELECT * FROM tbl1")
    run(executor, "create materialized view mvw1 AS SELECT * FROM tbl1")
    result = executor.view_definition("vw1")
    assert "FROM tbl1" in result
    # import pytest; pytest.set_trace()
    result = executor.view_definition("mvw1")
    assert "MATERIALIZED VIEW" in result 
开发者ID:dbcli,项目名称:pgcli,代码行数:11,代码来源:test_pgexecute.py

示例13: test_pdb_interaction_capturing_twice

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_interaction_capturing_twice(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def test_1():
                i = 0
                print("hello17")
                pytest.set_trace()
                x = 3
                print("hello18")
                pytest.set_trace()
                x = 4
                assert 0
        """
        )
        child = testdir.spawn_pytest(str(p1))
        child.expect(r"PDB set_trace \(IO-capturing turned off\)")
        child.expect("test_1")
        child.expect("x = 3")
        child.expect("Pdb")
        child.sendline("c")
        child.expect(r"PDB continue \(IO-capturing resumed\)")
        child.expect(r"PDB set_trace \(IO-capturing turned off\)")
        child.expect("x = 4")
        child.expect("Pdb")
        child.sendline("c")
        child.expect("_ test_1 _")
        child.expect("def test_1")
        rest = child.read().decode("utf8")
        assert "Captured stdout call" in rest
        assert "hello17" in rest  # out is captured
        assert "hello18" in rest  # out is captured
        assert "1 failed" in rest
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:36,代码来源:test_debugging.py

示例14: test_pdb_without_capture

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_without_capture(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            def test_1():
                pytest.set_trace()
        """
        )
        child = testdir.spawn_pytest("-s %s" % p1)
        child.expect(r">>> PDB set_trace >>>")
        child.expect("Pdb")
        child.sendline("c")
        child.expect(r">>> PDB continue >>>")
        child.expect("1 passed")
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:17,代码来源:test_debugging.py

示例15: test_pdb_used_outside_test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import set_trace [as 别名]
def test_pdb_used_outside_test(self, testdir):
        p1 = testdir.makepyfile(
            """
            import pytest
            pytest.set_trace()
            x = 5
        """
        )
        child = testdir.spawn("{} {}".format(sys.executable, p1))
        child.expect("x = 5")
        child.expect("Pdb")
        child.sendeof()
        self.flush(child) 
开发者ID:pytest-dev,项目名称:pytest,代码行数:15,代码来源:test_debugging.py


注:本文中的pytest.set_trace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。