~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_rio.py

  • Committer: Aaron Bentley
  • Date: 2007-02-28 16:51:18 UTC
  • mto: (2323.6.9 0.15-integration)
  • mto: This revision was merged to the branch mainline in revision 2330.
  • Revision ID: abentley@panoramicfeedback.com-20070228165118-1v8tiziwwq5wzr1z
Basic RIO patch-compatible format is working

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import cStringIO
26
26
import os
 
27
import re
27
28
import sys
28
29
from tempfile import TemporaryFile
29
30
 
353
354
        self.assertEqual(u'foo: %s\n' % uni_data, child_text)
354
355
        new_child = rio.read_stanza_unicode(child_text.splitlines(True))
355
356
        self.assertEqual(uni_data, new_child.get('foo'))
 
357
 
 
358
    def mail_munge(self, lines):
 
359
        new_lines = []
 
360
        for line in lines:
 
361
            line = re.sub('([^\r])\n', '\\1\r\n', line)
 
362
            new_lines.append(line)
 
363
        return new_lines
 
364
 
 
365
    def test_patch_rio(self):
 
366
        stanza = Stanza(data='#\n\r\\r ', space=' ' * 255)
 
367
        lines = rio.to_patch_lines(stanza)
 
368
        for line in lines:
 
369
            self.assertContainsRe(line, '^# ')
 
370
        lines = self.mail_munge(lines)
 
371
        new_stanza = rio.read_patch_stanza(lines)
 
372
        self.assertEqual('#\n\r\\r ', new_stanza.get('data'))
 
373
        self.assertEqual(' '* 255, new_stanza.get('space'))