Skip to content

Commit

Permalink
Do not set size to 0 on setting initial content
Browse files Browse the repository at this point in the history
- caused file system file to be wrong for non-empty files
- tests: add contextmanager version of assert_raises_os_error
- fixes pytest-dev#660
  • Loading branch information
mrbean-bremen committed Jan 28, 2022
1 parent 7ff50a8 commit 02d86bd
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 109 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# pyfakefs Release Notes
The released versions correspond to PyPi releases.

## Unreleased

### Fixes
* correctly handle file system space for files opened in write mode
(see [#660](../../issues/660))

## [Version 4.5.4](https://pypi.python.org/pypi/pyfakefs/4.5.4) (2022-01-12)
Minor bugfix release.

Expand Down
2 changes: 0 additions & 2 deletions pyfakefs/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,6 @@ def set_initial_contents(self, contents: AnyStr) -> bool:
current_size = self.st_size or 0
self.filesystem.change_disk_usage(
st_size - current_size, self.name, self.st_dev)
if self._byte_contents:
self.size = 0
self._byte_contents = byte_contents
self.st_size = st_size
self.epoch += 1
Expand Down
Loading

0 comments on commit 02d86bd

Please sign in to comment.