251
256
val = regen('clean: {clean}', check_for_clean=True)
252
257
self.assertEqual(val, 'clean: 0')
253
258
os.remove('branch/c')
261
class TestBuilder(version_info_formats.VersionInfoBuilder):
265
class TestVersionInfoFormatRegistry(tests.TestCase):
268
super(TestVersionInfoFormatRegistry, self).setUp()
269
registry = version_info_formats.format_registry
270
self._default_key = registry._default_key
271
self._dict = registry._dict.copy()
272
self._help_dict = registry._help_dict.copy()
273
self._info_dict = registry._info_dict.copy()
274
self.addCleanup(self._cleanup)
277
# Restore the registry to pristine state after the test runs
278
registry = version_info_formats.format_registry
279
registry._default_key = self._default_key
280
registry._dict = self._dict
281
registry._help_dict = self._help_dict
282
registry._info_dict = self._info_dict
284
def test_register_remove(self):
285
registry = version_info_formats.format_registry
286
registry.register('testbuilder',
287
TestBuilder, 'a simple test builder')
288
self.assertIs(TestBuilder, registry.get('testbuilder'))
289
self.assertEqual('a simple test builder',
290
registry.get_help('testbuilder'))
291
registry.remove('testbuilder')
292
self.assertRaises(KeyError, registry.get, 'testbuilder')
294
def test_old_functions(self):
295
self.applyDeprecated(symbol_versioning.one_zero,
296
version_info_formats.register_builder,
297
'test-builder', __name__, 'TestBuilder')
298
formats = self.applyDeprecated(symbol_versioning.one_zero,
299
version_info_formats.get_builder_formats)
300
self.failUnless('test-builder' in formats)
301
self.assertIs(TestBuilder,
302
self.applyDeprecated(symbol_versioning.one_zero,
303
version_info_formats.get_builder, 'test-builder'))
304
version_info_formats.format_registry.remove('test-builder')