You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DOC: Update multiple references to testdir to pytester
In https://docs.pytest.org/en/stable/reference.html#testdir, it is
suggested:
> New code should avoid using testdir in favor of pytester.
Multiple spots in the documents still use testdir and they can be quite
confusing (especially the plugin writing guide).
Copy file name to clipboardExpand all lines: CONTRIBUTING.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -324,20 +324,20 @@ Here is a simple overview, with pytest-specific bits:
324
324
Writing Tests
325
325
~~~~~~~~~~~~~
326
326
327
-
Writing tests for plugins or for pytest itself is often done using the `testdir fixture <https://docs.pytest.org/en/stable/reference.html#testdir>`_, as a "black-box" test.
327
+
Writing tests for plugins or for pytest itself is often done using the `pytester fixture <https://docs.pytest.org/en/stable/reference.html#pytester>`_, as a "black-box" test.
328
328
329
329
For example, to ensure a simple test passes you can write:
330
330
331
331
.. code-block:: python
332
332
333
-
deftest_true_assertion(testdir):
334
-
testdir.makepyfile(
333
+
deftest_true_assertion(pytester):
334
+
pytester.makepyfile(
335
335
"""
336
336
def test_foo():
337
337
assert True
338
338
"""
339
339
)
340
-
result =testdir.runpytest()
340
+
result =pytester.runpytest()
341
341
result.assert_outcomes(failed=0, passed=1)
342
342
343
343
@@ -346,14 +346,14 @@ Alternatively, it is possible to make checks based on the actual output of the t
0 commit comments