~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Andrew Bennetts
  • Date: 2009-12-03 05:57:41 UTC
  • mfrom: (4857 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4869.
  • Revision ID: andrew.bennetts@canonical.com-20091203055741-vmmg0fmjgjw2pwvu
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
378
378
        # Instead blackbox.test_locale should check for localized
379
379
        # dates once they do occur in output strings.
380
380
 
 
381
    def test_format_date_with_offset_in_original_timezone(self):
 
382
        self.assertEqual("Thu 1970-01-01 00:00:00 +0000",
 
383
            osutils.format_date_with_offset_in_original_timezone(0))
 
384
        self.assertEqual("Fri 1970-01-02 03:46:40 +0000",
 
385
            osutils.format_date_with_offset_in_original_timezone(100000))
 
386
        self.assertEqual("Fri 1970-01-02 05:46:40 +0200",
 
387
            osutils.format_date_with_offset_in_original_timezone(100000, 7200))
 
388
 
381
389
    def test_local_time_offset(self):
382
390
        """Test that local_time_offset() returns a sane value."""
383
391
        offset = osutils.local_time_offset()
1847
1855
 
1848
1856
class TestConcurrency(tests.TestCase):
1849
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
 
1850
1865
    def test_local_concurrency(self):
1851
1866
        concurrency = osutils.local_concurrency()
1852
1867
        self.assertIsInstance(concurrency, int)
1853
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
 
1854
1884
 
1855
1885
class TestFailedToLoadExtension(tests.TestCase):
1856
1886