Rev 181: Removed need for scriptname to be a instance variable. in http://bzr.daniel-watkins.co.uk/pqm/empty-queue

Daniel Watkins daniel at daniel-watkins.co.uk
Thu Jul 10 17:37:05 BST 2008


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

------------------------------------------------------------
revno: 181
revision-id: daniel at daniel-watkins.co.uk-20080710163552-maaev5jnyg7iyp3h
parent: daniel at daniel-watkins.co.uk-20080710162506-tpi33egh01pu79tg
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: TestCaseWithQueue
timestamp: Thu 2008-07-10 17:35:52 +0100
message:
  Removed need for scriptname to be a instance variable.
-------------- next part --------------
=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py	2008-07-10 16:25:06 +0000
+++ b/pqm/tests/test_pqm.py	2008-07-10 16:35:52 +0000
@@ -112,26 +112,24 @@
     def testName(self):
         patch = pqm.Script('foo.script', logging, False, 0, None, None)
         self.assertEqual(patch.filename, 'foo.script')
-        self.scriptname = 'fpp'
 
     def tearDown(self):
-        try:
-            os.unlink(self.scriptname)
-        except OSError:
-            pass
         self.queue.tearDown()
 
     def getScript(self, content):
         """Get a script for testing with."""
-        self.scriptname = 'foo.script'
-        scriptFile = open(self.scriptname, "w")
+        scriptname = 'foo.script'
+        scriptFile = open(scriptname, "w")
         scriptFile.write(content)
         scriptFile.close()
+        def cleanupScript():
+            os.unlink(scriptname)
+        self.addCleanup(cleanupScript)
         pqm.pqm_subdir = os.path.abspath('queue/pqm')
         configp = pqm.ConfigParser()
         configp.read([self.queue.configFileName])
         handler = pqm.BranchSpecOptionHandler(configp)
-        return pqm.Script(self.scriptname, logging, False, 54, handler, configp)
+        return pqm.Script(scriptname, logging, False, 54, handler, configp)
 
     def testFields(self):
         script = self.getScript(sample_message)



More information about the bazaar-commits mailing list