31
31
32
32
from ttconv .srt .reader import to_model
33
33
import ttconv .style_properties as styles
34
+ import ttconv .model as model
34
35
35
36
36
37
@@ -78,7 +79,7 @@ def test_bold(self):
78
79
def test_blank_lines (self ):
79
80
# from https://en.wikipedia.org/wiki/SubRip
80
81
SAMPLE = """
81
-
82
+
82
83
1
83
84
00:02:16,612 --> 00:02:19,376
84
85
Senator, we're making
@@ -135,7 +136,7 @@ def test_italic_alt(self):
135
136
if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
136
137
break
137
138
else :
138
- self .fail ()
139
+ self .fail ()
139
140
140
141
def test_underline (self ):
141
142
f = io .StringIO (r"""1
@@ -161,7 +162,7 @@ def test_underline_alt(self):
161
162
if text_decoration is not None and text_decoration .underline :
162
163
break
163
164
else :
164
- self .fail ()
165
+ self .fail ()
165
166
166
167
def test_blue (self ):
167
168
f = io .StringIO (r"""1
@@ -205,7 +206,35 @@ def test_long_hours(self):
205
206
363601 ,
206
207
doc .get_body ().first_child ().first_child ().get_end ()
207
208
)
208
-
209
+
210
+ def test_single_line_text (self ):
211
+ f = io .StringIO (r"""1
212
+ 101:00:00,000 --> 101:00:01,000
213
+ Hello
214
+ """ )
215
+ doc = to_model (f )
216
+
217
+ p_children = list (doc .get_body ().first_child ().first_child ())
218
+ self .assertEqual (len (p_children ), 1 )
219
+ self .assertIsInstance (p_children [0 ], model .Span )
220
+ self .assertEqual (p_children [0 ].first_child ().get_text (), "Hello" )
221
+
222
+ def test_multiline_text (self ):
223
+ f = io .StringIO (r"""1
224
+ 101:00:00,000 --> 101:00:01,000
225
+ Hello
226
+ World
227
+ """ )
228
+ doc = to_model (f )
229
+
230
+ p_children = list (doc .get_body ().first_child ().first_child ())
231
+ self .assertEqual (len (p_children ), 3 )
232
+ self .assertIsInstance (p_children [0 ], model .Span )
233
+ self .assertEqual (p_children [0 ].first_child ().get_text (), "Hello" )
234
+ self .assertIsInstance (p_children [1 ], model .Br )
235
+ self .assertIsInstance (p_children [2 ], model .Span )
236
+ self .assertEqual (p_children [2 ].first_child ().get_text (), "World" )
237
+
209
238
210
239
if __name__ == '__main__' :
211
240
unittest .main ()
0 commit comments