(name, contents, binary=False, absolute=False)
| 208 | |
| 209 | |
| 210 | def create_file(name, contents, binary=False, absolute=False): |
| 211 | name = Path(name) |
| 212 | assert absolute or not name.is_absolute(), name |
| 213 | if binary: |
| 214 | name.write_bytes(contents) |
| 215 | else: |
| 216 | # Dedent the contents of text files so that the files on disc all |
| 217 | # start in column 1, even if they are indented when embedded in the |
| 218 | # python test code. |
| 219 | contents = textwrap.dedent(contents) |
| 220 | name.write_text(contents, encoding='utf-8') |
| 221 | |
| 222 | |
| 223 | @contextlib.contextmanager |
no outgoing calls