def test_write_to_file(self): events = [ SrtEvent.from_string(SINGLE_LINE_SRT_EVENT), SrtEvent.from_string(MULTILINE_SRT_EVENT) ] SrtScript(events).save_to_file(self.script_path) with open(self.script_path) as script: text = script.read() self.assertEquals(SINGLE_LINE_SRT_EVENT + "\n\n" + MULTILINE_SRT_EVENT, text)
def test_multi_line_event_parsing(self): event = SrtEvent.from_string(MULTILINE_SRT_EVENT) self.assertEquals(13 * 60 + 12.140, event.start) self.assertEquals(13 * 60 + 14.100, event.end) self.assertEquals( "APPEARANCE!\nAppearrance (teisai)!\nNo wait, you're the worst (saitei)!", event.text)
def test_parsing_and_printing(self): self.assertEquals(SINGLE_LINE_SRT_EVENT, unicode(SrtEvent.from_string(SINGLE_LINE_SRT_EVENT))) self.assertEquals(MULTILINE_SRT_EVENT, unicode(SrtEvent.from_string(MULTILINE_SRT_EVENT)))
def test_simple_parsing(self): event = SrtEvent.from_string(SINGLE_LINE_SRT_EVENT) self.assertEquals(14 * 60 + 21.960, event.start) self.assertEquals(14 * 60 + 22.960, event.end) self.assertEquals("HOW DID IT END UP LIKE THIS?", event.text)
def test_write_to_file(self): events = [SrtEvent.from_string(SINGLE_LINE_SRT_EVENT), SrtEvent.from_string(MULTILINE_SRT_EVENT)] SrtScript(events).save_to_file(self.script_path) with open(self.script_path) as script: text = script.read() self.assertEquals(SINGLE_LINE_SRT_EVENT + "\n\n" + MULTILINE_SRT_EVENT, text)
def test_multi_line_event_parsing(self): event = SrtEvent.from_string(MULTILINE_SRT_EVENT) self.assertEquals(13*60+12.140, event.start) self.assertEquals(13*60+14.100, event.end) self.assertEquals("APPEARANCE!\nAppearrance (teisai)!\nNo wait, you're the worst (saitei)!", event.text)
def test_simple_parsing(self): event = SrtEvent.from_string(SINGLE_LINE_SRT_EVENT) self.assertEquals(14*60+21.960, event.start) self.assertEquals(14*60+22.960, event.end) self.assertEquals("HOW DID IT END UP LIKE THIS?", event.text)