mike dupont commited on
Commit
07e5088
Β·
1 Parent(s): 5470877

Add test script for app.py

Browse files

Tests without launching server:
- Import validation
- Syntax checking
- Function existence
- Interface creation

All 4 tests passing βœ…

Files changed (1) hide show
  1. test_app.py +71 -0
test_app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script for app.py - validates without launching server
4
+ """
5
+ import sys
6
+
7
+ def test_imports():
8
+ """Test that all imports work"""
9
+ try:
10
+ import gradio as gr
11
+ print("βœ“ gradio imported")
12
+ return True
13
+ except ImportError as e:
14
+ print(f"βœ— Import failed: {e}")
15
+ return False
16
+
17
+ def test_syntax():
18
+ """Test Python syntax"""
19
+ try:
20
+ with open('app.py', 'r') as f:
21
+ compile(f.read(), 'app.py', 'exec')
22
+ print("βœ“ Syntax valid")
23
+ return True
24
+ except SyntaxError as e:
25
+ print(f"βœ— Syntax error: {e}")
26
+ return False
27
+
28
+ def test_function_exists():
29
+ """Test that main function exists"""
30
+ try:
31
+ import app
32
+ assert hasattr(app, 'create_game_interface')
33
+ print("βœ“ create_game_interface() exists")
34
+ return True
35
+ except Exception as e:
36
+ print(f"βœ— Function test failed: {e}")
37
+ return False
38
+
39
+ def test_interface_creation():
40
+ """Test interface can be created without launching"""
41
+ try:
42
+ import app
43
+ demo = app.create_game_interface()
44
+ print("βœ“ Interface created successfully")
45
+ print(f" Components: {len(demo.blocks)}")
46
+ return True
47
+ except Exception as e:
48
+ print(f"βœ— Interface creation failed: {e}")
49
+ return False
50
+
51
+ if __name__ == "__main__":
52
+ print("πŸ§ͺ Testing app.py\n")
53
+
54
+ tests = [
55
+ test_imports,
56
+ test_syntax,
57
+ test_function_exists,
58
+ test_interface_creation,
59
+ ]
60
+
61
+ results = [test() for test in tests]
62
+
63
+ print(f"\n{'='*50}")
64
+ print(f"Results: {sum(results)}/{len(results)} tests passed")
65
+
66
+ if all(results):
67
+ print("βœ… All tests passed!")
68
+ sys.exit(0)
69
+ else:
70
+ print("❌ Some tests failed")
71
+ sys.exit(1)