Example #1
0
    def test_eol_conversion(self):
        input_file = open(self.windows_path, 'rU', encoding='windows-1252')
        input_file.read()
        self.assertEqual(input_file.newlines, '\r\n')

        srt_file = pysrt.open(self.windows_path, encoding='windows-1252')
        srt_file.save(self.temp_path, eol='\n')

        output_file = open(self.temp_path, 'rU', encoding='windows-1252')
        output_file.read()
        self.assertEqual(output_file.newlines, '\n')
Example #2
0
    def test_eol_conversion(self):
        input_file = open(self.windows_path, "rU", encoding="windows-1252")
        input_file.read()
        self.assertEqual(input_file.newlines, "\r\n")

        srt_file = pysrt.open(self.windows_path, encoding="windows-1252")
        srt_file.save(self.temp_path, eol="\n")

        output_file = open(self.temp_path, "rU", encoding="windows-1252")
        output_file.read()
        self.assertEqual(output_file.newlines, "\n")
Example #3
0
    def test_eol_conversion(self):
        input_file = open(self.windows_path, 'rU', encoding='windows-1252')
        input_file.read()
        self.assertEqual(input_file.newlines, '\r\n')

        srt_file = pysrt.open(self.windows_path, encoding='windows-1252')
        srt_file.save(self.temp_path, eol='\n')

        output_file = open(self.temp_path, 'rU', encoding='windows-1252')
        output_file.read()
        self.assertEqual(output_file.newlines, '\n')
Example #4
0
 def test_save(self):
     srt_file = pysrt.open(self.windows_path, encoding='windows-1252')
     srt_file.save(self.temp_path, eol='\n', encoding='utf-8')
     self.assertEqual(bytes(open(self.temp_path, 'rb').read()),
                      bytes(open(self.utf8_path, 'rb').read()))
     os.remove(self.temp_path)
Example #5
0
 def test_utf8(self):
     unicode_content = codecs.open(self.utf8_path, encoding='utf_8').read()
     self.assertEqual(len(pysrt.from_string(unicode_content)), 1332)
     self.assertRaises(UnicodeDecodeError, open(self.windows_path).read)
Example #6
0
 def test_save(self):
     srt_file = pysrt.open(self.windows_path, encoding="windows-1252")
     srt_file.save(self.temp_path, eol="\n", encoding="utf-8")
     self.assertEqual(bytes(open(self.temp_path, "rb").read()), bytes(open(self.utf8_path, "rb").read()))
     os.remove(self.temp_path)
Example #7
0
 def test_utf8(self):
     unicode_content = codecs.open(self.utf8_path, encoding="utf_8").read()
     self.assertEqual(len(pysrt.from_string(unicode_content)), 1332)
     self.assertRaises(UnicodeDecodeError, open(self.windows_path).read)
Example #8
0
 def test_save(self):
     srt_file = pysrt.open(self.windows_path, encoding='windows-1252')
     srt_file.save(self.temp_path, eol='\n', encoding='utf-8')
     self.assertEqual(bytes(open(self.temp_path, 'rb').read()),
                       bytes(open(self.utf8_path, 'rb').read()))
     os.remove(self.temp_path)