Rev 187: Converted TestCaseWithQueue to subclass bzrlib.tests.TestCaseWithTransport. in http://bzr.daniel-watkins.co.uk/pqm/testcase-queue

Daniel Watkins daniel at daniel-watkins.co.uk
Tue Jul 22 18:03:31 BST 2008


At http://bzr.daniel-watkins.co.uk/pqm/testcase-queue

------------------------------------------------------------
revno: 187
revision-id: daniel at daniel-watkins.co.uk-20080722170203-rr1mr5tlq1vxm9x6
parent: daniel at daniel-watkins.co.uk-20080717104404-m2mkd8o1luidl0s0
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Tue 2008-07-22 18:02:03 +0100
message:
  Converted TestCaseWithQueue to subclass bzrlib.tests.TestCaseWithTransport.
-------------- next part --------------
=== modified file 'pqm/tests/__init__.py'
--- a/pqm/tests/__init__.py	2008-07-17 10:44:04 +0000
+++ b/pqm/tests/__init__.py	2008-07-22 17:02:03 +0000
@@ -2,7 +2,7 @@
 import shutil
 from textwrap import dedent
 
-from twisted.trial import unittest
+from bzrlib.tests import TestCaseWithTransport
 
 
 sample_message = dedent("""\
@@ -72,15 +72,10 @@
             messageFile.write(self.message3)
             messageFile.close()
 
-    def tearDown(self):
-        os.unlink(self.configFileName)
-        shutil.rmtree(self.queuedir, ignore_errors=True)
-
-
-class TestCaseWithQueue(unittest.TestCase):
+
+class TestCaseWithQueue(TestCaseWithTransport):
 
     def getQueue(self, processing=True, empty=False):
         queue = QueueSetup(processing, empty)
         queue.setUp()
-        self.addCleanup(queue.tearDown)
         return queue

=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py	2008-07-17 10:23:29 +0000
+++ b/pqm/tests/test_pqm.py	2008-07-22 17:02:03 +0000
@@ -114,13 +114,7 @@
 
     def getScript(self, queue, content):
         """Get a script for testing with."""
-        scriptname = 'foo.script'
-        scriptFile = open(scriptname, "w")
-        scriptFile.write(content)
-        scriptFile.close()
-        def cleanupScript():
-            os.unlink(scriptname)
-        self.addCleanup(cleanupScript)
+        self.build_tree_contents([('foo.script', content)])
         pqm.pqm_subdir = os.path.abspath('queue/pqm')
         configp = ConfigParser()
         configp.read([queue.configFileName])



More information about the bazaar-commits mailing list