/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 breezy/tests/test_transport.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
from cStringIO import StringIO
19
18
import errno
20
19
import os
21
20
import subprocess
22
21
import sys
23
22
import threading
24
23
 
25
 
from breezy import (
 
24
from .. import (
26
25
    errors,
27
26
    osutils,
28
27
    tests,
29
28
    transport,
30
29
    urlutils,
31
30
    )
32
 
from breezy.directory_service import directories
33
 
from breezy.transport import (
 
31
from ..directory_service import directories
 
32
from ..sixish import (
 
33
    BytesIO,
 
34
    )
 
35
from ..transport import (
34
36
    chroot,
35
37
    fakenfs,
36
38
    http,
41
43
    readonly,
42
44
    )
43
45
import breezy.transport.trace
44
 
from breezy.tests import (
 
46
from . import (
45
47
    features,
46
48
    test_server,
47
49
    )
93
95
            'foo', 'breezy.tests.test_transport', 'BadTransportHandler')
94
96
        try:
95
97
            transport.get_transport_from_url('foo://fooserver/foo')
96
 
        except errors.UnsupportedProtocol, e:
 
98
        except errors.UnsupportedProtocol as e:
97
99
            e_str = str(e)
98
100
            self.assertEqual('Unsupported protocol'
99
101
                                ' for url "foo://fooserver/foo":'
119
121
        """Transport ssh:// should raise an error pointing out bzr+ssh://"""
120
122
        try:
121
123
            transport.get_transport_from_url('ssh://fooserver/foo')
122
 
        except errors.UnsupportedProtocol, e:
 
124
        except errors.UnsupportedProtocol as e:
123
125
            e_str = str(e)
124
126
            self.assertEqual('Unsupported protocol'
125
127
                              ' for url "ssh://fooserver/foo":'
134
136
        a_file = transport.LateReadError('a path')
135
137
        try:
136
138
            a_file.read()
137
 
        except errors.ReadError, error:
 
139
        except errors.ReadError as error:
138
140
            self.assertEqual('a path', error.path)
139
141
        self.assertRaises(errors.ReadError, a_file.read, 40)
140
142
        a_file.close()
272
274
        t = memory.MemoryTransport()
273
275
        t.append_bytes('path', 'content')
274
276
        self.assertEqual(t.get('path').read(), 'content')
275
 
        t.append_file('path', StringIO('content'))
 
277
        t.append_file('path', BytesIO(b'content'))
276
278
        self.assertEqual(t.get('path').read(), 'contentcontent')
277
279
 
278
280
    def test_put_and_get(self):
279
281
        t = memory.MemoryTransport()
280
 
        t.put_file('path', StringIO('content'))
 
282
        t.put_file('path', BytesIO(b'content'))
281
283
        self.assertEqual(t.get('path').read(), 'content')
282
284
        t.put_bytes('path', 'content')
283
285
        self.assertEqual(t.get('path').read(), 'content')
290
292
    def test_put_without_dir_fails(self):
291
293
        t = memory.MemoryTransport()
292
294
        self.assertRaises(errors.NoSuchFile,
293
 
                          t.put_file, 'dir/path', StringIO('content'))
 
295
                          t.put_file, 'dir/path', BytesIO(b'content'))
294
296
 
295
297
    def test_get_missing(self):
296
298
        transport = memory.MemoryTransport()
342
344
        t.put_bytes('dir/bar', 'content')
343
345
        t.put_bytes('bar', 'content')
344
346
        paths = set(t.iter_files_recursive())
345
 
        self.assertEqual(set(['dir/foo', 'dir/bar', 'bar']), paths)
 
347
        self.assertEqual({'dir/foo', 'dir/bar', 'bar'}, paths)
346
348
 
347
349
    def test_stat(self):
348
350
        t = memory.MemoryTransport()
780
782
            raise e
781
783
        self.overrideAttr(os, 'chmod', fake_chmod)
782
784
        t.mkdir('test')
783
 
        t.mkdir('test2', mode=0707)
 
785
        t.mkdir('test2', mode=0o707)
784
786
        self.assertTrue(os.path.exists('test'))
785
787
        self.assertTrue(os.path.exists('test2'))
786
788