Skip to content

Permissions for deleting files #27

Description

@GoogleCodeExporter
pyfakefs doesn't seem to honor permissions when deleting files. I marked a 
directory and the files contained within as read-only using the fake_os 
module's chmod function, but os.remove and shutil.rmtree were able to remove 
the files without issue.

What steps will reproduce the problem?
# Create filesystem with '/dir1/file1'

path = os.path.join('dir1', 'file1')
mode = self.fake_os.stat(path)[stat.ST_MODE]
self.fake_os.chmod('dir1', 0444)
self.fake_os.chmod(path, 0444)
self.fake_os.remove(path)

What is the expected output? What do you see instead?
I would expect an "OSError: [Errno 13] Permission denied" or equivalent, 
instead the file is removed.

What version of the product are you using? On what operating system?
pyfakefs 2.4, tested on Windows 7 and Red Hat 6

Please provide any additional information below.
It would be really helpful to acknowledge permissions, since many tests I write 
are around "how does my program behave if it doesn't have access to the 
necessary files?"

Original issue reported on code.google.com by londinop on 28 Feb 2014 at 5:02

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions