~jelmer/brz/fix-c-extensions

« back to all changes in this revision

Viewing changes to breezy/tests/test_bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
from .. import (
27
27
    branch,
 
28
    bzr,
28
29
    config,
29
30
    controldir,
30
31
    errors,
103
104
        my_format_registry.register_lazy('lazy', 'breezy.tests.test_bzrdir',
104
105
            'DeprecatedBzrDirFormat', 'Format registered lazily',
105
106
            deprecated=True)
106
 
        bzrdir.register_metadir(my_format_registry, 'knit',
 
107
        bzr.register_metadir(my_format_registry, 'knit',
107
108
            'breezy.bzr.knitrepo.RepositoryFormatKnit1',
108
109
            'Format using knits',
109
110
            )
110
111
        my_format_registry.set_default('knit')
111
 
        bzrdir.register_metadir(my_format_registry,
 
112
        bzr.register_metadir(my_format_registry,
112
113
            'branch6',
113
114
            'breezy.bzr.knitrepo.RepositoryFormatKnit3',
114
115
            'Experimental successor to knit.  Use at your own risk.',
115
116
            branch_format='breezy.bzr.branch.BzrBranchFormat6',
116
117
            experimental=True)
117
 
        bzrdir.register_metadir(my_format_registry,
 
118
        bzr.register_metadir(my_format_registry,
118
119
            'hidden format',
119
120
            'breezy.bzr.knitrepo.RepositoryFormatKnit3',
120
121
            'Experimental successor to knit.  Use at your own risk.',
281
282
    def test_find_format(self):
282
283
        # is the right format object found for a branch?
283
284
        # create a branch with a few known format objects.
284
 
        bzrdir.BzrProber.formats.register(BzrDirFormatTest1.get_format_string(),
 
285
        bzr.BzrProber.formats.register(BzrDirFormatTest1.get_format_string(),
285
286
            BzrDirFormatTest1())
286
 
        self.addCleanup(bzrdir.BzrProber.formats.remove,
 
287
        self.addCleanup(bzr.BzrProber.formats.remove,
287
288
            BzrDirFormatTest1.get_format_string())
288
 
        bzrdir.BzrProber.formats.register(BzrDirFormatTest2.get_format_string(),
 
289
        bzr.BzrProber.formats.register(BzrDirFormatTest2.get_format_string(),
289
290
            BzrDirFormatTest2())
290
 
        self.addCleanup(bzrdir.BzrProber.formats.remove,
 
291
        self.addCleanup(bzr.BzrProber.formats.remove,
291
292
            BzrDirFormatTest2.get_format_string())
292
293
        t = self.get_transport()
293
294
        self.build_tree(["foo/", "bar/"], transport=t)
318
319
        # make a bzrdir
319
320
        format.initialize(url)
320
321
        # register a format for it.
321
 
        bzrdir.BzrProber.formats.register(format.get_format_string(), format)
 
322
        bzr.BzrProber.formats.register(format.get_format_string(), format)
322
323
        # which bzrdir.Open will refuse (not supported)
323
324
        self.assertRaises(UnsupportedFormatError, bzrdir.BzrDir.open, url)
324
325
        # which bzrdir.open_containing will refuse (not supported)
327
328
        t = _mod_transport.get_transport_from_url(url)
328
329
        self.assertEqual(format.open(t), bzrdir.BzrDir.open_unsupported(url))
329
330
        # unregister the format
330
 
        bzrdir.BzrProber.formats.remove(format.get_format_string())
 
331
        bzr.BzrProber.formats.remove(format.get_format_string())
331
332
        # now open_downlevel should fail too.
332
333
        self.assertRaises(UnknownFormatError, bzrdir.BzrDir.open_unsupported, url)
333
334
 
1031
1032
    def test_with_features(self):
1032
1033
        tree = self.make_branch_and_tree('tree', format='2a')
1033
1034
        tree.controldir.update_feature_flags({"bar": "required"})
1034
 
        self.assertRaises(errors.MissingFeature, bzrdir.BzrDir.open, 'tree')
 
1035
        self.assertRaises(bzrdir.MissingFeature, bzrdir.BzrDir.open, 'tree')
1035
1036
        bzrdir.BzrDirMetaFormat1.register_feature('bar')
1036
1037
        self.addCleanup(bzrdir.BzrDirMetaFormat1.unregister_feature, 'bar')
1037
1038
        dir = bzrdir.BzrDir.open('tree')
1535
1536
        # Optional, so trigger an exception
1536
1537
        format = SampleBzrFormat()
1537
1538
        format.features = {"nested-trees": "required"}
1538
 
        self.assertRaises(errors.MissingFeature, format.check_support_status,
 
1539
        self.assertRaises(bzrdir.MissingFeature, format.check_support_status,
1539
1540
            True)
1540
1541
        self.addCleanup(SampleBzrFormat.unregister_feature, "nested-trees")
1541
1542
        SampleBzrFormat.register_feature("nested-trees")
1545
1546
        # treat unknown necessity as required
1546
1547
        format = SampleBzrFormat()
1547
1548
        format.features = {"nested-trees": "unknown"}
1548
 
        self.assertRaises(errors.MissingFeature, format.check_support_status,
 
1549
        self.assertRaises(bzrdir.MissingFeature, format.check_support_status,
1549
1550
            True)
1550
1551
        self.addCleanup(SampleBzrFormat.unregister_feature, "nested-trees")
1551
1552
        SampleBzrFormat.register_feature("nested-trees")