Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert patching of breakpointhook as it appears to do nothing #4028

Merged
merged 2 commits into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/4028.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert patching of ``sys.breakpointhook`` since it appears to do nothing.
16 changes: 0 additions & 16 deletions src/_pytest/debugging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
from __future__ import absolute_import, division, print_function
import pdb
import sys
import os
from doctest import UnexpectedException

from _pytest.config import hookimpl

try:
from builtins import breakpoint # noqa

SUPPORTS_BREAKPOINT_BUILTIN = True
except ImportError:
SUPPORTS_BREAKPOINT_BUILTIN = False


def pytest_addoption(parser):
group = parser.getgroup("general")
Expand Down Expand Up @@ -51,20 +43,12 @@ def pytest_configure(config):
if config.getvalue("usepdb"):
config.pluginmanager.register(PdbInvoke(), "pdbinvoke")

# Use custom Pdb class set_trace instead of default Pdb on breakpoint() call
if SUPPORTS_BREAKPOINT_BUILTIN:
_environ_pythonbreakpoint = os.environ.get("PYTHONBREAKPOINT", "")
if _environ_pythonbreakpoint == "":
sys.breakpointhook = pytestPDB.set_trace

old = (pdb.set_trace, pytestPDB._pluginmanager)

def fin():
pdb.set_trace, pytestPDB._pluginmanager = old
pytestPDB._config = None
pytestPDB._pdb_cls = pdb.Pdb
if SUPPORTS_BREAKPOINT_BUILTIN:
sys.breakpointhook = sys.__breakpointhook__

pdb.set_trace = pytestPDB.set_trace
pytestPDB._pluginmanager = config.pluginmanager
Expand Down
8 changes: 7 additions & 1 deletion testing/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
import os

import _pytest._code
from _pytest.debugging import SUPPORTS_BREAKPOINT_BUILTIN
import pytest

try:
breakpoint
except NameError:
SUPPORTS_BREAKPOINT_BUILTIN = False
else:
SUPPORTS_BREAKPOINT_BUILTIN = True


_ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "")

Expand Down