/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_patches.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
import os.path
19
19
 
20
 
from breezy.tests import TestCase
 
20
from bzrlib.tests import TestCase
21
21
 
22
 
from breezy.iterablefile import IterableFile
23
 
from breezy.patches import (MalformedLine,
 
22
from bzrlib.iterablefile import IterableFile
 
23
from bzrlib.patches import (MalformedLine,
24
24
                            MalformedHunkHeader,
25
25
                            MalformedPatchHeader,
26
26
                            BinaryPatch,
158
158
        self.makeMalformedLine("hello\n")
159
159
 
160
160
    def testMalformedLineNO_NL(self):
161
 
        """Parse invalid '\\ No newline at end of file' in hunk lines"""
 
161
        """Parse invalid '\ No newline at end of file' in hunk lines"""
162
162
        self.makeMalformedLine(NO_NL)
163
163
 
164
164
    def compare_parsed(self, patchtext):
167
167
        pstr = str(patch)
168
168
        i = difference_index(patchtext, pstr)
169
169
        if i is not None:
170
 
            print("%i: \"%s\" != \"%s\"" % (i, patchtext[i], pstr[i]))
 
170
            print "%i: \"%s\" != \"%s\"" % (i, patchtext[i], pstr[i])
171
171
        self.assertEqual(patchtext, str(patch))
172
172
 
173
173
    def testAll(self):
211
211
        self.compare_parsed(patchtext)
212
212
 
213
213
    def testLineLookup(self):
 
214
        import sys
214
215
        """Make sure we can accurately look up mod line from orig"""
215
216
        patch = parse_patch(self.datafile("diff"))
216
217
        orig = list(self.datafile("orig"))
226
227
        for hunk in patch.hunks:
227
228
            for line in hunk.lines:
228
229
                if isinstance(line, RemoveLine):
229
 
                    self.assertEqual(line.contents, next(rem_iter))
230
 
        self.assertRaises(StopIteration, next, rem_iter)
 
230
                    next = rem_iter.next()
 
231
                    if line.contents != next:
 
232
                        sys.stdout.write(" orig:%spatch:%s" % (next,
 
233
                                         line.contents))
 
234
                    self.assertEqual(line.contents, next)
 
235
        self.assertRaises(StopIteration, rem_iter.next)
231
236
 
232
237
    def testPatching(self):
233
238
        """Test a few patch files, and make sure they work."""