def test_proper_timestamps(self, sample_microdvd): captions = MicroDVDReader().read(sample_microdvd) paragraph = captions.get_captions(DEFAULT_LANGUAGE_CODE)[2] # due to lossy nature of microsec -> frame# we check that # conversion is within a second of expected value # (fyi: timestamps in examples/ and tests/fixtures/ differ) assert abs(17350000 - paragraph.start) < 10**6 assert abs(18752000 - paragraph.end) < 10**6
def test_proper_timestamps(self): captions = MicroDVDReader().read(SAMPLE_MICRODVD) paragraph = captions.get_captions(u"en-US")[2] # due to lossy nature of microsec -> frame# we check that # conversion is within a second of expected value # (fyi: timestamps in examples/ and test/samples/ differ) self.assertTrue(abs(17350000 - paragraph.start) < 10**6) self.assertTrue(abs(18752000 - paragraph.end) < 10**6)
def test_caption_length(self): captions = MicroDVDReader().read(SAMPLE_MICRODVD) self.assertEquals(12, len(captions.get_captions(u"en-US")))
def test_microdvd_to_microdvd_conversion(self, sample_microdvd): caption_set = MicroDVDReader().read(sample_microdvd) results = MicroDVDWriter().write(caption_set) assert isinstance(results, str) self.assert_microdvd_equals(sample_microdvd, results)
def test_detection(self, sample_microdvd): assert MicroDVDReader().detect(sample_microdvd) is True
def test_no_fps_provided(self, missing_fps_sample_microdvd): with pytest.raises(CaptionReadTimingError): MicroDVDReader().read(missing_fps_sample_microdvd)
def test_invalid_format(self, sample_microdvd_invalid_format): with pytest.raises(CaptionReadSyntaxError): MicroDVDReader().read(sample_microdvd_invalid_format)
def test_empty_file(self, sample_microdvd_empty): with pytest.raises(CaptionReadNoCaptions): MicroDVDReader().read(sample_microdvd_empty)
def test_caption_length(self, sample_microdvd): captions = MicroDVDReader().read(sample_microdvd) assert 7 == len(captions.get_captions(DEFAULT_LANGUAGE_CODE))