Skip to content

Commit

Permalink
Fixed tell position after seek in append mode
Browse files Browse the repository at this point in the history
- fixes #363
  • Loading branch information
mrbean-bremen committed Jun 9, 2018
1 parent d60833e commit 6c2132b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ The release versions are PyPi releases.
* use README.md in pypi ([#358](../../issues/358))

#### Fixes
* `tell` after `seek` gave incorrect result in append mode
([#363](../../issues/363))
* a failing pytest did not display the test function correctly
([#381](../../issues/381))
* flushing file contents after truncate was incorrect under some conditions
([#412](../../issues/412))
* `readline()` did not work correctly in binary mode
([#411](../../issues/411))
* `pathlib.Path.resolve()` behaved incorrectly if the path does not exist
([#401](../../issues/401))
* `closed` attribute was not implemented in fake file ([#380](../../issues/380))
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -4420,7 +4420,7 @@ def tell(self):
self._check_open_file()
if self._flushes_after_tell():
self.flush()
if self._read_seek:
if 0 < self._read_seek < self._flush_pos:
self._read_seek = self._flush_pos
self._read_whence = 0

Expand Down
7 changes: 7 additions & 0 deletions pyfakefs/tests/fake_os_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,13 @@ def test_append_mode_tell_macos(self):
self.check_macos_only()
self.check_append_mode_tell_after_truncate(7)

def test_tell_after_seek_in_append_mode(self):
# Regression test for #363
file_path = self.make_path('foo')
with self.open(file_path, 'a') as f:
f.seek(1)
self.assertEqual(1, f.tell())

def test_dir_with_trailing_sep_is_dir(self):
# regression test for #387
self.assertTrue(self, self.os.path.isdir(self.base_path + self.os.sep))
Expand Down

0 comments on commit 6c2132b

Please sign in to comment.