Pass pytest's config object to pytest_enter_pdb

This commit is contained in:
Bruno Oliveira 2015-11-23 13:05:56 -02:00
parent 1f148a93ec
commit b3166a538c
4 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,9 @@
* New `pytest.mark.skip` mark, which unconditional skips marked tests.
Thanks Michael Aquilina for the complete PR.
* `pytest_enter_pdb` now optionally receives the pytest config object.
Thanks Bruno Oliveira for the PR.
2.8.2.dev
---------

View File

@ -290,7 +290,10 @@ def pytest_exception_interact(node, call, report):
that is not an internal exception like "skip.Exception".
"""
def pytest_enter_pdb():
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
"""

View File

@ -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)

View File

@ -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