~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_rio.py

  • Committer: John Arbash Meinel
  • Date: 2006-06-18 04:43:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1794.
  • Revision ID: john@arbash-meinel.com-20060618044313-08d3915d095cb28b
Remove scope name for now, still log it, in case we need it for demandload.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
import sys
28
28
from tempfile import TemporaryFile
29
29
 
30
 
from bzrlib import (
31
 
    rio,
32
 
    )
33
30
from bzrlib.tests import TestCaseInTempDir, TestCase
34
31
from bzrlib.rio import (RioWriter, Stanza, read_stanza, read_stanzas, rio_file,
35
32
                        RioReader)
323
320
        self.assertRaises(TypeError, s.add, 10, {})
324
321
 
325
322
    def test_rio_unicode(self):
 
323
        # intentionally use cStringIO which doesn't accomodate unencoded unicode objects
 
324
        sio = cStringIO.StringIO()
326
325
        uni_data = u'\N{KATAKANA LETTER O}'
327
326
        s = Stanza(foo=uni_data)
328
327
        self.assertEquals(s.get('foo'), uni_data)
332
331
        new_s = read_stanza(raw_lines)
333
332
        self.assertEquals(new_s.get('foo'), uni_data)
334
333
 
335
 
    def test_rio_to_unicode(self):
336
 
        uni_data = u'\N{KATAKANA LETTER O}'
337
 
        s = Stanza(foo=uni_data)
338
 
        unicode_str = s.to_unicode()
339
 
        self.assertEqual(u'foo: %s\n' % (uni_data,), unicode_str)
340
 
        new_s = rio.read_stanza_unicode(unicode_str.splitlines(True))
341
 
        self.assertEqual(uni_data, new_s.get('foo'))
342
 
 
343
 
    def test_nested_rio_unicode(self):
344
 
        uni_data = u'\N{KATAKANA LETTER O}'
345
 
        s = Stanza(foo=uni_data)
346
 
        parent_stanza = Stanza(child=s.to_unicode())
347
 
        raw_lines = parent_stanza.to_lines()
348
 
        self.assertEqual(['child: foo: ' + uni_data.encode('utf-8') + '\n',
349
 
                          '\t\n',
350
 
                         ], raw_lines)
351
 
        new_parent = read_stanza(raw_lines)
352
 
        child_text = new_parent.get('child')
353
 
        self.assertEqual(u'foo: %s\n' % uni_data, child_text)
354
 
        new_child = rio.read_stanza_unicode(child_text.splitlines(True))
355
 
        self.assertEqual(uni_data, new_child.get('foo'))