Explain how to create binary files in the doc of pytest.makefile. (#8255)

This commit is contained in:
Hong Xu
2021-01-21 04:58:52 -08:00
committed by GitHub
parent bda9ce4e0f
commit d4f8e4b40c

View File

@@ -777,7 +777,7 @@ class Pytester:
return ret
def makefile(self, ext: str, *args: str, **kwargs: str) -> Path:
r"""Create new file(s) in the test directory.
r"""Create new text file(s) in the test directory.
:param str ext:
The extension the file(s) should use, including the dot, e.g. `.py`.
@@ -797,6 +797,12 @@ class Pytester:
pytester.makefile(".ini", pytest="[pytest]\naddopts=-rs\n")
To create binary files, use :meth:`pathlib.Path.write_bytes` directly:
.. code-block:: python
filename = pytester.path.joinpath("foo.bin")
filename.write_bytes(b"...")
"""
return self._makefile(ext, args, kwargs)