* morituri/test/Makefile.am:
* morituri/test/jose.toc (added): * morituri/test/JoséGonzález.toc (deleted): Rename utf-8 file to a normal file. * morituri/test/common.py: * morituri/test/test_common_checksum.py: * morituri/test/test_common_encode.py: * morituri/test/test_image_image.py: * morituri/test/test_image_toc.py: Copy the normal file first to the utf-8 filename, if supported. Skip tests that need unicode when we are not in a utf-8 locale.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
||||
2010-04-18 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/test/Makefile.am:
|
||||
* morituri/test/jose.toc (added):
|
||||
* morituri/test/JoséGonzález.toc (deleted):
|
||||
Rename utf-8 file to a normal file.
|
||||
* morituri/test/common.py:
|
||||
* morituri/test/test_common_checksum.py:
|
||||
* morituri/test/test_common_encode.py:
|
||||
* morituri/test/test_image_image.py:
|
||||
* morituri/test/test_image_toc.py:
|
||||
Copy the normal file first to the utf-8 filename, if supported.
|
||||
Skip tests that need unicode when we are not in a utf-8 locale.
|
||||
|
||||
2010-04-17 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* configure.ac:
|
||||
|
||||
@@ -22,7 +22,7 @@ EXTRA_DIST = \
|
||||
capital.2.toc \
|
||||
cure.cue \
|
||||
cure.toc \
|
||||
JoséGonzález.toc \
|
||||
jose.toc \
|
||||
dBAR-011-0010e284-009228a3-9809ff0b.bin \
|
||||
dBAR-020-002e5023-029d8e49-040eaa14.bin \
|
||||
kanye.cue \
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
# -*- Mode: Python -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
# twisted's unittests have skip support, standard unittest don't
|
||||
from twisted.trial import unittest
|
||||
|
||||
from morituri.common import log
|
||||
|
||||
@@ -53,3 +56,13 @@ class TestCase(unittest.TestCase):
|
||||
% (exception.__name__, result))
|
||||
|
||||
assertRaises = failUnlessRaises
|
||||
|
||||
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:
|
||||
skip = 'No UTF-8 locale'
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -40,10 +40,12 @@ class PathTestCase(common.TestCase):
|
||||
self.failUnless(isinstance(e.exception, gst.QueryError))
|
||||
os.unlink(path)
|
||||
|
||||
class UnicodePathTestCase(PathTestCase, common.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")
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ from morituri.test import common
|
||||
|
||||
from morituri.common import task, encode, log
|
||||
|
||||
from morituri.test import common
|
||||
|
||||
class PathTestCase(common.TestCase):
|
||||
def _testSuffix(self, suffix):
|
||||
self.runner = task.SyncRunner(verbose=False)
|
||||
@@ -30,10 +28,12 @@ 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")
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import gobject
|
||||
gobject.threads_init()
|
||||
@@ -19,7 +18,7 @@ log.init()
|
||||
def h(i):
|
||||
return "0x%08x" % i
|
||||
|
||||
class TrackSingleTestCase(unittest.TestCase):
|
||||
class TrackSingleTestCase(tcommon.TestCase):
|
||||
def setUp(self):
|
||||
self.image = image.Image(os.path.join(os.path.dirname(__file__),
|
||||
u'track-single.cue'))
|
||||
@@ -49,7 +48,7 @@ class TrackSingleTestCase(unittest.TestCase):
|
||||
self.assertEquals(self.image.table.getAccurateRipIds(), (
|
||||
"00000016", "0000005b"))
|
||||
|
||||
class TrackSeparateTestCase(unittest.TestCase):
|
||||
class TrackSeparateTestCase(tcommon.TestCase):
|
||||
def setUp(self):
|
||||
self.image = image.Image(os.path.join(os.path.dirname(__file__),
|
||||
u'track-separate.cue'))
|
||||
@@ -79,7 +78,7 @@ class TrackSeparateTestCase(unittest.TestCase):
|
||||
self.assertEquals(self.image.table.getAccurateRipIds(), (
|
||||
"00000064", "00000191"))
|
||||
|
||||
class AudioLengthTestCase(unittest.TestCase):
|
||||
class AudioLengthTestCase(tcommon.TestCase):
|
||||
def testLength(self):
|
||||
path = os.path.join(os.path.dirname(__file__), u'track.flac')
|
||||
t = image.AudioLengthTask(path)
|
||||
@@ -101,10 +100,7 @@ class AudioLengthPathTestCase(tcommon.TestCase):
|
||||
self.assertEquals(e.exception.code, gst.STREAM_ERROR_TYPE_NOT_FOUND)
|
||||
os.unlink(path)
|
||||
|
||||
def testUnicodePath(self):
|
||||
# this test makes sure we can checksum a unicode path
|
||||
self._testSuffix(u'morituri.test.B\xeate Noire.empty')
|
||||
|
||||
class NormalAudioLengthPathTestCase(AudioLengthPathTestCase):
|
||||
def testSingleQuote(self):
|
||||
self._testSuffix(u"morituri.test.Guns 'N Roses")
|
||||
|
||||
@@ -112,3 +108,9 @@ class AudioLengthPathTestCase(tcommon.TestCase):
|
||||
# This test makes sure we can checksum files with double quote in
|
||||
# their name
|
||||
self._testSuffix(u'morituri.test.12" edit')
|
||||
|
||||
class UnicodeAudioLengthPathTestCase(AudioLengthPathTestCase, tcommon.UnicodeTestMixin):
|
||||
def testUnicodePath(self):
|
||||
# this test makes sure we can checksum a unicode path
|
||||
self._testSuffix(u'morituri.test.B\xeate Noire.empty')
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
import os
|
||||
import copy
|
||||
import unittest
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
from morituri.image import toc
|
||||
|
||||
from morituri.test import common
|
||||
|
||||
class CureTestCase(unittest.TestCase):
|
||||
class CureTestCase(common.TestCase):
|
||||
def setUp(self):
|
||||
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
|
||||
u'cure.toc'))
|
||||
@@ -90,7 +91,7 @@ class CureTestCase(unittest.TestCase):
|
||||
'3/c/4/dBAR-013-0019d4c3-00fe8924-b90c650d.bin')
|
||||
|
||||
# Bloc Party - Silent Alarm has a Hidden Track One Audio
|
||||
class BlocTestCase(unittest.TestCase):
|
||||
class BlocTestCase(common.TestCase):
|
||||
def setUp(self):
|
||||
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
|
||||
u'bloc.toc'))
|
||||
@@ -137,7 +138,7 @@ class BlocTestCase(unittest.TestCase):
|
||||
'e/d/2/dBAR-013-001af2de-0105994e-ad0be00d.bin')
|
||||
|
||||
# The Breeders - Mountain Battles has CDText
|
||||
class BreedersTestCase(unittest.TestCase):
|
||||
class BreedersTestCase(common.TestCase):
|
||||
def setUp(self):
|
||||
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
|
||||
u'breeders.toc'))
|
||||
@@ -163,7 +164,7 @@ class BreedersTestCase(unittest.TestCase):
|
||||
self.assertEquals(cue, ref)
|
||||
|
||||
# Ladyhawke has a data track
|
||||
class LadyhawkeTestCase(unittest.TestCase):
|
||||
class LadyhawkeTestCase(common.TestCase):
|
||||
def setUp(self):
|
||||
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
|
||||
u'ladyhawke.toc'))
|
||||
@@ -179,7 +180,7 @@ class LadyhawkeTestCase(unittest.TestCase):
|
||||
# c60af50d 13 150 15687 31841 51016 66616 81352 99559 116070 133243
|
||||
# 149997 161710 177832 207256 2807
|
||||
|
||||
class CapitalMergeTestCase(unittest.TestCase):
|
||||
class CapitalMergeTestCase(common.TestCase):
|
||||
def setUp(self):
|
||||
self.toc1 = toc.TocFile(os.path.join(os.path.dirname(__file__),
|
||||
u'capital.1.toc'))
|
||||
@@ -208,14 +209,23 @@ class CapitalMergeTestCase(unittest.TestCase):
|
||||
self.assertEquals(self.table.getMusicBrainzDiscId(),
|
||||
"MAj3xXf6QMy7G.BIFOyHyq4MySE-")
|
||||
|
||||
class UnicodeTestCase(unittest.TestCase):
|
||||
class UnicodeTestCase(common.TestCase, common.UnicodeTestMixin):
|
||||
def setUp(self):
|
||||
# we copy the normal non-utf8 filename to a utf-8 filename
|
||||
# in this test because builds with LANG=C fail if we include
|
||||
# utf-8 filenames in the dist
|
||||
path = u'Jos\xe9Gonz\xe1lez.toc'
|
||||
self._performer = u'Jos\xe9 Gonz\xe1lez'
|
||||
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__), path))
|
||||
source = os.path.join(os.path.dirname(__file__), 'jose.toc')
|
||||
self.dest = os.path.join(os.path.dirname(__file__), path)
|
||||
shutil.copy(source, self.dest)
|
||||
self.toc = toc.TocFile(self.dest)
|
||||
self.toc.parse()
|
||||
self.assertEquals(len(self.toc.table.tracks), 10)
|
||||
|
||||
def tearDown(self):
|
||||
os.unlink(self.dest)
|
||||
|
||||
def testGetTrackLength(self):
|
||||
t = self.toc.table.tracks[0]
|
||||
# first track has known length because the .toc is a single file
|
||||
|
||||
Reference in New Issue
Block a user