From 98213c41960b795ea28c263aaa5a642fc16abd66 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Tue, 6 Apr 2010 00:02:56 +0000 Subject: [PATCH] * doc/release: Document having clean test run. * morituri/common/encode.py: Catch and properly stop on gst.QueryError. Don't set peak in stop if we had an error. * morituri/test/test_common_encode.py: * morituri/test/test_common_renamer.py: * morituri/test/test_image_cue.py: Clean up after tests. --- ChangeLog | 12 ++++++++++++ doc/release | 5 +++++ morituri/common/encode.py | 11 +++++++++-- morituri/test/test_common_encode.py | 8 +++++--- morituri/test/test_common_renamer.py | 26 ++++++++++++++++++++------ morituri/test/test_image_cue.py | 5 ++--- 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index bb1e80e..d7b0a04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-04-06 Thomas Vander Stichele + + * doc/release: + Document having clean test run. + * morituri/common/encode.py: + Catch and properly stop on gst.QueryError. + Don't set peak in stop if we had an error. + * morituri/test/test_common_encode.py: + * morituri/test/test_common_renamer.py: + * morituri/test/test_image_cue.py: + Clean up after tests. + 2010-04-06 Thomas Vander Stichele * morituri/common/task.py: diff --git a/doc/release b/doc/release index 763f5ea..9823d11 100644 --- a/doc/release +++ b/doc/release @@ -1,6 +1,11 @@ Release procedure for morituri ------------------------------ +- Verify that all tests run. +- Verify that test run doesn't leave anything around in /tmp: + ls /tmp/*morituri* +- Verify that all buildbots are green. + - Pick a new version number and set it: export VERSION=0.1.0 - Update configure.ac diff --git a/morituri/common/encode.py b/morituri/common/encode.py index d4b6e54..5144f2e 100644 --- a/morituri/common/encode.py +++ b/morituri/common/encode.py @@ -175,7 +175,13 @@ class EncodeTask(task.Task): # get length self.debug('query duration') - length, qformat = tagger.query_duration(gst.FORMAT_DEFAULT) + try: + length, qformat = tagger.query_duration(gst.FORMAT_DEFAULT) + except gst.QueryError, e: + self.setException(e) + self.stop() + return + # wavparse 0.10.14 returns in bytes if qformat == gst.FORMAT_BYTES: self.debug('query returned in BYTES format') @@ -250,4 +256,5 @@ class EncodeTask(task.Task): self.debug('set state to NULL') task.Task.stop(self) - self.peak = math.sqrt(math.pow(10, self._peakdB / 10.0)) + if self._peakdB: + self.peak = math.sqrt(math.pow(10, self._peakdB / 10.0)) diff --git a/morituri/test/test_common_encode.py b/morituri/test/test_common_encode.py index f0a76fa..9f41ad8 100644 --- a/morituri/test/test_common_encode.py +++ b/morituri/test/test_common_encode.py @@ -26,14 +26,16 @@ class PathTestCase(common.TestCase): encodetask, verbose=False) self.failUnless(isinstance(e.exception, gst.QueryError), "%r is not a gst.QueryError" % e.exception) + os.close(fd) os.unlink(path) + os.unlink(path + '.out') def testUnicodePath(self): # this test makes sure we can checksum a unicode path - self._testSuffix(u'morituri.test.B\xeate Noire.empty') + self._testSuffix(u'.morituri.test_encode.B\xeate Noire') def testSingleQuote(self): - self._testSuffix(u"morituri.test.Guns 'N Roses") + self._testSuffix(u".morituri.test_encode.Guns 'N Roses") def testDoubleQuote(self): - self._testSuffix(u'morituri.test.12" edit') + self._testSuffix(u'.morituri.test_encode.12" edit') diff --git a/morituri/test/test_common_renamer.py b/morituri/test/test_common_renamer.py index 5fbf1f2..e76bf37 100644 --- a/morituri/test/test_common_renamer.py +++ b/morituri/test/test_common_renamer.py @@ -10,7 +10,7 @@ from morituri.common import renamer class RenameInFileTestcase(unittest.TestCase): def setUp(self): - (fd, self._path) = tempfile.mkstemp(suffix='morituri') + (fd, self._path) = tempfile.mkstemp(suffix='.morituri.renamer.infile') os.write(fd, 'This is a test\nThis is another\n') os.close(fd) @@ -25,6 +25,7 @@ class RenameInFileTestcase(unittest.TestCase): o.do() output = open(self._path).read() self.assertEquals(output, 'That was some test\nThat was somenother\n') + os.unlink(self._path) def testSerialize(self): o = renamer.RenameInFile(self._path, 'is is a', 'at was some') @@ -33,13 +34,15 @@ class RenameInFileTestcase(unittest.TestCase): o2.do() output = open(self._path).read() self.assertEquals(output, 'That was some test\nThat was somenother\n') + os.unlink(self._path) class RenameFileTestcase(unittest.TestCase): def setUp(self): - (fd, self._source) = tempfile.mkstemp(suffix='morituri') + (fd, self._source) = tempfile.mkstemp(suffix='.morituri.renamer.file') os.write(fd, 'This is a test\nThis is another\n') os.close(fd) - (fd, self._destination) = tempfile.mkstemp(suffix='morituri') + (fd, self._destination) = tempfile.mkstemp( + suffix='.morituri.renamer.file') os.close(fd) os.unlink(self._destination) self._operation = renamer.RenameFile(self._source, self._destination) @@ -61,6 +64,7 @@ class RenameFileTestcase(unittest.TestCase): self._operation.do() output = open(self._destination).read() self.assertEquals(output, 'This is a test\nThis is another\n') + os.unlink(self._destination) def testSerialize(self): data = self._operation.serialize() @@ -68,16 +72,19 @@ class RenameFileTestcase(unittest.TestCase): o.do() output = open(self._destination).read() self.assertEquals(output, 'This is a test\nThis is another\n') + os.unlink(self._destination) class OperatorTestCase(unittest.TestCase): def setUp(self): - self._statePath = tempfile.mkdtemp(suffix='.morituri') + self._statePath = tempfile.mkdtemp(suffix='.morituri.renamer.operator') self._operator = renamer.Operator(self._statePath, 'test') - (fd, self._source) = tempfile.mkstemp(suffix='morituri') + (fd, self._source) = tempfile.mkstemp( + suffix='.morituri.renamer.operator') os.write(fd, 'This is a test\nThis is another\n') os.close(fd) - (fd, self._destination) = tempfile.mkstemp(suffix='morituri') + (fd, self._destination) = tempfile.mkstemp( + suffix='.morituri.renamer.operator') os.close(fd) os.unlink(self._destination) self._operator.addOperation( @@ -85,6 +92,9 @@ class OperatorTestCase(unittest.TestCase): self._operator.addOperation( renamer.RenameFile(self._source, self._destination)) + def tearDown(self): + os.system('rm -rf %s' % self._statePath) + def testLoadNoneDone(self): self._operator.save() @@ -93,6 +103,7 @@ class OperatorTestCase(unittest.TestCase): self.assertEquals(o._todo, self._operator._todo) self.assertEquals(o._done, []) + os.unlink(self._source) def testLoadOneDone(self): self.assertEquals(len(self._operator._done), 0) @@ -110,6 +121,7 @@ class OperatorTestCase(unittest.TestCase): # now continue o.next() self.assertEquals(len(o._done), 2) + os.unlink(self._destination) def testLoadOneInterrupted(self): self.assertEquals(len(self._operator._done), 0) @@ -132,3 +144,5 @@ class OperatorTestCase(unittest.TestCase): self.assertEquals(len(o._done), 1) o.next() self.assertEquals(len(o._done), 2) + + os.unlink(self._destination) diff --git a/morituri/test/test_image_cue.py b/morituri/test/test_image_cue.py index e8432fa..cdcb657 100644 --- a/morituri/test/test_image_cue.py +++ b/morituri/test/test_image_cue.py @@ -51,7 +51,7 @@ class KanyeMixedTestCase(unittest.TestCase): class WriteCueFileTestCase(unittest.TestCase): def testWrite(self): - fd, path = tempfile.mkstemp(suffix=u'morituri.test.cue') + fd, path = tempfile.mkstemp(suffix=u'.morituri.test.cue') os.close(fd) it = table.Table() @@ -78,5 +78,4 @@ FILE "track01.wav" WAVE FILE "track02.wav" WAVE INDEX 01 00:00:00 """) - - + os.unlink(path)