@@ -64,6 +64,43 @@ def test_zero_duration(self):
64
64
self .item .start .shift (seconds = 20 )
65
65
self .assertEqual (self .item .characters_per_second , 0.0 )
66
66
67
+ def test_tags (self ):
68
+ self .item .text = '<b>bold</b>, <i>italic</i>, <u>underlined</u>\n ' + \
69
+ '<font color="#ff0000">red text</font>' + \
70
+ ', <b>one,<i> two,<u> three</u></i></b>'
71
+ self .assertEqual (self .item .characters_per_second , 2.45 )
72
+
73
+
74
+ class TestTagRemoval (unittest .TestCase ):
75
+
76
+ def setUp (self ):
77
+ self .item = SubRipItem (1 , text = "Hello world !" )
78
+ self .item .shift (minutes = 1 )
79
+ self .item .end .shift (seconds = 20 )
80
+
81
+ def test_italics_tag (self ):
82
+ self .item .text = "<i>Hello world !</i>"
83
+ self .assertEqual (self .item .text_without_tags ,'Hello world !' )
84
+
85
+ def test_bold_tag (self ):
86
+ self .item .text = "<b>Hello world !</b>"
87
+ self .assertEqual (self .item .text_without_tags ,'Hello world !' )
88
+
89
+ def test_underline_tag (self ):
90
+ self .item .text = "<u>Hello world !</u>"
91
+ self .assertEqual (self .item .text_without_tags ,'Hello world !' )
92
+
93
+ def test_color_tag (self ):
94
+ self .item .text = '<font color="#ff0000">Hello world !</font>'
95
+ self .assertEqual (self .item .text_without_tags ,'Hello world !' )
96
+
97
+ def test_all_tags (self ):
98
+ self .item .text = '<b>Bold</b>, <i>italic</i>, <u>underlined</u>\n ' + \
99
+ '<font color="#ff0000">red text</font>' + \
100
+ ', <b>one,<i> two,<u> three</u></i></b>.'
101
+ self .assertEqual (self .item .text_without_tags ,'Bold, italic, underlined' + \
102
+ '\n red text, one, two, three.' )
103
+
67
104
68
105
class TestShifting (unittest .TestCase ):
69
106
0 commit comments