~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Martin
  • Date: 2010-07-04 07:09:09 UTC
  • mto: This revision was merged to the branch mainline in revision 5333.
  • Revision ID: gzlist@googlemail.com-20100704070909-r51s2leny0wjcqtn
Use same timestamp rounding logic as Inno, just in case

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
        imaginary_id = transform.trans_id_tree_path('imaginary')
124
124
        imaginary_id2 = transform.trans_id_tree_path('imaginary/')
125
125
        self.assertEqual(imaginary_id, imaginary_id2)
126
 
        self.assertEqual(root, transform.get_tree_parent(imaginary_id))
127
 
        self.assertEqual('directory', transform.final_kind(root))
128
 
        self.assertEqual(self.wt.get_root_id(), transform.final_file_id(root))
 
126
        self.assertEqual(transform.get_tree_parent(imaginary_id), root)
 
127
        self.assertEqual(transform.final_kind(root), 'directory')
 
128
        self.assertEqual(transform.final_file_id(root), self.wt.get_root_id())
129
129
        trans_id = transform.create_path('name', root)
130
130
        self.assertIs(transform.final_file_id(trans_id), None)
131
 
        self.assertIs(None, transform.final_kind(trans_id))
 
131
        self.assertRaises(NoSuchFile, transform.final_kind, trans_id)
132
132
        transform.create_file('contents', trans_id)
133
133
        transform.set_executability(True, trans_id)
134
134
        transform.version_file('my_pretties', trans_id)
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.