コード例 #1
0
ファイル: test_subtitle.py プロジェクト: seainm/subaligner
 def test_throw_exception_on_loading_unknown_subtitle(self):
     try:
         unknown_file_path = os.path.join(self.__resource_tmp, "subtitle_test.unknown")
         Path(unknown_file_path).touch()
         Undertest.shift_subtitle(unknown_file_path, 2, "", "")
     except Exception as e:
         self.assertTrue(isinstance(e, UnsupportedFormatException))
     else:
         self.fail("Should have thrown exception")
コード例 #2
0
ファイル: test_subtitle.py プロジェクト: seainm/subaligner
 def test_shift_stl_subtitle(self):
     shifted_stl_file_path = os.path.join(self.__resource_tmp, "subtitle_test.srt")
     Undertest.shift_subtitle(
         self.__stl_file_path, 2, shifted_stl_file_path, suffix="_test"
     )
     with open(shifted_stl_file_path) as shifted:
         for j, ls in enumerate(shifted):
             pass
     shifted_line_num = j + 1
     self.assertEqual(32, shifted_line_num)
コード例 #3
0
ファイル: test_subtitle.py プロジェクト: seainm/subaligner
 def test_shift_sami_subtitle(self):
     shifted_sami_file_path = os.path.join(self.__resource_tmp, "subtitle_test.sami")
     Undertest.shift_subtitle(
         self.__sami_file_path, 2, shifted_sami_file_path, suffix="_test"
     )
     with open(self.__sami_file_path) as original:
         for i, lo in enumerate(original):
             pass
     with open(shifted_sami_file_path) as shifted:
         for j, ls in enumerate(shifted):
             pass
     original_line_num = i + 1
     shifted_line_num = j + 1
     self.assertEqual(original_line_num, shifted_line_num)
コード例 #4
0
 def test_shift_srt_subtitle_without_destination_file_path(self):
     shifted_srt_file_path = os.path.join(self.__resource_tmp,
                                          "subtitle_test.srt")
     another_shifted_srt_file_path = os.path.join(
         self.__resource_tmp, "subtitle_test_aligned.srt")
     Undertest.shift_subtitle(self.__srt_file_path,
                              2,
                              shifted_srt_file_path,
                              suffix="_test")
     Undertest.shift_subtitle(shifted_srt_file_path,
                              2,
                              None,
                              suffix="_aligned")
     with open(shifted_srt_file_path) as original:
         for i, lo in enumerate(original):
             pass
     with open(another_shifted_srt_file_path) as shifted:
         for j, ls in enumerate(shifted):
             pass
     original_line_num = i + 1
     shifted_line_num = j + 1
     self.assertEqual(original_line_num, shifted_line_num)