~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-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004 - 2006 Aaron Bentley
 
1
# Copyright (C) 2004 - 2006 Aaron Bentley, Canonical Ltd
2
2
# <aaron.bentley@utoronto.ca>
3
3
#
4
 
#    This program is free software; you can redistribute it and/or modify
5
 
#    it under the terms of the GNU General Public License as published by
6
 
#    the Free Software Foundation; either version 2 of the License, or
7
 
#    (at your option) any later version.
8
 
#
9
 
#    This program is distributed in the hope that it will be useful,
10
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
#    GNU General Public License for more details.
13
 
#
14
 
#    You should have received a copy of the GNU General Public License
15
 
#    along with this program; if not, write to the Free Software
16
 
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
 
19
19
import unittest
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)