1
# Copyright (C) 2011 Canonical Ltd
1
# Copyright (C) 2011, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
50
50
def test_register_unregister_format(self):
51
51
format = SampleComponentFormat()
52
52
self.registry.register(format)
53
self.assertEquals(format,
53
self.assertEqual(format,
54
54
self.registry.get("Example component format."))
55
55
self.registry.remove(format)
56
56
self.assertRaises(KeyError, self.registry.get,
59
59
def test_get_all(self):
60
60
format = SampleComponentFormat()
61
self.assertEquals([], self.registry._get_all())
61
self.assertEqual([], self.registry._get_all())
62
62
self.registry.register(format)
63
self.assertEquals([format], self.registry._get_all())
63
self.assertEqual([format], self.registry._get_all())
65
65
def test_get_all_modules(self):
66
66
format = SampleComponentFormat()
67
self.assertEquals(set(), self.registry._get_all_modules())
67
self.assertEqual(set(), self.registry._get_all_modules())
68
68
self.registry.register(format)
70
70
set(["bzrlib.tests.test_controldir"]),
71
71
self.registry._get_all_modules())
73
73
def test_register_extra(self):
74
74
format = SampleExtraComponentFormat()
75
self.assertEquals([], self.registry._get_all())
75
self.assertEqual([], self.registry._get_all())
76
76
self.registry.register_extra(format)
77
self.assertEquals([format], self.registry._get_all())
77
self.assertEqual([format], self.registry._get_all())
79
79
def test_register_extra_lazy(self):
80
self.assertEquals([], self.registry._get_all())
80
self.assertEqual([], self.registry._get_all())
81
81
self.registry.register_extra_lazy("bzrlib.tests.test_controldir",
82
82
"SampleExtraComponentFormat")
83
83
formats = self.registry._get_all()
84
self.assertEquals(1, len(formats))
84
self.assertEqual(1, len(formats))
85
85
self.assertIsInstance(formats[0], SampleExtraComponentFormat)
219
219
format = controldir.ControlComponentFormat()
220
220
format.check_support_status(allow_unsupported=False,
221
221
recommend_upgrade=True)
222
self.assertEquals("", stderr.getvalue())
222
self.assertEqual("", stderr.getvalue())
224
224
def test_recommend_upgrade_old_format(self):
225
225
stderr = tests.StringIOWrapper()
227
227
format = OldControlComponentFormat()
228
228
format.check_support_status(allow_unsupported=False,
229
229
recommend_upgrade=False)
230
self.assertEquals("", stderr.getvalue())
230
self.assertEqual("", stderr.getvalue())
231
231
format.check_support_status(allow_unsupported=False,
232
232
recommend_upgrade=True, basedir='apath')
234
234
'An old format that is slow is deprecated and a better format '
235
235
'is available.\nIt is recommended that you upgrade by running '
236
236
'the command\n bzr upgrade apath\n',