def test_rio_to_unicode(self): uni_data = u'\N{KATAKANA LETTER O}' s = Stanza(foo=uni_data) unicode_str = s.to_unicode() self.assertEqual(u'foo: %s\n' % (uni_data,), unicode_str) new_s = rio.read_stanza_unicode(unicode_str.splitlines(True)) self.assertEqual(uni_data, new_s.get('foo'))
def test_rio_to_unicode(self): uni_data = u'\N{KATAKANA LETTER O}' s = Stanza(foo=uni_data) unicode_str = s.to_unicode() self.assertEqual(u'foo: %s\n' % (uni_data, ), unicode_str) new_s = rio.read_stanza_unicode(unicode_str.splitlines(True)) self.assertEqual(uni_data, new_s.get('foo'))
def test_nested_rio_unicode(self): uni_data = u'\N{KATAKANA LETTER O}' s = Stanza(foo=uni_data) parent_stanza = Stanza(child=s.to_unicode()) raw_lines = parent_stanza.to_lines() self.assertEqual(['child: foo: ' + uni_data.encode('utf-8') + '\n', '\t\n', ], raw_lines) new_parent = read_stanza(raw_lines) child_text = new_parent.get('child') self.assertEqual(u'foo: %s\n' % uni_data, child_text) new_child = rio.read_stanza_unicode(child_text.splitlines(True)) self.assertEqual(uni_data, new_child.get('foo'))
def test_nested_rio_unicode(self): uni_data = u'\N{KATAKANA LETTER O}' s = Stanza(foo=uni_data) parent_stanza = Stanza(child=s.to_unicode()) raw_lines = parent_stanza.to_lines() self.assertEqual([ 'child: foo: ' + uni_data.encode('utf-8') + '\n', '\t\n', ], raw_lines) new_parent = read_stanza(raw_lines) child_text = new_parent.get('child') self.assertEqual(u'foo: %s\n' % uni_data, child_text) new_child = rio.read_stanza_unicode(child_text.splitlines(True)) self.assertEqual(uni_data, new_child.get('foo'))