Mercurial > hg
changeset 29393:50269a4dce61
atomictempfile: add read to the supported file operations
author | Martijn Pieters <mjpieters@fb.com> |
---|---|
date | Thu, 23 Jun 2016 18:20:58 +0100 |
parents | f21286e48bc6 |
children | 6d96658a22b0 |
files | mercurial/util.py tests/test-atomictempfile.py |
diffstat | 2 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Thu Jun 23 18:18:33 2016 +0100 +++ b/mercurial/util.py Thu Jun 23 18:20:58 2016 +0100 @@ -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
--- a/tests/test-atomictempfile.py Thu Jun 23 18:18:33 2016 +0100 +++ b/tests/test-atomictempfile.py Thu Jun 23 18:20:58 2016 +0100 @@ -89,6 +89,13 @@ # on other faster platforms can detect problems pass + def testread(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__)