Skip to content

Commit

Permalink
more autodocs for pytester
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Aug 20, 2018
1 parent 28aff05 commit e620798
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions changelog/3833.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added missing docs for ``pytester.Testdir``
2 changes: 1 addition & 1 deletion doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ To use it, include in your top-most ``conftest.py`` file::


.. autoclass:: Testdir()
:members: runpytest,runpytest_subprocess,runpytest_inprocess,makeconftest,makepyfile
:members:

.. autoclass:: RunResult()
:members:
Expand Down
20 changes: 12 additions & 8 deletions src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,18 +550,22 @@ def to_text(s):
return ret

def makefile(self, ext, *args, **kwargs):
"""Create a new file in the testdir.
r"""Create new file(s) in the testdir.
ext: The extension the file should use, including the dot, e.g. `.py`.
args: All args will be treated as strings and joined using newlines.
:param str ext: The extension the file(s) should use, including the dot, e.g. `.py`.
:param list[str] args: All args will be treated as strings and joined using newlines.
The result will be written as contents to the file. The name of the
file will be based on the test function requesting this fixture.
E.g. "testdir.makefile('.txt', 'line1', 'line2')"
kwargs: Each keyword is the name of a file, while the value of it will
:param kwargs: Each keyword is the name of a file, while the value of it will
be written as contents of the file.
E.g. "testdir.makefile('.ini', pytest='[pytest]\naddopts=-rs\n')"
Examples:
.. code-block:: python
testdir.makefile(".txt", "line1", "line2")
testdir.makefile(".ini", pytest="[pytest]\naddopts=-rs\n")
"""
return self._makefile(ext, args, kwargs)
Expand Down

0 comments on commit e620798

Please sign in to comment.