Merge pull request #1188 from nicoddemus/pytest_enter_pdb
Pass pytest config object to pytest_enter_pdb
This commit is contained in:
commit
df767cca8f
|
@ -7,6 +7,9 @@
|
|||
`Config.fromdictargs` now represents its input much more faithfully.
|
||||
Thanks to Buck Evan for the complete PR.
|
||||
|
||||
* `pytest_enter_pdb` now optionally receives the pytest config object.
|
||||
Thanks Bruno Oliveira for the PR.
|
||||
|
||||
2.8.2.dev
|
||||
---------
|
||||
|
||||
|
|
|
@ -290,5 +290,10 @@ def pytest_exception_interact(node, call, report):
|
|||
that is not an internal exception like "skip.Exception".
|
||||
"""
|
||||
|
||||
def pytest_enter_pdb():
|
||||
""" called upon pdb.set_trace()"""
|
||||
def pytest_enter_pdb(config):
|
||||
""" called upon pdb.set_trace(), can be used by plugins to take special
|
||||
action just before the python debugger enters in interactive mode.
|
||||
|
||||
:arg config: pytest config object
|
||||
:type config: _pytest.config.Config
|
||||
"""
|
||||
|
|
|
@ -37,7 +37,6 @@ class pytestPDB:
|
|||
""" 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:
|
||||
|
@ -45,7 +44,7 @@ class pytestPDB:
|
|||
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()
|
||||
self._pluginmanager.hook.pytest_enter_pdb(config=self._config)
|
||||
pdb.Pdb().set_trace(frame)
|
||||
|
||||
|
||||
|
|
|
@ -501,7 +501,7 @@ reporting or interaction with exceptions:
|
|||
.. autofunction:: pytest_internalerror
|
||||
.. autofunction:: pytest_keyboard_interrupt
|
||||
.. autofunction:: pytest_exception_interact
|
||||
|
||||
.. autofunction:: pytest_enter_pdb
|
||||
|
||||
|
||||
Reference of objects involved in hooks
|
||||
|
|
|
@ -275,8 +275,12 @@ class TestPDB:
|
|||
|
||||
def test_enter_pdb_hook_is_called(self, testdir):
|
||||
testdir.makeconftest("""
|
||||
def pytest_enter_pdb():
|
||||
def pytest_enter_pdb(config):
|
||||
assert config.testing_verification == 'configured'
|
||||
print 'enter_pdb_hook'
|
||||
|
||||
def pytest_configure(config):
|
||||
config.testing_verification = 'configured'
|
||||
""")
|
||||
p1 = testdir.makepyfile("""
|
||||
import pytest
|
||||
|
|
Loading…
Reference in New Issue