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_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)
 def test_extra_trailing_empty_line(self):
     captions = SRTReader().read(SAMPLE_SRT_TRAILING_BLANKS)
     self.assertEqual(2, len(captions.get_captions("en-US")))
 def test_empty_file(self):
     self.assertRaises(CaptionReadNoCaptions,
                       SRTReader().read, SAMPLE_SRT_EMPTY)
 def test_numeric_captions(self):
     captions = SRTReader().read(SAMPLE_SRT_NUMERIC)
     self.assertEqual(7, len(captions.get_captions("en-US")))
    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_caption_length(self):
        captions = SRTReader().read(SAMPLE_SRT)

        self.assertEqual(7, len(captions.get_captions("en-US")))
 def test_detection(self):
     self.assertTrue(SRTReader().detect(SAMPLE_SRT))
Exemple #9
0
 def test_srt_reader_only_supports_unicode_input(self):
     with self.assertRaises(InvalidInputError):
         SRTReader().read(b'')
 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_to_sami_conversion(self):
     caption_set = SRTReader().read(SAMPLE_SRT)
     results = SAMIWriter().write(caption_set)
     self.assertTrue(isinstance(results, six.text_type))
     self.assertSAMIEquals(SAMPLE_SAMI, results)