Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_extra_empty_line(self):
captions = SRTReader().read(SAMPLE_SRT_BLANK_LINES)
self.assertEqual(2, len(captions.get_captions("en-US")))
def test_numeric_captions(self):
captions = SRTReader().read(SAMPLE_SRT_NUMERIC)
self.assertEqual(7, len(captions.get_captions("en-US")))
def _test_srt_to_scc_to_srt_conversion(self, srt_captions):
captions_1 = SRTReader().read(srt_captions)
scc_results = SCCWriter().write(captions_1)
scc_captions = SCCReader().read(scc_results)
srt_results = SRTWriter().write(scc_captions)
captions_2 = SRTReader().read(srt_results)
self.assertCaptionSetAlmostEquals(captions_1, captions_2,
TOLERANCE_MICROSECONDS)
def test_srt_to_webvtt_conversion(self):
caption_set = SRTReader().read(SAMPLE_SRT)
results = WebVTTWriter().write(caption_set)
self.assertTrue(isinstance(results, six.text_type))
self.assertWebVTTEquals(SAMPLE_WEBVTT_FROM_SRT, results)
def test_srt_reader_only_supports_unicode_input(self):
with self.assertRaises(InvalidInputError):
SRTReader().read(b'')
def _test_srt_to_scc_to_srt_conversion(self, srt_captions):
captions_1 = SRTReader().read(srt_captions)
scc_results = SCCWriter().write(captions_1)
scc_captions = SCCReader().read(scc_results)
srt_results = SRTWriter().write(scc_captions)
captions_2 = SRTReader().read(srt_results)
self.assertCaptionSetAlmostEquals(captions_1, captions_2,
TOLERANCE_MICROSECONDS)
def test_proper_timestamps(self):
captions = SRTReader().read(SAMPLE_SRT)
paragraph = captions.get_captions("en-US")[2]
self.assertEqual(17000000, paragraph.start)
self.assertEqual(18752000, paragraph.end)
def test_srt_to_srt_conversion(self):
caption_set = SRTReader().read(SAMPLE_SRT)
results = SRTWriter().write(caption_set)
self.assertTrue(isinstance(results, six.text_type))
self.assertSRTEquals(SAMPLE_SRT, results)
def test_detection(self):
self.assertTrue(SRTReader().detect(SAMPLE_SRT))
def test_srt_to_dfxp_conversion(self):
caption_set = SRTReader().read(SAMPLE_SRT)
results = DFXPWriter().write(caption_set)
self.assertTrue(isinstance(results, six.text_type))
self.assertDFXPEquals(
SAMPLE_DFXP, results,
ignore_styling=True, ignore_spans=True
)