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

Method makepyfile

src/_pytest/pytester.py:869–887  ·  src/_pytest/pytester.py::Pytester.makepyfile

r"""Shortcut for .makefile() with a .py extension. Defaults to the test name with a '.py' extension, e.g test_foobar.py, overwriting existing files. Examples: .. code-block:: python def test_something(pytester): # Initial file is create

(self, *args: _FileContent, **kwargs: _FileContent)

Source from the content-addressed store, hash-verified

867 return self.makefile(class="st">".toml", pyproject=source)
868
869 def makepyfile(self, *args: _FileContent, **kwargs: _FileContent) -> Path:
870 rclass="st">"""Shortcut for .makefile() with a .py extension.
871
872 Defaults to the test name with a &class="cm">#x27;.py' extension, e.g test_foobar.py, overwriting
873 existing files.
874
875 Examples:
876
877 .. code-block:: python
878
879 def test_something(pytester):
880 class="cm"># Initial file is created test_something.py.
881 pytester.makepyfile(class="st">"foobar")
882 class="cm"># To create multiple files, pass kwargs accordingly.
883 pytester.makepyfile(custom=class="st">"foobar")
884 class="cm"># At this point, both class="st">'test_something.py' & class="st">'custom.py' exist in the test directory.
885
886 class="st">"""
887 return self._makefile(class="st">".py", args, kwargs)
888
889 def maketxtfile(self, *args: _FileContent, **kwargs: _FileContent) -> Path:
890 rclass="st">"""Shortcut for .makefile() with a .txt extension.

Calls 1

_makefileMethod · 0.95

Tested by

no test coverage detected