當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。