/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: Aaron Bentley
  • Date: 2009-09-29 04:40:55 UTC
  • mfrom: (4717 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4718.
  • Revision ID: aaron@aaronbentley.com-20090929044055-e9jtpmz6eyut711h
Merged bzr.dev into fix_get_mtime.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    errors,
30
30
    osutils,
31
31
    tests,
 
32
    trace,
32
33
    win32utils,
33
34
    )
34
35
from bzrlib.tests import (
446
447
    def test_canonical_relpath_simple(self):
447
448
        f = file('MixedCaseName', 'w')
448
449
        f.close()
449
 
        # Watch out for tricky test dir (on OSX /tmp -> /private/tmp)
450
 
        real_base_dir = osutils.realpath(self.test_base_dir)
451
 
        actual = osutils.canonical_relpath(real_base_dir, 'mixedcasename')
 
450
        actual = osutils.canonical_relpath(self.test_base_dir, 'mixedcasename')
452
451
        self.failUnlessEqual('work/MixedCaseName', actual)
453
452
 
454
453
    def test_canonical_relpath_missing_tail(self):
455
454
        os.mkdir('MixedCaseParent')
456
 
        # Watch out for tricky test dir (on OSX /tmp -> /private/tmp)
457
 
        real_base_dir = osutils.realpath(self.test_base_dir)
458
 
        actual = osutils.canonical_relpath(real_base_dir,
 
455
        actual = osutils.canonical_relpath(self.test_base_dir,
459
456
                                           'mixedcaseparent/nochild')
460
457
        self.failUnlessEqual('work/MixedCaseParent/nochild', actual)
461
458
 
1798
1795
    def test_local_concurrency(self):
1799
1796
        concurrency = osutils.local_concurrency()
1800
1797
        self.assertIsInstance(concurrency, int)
 
1798
 
 
1799
 
 
1800
class TestFailedToLoadExtension(tests.TestCase):
 
1801
 
 
1802
    def _try_loading(self):
 
1803
        try:
 
1804
            import bzrlib._fictional_extension_py
 
1805
        except ImportError, e:
 
1806
            osutils.failed_to_load_extension(e)
 
1807
            return True
 
1808
 
 
1809
    def setUp(self):
 
1810
        super(TestFailedToLoadExtension, self).setUp()
 
1811
        self.saved_failures = osutils._extension_load_failures[:]
 
1812
        del osutils._extension_load_failures[:]
 
1813
        self.addCleanup(self.restore_failures)
 
1814
 
 
1815
    def restore_failures(self):
 
1816
        osutils._extension_load_failures = self.saved_failures
 
1817
 
 
1818
    def test_failure_to_load(self):
 
1819
        self._try_loading()
 
1820
        self.assertLength(1, osutils._extension_load_failures)
 
1821
        self.assertEquals(osutils._extension_load_failures[0],
 
1822
            "No module named _fictional_extension_py")
 
1823
 
 
1824
    def test_report_extension_load_failures_no_warning(self):
 
1825
        self.assertTrue(self._try_loading())
 
1826
        warnings, result = self.callCatchWarnings(osutils.report_extension_load_failures)
 
1827
        # it used to give a Python warning; it no longer does
 
1828
        self.assertLength(0, warnings)
 
1829
 
 
1830
    def test_report_extension_load_failures_message(self):
 
1831
        log = StringIO()
 
1832
        trace.push_log_file(log)
 
1833
        self.assertTrue(self._try_loading())
 
1834
        osutils.report_extension_load_failures()
 
1835
        self.assertContainsRe(
 
1836
            log.getvalue(),
 
1837
            r"bzr: warning: some compiled extensions could not be loaded; "
 
1838
            "see <https://answers\.launchpad\.net/bzr/\+faq/703>\n"
 
1839
            )