source: trunk/morituri/test/test_common_checksum.py @ 441

Revision 441, 1.9 KB checked in by thomas, 2 years ago (diff)
  • morituri/common/checksum.py: Actually raise the exception.
  • morituri/common/task.py: Document interface more clearly.
  • morituri/test/test_common_checksum.py: Use tcommon for test.common
Line 
1# -*- Mode: Python; test-case-name: morituri.test.test_common_checksum -*-
2# vi:si:et:sw=4:sts=4:ts=4
3
4import os
5import tempfile
6
7import gobject
8gobject.threads_init()
9
10import gst
11
12from morituri.test import common
13
14from morituri.common import task, checksum, log, common
15from morituri.image import image
16
17from morituri.test import common as tcommon
18
19def h(i):
20    return "0x%08x" % i
21
22class EmptyTestCase(tcommon.TestCase):
23    def testEmpty(self):
24        # this test makes sure that checksumming empty files doesn't hang
25        self.runner = task.SyncRunner(verbose=False)
26        fd, path = tempfile.mkstemp(suffix=u'morituri.test.empty')
27        checksumtask = checksum.ChecksumTask(path) 
28        # FIXME: do we want a specific error for this ?
29        e = self.assertRaises(task.TaskException, self.runner.run,
30            checksumtask, verbose=False)
31        self.failUnless(isinstance(e.exception, checksum.GstException))
32        os.unlink(path)
33
34class PathTestCase(tcommon.TestCase):
35    def _testSuffix(self, suffix):
36        self.runner = task.SyncRunner(verbose=False)
37        fd, path = tempfile.mkstemp(suffix=suffix)
38        checksumtask = checksum.ChecksumTask(path) 
39        e = self.assertRaises(task.TaskException, self.runner.run,
40            checksumtask, verbose=False)
41        self.failUnless(isinstance(e.exception, checksum.GstException))
42        os.unlink(path)
43
44class UnicodePathTestCase(PathTestCase, tcommon.UnicodeTestMixin):
45    def testUnicodePath(self):
46        # this test makes sure we can checksum a unicode path
47        self._testSuffix(u'morituri.test.B\xeate Noire.empty')
48
49class NormalPathTestCase(PathTestCase):
50    def testSingleQuote(self):
51        self._testSuffix(u"morituri.test.Guns 'N Roses")
52
53    def testDoubleQuote(self):
54        # This test makes sure we can checksum files with double quote in
55        # their name
56        self._testSuffix(u'morituri.test.12" edit')
Note: See TracBrowser for help on using the repository browser.