-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_progress_display.py
More file actions
61 lines (47 loc) · 1.58 KB
/
test_progress_display.py
File metadata and controls
61 lines (47 loc) · 1.58 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
"""Test script to verify progress bar display functionality"""
import time
import sys
def print_progress(percentage):
"""Test progress bar implementation"""
bar_length = 30
filled_length = int(round(bar_length * percentage / 100))
bar = "█" * filled_length + "-" * (bar_length - filled_length)
sys.stdout.write(f"\rProgress: [{bar}] {percentage}%")
sys.stdout.flush()
def test_progress_display():
"""Test progress display"""
print("Testing progress display...")
print("-" * 40)
# Test increasing progress
print("\n1. Increasing progress:")
for i in range(0, 101, 5):
print_progress(i)
time.sleep(0.1)
# Test stuck at 99%
print("\n\n2. Stuck at 99%:")
for i in range(10):
print_progress(99)
time.sleep(0.2)
# Test complete
print("\n\n3. Complete:")
print_progress(100)
print()
# Test fallback progress
print("\n4. Fallback time-based progress:")
start_time = time.time()
duration = 2 # seconds
while time.time() - start_time < duration:
elapsed = time.time() - start_time
progress = min(int((elapsed / duration) * 95), 95)
print_progress(progress)
time.sleep(0.05)
print_progress(100)
print()
print("\n✅ Progress display tests passed!")
print("\nThe progress bar should now:")
print("- Display actual percentage if detected")
print("- Show time-based fallback if percentage not available")
print("- Handle stuck cases appropriately")
if __name__ == "__main__":
test_progress_display()