-
Notifications
You must be signed in to change notification settings - Fork 91
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
Disk full error not being raised appropriately when file is re-opened #660
Comments
Thanks for the report! This certainly looks like a bug in pyfakefs, seems that these cases are not handled properly. I will have a closer look tonight. |
An even simpler test which I think might be at the heart of the problem:
|
- caused file system file to be wrong for non-empty files - tests: add contextmanager version of assert_raises_os_error - fixes pytest-dev#660
- caused file system file to be wrong for non-empty files - tests: add contextmanager version of assert_raises_os_error - fixes #660
@victorallume - this was a clear bug, probably a leftover from some code change - thanks again for the report. Please check if it works for you in master. If this and the other included bugfix work, I will probably make a bugfix release. |
Thanks; a quick check of the tests and it looks like master works fine. A side note though; the following test works exactly as expected now:
but the test below raises an OSError at runtime on the last line
Both tests are in the test class listed below.
|
Even the following code still fails with an OSError, even though the code in the except clause runs:
|
Yes, the exception is caught for |
The problem is that the |
Thanks; that makes sense (the below code works fine). But why does the first example (
|
You are right, this behaves differently - I missed this. Apparently, the flush position is reset before the exception is raised, so in the case of append the second flush will not try to append anything, which is wrong. I don't think that it will matter much in practice though, as the first |
- do not update flush position before disk size is checked - see pytest-dev#660
- do not update flush position before disk size is checked - see #660
…n before disk size is checked - see #660
Should be corrected now. I verified that the real filesystem is behaving the same way. Edit: that last sentence wasn't actually true, I did a mistake while testing this. It should behave as in the real fs. |
Describe the bug
There seems to be a bug when a file is re-opened for writing, that disk usage is not calculated correctly, and hence does not throw disk full exceptions at the right place. In the code below, in the first test, the assertion fails. The second test works fine. The third function fails the assertion. I discovered this error in code which re-opens files regularly, and uses random-access read/write mode ('r+'), and seeking within files.
How To Reproduce
Your environment
Please run the following and paste the output.
The text was updated successfully, but these errors were encountered: