Files
whipper-gui/morituri/test/test_common_checksum.py
Thomas Vander Stichele 798a209195 * morituri/extern/task (added):
* morituri/extern/task/taskgtk.py (added):
	* morituri/extern/task/gstreamer.py (added):
	* morituri/extern/task/task.py (added):
	* morituri/common/taskgtk.py (deleted):
	* morituri/common/gstreamer.py (deleted):
	* morituri/common/task.py (deleted):
	  Move task-related modules into an extern directory so other
	  projects can use them.
	* morituri/common/checksum.py:
	* morituri/common/encode.py:
	* morituri/image/image.py:
	* morituri/program/cdparanoia.py:
	* morituri/program/cdrdao.py:
	* morituri/rip/cd.py:
	* morituri/rip/debug.py:
	* morituri/rip/image.py:
	* morituri/rip/main.py:
	* morituri/rip/offset.py:
	* morituri/test/test_common_checksum.py:
	* morituri/test/test_common_encode.py:
	* morituri/test/test_image_image.py:
	  Adapt.  Tests work.
2011-08-05 18:50:51 +00:00

54 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()
from morituri.common import checksum, log
from morituri.extern.task import task, gstreamer
from morituri.test import common as tcommon
def h(i):
return "0x%08x" % i
class EmptyTestCase(tcommon.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, gstreamer.GstException))
os.unlink(path)
class PathTestCase(tcommon.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, gstreamer.GstException))
os.unlink(path)
class UnicodePathTestCase(PathTestCase, tcommon.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')