Patchwork D10477: testing: add a `write_file` function

login
register
mail settings
Submitter phabricator
Date April 20, 2021, 4:09 a.m.
Message ID <differential-rev-PHID-DREV-luolurwu77vizvkxtrvi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48794/
State Superseded
Headers show

Comments

phabricator - April 20, 2021, 4:09 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  The function is kinda trivial, but having a simple function avoid silly mistake.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10477

AFFECTED FILES
  mercurial/testing/__init__.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/testing/__init__.py b/mercurial/testing/__init__.py
--- a/mercurial/testing/__init__.py
+++ b/mercurial/testing/__init__.py
@@ -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)