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

Simulate buffering=False #549

Closed
couling opened this issue Aug 25, 2020 · 2 comments
Closed

Simulate buffering=False #549

couling opened this issue Aug 25, 2020 · 2 comments

Comments

@couling
Copy link

couling commented Aug 25, 2020

It would be really useful to simulate unbuffered file access to simulate disk limits.

When opened with open(... buffering=False):

  • File system limits should be checked on file.write()
  • As there's no buffer, after an OSError on file.write(), subsiquent operations file.truncate(), file.seek(), file.close() should succeed
  • file.flush() should effectively be a NoOp.

I'm trying to test recovery after a write failure due to disk limits. As I've discovered elsewhere, the only way to properly recover is to use unbuffered access. For this testing it's important that my code recovers differently on different failures to write. At the moment pyfakefs doesn't support simulation of unbuffered access.

@mrbean-bremen
Copy link
Member

I'm thinking about how to test this behavior. Are there any other cases except for failing write, where the buffer size will make a difference you know of?
This will probably take a bit, have to check the correct behavior first. The Python documentation is a bit scarce in that respect.

mrbean-bremen added a commit to mrbean-bremen/pyfakefs that referenced this issue Aug 29, 2020
- support for binary files
- incomplete support for text files (behave like binary files)
- see pytest-dev#549
@mrbean-bremen
Copy link
Member

@couling - I added support for the buffering parameter to master. The support is not complete (text mode line buffering is not implemented), but for binary files this should work. Please check if this works for you.

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

No branches or pull requests

2 participants