summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHong Xu <hong@topbug.net>2021-01-21 04:58:52 -0800
committerGitHub <noreply@github.com>2021-01-21 09:58:52 -0300
commitd4f8e4b40ce481df0f34b2eac5d61aefae4ed2e1 (patch)
tree76666d9b6b81d20204c9df3d93813324335f6318 /src
parentbda9ce4e0ffcbeb786101f988bbb51e5f832fcb3 (diff)
downloadpytest-d4f8e4b40ce481df0f34b2eac5d61aefae4ed2e1.tar.gz
Explain how to create binary files in the doc of `pytest.makefile`. (#8255)
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/pytester.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py
index 95b22b3b2..8ca21d1c5 100644
--- a/src/_pytest/pytester.py
+++ b/src/_pytest/pytester.py
@@ -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)