/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_read_bundle.py

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
def load_tests(standard_tests, module, loader):
36
36
    """Multiply tests for tranport implementations."""
37
37
    transport_tests, remaining_tests = tests.split_suite_by_condition(
38
 
        standard_tests, tests.condition_isinstance(TestReadBundleFromURL))
 
38
        standard_tests,
 
39
        tests.condition_isinstance(TestReadMergeableBundleFromURL))
39
40
    return tests.multiply_tests(transport_tests, transport_test_permutations(),
40
41
        remaining_tests)
41
42
 
60
61
    return out, wt
61
62
 
62
63
 
63
 
class TestDeprecations(tests.TestCaseInTempDir):
64
 
 
65
 
    def create_test_bundle(self):
66
 
        out, wt = create_bundle_file(self)
67
 
        f = open('test_bundle', 'wb')
68
 
        try:
69
 
            f.write(out.getvalue())
70
 
        finally:
71
 
            f.close()
72
 
        return wt
73
 
 
74
 
    def test_read_bundle_from_url_deprecated(self):
75
 
        wt = self.create_test_bundle()
76
 
        t = bzrlib.transport.get_transport(self.test_dir)
77
 
        url = t.abspath('test_bundle')
78
 
        self.callDeprecated([deprecated_in((1, 12, 0))
79
 
                             % 'bzrlib.bundle.read_bundle_from_url'],
80
 
                            bzrlib.bundle.read_bundle_from_url,
81
 
                            url)
82
 
 
83
 
 
84
 
class TestReadBundleFromURL(TestTransportImplementation):
 
64
class TestReadMergeableBundleFromURL(TestTransportImplementation):
85
65
    """Test that read_bundle works properly across multiple transports"""
86
66
 
87
67
    def setUp(self):
88
 
        super(TestReadBundleFromURL, self).setUp()
 
68
        super(TestReadMergeableBundleFromURL, self).setUp()
89
69
        self.bundle_name = 'test_bundle'
90
70
        # read_mergeable_from_url will invoke get_transport which may *not*
91
71
        # respect self._transport (i.e. returns a transport that is different