/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_rio.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-22 05:29:38 UTC
  • mto: This revision was merged to the branch mainline in revision 2032.
  • Revision ID: john@arbash-meinel.com-20060922052938-8a82e211a1b7540a
Make it easier to nest Stanzas with Unicode contents

Show diffs side-by-side

added added

removed removed

Lines of Context:
320
320
        self.assertRaises(TypeError, s.add, 10, {})
321
321
 
322
322
    def test_rio_unicode(self):
323
 
        # intentionally use cStringIO which doesn't accomodate unencoded unicode objects
324
 
        sio = cStringIO.StringIO()
325
323
        uni_data = u'\N{KATAKANA LETTER O}'
326
324
        s = Stanza(foo=uni_data)
327
325
        self.assertEquals(s.get('foo'), uni_data)
331
329
        new_s = read_stanza(raw_lines)
332
330
        self.assertEquals(new_s.get('foo'), uni_data)
333
331
 
 
332
    def test_rio_to_unicode(self):
 
333
        uni_data = u'\N{KATAKANA LETTER O}'
 
334
        s = Stanza(foo=uni_data)
 
335
        self.assertEqual(u'foo: %s\n' % (uni_data,), s.to_unicode())
 
336
 
 
337
    def test_nested_rio_unicode(self):
 
338
        uni_data = u'\N{KATAKANA LETTER O}'
 
339
        s = Stanza(foo=uni_data)
 
340
        parent_stanza = Stanza(child=s.to_unicode())
 
341
        raw_lines = parent_stanza.to_lines()
 
342
        self.assertEqual(['child: foo: ' + uni_data.encode('utf-8') + '\n',
 
343
                          '\t\n',
 
344
                         ], raw_lines)
 
345
        new_parent = read_stanza(raw_lines)
 
346
        child_text = new_parent.get('child')
 
347
        self.assertEqual(u'foo: %s\n' % uni_data, child_text)
 
348
        new_child = read_stanza(child_text.splitlines(True))
 
349
        self.assertEqual(uni_data, new_child.get('foo'))