Solve all flake8 warnings (#163)

Whipper is now fully PEP8 compliant.
Revised version which includes all the changes suggested by Freso.
This commit is contained in:
JoeLametta
2017-05-31 23:09:36 +02:00
committed by GitHub
parent b331f53b47
commit b6fb7e8a86
49 changed files with 614 additions and 539 deletions

View File

@@ -53,12 +53,12 @@ class TestCase(unittest.TestCase):
return inst
except exception, e:
raise Exception('%s raised instead of %s:\n %s' %
(sys.exec_info()[0], exception.__name__, str(e))
)
(sys.exec_info()[0], exception.__name__, str(e))
)
else:
raise Exception('%s not raised (%r returned)' %
(exception.__name__, result)
)
(exception.__name__, result)
)
assertRaises = failUnlessRaises
@@ -67,8 +67,8 @@ class TestCase(unittest.TestCase):
Read a .cue file, and replace the version comment with the current
version so we can use it in comparisons.
"""
ret = open(os.path.join(os.path.dirname(__file__), name)).read(
).decode('utf-8')
cuefile = os.path.join(os.path.dirname(__file__), name)
ret = open(cuefile).read().decode('utf-8')
ret = re.sub(
'REM COMMENT "whipper.*',
'REM COMMENT "whipper %s"' % (whipper.__version__),
@@ -76,6 +76,7 @@ class TestCase(unittest.TestCase):
return ret
class UnicodeTestMixin:
# A helper mixin to skip tests if we're not in a UTF-8 locale

View File

@@ -12,13 +12,12 @@ class AccurateRipResponseTestCase(tcommon.TestCase):
def testResponse(self):
path = os.path.join(os.path.dirname(__file__),
'dBAR-011-0010e284-009228a3-9809ff0b.bin')
'dBAR-011-0010e284-009228a3-9809ff0b.bin')
data = open(path, "rb").read()
responses = accurip.getAccurateRipResponses(data)
self.assertEquals(len(responses), 3)
response = responses[0]
self.assertEquals(response.trackCount, 11)

View File

@@ -13,12 +13,12 @@ class ShrinkTestCase(tcommon.TestCase):
def testSufjan(self):
path = (u'whipper/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')
'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')
shorter = common.shrinkPath(path)
self.failUnless(os.path.splitext(path)[0].startswith(
@@ -46,7 +46,7 @@ class GetRelativePathTestCase(tcommon.TestCase):
track = './' + directory + '/01. Placebo - Taste in Men.flac'
self.assertEquals(common.getRelativePath(track, cue),
'01. Placebo - Taste in Men.flac')
'01. Placebo - Taste in Men.flac')
class GetRealPathTestCase(tcommon.TestCase):
@@ -56,12 +56,12 @@ class GetRealPathTestCase(tcommon.TestCase):
refPath = os.path.join(os.path.dirname(path), 'fake.cue')
self.assertEquals(common.getRealPath(refPath, path),
path)
path)
# same path, but with wav extension, will point to flac file
wavPath = path[:-4] + 'wav'
self.assertEquals(common.getRealPath(refPath, wavPath),
path)
path)
os.close(fd)
os.unlink(path)

View File

@@ -20,24 +20,24 @@ class ConfigTestCase(tcommon.TestCase):
os.unlink(self._path)
def testAddReadOffset(self):
self.assertRaises(KeyError,
self._config.getReadOffset, 'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self.assertRaises(KeyError, self._config.getReadOffset,
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self._config.setReadOffset('PLEXTOR ', 'DVDR PX-L890SA', '1.05', 6)
# getting it from memory should work
offset = self._config.getReadOffset('PLEXTOR ', 'DVDR PX-L890SA',
'1.05')
offset = self._config.getReadOffset(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self.assertEquals(offset, 6)
# and so should getting it after reading it again
self._config.open()
offset = self._config.getReadOffset('PLEXTOR ', 'DVDR PX-L890SA',
'1.05')
offset = self._config.getReadOffset(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self.assertEquals(offset, 6)
def testAddReadOffsetSpaced(self):
self.assertRaises(KeyError,
self._config.getReadOffset, 'Slimtype', 'eSAU208 2 ', 'ML03')
self.assertRaises(KeyError, self._config.getReadOffset,
'Slimtype', 'eSAU208 2 ', 'ML03')
self._config.setReadOffset('Slimtype', 'eSAU208 2 ', 'ML03', 6)
# getting it from memory should work
@@ -53,7 +53,7 @@ class ConfigTestCase(tcommon.TestCase):
def testDefeatsCache(self):
self.assertRaises(KeyError, self._config.getDefeatsCache,
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
'PLEXTOR ', 'DVDR PX-L890SA', '1.05')
self._config.setDefeatsCache(
'PLEXTOR ', 'DVDR PX-L890SA', '1.05', False)

View File

@@ -13,8 +13,8 @@ class MetadataTestCase(unittest.TestCase):
# Generated with rip -R cd info
def testJeffEverybodySingle(self):
path = os.path.join(os.path.dirname(__file__),
'whipper.release.3451f29c-9bb8-4cc5-bfcc-bd50104b94f8.json')
filename = 'whipper.release.3451f29c-9bb8-4cc5-bfcc-bd50104b94f8.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
handle.close()
@@ -26,8 +26,8 @@ class MetadataTestCase(unittest.TestCase):
def test2MeterSessies10(self):
# various artists, multiple artists per track
path = os.path.join(os.path.dirname(__file__),
'whipper.release.a76714e0-32b1-4ed4-b28e-f86d99642193.json')
filename = 'whipper.release.a76714e0-32b1-4ed4-b28e-f86d99642193.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
handle.close()
@@ -38,7 +38,7 @@ class MetadataTestCase(unittest.TestCase):
self.assertEquals(metadata.artist, u'Various Artists')
self.assertEquals(metadata.release, u'2001-10-15')
self.assertEquals(metadata.mbidArtist,
u'89ad4ac3-39f7-470e-963a-56509c546377')
u'89ad4ac3-39f7-470e-963a-56509c546377')
self.assertEquals(len(metadata.tracks), 18)
@@ -46,16 +46,16 @@ class MetadataTestCase(unittest.TestCase):
self.assertEquals(track16.artist, 'Tom Jones & Stereophonics')
self.assertEquals(track16.mbidArtist,
u'57c6f649-6cde-48a7-8114-2a200247601a'
';0bfba3d3-6a04-4779-bb0a-df07df5b0558'
)
u'57c6f649-6cde-48a7-8114-2a200247601a'
';0bfba3d3-6a04-4779-bb0a-df07df5b0558'
)
self.assertEquals(track16.sortName,
u'Jones, Tom & Stereophonics')
u'Jones, Tom & Stereophonics')
def testBalladOfTheBrokenSeas(self):
# various artists disc
path = os.path.join(os.path.dirname(__file__),
'whipper.release.e32ae79a-336e-4d33-945c-8c5e8206dbd3.json')
filename = 'whipper.release.e32ae79a-336e-4d33-945c-8c5e8206dbd3.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
handle.close()
@@ -65,11 +65,11 @@ class MetadataTestCase(unittest.TestCase):
self.assertEquals(metadata.artist, u'Isobel Campbell & Mark Lanegan')
self.assertEquals(metadata.sortName,
u'Campbell, Isobel & Lanegan, Mark')
u'Campbell, Isobel & Lanegan, Mark')
self.assertEquals(metadata.release, u'2006-01-30')
self.assertEquals(metadata.mbidArtist,
u'd51f3a15-12a2-41a0-acfa-33b5eae71164;'
'a9126556-f555-4920-9617-6e013f8228a7')
u'd51f3a15-12a2-41a0-acfa-33b5eae71164;'
'a9126556-f555-4920-9617-6e013f8228a7')
self.assertEquals(len(metadata.tracks), 12)
@@ -77,18 +77,18 @@ class MetadataTestCase(unittest.TestCase):
self.assertEquals(track12.artist, u'Isobel Campbell & Mark Lanegan')
self.assertEquals(track12.sortName,
u'Campbell, Isobel'
' & Lanegan, Mark'
)
u'Campbell, Isobel'
' & Lanegan, Mark'
)
self.assertEquals(track12.mbidArtist,
u'd51f3a15-12a2-41a0-acfa-33b5eae71164;'
'a9126556-f555-4920-9617-6e013f8228a7')
u'd51f3a15-12a2-41a0-acfa-33b5eae71164;'
'a9126556-f555-4920-9617-6e013f8228a7')
def testMalaInCuba(self):
# single artist disc, but with multiple artists tracks
# see https://github.com/thomasvs/morituri/issues/19
path = os.path.join(os.path.dirname(__file__),
'whipper.release.61c6fd9b-18f8-4a45-963a-ba3c5d990cae.json')
filename = 'whipper.release.61c6fd9b-18f8-4a45-963a-ba3c5d990cae.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
handle.close()
@@ -100,7 +100,7 @@ class MetadataTestCase(unittest.TestCase):
self.assertEquals(metadata.sortName, u'Mala')
self.assertEquals(metadata.release, u'2012-09-17')
self.assertEquals(metadata.mbidArtist,
u'09f221eb-c97e-4da5-ac22-d7ab7c555bbb')
u'09f221eb-c97e-4da5-ac22-d7ab7c555bbb')
self.assertEquals(len(metadata.tracks), 14)
@@ -108,9 +108,9 @@ class MetadataTestCase(unittest.TestCase):
self.assertEquals(track6.artist, u'Mala feat. Dreiser & Sexto Sentido')
self.assertEquals(track6.sortName,
u'Mala feat. Dreiser & Sexto Sentido')
u'Mala feat. Dreiser & Sexto Sentido')
self.assertEquals(track6.mbidArtist,
u'09f221eb-c97e-4da5-ac22-d7ab7c555bbb'
';ec07a209-55ff-4084-bc41-9d4d1764e075'
';f626b92e-07b1-4a19-ad13-c09d690db66c'
)
u'09f221eb-c97e-4da5-ac22-d7ab7c555bbb'
';ec07a209-55ff-4084-bc41-9d4d1764e075'
';f626b92e-07b1-4a19-ad13-c09d690db66c'
)

View File

@@ -22,9 +22,9 @@ class FilterTestCase(common.TestCase):
def testSpecial(self):
part = u'<<< $&*!\' "()`{}[]spaceship>>>'
self.assertEquals(self._filter.filter(part),
u'___ _____ ________spaceship___')
u'___ _____ ________spaceship___')
def testGreatest(self):
part = u'Greatest Ever! Soul: The Definitive Collection'
self.assertEquals(self._filter.filter(part),
u'Greatest Ever_ Soul - The Definitive Collection')
u'Greatest Ever_ Soul - The Definitive Collection')

View File

@@ -19,15 +19,16 @@ class TrackImageVerifyTestCase(unittest.TestCase):
def testVerify(self):
path = os.path.join(os.path.dirname(__file__),
'dBAR-020-002e5023-029d8e49-040eaa14.bin')
'dBAR-020-002e5023-029d8e49-040eaa14.bin')
data = open(path, "rb").read()
responses = accurip.getAccurateRipResponses(data)
# these crc's were calculated from an actual rip
checksums = [1644890007, 2945205445, 3983436658, 1528082495,
1203704270, 1163423644, 3649097244, 100524219, 1583356174, 373652058,
1842579359, 2850056507, 1329730252, 2526965856, 2525886806, 209743350,
3184062337, 2099956663, 2943874164, 2321637196]
1203704270, 1163423644, 3649097244, 100524219,
1583356174, 373652058, 1842579359, 2850056507,
1329730252, 2526965856, 2525886806, 209743350,
3184062337, 2099956663, 2943874164, 2321637196]
prog = program.Program(config.Config())
prog.result = result.RipResult()
@@ -59,21 +60,21 @@ class TrackImageVerifyTestCase(unittest.TestCase):
res = prog.getAccurateRipResults()
self.assertEquals(res[1 - 1],
"Track 1: rip NOT accurate (not found) "
"[620b0797], DB [notfound]")
"Track 1: rip NOT accurate (not found) "
"[620b0797], DB [notfound]")
self.assertEquals(res[2 - 1],
"Track 2: rip accurate (max confidence 2) "
"[af8c44c5], DB [af8c44c5]")
"Track 2: rip accurate (max confidence 2) "
"[af8c44c5], DB [af8c44c5]")
self.assertEquals(res[10 - 1],
"Track 10: rip NOT accurate (max confidence 2) "
"[16457a5a], DB [eb6e55b4]")
"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')
'silentalarm.result.pickle')
self._tracks = pickle.load(open(path, 'rb'))
def testGetAccurateRipResults(self):
@@ -90,9 +91,10 @@ class PathTestCase(unittest.TestCase):
prog = program.Program(config.Config())
path = prog.getPath(u'/tmp', DEFAULT_DISC_TEMPLATE,
'mbdiscid', 0)
'mbdiscid', 0)
self.assertEquals(path,
u'/tmp/unknown/Unknown Artist - mbdiscid/Unknown Artist - mbdiscid')
unicode('/tmp/unknown/Unknown Artist - mbdiscid/'
'Unknown Artist - mbdiscid'))
def testStandardTemplateFilled(self):
prog = program.Program(config.Config())
@@ -102,9 +104,10 @@ class PathTestCase(unittest.TestCase):
prog.metadata = md
path = prog.getPath(u'/tmp', DEFAULT_DISC_TEMPLATE,
'mbdiscid', 0)
'mbdiscid', 0)
self.assertEquals(path,
u'/tmp/unknown/Jeff Buckley - Grace/Jeff Buckley - Grace')
unicode('/tmp/unknown/Jeff Buckley - Grace/'
'Jeff Buckley - Grace'))
def testIssue66TemplateFilled(self):
prog = program.Program(config.Config())
@@ -115,4 +118,4 @@ class PathTestCase(unittest.TestCase):
path = prog.getPath(u'/tmp', u'%A/%d', 'mbdiscid', 0)
self.assertEquals(path,
u'/tmp/Jeff Buckley/Grace')
u'/tmp/Jeff Buckley/Grace')

View File

@@ -11,11 +11,12 @@ from whipper.image import table, cue
from whipper.test import common
class KingsSingleTestCase(unittest.TestCase):
def setUp(self):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
u'kings-single.cue'))
u'kings-single.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.table.tracks), 11)
@@ -31,7 +32,7 @@ class KingsSeparateTestCase(unittest.TestCase):
def setUp(self):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
u'kings-separate.cue'))
u'kings-separate.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.table.tracks), 11)
@@ -47,7 +48,7 @@ class KanyeMixedTestCase(unittest.TestCase):
def setUp(self):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
u'kanye.cue'))
u'kanye.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.table.tracks), 13)
@@ -70,7 +71,7 @@ class WriteCueFileTestCase(unittest.TestCase):
t = table.Track(2)
t.index(0, absolute=1000, path=u'track01.wav',
relative=1000, counter=1)
relative=1000, counter=1)
t.index(1, absolute=2000, path=u'track02.wav', relative=0, counter=2)
it.tracks.append(t)
it.absolutize()

View File

@@ -36,7 +36,7 @@ class LadyhawkeTestCase(tcommon.TestCase):
self.table.tracks.append(table.Track(13, audio=False))
offsets = [0, 15537, 31691, 50866, 66466, 81202, 99409,
115920, 133093, 149847, 161560, 177682, 207106]
115920, 133093, 149847, 161560, 177682, 207106]
t = self.table.tracks
for i, offset in enumerate(offsets):
t[i].index(1, absolute=offset)
@@ -59,14 +59,14 @@ class LadyhawkeTestCase(tcommon.TestCase):
# however, not (yet) in MusicBrainz database
self.assertEquals(self.table.getMusicBrainzDiscId(),
"KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
"KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
def testAccurateRip(self):
self.assertEquals(self.table.getAccurateRipIds(), (
"0013bd5a", "00b8d489"))
self.assertEquals(self.table.getAccurateRipURL(),
"http://www.accuraterip.com/accuraterip/a/5/d/"
"dBAR-012-0013bd5a-00b8d489-c60af50d.bin")
"http://www.accuraterip.com/accuraterip/a/5/d/"
"dBAR-012-0013bd5a-00b8d489-c60af50d.bin")
def testDuration(self):
self.assertEquals(self.table.duration(), 2761413)
@@ -95,7 +95,7 @@ class MusicBrainzTestCase(tcommon.TestCase):
def testMusicBrainz(self):
self.assertEquals(self.table.getMusicBrainzDiscId(),
'49HHV7Eb8UKF3aQiNmu1GR8vKTY-')
'49HHV7Eb8UKF3aQiNmu1GR8vKTY-')
class PregapTestCase(tcommon.TestCase):

View File

@@ -14,8 +14,7 @@ from whipper.test import common
class CureTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'cure.toc')
self.path = os.path.join(os.path.dirname(__file__), u'cure.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 13)
@@ -26,7 +25,7 @@ class CureTestCase(common.TestCase):
# its length is all of track 1 from .toc, plus the INDEX 00 length
# of track 2
self.assertEquals(self.toc.getTrackLength(t),
(((6 * 60) + 16) * 75 + 45) + ((1 * 75) + 4))
(((6 * 60) + 16) * 75 + 45) + ((1 * 75) + 4))
# last track has unknown length
t = self.toc.table.tracks[-1]
self.assertEquals(self.toc.getTrackLength(t), -1)
@@ -91,8 +90,7 @@ class CureTestCase(common.TestCase):
# we verify it because it has failed in readdisc in the past
self.assertEquals(self.toc.table.getAccurateRipURL(),
'http://www.accuraterip.com/accuraterip/'
'3/c/4/dBAR-013-0019d4c3-00fe8924-b90c650d.bin')
'http://www.accuraterip.com/accuraterip/3/c/4/dBAR-013-0019d4c3-00fe8924-b90c650d.bin') # noqa: E501
def testGetRealPath(self):
self.assertRaises(KeyError, self.toc.getRealPath, u'track01.wav')
@@ -110,8 +108,7 @@ class CureTestCase(common.TestCase):
class BlocTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'bloc.toc')
self.path = os.path.join(os.path.dirname(__file__), u'bloc.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 13)
@@ -168,8 +165,7 @@ class BlocTestCase(common.TestCase):
def testAccurateRip(self):
# we verify it because it has failed in readdisc in the past
self.assertEquals(self.toc.table.getAccurateRipURL(),
'http://www.accuraterip.com/accuraterip/'
'e/d/2/dBAR-013-001af2de-0105994e-ad0be00d.bin')
'http://www.accuraterip.com/accuraterip/e/d/2/dBAR-013-001af2de-0105994e-ad0be00d.bin') # noqa: E501
# The Breeders - Mountain Battles has CDText
@@ -177,8 +173,7 @@ class BlocTestCase(common.TestCase):
class BreedersTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'breeders.toc')
self.path = os.path.join(os.path.dirname(__file__), u'breeders.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 13)
@@ -194,7 +189,6 @@ class BreedersTestCase(common.TestCase):
self.assertEquals(cdt['TITLE'], 'OVERGLAZED')
def testConvertCue(self):
# self.toc.table.absolutize()
self.failUnless(self.toc.table.hasTOC())
cue = self.toc.table.cue()
ref = self.readCue('breeders.cue')
@@ -206,8 +200,7 @@ class BreedersTestCase(common.TestCase):
class LadyhawkeTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'ladyhawke.toc')
self.path = os.path.join(os.path.dirname(__file__), u'ladyhawke.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 13)
@@ -221,12 +214,9 @@ class LadyhawkeTestCase(common.TestCase):
def testMusicBrainz(self):
self.assertEquals(self.toc.table.getMusicBrainzDiscId(),
"KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
"KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
self.assertEquals(self.toc.table.getMusicBrainzSubmitURL(),
"https://musicbrainz.org/cdtoc/attach?toc="
"1+12+195856+150+15687+31841+51016+66616+81352+99559+"
"116070+133243+149997+161710+177832&"
"tracks=12&id=KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
"https://musicbrainz.org/cdtoc/attach?toc=1+12+195856+150+15687+31841+51016+66616+81352+99559+116070+133243+149997+161710+177832&tracks=12&id=KnpGsLhvH.lPrNc1PBL21lb9Bg4-") # noqa: E501
# FIXME: I don't trust this toc, but I can't find the CD anymore
@@ -247,13 +237,13 @@ class CapitalMergeTestCase(common.TestCase):
def setUp(self):
self.toc1 = toc.TocFile(os.path.join(os.path.dirname(__file__),
u'capital.1.toc'))
u'capital.1.toc'))
self.toc1.parse()
self.assertEquals(len(self.toc1.table.tracks), 11)
self.failUnless(self.toc1.table.tracks[-1].audio)
self.toc2 = toc.TocFile(os.path.join(os.path.dirname(__file__),
u'capital.2.toc'))
u'capital.2.toc'))
self.toc2.parse()
self.assertEquals(len(self.toc2.table.tracks), 1)
self.failIf(self.toc2.table.tracks[-1].audio)
@@ -272,7 +262,7 @@ class CapitalMergeTestCase(common.TestCase):
# 197850+24320+44855+64090+77885+88095+104020+118245+129255+141765+
# 164487+181780&tracks=11&id=MAj3xXf6QMy7G.BIFOyHyq4MySE-
self.assertEquals(self.table.getMusicBrainzDiscId(),
"MAj3xXf6QMy7G.BIFOyHyq4MySE-")
"MAj3xXf6QMy7G.BIFOyHyq4MySE-")
def testDuration(self):
# this matches track 11 end sector - track 1 start sector on
@@ -321,8 +311,7 @@ class UnicodeTestCase(common.TestCase, common.UnicodeTestMixin):
class TOTBLTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'totbl.fast.toc')
self.path = os.path.join(os.path.dirname(__file__), u'totbl.fast.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 11)
@@ -338,7 +327,7 @@ class StrokesTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'strokes-someday.toc')
u'strokes-someday.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 1)
@@ -358,14 +347,16 @@ class StrokesTestCase(common.TestCase):
self.assertEquals(i1.path, u'data.wav')
cue = self._filterCue(self.toc.table.cue())
ref = self._filterCue(open(os.path.join(os.path.dirname(__file__),
'strokes-someday.eac.cue')).read()).decode('utf-8')
ref = self._filterCue(
open(os.path.join(
os.path.dirname(__file__),
'strokes-someday.eac.cue')).read()).decode('utf-8')
common.diffStrings(ref, cue)
def _filterCue(self, output):
# helper to be able to compare our generated .cue with the
# EAC-extracted one
discard = [ 'TITLE', 'PERFORMER', 'FLAGS', 'REM' ]
discard = ['TITLE', 'PERFORMER', 'FLAGS', 'REM']
lines = output.split('\n')
res = []
@@ -385,21 +376,16 @@ class StrokesTestCase(common.TestCase):
return '\n'.join(res)
# Surfer Rosa has
# track 00 consisting of 32 frames of SILENCE
# track 11 Vamos with an INDEX 02
# compared to an EAC single .cue file, all our offsets are 32 frames off
# because the toc uses silence for track 01 index 00 while EAC puts it in
# Range.wav
class SurferRosaTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__),
u'surferrosa.toc')
self.path = os.path.join(os.path.dirname(__file__), u'surferrosa.toc')
self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 21)

View File

@@ -15,7 +15,7 @@ class ParseTestCase(common.TestCase):
def setUp(self):
# report from Afghan Whigs - Sweet Son Of A Bitch
path = os.path.join(os.path.dirname(__file__),
'cdparanoia.progress')
'cdparanoia.progress')
self._parser = cdparanoia.ProgressParser(start=45990, stop=47719)
self._handle = open(path)
@@ -27,11 +27,12 @@ class ParseTestCase(common.TestCase):
q = '%.01f %%' % (self._parser.getTrackQuality() * 100.0, )
self.assertEquals(q, '99.6 %')
class Parse1FrameTestCase(common.TestCase):
def setUp(self):
path = os.path.join(os.path.dirname(__file__),
'cdparanoia.progress.strokes')
'cdparanoia.progress.strokes')
self._parser = cdparanoia.ProgressParser(start=0, stop=0)
self._handle = open(path)
@@ -49,7 +50,7 @@ class ErrorTestCase(common.TestCase):
def setUp(self):
# report from a rip with offset -1164 causing scsi errors
path = os.path.join(os.path.dirname(__file__),
'cdparanoia.progress.error')
'cdparanoia.progress.error')
self._parser = cdparanoia.ProgressParser(start=0, stop=10800)
self._handle = open(path)
@@ -87,7 +88,7 @@ class CacheTestCase(common.TestCase):
self.runner = task.SyncRunner(verbose=False)
path = os.path.join(os.path.dirname(__file__),
'cdparanoia', 'PX-L890SA.cdparanoia-A.stderr')
'cdparanoia', 'PX-L890SA.cdparanoia-A.stderr')
t = AnalyzeFileTask(path)
self.runner.run(t)
self.failUnless(t.defeatsCache)

View File

@@ -1,14 +1,12 @@
# -*- Mode: Python; test-case-name: whipper.test.test_program_cdparanoia -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
from whipper.program import cdrdao
from whipper.test import common
# TODO: Current test architecture makes testing cdrdao difficult. Revisit.
class VersionTestCase(common.TestCase):
def testGetVersion(self):
v = cdrdao.getCDRDAOVersion()

View File

@@ -5,6 +5,7 @@ import os
from whipper.program import sox
from whipper.test import common
class PeakLevelTestCase(common.TestCase):
def setUp(self):
self.path = os.path.join(os.path.dirname(__file__), 'track.flac')

View File

@@ -11,6 +11,7 @@ from whipper.test import common as tcommon
base_track_file = os.path.join(os.path.dirname(__file__), u'track.flac')
base_track_length = 10 * common.SAMPLES_PER_FRAME
class AudioLengthTestCase(tcommon.TestCase):
def testLength(self):
@@ -34,6 +35,7 @@ class AudioLengthPathTestCase(tcommon.TestCase):
self.assertEquals(t.length, base_track_length)
os.unlink(path)
class NormalAudioLengthPathTestCase(AudioLengthPathTestCase):
def testSingleQuote(self):
@@ -46,12 +48,13 @@ class NormalAudioLengthPathTestCase(AudioLengthPathTestCase):
class UnicodeAudioLengthPathTestCase(AudioLengthPathTestCase,
tcommon.UnicodeTestMixin):
tcommon.UnicodeTestMixin):
def testUnicodePath(self):
# this test makes sure we can checksum a unicode path
self._testSuffix(u'whipper.test.B\xeate Noire.empty.flac')
class AbsentFileAudioLengthPathTestCase(AudioLengthPathTestCase):
def testAbsentFile(self):
tempdir = tempfile.mkdtemp()
@@ -60,6 +63,6 @@ class AbsentFileAudioLengthPathTestCase(AudioLengthPathTestCase):
t = AudioLengthTask(path)
runner = task.SyncRunner()
self.assertRaises(task.TaskException, runner.run,
t, verbose=False)
t, verbose=False)
os.rmdir(tempdir)