diff --git a/fake_filesystem_test.py b/fake_filesystem_test.py index 78fa9ae3..a5844bd8 100755 --- a/fake_filesystem_test.py +++ b/fake_filesystem_test.py @@ -3462,7 +3462,7 @@ def testFileSizeAfterWrite(self): expected_size = original_size + len(added_content) fh = self.open(file_path, 'a') fh.write(added_content) - self.assertEqual(expected_size, fh.Size()) + self.assertEqual(original_size, fh.Size()) fh.close() self.assertEqual(expected_size, self.open(file_path, 'r').Size()) @@ -3473,13 +3473,8 @@ def testLargeFileSizeAfterWrite(self): self.filesystem.CreateFile(file_path, st_size=original_size) added_content = 'foo bar' fh = self.open(file_path, 'a') - # We can't use assertRaises, because the exception is thrown - # in __getattr__, so just saying 'fh.write' causes the exception. - try: - fh.write(added_content) - except fake_filesystem.FakeLargeFileIoException: - return - self.fail('Writing to a large file should not be allowed') + self.assertRaises(fake_filesystem.FakeLargeFileIoException, + lambda: fh.write(added_content)) def testFileSizeUpdatedViaFlush(self): """test that file size gets updated via flush().""" diff --git a/pyfakefs/fake_filesystem.py b/pyfakefs/fake_filesystem.py index f2b3f575..ce3c020b 100644 --- a/pyfakefs/fake_filesystem.py +++ b/pyfakefs/fake_filesystem.py @@ -4255,7 +4255,6 @@ def other_wrapper(*args, **kwargs): if write_seek != self._io.tell(): self._read_seek = self._io.tell() self._read_whence = 0 - self._file_object.st_size += (self._read_seek - write_seek) return ret_value return other_wrapper