testing: add a `write_file` function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 19 Apr 2021 19:10:49 +0200
changeset 46985 52cee44aa1a0
parent 46984 99c629101b73
child 46986 faa43f09ad98
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
mercurial/testing/__init__.py
--- 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)