From 5b0ca8526d4820446ea8d2d0cf3e941a037c0e3a Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Mon, 26 May 2014 15:39:58 -0400 Subject: [PATCH] read cue and substitute current version to make tests pass --- morituri/test/common.py | 15 +++++++++++++++ morituri/test/test_image_toc.py | 9 +++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/morituri/test/common.py b/morituri/test/common.py index 955db36..aebf004 100644 --- a/morituri/test/common.py +++ b/morituri/test/common.py @@ -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 diff --git a/morituri/test/test_image_toc.py b/morituri/test/test_image_toc.py index 998bc0a..7fe79bc 100644 --- a/morituri/test/test_image_toc.py +++ b/morituri/test/test_image_toc.py @@ -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