Python pytest 模块,set_trace() 实例源码

我们从Python开源项目中,提取了以下27个代码示例,用于说明如何使用pytest.set_trace()

项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def pytest_configure(config):
    if config.getvalue("usepdb") or config.getvalue("usepdb_cls"):
        config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
        if config.getvalue("usepdb_cls"):
            modname, classname = config.getvalue("usepdb_cls").split(":")
            __import__(modname)
            pdb_cls = getattr(sys.modules[modname], classname)
        else:
            pdb_cls = pdb.Pdb
        pytestPDB._pdb_cls = pdb_cls

    old = (pdb.set_trace, pytestPDB._pluginmanager)
    def fin():
        pdb.set_trace, pytestPDB._pluginmanager = old
        pytestPDB._config = None
        pytestPDB._pdb_cls = pdb.Pdb
    pdb.set_trace = pytest.set_trace
    pytestPDB._pluginmanager = config.pluginmanager
    pytestPDB._config = config
    config._cleanup.append(fin)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def pytest_configure(config):
    if config.getvalue("usepdb") or config.getvalue("usepdb_cls"):
        config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
        if config.getvalue("usepdb_cls"):
            modname, classname = config.getvalue("usepdb_cls").split(":")
            __import__(modname)
            pdb_cls = getattr(sys.modules[modname], classname)
        else:
            pdb_cls = pdb.Pdb
        pytestPDB._pdb_cls = pdb_cls

    old = (pdb.set_trace, pytestPDB._pluginmanager)
    def fin():
        pdb.set_trace, pytestPDB._pluginmanager = old
        pytestPDB._config = None
        pytestPDB._pdb_cls = pdb.Pdb
    pdb.set_trace = pytest.set_trace
    pytestPDB._pluginmanager = config.pluginmanager
    pytestPDB._config = config
    config._cleanup.append(fin)
项目:godot-python    作者:touilleMan    | 项目源码 | 文件源码
def pytest_configure(config):
    if config.getvalue("usepdb") or config.getvalue("usepdb_cls"):
        config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
        if config.getvalue("usepdb_cls"):
            modname, classname = config.getvalue("usepdb_cls").split(":")
            __import__(modname)
            pdb_cls = getattr(sys.modules[modname], classname)
        else:
            pdb_cls = pdb.Pdb
        pytestPDB._pdb_cls = pdb_cls

    old = (pdb.set_trace, pytestPDB._pluginmanager)

    def fin():
        pdb.set_trace, pytestPDB._pluginmanager = old
        pytestPDB._config = None
        pytestPDB._pdb_cls = pdb.Pdb

    pdb.set_trace = pytest.set_trace
    pytestPDB._pluginmanager = config.pluginmanager
    pytestPDB._config = config
    config._cleanup.append(fin)
项目:godot-python    作者:touilleMan    | 项目源码 | 文件源码
def pytest_configure(config):
    if config.getvalue("usepdb") or config.getvalue("usepdb_cls"):
        config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')
        if config.getvalue("usepdb_cls"):
            modname, classname = config.getvalue("usepdb_cls").split(":")
            __import__(modname)
            pdb_cls = getattr(sys.modules[modname], classname)
        else:
            pdb_cls = pdb.Pdb
        pytestPDB._pdb_cls = pdb_cls

    old = (pdb.set_trace, pytestPDB._pluginmanager)

    def fin():
        pdb.set_trace, pytestPDB._pluginmanager = old
        pytestPDB._config = None
        pytestPDB._pdb_cls = pdb.Pdb

    pdb.set_trace = pytest.set_trace
    pytestPDB._pluginmanager = config.pluginmanager
    pytestPDB._config = config
    config._cleanup.append(fin)
