diff --git a/morituri/test/common.py b/morituri/test/common.py index aaa3cdc..ce14663 100644 --- a/morituri/test/common.py +++ b/morituri/test/common.py @@ -13,6 +13,7 @@ log.init() # lifted from flumotion + def _diff(old, new, desc): import difflib lines = difflib.unified_diff(old, new) @@ -37,10 +38,12 @@ def diffStrings(orig, new, desc='input'): _tolines(new), desc=desc) + class TestCase(unittest.TestCase): # unittest.TestCase.failUnlessRaises does not return the exception, # and we'd like to check for the actual exception under TaskException, # so override the way twisted.trial.unittest does, without failure + def failUnlessRaises(self, exception, f, *args, **kwargs): try: result = f(*args, **kwargs) @@ -60,6 +63,7 @@ class TestCase(unittest.TestCase): class UnicodeTestMixin: # A helper mixin to skip tests if we're not in a UTF-8 locale + try: os.stat(u'morituri.test.B\xeate Noire.empty') except UnicodeEncodeError: diff --git a/morituri/test/test_common_accurip.py b/morituri/test/test_common_accurip.py index bd15721..e5e957d 100644 --- a/morituri/test/test_common_accurip.py +++ b/morituri/test/test_common_accurip.py @@ -7,7 +7,9 @@ from morituri.common import accurip from morituri.test import common as tcommon + class AccurateRipResponseTestCase(tcommon.TestCase): + def testResponse(self): path = os.path.join(os.path.dirname(__file__), 'dBAR-011-0010e284-009228a3-9809ff0b.bin') diff --git a/morituri/test/test_common_checksum.py b/morituri/test/test_common_checksum.py index d9e0bb4..0c8b3b7 100644 --- a/morituri/test/test_common_checksum.py +++ b/morituri/test/test_common_checksum.py @@ -13,10 +13,13 @@ 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) @@ -28,7 +31,9 @@ class EmptyTestCase(tcommon.TestCase): 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) @@ -38,12 +43,16 @@ class PathTestCase(tcommon.TestCase): 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") diff --git a/morituri/test/test_common_common.py b/morituri/test/test_common_common.py index a05dce4..7b178b1 100644 --- a/morituri/test/test_common_common.py +++ b/morituri/test/test_common_common.py @@ -7,7 +7,9 @@ from morituri.common import common from morituri.test import common as tcommon + class ShrinkTestCase(tcommon.TestCase): + def testSufjan(self): path = u'morituri/Sufjan Stevens - Illinois/02. Sufjan Stevens - The Black Hawk War, or, How to Demolish an Entire Civilization and Still Feel Good About Yourself in the Morning, or, We Apologize for the Inconvenience but You\'re Going to Have to Leave Now, or, "I Have Fought the Big Knives and Will Continue to Fight Them Until They Are Off Our Lands!".flac' diff --git a/morituri/test/test_common_drive.py b/morituri/test/test_common_drive.py index 8e56be2..4732742 100644 --- a/morituri/test/test_common_drive.py +++ b/morituri/test/test_common_drive.py @@ -4,6 +4,7 @@ from morituri.test import common from morituri.common import drive + class ListifyTestCase(common.TestCase): def testString(self): diff --git a/morituri/test/test_common_encode.py b/morituri/test/test_common_encode.py index 1937a92..5dcee01 100644 --- a/morituri/test/test_common_encode.py +++ b/morituri/test/test_common_encode.py @@ -17,6 +17,7 @@ from morituri.test import common class PathTestCase(common.TestCase): + def _testSuffix(self, suffix): self.runner = task.SyncRunner(verbose=False) fd, path = tempfile.mkstemp(suffix=suffix) @@ -35,19 +36,25 @@ class PathTestCase(common.TestCase): os.unlink(path) os.unlink(path + '.out') + class UnicodePathTestCase(PathTestCase, common.UnicodeTestMixin): + def testUnicodePath(self): # this test makes sure we can checksum a unicode path self._testSuffix(u'.morituri.test_encode.B\xeate Noire') + class NormalPathTestCase(PathTestCase): + def testSingleQuote(self): self._testSuffix(u".morituri.test_encode.Guns 'N Roses") def testDoubleQuote(self): self._testSuffix(u'.morituri.test_encode.12" edit') + class TagReadTestCase(common.TestCase): + def testRead(self): path = os.path.join(os.path.dirname(__file__), u'track.flac') self.runner = task.SyncRunner(verbose=False) @@ -57,7 +64,9 @@ class TagReadTestCase(common.TestCase): self.assertEquals(t.taglist['audio-codec'], 'FLAC') self.assertEquals(t.taglist['description'], 'audiotest wave') + class TagWriteTestCase(common.TestCase): + def testWrite(self): fd, inpath = tempfile.mkstemp(suffix=u'.morituri.tagwrite.flac') @@ -92,7 +101,9 @@ class TagWriteTestCase(common.TestCase): os.unlink(inpath) os.unlink(outpath) + class SafeRetagTestCase(common.TestCase): + def setUp(self): self._fd, self._path = tempfile.mkstemp(suffix=u'.morituri.retag.flac') diff --git a/morituri/test/test_common_musicbrainz.py b/morituri/test/test_common_musicbrainz.py index 73a0735..ba5b894 100644 --- a/morituri/test/test_common_musicbrainz.py +++ b/morituri/test/test_common_musicbrainz.py @@ -9,6 +9,7 @@ from morituri.common import musicbrainz class MetadataLengthTestCase(unittest.TestCase): + def testLamprey(self): from musicbrainz2 import wsxml diff --git a/morituri/test/test_common_musicbrainzngs.py b/morituri/test/test_common_musicbrainzngs.py index 51446eb..53627e3 100644 --- a/morituri/test/test_common_musicbrainzngs.py +++ b/morituri/test/test_common_musicbrainzngs.py @@ -10,6 +10,7 @@ from morituri.common import musicbrainzngs class MetadataTestCase(unittest.TestCase): + def testJeffEverybodySingle(self): path = os.path.join(os.path.dirname(__file__), 'morituri.release.3451f29c-9bb8-4cc5-bfcc-bd50104b94f8.json') diff --git a/morituri/test/test_common_program.py b/morituri/test/test_common_program.py index 039f77c..7b49fb1 100644 --- a/morituri/test/test_common_program.py +++ b/morituri/test/test_common_program.py @@ -67,7 +67,9 @@ class TrackImageVerifyTestCase(unittest.TestCase): "Track 10: rip NOT accurate (max confidence 2) " "[16457a5a], DB [eb6e55b4]") + class HTOATestCase(unittest.TestCase): + def setUp(self): path = os.path.join(os.path.dirname(__file__), 'silentalarm.result.pickle') @@ -82,6 +84,7 @@ class HTOATestCase(unittest.TestCase): class PathTestCase(unittest.TestCase): + def testStandardTemplateEmpty(self): prog = program.Program()