MCPcopy Create free account
hub / github.com/pytest-dev/pytest / makepyfile

Method makepyfile

src/_pytest/pytester.py:852–870  ·  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, **kwargs)

Source from the content-addressed store, hash-verified

850 return self.makefile(".toml", pyproject=source)
851
852 def makepyfile(self, *args, **kwargs) -> Path:
853 r"""Shortcut for .makefile() with a .py extension.
854
855 Defaults to the test name with a '.py' extension, e.g test_foobar.py, overwriting
856 existing files.
857
858 Examples:
859
860 .. code-block:: python
861
862 def test_something(pytester):
863 # Initial file is created test_something.py.
864 pytester.makepyfile("foobar")
865 # To create multiple files, pass kwargs accordingly.
866 pytester.makepyfile(custom="foobar")
867 # At this point, both 'test_something.py' & 'custom.py' exist in the test directory.
868
869 """
870 return self._makefile(".py", args, kwargs)
871
872 def maketxtfile(self, *args, **kwargs) -> Path:
873 r"""Shortcut for .makefile() with a .txt extension.

Calls 1

_makefileMethod · 0.95

Tested by

no test coverage detected