/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: Canonical.com Patch Queue Manager
  • Date: 2009-03-10 00:49:23 UTC
  • mfrom: (4095.1.4 338653-oserror)
  • Revision ID: pqm@pqm.ubuntu.com-20090310004923-3gtpq4ned1d6xhoj
(mbp) better OSErrors from _readdir_pyx

Show diffs side-by-side

added added

removed removed

Lines of Context:
879
879
        self.assertEqual(expected_dirblocks[1:],
880
880
            [(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
881
881
 
 
882
    def test_walkdirs_os_error(self):
 
883
        # <https://bugs.edge.launchpad.net/bzr/+bug/338653>
 
884
        # Pyrex readdir didn't raise useful messages if it had an error
 
885
        # reading the directory
 
886
        if sys.platform == 'win32':
 
887
            raise tests.TestNotApplicable(
 
888
                "readdir IOError not tested on win32")
 
889
        os.mkdir("test-unreadable")
 
890
        os.chmod("test-unreadable", 0000)
 
891
        # must chmod it back so that it can be removed
 
892
        self.addCleanup(lambda: os.chmod("test-unreadable", 0700))
 
893
        # The error is not raised until the generator is actually evaluated.
 
894
        # (It would be ok if it happened earlier but at the moment it
 
895
        # doesn't.)
 
896
        e = self.assertRaises(OSError, list,
 
897
            osutils._walkdirs_utf8("."))
 
898
        self.assertEquals(e.filename, './test-unreadable')
 
899
        self.assertEquals(str(e),
 
900
            "[Errno 13] chdir: Permission denied: './test-unreadable'")
 
901
 
882
902
    def test__walkdirs_utf8(self):
883
903
        tree = [
884
904
            '.bzr',