项目:qtpandas    作者:draperjames    | 项目源码 | 文件源码
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_)
项目:TestLadies    作者:PyLadiesCZ    | 项目源码 | 文件源码
def step_03_check_basket_is_empty(selenium):
    # //*[@id="messages"]/div[2]/p
    # pytest.set_trace()
    # el = selenium.find_element_by_id('messages')
    # import time
    # time.sleep(1)
    # assert 'Your basket is now empty' in el.text

    WebDriverWait(selenium, 2).until(
        EC.text_to_be_present_in_element(
            # (By.ID, 'messages'),
            (By.XPATH, '//p[contains(text(),"Your basket is now empty")]'),
            'Your basket is now empty'
         )
    )

    # empty_alert = selenium.find_element(By.XPATH,'//p[contains(text(),"Your basket is now empty")]')
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_pdb_interaction_capturing_simple(self, testdir):
        p1 = testdir.makepyfile("""
            import pytest
            def test_1():
                i = 0
                print ("hello17")
                pytest.set_trace()
                x = 3
        """)
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.expect("x = 3")
        child.expect("(Pdb)")
        child.sendeof()
        rest = child.read().decode("utf-8")
        assert "1 failed" in rest
        assert "def test_1" in rest
        assert "hello17" in rest # out is captured
        if child.isalive():
            child.wait()
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_set_trace_capturing_afterwards(self, testdir):
        p1 = testdir.makepyfile("""
            import pdb
            def test_1():
                pdb.set_trace()
            def test_2():
                print ("hello")
                assert 0
        """)
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.send("c\n")
        child.expect("test_2")
        child.expect("Captured")
        child.expect("hello")
        child.sendeof()
        child.read()
        if child.isalive():
            child.wait()
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def test_enter_pdb_hook_is_called(self, testdir):
        testdir.makeconftest("""
            def pytest_enter_pdb():
                print 'enter_pdb_hook'
        """)
        p1 = testdir.makepyfile("""
            import pytest

            def test_foo():
                pytest.set_trace()
        """)
        child = testdir.spawn_pytest(str(p1))
        child.expect("enter_pdb_hook")
        child.send('c\n')
        child.sendeof()
        if child.isalive():
            child.wait()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def pytest_namespace():
    return {'set_trace': pytestPDB().set_trace}
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def set_trace(self):
        """ invoke PDB set_trace debugging, dropping any IO capturing. """
        import _pytest.config
        frame = sys._getframe().f_back
        if self._pluginmanager is not None:
            capman = self._pluginmanager.getplugin("capturemanager")
            if capman:
                capman.suspendcapture(in_=True)
            tw = _pytest.config.create_terminal_writer(self._config)
            tw.line()
            tw.sep(">", "PDB set_trace (IO-capturing turned off)")
            self._pluginmanager.hook.pytest_enter_pdb(config=self._config)
        self._pdb_cls().set_trace(frame)
项目:options-screener    作者:dcwangmit01    | 项目源码 | 文件源码
def yahoo_stock_info(self, ticker):
        r = requests.get('http://finance.yahoo.com/quote/AAPL?p=' + ticker)
        soup = BeautifulSoup(r.text)
        tables = soup.find_all('table')[1:]  # drop the first useless table

        # curl 'https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=summaryProfile%2CfinancialData%2CrecommendationTrend%2CupgradeDowngradeHistory%2Cearnings%2CdefaultKeyStatistics%2CcalendarEvents' | python -m json.tool > tmp2.txt
        print(soup.prettify())
        import pytest
        pytest.set_trace()
项目:options-screener    作者:dcwangmit01    | 项目源码 | 文件源码
def dtest_google_stock_info(self):
        d = dr.google_stock_info('AAPL')
        print(d)
        import pytest
        pytest.set_trace()
项目:options-screener    作者:dcwangmit01    | 项目源码 | 文件源码
def test_yahoo_stock_info(self):
        d = dr.yahoo_stock_info('AAPL')
        print(d)
        import pytest
        pytest.set_trace()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def pytest_namespace():
    return {'set_trace': pytestPDB().set_trace}
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def set_trace(self):
        """ invoke PDB set_trace debugging, dropping any IO capturing. """
        import _pytest.config
        frame = sys._getframe().f_back
        if self._pluginmanager is not None:
            capman = self._pluginmanager.getplugin("capturemanager")
            if capman:
                capman.suspendcapture(in_=True)
            tw = _pytest.config.create_terminal_writer(self._config)
            tw.line()
            tw.sep(">", "PDB set_trace (IO-capturing turned off)")
            self._pluginmanager.hook.pytest_enter_pdb(config=self._config)
        self._pdb_cls().set_trace(frame)
