Skip to content

Preserve file permissions in fakefs after add_real_file #1138

Answered by mrbean-bremen
daviewales asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I completly forgot that this is expected behavior. By default, files from the real filesystem are mapped as read-only. From the documentation:

The access to the files is by default read-only, but even if you add them using read_only=False, the files are written only in the fake system (e.g. in memory).

Replacing fs.add_real_file(file) with fs.add_real_file(file, read_only=False) should give you the wanted behavior.
Please check if this is sufficient for you.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by daviewales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1119 on March 10, 2025 06:24.