-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_markup_fix.py
More file actions
39 lines (33 loc) · 1.3 KB
/
test_markup_fix.py
File metadata and controls
39 lines (33 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
"""Test script to reproduce and verify the markup error fix."""
import sys
from rich.console import Console
console = Console()
def test_markup_error():
"""Test that demonstrates the original markup error issue."""
try:
# Simulate an exception message with square brackets
raise Exception("Error in module [trae_agent.cli] at line 42")
except Exception as e:
# This should trigger the MarkupError
console.print(f"[red]Error: {e}[/red]")
def test_markup_fix():
"""Test that verifies the fix works correctly."""
try:
# Simulate an exception message with square brackets
raise Exception("Error in module [trae_agent.cli] at line 42")
except Exception as e:
# This should NOT trigger the MarkupError
console.print(f"[red]Error: {e}[/red]", markup=False)
if __name__ == "__main__":
print("Testing original behavior (should fail with MarkupError):")
try:
test_markup_error()
except Exception as e:
print(f"✗ Failed with: {type(e).__name__}: {e}")
print("\nTesting fixed behavior (should work without error):")
try:
test_markup_fix()
print("✓ Success! No MarkupError occurred.")
except Exception as e:
print(f"✗ Failed with: {type(e).__name__}: {e}")