~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Jelmer Vernooij
  • Date: 2010-08-02 13:40:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5389.
  • Revision ID: jelmer@samba.org-20100802134008-kbinww4ikgqu8g1f
Add ControlDirFormat.{un,}register_{server_,}prober.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from bzrlib import (
27
27
    branch,
28
28
    bzrdir,
 
29
    controldir,
29
30
    errors,
30
31
    help_topics,
31
32
    repository,
1058
1059
    def _known_formats(self):
1059
1060
        return set([NotBzrDirFormat()])
1060
1061
 
1061
 
    @classmethod
 
1062
 
 
1063
class NotBzrDirProber(controldir.Prober):
 
1064
 
1062
1065
    def probe_transport(self, transport):
1063
1066
        """Our format is present if the transport ends in '.not/'."""
1064
1067
        if transport.has('.not'):
1078
1081
        dir = format.initialize(self.get_url())
1079
1082
        self.assertIsInstance(dir, NotBzrDir)
1080
1083
        # now probe for it.
1081
 
        bzrlib.controldir.ControlDirformat.register_format(format)
 
1084
        controldir.ControlDirFormat.register_prober(NotBzrDirProber)
1082
1085
        try:
1083
1086
            found = bzrlib.bzrdir.BzrDirFormat.find_format(
1084
1087
                get_transport(self.get_url()))
1085
1088
            self.assertIsInstance(found, NotBzrDirFormat)
1086
1089
        finally:
1087
 
            bzrlib.controldir.ControlDirformat.unregister_format(format)
 
1090
            controldir.ControlDirFormat.unregister_prober(NotBzrDirProber)
1088
1091
 
1089
1092
    def test_included_in_known_formats(self):
1090
 
        bzrlib.controldir.ControlDirformat.register_format(NotBzrDirFormat)
 
1093
        bzrlib.controldir.ControlDirFormat.register_format(NotBzrDirFormat)
1091
1094
        try:
1092
1095
            formats = bzrlib.bzrdir.BzrDirFormat.known_formats()
1093
1096
            for format in formats:
1095
1098
                    return
1096
1099
            self.fail("No NotBzrDirFormat in %s" % formats)
1097
1100
        finally:
1098
 
            bzrlib.controldir.ControlDirformat.unregister_format(NotBzrDirFormat)
 
1101
            bzrlib.controldir.ControlDirFormat.unregister_format(NotBzrDirFormat)
1099
1102
 
1100
1103
 
1101
1104
class NonLocalTests(TestCaseWithTransport):