~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-23 17:54:07 UTC
  • mfrom: (5387 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100823175407-yomx2h1x5v8amt6w
Merge bzr.dev 5387 in prep for NEWS

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
 
        # 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'))
 
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")
866
870
        # now transform to rename
867
871
        rename_transform, root_id = self.get_transform()
868
872
        file_trans_id = rename_transform.trans_id_file_id('myfile-id')
870
874
        rename_transform.adjust_path('newname', dir_id, file_trans_id)
871
875
        e = self.assertRaises(errors.TransformRenameFailed,
872
876
            rename_transform.apply)
873
 
        # Looks like: 
 
877
        # On nix looks like: 
874
878
        # "Failed to rename .../work/.bzr/checkout/limbo/new-1
875
879
        # to .../first-dir/newname: [Errno 13] Permission denied"
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
 
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
878
884
        self.assertContainsRe(str(e),
879
 
            "Failed to rename .*first-dir.newname:")
 
885
            "Failed to rename .*(first-dir.newname:|myfile)")
880
886
 
881
887
    def test_set_executability_order(self):
882
888
        """Ensure that executability behaves the same, no matter what order.