/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

local_concurrency can be overridden from command-line

Show diffs side-by-side

added added

removed removed

Lines of Context:
1855
1855
 
1856
1856
class TestConcurrency(tests.TestCase):
1857
1857
 
 
1858
    def setUp(self):
 
1859
        super(TestConcurrency, self).setUp()
 
1860
        orig = osutils._cached_local_concurrency
 
1861
        def restore():
 
1862
            osutils._cached_local_concurrency = orig
 
1863
        self.addCleanup(restore)
 
1864
 
1858
1865
    def test_local_concurrency(self):
1859
1866
        concurrency = osutils.local_concurrency()
1860
1867
        self.assertIsInstance(concurrency, int)
1861
1868
 
 
1869
    def test_local_concurrency_environment_variable(self):
 
1870
        os.environ['BZR_CONCURRENCY'] = '2'
 
1871
        self.assertEqual(2, osutils.local_concurrency(use_cache=False))
 
1872
        os.environ['BZR_CONCURRENCY'] = '3'
 
1873
        self.assertEqual(3, osutils.local_concurrency(use_cache=False))
 
1874
        os.environ['BZR_CONCURRENCY'] = 'foo'
 
1875
        self.assertEqual(1, osutils.local_concurrency(use_cache=False))
 
1876
 
 
1877
    def test_option_concurrency(self):
 
1878
        os.environ['BZR_CONCURRENCY'] = '1'
 
1879
        self.run_bzr('rocks --concurrency 42')
 
1880
        # Command line overrides envrionment variable
 
1881
        self.assertEquals('42', os.environ['BZR_CONCURRENCY'])
 
1882
        self.assertEquals(42, osutils.local_concurrency(use_cache=False))
 
1883
 
1862
1884
 
1863
1885
class TestFailedToLoadExtension(tests.TestCase):
1864
1886