Create a GstException to wrap a Gst.GError. Create a base GstPipelineTask class. Use it in Checksum and TRM tasks. Raise and don't proceed to call .paused() when a GstError happens. Should help debug https://bugs.launchpad.net/bugs/735053 * morituri/test/test_common_checksum.py: Adapt test.
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
# -*- Mode: Python; test-case-name: morituri.test.test_common_checksum -*-
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
import os
|
|
import tempfile
|
|
|
|
import gobject
|
|
gobject.threads_init()
|
|
|
|
import gst
|
|
|
|
from morituri.test import common
|
|
|
|
from morituri.common import task, checksum, log
|
|
|
|
from morituri.test import common
|
|
|
|
def h(i):
|
|
return "0x%08x" % i
|
|
|
|
class EmptyTestCase(common.TestCase):
|
|
def testEmpty(self):
|
|
# this test makes sure that checksumming empty files doesn't hang
|
|
self.runner = task.SyncRunner(verbose=False)
|
|
fd, path = tempfile.mkstemp(suffix=u'morituri.test.empty')
|
|
checksumtask = checksum.ChecksumTask(path)
|
|
# FIXME: do we want a specific error for this ?
|
|
e = self.assertRaises(task.TaskException, self.runner.run,
|
|
checksumtask, verbose=False)
|
|
self.failUnless(isinstance(e.exception, checksum.GstException))
|
|
os.unlink(path)
|
|
|
|
class PathTestCase(common.TestCase):
|
|
def _testSuffix(self, suffix):
|
|
self.runner = task.SyncRunner(verbose=False)
|
|
fd, path = tempfile.mkstemp(suffix=suffix)
|
|
checksumtask = checksum.ChecksumTask(path)
|
|
e = self.assertRaises(task.TaskException, self.runner.run,
|
|
checksumtask, verbose=False)
|
|
self.failUnless(isinstance(e.exception, checksum.GstException))
|
|
os.unlink(path)
|
|
|
|
class UnicodePathTestCase(PathTestCase, common.UnicodeTestMixin):
|
|
def testUnicodePath(self):
|
|
# this test makes sure we can checksum a unicode path
|
|
self._testSuffix(u'morituri.test.B\xeate Noire.empty')
|
|
|
|
class NormalPathTestCase(PathTestCase):
|
|
def testSingleQuote(self):
|
|
self._testSuffix(u"morituri.test.Guns 'N Roses")
|
|
|
|
def testDoubleQuote(self):
|
|
# This test makes sure we can checksum files with double quote in
|
|
# their name
|
|
self._testSuffix(u'morituri.test.12" edit')
|