/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: Martin Pool
  • Date: 2007-10-03 08:06:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2901.
  • Revision ID: mbp@sourcefrog.net-20071003080644-oivy0gkg98sex0ed
Avoid internal error tracebacks on failure to lock on readonly transport (#129701).

Add new LockFailed, which doesn't imply that we failed to get it because of
contention.  Raise this if we fail to create the pending or lock directories
because of Transport errors.

UnlockableTransport is not an internal error.

ReadOnlyLockError has a message which didn't match its name or usage; it's now
deprecated and callers are updated to use LockFailed which is more appropriate.

Add zero_ninetytwo deprecation symbol.

Unify assertMatchesRe with TestCase.assertContainsRe.

When the constructor is deprecated, just say that the class is deprecated, not
the __init__ method - this works better with applyDeprecated in tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for rio serialization
18
18
 
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:\x20
145
 
one:\x20
 
144
none: 
 
145
one: 
146
146
\t
147
 
two:\x20
 
147
two: 
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:\x20
 
157
combo: 
158
158
\t\t\t
159
159
\t
160
 
space:\x20\x20
 
160
space:  
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:\x20
 
262
s: 
263
263
\t"one"
264
264
\t
265
265
 
269
269
 
270
270
s: """
271
271
 
272
 
s:\x20
 
272
s: 
273
273
\t
274
274
 
275
275
s: \\
276
276
 
277
 
s:\x20
 
277
s: 
278
278
\t\\
279
279
\t\\\\
280
280
\t