355
355
new_child = rio.read_stanza_unicode(child_text.splitlines(True))
356
356
self.assertEqual(uni_data, new_child.get('foo'))
358
def mail_munge(self, lines):
358
def mail_munge(self, lines, dos_nl=True):
360
360
for line in lines:
361
line = re.sub('([^\r])\n', '\\1\r\n', line)
361
line = re.sub(' *\n', '\n', line)
363
line = re.sub('([^\r])\n', '\\1\r\n', line)
362
364
new_lines.append(line)
365
367
def test_patch_rio(self):
366
stanza = Stanza(data='#\n\r\\r ', space=' ' * 255)
368
stanza = Stanza(data='#\n\r\\r ', space=' ' * 255, hash='#' * 255)
367
369
lines = rio.to_patch_lines(stanza)
368
370
for line in lines:
369
371
self.assertContainsRe(line, '^# ')
372
self.assertTrue(72 >= len(line))
373
for line in rio.to_patch_lines(stanza, max_width=12):
374
self.assertTrue(12 >= len(line))
375
new_stanza = rio.read_patch_stanza(self.mail_munge(lines,
370
377
lines = self.mail_munge(lines)
371
378
new_stanza = rio.read_patch_stanza(lines)
372
379
self.assertEqual('#\n\r\\r ', new_stanza.get('data'))
373
380
self.assertEqual(' '* 255, new_stanza.get('space'))
381
self.assertEqual('#'* 255, new_stanza.get('hash'))
383
def test_patch_rio_linebreaks(self):
384
stanza = Stanza(breaktest='linebreak -/'*30)
385
self.assertContainsRe(rio.to_patch_lines(stanza, 71)[0],
387
stanza = Stanza(breaktest='linebreak-/'*30)
388
self.assertContainsRe(rio.to_patch_lines(stanza, 70)[0],
390
stanza = Stanza(breaktest='linebreak/'*30)
391
self.assertContainsRe(rio.to_patch_lines(stanza, 70)[0],