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

  • Committer: Jelmer Vernooij
  • Date: 2018-05-06 11:48:54 UTC
  • mto: This revision was merged to the branch mainline in revision 6960.
  • Revision ID: jelmer@jelmer.uk-20180506114854-h4qd9ojaqy8wxjsd
Move .mailmap to root.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        format = SampleComponentFormat()
60
60
        self.registry.register(format)
61
61
        self.assertEqual(format,
62
 
                         self.registry.get(b"Example component format."))
 
62
            self.registry.get(b"Example component format."))
63
63
        self.registry.remove(format)
64
64
        self.assertRaises(KeyError, self.registry.get,
65
 
                          b"Example component format.")
 
65
            b"Example component format.")
66
66
 
67
67
    def test_get_all(self):
68
68
        format = SampleComponentFormat()
87
87
    def test_register_extra_lazy(self):
88
88
        self.assertEqual([], self.registry._get_all())
89
89
        self.registry.register_extra_lazy("breezy.tests.test_controldir",
90
 
                                          "SampleExtraComponentFormat")
 
90
            "SampleExtraComponentFormat")
91
91
        formats = self.registry._get_all()
92
92
        self.assertEqual(1, len(formats))
93
93
        self.assertIsInstance(formats[0], SampleExtraComponentFormat)
104
104
        super(TestProber, self).setUp()
105
105
        self.prober = self.prober_cls()
106
106
 
107
 
    def test_priority(self):
108
 
        transport = self.get_transport(".")
109
 
        self.assertIsInstance(self.prober.priority(transport), int)
110
 
 
111
107
    def test_probe_transport_empty(self):
112
108
        transport = self.get_transport(".")
113
109
        self.assertRaises(errors.NotBranchError,
114
 
                          self.prober.probe_transport, transport)
 
110
            self.prober.probe_transport, transport)
115
111
 
116
112
    def test_known_formats(self):
117
113
        known_formats = self.prober_cls.known_formats()
118
 
        self.assertIsInstance(known_formats, list)
 
114
        self.assertIsInstance(known_formats, set)
119
115
        for format in known_formats:
120
116
            self.assertIsInstance(format, controldir.ControlDirFormat,
121
 
                                  repr(format))
 
117
                repr(format))
122
118
 
123
119
 
124
120
class NotBzrDir(controldir.ControlDir):
152
148
 
153
149
    @classmethod
154
150
    def known_formats(cls):
155
 
        return [NotBzrDirFormat()]
 
151
        return {NotBzrDirFormat()}
156
152
 
157
153
 
158
154
class TestNotBzrDir(tests.TestCaseWithTransport):
170
166
        # now probe for it.
171
167
        controldir.ControlDirFormat.register_prober(NotBzrDirProber)
172
168
        try:
173
 
            found = controldir.ControlDirFormat.find_format(
174
 
                self.get_transport())
 
169
            found = controldir.ControlDirFormat.find_format(self.get_transport())
175
170
            self.assertIsInstance(found, NotBzrDirFormat)
176
171
        finally:
177
172
            controldir.ControlDirFormat.unregister_prober(NotBzrDirProber)
178
173
 
179
174
    def test_included_in_known_formats(self):
180
175
        controldir.ControlDirFormat.register_prober(NotBzrDirProber)
181
 
        self.addCleanup(
182
 
            controldir.ControlDirFormat.unregister_prober, NotBzrDirProber)
 
176
        self.addCleanup(controldir.ControlDirFormat.unregister_prober, NotBzrDirProber)
183
177
        formats = controldir.ControlDirFormat.known_formats()
184
 
        self.assertIsInstance(formats, list)
 
178
        self.assertIsInstance(formats, set)
185
179
        for format in formats:
186
180
            if isinstance(format, NotBzrDirFormat):
187
181
                break
208
202
 
209
203
    def test_check_support_status_unsupported(self):
210
204
        self.assertRaises(errors.UnsupportedFormatError,
211
 
                          UnsupportedControlComponentFormat().check_support_status,
212
 
                          allow_unsupported=False)
 
205
            UnsupportedControlComponentFormat().check_support_status,
 
206
            allow_unsupported=False)
213
207
        UnsupportedControlComponentFormat().check_support_status(
214
208
            allow_unsupported=True)
215
209
 
223
217
        ui.ui_factory = tests.TestUIFactory()
224
218
        format = controldir.ControlComponentFormat()
225
219
        format.check_support_status(allow_unsupported=False,
226
 
                                    recommend_upgrade=True)
 
220
            recommend_upgrade=True)
227
221
        self.assertEqual("", ui.ui_factory.stderr.getvalue())
228
222
 
229
223
    def test_recommend_upgrade_old_format(self):
230
224
        ui.ui_factory = tests.TestUIFactory()
231
225
        format = OldControlComponentFormat()
232
226
        format.check_support_status(allow_unsupported=False,
233
 
                                    recommend_upgrade=False)
 
227
            recommend_upgrade=False)
234
228
        self.assertEqual("", ui.ui_factory.stderr.getvalue())
235
229
        format.check_support_status(allow_unsupported=False,
236
 
                                    recommend_upgrade=True, basedir='apath')
 
230
            recommend_upgrade=True, basedir='apath')
237
231
        self.assertEqual(
238
232
            'An old format that is slow is deprecated and a better format '
239
233
            'is available.\nIt is recommended that you upgrade by running '
245
239
 
246
240
    def test_is_bzrdir(self):
247
241
        self.assertTrue(controldir.is_control_filename('.bzr'))
248
 
        self.assertTrue(controldir.is_control_filename('.git'))
249
242
 
250
243
    def test_is_not_bzrdir(self):
 
244
        self.assertFalse(controldir.is_control_filename('.git'))
251
245
        self.assertFalse(controldir.is_control_filename('bla'))