~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_patches.py

  • Committer: Robert Collins
  • Date: 2007-05-07 16:48:14 UTC
  • mto: This revision was merged to the branch mainline in revision 2485.
  • Revision ID: robertc@robertcollins.net-20070507164814-wpagonutf4b5cf8s
Move HACKING to docs/developers/HACKING and adjust Makefile to accomodate this.

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)
 
34
                            parse_patch,
 
35
                            parse_patches)
35
36
 
36
37
 
37
38
class PatchesTester(unittest.TestCase):
182
183
        patch = parse_patch(self.datafile("insert_top.patch"))
183
184
        assert (patch.pos_in_mod(0)==1)
184
185
 
 
186
    def testParsePatches(self):
 
187
        """Make sure file names can be extracted from tricky unified diffs"""
 
188
        patchtext = \
 
189
"""--- orig-7
 
190
+++ mod-7
 
191
@@ -1,10 +1,10 @@
 
192
 -- a
 
193
--- b
 
194
+++ c
 
195
 xx d
 
196
 xx e
 
197
 ++ f
 
198
-++ g
 
199
+-- h
 
200
 xx i
 
201
 xx j
 
202
 -- k
 
203
--- l
 
204
+++ m
 
205
--- orig-8
 
206
+++ mod-8
 
207
@@ -1 +1 @@
 
208
--- A
 
209
+++ B
 
210
@@ -1 +1 @@
 
211
--- C
 
212
+++ D
 
213
"""
 
214
        filenames = [('orig-7', 'mod-7'),
 
215
                     ('orig-8', 'mod-8')]
 
216
        patches = parse_patches(patchtext.splitlines(True))
 
217
        patch_files = []
 
218
        for patch in patches:
 
219
            patch_files.append((patch.oldname, patch.newname))
 
220
        assert (patch_files == filenames)
 
221
            
185
222
def test():
186
223
    patchesTestSuite = unittest.makeSuite(PatchesTester,'test')
187
224
    runner = unittest.TextTestRunner(verbosity=0)