summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2020-10-23 17:21:22 -0300
committerGitHub <noreply@github.com>2020-10-23 17:21:22 -0300
commitdaa11ab9f130c7557623872bd9a7ca854406f24e (patch)
tree8535d9f25ff520b46c95bc911c7c49009e0486ed /src
parent0b14350f23493cb5001c7579ed49622af3cf5e05 (diff)
parent1c0c56dfb99bd404071716612bb0ca5928b02e98 (diff)
downloadpytest-daa11ab9f130c7557623872bd9a7ca854406f24e.tar.gz
Merge pull request #7930 from bluetech/pytester-doc-fixes
pytester: minor doc fixes
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/pytester.py27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py
index dc234dc63..a1768363b 100644
--- a/src/_pytest/pytester.py
+++ b/src/_pytest/pytester.py
@@ -771,9 +771,9 @@ class Pytester:
.. code-block:: python
- testdir.makefile(".txt", "line1", "line2")
+ pytester.makefile(".txt", "line1", "line2")
- testdir.makefile(".ini", pytest="[pytest]\naddopts=-rs\n")
+ pytester.makefile(".ini", pytest="[pytest]\naddopts=-rs\n")
"""
return self._makefile(ext, args, kwargs)
@@ -808,11 +808,11 @@ class Pytester:
.. code-block:: python
- def test_something(testdir):
+ def test_something(pytester):
# Initial file is created test_something.py.
- testdir.makepyfile("foobar")
+ pytester.makepyfile("foobar")
# To create multiple files, pass kwargs accordingly.
- testdir.makepyfile(custom="foobar")
+ pytester.makepyfile(custom="foobar")
# At this point, both 'test_something.py' & 'custom.py' exist in the test directory.
"""
@@ -828,11 +828,11 @@ class Pytester:
.. code-block:: python
- def test_something(testdir):
+ def test_something(pytester):
# Initial file is created test_something.txt.
- testdir.maketxtfile("foobar")
+ pytester.maketxtfile("foobar")
# To create multiple files, pass kwargs accordingly.
- testdir.maketxtfile(custom="foobar")
+ pytester.maketxtfile(custom="foobar")
# At this point, both 'test_something.txt' & 'custom.txt' exist in the test directory.
"""
@@ -1279,7 +1279,7 @@ class Pytester:
)
kw["env"] = env
- if stdin is Testdir.CLOSE_STDIN:
+ if stdin is self.CLOSE_STDIN:
kw["stdin"] = subprocess.PIPE
elif isinstance(stdin, bytes):
kw["stdin"] = subprocess.PIPE
@@ -1287,7 +1287,7 @@ class Pytester:
kw["stdin"] = stdin
popen = subprocess.Popen(cmdargs, stdout=stdout, stderr=stderr, **kw)
- if stdin is Testdir.CLOSE_STDIN:
+ if stdin is self.CLOSE_STDIN:
assert popen.stdin is not None
popen.stdin.close()
elif isinstance(stdin, bytes):
@@ -1311,7 +1311,7 @@ class Pytester:
being converted to ``str`` automatically.
:param timeout:
The period in seconds after which to timeout and raise
- :py:class:`Testdir.TimeoutExpired`.
+ :py:class:`Pytester.TimeoutExpired`.
:param stdin:
Optional standard input. Bytes are being send, closing
the pipe, otherwise it is passed through to ``popen``.
@@ -1412,7 +1412,7 @@ class Pytester:
The sequence of arguments to pass to the pytest subprocess.
:param timeout:
The period in seconds after which to timeout and raise
- :py:class:`Testdir.TimeoutExpired`.
+ :py:class:`Pytester.TimeoutExpired`.
:rtype: RunResult
"""
@@ -1453,9 +1453,8 @@ class Pytester:
pytest.skip("pexpect.spawn not available")
logfile = self.path.joinpath("spawn.out").open("wb")
- child = pexpect.spawn(cmd, logfile=logfile)
+ child = pexpect.spawn(cmd, logfile=logfile, timeout=expect_timeout)
self._request.addfinalizer(logfile.close)
- child.timeout = expect_timeout
return child