Spaces:
Configuration error
Configuration error
| #!/usr/bin/env python3 | |
| """ | |
| Test script for app.py - validates without launching server | |
| """ | |
| import sys | |
| def test_imports(): | |
| """Test that all imports work""" | |
| try: | |
| import gradio as gr | |
| print("β gradio imported") | |
| return True | |
| except ImportError as e: | |
| print(f"β Import failed: {e}") | |
| return False | |
| def test_syntax(): | |
| """Test Python syntax""" | |
| try: | |
| with open('app.py', 'r') as f: | |
| compile(f.read(), 'app.py', 'exec') | |
| print("β Syntax valid") | |
| return True | |
| except SyntaxError as e: | |
| print(f"β Syntax error: {e}") | |
| return False | |
| def test_function_exists(): | |
| """Test that main function exists""" | |
| try: | |
| import app | |
| assert hasattr(app, 'create_game_interface') | |
| print("β create_game_interface() exists") | |
| return True | |
| except Exception as e: | |
| print(f"β Function test failed: {e}") | |
| return False | |
| def test_interface_creation(): | |
| """Test interface can be created without launching""" | |
| try: | |
| import app | |
| demo = app.create_game_interface() | |
| print("β Interface created successfully") | |
| print(f" Components: {len(demo.blocks)}") | |
| return True | |
| except Exception as e: | |
| print(f"β Interface creation failed: {e}") | |
| return False | |
| if __name__ == "__main__": | |
| print("π§ͺ Testing app.py\n") | |
| tests = [ | |
| test_imports, | |
| test_syntax, | |
| test_function_exists, | |
| test_interface_creation, | |
| ] | |
| results = [test() for test in tests] | |
| print(f"\n{'='*50}") | |
| print(f"Results: {sum(results)}/{len(results)} tests passed") | |
| if all(results): | |
| print("β All tests passed!") | |
| sys.exit(0) | |
| else: | |
| print("β Some tests failed") | |
| sys.exit(1) | |