[PATCH 3 of 4] atomictempfile: add read to the supported file operations
Martijn Pieters
mj at zopatista.com
Thu Jun 23 12:44:00 EDT 2016
# HG changeset patch
# User Martijn Pieters <mjpieters at fb.com>
# Date 1466700071 -3600
# Thu Jun 23 17:41:11 2016 +0100
# Node ID ce8e19a9c8df0f3992183f4eaf180f993d915149
# Parent 3b77e79175cdbb148ad78fc6beedee4dd16bf4c0
atomictempfile: add read to the supported file operations
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1483,6 +1483,7 @@
self._checkambig = checkambig
# delegated methods
+ self.read = self._fp.read
self.write = self._fp.write
self.seek = self._fp.seek
self.tell = self._fp.tell
diff --git a/tests/test-atomictempfile.py b/tests/test-atomictempfile.py
--- a/tests/test-atomictempfile.py
+++ b/tests/test-atomictempfile.py
@@ -89,6 +89,13 @@
# on other faster platforms can detect problems
pass
+ def test_read(self):
+ with open(self._filename, 'wb') as f:
+ f.write(b'foobar\n')
+ file = atomictempfile(self._filename, mode='rb')
+ self.assertTrue(file.read(), b'foobar\n')
+ file.discard()
+
if __name__ == '__main__':
import silenttestrunner
silenttestrunner.main(__name__)
More information about the Mercurial-devel
mailing list