pep8 fixes

This commit is contained in:
Thomas Vander Stichele
2012-11-11 22:45:41 +00:00
parent 4a4e1ba128
commit 6adf75a832
9 changed files with 34 additions and 0 deletions

View File

@@ -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:

View File

@@ -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')

View File

@@ -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")

View File

@@ -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'

View File

@@ -4,6 +4,7 @@
from morituri.test import common
from morituri.common import drive
class ListifyTestCase(common.TestCase):
def testString(self):

View File

@@ -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')

View File

@@ -9,6 +9,7 @@ from morituri.common import musicbrainz
class MetadataLengthTestCase(unittest.TestCase):
def testLamprey(self):
from musicbrainz2 import wsxml

View File

@@ -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')

View File

@@ -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()