2929import unittest
3030import io
3131
32+ from ttconv .srt .config import SRTReaderConfiguration
3233from ttconv .srt .reader import to_model
3334import ttconv .style_properties as styles
3435import ttconv .model as model
@@ -67,7 +68,7 @@ def test_sample(self):
6768 def test_bold (self ):
6869 f = io .StringIO (r"""1
697000:02:16,612 --> 00:02:19,376
70- Hello <bold >my</bold > name is Bob
71+ Hello <b >my</b > name is Bob
7172""" )
7273 doc = to_model (f )
7374 for e in doc .get_body ().dfs_iterator ():
@@ -107,17 +108,53 @@ def test_bold_alt(self):
10710800:02:16,612 --> 00:02:19,376
108109Hello {bold}my{/bold} name is Bob
109110""" )
111+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
112+ for e in doc .get_body ().dfs_iterator ():
113+ if e .get_style (styles .StyleProperties .FontWeight ) == styles .FontWeightType .bold :
114+ break
115+ else :
116+ self .fail ()
117+ doc = to_model (f )
118+ for e in doc .get_body ().dfs_iterator ():
119+ if e .get_style (styles .StyleProperties .FontWeight ) == styles .FontWeightType .bold :
120+ self .fail ()
121+
122+ def test_bold_alt2 (self ):
123+ f = io .StringIO (r"""1
124+ 00:02:16,612 --> 00:02:19,376
125+ Hello <bold>my</bold> name is Bob
126+ """ )
127+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
128+ for e in doc .get_body ().dfs_iterator ():
129+ if e .get_style (styles .StyleProperties .FontWeight ) == styles .FontWeightType .bold :
130+ break
131+ else :
132+ self .fail ()
110133 doc = to_model (f )
134+ for e in doc .get_body ().dfs_iterator ():
135+ if e .get_style (styles .StyleProperties .FontWeight ) == styles .FontWeightType .bold :
136+ self .fail ()
137+
138+ def test_bold_alt3 (self ):
139+ f = io .StringIO (r"""1
140+ 00:02:16,612 --> 00:02:19,376
141+ Hello {b}my{/b} name is Bob
142+ """ )
143+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
111144 for e in doc .get_body ().dfs_iterator ():
112145 if e .get_style (styles .StyleProperties .FontWeight ) == styles .FontWeightType .bold :
113146 break
114147 else :
115148 self .fail ()
149+ doc = to_model (f )
150+ for e in doc .get_body ().dfs_iterator ():
151+ if e .get_style (styles .StyleProperties .FontWeight ) == styles .FontWeightType .bold :
152+ self .fail ()
116153
117154 def test_italic (self ):
118155 f = io .StringIO (r"""1
11915600:02:16,612 --> 00:02:19,376
120- Hello <italic >my</italic > name is Bob
157+ Hello <i >my</i > name is Bob
121158""" )
122159 doc = to_model (f )
123160 for e in doc .get_body ().dfs_iterator ():
@@ -131,17 +168,53 @@ def test_italic_alt(self):
13116800:02:16,612 --> 00:02:19,376
132169Hello {italic}my{/italic} name is Bob
133170""" )
171+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
172+ for e in doc .get_body ().dfs_iterator ():
173+ if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
174+ break
175+ else :
176+ self .fail ()
177+ doc = to_model (f )
178+ for e in doc .get_body ().dfs_iterator ():
179+ if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
180+ self .fail ()
181+
182+ def test_italic_alt1 (self ):
183+ f = io .StringIO (r"""1
184+ 00:02:16,612 --> 00:02:19,376
185+ Hello {i}my{/i} name is Bob
186+ """ )
187+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
188+ for e in doc .get_body ().dfs_iterator ():
189+ if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
190+ break
191+ else :
192+ self .fail ()
134193 doc = to_model (f )
194+ for e in doc .get_body ().dfs_iterator ():
195+ if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
196+ self .fail ()
197+
198+ def test_italic_alt2 (self ):
199+ f = io .StringIO (r"""1
200+ 00:02:16,612 --> 00:02:19,376
201+ Hello <italic>my</italic> name is Bob
202+ """ )
203+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
135204 for e in doc .get_body ().dfs_iterator ():
136205 if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
137206 break
138207 else :
139208 self .fail ()
209+ doc = to_model (f )
210+ for e in doc .get_body ().dfs_iterator ():
211+ if e .get_style (styles .StyleProperties .FontStyle ) == styles .FontStyleType .italic :
212+ self .fail ()
140213
141214 def test_underline (self ):
142215 f = io .StringIO (r"""1
14321600:02:16,612 --> 00:02:19,376
144- Hello <underline >my</underline > name is Bob
217+ Hello <u >my</u > name is Bob
145218""" )
146219 doc = to_model (f )
147220 for e in doc .get_body ().dfs_iterator ():
@@ -156,13 +229,54 @@ def test_underline_alt(self):
15622900:02:16,612 --> 00:02:19,376
157230Hello {underline}my{/underline} name is Bob
158231""" )
232+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
233+ for e in doc .get_body ().dfs_iterator ():
234+ text_decoration = e .get_style (styles .StyleProperties .TextDecoration )
235+ if text_decoration is not None and text_decoration .underline :
236+ break
237+ else :
238+ self .fail ()
239+ doc = to_model (f )
240+ for e in doc .get_body ().dfs_iterator ():
241+ text_decoration = e .get_style (styles .StyleProperties .TextDecoration )
242+ if text_decoration is not None and text_decoration .underline :
243+ self .fail ()
244+
245+ def test_underline_alt1 (self ):
246+ f = io .StringIO (r"""1
247+ 00:02:16,612 --> 00:02:19,376
248+ Hello {u}my{/u} name is Bob
249+ """ )
250+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
251+ for e in doc .get_body ().dfs_iterator ():
252+ text_decoration = e .get_style (styles .StyleProperties .TextDecoration )
253+ if text_decoration is not None and text_decoration .underline :
254+ break
255+ else :
256+ self .fail ()
159257 doc = to_model (f )
258+ for e in doc .get_body ().dfs_iterator ():
259+ text_decoration = e .get_style (styles .StyleProperties .TextDecoration )
260+ if text_decoration is not None and text_decoration .underline :
261+ self .fail ()
262+
263+ def test_underline_alt2 (self ):
264+ f = io .StringIO (r"""1
265+ 00:02:16,612 --> 00:02:19,376
266+ Hello <underline>my</underline> name is Bob
267+ """ )
268+ doc = to_model (f , SRTReaderConfiguration (extended_tags = True ))
160269 for e in doc .get_body ().dfs_iterator ():
161270 text_decoration = e .get_style (styles .StyleProperties .TextDecoration )
162271 if text_decoration is not None and text_decoration .underline :
163272 break
164273 else :
165274 self .fail ()
275+ doc = to_model (f )
276+ for e in doc .get_body ().dfs_iterator ():
277+ text_decoration = e .get_style (styles .StyleProperties .TextDecoration )
278+ if text_decoration is not None and text_decoration .underline :
279+ self .fail ()
166280
167281 def test_blue (self ):
168282 f = io .StringIO (r"""1
@@ -180,8 +294,8 @@ def test_blue(self):
180294 def test_multiline_tags (self ):
181295 f = io .StringIO (r"""1
18229600:02:16,612 --> 00:02:19,376
183- Hello <bold >my
184- </bold > name is Bob
297+ Hello <b >my
298+ </b > name is Bob
185299""" )
186300 doc = to_model (f )
187301 for e in doc .get_body ().dfs_iterator ():
0 commit comments