# HG changeset patch # User Pierre-Yves David # Date 1618852249 -7200 # Node ID 52cee44aa1a073fa34b79c7b03eea53e2a803169 # Parent 99c629101b738ae88dc5c7ac1b74c60dd75d9efd 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 diff -r 99c629101b73 -r 52cee44aa1a0 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)