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

Method makepyfile

src/_pytest/pytester.py:869–887  ·  view source on GitHub ↗

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(".toml", pyproject=source)
868
869 def makepyfile(self, *args: _FileContent, **kwargs: _FileContent) -> Path:
870 r"""Shortcut for .makefile() with a .py extension.
871
872 Defaults to the test name with a '.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 # Initial file is created test_something.py.
881 pytester.makepyfile("foobar")
882 # To create multiple files, pass kwargs accordingly.
883 pytester.makepyfile(custom="foobar")
884 # At this point, both 'test_something.py' & 'custom.py' exist in the test directory.
885
886 """
887 return self._makefile(".py", args, kwargs)
888
889 def maketxtfile(self, *args: _FileContent, **kwargs: _FileContent) -> Path:
890 r"""Shortcut for .makefile() with a .txt extension.

Calls 1

_makefileMethod · 0.95

Tested by

no test coverage detected