~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_plugins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-11-03 21:16:53 UTC
  • mfrom: (3777.6.7 bzr.plugins)
  • Revision ID: pqm@pqm.ubuntu.com-20081103211653-vyode1g8p1lfsuzy
(Marius Kruger) Give a reasonable version string for plugins with
        invalid version_info values.

Show diffs side-by-side

added added

removed removed

Lines of Context:
353
353
        plugin = bzrlib.plugin.plugins()['plugin']
354
354
        self.assertEqual("unknown", plugin.__version__)
355
355
 
356
 
    def test___version__with_version_info(self):
 
356
    def test_str__version__with_version_info(self):
 
357
        self.setup_plugin("version_info = '1.2.3'")
 
358
        plugin = bzrlib.plugin.plugins()['plugin']
 
359
        self.assertEqual("1.2.3", plugin.__version__)
 
360
 
 
361
    def test_noniterable__version__with_version_info(self):
 
362
        self.setup_plugin("version_info = (1)")
 
363
        plugin = bzrlib.plugin.plugins()['plugin']
 
364
        self.assertEqual("1", plugin.__version__)
 
365
 
 
366
    def test_1__version__with_version_info(self):
 
367
        self.setup_plugin("version_info = (1,)")
 
368
        plugin = bzrlib.plugin.plugins()['plugin']
 
369
        self.assertEqual("1", plugin.__version__)
 
370
 
 
371
    def test_1_2__version__with_version_info(self):
 
372
        self.setup_plugin("version_info = (1, 2)")
 
373
        plugin = bzrlib.plugin.plugins()['plugin']
 
374
        self.assertEqual("1.2", plugin.__version__)
 
375
 
 
376
    def test_1_2_3__version__with_version_info(self):
 
377
        self.setup_plugin("version_info = (1, 2, 3)")
 
378
        plugin = bzrlib.plugin.plugins()['plugin']
 
379
        self.assertEqual("1.2.3", plugin.__version__)
 
380
 
 
381
    def test_candidate__version__with_version_info(self):
 
382
        self.setup_plugin("version_info = (1, 2, 3, 'candidate', 1)")
 
383
        plugin = bzrlib.plugin.plugins()['plugin']
 
384
        self.assertEqual("1.2.3rc1", plugin.__version__)
 
385
 
 
386
    def test_dev__version__with_version_info(self):
 
387
        self.setup_plugin("version_info = (1, 2, 3, 'dev', 0)")
 
388
        plugin = bzrlib.plugin.plugins()['plugin']
 
389
        self.assertEqual("1.2.3dev", plugin.__version__)
 
390
 
 
391
    def test_dev_fallback__version__with_version_info(self):
357
392
        self.setup_plugin("version_info = (1, 2, 3, 'dev', 4)")
358
393
        plugin = bzrlib.plugin.plugins()['plugin']
359
 
        self.assertEqual("1.2.3dev4", plugin.__version__)
 
394
        self.assertEqual("1.2.3.dev.4", plugin.__version__)
360
395
 
361
396
    def test_final__version__with_version_info(self):
362
 
        self.setup_plugin("version_info = (1, 2, 3, 'final', 4)")
 
397
        self.setup_plugin("version_info = (1, 2, 3, 'final', 0)")
363
398
        plugin = bzrlib.plugin.plugins()['plugin']
364
399
        self.assertEqual("1.2.3", plugin.__version__)
365
400