~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_transport.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-02 19:20:30 UTC
  • mto: This revision was merged to the branch mainline in revision 5369.
  • Revision ID: john@arbash-meinel.com-20100802192030-p5ofsyvopbog4xj3
Simplify the test to better cope with platform and version variation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from StringIO import StringIO as pyStringIO
27
27
import stat
28
28
import sys
 
29
import unittest
29
30
 
30
31
from bzrlib import (
31
32
    errors,
32
33
    osutils,
33
 
    pyutils,
34
34
    tests,
35
35
    urlutils,
36
36
    )
37
37
from bzrlib.errors import (ConnectionError,
 
38
                           DirectoryNotEmpty,
38
39
                           FileExists,
39
40
                           InvalidURL,
 
41
                           LockError,
40
42
                           NoSuchFile,
 
43
                           NotLocalUrl,
41
44
                           PathError,
42
45
                           TransportNotPossible,
43
46
                           )
44
47
from bzrlib.osutils import getcwd
45
48
from bzrlib.smart import medium
46
49
from bzrlib.tests import (
 
50
    TestCaseInTempDir,
47
51
    TestSkipped,
48
52
    TestNotApplicable,
49
53
    multiply_tests,
74
78
    for module in _get_transport_modules():
75
79
        try:
76
80
            permutations = get_transport_test_permutations(
77
 
                pyutils.get_named_object(module))
 
81
                reduce(getattr, (module).split('.')[1:], __import__(module)))
78
82
            for (klass, server_factory) in permutations:
79
83
                scenario = ('%s,%s' % (klass.__name__, server_factory.__name__),
80
84
                    {"transport_class":klass,
98
102
 
99
103
    def setUp(self):
100
104
        super(TransportTests, self).setUp()
101
 
        self.overrideEnv('BZR_NO_SMART_VFS', None)
 
105
        self._captureVar('BZR_NO_SMART_VFS', None)
102
106
 
103
107
    def check_transport_contents(self, content, transport, relpath):
104
108
        """Check that transport.get(relpath).read() == content."""
247
251
 
248
252
    def test_get_bytes_unknown_file(self):
249
253
        t = self.get_transport()
 
254
 
250
255
        self.assertRaises(NoSuchFile, t.get_bytes, 'c')
251
256
 
252
257
    def test_get_with_open_write_stream_sees_all_content(self):
1261
1266
        self.assertIs(t._get_connection(), c._get_connection())
1262
1267
 
1263
1268
        # Temporary failure, we need to create a new dummy connection
1264
 
        new_connection = None
 
1269
        new_connection = object()
1265
1270
        t._set_connection(new_connection)
1266
1271
        # Check that both transports use the same connection
1267
1272
        self.assertIs(new_connection, t._get_connection())