diff --git a/CHANGELOG b/CHANGELOG index e20532a9b..91c006553 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 --------- diff --git a/_pytest/hookspec.py b/_pytest/hookspec.py index 113915d2d..a9024b1d3 100644 --- a/_pytest/hookspec.py +++ b/_pytest/hookspec.py @@ -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 """ diff --git a/_pytest/pdb.py b/_pytest/pdb.py index 78fedd373..8a615d0d3 100644 --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -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) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index a2fd4d43d..06fc056e3 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -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