Skip to content

Commit 9adb886

Browse files
Josverlandrewleech
authored andcommitted
test_vscode: Add global variables to show vaiable tracking and hover.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
1 parent c98b355 commit 9adb886

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

python-ecosys/debugpy/test_vscode.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
"""Test script for VS Code debugging with MicroPython debugpy."""
33

44
import sys
5+
56
sys.path.insert(0, '.')
67

78
import debugpy
89

10+
foo = 42
11+
bar = "Hello, MicroPython!"
12+
913
def fibonacci(n):
1014
"""Calculate fibonacci number (iterative for efficiency)."""
1115
if n <= 1:
@@ -17,13 +21,15 @@ def fibonacci(n):
1721

1822
def debuggable_code():
1923
"""The actual code we want to debug - wrapped in a function so sys.settrace will trace it."""
24+
global foo
2025
print("Starting debuggable code...")
2126

2227
# Test data - set breakpoint here (using smaller numbers to avoid slow fibonacci)
2328
numbers = [3, 4, 5]
2429
for i, num in enumerate(numbers):
2530
print(f"Calculating fibonacci({num})...")
2631
result = fibonacci(num) # <-- SET BREAKPOINT HERE (line 26)
32+
foo += result # Modify foo to see if it gets traced
2733
print(f"fibonacci({num}) = {result}")
2834
print(sys.implementation)
2935
import machine

0 commit comments

Comments
 (0)