~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__rio.py

  • Committer: Jelmer Vernooij
  • Date: 2009-05-14 21:29:57 UTC
  • mto: (4290.1.9 rio-serializer2)
  • mto: This revision was merged to the branch mainline in revision 4368.
  • Revision ID: jelmer@samba.org-20090514212957-fdg0uxi17n5j93ui
Extend valid_tags tests a bit, test that stanza pairs contain the right types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
    def test_empty(self):
78
78
        self.assertFalse(self.module._valid_tag(""))
79
79
 
 
80
    def test_unicode(self):
 
81
        self.assertRaises(TypeError, self.module._valid_tag, u"foo")
 
82
 
 
83
    def test_non_ascii_char(self):
 
84
        self.assertFalse(self.module._valid_tag("\xb5"))
 
85
 
80
86
 
81
87
class TestReadUTF8Stanza(tests.TestCase):
82
88
 
83
89
    module = None # Filled in by test parameterization
84
90
 
85
91
    def assertReadStanza(self, result, line_iter):
86
 
        self.assertEquals(result, self.module._read_stanza_utf8(line_iter))
 
92
        s = self.module._read_stanza_utf8(line_iter)
 
93
        self.assertEquals(result, s)
 
94
        if s is not None:
 
95
            for tag, value in s.iter_pairs():
 
96
                self.assertIsInstance(tag, str)
 
97
                self.assertIsInstance(value, unicode)
87
98
 
88
99
    def assertReadStanzaRaises(self, exception, line_iter):
89
100
        self.assertRaises(exception, self.module._read_stanza_utf8, line_iter)
134
145
    module = None # Filled in by test parameterization
135
146
 
136
147
    def assertReadStanza(self, result, line_iter):
137
 
        self.assertEquals(result, self.module._read_stanza_unicode(line_iter))
 
148
        s = self.module._read_stanza_unicode(line_iter)
 
149
        self.assertEquals(result, s)
 
150
        if s is not None:
 
151
            for tag, value in s.iter_pairs():
 
152
                self.assertIsInstance(tag, str)
 
153
                self.assertIsInstance(value, unicode)
138
154
 
139
155
    def assertReadStanzaRaises(self, exception, line_iter):
140
156
        self.assertRaises(exception, self.module._read_stanza_unicode,