MCPcopy
hub / github.com/pytest-dev/pytest / makefile

Method makefile

src/_pytest/pytester.py:796–826  ·  src/_pytest/pytester.py::Pytester.makefile

r"""Create new text file(s) in the test directory. :param ext: The extension the file(s) should use, including the dot, e.g. `.py`. :param args: All args are treated as strings and joined using newlines. The result is written as contents to the fi

(self, ext: str, *args: str, **kwargs: str)

Source from the content-addressed store, hash-verified

794 return ret
795
796 def makefile(self, ext: str, *args: str, **kwargs: str) -> Path:
797 rclass="st">"""Create new text file(s) in the test directory.
798
799 :param ext:
800 The extension the file(s) should use, including the dot, e.g. `.py`.
801 :param args:
802 All args are treated as strings and joined using newlines.
803 The result is written as contents to the file. The name of the
804 file is based on the test function requesting this fixture.
805 :param kwargs:
806 Each keyword is the name of a file, while the value of it will
807 be written as contents of the file.
808 :returns:
809 The first created file.
810
811 Examples:
812
813 .. code-block:: python
814
815 pytester.makefile(class="st">".txt", class="st">"line1", class="st">"line2")
816
817 pytester.makefile(class="st">".ini", pytest=class="st">"[pytest]\naddopts=-rs\n")
818
819 To create binary files, use :meth:`pathlib.Path.write_bytes` directly:
820
821 .. code-block:: python
822
823 filename = pytester.path.joinpath(class="st">"foo.bin")
824 filename.write_bytes(bclass="st">"...")
825 class="st">"""
826 return self._makefile(ext, args, kwargs)
827
828 def makeconftest(self, source: str) -> Path:
829 class="st">"""Write a conftest.py file.

Calls 1

_makefileMethod · 0.95

Tested by

no test coverage detected