Skip to content

Commit

Permalink
Fixed unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Dean-Kawamura committed Mar 8, 2016
1 parent 3b2d21f commit 96d3b15
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions babelsubs/tests/data/with-formatting.dfxp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</head>
<body region="amara-subtitle-area">
<div>
<p begin="00:00:00.000" end="00:00:01.038">This is a full fledge test of the migration of subtitles into DMR.</p><p begin="00:00:01.300" end="00:00:03.073">It has non ascii characters in can&#231;&#227;o, viol&#227;o, n&#233;?</p><p begin="00:00:03.509" end="00:00:05.926">It has <span tts:fontWeight="bold">bold</span> formatting</p><p begin="00:00:05.926" end="00:00:07.676">It has <span tts:fontStyle="italic">italics</span> too</p><p begin="00:00:07.676" end="00:00:09.847">And why not <span tts:textDecoration="underline">underline</span></p><p begin="00:00:09.847" end="00:00:11.757">It has a html tag &lt;a&gt; should be in brackets</p><p begin="00:00:11.757" end="00:00:13.852">It has speaker changes &gt;&gt;&gt;</p><p begin="00:00:13.852" end="00:00:15.758">And an &amp; (ampersand) of course</p></div>
<p begin="00:00:00.000" end="00:00:01.038">This is a full fledge test of the migration of subtitles into DMR.</p><p begin="00:00:01.300" end="00:00:03.073">It has non ascii characters in can&#231;&#227;o, viol&#227;o, n&#233;?</p><p begin="00:00:03.509" end="00:00:05.926">It has <span tts:fontWeight="bold">bold</span> formatting</p><p begin="00:00:05.926" end="00:00:07.676">It has <span tts:fontStyle="italic">italics</span> too</p><p begin="00:00:07.676" end="00:00:09.847">And why not <span tts:textDecoration="underline">underline</span></p><p begin="00:00:09.847" end="00:00:11.757">It has a html tag &lt;a&gt; should be escaped</p><p begin="00:00:11.757" end="00:00:13.852">It has speaker changes &gt;&gt;&gt;</p><p begin="00:00:13.852" end="00:00:15.758">And an &amp; (ampersand) of course</p></div>
</body>
</tt>
</tt>
9 changes: 6 additions & 3 deletions babelsubs/tests/test_srt.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def test_ampersand_escaping(self):
subs = utils.get_subs("simple.srt")
parsed = subs.to_internal()
sub_data = [x for x in parsed.subtitle_items(SRTGenerator.MAPPINGS)]
self.assertEquals(sub_data[16].text, "such as MP4, theora, webM and <i>&</i> HTML 5.")
self.assertEquals(sub_data[16].text,
"such as MP4, theora, webM and <i>&amp;</i> HTML 5.")

def test_unsynced_generator(self):
subs = SubtitleSet('en')
Expand Down Expand Up @@ -182,8 +183,10 @@ def test_generated_formatting(self):
self.assertEqual(self.subs[2].text,'It has <b>bold</b> formatting' )
self.assertEqual(self.subs[3].text,'It has <i>italics</i> too' )
self.assertEqual(self.subs[4].text,'And why not <u>underline</u>' )
self.assertEqual(self.subs[5].text,'It has a html tag <a> should be in brackets' )
self.assertEqual(self.subs[6].text,'It has speaker changes >>>' )
self.assertEqual(self.subs[5].text,
'It has a html tag &lt;a&gt; should be escaped' )
self.assertEqual(self.subs[6].text,
'It has speaker changes &gt;&gt;&gt;')

class SRTMultiLines(TestCase):
def setUp(self):
Expand Down
9 changes: 6 additions & 3 deletions babelsubs/tests/test_webvtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def test_ampersand_escaping(self):
subs = utils.get_subs("basic.vtt")
parsed = subs.to_internal()
sub_data = [x for x in parsed.subtitle_items(WEBVTTGenerator.MAPPINGS)]
self.assertEquals(sub_data[16].text, "such as MP4, theora, webM and <i>&</i> HTML 5.")
self.assertEquals(sub_data[16].text,
"such as MP4, theora, webM and <i>&amp;</i> HTML 5.")

def test_invalid(self):
with self.assertRaises(SubtitleParserError):
Expand Down Expand Up @@ -97,8 +98,10 @@ def test_generated_formatting(self):
self.assertEqual(subs[2].text,'It has <b>bold</b> formatting' )
self.assertEqual(subs[3].text,'It has <i>italics</i> too' )
self.assertEqual(subs[4].text,'And why not <u>underline</u>' )
self.assertEqual(subs[5].text,'It has a html tag <a> should be in brackets' )
self.assertEqual(subs[6].text,'It has speaker changes >>>' )
self.assertEqual(subs[5].text,
'It has a html tag &lt;a&gt; should be escaped' )
self.assertEqual(subs[6].text,
'It has speaker changes &gt;&gt;&gt;' )

def test_span_around_newline(self):
source = 'one<span fontStyle="italic"><br/></span>two'
Expand Down

0 comments on commit 96d3b15

Please sign in to comment.