~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_patches.py

  • Committer: Alexander Belchenko
  • Date: 2007-01-30 23:05:35 UTC
  • mto: This revision was merged to the branch mainline in revision 2259.
  • Revision ID: bialix@ukr.net-20070130230535-kx1rd478rtigyc3v
standalone installer: win98 support

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
                            hunk_from_header, 
32
32
                            iter_patched, 
33
33
                            parse_line,
34
 
                            parse_patch,
35
 
                            parse_patches)
 
34
                            parse_patch)
36
35
 
37
36
 
38
37
class PatchesTester(unittest.TestCase):
74
73
        assert (hunk.mod_range == 0)
75
74
        assert (str(hunk) == header)
76
75
 
77
 
    def testPDiff(self):
78
 
        """Parse a hunk header produced by diff -p"""
79
 
        header = "@@ -407,7 +292,7 @@ bzr 0.18rc1  2007-07-10\n"
80
 
        hunk = hunk_from_header(header)
81
 
        self.assertEqual('bzr 0.18rc1  2007-07-10', hunk.tail)
82
 
        self.assertEqual(header, str(hunk))
83
 
 
84
76
    def makeMalformed(self, header):
85
77
        self.assertRaises(MalformedHunkHeader, hunk_from_header, header)
86
78
 
190
182
        patch = parse_patch(self.datafile("insert_top.patch"))
191
183
        assert (patch.pos_in_mod(0)==1)
192
184
 
193
 
    def testParsePatches(self):
194
 
        """Make sure file names can be extracted from tricky unified diffs"""
195
 
        patchtext = \
196
 
"""--- orig-7
197
 
+++ mod-7
198
 
@@ -1,10 +1,10 @@
199
 
 -- a
200
 
--- b
201
 
+++ c
202
 
 xx d
203
 
 xx e
204
 
 ++ f
205
 
-++ g
206
 
+-- h
207
 
 xx i
208
 
 xx j
209
 
 -- k
210
 
--- l
211
 
+++ m
212
 
--- orig-8
213
 
+++ mod-8
214
 
@@ -1 +1 @@
215
 
--- A
216
 
+++ B
217
 
@@ -1 +1 @@
218
 
--- C
219
 
+++ D
220
 
"""
221
 
        filenames = [('orig-7', 'mod-7'),
222
 
                     ('orig-8', 'mod-8')]
223
 
        patches = parse_patches(patchtext.splitlines(True))
224
 
        patch_files = []
225
 
        for patch in patches:
226
 
            patch_files.append((patch.oldname, patch.newname))
227
 
        assert (patch_files == filenames)
228
 
            
229
185
def test():
230
186
    patchesTestSuite = unittest.makeSuite(PatchesTester,'test')
231
187
    runner = unittest.TextTestRunner(verbosity=0)