예제 #1
0
class LoaderTestCase(unittest.TestCase):
    def setUp(self):
        self.subsloader = SubsLoader(PARSERS, ENCODINGS)

    def test_loader(self):
        for subpath in TESTFILES:
            sublist, encoding = self.subsloader.load(subpath, fps=25)
            self.assertTrue(len(sublist) > 1, 'parsed subtitle list has to have at least 2 entries')
            self.assertTrue(encoding != '', 'cannot detect encoding')
            print '\n'

    def test_utf16(self):
        self.subsloader.change_encodings(['utf-8','utf-16'])
        sublist, encoding = self.subsloader.load(os.path.join(SUBS_PATH,'test_utf16.srt'))
        self.assertTrue(len(sublist) > 1, 'parsed subtitle list has to have at least 2 entries')
        self.assertTrue(encoding != '', 'cannot detect encoding')
        self.assertTrue(encoding == 'utf-16', 'utf-16 file has to be decoded with utf-16 encoding')

    def test_invalid_path_local(self):
        self.assertRaises(LoadError, self.subsloader.load, 'dsadsa')

    def test_invalid_path_remote(self):
        self.assertRaises(LoadError, self.subsloader.load, 'http://dsakldmskla.srt')

    def test_invalid_encoding(self):
        self.subsloader.change_encodings(['utf-8'])
        self.assertRaises(DecodeError, self.subsloader.load, os.path.join(SUBS_PATH,'test_arabic.srt'))

    def test_invalid_subtitles(self):
        #self.assertRaises((ParseError,ParserNotFoundError), self.subsloader.load, os.path.join(SUBS_PATH,'test_invalid_file.srt'))
        self.assertRaises((ParseError,ParserNotFoundError), self.subsloader.load, os.path.join(SUBS_PATH,'test_vobsub.idx'))

    def test_not_supported_size(self):
        self.assertRaises(LoadError, self.subsloader.load, os.path.join(SUBS_PATH,'test_vobsub.sub'))
예제 #2
0
class LoaderTestCase(unittest.TestCase):
    def setUp(self):
        self.subsloader = SubsLoader(PARSERS, ENCODINGS)

    def test_loader(self):
        for subpath in TESTFILES:
            sublist, encoding = self.subsloader.load(subpath, fps=25)
            self.assertTrue(
                len(sublist) > 1,
                'parsed subtitle list has to have at least 2 entries')
            self.assertTrue(encoding != '', 'cannot detect encoding')
            print('\n')

    def test_utf16(self):
        self.subsloader.change_encodings(['utf-8', 'utf-16'])
        sublist, encoding = self.subsloader.load(
            os.path.join(SUBS_PATH, 'test_utf16.srt'))
        self.assertTrue(
            len(sublist) > 1,
            'parsed subtitle list has to have at least 2 entries')
        self.assertTrue(encoding != '', 'cannot detect encoding')
        self.assertTrue(encoding == 'utf-16',
                        'utf-16 file has to be decoded with utf-16 encoding')

    def test_invalid_path_local(self):
        self.assertRaises(LoadError, self.subsloader.load, 'dsadsa')

    def test_invalid_path_remote(self):
        self.assertRaises(LoadError, self.subsloader.load,
                          'http://dsakldmskla.srt')

    def test_invalid_encoding(self):
        self.subsloader.change_encodings(['utf-8'])
        self.assertRaises(DecodeError, self.subsloader.load,
                          os.path.join(SUBS_PATH, 'test_arabic.srt'))

    def test_invalid_subtitles(self):
        #self.assertRaises((ParseError,ParserNotFoundError), self.subsloader.load, os.path.join(SUBS_PATH,'test_invalid_file.srt'))
        self.assertRaises((ParseError, ParserNotFoundError),
                          self.subsloader.load,
                          os.path.join(SUBS_PATH, 'test_vobsub.idx'))

    def test_not_supported_size(self):
        self.assertRaises(LoadError, self.subsloader.load,
                          os.path.join(SUBS_PATH, 'test_vobsub.sub'))
예제 #3
0
 def setUp(self):
     self.subsloader = SubsLoader(PARSERS, ENCODINGS)
예제 #4
0
 def setUp(self):
     self.subsloader = SubsLoader(PARSERS, ENCODINGS)