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
--- 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)