/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 bzrlib/tests/test_osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2009-12-01 16:53:42 UTC
  • mto: (4850.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4851.
  • Revision ID: v.ladeuil+lp@free.fr-20091201165342-dlwehwo3cdfu59br
Mix BZR_CONCURRENCY and --concurrency so both are available.

* bzrlib/tests/test_osutils.py:
(TestConcurrency.setUp): Simplified.
(TestConcurrency.test_local_concurrency_environment_variable):
Restore the env varible tests.
(TestConcurrency.test_option_concurrency): Test the global option.

* bzrlib/tests/__init__.py:
(TestCase._cleanEnvironment): Add BZR_CONCURRENCY.

* bzrlib/osutils.py:
(local_concurrency): Simplify implementation: environment variable
overrides OS specific definition.

* bzrlib/help_topics/__init__.py:
(_env_variables): Restore the documentation.

* bzrlib/commands.py:
(run_bzr): Simplify --concurrency handling: it just overrides the
environment variable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1837
1837
 
1838
1838
    def setUp(self):
1839
1839
        super(TestConcurrency, self).setUp()
1840
 
        self.saved_concurrency_override = osutils._local_concurrency_override
1841
 
        self.addCleanup(self.restore_concurrency_override)
1842
 
 
1843
 
    def restore_concurrency_override(self):
1844
 
        osutils._local_concurrency_override = self.saved_concurrency_override
 
1840
        orig = osutils._cached_local_concurrency
 
1841
        def restore():
 
1842
            osutils._cached_local_concurrency = orig
 
1843
        self.addCleanup(restore)
1845
1844
 
1846
1845
    def test_local_concurrency(self):
1847
1846
        concurrency = osutils.local_concurrency()
1848
1847
        self.assertIsInstance(concurrency, int)
1849
1848
 
1850
 
    def test_local_concurrency_option(self):
1851
 
        osutils._local_concurrency_override = 2
1852
 
        self.assertEqual(2, osutils.local_concurrency(False))
1853
 
        osutils._local_concurrency_override = 3
1854
 
        self.assertEqual(3, osutils.local_concurrency(False))
1855
 
        #os.environ['BZR_CONCURRENCY'] = 'foo'
1856
 
        #self.assertEqual(1, osutils.local_concurrency(False))
 
1849
    def test_local_concurrency_environment_variable(self):
 
1850
        os.environ['BZR_CONCURRENCY'] = '2'
 
1851
        self.assertEqual(2, osutils.local_concurrency(use_cache=False))
 
1852
        os.environ['BZR_CONCURRENCY'] = '3'
 
1853
        self.assertEqual(3, osutils.local_concurrency(use_cache=False))
 
1854
        os.environ['BZR_CONCURRENCY'] = 'foo'
 
1855
        self.assertEqual(1, osutils.local_concurrency(use_cache=False))
 
1856
 
 
1857
    def test_option_concurrency(self):
 
1858
        os.environ['BZR_CONCURRENCY'] = '1'
 
1859
        self.run_bzr('rocks --concurrency 42')
 
1860
        # Command line overrides envrionment variable
 
1861
        self.assertEquals('42', os.environ['BZR_CONCURRENCY'])
 
1862
        self.assertEquals(42, osutils.local_concurrency(use_cache=False))
1857
1863
 
1858
1864
 
1859
1865
class TestFailedToLoadExtension(tests.TestCase):