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

Method maketxtfile

src/_pytest/pytester.py:889–907  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

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.
891
892 Defaults to the test name with a '.txt' extension, e.g test_foobar.txt, overwriting
893 existing files.
894
895 Examples:
896
897 .. code-block:: python
898
899 def test_something(pytester):
900 # Initial file is created test_something.txt.
901 pytester.maketxtfile("foobar")
902 # To create multiple files, pass kwargs accordingly.
903 pytester.maketxtfile(custom="foobar")
904 # At this point, both 'test_something.txt' & 'custom.txt' exist in the test directory.
905
906 """
907 return self._makefile(".txt", args, kwargs)
908
909 def syspathinsert(self, path: str | os.PathLike[str] | None = None) -> None:
910 """Prepend a directory to sys.path, defaults to :attr:`path`.

Calls 1

_makefileMethod · 0.95

Tested by

no test coverage detected