/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 brzlib/tests/test_store.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Test Store implementations."""
18
18
 
19
 
from io import BytesIO
 
19
from cStringIO import StringIO
20
20
import os
21
21
import gzip
22
22
 
23
 
from ... import errors as errors
24
 
from ...errors import BzrError
25
 
from .store import TransportStore
26
 
from .store.text import TextStore
27
 
from .store.versioned import VersionedFileStore
28
 
from ...tests import TestCase, TestCaseInTempDir, TestCaseWithTransport
29
 
from ... import transactions
30
 
from ... import transport
31
 
from ...transport.memory import MemoryTransport
32
 
from ...bzr.weave import WeaveFile
 
23
import brzlib.errors as errors
 
24
from brzlib.errors import BzrError
 
25
from brzlib.store import TransportStore
 
26
from brzlib.store.text import TextStore
 
27
from brzlib.store.versioned import VersionedFileStore
 
28
from brzlib.tests import TestCase, TestCaseInTempDir, TestCaseWithTransport
 
29
import brzlib.transactions as transactions
 
30
import brzlib.transport as transport
 
31
from brzlib.transport.memory import MemoryTransport
 
32
from brzlib.weave import WeaveFile
33
33
 
34
34
 
35
35
class TestStores(object):
40
40
        self.assertEqual(f.read(), value)
41
41
 
42
42
    def fill_store(self, store):
43
 
        store.add(BytesIO(b'hello'), b'a')
44
 
        store.add(BytesIO(b'other'), b'b')
45
 
        store.add(BytesIO(b'something'), b'c')
46
 
        store.add(BytesIO(b'goodbye'), b'123123')
 
43
        store.add(StringIO('hello'), 'a')
 
44
        store.add(StringIO('other'), 'b')
 
45
        store.add(StringIO('something'), 'c')
 
46
        store.add(StringIO('goodbye'), '123123')
 
47
 
 
48
    def test_copy_all(self):
 
49
        """Test copying"""
 
50
        os.mkdir('a')
 
51
        store_a = self.get_store('a')
 
52
        store_a.add(StringIO('foo'), '1')
 
53
        os.mkdir('b')
 
54
        store_b = self.get_store('b')
 
55
        store_b.copy_all_ids(store_a)
 
56
        self.assertEqual(store_a.get('1').read(), 'foo')
 
57
        self.assertEqual(store_b.get('1').read(), 'foo')
 
58
        # TODO: Switch the exception form UnlistableStore to
 
59
        #       or make Stores throw UnlistableStore if their
 
60
        #       Transport doesn't support listing
 
61
        # store_c = RemoteStore('http://example.com/')
 
62
        # self.assertRaises(UnlistableStore, copy_all, store_c, store_b)
47
63
 
48
64
    def test_get(self):
49
65
        store = self.get_store()
50
66
        self.fill_store(store)
51
67
 
52
 
        self.check_content(store, b'a', b'hello')
53
 
        self.check_content(store, b'b', b'other')
54
 
        self.check_content(store, b'c', b'something')
 
68
        self.check_content(store, 'a', 'hello')
 
69
        self.check_content(store, 'b', 'other')
 
70
        self.check_content(store, 'c', 'something')
55
71
 
56
72
        # Make sure that requesting a non-existing file fails
57
 
        self.assertRaises(KeyError, self.check_content, store, b'd', None)
 
73
        self.assertRaises(KeyError, self.check_content, store, 'd', None)
58
74
 
59
75
    def test_multiple_add(self):
60
76
        """Multiple add with same ID should raise a BzrError"""
61
77
        store = self.get_store()
62
78
        self.fill_store(store)
63
 
        self.assertRaises(BzrError, store.add, BytesIO(b'goodbye'), b'123123')
 
79
        self.assertRaises(BzrError, store.add, StringIO('goodbye'), '123123')
64
80
 
65
81
 
66
82
class TestCompressedTextStore(TestCaseInTempDir, TestStores):
72
88
    def test_total_size(self):
73
89
        store = self.get_store(u'.')
74
90
        store.register_suffix('dsc')
75
 
        store.add(BytesIO(b'goodbye'), b'123123')
76
 
        store.add(BytesIO(b'goodbye2'), b'123123', 'dsc')
 
91
        store.add(StringIO('goodbye'), '123123')
 
92
        store.add(StringIO('goodbye2'), '123123', 'dsc')
77
93
        # these get gzipped - content should be stable
78
94
        self.assertEqual(store.total_size(), (2, 55))
79
95
 
81
97
        my_store = TextStore(MockTransport(),
82
98
                             prefixed=True, compressed=True)
83
99
        my_store.register_suffix('dsc')
84
 
        self.assertEqual('45/foo.dsc', my_store._relpath(b'foo', ['dsc']))
 
100
        self.assertEqual('45/foo.dsc', my_store._relpath('foo', ['dsc']))
85
101
 
86
102
 
87
103
class TestMemoryStore(TestCase):
91
107
 
92
108
    def test_add_and_retrieve(self):
93
109
        store = self.get_store()
94
 
        store.add(BytesIO(b'hello'), b'aa')
95
 
        self.assertNotEqual(store.get(b'aa'), None)
96
 
        self.assertEqual(store.get(b'aa').read(), b'hello')
97
 
        store.add(BytesIO(b'hello world'), b'bb')
98
 
        self.assertNotEqual(store.get(b'bb'), None)
99
 
        self.assertEqual(store.get(b'bb').read(), b'hello world')
 
110
        store.add(StringIO('hello'), 'aa')
 
111
        self.assertNotEqual(store.get('aa'), None)
 
112
        self.assertEqual(store.get('aa').read(), 'hello')
 
113
        store.add(StringIO('hello world'), 'bb')
 
114
        self.assertNotEqual(store.get('bb'), None)
 
115
        self.assertEqual(store.get('bb').read(), 'hello world')
100
116
 
101
117
    def test_missing_is_absent(self):
102
118
        store = self.get_store()
103
 
        self.assertNotIn(b'aa', store)
 
119
        self.assertFalse('aa' in store)
104
120
 
105
121
    def test_adding_fails_when_present(self):
106
122
        my_store = self.get_store()
107
 
        my_store.add(BytesIO(b'hello'), b'aa')
 
123
        my_store.add(StringIO('hello'), 'aa')
108
124
        self.assertRaises(BzrError,
109
 
                          my_store.add, BytesIO(b'hello'), b'aa')
 
125
                          my_store.add, StringIO('hello'), 'aa')
110
126
 
111
127
    def test_total_size(self):
112
128
        store = self.get_store()
113
 
        store.add(BytesIO(b'goodbye'), b'123123')
114
 
        store.add(BytesIO(b'goodbye2'), b'123123.dsc')
 
129
        store.add(StringIO('goodbye'), '123123')
 
130
        store.add(StringIO('goodbye2'), '123123.dsc')
115
131
        self.assertEqual(store.total_size(), (2, 15))
116
132
        # TODO: Switch the exception form UnlistableStore to
117
133
        #       or make Stores throw UnlistableStore if their
128
144
 
129
145
    def test_total_size(self):
130
146
        store = self.get_store()
131
 
        store.add(BytesIO(b'goodbye'), b'123123')
132
 
        store.add(BytesIO(b'goodbye2'), b'123123.dsc')
 
147
        store.add(StringIO('goodbye'), '123123')
 
148
        store.add(StringIO('goodbye2'), '123123.dsc')
133
149
        self.assertEqual(store.total_size(), (2, 15))
134
150
        # TODO: Switch the exception form UnlistableStore to
135
151
        #       or make Stores throw UnlistableStore if their
147
163
    def test_get_mixed(self):
148
164
        cs = self.get_store(u'.', compressed=True)
149
165
        s = self.get_store(u'.', compressed=False)
150
 
        cs.add(BytesIO(b'hello there'), b'a')
 
166
        cs.add(StringIO('hello there'), 'a')
151
167
 
152
168
        self.assertPathExists('a.gz')
153
169
        self.assertFalse(os.path.lexists('a'))
154
170
 
155
 
        with gzip.GzipFile('a.gz') as f:
156
 
            self.assertEqual(f.read(), b'hello there')
157
 
 
158
 
        self.assertEqual(cs.has_id(b'a'), True)
159
 
        self.assertEqual(s.has_id(b'a'), True)
160
 
        self.assertEqual(cs.get(b'a').read(), b'hello there')
161
 
        self.assertEqual(s.get(b'a').read(), b'hello there')
162
 
 
163
 
        self.assertRaises(BzrError, s.add, BytesIO(b'goodbye'), b'a')
164
 
 
165
 
        s.add(BytesIO(b'goodbye'), b'b')
 
171
        self.assertEqual(gzip.GzipFile('a.gz').read(), 'hello there')
 
172
 
 
173
        self.assertEqual(cs.has_id('a'), True)
 
174
        self.assertEqual(s.has_id('a'), True)
 
175
        self.assertEqual(cs.get('a').read(), 'hello there')
 
176
        self.assertEqual(s.get('a').read(), 'hello there')
 
177
 
 
178
        self.assertRaises(BzrError, s.add, StringIO('goodbye'), 'a')
 
179
 
 
180
        s.add(StringIO('goodbye'), 'b')
166
181
        self.assertPathExists('b')
167
182
        self.assertFalse(os.path.lexists('b.gz'))
168
 
        with open('b', 'rb') as f:
169
 
            self.assertEqual(f.read(), b'goodbye')
170
 
 
171
 
        self.assertEqual(cs.has_id(b'b'), True)
172
 
        self.assertEqual(s.has_id(b'b'), True)
173
 
        self.assertEqual(cs.get(b'b').read(), b'goodbye')
174
 
        self.assertEqual(s.get(b'b').read(), b'goodbye')
175
 
 
176
 
        self.assertRaises(BzrError, cs.add, BytesIO(b'again'), b'b')
177
 
 
 
183
        self.assertEqual(open('b').read(), 'goodbye')
 
184
 
 
185
        self.assertEqual(cs.has_id('b'), True)
 
186
        self.assertEqual(s.has_id('b'), True)
 
187
        self.assertEqual(cs.get('b').read(), 'goodbye')
 
188
        self.assertEqual(s.get('b').read(), 'goodbye')
 
189
 
 
190
        self.assertRaises(BzrError, cs.add, StringIO('again'), 'b')
178
191
 
179
192
class MockTransport(transport.Transport):
180
193
    """A fake transport for testing with."""
230
243
 
231
244
    def test__relpath_invalid(self):
232
245
        my_store = TransportStore(MockTransport())
233
 
        self.assertRaises(ValueError, my_store._relpath, b'/foo')
234
 
        self.assertRaises(ValueError, my_store._relpath, b'foo/')
 
246
        self.assertRaises(ValueError, my_store._relpath, '/foo')
 
247
        self.assertRaises(ValueError, my_store._relpath, 'foo/')
235
248
 
236
249
    def test_register_invalid_suffixes(self):
237
250
        my_store = TransportStore(MockTransport())
240
253
 
241
254
    def test__relpath_unregister_suffixes(self):
242
255
        my_store = TransportStore(MockTransport())
243
 
        self.assertRaises(ValueError, my_store._relpath, b'foo', [b'gz'])
244
 
        self.assertRaises(ValueError, my_store._relpath,
245
 
                          b'foo', [b'dsc', b'gz'])
 
256
        self.assertRaises(ValueError, my_store._relpath, 'foo', ['gz'])
 
257
        self.assertRaises(ValueError, my_store._relpath, 'foo', ['dsc', 'gz'])
246
258
 
247
259
    def test__relpath_simple(self):
248
260
        my_store = TransportStore(MockTransport())
249
 
        self.assertEqual("foo", my_store._relpath(b'foo'))
 
261
        self.assertEqual("foo", my_store._relpath('foo'))
250
262
 
251
263
    def test__relpath_prefixed(self):
252
264
        my_store = TransportStore(MockTransport(), True)
253
 
        self.assertEqual('45/foo', my_store._relpath(b'foo'))
 
265
        self.assertEqual('45/foo', my_store._relpath('foo'))
254
266
 
255
267
    def test__relpath_simple_suffixed(self):
256
268
        my_store = TransportStore(MockTransport())
257
269
        my_store.register_suffix('bar')
258
270
        my_store.register_suffix('baz')
259
 
        self.assertEqual('foo.baz', my_store._relpath(b'foo', ['baz']))
260
 
        self.assertEqual('foo.bar.baz', my_store._relpath(
261
 
            b'foo', ['bar', 'baz']))
 
271
        self.assertEqual('foo.baz', my_store._relpath('foo', ['baz']))
 
272
        self.assertEqual('foo.bar.baz', my_store._relpath('foo', ['bar', 'baz']))
262
273
 
263
274
    def test__relpath_prefixed_suffixed(self):
264
275
        my_store = TransportStore(MockTransport(), True)
265
276
        my_store.register_suffix('bar')
266
277
        my_store.register_suffix('baz')
267
 
        self.assertEqual('45/foo.baz', my_store._relpath(b'foo', ['baz']))
 
278
        self.assertEqual('45/foo.baz', my_store._relpath('foo', ['baz']))
268
279
        self.assertEqual('45/foo.bar.baz',
269
 
                         my_store._relpath(b'foo', ['bar', 'baz']))
 
280
                         my_store._relpath('foo', ['bar', 'baz']))
270
281
 
271
282
    def test_add_simple(self):
272
 
        stream = BytesIO(b"content")
 
283
        stream = StringIO("content")
273
284
        my_store = InstrumentedTransportStore(MockTransport())
274
 
        my_store.add(stream, b"foo")
 
285
        my_store.add(stream, "foo")
275
286
        self.assertEqual([("_add", "foo", stream)], my_store._calls)
276
287
 
277
288
    def test_add_prefixed(self):
278
 
        stream = BytesIO(b"content")
 
289
        stream = StringIO("content")
279
290
        my_store = InstrumentedTransportStore(MockTransport(), True)
280
 
        my_store.add(stream, b"foo")
 
291
        my_store.add(stream, "foo")
281
292
        self.assertEqual([("_add", "45/foo", stream)], my_store._calls)
282
293
 
283
294
    def test_add_simple_suffixed(self):
284
 
        stream = BytesIO(b"content")
 
295
        stream = StringIO("content")
285
296
        my_store = InstrumentedTransportStore(MockTransport())
286
297
        my_store.register_suffix('dsc')
287
 
        my_store.add(stream, b"foo", b'dsc')
 
298
        my_store.add(stream, "foo", 'dsc')
288
299
        self.assertEqual([("_add", "foo.dsc", stream)], my_store._calls)
289
300
 
290
301
    def test_add_simple_suffixed(self):
291
 
        stream = BytesIO(b"content")
 
302
        stream = StringIO("content")
292
303
        my_store = InstrumentedTransportStore(MockTransport(), True)
293
304
        my_store.register_suffix('dsc')
294
 
        my_store.add(stream, b"foo", 'dsc')
 
305
        my_store.add(stream, "foo", 'dsc')
295
306
        self.assertEqual([("_add", "45/foo.dsc", stream)], my_store._calls)
296
307
 
297
308
    def get_populated_store(self, prefixed=False,
298
 
                            store_class=TextStore, compressed=False):
 
309
            store_class=TextStore, compressed=False):
299
310
        my_store = store_class(MemoryTransport(), prefixed,
300
311
                               compressed=compressed)
301
312
        my_store.register_suffix('sig')
302
 
        stream = BytesIO(b"signature")
303
 
        my_store.add(stream, b"foo", 'sig')
304
 
        stream = BytesIO(b"content")
305
 
        my_store.add(stream, b"foo")
306
 
        stream = BytesIO(b"signature for missing base")
307
 
        my_store.add(stream, b"missing", 'sig')
 
313
        stream = StringIO("signature")
 
314
        my_store.add(stream, "foo", 'sig')
 
315
        stream = StringIO("content")
 
316
        my_store.add(stream, "foo")
 
317
        stream = StringIO("signature for missing base")
 
318
        my_store.add(stream, "missing", 'sig')
308
319
        return my_store
309
320
 
310
321
    def test_has_simple(self):
311
322
        my_store = self.get_populated_store()
312
 
        self.assertEqual(True, my_store.has_id(b'foo'))
 
323
        self.assertEqual(True, my_store.has_id('foo'))
313
324
        my_store = self.get_populated_store(True)
314
 
        self.assertEqual(True, my_store.has_id(b'foo'))
 
325
        self.assertEqual(True, my_store.has_id('foo'))
315
326
 
316
327
    def test_has_suffixed(self):
317
328
        my_store = self.get_populated_store()
318
 
        self.assertEqual(True, my_store.has_id(b'foo', 'sig'))
 
329
        self.assertEqual(True, my_store.has_id('foo', 'sig'))
319
330
        my_store = self.get_populated_store(True)
320
 
        self.assertEqual(True, my_store.has_id(b'foo', 'sig'))
 
331
        self.assertEqual(True, my_store.has_id('foo', 'sig'))
321
332
 
322
333
    def test_has_suffixed_no_base(self):
323
334
        my_store = self.get_populated_store()
324
 
        self.assertEqual(False, my_store.has_id(b'missing'))
 
335
        self.assertEqual(False, my_store.has_id('missing'))
325
336
        my_store = self.get_populated_store(True)
326
 
        self.assertEqual(False, my_store.has_id(b'missing'))
 
337
        self.assertEqual(False, my_store.has_id('missing'))
327
338
 
328
339
    def test_get_simple(self):
329
340
        my_store = self.get_populated_store()
330
 
        self.assertEqual(b'content', my_store.get(b'foo').read())
 
341
        self.assertEqual('content', my_store.get('foo').read())
331
342
        my_store = self.get_populated_store(True)
332
 
        self.assertEqual(b'content', my_store.get(b'foo').read())
 
343
        self.assertEqual('content', my_store.get('foo').read())
333
344
 
334
345
    def test_get_suffixed(self):
335
346
        my_store = self.get_populated_store()
336
 
        self.assertEqual(b'signature', my_store.get(b'foo', 'sig').read())
 
347
        self.assertEqual('signature', my_store.get('foo', 'sig').read())
337
348
        my_store = self.get_populated_store(True)
338
 
        self.assertEqual(b'signature', my_store.get(b'foo', 'sig').read())
 
349
        self.assertEqual('signature', my_store.get('foo', 'sig').read())
339
350
 
340
351
    def test_get_suffixed_no_base(self):
341
352
        my_store = self.get_populated_store()
342
 
        self.assertEqual(b'signature for missing base',
343
 
                         my_store.get(b'missing', 'sig').read())
 
353
        self.assertEqual('signature for missing base',
 
354
                         my_store.get('missing', 'sig').read())
344
355
        my_store = self.get_populated_store(True)
345
 
        self.assertEqual(b'signature for missing base',
346
 
                         my_store.get(b'missing', 'sig').read())
 
356
        self.assertEqual('signature for missing base',
 
357
                         my_store.get('missing', 'sig').read())
347
358
 
348
359
    def test___iter__no_suffix(self):
349
360
        my_store = TextStore(MemoryTransport(),
350
361
                             prefixed=False, compressed=False)
351
 
        stream = BytesIO(b"content")
352
 
        my_store.add(stream, b"foo")
353
 
        self.assertEqual({b'foo'},
 
362
        stream = StringIO("content")
 
363
        my_store.add(stream, "foo")
 
364
        self.assertEqual(set(['foo']),
354
365
                         set(my_store.__iter__()))
355
366
 
356
367
    def test___iter__(self):
357
 
        self.assertEqual({b'foo'},
 
368
        self.assertEqual(set(['foo']),
358
369
                         set(self.get_populated_store().__iter__()))
359
 
        self.assertEqual({b'foo'},
 
370
        self.assertEqual(set(['foo']),
360
371
                         set(self.get_populated_store(True).__iter__()))
361
372
 
362
373
    def test___iter__compressed(self):
363
 
        self.assertEqual({b'foo'},
 
374
        self.assertEqual(set(['foo']),
364
375
                         set(self.get_populated_store(
365
376
                             compressed=True).__iter__()))
366
 
        self.assertEqual({b'foo'},
 
377
        self.assertEqual(set(['foo']),
367
378
                         set(self.get_populated_store(
368
379
                             True, compressed=True).__iter__()))
369
380
 
370
381
    def test___len__(self):
371
382
        self.assertEqual(1, len(self.get_populated_store()))
372
383
 
 
384
    def test_copy_suffixes(self):
 
385
        from_store = self.get_populated_store()
 
386
        to_store = TextStore(MemoryTransport(),
 
387
                             prefixed=True, compressed=True)
 
388
        to_store.register_suffix('sig')
 
389
        to_store.copy_all_ids(from_store)
 
390
        self.assertEqual(1, len(to_store))
 
391
        self.assertEqual(set(['foo']), set(to_store.__iter__()))
 
392
        self.assertEqual('content', to_store.get('foo').read())
 
393
        self.assertEqual('signature', to_store.get('foo', 'sig').read())
 
394
        self.assertRaises(KeyError, to_store.get, 'missing', 'sig')
 
395
 
373
396
    def test_relpath_escaped(self):
374
397
        my_store = TransportStore(MemoryTransport())
375
 
        self.assertEqual('%25', my_store._relpath(b'%'))
 
398
        self.assertEqual('%25', my_store._relpath('%'))
376
399
 
377
400
    def test_escaped_uppercase(self):
378
401
        """Uppercase letters are escaped for safety on Windows"""
379
402
        my_store = TransportStore(MemoryTransport(), prefixed=True,
380
 
                                  escaped=True)
 
403
            escaped=True)
381
404
        # a particularly perverse file-id! :-)
382
 
        self.assertEqual(my_store._relpath(b'C:<>'), 'be/%2543%253a%253c%253e')
 
405
        self.assertEqual(my_store._relpath('C:<>'), 'be/%2543%253a%253c%253e')
383
406
 
384
407
 
385
408
class TestVersionFileStore(TestCaseWithTransport):
390
413
    def setUp(self):
391
414
        super(TestVersionFileStore, self).setUp()
392
415
        self.vfstore = VersionedFileStore(MemoryTransport(),
393
 
                                          versionedfile_class=WeaveFile)
 
416
            versionedfile_class=WeaveFile)
394
417
        self.vfstore.get_scope = self.get_scope
395
418
        self._transaction = None
396
419
 
397
420
    def test_get_weave_registers_dirty_in_write(self):
398
421
        self._transaction = transactions.WriteTransaction()
399
 
        vf = self.vfstore.get_weave_or_empty(b'id', self._transaction)
 
422
        vf = self.vfstore.get_weave_or_empty('id', self._transaction)
400
423
        self._transaction.finish()
401
424
        self._transaction = None
402
 
        self.assertRaises(errors.OutSideTransaction,
403
 
                          vf.add_lines, b'b', [], [])
 
425
        self.assertRaises(errors.OutSideTransaction, vf.add_lines, 'b', [], [])
404
426
        self._transaction = transactions.WriteTransaction()
405
 
        vf = self.vfstore.get_weave(b'id', self._transaction)
 
427
        vf = self.vfstore.get_weave('id', self._transaction)
406
428
        self._transaction.finish()
407
429
        self._transaction = None
408
 
        self.assertRaises(errors.OutSideTransaction,
409
 
                          vf.add_lines, b'b', [], [])
 
430
        self.assertRaises(errors.OutSideTransaction, vf.add_lines, 'b', [], [])
410
431
 
411
432
    def test_get_weave_readonly_cant_write(self):
412
433
        self._transaction = transactions.WriteTransaction()
413
 
        vf = self.vfstore.get_weave_or_empty(b'id', self._transaction)
 
434
        vf = self.vfstore.get_weave_or_empty('id', self._transaction)
414
435
        self._transaction.finish()
415
436
        self._transaction = transactions.ReadOnlyTransaction()
416
 
        vf = self.vfstore.get_weave_or_empty(b'id', self._transaction)
417
 
        self.assertRaises(errors.ReadOnlyError, vf.add_lines, b'b', [], [])
 
437
        vf = self.vfstore.get_weave_or_empty('id', self._transaction)
 
438
        self.assertRaises(errors.ReadOnlyError, vf.add_lines, 'b', [], [])
418
439
 
419
440
    def test___iter__escaped(self):
420
441
        self.vfstore = VersionedFileStore(MemoryTransport(),
421
 
                                          prefixed=True, escaped=True, versionedfile_class=WeaveFile)
 
442
            prefixed=True, escaped=True, versionedfile_class=WeaveFile)
422
443
        self.vfstore.get_scope = self.get_scope
423
444
        self._transaction = transactions.WriteTransaction()
424
 
        vf = self.vfstore.get_weave_or_empty(b' ', self._transaction)
425
 
        vf.add_lines(b'a', [], [])
 
445
        vf = self.vfstore.get_weave_or_empty(' ', self._transaction)
 
446
        vf.add_lines('a', [], [])
426
447
        del vf
427
448
        self._transaction.finish()
428
 
        self.assertEqual([b' '], list(self.vfstore))
 
449
        self.assertEqual([' '], list(self.vfstore))