Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions for deleting files #27

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 1 comment · Fixed by #114
Closed

Permissions for deleting files #27

GoogleCodeExporter opened this issue Mar 16, 2015 · 1 comment · Fixed by #114
Labels

Comments

@GoogleCodeExporter
Copy link

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

@mrbean-bremen
Copy link
Member

Related Windows specific problem: under Windows, it is not possible to delete an open file. This is also not handled by pyfakefs.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Jun 27, 2016
- raise on file deletion if missing write permission
- raise on deleting an open file under Windows
- make sure check is done recursively if deleting directories
- fixes pytest-dev#27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants