Rev 187: Refactored TestTagCommand setup code. in http://bzr.daniel-watkins.co.uk/pqm/tag

Daniel Watkins daniel at daniel-watkins.co.uk
Tue Jul 22 21:21:01 BST 2008


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

------------------------------------------------------------
revno: 187
revision-id: daniel at daniel-watkins.co.uk-20080722201932-u67lqyd63voihn2f
parent: daniel at daniel-watkins.co.uk-20080722201220-mgx9cjuezszfdqze
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: tag
timestamp: Tue 2008-07-22 21:19:32 +0100
message:
  Refactored TestTagCommand setup code.
-------------- next part --------------
=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py	2008-07-22 20:12:20 +0000
+++ b/pqm/tests/test_pqm.py	2008-07-22 20:19:32 +0000
@@ -418,34 +418,31 @@
 
 class TestTagCommand(TestCaseWithQueue):
 
-    def set_up(self):
+    def setUp(self):
+        super(TestCaseWithQueue, self).setUp()
         # Create branch to be tagged
-        tree = self.make_branch_and_tree('foo')
-        configp = ConfigParser()
-        configp.add_section('foo')
+        self.tree = self.make_branch_and_tree('foo')
+        self.configp = ConfigParser()
+        self.configp.add_section('foo')
         self.getQueue(empty=True)
         # Create PQM working directory
         self.build_tree(['bar/'])
         pqm.workdir = 'bar'
         pqm.precommit_hook = []
-        return configp, tree
 
     def get_tag_command(self, revision, tag):
-        configp, tree = self.set_up()
         self.build_tree_contents([('foo/bar', '')])
-        tree.smart_add(['foo/bar'])
-        rev_id = tree.commit("Add bar.")
+        self.tree.smart_add(['foo/bar'])
+        self.rev_id = self.tree.commit("Add bar.")
         script = MockScript()
-        handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
-        return (TagCommand(script, handler, configp, 'foo', revision, tag),
-                rev_id)
+        handler = pqm.BranchSpecOptionHandler(self.configp, queuedir='queue')
+        return TagCommand(script, handler, self.configp, 'foo', revision, tag)
 
     def test_TagCommand_revno(self):
         from bzrlib.branch import Branch
-        command, rev_id = self.get_tag_command('1', 'tag')
+        command = self.get_tag_command('1', 'tag')
         command.run()
-        branch = Branch.open('foo')
-        self.assertEqual(branch.tags.lookup_tag('tag'), rev_id)
+        self.assertEqual(self.tree.branch.tags.lookup_tag('tag'), self.rev_id)
 
 
 class FunctionalTestCommandRunner(unittest.TestCase):



More information about the bazaar-commits mailing list