changeset 46985:52cee44aa1a0

testing: add a `write_file` function The function is kinda trivial, but having a simple function avoid silly mistake. Differential Revision: https://phab.mercurial-scm.org/D10477
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 19 Apr 2021 19:10:49 +0200
parents 99c629101b73
children faa43f09ad98
files mercurial/testing/__init__.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/testing/__init__.py	Mon Apr 19 19:10:18 2021 +0200
+++ b/mercurial/testing/__init__.py	Mon Apr 19 19:10:49 2021 +0200
@@ -28,3 +28,8 @@
         if time.time() - start > timeout:
             raise RuntimeError(b"timed out waiting for file: %s" % path)
         time.sleep(0.01)
+
+
+def write_file(path, content=b''):
+    with open(path, 'wb') as f:
+        f.write(content)