-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtest_installation.py
More file actions
166 lines (132 loc) · 4.24 KB
/
test_installation.py
File metadata and controls
166 lines (132 loc) · 4.24 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python3
"""
Quick test script to verify ScreenPy installation and functionality.
"""
import sys
from pathlib import Path
def test_imports():
"""Test that all modules can be imported."""
print("Testing imports...")
try:
from screenpy import ScreenplayParser
print("✅ Core parser imported successfully")
except ImportError as e:
print(f"❌ Failed to import core parser: {e}")
return False
try:
from screenpy.models import Screenplay, ShotHeading, Segment
print("✅ Models imported successfully")
except ImportError as e:
print(f"❌ Failed to import models: {e}")
return False
try:
from screenpy.parser.grammar import SHOT_TYPES, TIME_WORDS
print("✅ Grammar imported successfully")
except ImportError as e:
print(f"❌ Failed to import grammar: {e}")
return False
try:
from screenpy.vsd import VerbSenseAnalyzer
print("✅ VSD module imported successfully")
except ImportError as e:
print(f"❌ Failed to import VSD: {e}")
return False
return True
def test_basic_parsing():
"""Test basic parsing functionality."""
print("\nTesting basic parsing...")
try:
from screenpy import ScreenplayParser
# Simple test screenplay
test_script = """
INT. TEST ROOM - DAY
JOHN sits at a table.
JOHN
Hello, world!
CUT TO:
EXT. STREET - NIGHT
JOHN walks alone.
"""
parser = ScreenplayParser()
screenplay = parser.parse(test_script)
print(f"✅ Parsed screenplay with {len(screenplay.segments)} segments")
print(f"✅ Found {len(screenplay.characters)} characters: {list(screenplay.characters.keys())}")
print(f"✅ Found {len(screenplay.transitions)} transitions")
# Test shot heading parsing
master_segments = [s for s in screenplay.segments if s.is_master_segment]
print(f"✅ Found {len(master_segments)} master segments")
return True
except Exception as e:
print(f"❌ Parsing test failed: {e}")
return False
def test_cli_available():
"""Test that CLI is available."""
print("\nTesting CLI availability...")
try:
from screenpy.cli import main
print("✅ CLI module available")
return True
except ImportError as e:
print(f"❌ CLI not available: {e}")
return False
def test_project_structure():
"""Test that project structure is correct."""
print("\nTesting project structure...")
expected_paths = [
"src/screenpy/__init__.py",
"src/screenpy/models.py",
"src/screenpy/cli.py",
"src/screenpy/parser/__init__.py",
"src/screenpy/parser/core.py",
"src/screenpy/parser/grammar.py",
"src/screenpy/parser/shot_parser.py",
"src/screenpy/parser/time_parser.py",
"src/screenpy/vsd/__init__.py",
"src/screenpy/vsd/analyzer.py",
"tests/test_parser.py",
"examples/parse_screenplay.py",
"pyproject.toml",
"requirements.txt",
"README.md",
]
missing = []
for path in expected_paths:
if not Path(path).exists():
missing.append(path)
if missing:
print(f"❌ Missing files: {missing}")
return False
else:
print("✅ All expected files present")
return True
def main():
"""Run all tests."""
print("=" * 60)
print("ScreenPy Installation Test")
print("=" * 60)
all_passed = True
# Test imports
if not test_imports():
all_passed = False
# Test basic parsing
if not test_basic_parsing():
all_passed = False
# Test CLI
if not test_cli_available():
all_passed = False
# Test structure
if not test_project_structure():
all_passed = False
print("\n" + "=" * 60)
if all_passed:
print("🎉 All tests passed! ScreenPy is ready to use.")
print("\nNext steps:")
print("1. pip install -e .")
print("2. Run: python examples/parse_screenplay.py")
print("3. Try: screenpy parse <screenplay.txt>")
else:
print("❌ Some tests failed. Check the errors above.")
sys.exit(1)
print("=" * 60)
if __name__ == "__main__":
main()