~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Martin Pool
  • Date: 2010-07-21 09:58:42 UTC
  • mfrom: (4797.58.7 2.1)
  • mto: (5050.3.13 2.2)
  • mto: This revision was merged to the branch mainline in revision 5365.
  • Revision ID: mbp@canonical.com-20100721095842-hz0obu8gl0x05nty
merge up 2.1 to 2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
859
859
        myfile = create.new_file('myfile', root_id, 'myfile-text',
860
860
                                 'myfile-id')
861
861
        create.apply()
862
 
        if os.name == "posix" and sys.platform != "cygwin":
863
 
            # posix filesystems fail on renaming if the readonly bit is set
864
 
            osutils.make_readonly(self.wt.abspath('first-dir'))
865
 
        elif os.name == "nt":
866
 
            # windows filesystems fail on renaming open files
867
 
            self.addCleanup(file(self.wt.abspath('myfile')).close)
868
 
        else:
869
 
            self.skip("Don't know how to force a permissions error on rename")
 
862
        # make the file and directory readonly in the hope this will prevent
 
863
        # renames
 
864
        osutils.make_readonly(self.wt.abspath('first-dir'))
 
865
        osutils.make_readonly(self.wt.abspath('myfile'))
870
866
        # now transform to rename
871
867
        rename_transform, root_id = self.get_transform()
872
868
        file_trans_id = rename_transform.trans_id_file_id('myfile-id')
874
870
        rename_transform.adjust_path('newname', dir_id, file_trans_id)
875
871
        e = self.assertRaises(errors.TransformRenameFailed,
876
872
            rename_transform.apply)
877
 
        # On nix looks like: 
 
873
        # Looks like: 
878
874
        # "Failed to rename .../work/.bzr/checkout/limbo/new-1
879
875
        # to .../first-dir/newname: [Errno 13] Permission denied"
880
 
        # On windows looks like:
881
 
        # "Failed to rename .../work/myfile to 
882
 
        # .../work/.bzr/checkout/limbo/new-1: [Errno 13] Permission denied"
883
 
        # The strerror will vary per OS and language so it's not checked here
 
876
        # so the first filename is not visible in it; we expect a strerror but
 
877
        # it may vary per OS and language so it's not checked here
884
878
        self.assertContainsRe(str(e),
885
 
            "Failed to rename .*(first-dir.newname:|myfile)")
 
879
            "Failed to rename .*first-dir.newname:")
886
880
 
887
881
    def test_set_executability_order(self):
888
882
        """Ensure that executability behaves the same, no matter what order.