Files
openide/python/helpers/pydev/_pydevd_bundle/pydevd_console_pytest.py
Elizaveta Shashkova a183d5dcac PY-37361 Add missing import
GitOrigin-RevId: e40d6910cf89b262e0c944c4055c80f57d0c640c
2019-09-11 13:03:59 +00:00

27 lines
898 B
Python

from _pydev_bundle import pydev_log
import traceback
def enable_pytest_output():
try:
import _pytest
if hasattr(_pytest, "debugging"): # pytest >= 3
from _pytest.debugging import pytestPDB as _pytestDebug
else:
raise ValueError("Failed to find debugger in _pytest")
plugin_manager = _pytestDebug._pluginmanager
if plugin_manager is not None:
capman = plugin_manager.getplugin("capturemanager")
if hasattr(capman, "suspend"): # pytest 4
capman.suspend(in_=True)
elif hasattr(capman, "suspend_global_capture"): # pytest 3
capman.suspend_global_capture(in_=True)
else:
raise ValueError("Failed to find suspend method")
except Exception:
pydev_log.debug("Failed to enable pytest output: %s" % traceback.format_exc())