~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_rio.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-23 17:00:36 UTC
  • mfrom: (4032.1.4 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090223170036-3q1v68ewdt8i0to5
(Marius Kruger) Remove all trailing whitespace and add tests to
        enforce this.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        # these aren't enforced at construction time
55
55
        ## self.assertRaises(ValueError,
56
56
        ##        Stanza, complex=42 + 3j)
57
 
        ## self.assertRaises(ValueError, 
 
57
        ## self.assertRaises(ValueError,
58
58
        ##        Stanza, several=range(10))
59
59
 
60
60
    def test_empty_value(self):
123
123
    def test_repeated_field(self):
124
124
        """Repeated field in rio"""
125
125
        s = Stanza()
126
 
        for k, v in [('a', '10'), ('b', '20'), ('a', '100'), ('b', '200'), 
 
126
        for k, v in [('a', '10'), ('b', '20'), ('a', '100'), ('b', '200'),
127
127
                     ('a', '1000'), ('b', '2000')]:
128
128
            s.add(k, v)
129
129
        s2 = read_stanza(s.to_lines())
141
141
    def test_blank_line(self):
142
142
        s = Stanza(none='', one='\n', two='\n\n')
143
143
        self.assertEqualDiff(s.to_string(), """\
144
 
none: 
145
 
one: 
 
144
none:\x20
 
145
one:\x20
146
146
\t
147
 
two: 
 
147
two:\x20
148
148
\t
149
149
\t
150
150
""")
154
154
    def test_whitespace_value(self):
155
155
        s = Stanza(space=' ', tabs='\t\t\t', combo='\n\t\t\n')
156
156
        self.assertEqualDiff(s.to_string(), """\
157
 
combo: 
 
157
combo:\x20
158
158
\t\t\t
159
159
\t
160
 
space:  
 
160
space:\x20\x20
161
161
tabs: \t\t\t
162
162
""")
163
163
        s2 = read_stanza(s.to_lines())
166
166
 
167
167
    def test_quoted(self):
168
168
        """rio quoted string cases"""
169
 
        s = Stanza(q1='"hello"', 
170
 
                   q2=' "for', 
 
169
        s = Stanza(q1='"hello"',
 
170
                   q2=' "for',
171
171
                   q3='\n\n"for"\n',
172
172
                   q4='for\n"\nfor',
173
173
                   q5='\n',
174
 
                   q6='"', 
 
174
                   q6='"',
175
175
                   q7='""',
176
176
                   q8='\\',
177
177
                   q9='\\"\\"',
187
187
        s = read_stanza([])
188
188
        self.assertEqual(s, None)
189
189
        self.assertTrue(s is None)
190
 
        
 
190
 
191
191
    def test_read_iter(self):
192
192
        """Read several stanzas from file"""
193
193
        tmpf = TemporaryFile()
204
204
        reader = read_stanzas(tmpf)
205
205
        read_iter = iter(reader)
206
206
        stuff = list(reader)
207
 
        self.assertEqual(stuff, 
 
207
        self.assertEqual(stuff,
208
208
                [ Stanza(version_header='1'),
209
209
                  Stanza(name="foo", val='123'),
210
210
                  Stanza(name="bar", val='129319'), ])
259
259
        tmpf.write('''\
260
260
s: "one"
261
261
 
262
 
s: 
 
262
s:\x20
263
263
\t"one"
264
264
\t
265
265
 
269
269
 
270
270
s: """
271
271
 
272
 
s: 
 
272
s:\x20
273
273
\t
274
274
 
275
275
s: \\
276
276
 
277
 
s: 
 
277
s:\x20
278
278
\t\\
279
279
\t\\\\
280
280
\t