From 1c0c56dfb99bd404071716612bb0ca5928b02e98 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Fri, 23 Oct 2020 21:01:31 +0300 Subject: pytester: minor doc fixes --- src/_pytest/pytester.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src') 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 -- cgit v1.2.3