项目:gridded    作者:NOAA-ORR-ERD    | 项目源码 | 文件源码
def test_construction(self):
        curr_file = os.path.join(test_dir, 'staggered_sine_channel.nc')
        u = Variable.from_netCDF(filename=curr_file, varname='u_rho')
        v = Variable.from_netCDF(filename=curr_file, varname='v_rho')
        gvp = VectorVariable(name='velocity', units='m/s', time=u.time, variables=[u, v])
        assert gvp.name == 'velocity'
        assert gvp.units == 'm/s'
        assert gvp.varnames[0] == 'u_rho'
#         pytest.set_trace()
项目:godot-python    作者:touilleMan    | 项目源码 | 文件源码
def pytest_namespace():
    return {'set_trace': pytestPDB().set_trace}
项目:godot-python    作者:touilleMan    | 项目源码 | 文件源码
def set_trace(self):
        """ invoke PDB set_trace debugging, dropping any IO capturing. """
        import _pytest.config
        frame = sys._getframe().f_back
        if self._pluginmanager is not None:
            capman = self._pluginmanager.getplugin("capturemanager")
            if capman:
                capman.suspendcapture(in_=True)
            tw = _pytest.config.create_terminal_writer(self._config)
            tw.line()
            tw.sep(">", "PDB set_trace (IO-capturing turned off)")
            self._pluginmanager.hook.pytest_enter_pdb(config=self._config)
        self._pdb_cls().set_trace(frame)
项目:godot-python    作者:touilleMan    | 项目源码 | 文件源码
def pytest_namespace():
    return {'set_trace': pytestPDB().set_trace}
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
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.sendeof()
        rest = child.read().decode("utf8")
        assert "1 failed" in rest
        assert "reading from stdin while output" not in rest
        if child.isalive():
            child.wait()
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
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()
        if child.isalive():
            child.wait()
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
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
        """)
        child = testdir.spawn_pytest(str(p1))
        child.expect("test_1")
        child.expect("x = 3")
        child.expect("(Pdb)")
        child.sendline('c')
        child.expect("x = 4")
        child.sendeof()
        rest = child.read().decode("utf8")
        assert "1 failed" in rest
        assert "def test_1" in rest
        assert "hello17" in rest # out is captured
        assert "hello18" in rest # out is captured
        if child.isalive():
            child.wait()
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
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.sendeof()
        child.wait()
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def pytest_namespace():
    return {'set_trace': pytestPDB().set_trace}
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def pytest_configure(config):
    if config.getvalue("usepdb"):
        config.pluginmanager.register(PdbInvoke(), 'pdbinvoke')

    old = (pdb.set_trace, pytestPDB._pluginmanager)
    def fin():
        pdb.set_trace, pytestPDB._pluginmanager = old
        pytestPDB._config = None
    pdb.set_trace = pytest.set_trace
    pytestPDB._pluginmanager = config.pluginmanager
    pytestPDB._config = config
    config._cleanup.append(fin)
项目:GSM-scanner    作者:yosriayed    | 项目源码 | 文件源码
def set_trace(self):
        """ invoke PDB set_trace debugging, dropping any IO capturing. """
        import _pytest.config
        frame = sys._getframe().f_back
        capman = None
        if self._pluginmanager is not None:
            capman = self._pluginmanager.getplugin("capturemanager")
            if capman:
                capman.suspendcapture(in_=True)
            tw = _pytest.config.create_terminal_writer(self._config)
            tw.line()
            tw.sep(">", "PDB set_trace (IO-capturing turned off)")
            self._pluginmanager.hook.pytest_enter_pdb()
        pdb.Pdb().set_trace(frame)