Rev 209: Extracted common test code to a helper method. in http://bzr.daniel-watkins.co.uk/pqm/abstract-patch
Daniel Watkins
daniel at daniel-watkins.co.uk
Tue Jul 22 19:20:45 BST 2008
At http://bzr.daniel-watkins.co.uk/pqm/abstract-patch
------------------------------------------------------------
revno: 209
revision-id: daniel at daniel-watkins.co.uk-20080722181915-2e90z3wentgvby5n
parent: daniel at daniel-watkins.co.uk-20080722180836-duk15azwrfjveity
committer: Daniel Watkins <daniel at daniel-watkins.co.uk>
branch nick: abstract-patch
timestamp: Tue 2008-07-22 19:19:15 +0100
message:
Extracted common test code to a helper method.
-------------- next part --------------
=== modified file 'pqm/tests/test_pqm.py'
--- a/pqm/tests/test_pqm.py 2008-07-22 18:08:36 +0000
+++ b/pqm/tests/test_pqm.py 2008-07-22 18:19:15 +0000
@@ -352,46 +352,37 @@
pqm.precommit_hook = []
return configp, tree
+ def get_patch_command(self, lines):
+ configp, tree = self.set_up()
+ self.build_tree_contents([('foo/bar', '')])
+ tree.smart_add(['foo/bar'])
+ tree.commit("Add bar.")
+ script = MockScript()
+ handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
+ return PatchCommand(script, handler, configp, lines, 'foo')
+
def test_PatchCommand_empty_patch(self):
- configp, tree = self.set_up()
- script = MockScript()
- handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
- command = PatchCommand(script, handler, configp, [], 'foo')
+ patch = []
+ command = self.get_patch_command(patch)
e = self.assertRaises(PQMException, command.run)
self.assertEqual("'Empty patch content'", str(e))
def test_PatchCommand_valid_patch(self):
- configp, tree = self.set_up()
- self.build_tree_contents([('foo/bar', '')])
- tree.smart_add(['foo/bar'])
- tree.commit("Add bar.")
-
patch = ["=== modified file 'bar'",
"--- old/bar 2008-07-20 16:06:44.000000000 +0100",
"+++ new/bar 2008-07-20 16:06:48.000000000 +0100",
"@@ -0,0 +1 @@",
"+foo"]
-
- script = MockScript()
- handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
- command = PatchCommand(script, handler, configp, patch, 'foo')
+ command = self.get_patch_command(patch)
command.run()
self.assertFileEqual('foo\n', 'bar/foo/foo/bar')
def test_PatchCommand_nonsense_patch(self):
- configp, tree = self.set_up()
- self.build_tree_contents([('foo/bar', '')])
- tree.smart_add(['foo/bar'])
- tree.commit("Add bar.")
-
patch = ["`Twas brillig, and the slithy toves",
" Did gyre and gimble in the wabe;",
"All mimsy were the borogoves,",
" And the mome raths outgrabe."]
-
- script = MockScript()
- handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
- command = PatchCommand(script, handler, configp, patch, 'foo')
+ command = self.get_patch_command(patch)
e = self.assertRaises(PQMException, command.run)
self.assertEqual(
"['patch command \"patch\" failed (512): patch exited with error"
@@ -400,30 +391,24 @@
str(e))
def test_PatchCommand_absolute_path(self):
- configp, tree = self.set_up()
patch = ["=== modified file 'bar'",
"--- /bar 2008-07-20 16:06:44.000000000 +0100",
"+++ /bar 2008-07-20 16:06:48.000000000 +0100",
"@@ -0,0 +1 @@",
"+foo"]
- script = MockScript()
- handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
- command = PatchCommand(script, handler, configp, patch, 'foo')
+ command = self.get_patch_command(patch)
e = self.assertRaises(PQMException, command.run)
self.assertEqual("'Invalid absolute filename in patch: /bar 2008-07-20"
" 16:06:48.000000000 +0100'",
str(e))
def test_PatchCommand_backreferencing_path(self):
- configp, tree = self.set_up()
patch = ["=== modified file 'bar'",
"--- bar/.. 2008-07-20 16:06:44.000000000 +0100",
"+++ bar/.. 2008-07-20 16:06:48.000000000 +0100",
"@@ -0,0 +1 @@",
"+foo"]
- script = MockScript()
- handler = pqm.BranchSpecOptionHandler(configp, queuedir='queue')
- command = PatchCommand(script, handler, configp, patch, 'foo')
+ command = self.get_patch_command(patch)
e = self.assertRaises(PQMException, command.run)
self.assertEqual("'Invalid backreferencing filename in patch: bar/.."
" 2008-07-20 16:06:48.000000000 +0100'",
More information about the bazaar-commits
mailing list