Skip to content

Commit

Permalink
issue openwallet-foundation#3182: fix up conftest.py to use debugpy
Browse files Browse the repository at this point in the history
Signed-off-by: Ricky Ng-Adam <[email protected]>
  • Loading branch information
rngadam committed Aug 21, 2024
1 parent 091e167 commit 69060c9
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,24 @@ def stub_ursa_bbs_signatures() -> Stub:

def pytest_sessionstart(session):
global STUBS, POSTGRES_URL, ENABLE_PTVSD
ENABLE_PTVSD = os.getenv("ENABLE_PTVSD", False)
# --debug-vs to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in sys.argv:
args = sys.argv

# copied from __main__.py:init_debug
ENABLE_PTVSD = os.getenv("ENABLE_PTVSD", "").lower()
ENABLE_PTVSD = ENABLE_PTVSD and ENABLE_PTVSD not in ("false", "0")

# --debug to use microsoft's visual studio remote debugger
if ENABLE_PTVSD or "--debug" in args:
DAP_HOST = os.getenv("PTVSD_HOST", None) or os.getenv("DAP_HOST", "localhost")
DAP_PORT = os.getenv("PTVSD_PORT", None) or os.getenv("DAP_PORT", 5678)
try:
import ptvsd
import debugpy

ptvsd.enable_attach(address=("0.0.0.0", 5678))
print("ptvsd is running")
print("=== Waiting for debugger to attach ===")
# To pause execution until the debugger is attached:
ptvsd.wait_for_attach()
debugpy.listen((DAP_HOST, DAP_PORT))
print(f"=== Waiting for debugger to attach to {DAP_HOST}:{DAP_PORT} ===")
debugpy.wait_for_client()
except ImportError:
print("ptvsd library was not found")
print("debugpy library was not found")

POSTGRES_URL = os.getenv("POSTGRES_URL")

Expand Down

0 comments on commit 69060c9

Please sign in to comment.