read cue and substitute current version to make tests pass

This commit is contained in:
Thomas Vander Stichele
2014-05-26 15:39:58 -04:00
parent f5fac325d2
commit 5b0ca8526d
2 changed files with 18 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import re
import os
import sys
@@ -8,6 +9,7 @@ import sys
from twisted.trial import unittest
from morituri.common import log
from morituri.configure import configure
log.init()
@@ -63,6 +65,19 @@ class TestCase(log.Loggable, unittest.TestCase):
assertRaises = failUnlessRaises
def readCue(self, name):
"""
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')
ret = re.sub(
'REM COMMENT "Morituri.*',
'REM COMMENT "Morituri %s"' % (configure.version),
ret, re.MULTILINE)
return ret
class UnicodeTestMixin:
# A helper mixin to skip tests if we're not in a UTF-8 locale

View File

@@ -88,8 +88,7 @@ class CureTestCase(common.TestCase):
def testConvertCue(self):
# self.toc.table.absolutize()
cue = self.toc.table.cue()
ref = open(os.path.join(os.path.dirname(__file__), 'cure.cue')).read(
).decode('utf-8')
ref = self.readCue('cure.cue')
common.diffStrings(ref, cue)
# we verify it because it has failed in readdisc in the past
@@ -159,8 +158,7 @@ class BlocTestCase(common.TestCase):
#self.toc.table.absolutize()
self.failUnless(self.toc.table.hasTOC())
cue = self.toc.table.cue()
ref = open(os.path.join(os.path.dirname(__file__),
'bloc.cue')).read().decode('utf-8')
ref = self.readCue('bloc.cue')
common.diffStrings(ref, cue)
def testCDDBId(self):
@@ -204,8 +202,7 @@ class BreedersTestCase(common.TestCase):
# self.toc.table.absolutize()
self.failUnless(self.toc.table.hasTOC())
cue = self.toc.table.cue()
ref = open(os.path.join(os.path.dirname(__file__),
'breeders.cue')).read()
ref = self.readCue('breeders.cue')
self.assertEquals(cue, ref)
# Ladyhawke has a data track