Imported Upstream version 7.4.3 upstream upstream/7.4.3
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 29 Dec 2023 04:16:44 +0000 (13:16 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 29 Dec 2023 04:16:44 +0000 (13:16 +0900)
332 files changed:
.coveragerc
.github/PULL_REQUEST_TEMPLATE.md
.github/dependabot.yml
.github/workflows/backport.yml [new file with mode: 0644]
.github/workflows/deploy.yml [new file with mode: 0644]
.github/workflows/main.yml [deleted file]
.github/workflows/prepare-release-pr.yml [new file with mode: 0644]
.github/workflows/release-on-comment.yml [deleted file]
.github/workflows/stale.yml [new file with mode: 0644]
.github/workflows/test.yml [new file with mode: 0644]
.github/workflows/update-plugin-list.yml [new file with mode: 0644]
.gitignore
.pre-commit-config.yaml
.readthedocs.yml
AUTHORS
CHANGELOG.rst
CONTRIBUTING.rst
LICENSE
PKG-INFO [new file with mode: 0644]
README.rst
RELEASING.rst
TIDELIFT.rst
doc/en/Makefile
doc/en/_templates/globaltoc.html
doc/en/_templates/links.html
doc/en/adopt.rst
doc/en/announce/index.rst
doc/en/announce/release-2.0.0.rst
doc/en/announce/release-2.0.1.rst
doc/en/announce/release-2.1.0.rst
doc/en/announce/release-2.1.1.rst
doc/en/announce/release-2.1.2.rst
doc/en/announce/release-2.2.0.rst
doc/en/announce/release-2.3.0.rst
doc/en/announce/release-2.3.4.rst
doc/en/announce/release-2.4.0.rst
doc/en/announce/release-2.5.0.rst
doc/en/announce/release-2.9.0.rst
doc/en/announce/release-2.9.1.rst
doc/en/announce/release-2.9.2.rst
doc/en/announce/release-6.2.3.rst [new file with mode: 0644]
doc/en/announce/release-6.2.4.rst [new file with mode: 0644]
doc/en/announce/release-6.2.5.rst [new file with mode: 0644]
doc/en/announce/release-7.0.0.rst [new file with mode: 0644]
doc/en/announce/release-7.0.0rc1.rst [new file with mode: 0644]
doc/en/announce/release-7.0.1.rst [new file with mode: 0644]
doc/en/announce/release-7.1.0.rst [new file with mode: 0644]
doc/en/announce/release-7.1.1.rst [new file with mode: 0644]
doc/en/announce/release-7.1.2.rst [new file with mode: 0644]
doc/en/announce/release-7.1.3.rst [new file with mode: 0644]
doc/en/announce/release-7.2.0.rst [new file with mode: 0644]
doc/en/announce/release-7.2.1.rst [new file with mode: 0644]
doc/en/announce/release-7.2.2.rst [new file with mode: 0644]
doc/en/announce/release-7.3.0.rst [new file with mode: 0644]
doc/en/announce/release-7.3.1.rst [new file with mode: 0644]
doc/en/announce/release-7.3.2.rst [new file with mode: 0644]
doc/en/announce/release-7.4.0.rst [new file with mode: 0644]
doc/en/announce/release-7.4.1.rst [new file with mode: 0644]
doc/en/announce/release-7.4.2.rst [new file with mode: 0644]
doc/en/announce/release-7.4.3.rst [new file with mode: 0644]
doc/en/assert.rst [deleted file]
doc/en/backwards-compatibility.rst
doc/en/bash-completion.rst [deleted file]
doc/en/builtin.rst
doc/en/cache.rst [deleted file]
doc/en/capture.rst [deleted file]
doc/en/changelog.rst
doc/en/conf.py
doc/en/contact.rst
doc/en/contents.rst
doc/en/customize.rst [deleted file]
doc/en/deprecations.rst
doc/en/development_guide.rst
doc/en/doctest.rst [deleted file]
doc/en/example/assertion/test_failures.py
doc/en/example/attic.rst
doc/en/example/fixtures/fixture_availability.svg
doc/en/example/fixtures/fixture_availability_plugins.svg
doc/en/example/fixtures/test_fixtures_order_autouse_flat.svg [new file with mode: 0644]
doc/en/example/fixtures/test_fixtures_order_autouse_multiple_scopes.svg
doc/en/example/fixtures/test_fixtures_order_autouse_temp_effects.svg
doc/en/example/fixtures/test_fixtures_order_dependencies.py
doc/en/example/fixtures/test_fixtures_order_scope.svg
doc/en/example/fixtures/test_fixtures_request_different_scope.svg
doc/en/example/index.rst
doc/en/example/markers.rst
doc/en/example/multipython.py
doc/en/example/nonpython.rst
doc/en/example/nonpython/conftest.py
doc/en/example/parametrize.rst
doc/en/example/pythoncollection.rst
doc/en/example/reportingdemo.rst
doc/en/example/simple.rst
doc/en/example/special.rst
doc/en/existingtestsuite.rst [deleted file]
doc/en/explanation/anatomy.rst [new file with mode: 0644]
doc/en/explanation/fixtures.rst [new file with mode: 0644]
doc/en/explanation/flaky.rst [new file with mode: 0644]
doc/en/explanation/goodpractices.rst [new file with mode: 0644]
doc/en/explanation/index.rst [new file with mode: 0644]
doc/en/explanation/pythonpath.rst [new file with mode: 0644]
doc/en/fixture.rst [deleted file]
doc/en/flaky.rst [deleted file]
doc/en/funcarg_compare.rst
doc/en/getting-started.rst
doc/en/goodpractices.rst [deleted file]
doc/en/historical-notes.rst
doc/en/history.rst [new file with mode: 0644]
doc/en/how-to/assert.rst [new file with mode: 0644]
doc/en/how-to/bash-completion.rst [new file with mode: 0644]
doc/en/how-to/cache.rst [new file with mode: 0644]
doc/en/how-to/capture-stdout-stderr.rst [new file with mode: 0644]
doc/en/how-to/capture-warnings.rst [new file with mode: 0644]
doc/en/how-to/doctest.rst [new file with mode: 0644]
doc/en/how-to/existingtestsuite.rst [new file with mode: 0644]
doc/en/how-to/failures.rst [new file with mode: 0644]
doc/en/how-to/fixtures.rst [new file with mode: 0644]
doc/en/how-to/index.rst [new file with mode: 0644]
doc/en/how-to/logging.rst [new file with mode: 0644]
doc/en/how-to/mark.rst [new file with mode: 0644]
doc/en/how-to/monkeypatch.rst [new file with mode: 0644]
doc/en/how-to/nose.rst [new file with mode: 0644]
doc/en/how-to/output.rst [new file with mode: 0644]
doc/en/how-to/parametrize.rst [new file with mode: 0644]
doc/en/how-to/plugins.rst [new file with mode: 0644]
doc/en/how-to/skipping.rst [new file with mode: 0644]
doc/en/how-to/tmp_path.rst [new file with mode: 0644]
doc/en/how-to/unittest.rst [new file with mode: 0644]
doc/en/how-to/usage.rst [new file with mode: 0644]
doc/en/how-to/writing_hook_functions.rst [new file with mode: 0644]
doc/en/how-to/writing_plugins.rst [new file with mode: 0644]
doc/en/how-to/xunit_setup.rst [new file with mode: 0644]
doc/en/img/pytest1.png
doc/en/img/pytest_logo_curves.svg [new file with mode: 0644]
doc/en/index.rst
doc/en/license.rst
doc/en/logging.rst [deleted file]
doc/en/mark.rst [deleted file]
doc/en/monkeypatch.rst [deleted file]
doc/en/nose.rst [deleted file]
doc/en/parametrize.rst [deleted file]
doc/en/plugins.rst [deleted file]
doc/en/projects.rst [deleted file]
doc/en/proposals/parametrize_with_fixtures.rst
doc/en/py27-py34-deprecation.rst [deleted file]
doc/en/pythonpath.rst [deleted file]
doc/en/reference.rst [deleted file]
doc/en/reference/customize.rst [new file with mode: 0644]
doc/en/reference/exit-codes.rst [new file with mode: 0644]
doc/en/reference/fixtures.rst [new file with mode: 0644]
doc/en/reference/index.rst [new file with mode: 0644]
doc/en/reference/plugin_list.rst [new file with mode: 0644]
doc/en/reference/reference.rst [new file with mode: 0644]
doc/en/requirements.txt
doc/en/skipping.rst [deleted file]
doc/en/talks.rst
doc/en/tmpdir.rst [deleted file]
doc/en/unittest.rst [deleted file]
doc/en/usage.rst [deleted file]
doc/en/warnings.rst [deleted file]
doc/en/writing_plugins.rst [deleted file]
doc/en/xunit_setup.rst [deleted file]
extra/setup-py.test/setup.py [deleted file]
pyproject.toml
scripts/append_codecov_token.py [deleted file]
scripts/prepare-release-pr.py [new file with mode: 0644]
scripts/publish-gh-release-notes.py
scripts/release-on-comment.py [deleted file]
scripts/release.major.rst [new file with mode: 0644]
scripts/release.minor.rst
scripts/release.pre.rst [new file with mode: 0644]
scripts/release.py
scripts/report-coverage.sh [deleted file]
scripts/towncrier-draft-to-file.py
scripts/update-plugin-list.py [new file with mode: 0644]
setup.cfg
src/_pytest/__init__.py
src/_pytest/_argcomplete.py
src/_pytest/_code/code.py
src/_pytest/_code/source.py
src/_pytest/_io/saferepr.py
src/_pytest/_io/terminalwriter.py
src/_pytest/_py/__init__.py [new file with mode: 0644]
src/_pytest/_py/error.py [new file with mode: 0644]
src/_pytest/_py/path.py [new file with mode: 0644]
src/_pytest/_version.py [new file with mode: 0644]
src/_pytest/assertion/__init__.py
src/_pytest/assertion/rewrite.py
src/_pytest/assertion/truncate.py
src/_pytest/assertion/util.py
src/_pytest/cacheprovider.py
src/_pytest/capture.py
src/_pytest/compat.py
src/_pytest/config/__init__.py
src/_pytest/config/argparsing.py
src/_pytest/config/compat.py [new file with mode: 0644]
src/_pytest/config/findpaths.py
src/_pytest/debugging.py
src/_pytest/deprecated.py
src/_pytest/doctest.py
src/_pytest/faulthandler.py
src/_pytest/fixtures.py
src/_pytest/freeze_support.py
src/_pytest/helpconfig.py
src/_pytest/hookspec.py
src/_pytest/junitxml.py
src/_pytest/legacypath.py [new file with mode: 0644]
src/_pytest/logging.py
src/_pytest/main.py
src/_pytest/mark/__init__.py
src/_pytest/mark/expression.py
src/_pytest/mark/structures.py
src/_pytest/monkeypatch.py
src/_pytest/nodes.py
src/_pytest/nose.py
src/_pytest/outcomes.py
src/_pytest/pastebin.py
src/_pytest/pathlib.py
src/_pytest/pytester.py
src/_pytest/pytester_assertions.py
src/_pytest/python.py
src/_pytest/python_api.py
src/_pytest/python_path.py [new file with mode: 0644]
src/_pytest/recwarn.py
src/_pytest/reports.py
src/_pytest/runner.py
src/_pytest/scope.py [new file with mode: 0644]
src/_pytest/setuponly.py
src/_pytest/setupplan.py
src/_pytest/skipping.py
src/_pytest/stash.py [new file with mode: 0644]
src/_pytest/stepwise.py
src/_pytest/store.py [deleted file]
src/_pytest/terminal.py
src/_pytest/threadexception.py
src/_pytest/tmpdir.py
src/_pytest/unittest.py
src/_pytest/warning_types.py
src/_pytest/warnings.py
src/py.py [new file with mode: 0644]
src/pytest.egg-info/PKG-INFO [new file with mode: 0644]
src/pytest.egg-info/SOURCES.txt [new file with mode: 0644]
src/pytest.egg-info/dependency_links.txt [new file with mode: 0644]
src/pytest.egg-info/entry_points.txt [new file with mode: 0644]
src/pytest.egg-info/not-zip-safe [new file with mode: 0644]
src/pytest.egg-info/requires.txt [new file with mode: 0644]
src/pytest.egg-info/top_level.txt [new file with mode: 0644]
src/pytest/__init__.py
src/pytest/collect.py [deleted file]
testing/_py/test_local.py [new file with mode: 0644]
testing/acceptance_test.py
testing/code/test_excinfo.py
testing/code/test_source.py
testing/conftest.py
testing/deprecated_test.py
testing/example_scripts/__init__.py [new file with mode: 0644]
testing/example_scripts/collect/package_infinite_recursion/conftest.py
testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py [new file with mode: 0644]
testing/example_scripts/dataclasses/test_compare_initvar.py [new file with mode: 0644]
testing/example_scripts/dataclasses/test_compare_recursive_dataclasses.py
testing/example_scripts/doctest/main_py/__main__.py [new file with mode: 0644]
testing/example_scripts/doctest/main_py/test_normal_module.py [new file with mode: 0644]
testing/example_scripts/fixtures/custom_item/conftest.py
testing/example_scripts/issue88_initial_file_multinodes/conftest.py
testing/example_scripts/issue_519.py
testing/example_scripts/tmpdir/tmp_path_fixture.py [new file with mode: 0644]
testing/example_scripts/tmpdir/tmpdir_fixture.py [deleted file]
testing/example_scripts/unittest/test_unittest_asyncio.py
testing/examples/test_issue519.py
testing/io/test_saferepr.py
testing/io/test_terminalwriter.py
testing/logging/test_fixture.py
testing/logging/test_formatter.py
testing/logging/test_reporting.py
testing/plugins_integration/pytest.ini
testing/plugins_integration/requirements.txt
testing/python/approx.py
testing/python/collect.py
testing/python/fixtures.py
testing/python/integration.py
testing/python/metafunc.py
testing/python/raises.py
testing/python/show_fixtures_per_test.py
testing/test_argcomplete.py
testing/test_assertion.py
testing/test_assertrewrite.py
testing/test_cacheprovider.py
testing/test_capture.py
testing/test_collection.py
testing/test_compat.py
testing/test_config.py
testing/test_conftest.py
testing/test_debugging.py
testing/test_doctest.py
testing/test_error_diffs.py
testing/test_faulthandler.py
testing/test_findpaths.py
testing/test_helpconfig.py
testing/test_junitxml.py
testing/test_legacypath.py [new file with mode: 0644]
testing/test_link_resolve.py
testing/test_main.py
testing/test_mark.py
testing/test_mark_expression.py
testing/test_monkeypatch.py
testing/test_nodes.py
testing/test_nose.py
testing/test_parseopt.py
testing/test_pastebin.py
testing/test_pathlib.py
testing/test_pluginmanager.py
testing/test_pytester.py
testing/test_python_path.py [new file with mode: 0644]
testing/test_recwarn.py
testing/test_reports.py
testing/test_runner.py
testing/test_runner_xunit.py
testing/test_scope.py [new file with mode: 0644]
testing/test_session.py
testing/test_skipping.py
testing/test_stash.py [new file with mode: 0644]
testing/test_stepwise.py
testing/test_store.py [deleted file]
testing/test_terminal.py
testing/test_threadexception.py
testing/test_tmpdir.py
testing/test_unittest.py
testing/test_unraisableexception.py
testing/test_warning_types.py
testing/test_warnings.py
testing/typing_checks.py
tox.ini

index 09ab37643377185e9e6ecd1b080ddd2bfc0c26ee..a335557d4f146f002a998e9fb17cf80288c72aa3 100644 (file)
@@ -25,6 +25,7 @@ exclude_lines =
     ^\s*raise NotImplementedError\b
     ^\s*return NotImplemented\b
     ^\s*assert False(,|$)
+    ^\s*assert_never\(
 
     ^\s*if TYPE_CHECKING:
     ^\s*@overload( |$)
index 9408fceafe36b55a728db461aa4919fa37012487..5e7282bfd77aa4214f70062e3fa8850bcd8396d5 100644 (file)
@@ -13,7 +13,7 @@ If this change fixes an issue, please:
 
 Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
 
-- [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details.
+- [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/main/changelog/README.rst) for details.
 
   Write sentences in the **past or present tense**, examples:
 
index 507789bf5a4cd5902358cfb5b4870f7c68382f76..294b13743e2d4eb3cf3596485a1801336cb0e192 100644 (file)
@@ -9,3 +9,9 @@ updates:
   allow:
   - dependency-type: direct
   - dependency-type: indirect
+- package-ecosystem: github-actions
+  directory: /
+  schedule:
+    interval: weekly
+    time: "03:00"
+  open-pull-requests-limit: 10
diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml
new file mode 100644 (file)
index 0000000..aa90b51
--- /dev/null
@@ -0,0 +1,51 @@
+name: backport
+
+on:
+  # Note that `pull_request_target` has security implications:
+  # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
+  # In particular:
+  # - Only allow triggers that can be used only be trusted users
+  # - Don't execute any code from the target branch
+  # - Don't use cache
+  pull_request_target:
+    types: [labeled]
+
+# Set permissions at the job level.
+permissions: {}
+
+jobs:
+  backport:
+    if: startsWith(github.event.label.name, 'backport ') && github.event.pull_request.merged
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pull-requests: write
+
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+        persist-credentials: true
+
+    - name: Create backport PR
+      run: |
+        set -eux
+
+        git config --global user.name "pytest bot"
+        git config --global user.email "pytestbot@gmail.com"
+
+        label='${{ github.event.label.name }}'
+        target_branch="${label#backport }"
+        backport_branch=backport-${{ github.event.number }}-to-"${target_branch}"
+        subject="[$target_branch] $(gh pr view --json title -q .title ${{ github.event.number }})"
+
+        git checkout origin/"${target_branch}" -b "${backport_branch}"
+        git cherry-pick -x --mainline 1 ${{ github.event.pull_request.merge_commit_sha }}
+        git commit --amend --message "$subject"
+        git push --set-upstream origin --force-with-lease "${backport_branch}"
+        gh pr create \
+          --base "${target_branch}" \
+          --title "${subject}" \
+          --body "Backport of PR #${{ github.event.number }} to $target_branch branch. PR created by backport workflow."
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644 (file)
index 0000000..7340e13
--- /dev/null
@@ -0,0 +1,90 @@
+name: deploy
+
+on:
+  workflow_dispatch:
+    inputs:
+      version:
+        description: 'Release version'
+        required: true
+        default: '1.2.3'
+
+
+# Set permissions at the job level.
+permissions: {}
+
+jobs:
+  package:
+    runs-on: ubuntu-latest
+    env:
+      SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
+    timeout-minutes: 10
+
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+        persist-credentials: false
+
+    - name: Build and Check Package
+      uses: hynek/build-and-inspect-python-package@v1.5
+
+  deploy:
+    if: github.repository == 'pytest-dev/pytest'
+    needs: [package]
+    runs-on: ubuntu-latest
+    environment: deploy
+    timeout-minutes: 30
+    permissions:
+      id-token: write
+      contents: write
+    steps:
+    - uses: actions/checkout@v3
+
+    - name: Download Package
+      uses: actions/download-artifact@v3
+      with:
+        name: Packages
+        path: dist
+
+    - name: Publish package to PyPI
+      uses: pypa/gh-action-pypi-publish@v1.8.5
+
+    - name: Push tag
+      run: |
+        git config user.name "pytest bot"
+        git config user.email "pytestbot@gmail.com"
+        git tag --annotate --message=v${{ github.event.inputs.version }} v${{ github.event.inputs.version }} ${{ github.sha }}
+        git push origin v${{ github.event.inputs.version }}
+
+  release-notes:
+
+    # todo: generate the content in the build  job
+    #       the goal being of using a github action script to push the release data
+    #       after success instead of creating a complete python/tox env
+    needs: [deploy]
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+    permissions:
+      contents: write
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+        persist-credentials: false
+
+    - name: Set up Python
+      uses: actions/setup-python@v4
+      with:
+        python-version: "3.10"
+
+    - name: Install tox
+      run: |
+        python -m pip install --upgrade pip
+        pip install --upgrade tox
+
+    - name: Publish GitHub release notes
+      env:
+        GH_RELEASE_NOTES_TOKEN: ${{ github.token }}
+      run: |
+        sudo apt-get install pandoc
+        tox -e publish-gh-release-notes
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
deleted file mode 100644 (file)
index 2b77927..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-name: main
-
-on:
-  push:
-    branches:
-      - master
-      - "[0-9]+.[0-9]+.x"
-    tags:
-      - "[0-9]+.[0-9]+.[0-9]+"
-      - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
-
-  pull_request:
-    branches:
-      - master
-      - "[0-9]+.[0-9]+.x"
-
-jobs:
-  build:
-    runs-on: ${{ matrix.os }}
-    timeout-minutes: 30
-
-    strategy:
-      fail-fast: false
-      matrix:
-        name: [
-          "windows-py36",
-          "windows-py37",
-          "windows-py37-pluggy",
-          "windows-py38",
-
-          "ubuntu-py36",
-          "ubuntu-py37",
-          "ubuntu-py37-pluggy",
-          "ubuntu-py37-freeze",
-          "ubuntu-py38",
-          "ubuntu-py39",
-          "ubuntu-pypy3",
-
-          "macos-py37",
-          "macos-py38",
-
-          "docs",
-          "doctesting",
-          "plugins",
-        ]
-
-        include:
-          - name: "windows-py36"
-            python: "3.6"
-            os: windows-latest
-            tox_env: "py36-xdist"
-          - name: "windows-py37"
-            python: "3.7"
-            os: windows-latest
-            tox_env: "py37-numpy"
-          - name: "windows-py37-pluggy"
-            python: "3.7"
-            os: windows-latest
-            tox_env: "py37-pluggymaster-xdist"
-          - name: "windows-py38"
-            python: "3.8"
-            os: windows-latest
-            tox_env: "py38-unittestextras"
-            use_coverage: true
-
-          - name: "ubuntu-py36"
-            python: "3.6"
-            os: ubuntu-latest
-            tox_env: "py36-xdist"
-          - name: "ubuntu-py37"
-            python: "3.7"
-            os: ubuntu-latest
-            tox_env: "py37-lsof-numpy-pexpect"
-            use_coverage: true
-          - name: "ubuntu-py37-pluggy"
-            python: "3.7"
-            os: ubuntu-latest
-            tox_env: "py37-pluggymaster-xdist"
-          - name: "ubuntu-py37-freeze"
-            python: "3.7"
-            os: ubuntu-latest
-            tox_env: "py37-freeze"
-          - name: "ubuntu-py38"
-            python: "3.8"
-            os: ubuntu-latest
-            tox_env: "py38-xdist"
-          - name: "ubuntu-py39"
-            python: "3.9"
-            os: ubuntu-latest
-            tox_env: "py39-xdist"
-          - name: "ubuntu-pypy3"
-            python: "pypy3"
-            os: ubuntu-latest
-            tox_env: "pypy3-xdist"
-
-          - name: "macos-py37"
-            python: "3.7"
-            os: macos-latest
-            tox_env: "py37-xdist"
-          - name: "macos-py38"
-            python: "3.8"
-            os: macos-latest
-            tox_env: "py38-xdist"
-            use_coverage: true
-
-          - name: "plugins"
-            python: "3.7"
-            os: ubuntu-latest
-            tox_env: "plugins"
-
-          - name: "docs"
-            python: "3.7"
-            os: ubuntu-latest
-            tox_env: "docs"
-          - name: "doctesting"
-            python: "3.7"
-            os: ubuntu-latest
-            tox_env: "doctesting"
-            use_coverage: true
-
-    steps:
-    - uses: actions/checkout@v2
-      with:
-        fetch-depth: 0
-    - name: Set up Python ${{ matrix.python }}
-      uses: actions/setup-python@v2
-      with:
-        python-version: ${{ matrix.python }}
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install tox coverage
-
-    - name: Test without coverage
-      if: "! matrix.use_coverage"
-      run: "tox -e ${{ matrix.tox_env }}"
-
-    - name: Test with coverage
-      if: "matrix.use_coverage"
-      env:
-        _PYTEST_TOX_COVERAGE_RUN: "coverage run -m"
-        COVERAGE_PROCESS_START: ".coveragerc"
-        _PYTEST_TOX_EXTRA_DEP: "coverage-enable-subprocess"
-      run: "tox -e ${{ matrix.tox_env }}"
-
-    - name: Prepare coverage token
-      if: (matrix.use_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' ))
-      run: |
-        python scripts/append_codecov_token.py
-
-    - name: Report coverage
-      if: (matrix.use_coverage)
-      env:
-        CODECOV_NAME: ${{ matrix.name }}
-      run: bash scripts/report-coverage.sh -F GHA,${{ runner.os }}
-
-  linting:
-    runs-on: ubuntu-latest
-    steps:
-    - uses: actions/checkout@v2
-    - uses: actions/setup-python@v2
-    - name: set PY
-      run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
-    - uses: actions/cache@v2
-      with:
-        path: ~/.cache/pre-commit
-        key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install tox
-    - run: tox -e linting
-
-  deploy:
-    if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest'
-
-    runs-on: ubuntu-latest
-    timeout-minutes: 30
-
-    needs: [build]
-
-    steps:
-    - uses: actions/checkout@v2
-      with:
-        fetch-depth: 0
-    - name: Set up Python
-      uses: actions/setup-python@v2
-      with:
-        python-version: "3.7"
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install --upgrade wheel setuptools tox
-    - name: Build package
-      run: |
-        python setup.py sdist bdist_wheel
-    - name: Publish package to PyPI
-      uses: pypa/gh-action-pypi-publish@master
-      with:
-        user: __token__
-        password: ${{ secrets.pypi_token }}
-    - name: Publish GitHub release notes
-      env:
-        GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }}
-      run: |
-        sudo apt-get install pandoc
-        tox -e publish-gh-release-notes
diff --git a/.github/workflows/prepare-release-pr.yml b/.github/workflows/prepare-release-pr.yml
new file mode 100644 (file)
index 0000000..76bf14d
--- /dev/null
@@ -0,0 +1,52 @@
+name: prepare release pr
+
+on:
+  workflow_dispatch:
+    inputs:
+      branch:
+        description: 'Branch to base the release from'
+        required: true
+        default: ''
+      major:
+        description: 'Major release? (yes/no)'
+        required: true
+        default: 'no'
+      prerelease:
+        description: 'Prerelease (ex: rc1). Leave empty if not a pre-release.'
+        required: false
+        default: ''
+
+# Set permissions at the job level.
+permissions: {}
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pull-requests: write
+
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+
+    - name: Set up Python
+      uses: actions/setup-python@v4
+      with:
+        python-version: "3.8"
+
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install --upgrade setuptools tox
+
+    - name: Prepare release PR (minor/patch release)
+      if: github.event.inputs.major == 'no'
+      run: |
+        tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --prerelease='${{ github.event.inputs.prerelease }}'
+
+    - name: Prepare release PR (major release)
+      if: github.event.inputs.major == 'yes'
+      run: |
+        tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --major --prerelease='${{ github.event.inputs.prerelease }}'
diff --git a/.github/workflows/release-on-comment.yml b/.github/workflows/release-on-comment.yml
deleted file mode 100644 (file)
index 94863d8..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-# part of our release process, see `release-on-comment.py`
-name: release on comment
-
-on:
-  issues:
-    types: [opened, edited]
-  issue_comment:
-    types: [created, edited]
-
-jobs:
-  build:
-    runs-on: ubuntu-latest
-
-    if: (github.event.comment && startsWith(github.event.comment.body, '@pytestbot please')) || (github.event.issue && !github.event.comment && startsWith(github.event.issue.body, '@pytestbot please'))
-
-    steps:
-    - uses: actions/checkout@v2
-      with:
-        fetch-depth: 0
-
-    - name: Set up Python
-      uses: actions/setup-python@v2
-      with:
-        python-version: "3.8"
-    - name: Install dependencies
-      run: |
-        python -m pip install --upgrade pip
-        pip install --upgrade setuptools tox
-    - name: Prepare release
-      run: |
-        tox -e release-on-comment -- $GITHUB_EVENT_PATH ${{ secrets.chatops }}
diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml
new file mode 100644 (file)
index 0000000..3f8ca18
--- /dev/null
@@ -0,0 +1,23 @@
+name: close needs-information issues
+on:
+  schedule:
+    - cron: "30 1 * * *"
+  workflow_dispatch:
+
+jobs:
+  close-issues:
+    runs-on: ubuntu-latest
+    permissions:
+      issues: write
+    steps:
+      - uses: actions/stale@v8
+        with:
+          debug-only: false
+          days-before-issue-stale: 14
+          days-before-issue-close: 7
+          only-labels: "status: needs information"
+          stale-issue-label: "stale"
+          stale-issue-message: "This issue is stale because it has been open for 14 days with no activity."
+          close-issue-message: "This issue was closed because it has been inactive for 7 days since being marked as stale."
+          days-before-pr-stale: -1
+          days-before-pr-close: -1
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644 (file)
index 0000000..a3c2d9e
--- /dev/null
@@ -0,0 +1,223 @@
+name: test
+
+on:
+  push:
+    branches:
+      - main
+      - "[0-9]+.[0-9]+.x"
+      - "test-me-*"
+    tags:
+      - "[0-9]+.[0-9]+.[0-9]+"
+      - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
+
+  pull_request:
+    branches:
+      - main
+      - "[0-9]+.[0-9]+.x"
+
+env:
+  PYTEST_ADDOPTS: "--color=yes"
+
+# Cancel running jobs for the same workflow and branch.
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+# Set permissions at the job level.
+permissions: {}
+
+jobs:
+  package:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+        persist-credentials: false
+    - name: Build and Check Package
+      uses: hynek/build-and-inspect-python-package@v1.5
+
+  build:
+    needs: [package]
+
+    runs-on: ${{ matrix.os }}
+    timeout-minutes: 45
+    permissions:
+      contents: read
+
+    strategy:
+      fail-fast: false
+      matrix:
+        name: [
+          "windows-py37",
+          "windows-py38",
+          "windows-py38-pluggy",
+          "windows-py39",
+          "windows-py310",
+          "windows-py311",
+          "windows-py312",
+
+          "ubuntu-py37",
+          "ubuntu-py37-freeze",
+          "ubuntu-py38",
+          "ubuntu-py38-pluggy",
+          "ubuntu-py39",
+          "ubuntu-py310",
+          "ubuntu-py311",
+          "ubuntu-py312",
+          "ubuntu-pypy3",
+
+          "macos-py37",
+          "macos-py39",
+          "macos-py310",
+          "macos-py312",
+
+          "doctesting",
+          "plugins",
+        ]
+
+        include:
+          - name: "windows-py37"
+            python: "3.7"
+            os: windows-latest
+            tox_env: "py37-numpy"
+          - name: "windows-py38"
+            python: "3.8"
+            os: windows-latest
+            tox_env: "py38-unittestextras"
+            use_coverage: true
+          - name: "windows-py38-pluggy"
+            python: "3.8"
+            os: windows-latest
+            tox_env: "py38-pluggymain-pylib-xdist"
+          - name: "windows-py39"
+            python: "3.9"
+            os: windows-latest
+            tox_env: "py39-xdist"
+          - name: "windows-py310"
+            python: "3.10"
+            os: windows-latest
+            tox_env: "py310-xdist"
+          - name: "windows-py311"
+            python: "3.11"
+            os: windows-latest
+            tox_env: "py311"
+          - name: "windows-py312"
+            python: "3.12-dev"
+            os: windows-latest
+            tox_env: "py312"
+
+          - name: "ubuntu-py37"
+            python: "3.7"
+            os: ubuntu-latest
+            tox_env: "py37-lsof-numpy-pexpect"
+            use_coverage: true
+          - name: "ubuntu-py37-freeze"
+            python: "3.7"
+            os: ubuntu-latest
+            tox_env: "py37-freeze"
+          - name: "ubuntu-py38"
+            python: "3.8"
+            os: ubuntu-latest
+            tox_env: "py38-xdist"
+          - name: "ubuntu-py38-pluggy"
+            python: "3.8"
+            os: ubuntu-latest
+            tox_env: "py38-pluggymain-pylib-xdist"
+          - name: "ubuntu-py39"
+            python: "3.9"
+            os: ubuntu-latest
+            tox_env: "py39-xdist"
+          - name: "ubuntu-py310"
+            python: "3.10"
+            os: ubuntu-latest
+            tox_env: "py310-xdist"
+          - name: "ubuntu-py311"
+            python: "3.11"
+            os: ubuntu-latest
+            tox_env: "py311"
+            use_coverage: true
+          - name: "ubuntu-py312"
+            python: "3.12-dev"
+            os: ubuntu-latest
+            tox_env: "py312"
+            use_coverage: true
+          - name: "ubuntu-pypy3"
+            python: "pypy-3.7"
+            os: ubuntu-latest
+            tox_env: "pypy3-xdist"
+
+          - name: "macos-py37"
+            python: "3.7"
+            os: macos-latest
+            tox_env: "py37-xdist"
+          - name: "macos-py39"
+            python: "3.9"
+            os: macos-latest
+            tox_env: "py39-xdist"
+            use_coverage: true
+          - name: "macos-py310"
+            python: "3.10"
+            os: macos-latest
+            tox_env: "py310-xdist"
+          - name: "macos-py312"
+            python: "3.12-dev"
+            os: macos-latest
+            tox_env: "py312-xdist"
+
+          - name: "plugins"
+            python: "3.9"
+            os: ubuntu-latest
+            tox_env: "plugins"
+
+          - name: "doctesting"
+            python: "3.7"
+            os: ubuntu-latest
+            tox_env: "doctesting"
+            use_coverage: true
+
+    steps:
+    - uses: actions/checkout@v3
+      with:
+        fetch-depth: 0
+        persist-credentials: false
+
+    - name: Download Package
+      uses: actions/download-artifact@v3
+      with:
+        name: Packages
+        path: dist
+
+    - name: Set up Python ${{ matrix.python }}
+      uses: actions/setup-python@v4
+      with:
+        python-version: ${{ matrix.python }}
+        check-latest: ${{ endsWith(matrix.python, '-dev') }}
+
+    - name: Install dependencies
+      run: |
+        python -m pip install --upgrade pip
+        pip install tox coverage
+
+    - name: Test without coverage
+      if: "! matrix.use_coverage"
+      shell: bash
+      run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz`
+
+    - name: Test with coverage
+      if: "matrix.use_coverage"
+      shell: bash
+      run: tox run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz`
+
+    - name: Generate coverage report
+      if: "matrix.use_coverage"
+      run: python -m coverage xml
+
+    - name: Upload coverage to Codecov
+      if: "matrix.use_coverage"
+      uses: codecov/codecov-action@v3
+      continue-on-error: true
+      with:
+        fail_ci_if_error: true
+        files: ./coverage.xml
+        verbose: true
diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml
new file mode 100644 (file)
index 0000000..e7cbc4e
--- /dev/null
@@ -0,0 +1,49 @@
+name: Update Plugin List
+
+on:
+  schedule:
+    # At 00:00 on Sunday.
+    # https://crontab.guru
+    - cron: '0 0 * * 0'
+  workflow_dispatch:
+
+# Set permissions at the job level.
+permissions: {}
+
+jobs:
+  update-plugin-list:
+    if: github.repository_owner == 'pytest-dev'
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      pull-requests: write
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+        with:
+          fetch-depth: 0
+
+      - name: Setup Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: 3.8
+
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          pip install packaging requests tabulate[widechars] tqdm
+
+      - name: Update Plugin List
+        run: python scripts/update-plugin-list.py
+
+      - name: Create Pull Request
+        uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
+        with:
+          commit-message: '[automated] Update plugin list'
+          author: 'pytest bot <pytestbot@users.noreply.github.com>'
+          branch: update-plugin-list/patch
+          delete-branch: true
+          branch-suffix: short-commit-hash
+          title: '[automated] Update plugin list'
+          body: '[automated] Update plugin list'
index 23e7c99668832e139d8d0898895b65fe5c8b8753..3cac2474a5941681a27b68ea790ac36411a48158 100644 (file)
@@ -50,6 +50,10 @@ coverage.xml
 .project
 .settings
 .vscode
+__pycache__/
 
 # generated by pip
 pip-wheel-metadata/
+
+# pytest debug logs generated via --debug
+pytestdebug.log
index 68cc3273bbae543c5ce29ea734bfc68e989fc688..b5089e1294298c6115c6b05e0c45b3e38d49d8db 100644 (file)
@@ -1,16 +1,16 @@
 repos:
 -   repo: https://github.com/psf/black
-    rev: 19.10b0
+    rev: 23.3.0
     hooks:
     -   id: black
         args: [--safe, --quiet]
 -   repo: https://github.com/asottile/blacken-docs
-    rev: v1.8.0
+    rev: 1.14.0
     hooks:
     -   id: blacken-docs
-        additional_dependencies: [black==19.10b0]
+        additional_dependencies: [black==23.1.0]
 -   repo: https://github.com/pre-commit/pre-commit-hooks
-    rev: v3.2.0
+    rev: v4.4.0
     hooks:
     -   id: trailing-whitespace
     -   id: end-of-file-fixer
@@ -20,45 +20,56 @@ repos:
     -   id: debug-statements
         exclude: _pytest/(debugging|hookspec).py
         language_version: python3
--   repo: https://gitlab.com/pycqa/flake8
-    rev: 3.8.3
+-   repo: https://github.com/PyCQA/autoflake
+    rev: v2.1.1
+    hooks:
+    -   id: autoflake
+        name: autoflake
+        args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
+        language: python
+        files: \.py$
+-   repo: https://github.com/PyCQA/flake8
+    rev: 6.0.0
     hooks:
     -   id: flake8
         language_version: python3
         additional_dependencies:
-          - flake8-typing-imports==1.9.0
+          - flake8-typing-imports==1.12.0
           - flake8-docstrings==1.5.0
--   repo: https://github.com/asottile/reorder_python_imports
-    rev: v2.3.5
+-   repo: https://github.com/asottile/reorder-python-imports
+    rev: v3.10.0
     hooks:
     -   id: reorder-python-imports
-        args: ['--application-directories=.:src', --py36-plus]
+        args: ['--application-directories=.:src', --py37-plus]
 -   repo: https://github.com/asottile/pyupgrade
-    rev: v2.7.2
+    rev: v3.7.0
     hooks:
     -   id: pyupgrade
-        args: [--py36-plus]
+        args: [--py37-plus]
 -   repo: https://github.com/asottile/setup-cfg-fmt
-    rev: v1.11.0
+    rev: v2.3.0
     hooks:
     -   id: setup-cfg-fmt
-        # TODO: when upgrading setup-cfg-fmt this can be removed
-        args: [--max-py-version=3.9]
+        args: ["--max-py-version=3.12", "--include-version-classifiers"]
 -   repo: https://github.com/pre-commit/pygrep-hooks
-    rev: v1.6.0
+    rev: v1.10.0
     hooks:
     -   id: python-use-type-annotations
 -   repo: https://github.com/pre-commit/mirrors-mypy
-    rev: v0.790
+    rev: v1.3.0
     hooks:
     -   id: mypy
         files: ^(src/|testing/)
         args: []
         additional_dependencies:
           - iniconfig>=1.1.0
-          - py>=1.8.2
           - attrs>=19.2.0
           - packaging
+          - tomli
+          - types-pkg_resources
+            # for mypy running on python>=3.11 since exceptiongroup is only a dependency
+            # on <3.11
+          - exceptiongroup>=1.0.0rc8
 -   repo: local
     hooks:
     -   id: rst
@@ -89,3 +100,9 @@ repos:
                 xml\.
             )
         types: [python]
+    -   id: py-path-deprecated
+        name: py.path usage is deprecated
+        exclude: docs|src/_pytest/deprecated.py|testing/deprecated_test.py|src/_pytest/legacypath.py
+        language: pygrep
+        entry: \bpy\.path\.local
+        types: [python]
index 0176c2640015ee932f21ec01f8d896b1d7410e33..266d4e07aead5fafdcdbddf96a748e118e18b8da 100644 (file)
@@ -1,12 +1,26 @@
 version: 2
 
 python:
-   version: 3.7
    install:
-      - requirements: doc/en/requirements.txt
-      - method: pip
-        path: .
+     # Install pytest first, then doc/en/requirements.txt.
+     # This order is important to honor any pins in doc/en/requirements.txt
+     # when the pinned library is also a dependency of pytest.
+     - method: pip
+       path: .
+     - requirements: doc/en/requirements.txt
+
+sphinx:
+  configuration: doc/en/conf.py
+  fail_on_warning: true
+
+build:
+  os: ubuntu-20.04
+  tools:
+    python: "3.9"
+  apt_packages:
+    - inkscape
 
 formats:
   - epub
   - pdf
+  - htmlzip
diff --git a/AUTHORS b/AUTHORS
index b35bebf7af35008eb94424ff3841605c9e347059..be1e7863860711c35fe9a180cad20924895e850c 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,14 +5,21 @@ Contributors include::
 
 Aaron Coleman
 Abdeali JK
+Abdelrahman Elbehery
 Abhijeet Kasurde
 Adam Johnson
+Adam Stewart
 Adam Uhlir
 Ahn Ki-Wook
 Akiomi Kamakura
 Alan Velasco
+Alessio Izzo
+Alex Jones
+Alex Lambson
 Alexander Johnson
+Alexander King
 Alexei Kozlenok
+Alice Purcell
 Allan Feldman
 Aly Sivji
 Amir Elkess
@@ -23,6 +30,7 @@ Andras Tim
 Andrea Cimatoribus
 Andreas Motl
 Andreas Zeidler
+Andrew Shapton
 Andrey Paramonov
 Andrzej Klajnert
 Andrzej Ostrowski
@@ -30,25 +38,32 @@ Andy Freeland
 Anthon van der Neut
 Anthony Shaw
 Anthony Sottile
+Anton Grinevich
 Anton Lodder
 Antony Lee
 Arel Cordero
+Arias Emmanuel
 Ariel Pillemer
 Armin Rigo
 Aron Coyle
 Aron Curzon
+Ashish Kurmi
 Aviral Verma
 Aviv Palivoda
+Babak Keyvani
 Barney Gale
+Ben Gartner
 Ben Webb
 Benjamin Peterson
 Bernard Pratz
 Bob Ippolito
 Brian Dorsey
+Brian Larsen
 Brian Maissy
 Brian Okken
 Brianna Laugher
 Bruno Oliveira
+Cal Jacobson
 Cal Leeming
 Carl Friedrich Bolz
 Carlos Jenkins
@@ -56,8 +71,12 @@ Ceridwen
 Charles Cloud
 Charles Machalow
 Charnjit SiNGH (CCSJ)
+Cheuk Ting Ho
+Chris Mahoney
 Chris Lamb
 Chris NeJame
+Chris Rose
+Chris Wheeler
 Christian Boelsen
 Christian Fetzer
 Christian Neumüller
@@ -70,12 +89,16 @@ Christopher Gilling
 Claire Cecil
 Claudio Madotto
 CrazyMerlyn
+Cristian Vera
 Cyrus Maden
 Damian Skrzypczak
 Daniel Grana
 Daniel Hahler
 Daniel Nuri
+Daniel Sánchez Castelló
+Daniel Valenzuela Zenteno
 Daniel Wandschneider
+Daniele Procida
 Danielle Jenkins
 Daniil Galiev
 Dave Hunt
@@ -87,6 +110,7 @@ David Vierra
 Daw-Ran Liou
 Debi Mishra
 Denis Kirisov
+Denivy Braiam Rück
 Dhiren Serai
 Diego Russo
 Dmitry Dygalo
@@ -95,28 +119,36 @@ Dominic Mortlock
 Duncan Betts
 Edison Gustavo Muenz
 Edoardo Batini
+Edson Tadeu M. Manoel
 Eduardo Schettino
 Eli Boyarski
 Elizaveta Shashkova
+Éloi Rivard
 Endre Galaczi
 Eric Hunsberger
+Eric Liu
 Eric Siegerman
 Erik Aronesty
 Erik M. Bray
 Evan Kepner
+Evgeny Seliverstov
 Fabien Zarifian
 Fabio Zadrozny
+Felix Hofstätter
 Felix Nieuwenhuizen
 Feng Ma
 Florian Bruhin
 Florian Dahlitz
 Floris Bruynooghe
+Gabriel Landau
 Gabriel Reis
 Garvit Shubham
 Gene Wood
 George Kussumoto
 Georgy Dyuldin
+Gergely Kalmár
 Gleb Nikonorov
+Graeme Smecher
 Graham Horler
 Greg Price
 Gregory Lee
@@ -125,6 +157,7 @@ Grigorii Eremeev (budulianin)
 Guido Wesdorp
 Guoqiang Zhang
 Harald Armin Massa
+Harshna
 Henk-Jaap Wagenaar
 Holger Kohr
 Hugo van Kemenade
@@ -133,10 +166,15 @@ Ian Bicking
 Ian Lesperance
 Ilya Konstantinov
 Ionuț Turturică
+Isaac Virshup
+Israel Fruchter
+Itxaso Aizpurua
 Iwan Briquemont
 Jaap Broekhuizen
+Jake VanderPlas
 Jakob van Santen
 Jakub Mitoraj
+James Bourbeau
 Jan Balster
 Janne Vanhala
 Jason R. Coombs
@@ -146,7 +184,9 @@ Jeff Rackauckas
 Jeff Widman
 Jenni Rinker
 John Eddie Ayson
+John Litborn
 John Towler
+Jon Parise
 Jon Sonesen
 Jonas Obrist
 Jordan Guymon
@@ -156,18 +196,25 @@ Joseph Hunkeler
 Josh Karpel
 Joshua Bronson
 Jurko Gospodnetić
+Justice Ndou
 Justyna Janczyszyn
 Kale Kundert
 Kamran Ahmad
+Kenny Y
 Karl O. Pinc
 Karthikeyan Singaravelan
 Katarzyna Jachim
 Katarzyna Król
 Katerina Koukiou
 Keri Volans
+Kevin C
 Kevin Cox
+Kevin Hierro Carrasco
 Kevin J. Foley
+Kian Eliasi
+Kian-Meng Ang
 Kodi B. Arfer
+Kojo Idrissa
 Kostis Anagnostopoulos
 Kristoffer Nordström
 Kyle Altendorf
@@ -184,12 +231,14 @@ Maho
 Maik Figura
 Mandeep Bhutani
 Manuel Krebber
+Marc Mueller
 Marc Schlaich
 Marcelo Duarte Trevisani
 Marcin Bachry
 Marco Gorelli
 Mark Abramowitz
 Mark Dickinson
+Marko Pacak
 Markus Unterwaditzer
 Martijn Faassen
 Martin Altmayer
@@ -203,7 +252,6 @@ Matthias Hafner
 Maxim Filipenko
 Maximilian Cosmo Sitter
 mbyt
-Mickey Pashov
 Michael Aquilina
 Michael Birtwell
 Michael Droettboom
@@ -211,6 +259,8 @@ Michael Goerz
 Michael Krebs
 Michael Seifert
 Michal Wajszczuk
+Michał Zięba
+Mickey Pashov
 Mihai Capotă
 Mike Hoyle (hoylemd)
 Mike Lundy
@@ -224,20 +274,26 @@ Nicholas Murphy
 Niclas Olofsson
 Nicolas Delaby
 Nikolay Kondratyev
+Nipunn Koorapati
 Oleg Pidsadnyi
 Oleg Sushchenko
+Olga Matoula
 Oliver Bestwalter
 Omar Kohl
 Omer Hadari
 Ondřej Súkup
 Oscar Benjamin
+Parth Patel
 Patrick Hayes
+Paul Müller
+Paul Reece
 Pauli Virtanen
 Pavel Karateev
 Paweł Adamczak
 Pedro Algarvio
 Petter Strandmark
 Philipp Loose
+Pierre Sassoulas
 Pieter Mulder
 Piotr Banaszkiewicz
 Piotr Helm
@@ -247,15 +303,18 @@ Prashant Sharma
 Pulkit Goyal
 Punyashloka Biswal
 Quentin Pradet
+q0w
 Ralf Schmitt
-Ram Rachum
 Ralph Giles
+Ram Rachum
 Ran Benita
 Raphael Castaneda
 Raphael Pierzina
+Rafal Semik
 Raquel Alegre
 Ravi Chandra
 Robert Holt
+Roberto Aldera
 Roberto Polli
 Roland Puntaier
 Romain Dorgueil
@@ -265,22 +324,30 @@ Ross Lawley
 Ruaridh Williamson
 Russel Winder
 Ryan Wooden
+Saiprasad Kale
+Samuel Colvin
 Samuel Dion-Girardeau
 Samuel Searles-Bryant
 Samuele Pedroni
 Sanket Duthade
 Sankt Petersbug
+Saravanan Padmanaban
 Segev Finer
 Serhii Mozghovyi
 Seth Junot
+Shantanu Jain
 Shubham Adep
+Simon Blanchard
 Simon Gomizelj
+Simon Holesch
 Simon Kerr
 Skylar Downes
 Srinivas Reddy Thatiparthy
+Stefaan Lippens
 Stefan Farmbauer
 Stefan Scherfke
 Stefan Zimmermann
+Stefanie Molin
 Stefano Taschini
 Steffen Allner
 Stephan Obermann
@@ -288,28 +355,38 @@ Sven-Hendrik Haase
 Sylvain Marié
 Tadek Teleżyński
 Takafumi Arakaki
+Taneli Hukkinen
 Tanvi Mehta
 Tarcisio Fischer
 Tareq Alayan
+Tatiana Ovary
 Ted Xiao
+Terje Runde
 Thomas Grainger
 Thomas Hisch
 Tim Hoffmann
 Tim Strazny
+TJ Bruno
+Tobias Diez
 Tom Dalton
 Tom Viner
 Tomáš Gavenčiak
 Tomer Keren
+Tony Narlock
 Tor Colvin
 Trevor Bekolay
 Tyler Goodlet
+Tyler Smart
 Tzu-ping Chung
 Vasily Kuznetsov
 Victor Maryama
+Victor Rodriguez
 Victor Uriarte
 Vidar T. Fauske
+Vijay Arora
 Virgil Dupras
 Vitaly Lashmanov
+Vivaan Verma
 Vlad Dragos
 Vlad Radziuk
 Vladyslav Rachek
@@ -322,7 +399,14 @@ Wouter van Ackooy
 Xixi Zhao
 Xuan Luong
 Xuecong Liao
+Yannick Péroux
 Yoav Caspi
+Yuliang Shao
+Yusuke Kadowaki
+Yuval Shimon
 Zac Hatfield-Dodds
+Zachary Kneupper
+Zachary OBrien
+Zhouxin Qiu
 Zoltán Máté
 Zsolt Cserna
index 3865f250c26e4704bd12cc20e706c1bb98d08bdf..481f277813a5bf545b772aec31fb69ae11bdb514 100644 (file)
@@ -4,4 +4,4 @@ Changelog
 
 The pytest CHANGELOG is located `here <https://docs.pytest.org/en/stable/changelog.html>`__.
 
-The source document can be found at: https://github.com/pytest-dev/pytest/blob/master/doc/en/changelog.rst
+The source document can be found at: https://github.com/pytest-dev/pytest/blob/main/doc/en/changelog.rst
index 2669cb19509b920e98749850c533282038471a3e..5ccc66bf5c46c921f56d4f99040b499191236e7a 100644 (file)
@@ -50,6 +50,8 @@ Fix bugs
 --------
 
 Look through the `GitHub issues for bugs <https://github.com/pytest-dev/pytest/labels/type:%20bug>`_.
+See also the `"good first issue" issues <https://github.com/pytest-dev/pytest/labels/good%20first%20issue>`_
+that are friendly to new contributors.
 
 :ref:`Talk <contact>` to developers to find out how you can fix specific bugs. To indicate that you are going
 to work on a particular issue, add a comment to that effect on the specific issue.
@@ -160,7 +162,7 @@ the following:
 
 - an issue tracker for bug reports and enhancement requests.
 
-- a `changelog <http://keepachangelog.com/>`_.
+- a `changelog <https://keepachangelog.com/>`_.
 
 If no contributor strongly objects and two agree, the repository can then be
 transferred to the ``pytest-dev`` organisation.
@@ -221,7 +223,7 @@ changes you want to review and merge.  Pull requests are stored on
 Once you send a pull request, we can discuss its potential modifications and
 even add more commits to it later on. There's an excellent tutorial on how Pull
 Requests work in the
-`GitHub Help Center <https://help.github.com/articles/using-pull-requests/>`_.
+`GitHub Help Center <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>`_.
 
 Here is a simple overview, with pytest-specific bits:
 
@@ -234,14 +236,19 @@ Here is a simple overview, with pytest-specific bits:
 
     $ git clone git@github.com:YOUR_GITHUB_USERNAME/pytest.git
     $ cd pytest
-    # now, create your own branch off "master":
+    # now, create your own branch off "main":
 
-        $ git checkout -b your-bugfix-branch-name master
+        $ git checkout -b your-bugfix-branch-name main
 
    Given we have "major.minor.micro" version numbers, bug fixes will usually
    be released in micro releases whereas features will be released in
    minor releases and incompatible changes in major releases.
 
+   You will need the tags to test locally, so be sure you have the tags from the main repository. If you suspect you don't, set the main repository as upstream and fetch the tags::
+
+     $ git remote add upstream https://github.com/pytest-dev/pytest
+     $ git fetch upstream --tags
+
    If you need some help with Git, follow this quick start
    guide: https://git.wiki.kernel.org/index.php/QuickStart
 
@@ -259,7 +266,7 @@ Here is a simple overview, with pytest-specific bits:
 
    Tox is used to run all the tests and will automatically setup virtualenvs
    to run the tests in.
-   (will implicitly use http://www.virtualenv.org/en/latest/)::
+   (will implicitly use https://virtualenv.pypa.io/en/latest/)::
 
     $ pip install tox
 
@@ -318,26 +325,26 @@ Here is a simple overview, with pytest-specific bits:
     compare: your-branch-name
 
     base-fork: pytest-dev/pytest
-    base: master
+    base: main
 
 
 Writing Tests
 ~~~~~~~~~~~~~
 
-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.
+Writing tests for plugins or for pytest itself is often done using the `pytester fixture <https://docs.pytest.org/en/stable/reference/reference.html#pytester>`_, as a "black-box" test.
 
 For example, to ensure a simple test passes you can write:
 
 .. code-block:: python
 
-    def test_true_assertion(testdir):
-        testdir.makepyfile(
+    def test_true_assertion(pytester):
+        pytester.makepyfile(
             """
             def test_foo():
                 assert True
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.assert_outcomes(failed=0, passed=1)
 
 
@@ -346,14 +353,14 @@ Alternatively, it is possible to make checks based on the actual output of the t
 
 .. code-block:: python
 
-    def test_true_assertion(testdir):
-        testdir.makepyfile(
+    def test_true_assertion(pytester):
+        pytester.makepyfile(
             """
             def test_foo():
                 assert False
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*assert False*", "*1 failed*"])
 
 When choosing a file where to write a new test, take a look at the existing files and see if there's
@@ -378,7 +385,7 @@ them.
 Backporting bug fixes for the next patch release
 ------------------------------------------------
 
-Pytest makes feature release every few weeks or months. In between, patch releases
+Pytest makes feature release every few weeks or months. In between, patch releases
 are made to the previous feature release, containing bug fixes only. The bug fixes
 usually fix regressions, but may be any change that should reach users before the
 next feature release.
@@ -387,15 +394,22 @@ Suppose for example that the latest release was 1.2.3, and you want to include
 a bug fix in 1.2.4 (check https://github.com/pytest-dev/pytest/releases for the
 actual latest release). The procedure for this is:
 
-#. First, make sure the bug is fixed the ``master`` branch, with a regular pull
+#. First, make sure the bug is fixed in the ``main`` branch, with a regular pull
    request, as described above. An exception to this is if the bug fix is not
-   applicable to ``master`` anymore.
+   applicable to ``main`` anymore.
+
+Automatic method:
+
+Add a ``backport 1.2.x`` label to the PR you want to backport. This will create
+a backport PR against the ``1.2.x`` branch.
+
+Manual method:
 
-#. ``git checkout origin/1.2.x -b backport-XXXX`` # use the master PR number here
+#. ``git checkout origin/1.2.x -b backport-XXXX`` # use the main PR number here
 
 #. Locate the merge commit on the PR, in the *merged* message, for example:
 
-    nicoddemus merged commit 0f8b462 into pytest-dev:master
+    nicoddemus merged commit 0f8b462 into pytest-dev:main
 
 #. ``git cherry-pick -x -m1 REVISION`` # use the revision you found above (``0f8b462``).
 
@@ -408,8 +422,8 @@ actual latest release). The procedure for this is:
 Who does the backporting
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
-As mentioned above, bugs should first be fixed on ``master`` (except in rare occasions
-that a bug only happens in a previous release). So who should do the backport procedure described
+As mentioned above, bugs should first be fixed on ``main`` (except in rare occasions
+that a bug only happens in a previous release). So, who should do the backport procedure described
 above?
 
 1. If the bug was fixed by a core developer, it is the main responsibility of that core developer
@@ -417,8 +431,8 @@ above?
 2. However, often the merge is done by another maintainer, in which case it is nice of them to
    do the backport procedure if they have the time.
 3. For bugs submitted by non-maintainers, it is expected that a core developer will to do
-   the backport, normally the one that merged the PR on ``master``.
-4. If a non-maintainers notices a bug which is fixed on ``master`` but has not been backported
+   the backport, normally the one that merged the PR on ``main``.
+4. If a non-maintainers notices a bug which is fixed on ``main`` but has not been backported
    (due to maintainers forgetting to apply the *needs backport* label, or just plain missing it),
    they are also welcome to open a PR with the backport. The procedure is simple and really
    helps with the maintenance of the project.
@@ -447,7 +461,7 @@ can always reopen the issue/pull request in their own time later if it makes sen
 When to close
 ~~~~~~~~~~~~~
 
-Here are a few general rules the maintainers use to decide when to close issues/PRs because
+Here are a few general rules the maintainers use deciding when to close issues/PRs because
 of lack of inactivity:
 
 * Issues labeled ``question`` or ``needs information``: closed after 14 days inactive.
@@ -459,15 +473,15 @@ The above are **not hard rules**, but merely **guidelines**, and can be (and oft
 Closing pull requests
 ~~~~~~~~~~~~~~~~~~~~~
 
-When closing a Pull Request, it needs to be acknowledge the time, effort, and interest demonstrated by the person which submitted it. As mentioned previously, it is not the intent of the team to dismiss stalled pull request entirely but to merely to clear up our queue, so a message like the one below is warranted when closing a pull request that went stale:
+When closing a Pull Request, it needs to be acknowledging the time, effort, and interest demonstrated by the person which submitted it. As mentioned previously, it is not the intent of the team to dismiss a stalled pull request entirely but to merely to clear up our queue, so a message like the one below is warranted when closing a pull request that went stale:
 
     Hi <contributor>,
 
-    First of all we would like to thank you for your time and effort on working on this, the pytest team deeply appreciates it.
+    First of all, we would like to thank you for your time and effort on working on this, the pytest team deeply appreciates it.
 
     We noticed it has been awhile since you have updated this PR, however. pytest is a high activity project, with many issues/PRs being opened daily, so it is hard for us maintainers to track which PRs are ready for merging, for review, or need more attention.
 
-    So for those reasons we think it is best to close the PR for now, but with the only intention to cleanup our queue, it is by no means a rejection of your changes. We still encourage you to re-open this PR (it is just a click of a button away) when you are ready to get back to it.
+    So for those reasons we, think it is best to close the PR for now, but with the only intention to clean up our queue, it is by no means a rejection of your changes. We still encourage you to re-open this PR (it is just a click of a button away) when you are ready to get back to it.
 
     Again we appreciate your time for working on this, and hope you might get back to this at a later time!
 
diff --git a/LICENSE b/LICENSE
index d14fb7ff4b34be8cfb361a3ce90a0e881475a97a..c3f1657fce94589bd1ec7cead810639047f3d359 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2004-2020 Holger Krekel and others
+Copyright (c) 2004 Holger Krekel and others
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
 this software and associated documentation files (the "Software"), to deal in
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644 (file)
index 0000000..386915f
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,222 @@
+Metadata-Version: 2.1
+Name: pytest
+Version: 7.4.3
+Summary: pytest: simple powerful testing with Python
+Home-page: https://docs.pytest.org/en/latest/
+Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
+License: MIT
+Project-URL: Changelog, https://docs.pytest.org/en/stable/changelog.html
+Project-URL: Twitter, https://twitter.com/pytestdotorg
+Project-URL: Source, https://github.com/pytest-dev/pytest
+Project-URL: Tracker, https://github.com/pytest-dev/pytest/issues
+Keywords: test,unittest
+Platform: unix
+Platform: linux
+Platform: osx
+Platform: cygwin
+Platform: win32
+Classifier: Development Status :: 6 - Mature
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: POSIX
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
+Classifier: Programming Language :: Python :: 3.12
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Testing
+Classifier: Topic :: Utilities
+Requires-Python: >=3.7
+Description-Content-Type: text/x-rst
+License-File: LICENSE
+Requires-Dist: iniconfig
+Requires-Dist: packaging
+Requires-Dist: pluggy<2.0,>=0.12
+Requires-Dist: colorama; sys_platform == "win32"
+Requires-Dist: exceptiongroup>=1.0.0rc8; python_version < "3.11"
+Requires-Dist: importlib-metadata>=0.12; python_version < "3.8"
+Requires-Dist: tomli>=1.0.0; python_version < "3.11"
+Provides-Extra: testing
+Requires-Dist: argcomplete; extra == "testing"
+Requires-Dist: attrs>=19.2.0; extra == "testing"
+Requires-Dist: hypothesis>=3.56; extra == "testing"
+Requires-Dist: mock; extra == "testing"
+Requires-Dist: nose; extra == "testing"
+Requires-Dist: pygments>=2.7.2; extra == "testing"
+Requires-Dist: requests; extra == "testing"
+Requires-Dist: setuptools; extra == "testing"
+Requires-Dist: xmlschema; extra == "testing"
+
+.. image:: https://github.com/pytest-dev/pytest/raw/main/doc/en/img/pytest_logo_curves.svg
+   :target: https://docs.pytest.org/en/stable/
+   :align: center
+   :height: 200
+   :alt: pytest
+
+
+------
+
+.. image:: https://img.shields.io/pypi/v/pytest.svg
+    :target: https://pypi.org/project/pytest/
+
+.. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg
+    :target: https://anaconda.org/conda-forge/pytest
+
+.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
+    :target: https://pypi.org/project/pytest/
+
+.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/main/graph/badge.svg
+    :target: https://codecov.io/gh/pytest-dev/pytest
+    :alt: Code coverage Status
+
+.. image:: https://github.com/pytest-dev/pytest/workflows/test/badge.svg
+    :target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Atest
+
+.. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
+   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
+   :alt: pre-commit.ci status
+
+.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
+    :target: https://github.com/psf/black
+
+.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
+    :target: https://www.codetriage.com/pytest-dev/pytest
+
+.. image:: https://readthedocs.org/projects/pytest/badge/?version=latest
+    :target: https://pytest.readthedocs.io/en/latest/?badge=latest
+    :alt: Documentation Status
+
+.. image:: https://img.shields.io/badge/Discord-pytest--dev-blue
+    :target: https://discord.com/invite/pytest-dev
+    :alt: Discord
+
+.. image:: https://img.shields.io/badge/Libera%20chat-%23pytest-orange
+    :target: https://web.libera.chat/#pytest
+    :alt: Libera chat
+
+
+The ``pytest`` framework makes it easy to write small tests, yet
+scales to support complex functional testing for applications and libraries.
+
+An example of a simple test:
+
+.. code-block:: python
+
+    # content of test_sample.py
+    def inc(x):
+        return x + 1
+
+
+    def test_answer():
+        assert inc(3) == 5
+
+
+To execute it::
+
+    $ pytest
+    ============================= test session starts =============================
+    collected 1 items
+
+    test_sample.py F
+
+    ================================== FAILURES ===================================
+    _________________________________ test_answer _________________________________
+
+        def test_answer():
+    >       assert inc(3) == 5
+    E       assert 4 == 5
+    E        +  where 4 = inc(3)
+
+    test_sample.py:5: AssertionError
+    ========================== 1 failed in 0.04 seconds ===========================
+
+
+Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <https://docs.pytest.org/en/stable/getting-started.html#our-first-test-run>`_ for more examples.
+
+
+Features
+--------
+
+- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/how-to/assert.html>`_ (no need to remember ``self.assert*`` names)
+
+- `Auto-discovery
+  <https://docs.pytest.org/en/stable/explanation/goodpractices.html#python-test-discovery>`_
+  of test modules and functions
+
+- `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
+  managing small or parametrized long-lived test resources
+
+- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
+  `nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
+
+- Python 3.7+ or PyPy3
+
+- Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
+
+
+Documentation
+-------------
+
+For full documentation, including installation, tutorials and PDF documents, please see https://docs.pytest.org/en/stable/.
+
+
+Bugs/Requests
+-------------
+
+Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features.
+
+
+Changelog
+---------
+
+Consult the `Changelog <https://docs.pytest.org/en/stable/changelog.html>`__ page for fixes and enhancements of each version.
+
+
+Support pytest
+--------------
+
+`Open Collective`_ is an online funding platform for open and transparent communities.
+It provides tools to raise money and share your finances in full transparency.
+
+It is the platform of choice for individuals and companies that want to make one-time or
+monthly donations directly to the project.
+
+See more details in the `pytest collective`_.
+
+.. _Open Collective: https://opencollective.com
+.. _pytest collective: https://opencollective.com/pytest
+
+
+pytest for enterprise
+---------------------
+
+Available as part of the Tidelift Subscription.
+
+The maintainers of pytest and thousands of other packages are working with Tidelift to deliver commercial support and
+maintenance for the open source dependencies you use to build your applications.
+Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
+
+`Learn more. <https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`_
+
+Security
+^^^^^^^^
+
+pytest has never been associated with a security vulnerability, but in any case, to report a
+security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
+Tidelift will coordinate the fix and disclosure.
+
+
+License
+-------
+
+Copyright Holger Krekel and others, 2004.
+
+Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
+
+.. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE
index 398d6451c581aa688acdce34fad060e1a9dba20f..034034a40b8e7ac28c7095e38ca437b6e99216a5 100644 (file)
@@ -1,6 +1,7 @@
-.. image:: https://docs.pytest.org/en/stable/_static/pytest1.png
+.. image:: https://github.com/pytest-dev/pytest/raw/main/doc/en/img/pytest_logo_curves.svg
    :target: https://docs.pytest.org/en/stable/
    :align: center
+   :height: 200
    :alt: pytest
 
 
 .. image:: https://img.shields.io/pypi/pyversions/pytest.svg
     :target: https://pypi.org/project/pytest/
 
-.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/master/graph/badge.svg
+.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/main/graph/badge.svg
     :target: https://codecov.io/gh/pytest-dev/pytest
     :alt: Code coverage Status
 
-.. image:: https://travis-ci.org/pytest-dev/pytest.svg?branch=master
-    :target: https://travis-ci.org/pytest-dev/pytest
+.. image:: https://github.com/pytest-dev/pytest/workflows/test/badge.svg
+    :target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Atest
 
-.. image:: https://github.com/pytest-dev/pytest/workflows/main/badge.svg
-    :target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Amain
+.. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
+   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
+   :alt: pre-commit.ci status
 
 .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
     :target: https://github.com/psf/black
     :target: https://pytest.readthedocs.io/en/latest/?badge=latest
     :alt: Documentation Status
 
+.. image:: https://img.shields.io/badge/Discord-pytest--dev-blue
+    :target: https://discord.com/invite/pytest-dev
+    :alt: Discord
+
+.. image:: https://img.shields.io/badge/Libera%20chat-%23pytest-orange
+    :target: https://web.libera.chat/#pytest
+    :alt: Libera chat
+
+
 The ``pytest`` framework makes it easy to write small tests, yet
 scales to support complex functional testing for applications and libraries.
 
@@ -77,21 +88,21 @@ Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` stat
 Features
 --------
 
-- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/assert.html>`_ (no need to remember ``self.assert*`` names)
+- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/how-to/assert.html>`_ (no need to remember ``self.assert*`` names)
 
 - `Auto-discovery
-  <https://docs.pytest.org/en/stable/goodpractices.html#python-test-discovery>`_
+  <https://docs.pytest.org/en/stable/explanation/goodpractices.html#python-test-discovery>`_
   of test modules and functions
 
-- `Modular fixtures <https://docs.pytest.org/en/stable/fixture.html>`_ for
+- `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
   managing small or parametrized long-lived test resources
 
-- Can run `unittest <https://docs.pytest.org/en/stable/unittest.html>`_ (or trial),
-  `nose <https://docs.pytest.org/en/stable/nose.html>`_ test suites out of the box
+- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
+  `nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
 
-- Python 3.6+ and PyPy3
+- Python 3.7+ or PyPy3
 
-- Rich plugin architecture, with over 850+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community
+- Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
 
 
 Documentation
@@ -149,8 +160,8 @@ Tidelift will coordinate the fix and disclosure.
 License
 -------
 
-Copyright Holger Krekel and others, 2004-2020.
+Copyright Holger Krekel and others, 2004.
 
 Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
 
-.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE
+.. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE
index 9ec2b069c68efcedd4cfb296d10d277291d74d74..08004a84c00a8a5faccf48d2f0a23ad90ec450c0 100644 (file)
@@ -14,59 +14,89 @@ Preparing: Automatic Method
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 We have developed an automated workflow for releases, that uses GitHub workflows and is triggered
-by opening an issue.
+by `manually running <https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow>`__
+the `prepare-release-pr workflow <https://github.com/pytest-dev/pytest/actions/workflows/prepare-release-pr.yml>`__
+on GitHub Actions.
 
-Bug-fix releases
-^^^^^^^^^^^^^^^^
+The automation will decide the new version number based on the following criteria:
 
-A bug-fix release is always done from a maintenance branch, so for example to release bug-fix
-``5.1.2``, open a new issue and add this comment to the body::
+- If the "major release" input is set to "yes", release a new major release
+  (e.g. 7.0.0 -> 8.0.0)
+- If there are any ``.feature.rst`` or ``.breaking.rst`` files in the
+  ``changelog`` directory, release a new minor release (e.g. 7.0.0 -> 7.1.0)
+- Otherwise, release a bugfix release (e.g. 7.0.0 -> 7.0.1)
+- If the "prerelease" input is set, append the string to the version number
+  (e.g. 7.0.0 -> 8.0.0rc1), if "major" is set, and "prerelease" is set to `rc1`)
 
-    @pytestbot please prepare release from 5.1.x
+Bug-fix and minor releases
+^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-Where ``5.1.x`` is the maintenance branch for the ``5.1`` series.
+Bug-fix and minor releases are always done from a maintenance branch. First,
+consider double-checking the ``changelog`` directory to see if there are any
+breaking changes or new features.
 
-The automated workflow will publish a PR for a branch ``release-5.1.2``
-and notify it as a comment in the issue.
+For a new minor release, first create a new maintenance branch from ``main``::
 
-Minor releases
-^^^^^^^^^^^^^^
+     git fetch upstream
+     git branch 7.1.x upstream/main
+     git push upstream 7.1.x
+
+Then, trigger the workflow with the following inputs:
 
-1. Create a new maintenance branch from ``master``::
+- branch: **7.1.x**
+- major release: **no**
+- prerelease: empty
 
-        git fetch --all
-        git branch 5.2.x upstream/master
-        git push upstream 5.2.x
+Or via the commandline using `GitHub's cli <https://github.com/cli/cli>`__::
 
-2. Open a new issue and add this comment to the body::
+    gh workflow run prepare-release-pr.yml -f branch=7.1.x -f major=no -f prerelease=
 
-    @pytestbot please prepare release from 5.2.x
+Where ``7.1.x`` is the maintenance branch for the ``7.1`` series. The automated
+workflow will publish a PR for a branch ``release-7.1.0``.
 
-The automated workflow will publish a PR for a branch ``release-5.2.0`` and
-notify it as a comment in the issue.
+Similarly, for a bug-fix release, use the existing maintenance branch and
+trigger the workflow with e.g. ``branch: 7.0.x`` to get a new ``release-7.0.1``
+PR.
 
-Major and release candidates
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+Major releases
+^^^^^^^^^^^^^^
 
-1. Create a new maintenance branch from ``master``::
+1. Create a new maintenance branch from ``main``::
 
-        git fetch --all
-        git branch 6.0.x upstream/master
-        git push upstream 6.0.x
+        git fetch upstream
+        git branch 8.0.x upstream/main
+        git push upstream 8.0.x
 
-2. For a **major release**, open a new issue and add this comment in the body::
+2. Trigger the workflow with the following inputs:
 
-        @pytestbot please prepare major release from 6.0.x
+   - branch: **8.0.x**
+   - major release: **yes**
+   - prerelease: empty
 
-   For a **release candidate**, the comment must be (TODO: `#7551 <https://github.com/pytest-dev/pytest/issues/7551>`__)::
+Or via the commandline::
 
-        @pytestbot please prepare release candidate from 6.0.x
+    gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=
 
-The automated workflow will publish a PR for a branch ``release-6.0.0`` and
-notify it as a comment in the issue.
+The automated workflow will publish a PR for a branch ``release-8.0.0``.
 
 At this point on, this follows the same workflow as other maintenance branches: bug-fixes are merged
-into ``master`` and ported back to the maintenance branch, even for release candidates.
+into ``main`` and ported back to the maintenance branch, even for release candidates.
+
+Release candidates
+^^^^^^^^^^^^^^^^^^
+
+To release a release candidate, set the "prerelease" input to the version number
+suffix to use. To release a ``8.0.0rc1``, proceed like under "major releases", but set:
+
+- branch: 8.0.x
+- major release: yes
+- prerelease: **rc1**
+
+Or via the commandline::
+
+    gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=rc1
+
+The automated workflow will publish a PR for a branch ``release-8.0.0rc1``.
 
 **A note about release candidates**
 
@@ -83,7 +113,7 @@ to be executed on that platform.
 To release a version ``MAJOR.MINOR.PATCH``, follow these steps:
 
 #. For major and minor releases, create a new branch ``MAJOR.MINOR.x`` from
-   ``upstream/master`` and push it to ``upstream``.
+   ``upstream/main`` and push it to ``upstream``.
 
 #. Create a branch ``release-MAJOR.MINOR.PATCH`` from the ``MAJOR.MINOR.x`` branch.
 
@@ -103,32 +133,32 @@ Releasing
 
 Both automatic and manual processes described above follow the same steps from this point onward.
 
-#. After all tests pass and the PR has been approved, tag the release commit
-   in the ``release-MAJOR.MINOR.PATCH`` branch and push it. This will publish to PyPI::
+#. After all tests pass and the PR has been approved, trigger the ``deploy`` job
+   in https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml, using the ``release-MAJOR.MINOR.PATCH`` branch
+   as source.
 
-     git fetch --all
-     git tag MAJOR.MINOR.PATCH upstream/release-MAJOR.MINOR.PATCH
-     git push git@github.com:pytest-dev/pytest.git MAJOR.MINOR.PATCH
+   This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI
+   and tag the repository.
 
-   Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
+#. Merge the PR. **Make sure it's not squash-merged**, so that the tagged commit ends up in the main branch.
 
-#. Merge the PR.
+#. Cherry-pick the CHANGELOG / announce files to the ``main`` branch::
 
-#. Cherry-pick the CHANGELOG / announce files to the ``master`` branch::
-
-       git fetch --all --prune
-       git checkout origin/master -b cherry-pick-release
+       git fetch upstream
+       git checkout upstream/main -b cherry-pick-release
        git cherry-pick -x -m1 upstream/MAJOR.MINOR.x
 
 #. Open a PR for ``cherry-pick-release`` and merge it once CI passes. No need to wait for approvals if there were no conflicts on the previous step.
 
-#. For major and minor releases, tag the release cherry-pick merge commit in master with
+#. For major and minor releases (or the first prerelease of it), tag the release cherry-pick merge commit in main with
    a dev tag for the next feature release::
 
-       git checkout master
+       git checkout main
        git pull
        git tag MAJOR.{MINOR+1}.0.dev0
-       git push git@github.com:pytest-dev/pytest.git MAJOR.{MINOR+1}.0.dev0
+       git push upstream MAJOR.{MINOR+1}.0.dev0
+
+#. For major and minor releases, change the default version in the `Read the Docs Settings <https://readthedocs.org/dashboard/pytest/advanced/>`_ to the new branch.
 
 #. Send an email announcement with the contents from::
 
index b18f4793f8154f2aee621b6adeff5a83b13023fa..2fe25841c3a44a62c2a7ce835d5ebfbeaf3074b2 100644 (file)
@@ -25,6 +25,7 @@ The current list of contributors receiving funding are:
 
 * `@asottile`_
 * `@nicoddemus`_
+* `@The-Compiler`_
 
 Contributors interested in receiving a part of the funds just need to submit a PR adding their
 name to the list. Contributors that want to stop receiving the funds should also submit a PR
@@ -56,3 +57,4 @@ funds. Just drop a line to one of the `@pytest-dev/tidelift-admins`_ or use the
 
 .. _`@asottile`: https://github.com/asottile
 .. _`@nicoddemus`: https://github.com/nicoddemus
+.. _`@The-Compiler`: https://github.com/The-Compiler
index 1cffbd463d89ad9b6ea2a9ffb7a860000b7a5f9b..f2db6891211d697544a1145ea4a100514983678a 100644 (file)
@@ -34,6 +34,10 @@ REGENDOC_ARGS := \
 
 regen: REGENDOC_FILES:=*.rst */*.rst
 regen:
-       PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="-pno:hypothesis -Wignore::pytest.PytestUnknownMarkWarning" COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
+# need to reset cachedir to the non-tox default
+       PYTHONDONTWRITEBYTECODE=1 \
+       PYTEST_ADDOPTS="-pno:hypothesis -p no:hypothesispytest -Wignore::pytest.PytestUnknownMarkWarning -o cache_dir=.pytest_cache" \
+       COLUMNS=76 \
+       regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
 
 .PHONY: regen
index 4522eb2dec9b8e9aa992316523958d1a09c2bd02..09d970b64ed1fab682184957ed7edf9073ec43e3 100644 (file)
@@ -1,16 +1,22 @@
-<h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
+<h3>Contents</h3>
 
 <ul>
   <li><a href="{{ pathto('index') }}">Home</a></li>
-  <li><a href="{{ pathto('getting-started') }}">Install</a></li>
-  <li><a href="{{ pathto('contents') }}">Contents</a></li>
-  <li><a href="{{ pathto('reference') }}">API Reference</a></li>
-  <li><a href="{{ pathto('example/index') }}">Examples</a></li>
-  <li><a href="{{ pathto('customize') }}">Customize</a></li>
+
+  <li><a href="{{ pathto('getting-started') }}">Get started</a></li>
+  <li><a href="{{ pathto('how-to/index') }}">How-to guides</a></li>
+  <li><a href="{{ pathto('reference/index') }}">Reference guides</a></li>
+  <li><a href="{{ pathto('explanation/index') }}">Explanation</a></li>
+  <li><a href="{{ pathto('contents') }}">Complete table of contents</a></li>
+  <li><a href="{{ pathto('example/index') }}">Library of examples</a></li>
+</ul>
+
+<h3>About the project</h3>
+
+<ul>
   <li><a href="{{ pathto('changelog') }}">Changelog</a></li>
   <li><a href="{{ pathto('contributing') }}">Contributing</a></li>
   <li><a href="{{ pathto('backwards-compatibility') }}">Backwards Compatibility</a></li>
-  <li><a href="{{ pathto('py27-py34-deprecation') }}">Python 2.7 and 3.4 Support</a></li>
   <li><a href="{{ pathto('sponsor') }}">Sponsor</a></li>
   <li><a href="{{ pathto('tidelift') }}">pytest for Enterprise</a></li>
   <li><a href="{{ pathto('license') }}">License</a></li>
@@ -23,5 +29,3 @@
 {%- endif %}
 
 <hr>
-<a href="{{ pathto('genindex') }}">Index</a>
-<hr>
index 6f27757a3483877afadc13f3704ab7a80ec5d713..c253ecabfd2a2e0cf0feb970cbc0900922c3ee8b 100644 (file)
@@ -2,7 +2,6 @@
 <ul>
   <li><a href="https://pypi.org/project/pytest/">pytest @ PyPI</a></li>
   <li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li>
-  <li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li>
   <li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li>
   <li><a href="https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf">PDF Documentation</a>
 </ul>
index 82e2111ed3b3a7a00698edbef4132efdfc1e1cf8..13d82bf011673d9f3e3028c91c48d906842c982f 100644 (file)
@@ -10,10 +10,9 @@ Are you an enthusiastic pytest user, the local testing guru in your workplace? O
 
 We will pair experienced pytest users with open source projects, for a month's effort of getting new development teams started with pytest.
 
-In 2015 we are trying this for the first time. In February and March 2015 we will gather volunteers on both sides, in April we will do the work, and in May we will evaluate how it went. This effort is being coordinated by Brianna Laugher. If you have any questions or comments, you can raise them on the `@pytestdotorg twitter account <https://twitter.com/pytestdotorg>`_ the `issue tracker`_ or the `pytest-dev mailing list`_.
+In 2015 we are trying this for the first time. In February and March 2015 we will gather volunteers on both sides, in April we will do the work, and in May we will evaluate how it went. This effort is being coordinated by Brianna Laugher. If you have any questions or comments, you can raise them on the `@pytestdotorg twitter account <https://twitter.com/pytestdotorg>`_\, the :issue:`issue tracker <676>` or the `pytest-dev mailing list`_.
 
 
-.. _`issue tracker`: https://github.com/pytest-dev/pytest/issues/676
 .. _`pytest-dev mailing list`: https://mail.python.org/mailman/listinfo/pytest-dev
 
 
index a7656c5ee267c8b9a00caa7376b75006c5f4ac08..854666f6725efbba0f58ca46b2a601e3581a97d7 100644 (file)
@@ -6,6 +6,26 @@ Release announcements
    :maxdepth: 2
 
 
+   release-7.4.3
+   release-7.4.2
+   release-7.4.1
+   release-7.4.0
+   release-7.3.2
+   release-7.3.1
+   release-7.3.0
+   release-7.2.2
+   release-7.2.1
+   release-7.2.0
+   release-7.1.3
+   release-7.1.2
+   release-7.1.1
+   release-7.1.0
+   release-7.0.1
+   release-7.0.0
+   release-7.0.0rc1
+   release-6.2.5
+   release-6.2.4
+   release-6.2.3
    release-6.2.2
    release-6.2.1
    release-6.2.0
index 1aaad740a4fc17154b396ee8f851fbc8824c26e4..ecb1a1db9889312788c64801cabc43b06f92c881 100644 (file)
@@ -36,12 +36,12 @@ New Features
 
     import pytest ; pytest.main(arglist, pluginlist)
 
-  see http://pytest.org/en/stable/usage.html for details.
+  see http://pytest.org/en/stable/how-to/usage.html for details.
 
 - new and better reporting information in assert expressions
   if comparing lists, sequences or strings.
 
-  see http://pytest.org/en/stable/assert.html#newreport
+  see http://pytest.org/en/stable/how-to/assert.html#newreport
 
 - new configuration through ini-files (setup.cfg or tox.ini recognized),
   for example::
@@ -50,7 +50,7 @@ New Features
     norecursedirs = .hg data*  # don't ever recurse in such dirs
     addopts = -x --pyargs      # add these command line options by default
 
-  see http://pytest.org/en/stable/customize.html
+  see http://pytest.org/en/stable/reference/customize.html
 
 - improved standard unittest support.  In general py.test should now
   better be able to run custom unittest.TestCases like twisted trial
index 72401d8098f3ceef6c45de9b15107e056b9a4faf..4ff3e9f550af10e68ac779252bb8df6c6e118e3a 100644 (file)
@@ -57,7 +57,7 @@ Changes between 2.0.0 and 2.0.1
 - refinements to "collecting" output on non-ttys
 - refine internal plugin registration and --traceconfig output
 - introduce a mechanism to prevent/unregister plugins from the
-  command line, see http://pytest.org/en/stable/plugins.html#cmdunregister
+  command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister
 - activate resultlog plugin by default
 - fix regression wrt yielded tests which due to the
   collection-before-running semantics were not
index 29463ab533e40f4256a6fbf17585b0dd3a3aaa94..78247247e2f79d716c36230136f0720f19d82f03 100644 (file)
@@ -12,7 +12,7 @@ courtesy of Benjamin Peterson.  You can now safely use ``assert``
 statements in test modules without having to worry about side effects
 or python optimization ("-OO") options.  This is achieved by rewriting
 assert statements in test modules upon import, using a PEP302 hook.
-See https://docs.pytest.org/en/stable/assert.html for
+See https://docs.pytest.org/en/stable/how-to/assert.html for
 detailed information.  The work has been partly sponsored by my company,
 merlinux GmbH.
 
@@ -24,7 +24,7 @@ If you want to install or upgrade pytest, just type one of::
     easy_install -U pytest
 
 best,
-holger krekel / http://merlinux.eu
+holger krekel / https://merlinux.eu/
 
 Changes between 2.0.3 and 2.1.0
 ----------------------------------------------
index c2285eba9fa2af7f7c9c55421e34e24d23209815..369428ed2ea7a18f3b6ec3b38d89bad0adf299c7 100644 (file)
@@ -20,7 +20,7 @@ If you want to install or upgrade pytest, just type one of::
     easy_install -U pytest
 
 best,
-holger krekel / http://merlinux.eu
+holger krekel / https://merlinux.eu/
 
 Changes between 2.1.0 and 2.1.1
 ----------------------------------------------
index 1975f368a3fcef5765a57777edb89772866136cc..a3c0c1a38a40b992146c68752b7e05635b76f293 100644 (file)
@@ -19,7 +19,7 @@ If you want to install or upgrade pytest, just type one of::
     easy_install -U pytest
 
 best,
-holger krekel / http://merlinux.eu
+holger krekel / https://merlinux.eu/
 
 Changes between 2.1.1 and 2.1.2
 ----------------------------------------
index 0193ffb346533fb8f2a040aab723dda060b787e8..7a32dca173c1a58bda52b357240361546d07743d 100644 (file)
@@ -9,7 +9,7 @@ with these improvements:
 
   - new @pytest.mark.parametrize decorator to run tests with different arguments
   - new metafunc.parametrize() API for parametrizing arguments independently
-  - see examples at http://pytest.org/en/stable/example/parametrize.html
+  - see examples at http://pytest.org/en/stable/example/how-to/parametrize.html
   - NOTE that parametrize() related APIs are still a bit experimental
     and might change in future releases.
 
@@ -78,7 +78,7 @@ Changes between 2.1.3 and 2.2.0
   or through plugin hooks.  Also introduce a "--strict" option which
   will treat unregistered markers as errors
   allowing to avoid typos and maintain a well described set of markers
-  for your test suite.  See examples at http://pytest.org/en/stable/mark.html
+  for your test suite.  See examples at http://pytest.org/en/stable/how-to/mark.html
   and its links.
 - issue50: introduce "-m marker" option to select tests based on markers
   (this is a stricter and more predictable version of "-k" in that "-m"
index bdd92a98fde3439445844f75e38d339b1ca6dec7..6905b77b923b6cc08a48050b89c5bb08300febac 100644 (file)
@@ -13,12 +13,12 @@ re-usable fixture design.
 
 For detailed info and tutorial-style examples, see:
 
-    http://pytest.org/en/stable/fixture.html
+    http://pytest.org/en/stable/explanation/fixtures.html
 
 Moreover, there is now support for using pytest fixtures/funcargs with
 unittest-style suites, see here for examples:
 
-    http://pytest.org/en/stable/unittest.html
+    http://pytest.org/en/stable/how-to/unittest.html
 
 Besides, more unittest-test suites are now expected to "simply work"
 with pytest.
index 26f76630e849f18423e95225f98cc8d2f8a07bbb..43bf03b02befc816d94c7d4b9d332eebf6cf6199 100644 (file)
@@ -16,7 +16,7 @@ comes with the following fixes and features:
 - yielded test functions will now have autouse-fixtures active but
   cannot accept fixtures as funcargs - it's anyway recommended to
   rather use the post-2.0 parametrize features instead of yield, see:
-  http://pytest.org/en/stable/example/parametrize.html
+  http://pytest.org/en/stable/example/how-to/parametrize.html
 - fix autouse-issue where autouse-fixtures would not be discovered
   if defined in an a/conftest.py file and tests in a/tests/test_some.py
 - fix issue226 - LIFO ordering for fixture teardowns
index 68297b26c4e3ac753c8edce4eefa72c8756e6bb7..138cc89576c214eb2f8105e6956824b46428035f 100644 (file)
@@ -23,14 +23,13 @@ a full list of details.  A few feature highlights:
   called if the corresponding setup method succeeded.
 
 - integrate tab-completion on command line options if you
-  have `argcomplete <https://pypi.org/project/argcomplete/>`_
-  configured.
+  have :pypi:`argcomplete` configured.
 
 - allow boolean expression directly with skipif/xfail
   if a "reason" is also specified.
 
 - a new hook ``pytest_load_initial_conftests`` allows plugins like
-  `pytest-django <https://pypi.org/project/pytest-django/>`_ to
+  :pypi:`pytest-django` to
   influence the environment before conftest files import ``django``.
 
 - reporting: color the last line red or green depending if
index bc83fdc122c909b72dc26e45f28c5ac19604b201..c6cdcdd8a830a3d6e9d5f85844d4f8f01019314c 100644 (file)
@@ -11,7 +11,7 @@ clear information about the circumstances and a simple example which
 reproduces the problem.
 
 The issue tracker is of course not empty now.  We have many remaining
-"enhacement" issues which we'll hopefully can tackle in 2014 with your
+"enhancement" issues which we'll hopefully can tackle in 2014 with your
 help.
 
 For those who use older Python versions, please note that pytest is not
index 8c2ee05f9bf30ecb126036234076a055cc1be2eb..3aea08cb225d200fea1651d0a34cb81ea33bda72 100644 (file)
@@ -45,29 +45,29 @@ The py.test Development Team
 **New Features**
 
 * New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
-  Thanks `@MichaelAquilina`_ for the complete PR (`#1040`_).
+  Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
 
 * ``--doctest-glob`` may now be passed multiple times in the command-line.
-  Thanks `@jab`_ and `@nicoddemus`_ for the PR.
+  Thanks :user:`jab` and :user:`nicoddemus` for the PR.
 
 * New ``-rp`` and ``-rP`` reporting options give the summary and full output
-  of passing tests, respectively. Thanks to `@codewarrior0`_ for the PR.
+  of passing tests, respectively. Thanks to :user:`codewarrior0` for the PR.
 
 * ``pytest.mark.xfail`` now has a ``strict`` option which makes ``XPASS``
   tests to fail the test suite, defaulting to ``False``. There's also a
   ``xfail_strict`` ini option that can be used to configure it project-wise.
-  Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_).
+  Thanks :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (:issue:`1355`).
 
 * ``Parser.addini`` now supports options of type ``bool``. Thanks
-  `@nicoddemus`_ for the PR.
+  :user:`nicoddemus` for the PR.
 
 * New ``ALLOW_BYTES`` doctest option strips ``b`` prefixes from byte strings
   in doctest output (similar to ``ALLOW_UNICODE``).
-  Thanks `@jaraco`_ for the request and `@nicoddemus`_ for the PR (`#1287`_).
+  Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:issue:`1287`).
 
 * give a hint on KeyboardInterrupt to use the --fulltrace option to show the errors,
-  this fixes `#1366`_.
-  Thanks to `@hpk42`_ for the report and `@RonnyPfannschmidt`_ for the PR.
+  this fixes :issue:`1366`.
+  Thanks to :user:`hpk42` for the report and :user:`RonnyPfannschmidt` for the PR.
 
 * catch IndexError exceptions when getting exception source location. This fixes
   pytest internal error for dynamically generated code (fixtures and tests)
@@ -91,69 +91,44 @@ The py.test Development Team
   `pylib <https://pylib.readthedocs.io/en/stable/>`_.
 
 * ``pytest_enter_pdb`` now optionally receives the pytest config object.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * Removed code and documentation for Python 2.5 or lower versions,
   including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
-  Thanks `@nicoddemus`_ for the PR (`#1226`_).
+  Thanks :user:`nicoddemus` for the PR (:issue:`1226`).
 
 * Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is
   found in the environment, even when -vv isn't used.
-  Thanks `@The-Compiler`_ for the PR.
+  Thanks :user:`The-Compiler` for the PR.
 
 * ``--lf`` and ``--ff`` now support long names: ``--last-failed`` and
   ``--failed-first`` respectively.
-  Thanks `@MichaelAquilina`_ for the PR.
+  Thanks :user:`MichaelAquilina` for the PR.
 
 * Added expected exceptions to pytest.raises fail message
 
 * Collection only displays progress ("collecting X items") when in a terminal.
   This avoids cluttering the output when using ``--color=yes`` to obtain
-  colors in CI integrations systems (`#1397`_).
+  colors in CI integrations systems (:issue:`1397`).
 
 **Bug Fixes**
 
 * The ``-s`` and ``-c`` options should now work under ``xdist``;
   ``Config.fromdictargs`` now represents its input much more faithfully.
-  Thanks to `@bukzor`_ for the complete PR (`#680`_).
+  Thanks to :user:`bukzor` for the complete PR (:issue:`680`).
 
-* Fix (`#1290`_): support Python 3.5's ``@`` operator in assertion rewriting.
-  Thanks `@Shinkenjoe`_ for report with test case and `@tomviner`_ for the PR.
+* Fix (:issue:`1290`): support Python 3.5's ``@`` operator in assertion rewriting.
+  Thanks :user:`Shinkenjoe` for report with test case and :user:`tomviner` for the PR.
 
-* Fix formatting utf-8 explanation messages (`#1379`_).
-  Thanks `@biern`_ for the PR.
+* Fix formatting utf-8 explanation messages (:issue:`1379`).
+  Thanks :user:`biern` for the PR.
 
 * Fix `traceback style docs`_ to describe all of the available options
   (auto/long/short/line/native/no), with ``auto`` being the default since v2.6.
-  Thanks `@hackebrot`_ for the PR.
+  Thanks :user:`hackebrot` for the PR.
 
-* Fix (`#1422`_): junit record_xml_property doesn't allow multiple records
+* Fix (:issue:`1422`): junit record_xml_property doesn't allow multiple records
   with same name.
 
 
-.. _`traceback style docs`: https://pytest.org/en/stable/usage.html#modifying-python-traceback-printing
-
-.. _#1422: https://github.com/pytest-dev/pytest/issues/1422
-.. _#1379: https://github.com/pytest-dev/pytest/issues/1379
-.. _#1366: https://github.com/pytest-dev/pytest/issues/1366
-.. _#1040: https://github.com/pytest-dev/pytest/pull/1040
-.. _#680: https://github.com/pytest-dev/pytest/issues/680
-.. _#1287: https://github.com/pytest-dev/pytest/pull/1287
-.. _#1226: https://github.com/pytest-dev/pytest/pull/1226
-.. _#1290: https://github.com/pytest-dev/pytest/pull/1290
-.. _#1355: https://github.com/pytest-dev/pytest/pull/1355
-.. _#1397: https://github.com/pytest-dev/pytest/issues/1397
-.. _@biern: https://github.com/biern
-.. _@MichaelAquilina: https://github.com/MichaelAquilina
-.. _@bukzor: https://github.com/bukzor
-.. _@hpk42: https://github.com/hpk42
-.. _@nicoddemus: https://github.com/nicoddemus
-.. _@jab: https://github.com/jab
-.. _@codewarrior0: https://github.com/codewarrior0
-.. _@jaraco: https://github.com/jaraco
-.. _@The-Compiler: https://github.com/The-Compiler
-.. _@Shinkenjoe: https://github.com/Shinkenjoe
-.. _@tomviner: https://github.com/tomviner
-.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
-.. _@rabbbit: https://github.com/rabbbit
-.. _@hackebrot: https://github.com/hackebrot
+.. _`traceback style docs`: https://pytest.org/en/stable/how-to/output.html#modifying-python-traceback-printing
index 47bc2e6d38ba7512ee1a4eb1ff3fa593b98c0524..6a627ad3cd6414a48c50de3a4ad0527ee11f2d51 100644 (file)
@@ -37,31 +37,21 @@ The py.test Development Team
 **Bug Fixes**
 
 * Improve error message when a plugin fails to load.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
-* Fix (`#1178 <https://github.com/pytest-dev/pytest/issues/1178>`_):
+* Fix (:issue:`1178`):
   ``pytest.fail`` with non-ascii characters raises an internal pytest error.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
-* Fix (`#469`_): junit parses report.nodeid incorrectly, when params IDs
-  contain ``::``. Thanks `@tomviner`_ for the PR (`#1431`_).
+* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
+  contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
 
-* Fix (`#578 <https://github.com/pytest-dev/pytest/issues/578>`_): SyntaxErrors
+* Fix (:issue:`578`): SyntaxErrors
   containing non-ascii lines at the point of failure generated an internal
   py.test error.
-  Thanks `@asottile`_ for the report and `@nicoddemus`_ for the PR.
+  Thanks :user:`asottile` for the report and :user:`nicoddemus` for the PR.
 
-* Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize
+* Fix (:issue:`1437`): When passing in a bytestring regex pattern to parameterize
   attempt to decode it as utf-8 ignoring errors.
 
-* Fix (`#649`_): parametrized test nodes cannot be specified to run on the command line.
-
-
-.. _#1437: https://github.com/pytest-dev/pytest/issues/1437
-.. _#469: https://github.com/pytest-dev/pytest/issues/469
-.. _#1431: https://github.com/pytest-dev/pytest/pull/1431
-.. _#649: https://github.com/pytest-dev/pytest/issues/649
-
-.. _@asottile: https://github.com/asottile
-.. _@nicoddemus: https://github.com/nicoddemus
-.. _@tomviner: https://github.com/tomviner
+* Fix (:issue:`649`): parametrized test nodes cannot be specified to run on the command line.
index ffd8dc58ed50a8d748e1ea4353751f53694f7a11..2dc82a1117ba7ff082b1e0a83a4832eb32354680 100644 (file)
@@ -39,40 +39,27 @@ The py.test Development Team
 
 **Bug Fixes**
 
-* fix `#510`_: skip tests where one parameterize dimension was empty
-  thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR
+* fix :issue:`510`: skip tests where one parameterize dimension was empty
+  thanks Alex Stapleton for the Report and :user:`RonnyPfannschmidt` for the PR
 
 * Fix Xfail does not work with condition keyword argument.
-  Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_
-  for PR the (`#1524`_).
+  Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
+  for PR the (:pull:`1524`).
 
 * Fix win32 path issue when putting custom config file with absolute path
   in ``pytest.main("-c your_absolute_path")``.
 
 * Fix maximum recursion depth detection when raised error class is not aware
   of unicode/encoded bytes.
-  Thanks `@prusse-martin`_ for the PR (`#1506`_).
+  Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
 
 * Fix ``pytest.mark.skip`` mark when used in strict mode.
-  Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
+  Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
   showing how to fix the bug.
 
 * Minor improvements and fixes to the documentation.
-  Thanks `@omarkohl`_ for the PR.
+  Thanks :user:`omarkohl` for the PR.
 
 * Fix ``--fixtures`` to show all fixture definitions as opposed to just
   one per fixture name.
-  Thanks to `@hackebrot`_ for the PR.
-
-.. _#510: https://github.com/pytest-dev/pytest/issues/510
-.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
-.. _#1496: https://github.com/pytest-dev/pytest/issues/1496
-.. _#1524: https://github.com/pytest-dev/pytest/pull/1524
-
-.. _@astraw38: https://github.com/astraw38
-.. _@hackebrot: https://github.com/hackebrot
-.. _@omarkohl: https://github.com/omarkohl
-.. _@pquentin: https://github.com/pquentin
-.. _@prusse-martin: https://github.com/prusse-martin
-.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
-.. _@tomviner: https://github.com/tomviner
+  Thanks to :user:`hackebrot` for the PR.
diff --git a/doc/en/announce/release-6.2.3.rst b/doc/en/announce/release-6.2.3.rst
new file mode 100644 (file)
index 0000000..e45aa6a
--- /dev/null
@@ -0,0 +1,19 @@
+pytest-6.2.3
+=======================================
+
+pytest 6.2.3 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Bruno Oliveira
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-6.2.4.rst b/doc/en/announce/release-6.2.4.rst
new file mode 100644 (file)
index 0000000..fa2e3e7
--- /dev/null
@@ -0,0 +1,22 @@
+pytest-6.2.4
+=======================================
+
+pytest 6.2.4 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Christian Maurer
+* Florian Bruhin
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-6.2.5.rst b/doc/en/announce/release-6.2.5.rst
new file mode 100644 (file)
index 0000000..bc6b4cf
--- /dev/null
@@ -0,0 +1,30 @@
+pytest-6.2.5
+=======================================
+
+pytest 6.2.5 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Brylie Christopher Oxley
+* Daniel Asztalos
+* Florian Bruhin
+* Jason Haugen
+* MapleCCC
+* Michał Górny
+* Miro Hrončok
+* Ran Benita
+* Ronny Pfannschmidt
+* Sylvain Bellemare
+* Thomas Güttler
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.0.0.rst b/doc/en/announce/release-7.0.0.rst
new file mode 100644 (file)
index 0000000..3ce4335
--- /dev/null
@@ -0,0 +1,74 @@
+pytest-7.0.0
+=======================================
+
+The pytest team is proud to announce the 7.0.0 release!
+
+This release contains new features, improvements, bug fixes, and breaking changes, so users
+are encouraged to take a look at the CHANGELOG carefully:
+
+    https://docs.pytest.org/en/stable/changelog.html
+
+For complete documentation, please visit:
+
+    https://docs.pytest.org/en/stable/
+
+As usual, you can upgrade from PyPI via:
+
+    pip install -U pytest
+
+Thanks to all of the contributors to this release:
+
+* Adam J. Stewart
+* Alexander King
+* Amin Alaee
+* Andrew Neitsch
+* Anthony Sottile
+* Ben Davies
+* Bernát Gábor
+* Brian Okken
+* Bruno Oliveira
+* Cristian Vera
+* Dan Alvizu
+* David Szotten
+* Eddie
+* Emmanuel Arias
+* Emmanuel Meric de Bellefon
+* Eric Liu
+* Florian Bruhin
+* GergelyKalmar
+* Graeme Smecher
+* Harshna
+* Hugo van Kemenade
+* Jakub Kulík
+* James Myatt
+* Jeff Rasley
+* Kale Kundert
+* Kian Meng, Ang
+* Miro Hrončok
+* Naveen-Pratap
+* Oleg Höfling
+* Olga Matoula
+* Ran Benita
+* Ronny Pfannschmidt
+* Simon K
+* Srip
+* Sören Wegener
+* Taneli Hukkinen
+* Terje Runde
+* Thomas Grainger
+* Thomas Hisch
+* William Jamir Silva
+* Yuval Shimon
+* Zac Hatfield-Dodds
+* andrewdotn
+* denivyruck
+* ericluoliu
+* oleg.hoefling
+* symonk
+* ziebam
+* Éloi Rivard
+* Éric
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.0.0rc1.rst b/doc/en/announce/release-7.0.0rc1.rst
new file mode 100644 (file)
index 0000000..a5bf0ed
--- /dev/null
@@ -0,0 +1,74 @@
+pytest-7.0.0rc1
+=======================================
+
+The pytest team is proud to announce the 7.0.0rc1 prerelease!
+
+This is a prerelease, not intended for production use, but to test the upcoming features and improvements
+in order to catch any major problems before the final version is released to the major public.
+
+We appreciate your help testing this out before the final release, making sure to report any
+regressions to our issue tracker:
+
+https://github.com/pytest-dev/pytest/issues
+
+When doing so, please include the string ``[prerelease]`` in the title.
+
+You can upgrade from PyPI via:
+
+    pip install pytest==7.0.0rc1
+
+Users are encouraged to take a look at the CHANGELOG carefully:
+
+    https://docs.pytest.org/en/7.0.x/changelog.html
+
+Thanks to all the contributors to this release:
+
+* Adam J. Stewart
+* Alexander King
+* Amin Alaee
+* Andrew Neitsch
+* Anthony Sottile
+* Ben Davies
+* Bernát Gábor
+* Brian Okken
+* Bruno Oliveira
+* Cristian Vera
+* David Szotten
+* Eddie
+* Emmanuel Arias
+* Emmanuel Meric de Bellefon
+* Eric Liu
+* Florian Bruhin
+* GergelyKalmar
+* Graeme Smecher
+* Harshna
+* Hugo van Kemenade
+* Jakub Kulík
+* James Myatt
+* Jeff Rasley
+* Kale Kundert
+* Miro Hrončok
+* Naveen-Pratap
+* Oleg Höfling
+* Ran Benita
+* Ronny Pfannschmidt
+* Simon K
+* Srip
+* Sören Wegener
+* Taneli Hukkinen
+* Terje Runde
+* Thomas Grainger
+* Thomas Hisch
+* William Jamir Silva
+* Zac Hatfield-Dodds
+* andrewdotn
+* denivyruck
+* ericluoliu
+* oleg.hoefling
+* symonk
+* ziebam
+* Éloi Rivard
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.0.1.rst b/doc/en/announce/release-7.0.1.rst
new file mode 100644 (file)
index 0000000..5accfba
--- /dev/null
@@ -0,0 +1,20 @@
+pytest-7.0.1
+=======================================
+
+pytest 7.0.1 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.1.0.rst b/doc/en/announce/release-7.1.0.rst
new file mode 100644 (file)
index 0000000..3361e1c
--- /dev/null
@@ -0,0 +1,48 @@
+pytest-7.1.0
+=======================================
+
+The pytest team is proud to announce the 7.1.0 release!
+
+This release contains new features, improvements, and bug fixes,
+the full list of changes is available in the changelog:
+
+    https://docs.pytest.org/en/stable/changelog.html
+
+For complete documentation, please visit:
+
+    https://docs.pytest.org/en/stable/
+
+As usual, you can upgrade from PyPI via:
+
+    pip install -U pytest
+
+Thanks to all of the contributors to this release:
+
+* Akuli
+* Andrew Svetlov
+* Anthony Sottile
+* Brett Holman
+* Bruno Oliveira
+* Chris NeJame
+* Dan Alvizu
+* Elijah DeLee
+* Emmanuel Arias
+* Fabian Egli
+* Florian Bruhin
+* Gabor Szabo
+* Hasan Ramezani
+* Hugo van Kemenade
+* Kian Meng, Ang
+* Kojo Idrissa
+* Masaru Tsuchiyama
+* Olga Matoula
+* P. L. Lim
+* Ran Benita
+* Tobias Deiminger
+* Yuval Shimon
+* eduardo naufel schettino
+* Éric
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.1.1.rst b/doc/en/announce/release-7.1.1.rst
new file mode 100644 (file)
index 0000000..d271c45
--- /dev/null
@@ -0,0 +1,18 @@
+pytest-7.1.1
+=======================================
+
+pytest 7.1.1 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.1.2.rst b/doc/en/announce/release-7.1.2.rst
new file mode 100644 (file)
index 0000000..ba33cdc
--- /dev/null
@@ -0,0 +1,23 @@
+pytest-7.1.2
+=======================================
+
+pytest 7.1.2 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Hugo van Kemenade
+* Kian Eliasi
+* Ran Benita
+* Zac Hatfield-Dodds
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.1.3.rst b/doc/en/announce/release-7.1.3.rst
new file mode 100644 (file)
index 0000000..4cb1b27
--- /dev/null
@@ -0,0 +1,28 @@
+pytest-7.1.3
+=======================================
+
+pytest 7.1.3 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Gergely Kalmár
+* Nipunn Koorapati
+* Pax
+* Sviatoslav Sydorenko
+* Tim Hoffmann
+* Tony Narlock
+* Wolfremium
+* Zach OBrien
+* aizpurua23a
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.2.0.rst b/doc/en/announce/release-7.2.0.rst
new file mode 100644 (file)
index 0000000..eca84ae
--- /dev/null
@@ -0,0 +1,93 @@
+pytest-7.2.0
+=======================================
+
+The pytest team is proud to announce the 7.2.0 release!
+
+This release contains new features, improvements, and bug fixes,
+the full list of changes is available in the changelog:
+
+    https://docs.pytest.org/en/stable/changelog.html
+
+For complete documentation, please visit:
+
+    https://docs.pytest.org/en/stable/
+
+As usual, you can upgrade from PyPI via:
+
+    pip install -U pytest
+
+Thanks to all of the contributors to this release:
+
+* Aaron Berdy
+* Adam Turner
+* Albert Villanova del Moral
+* Alice Purcell
+* Anthony Sottile
+* Anton Yakutovich
+* Babak Keyvani
+* Brandon Chinn
+* Bruno Oliveira
+* Chanvin Xiao
+* Cheuk Ting Ho
+* Chris Wheeler
+* EmptyRabbit
+* Ezio Melotti
+* Florian Best
+* Florian Bruhin
+* Fredrik Berndtsson
+* Gabriel Landau
+* Gergely Kalmár
+* Hugo van Kemenade
+* James Gerity
+* John Litborn
+* Jon Parise
+* Kevin C
+* Kian Eliasi
+* MatthewFlamm
+* Miro Hrončok
+* Nate Meyvis
+* Neil Girdhar
+* Nhieuvu1802
+* Nipunn Koorapati
+* Ofek Lev
+* Paul Müller
+* Paul Reece
+* Pax
+* Pete Baughman
+* Peyman Salehi
+* Philipp A
+* Ran Benita
+* Robert O'Shea
+* Ronny Pfannschmidt
+* Rowin
+* Ruth Comer
+* Samuel Colvin
+* Samuel Gaist
+* Sandro Tosi
+* Shantanu
+* Simon K
+* Stephen Rosen
+* Sviatoslav Sydorenko
+* Tatiana Ovary
+* Thierry Moisan
+* Thomas Grainger
+* Tim Hoffmann
+* Tobias Diez
+* Tony Narlock
+* Vivaan Verma
+* Wolfremium
+* Zac Hatfield-Dodds
+* Zach OBrien
+* aizpurua23a
+* gresm
+* holesch
+* itxasos23
+* johnkangw
+* skhomuti
+* sommersoft
+* wodny
+* zx.qiu
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.2.1.rst b/doc/en/announce/release-7.2.1.rst
new file mode 100644 (file)
index 0000000..80ac7af
--- /dev/null
@@ -0,0 +1,25 @@
+pytest-7.2.1
+=======================================
+
+pytest 7.2.1 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Daniel Valenzuela
+* Kadino
+* Prerak Patel
+* Ronny Pfannschmidt
+* Santiago Castro
+* s-padmanaban
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.2.2.rst b/doc/en/announce/release-7.2.2.rst
new file mode 100644 (file)
index 0000000..b34a6ff
--- /dev/null
@@ -0,0 +1,25 @@
+pytest-7.2.2
+=======================================
+
+pytest 7.2.2 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Bruno Oliveira
+* Garvit Shubham
+* Mahesh Vashishtha
+* Ramsey
+* Ronny Pfannschmidt
+* Teejay
+* q0w
+* vin01
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.3.0.rst b/doc/en/announce/release-7.3.0.rst
new file mode 100644 (file)
index 0000000..33258da
--- /dev/null
@@ -0,0 +1,130 @@
+pytest-7.3.0
+=======================================
+
+The pytest team is proud to announce the 7.3.0 release!
+
+This release contains new features, improvements, and bug fixes,
+the full list of changes is available in the changelog:
+
+    https://docs.pytest.org/en/stable/changelog.html
+
+For complete documentation, please visit:
+
+    https://docs.pytest.org/en/stable/
+
+As usual, you can upgrade from PyPI via:
+
+    pip install -U pytest
+
+Thanks to all of the contributors to this release:
+
+* Aaron Berdy
+* Adam Turner
+* Albert Villanova del Moral
+* Alessio Izzo
+* Alex Hadley
+* Alice Purcell
+* Anthony Sottile
+* Anton Yakutovich
+* Ashish Kurmi
+* Babak Keyvani
+* Billy
+* Brandon Chinn
+* Bruno Oliveira
+* Cal Jacobson
+* Chanvin Xiao
+* Cheuk Ting Ho
+* Chris Wheeler
+* Daniel Garcia Moreno
+* Daniel Scheffler
+* Daniel Valenzuela
+* EmptyRabbit
+* Ezio Melotti
+* Felix Hofstätter
+* Florian Best
+* Florian Bruhin
+* Fredrik Berndtsson
+* Gabriel Landau
+* Garvit Shubham
+* Gergely Kalmár
+* HTRafal
+* Hugo van Kemenade
+* Ilya Konstantinov
+* Itxaso Aizpurua
+* James Gerity
+* Jay
+* John Litborn
+* Jon Parise
+* Jouke Witteveen
+* Kadino
+* Kevin C
+* Kian Eliasi
+* Klaus Rettinghaus
+* Kodi Arfer
+* Mahesh Vashishtha
+* Manuel Jacob
+* Marko Pacak
+* MatthewFlamm
+* Miro Hrončok
+* Nate Meyvis
+* Neil Girdhar
+* Nhieuvu1802
+* Nipunn Koorapati
+* Ofek Lev
+* Paul Kehrer
+* Paul Müller
+* Paul Reece
+* Pax
+* Pete Baughman
+* Peyman Salehi
+* Philipp A
+* Pierre Sassoulas
+* Prerak Patel
+* Ramsey
+* Ran Benita
+* Robert O'Shea
+* Ronny Pfannschmidt
+* Rowin
+* Ruth Comer
+* Samuel Colvin
+* Samuel Gaist
+* Sandro Tosi
+* Santiago Castro
+* Shantanu
+* Simon K
+* Stefanie Molin
+* Stephen Rosen
+* Sviatoslav Sydorenko
+* Tatiana Ovary
+* Teejay
+* Thierry Moisan
+* Thomas Grainger
+* Tim Hoffmann
+* Tobias Diez
+* Tony Narlock
+* Vivaan Verma
+* Wolfremium
+* Yannick PÉROUX
+* Yusuke Kadowaki
+* Zac Hatfield-Dodds
+* Zach OBrien
+* aizpurua23a
+* bitzge
+* bluthej
+* gresm
+* holesch
+* itxasos23
+* johnkangw
+* q0w
+* rdb
+* s-padmanaban
+* skhomuti
+* sommersoft
+* vin01
+* wim glenn
+* wodny
+* zx.qiu
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.3.1.rst b/doc/en/announce/release-7.3.1.rst
new file mode 100644 (file)
index 0000000..e920fa8
--- /dev/null
@@ -0,0 +1,18 @@
+pytest-7.3.1
+=======================================
+
+pytest 7.3.1 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.3.2.rst b/doc/en/announce/release-7.3.2.rst
new file mode 100644 (file)
index 0000000..b3b112f
--- /dev/null
@@ -0,0 +1,21 @@
+pytest-7.3.2
+=======================================
+
+pytest 7.3.2 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Adam J. Stewart
+* Alessio Izzo
+* Bruno Oliveira
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.4.0.rst b/doc/en/announce/release-7.4.0.rst
new file mode 100644 (file)
index 0000000..5a0d182
--- /dev/null
@@ -0,0 +1,49 @@
+pytest-7.4.0
+=======================================
+
+The pytest team is proud to announce the 7.4.0 release!
+
+This release contains new features, improvements, and bug fixes,
+the full list of changes is available in the changelog:
+
+    https://docs.pytest.org/en/stable/changelog.html
+
+For complete documentation, please visit:
+
+    https://docs.pytest.org/en/stable/
+
+As usual, you can upgrade from PyPI via:
+
+    pip install -U pytest
+
+Thanks to all of the contributors to this release:
+
+* Adam J. Stewart
+* Alessio Izzo
+* Alex
+* Alex Lambson
+* Brian Larsen
+* Bruno Oliveira
+* Bryan Ricker
+* Chris Mahoney
+* Facundo Batista
+* Florian Bruhin
+* Jarrett Keifer
+* Kenny Y
+* Miro Hrončok
+* Ran Benita
+* Roberto Aldera
+* Ronny Pfannschmidt
+* Sergey Kim
+* Stefanie Molin
+* Vijay Arora
+* Ville Skyttä
+* Zac Hatfield-Dodds
+* bzoracler
+* leeyueh
+* nondescryptid
+* theirix
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.4.1.rst b/doc/en/announce/release-7.4.1.rst
new file mode 100644 (file)
index 0000000..efadcf9
--- /dev/null
@@ -0,0 +1,20 @@
+pytest-7.4.1
+=======================================
+
+pytest 7.4.1 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Bruno Oliveira
+* Florian Bruhin
+* Ran Benita
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.4.2.rst b/doc/en/announce/release-7.4.2.rst
new file mode 100644 (file)
index 0000000..22191e7
--- /dev/null
@@ -0,0 +1,18 @@
+pytest-7.4.2
+=======================================
+
+pytest 7.4.2 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Bruno Oliveira
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/announce/release-7.4.3.rst b/doc/en/announce/release-7.4.3.rst
new file mode 100644 (file)
index 0000000..0f319c1
--- /dev/null
@@ -0,0 +1,19 @@
+pytest-7.4.3
+=======================================
+
+pytest 7.4.3 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
+
+Thanks to all of the contributors to this release:
+
+* Bruno Oliveira
+* Marc Mueller
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/assert.rst b/doc/en/assert.rst
deleted file mode 100644 (file)
index b83e30e..0000000
+++ /dev/null
@@ -1,342 +0,0 @@
-
-The writing and reporting of assertions in tests
-==================================================
-
-.. _`assertfeedback`:
-.. _`assert with the assert statement`:
-.. _`assert`:
-
-
-Asserting with the ``assert`` statement
----------------------------------------------------------
-
-``pytest`` allows you to use the standard python ``assert`` for verifying
-expectations and values in Python tests.  For example, you can write the
-following:
-
-.. code-block:: python
-
-    # content of test_assert1.py
-    def f():
-        return 3
-
-
-    def test_function():
-        assert f() == 4
-
-to assert that your function returns a certain value. If this assertion fails
-you will see the return value of the function call:
-
-.. code-block:: pytest
-
-    $ pytest test_assert1.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 1 item
-
-    test_assert1.py F                                                    [100%]
-
-    ================================= FAILURES =================================
-    ______________________________ test_function _______________________________
-
-        def test_function():
-    >       assert f() == 4
-    E       assert 3 == 4
-    E        +  where 3 = f()
-
-    test_assert1.py:6: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_assert1.py::test_function - assert 3 == 4
-    ============================ 1 failed in 0.12s =============================
-
-``pytest`` has support for showing the values of the most common subexpressions
-including calls, attributes, comparisons, and binary and unary
-operators. (See :ref:`tbreportdemo`).  This allows you to use the
-idiomatic python constructs without boilerplate code while not losing
-introspection information.
-
-However, if you specify a message with the assertion like this:
-
-.. code-block:: python
-
-    assert a % 2 == 0, "value was odd, should be even"
-
-then no assertion introspection takes places at all and the message
-will be simply shown in the traceback.
-
-See :ref:`assert-details` for more information on assertion introspection.
-
-.. _`assertraises`:
-
-Assertions about expected exceptions
-------------------------------------------
-
-In order to write assertions about raised exceptions, you can use
-:func:`pytest.raises` as a context manager like this:
-
-.. code-block:: python
-
-    import pytest
-
-
-    def test_zero_division():
-        with pytest.raises(ZeroDivisionError):
-            1 / 0
-
-and if you need to have access to the actual exception info you may use:
-
-.. code-block:: python
-
-    def test_recursion_depth():
-        with pytest.raises(RuntimeError) as excinfo:
-
-            def f():
-                f()
-
-            f()
-        assert "maximum recursion" in str(excinfo.value)
-
-``excinfo`` is an ``ExceptionInfo`` instance, which is a wrapper around
-the actual exception raised.  The main attributes of interest are
-``.type``, ``.value`` and ``.traceback``.
-
-You can pass a ``match`` keyword parameter to the context-manager to test
-that a regular expression matches on the string representation of an exception
-(similar to the ``TestCase.assertRaisesRegexp`` method from ``unittest``):
-
-.. code-block:: python
-
-    import pytest
-
-
-    def myfunc():
-        raise ValueError("Exception 123 raised")
-
-
-    def test_match():
-        with pytest.raises(ValueError, match=r".* 123 .*"):
-            myfunc()
-
-The regexp parameter of the ``match`` method is matched with the ``re.search``
-function, so in the above example ``match='123'`` would have worked as
-well.
-
-There's an alternate form of the :func:`pytest.raises` function where you pass
-a function that will be executed with the given ``*args`` and ``**kwargs`` and
-assert that the given exception is raised:
-
-.. code-block:: python
-
-    pytest.raises(ExpectedException, func, *args, **kwargs)
-
-The reporter will provide you with helpful output in case of failures such as *no
-exception* or *wrong exception*.
-
-Note that it is also possible to specify a "raises" argument to
-``pytest.mark.xfail``, which checks that the test is failing in a more
-specific way than just having any exception raised:
-
-.. code-block:: python
-
-    @pytest.mark.xfail(raises=IndexError)
-    def test_f():
-        f()
-
-Using :func:`pytest.raises` is likely to be better for cases where you are
-testing exceptions your own code is deliberately raising, whereas using
-``@pytest.mark.xfail`` with a check function is probably better for something
-like documenting unfixed bugs (where the test describes what "should" happen)
-or bugs in dependencies.
-
-
-.. _`assertwarns`:
-
-Assertions about expected warnings
------------------------------------------
-
-
-
-You can check that code raises a particular warning using
-:ref:`pytest.warns <warns>`.
-
-
-.. _newreport:
-
-Making use of context-sensitive comparisons
--------------------------------------------------
-
-
-
-``pytest`` has rich support for providing context-sensitive information
-when it encounters comparisons.  For example:
-
-.. code-block:: python
-
-    # content of test_assert2.py
-
-
-    def test_set_comparison():
-        set1 = set("1308")
-        set2 = set("8035")
-        assert set1 == set2
-
-if you run this module:
-
-.. code-block:: pytest
-
-    $ pytest test_assert2.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 1 item
-
-    test_assert2.py F                                                    [100%]
-
-    ================================= FAILURES =================================
-    ___________________________ test_set_comparison ____________________________
-
-        def test_set_comparison():
-            set1 = set("1308")
-            set2 = set("8035")
-    >       assert set1 == set2
-    E       AssertionError: assert {'0', '1', '3', '8'} == {'0', '3', '5', '8'}
-    E         Extra items in the left set:
-    E         '1'
-    E         Extra items in the right set:
-    E         '5'
-    E         Use -v to get the full diff
-
-    test_assert2.py:6: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_assert2.py::test_set_comparison - AssertionError: assert {'0'...
-    ============================ 1 failed in 0.12s =============================
-
-Special comparisons are done for a number of cases:
-
-* comparing long strings: a context diff is shown
-* comparing long sequences: first failing indices
-* comparing dicts: different entries
-
-See the :ref:`reporting demo <tbreportdemo>` for many more examples.
-
-Defining your own explanation for failed assertions
----------------------------------------------------
-
-It is possible to add your own detailed explanations by implementing
-the ``pytest_assertrepr_compare`` hook.
-
-.. autofunction:: _pytest.hookspec.pytest_assertrepr_compare
-   :noindex:
-
-As an example consider adding the following hook in a :ref:`conftest.py <conftest.py>`
-file which provides an alternative explanation for ``Foo`` objects:
-
-.. code-block:: python
-
-   # content of conftest.py
-   from test_foocompare import Foo
-
-
-   def pytest_assertrepr_compare(op, left, right):
-       if isinstance(left, Foo) and isinstance(right, Foo) and op == "==":
-           return [
-               "Comparing Foo instances:",
-               "   vals: {} != {}".format(left.val, right.val),
-           ]
-
-now, given this test module:
-
-.. code-block:: python
-
-   # content of test_foocompare.py
-   class Foo:
-       def __init__(self, val):
-           self.val = val
-
-       def __eq__(self, other):
-           return self.val == other.val
-
-
-   def test_compare():
-       f1 = Foo(1)
-       f2 = Foo(2)
-       assert f1 == f2
-
-you can run the test module and get the custom output defined in
-the conftest file:
-
-.. code-block:: pytest
-
-   $ pytest -q test_foocompare.py
-   F                                                                    [100%]
-   ================================= FAILURES =================================
-   _______________________________ test_compare _______________________________
-
-       def test_compare():
-           f1 = Foo(1)
-           f2 = Foo(2)
-   >       assert f1 == f2
-   E       assert Comparing Foo instances:
-   E            vals: 1 != 2
-
-   test_foocompare.py:12: AssertionError
-   ========================= short test summary info ==========================
-   FAILED test_foocompare.py::test_compare - assert Comparing Foo instances:
-   1 failed in 0.12s
-
-.. _assert-details:
-.. _`assert introspection`:
-
-Assertion introspection details
--------------------------------
-
-
-Reporting details about a failing assertion is achieved by rewriting assert
-statements before they are run.  Rewritten assert statements put introspection
-information into the assertion failure message.  ``pytest`` only rewrites test
-modules directly discovered by its test collection process, so **asserts in
-supporting modules which are not themselves test modules will not be rewritten**.
-
-You can manually enable assertion rewriting for an imported module by calling
-`register_assert_rewrite <https://docs.pytest.org/en/stable/writing_plugins.html#assertion-rewriting>`_
-before you import it (a good place to do that is in your root ``conftest.py``).
-
-For further information, Benjamin Peterson wrote up `Behind the scenes of pytest's new assertion rewriting <http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests-new-assertion.html>`_.
-
-Assertion rewriting caches files on disk
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-``pytest`` will write back the rewritten modules to disk for caching. You can disable
-this behavior (for example to avoid leaving stale ``.pyc`` files around in projects that
-move files around a lot) by adding this to the top of your ``conftest.py`` file:
-
-.. code-block:: python
-
-   import sys
-
-   sys.dont_write_bytecode = True
-
-Note that you still get the benefits of assertion introspection, the only change is that
-the ``.pyc`` files won't be cached on disk.
-
-Additionally, rewriting will silently skip caching if it cannot write new ``.pyc`` files,
-i.e. in a read-only filesystem or a zipfile.
-
-
-Disabling assert rewriting
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-``pytest`` rewrites test modules on import by using an import
-hook to write new ``pyc`` files. Most of the time this works transparently.
-However, if you are working with the import machinery yourself, the import hook may
-interfere.
-
-If this is the case you have two options:
-
-* Disable rewriting for a specific module by adding the string
-  ``PYTEST_DONT_REWRITE`` to its docstring.
-
-* Disable rewriting for all modules by using ``--assert=plain``.
index 7b3027e790adbd636acf8c8068817b9a095ee590..ea0c6a71a2845100b6a445439815754d5a323594 100644 (file)
@@ -22,7 +22,9 @@ b) transitional: the old and new API don't conflict
 
    We will only start the removal of deprecated functionality in major releases (e.g. if we deprecate something in 3.0 we will start to remove it in 4.0), and keep it around for at least two minor releases (e.g. if we deprecate something in 3.9 and 4.0 is the next release, we start to remove it in 5.0, not in 4.0).
 
-   When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn them into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
+   A deprecated feature scheduled to be removed in major version X will use the warning class `PytestRemovedInXWarning` (a subclass of :class:`~pytest.PytestDeprecationwarning`).
+
+   When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn `PytestRemovedInXWarning` (e.g. `PytestRemovedIn4Warning`) into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
 
 
 c) true breakage: should only be considered when normal transition is unreasonably unsustainable and would offset important development/features by years.
@@ -30,15 +32,15 @@ c) true breakage: should only be considered when normal transition is unreasonab
 
    Examples for such upcoming changes:
 
-   * removal of ``pytest_runtest_protocol/nextitem`` - `#895`_
+   * removal of ``pytest_runtest_protocol/nextitem`` - :issue:`895`
    * rearranging of the node tree to include ``FunctionDefinition``
-   * rearranging of ``SetupState`` `#895`_
+   * rearranging of ``SetupState`` :issue:`895`
 
    True breakages must be announced first in an issue containing:
 
    * Detailed description of the change
    * Rationale
-   * Expected impact on users and plugin authors (example in `#895`_)
+   * Expected impact on users and plugin authors (example in :issue:`895`)
 
    After there's no hard *-1* on the issue it should be followed up by an initial proof-of-concept Pull Request.
 
@@ -77,4 +79,18 @@ Features currently deprecated and removed in previous releases can be found in :
 We track future deprecation and removal of features using milestones and the `deprecation <https://github.com/pytest-dev/pytest/issues?q=label%3A%22type%3A+deprecation%22>`_ and `removal <https://github.com/pytest-dev/pytest/labels/type%3A%20removal>`_ labels on GitHub.
 
 
-.. _`#895`: https://github.com/pytest-dev/pytest/issues/895
+Python version support
+======================
+
+Released pytest versions support all Python versions that are actively maintained at the time of the release:
+
+==============  ===================
+pytest version  min. Python version
+==============  ===================
+7.1+            3.7+
+6.2 - 7.0       3.6+
+5.0 - 6.1       3.5+
+3.3 - 4.6       2.7, 3.4+
+==============  ===================
+
+`Status of Python Versions <https://devguide.python.org/versions/>`__.
diff --git a/doc/en/bash-completion.rst b/doc/en/bash-completion.rst
deleted file mode 100644 (file)
index eaa0788..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-
-.. _bash_completion:
-
-Setting up bash completion
-==========================
-
-When using bash as your shell, ``pytest`` can use argcomplete
-(https://argcomplete.readthedocs.io/) for auto-completion.
-For this ``argcomplete`` needs to be installed **and** enabled.
-
-Install argcomplete using:
-
-.. code-block:: bash
-
-    sudo pip install 'argcomplete>=0.5.7'
-
-For global activation of all argcomplete enabled python applications run:
-
-.. code-block:: bash
-
-    sudo activate-global-python-argcomplete
-
-For permanent (but not global) ``pytest`` activation, use:
-
-.. code-block:: bash
-
-    register-python-argcomplete pytest >> ~/.bashrc
-
-For one-time activation of argcomplete for ``pytest`` only, use:
-
-.. code-block:: bash
-
-    eval "$(register-python-argcomplete pytest)"
index 5c7c8dfe666d619d4e0a4ddece326b30e09ec48c..405289444a8b31dc522faadb7d5f562f468835e7 100644 (file)
@@ -6,7 +6,7 @@ Pytest API and builtin fixtures
 ================================================
 
 
-Most of the information of this page has been moved over to :ref:`reference`.
+Most of the information of this page has been moved over to :ref:`api-reference`.
 
 For information on plugin hooks and objects, see :ref:`plugins`.
 
@@ -16,8 +16,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
 
 .. code-block:: pytest
 
-    $ pytest -q --fixtures
-    cache
+    $ pytest  --fixtures -v
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
+    collected 0 items
+    cache -- .../_pytest/cacheprovider.py:532
         Return a cache object that can persist state between testing sessions.
 
         cache.get(key, default)
@@ -28,40 +33,95 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
 
         Values can be any object handled by the json stdlib module.
 
-    capsys
-        Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
-
-        The captured output is made available via ``capsys.readouterr()`` method
-        calls, which return a ``(out, err)`` namedtuple.
-        ``out`` and ``err`` will be ``text`` objects.
-
-    capsysbinary
+    capsysbinary -- .../_pytest/capture.py:1001
         Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
 
         The captured output is made available via ``capsysbinary.readouterr()``
         method calls, which return a ``(out, err)`` namedtuple.
         ``out`` and ``err`` will be ``bytes`` objects.
 
-    capfd
+        Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
+
+        Example:
+
+        .. code-block:: python
+
+            def test_output(capsysbinary):
+                print("hello")
+                captured = capsysbinary.readouterr()
+                assert captured.out == b"hello\n"
+
+    capfd -- .../_pytest/capture.py:1029
         Enable text capturing of writes to file descriptors ``1`` and ``2``.
 
         The captured output is made available via ``capfd.readouterr()`` method
         calls, which return a ``(out, err)`` namedtuple.
         ``out`` and ``err`` will be ``text`` objects.
 
-    capfdbinary
+        Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
+
+        Example:
+
+        .. code-block:: python
+
+            def test_system_echo(capfd):
+                os.system('echo "hello"')
+                captured = capfd.readouterr()
+                assert captured.out == "hello\n"
+
+    capfdbinary -- .../_pytest/capture.py:1057
         Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
 
         The captured output is made available via ``capfd.readouterr()`` method
         calls, which return a ``(out, err)`` namedtuple.
         ``out`` and ``err`` will be ``byte`` objects.
 
-    doctest_namespace [session scope]
+        Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
+
+        Example:
+
+        .. code-block:: python
+
+            def test_system_echo(capfdbinary):
+                os.system('echo "hello"')
+                captured = capfdbinary.readouterr()
+                assert captured.out == b"hello\n"
+
+    capsys -- .../_pytest/capture.py:973
+        Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
+
+        The captured output is made available via ``capsys.readouterr()`` method
+        calls, which return a ``(out, err)`` namedtuple.
+        ``out`` and ``err`` will be ``text`` objects.
+
+        Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
+
+        Example:
+
+        .. code-block:: python
+
+            def test_output(capsys):
+                print("hello")
+                captured = capsys.readouterr()
+                assert captured.out == "hello\n"
+
+    doctest_namespace [session scope] -- .../_pytest/doctest.py:757
         Fixture that returns a :py:class:`dict` that will be injected into the
         namespace of doctests.
 
-    pytestconfig [session scope]
-        Session-scoped fixture that returns the :class:`_pytest.config.Config` object.
+        Usually this fixture is used in conjunction with another ``autouse`` fixture:
+
+        .. code-block:: python
+
+            @pytest.fixture(autouse=True)
+            def add_np(doctest_namespace):
+                doctest_namespace["np"] = numpy
+
+        For more details: :ref:`doctest_namespace`.
+
+    pytestconfig [session scope] -- .../_pytest/fixtures.py:1353
+        Session-scoped fixture that returns the session's :class:`pytest.Config`
+        object.
 
         Example::
 
@@ -69,7 +129,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
                 if pytestconfig.getoption("verbose") > 0:
                     ...
 
-    record_property
+    record_property -- .../_pytest/junitxml.py:282
         Add extra properties to the calling test.
 
         User properties become part of the test report and are available to the
@@ -83,13 +143,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
             def test_function(record_property):
                 record_property("example_key", 1)
 
-    record_xml_attribute
+    record_xml_attribute -- .../_pytest/junitxml.py:305
         Add extra xml attributes to the tag for the calling test.
 
         The fixture is callable with ``name, value``. The value is
         automatically XML-encoded.
 
-    record_testsuite_property [session scope]
+    record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
         Record a new ``<property>`` tag as child of the root ``<testsuite>``.
 
         This is suitable to writing global information regarding the entire test
@@ -103,15 +163,40 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
                 record_testsuite_property("ARCH", "PPC")
                 record_testsuite_property("STORAGE_TYPE", "CEPH")
 
-        ``name`` must be a string, ``value`` will be converted to a string and properly xml-escaped.
+        :param name:
+            The property name.
+        :param value:
+            The property value. Will be converted to a string.
 
         .. warning::
 
             Currently this fixture **does not work** with the
-            `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See issue
-            `#7767 <https://github.com/pytest-dev/pytest/issues/7767>`__ for details.
+            `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
+            :issue:`7767` for details.
+
+    tmpdir_factory [session scope] -- .../_pytest/legacypath.py:302
+        Return a :class:`pytest.TempdirFactory` instance for the test session.
+
+    tmpdir -- .../_pytest/legacypath.py:309
+        Return a temporary directory path object which is unique to each test
+        function invocation, created as a sub directory of the base temporary
+        directory.
+
+        By default, a new base temporary directory is created each test session,
+        and old bases are removed after 3 sessions, to aid in debugging. If
+        ``--basetemp`` is used then it is cleared each session. See :ref:`base
+        temporary directory`.
+
+        The returned object is a `legacy_path`_ object.
+
+        .. note::
+            These days, it is preferred to use ``tmp_path``.
+
+            :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.
 
-    caplog
+        .. _legacy_path: https://py.readthedocs.io/en/latest/path.html
+
+    caplog -- .../_pytest/logging.py:570
         Access and control log capturing.
 
         Captured logs are available through the following properties/methods::
@@ -122,65 +207,55 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
         * caplog.record_tuples   -> list of (logger_name, level, message) tuples
         * caplog.clear()         -> clear captured records and formatted log output string
 
-    monkeypatch
+    monkeypatch -- .../_pytest/monkeypatch.py:30
         A convenient fixture for monkey-patching.
 
-        The fixture provides these methods to modify objects, dictionaries or
-        os.environ::
+        The fixture provides these methods to modify objects, dictionaries, or
+        :data:`os.environ`:
 
-            monkeypatch.setattr(obj, name, value, raising=True)
-            monkeypatch.delattr(obj, name, raising=True)
-            monkeypatch.setitem(mapping, name, value)
-            monkeypatch.delitem(obj, name, raising=True)
-            monkeypatch.setenv(name, value, prepend=False)
-            monkeypatch.delenv(name, raising=True)
-            monkeypatch.syspath_prepend(path)
-            monkeypatch.chdir(path)
+        * :meth:`monkeypatch.setattr(obj, name, value, raising=True) <pytest.MonkeyPatch.setattr>`
+        * :meth:`monkeypatch.delattr(obj, name, raising=True) <pytest.MonkeyPatch.delattr>`
+        * :meth:`monkeypatch.setitem(mapping, name, value) <pytest.MonkeyPatch.setitem>`
+        * :meth:`monkeypatch.delitem(obj, name, raising=True) <pytest.MonkeyPatch.delitem>`
+        * :meth:`monkeypatch.setenv(name, value, prepend=None) <pytest.MonkeyPatch.setenv>`
+        * :meth:`monkeypatch.delenv(name, raising=True) <pytest.MonkeyPatch.delenv>`
+        * :meth:`monkeypatch.syspath_prepend(path) <pytest.MonkeyPatch.syspath_prepend>`
+        * :meth:`monkeypatch.chdir(path) <pytest.MonkeyPatch.chdir>`
+        * :meth:`monkeypatch.context() <pytest.MonkeyPatch.context>`
 
         All modifications will be undone after the requesting test function or
-        fixture has finished. The ``raising`` parameter determines if a KeyError
-        or AttributeError will be raised if the set/deletion operation has no target.
+        fixture has finished. The ``raising`` parameter determines if a :class:`KeyError`
+        or :class:`AttributeError` will be raised if the set/deletion operation does not have the
+        specified target.
+
+        To undo modifications done by the fixture in a contained scope,
+        use :meth:`context() <pytest.MonkeyPatch.context>`.
 
-    recwarn
+    recwarn -- .../_pytest/recwarn.py:30
         Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
 
-        See http://docs.python.org/library/warnings.html for information
+        See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
         on warning categories.
 
-    tmpdir_factory [session scope]
-        Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session.
-
-    tmp_path_factory [session scope]
-        Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session.
-
-    tmpdir
-        Return a temporary directory path object which is unique to each test
-        function invocation, created as a sub directory of the base temporary
-        directory.
-
-        By default, a new base temporary directory is created each test session,
-        and old bases are removed after 3 sessions, to aid in debugging. If
-        ``--basetemp`` is used then it is cleared each session. See :ref:`base
-        temporary directory`.
+    tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:245
+        Return a :class:`pytest.TempPathFactory` instance for the test session.
 
-        The returned object is a `py.path.local`_ path object.
-
-        .. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
-
-    tmp_path
+    tmp_path -- .../_pytest/tmpdir.py:260
         Return a temporary directory path object which is unique to each test
         function invocation, created as a sub directory of the base temporary
         directory.
 
         By default, a new base temporary directory is created each test session,
-        and old bases are removed after 3 sessions, to aid in debugging. If
-        ``--basetemp`` is used then it is cleared each session. See :ref:`base
+        and old bases are removed after 3 sessions, to aid in debugging.
+        This behavior can be configured with :confval:`tmp_path_retention_count` and
+        :confval:`tmp_path_retention_policy`.
+        If ``--basetemp`` is used then it is cleared each session. See :ref:`base
         temporary directory`.
 
         The returned object is a :class:`pathlib.Path` object.
 
 
-    no tests ran in 0.12s
+    ========================== no tests ran in 0.12s ===========================
 
 You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like:
 
diff --git a/doc/en/cache.rst b/doc/en/cache.rst
deleted file mode 100644 (file)
index 42ca473..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-.. _`cache_provider`:
-.. _cache:
-
-
-Cache: working with cross-testrun state
-=======================================
-
-
-
-Usage
----------
-
-The plugin provides two command line options to rerun failures from the
-last ``pytest`` invocation:
-
-* ``--lf``, ``--last-failed`` - to only re-run the failures.
-* ``--ff``, ``--failed-first`` - to run the failures first and then the rest of
-  the tests.
-
-For cleanup (usually not needed), a ``--cache-clear`` option allows to remove
-all cross-session cache contents ahead of a test run.
-
-Other plugins may access the `config.cache`_ object to set/get
-**json encodable** values between ``pytest`` invocations.
-
-.. note::
-
-    This plugin is enabled by default, but can be disabled if needed: see
-    :ref:`cmdunregister` (the internal name for this plugin is
-    ``cacheprovider``).
-
-
-Rerunning only failures or failures first
------------------------------------------------
-
-First, let's create 50 test invocation of which only 2 fail:
-
-.. code-block:: python
-
-    # content of test_50.py
-    import pytest
-
-
-    @pytest.mark.parametrize("i", range(50))
-    def test_num(i):
-        if i in (17, 25):
-            pytest.fail("bad luck")
-
-If you run this for the first time you will see two failures:
-
-.. code-block:: pytest
-
-    $ pytest -q
-    .................F.......F........................                   [100%]
-    ================================= FAILURES =================================
-    _______________________________ test_num[17] _______________________________
-
-    i = 17
-
-        @pytest.mark.parametrize("i", range(50))
-        def test_num(i):
-            if i in (17, 25):
-    >           pytest.fail("bad luck")
-    E           Failed: bad luck
-
-    test_50.py:7: Failed
-    _______________________________ test_num[25] _______________________________
-
-    i = 25
-
-        @pytest.mark.parametrize("i", range(50))
-        def test_num(i):
-            if i in (17, 25):
-    >           pytest.fail("bad luck")
-    E           Failed: bad luck
-
-    test_50.py:7: Failed
-    ========================= short test summary info ==========================
-    FAILED test_50.py::test_num[17] - Failed: bad luck
-    FAILED test_50.py::test_num[25] - Failed: bad luck
-    2 failed, 48 passed in 0.12s
-
-If you then run it with ``--lf``:
-
-.. code-block:: pytest
-
-    $ pytest --lf
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 2 items
-    run-last-failure: rerun previous 2 failures
-
-    test_50.py FF                                                        [100%]
-
-    ================================= FAILURES =================================
-    _______________________________ test_num[17] _______________________________
-
-    i = 17
-
-        @pytest.mark.parametrize("i", range(50))
-        def test_num(i):
-            if i in (17, 25):
-    >           pytest.fail("bad luck")
-    E           Failed: bad luck
-
-    test_50.py:7: Failed
-    _______________________________ test_num[25] _______________________________
-
-    i = 25
-
-        @pytest.mark.parametrize("i", range(50))
-        def test_num(i):
-            if i in (17, 25):
-    >           pytest.fail("bad luck")
-    E           Failed: bad luck
-
-    test_50.py:7: Failed
-    ========================= short test summary info ==========================
-    FAILED test_50.py::test_num[17] - Failed: bad luck
-    FAILED test_50.py::test_num[25] - Failed: bad luck
-    ============================ 2 failed in 0.12s =============================
-
-You have run only the two failing tests from the last run, while the 48 passing
-tests have not been run ("deselected").
-
-Now, if you run with the ``--ff`` option, all tests will be run but the first
-previous failures will be executed first (as can be seen from the series
-of ``FF`` and dots):
-
-.. code-block:: pytest
-
-    $ pytest --ff
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 50 items
-    run-last-failure: rerun previous 2 failures first
-
-    test_50.py FF................................................        [100%]
-
-    ================================= FAILURES =================================
-    _______________________________ test_num[17] _______________________________
-
-    i = 17
-
-        @pytest.mark.parametrize("i", range(50))
-        def test_num(i):
-            if i in (17, 25):
-    >           pytest.fail("bad luck")
-    E           Failed: bad luck
-
-    test_50.py:7: Failed
-    _______________________________ test_num[25] _______________________________
-
-    i = 25
-
-        @pytest.mark.parametrize("i", range(50))
-        def test_num(i):
-            if i in (17, 25):
-    >           pytest.fail("bad luck")
-    E           Failed: bad luck
-
-    test_50.py:7: Failed
-    ========================= short test summary info ==========================
-    FAILED test_50.py::test_num[17] - Failed: bad luck
-    FAILED test_50.py::test_num[25] - Failed: bad luck
-    ======================= 2 failed, 48 passed in 0.12s =======================
-
-.. _`config.cache`:
-
-New ``--nf``, ``--new-first`` options: run new tests first followed by the rest
-of the tests, in both cases tests are also sorted by the file modified time,
-with more recent files coming first.
-
-Behavior when no tests failed in the last run
----------------------------------------------
-
-When no tests failed in the last run, or when no cached ``lastfailed`` data was
-found, ``pytest`` can be configured either to run all of the tests or no tests,
-using the ``--last-failed-no-failures`` option, which takes one of the following values:
-
-.. code-block:: bash
-
-    pytest --last-failed --last-failed-no-failures all    # run all tests (default behavior)
-    pytest --last-failed --last-failed-no-failures none   # run no tests and exit
-
-The new config.cache object
---------------------------------
-
-.. regendoc:wipe
-
-Plugins or conftest.py support code can get a cached value using the
-pytest ``config`` object.  Here is a basic example plugin which
-implements a :ref:`fixture <fixture>` which re-uses previously created state
-across pytest invocations:
-
-.. code-block:: python
-
-    # content of test_caching.py
-    import pytest
-    import time
-
-
-    def expensive_computation():
-        print("running expensive computation...")
-
-
-    @pytest.fixture
-    def mydata(request):
-        val = request.config.cache.get("example/value", None)
-        if val is None:
-            expensive_computation()
-            val = 42
-            request.config.cache.set("example/value", val)
-        return val
-
-
-    def test_function(mydata):
-        assert mydata == 23
-
-If you run this command for the first time, you can see the print statement:
-
-.. code-block:: pytest
-
-    $ pytest -q
-    F                                                                    [100%]
-    ================================= FAILURES =================================
-    ______________________________ test_function _______________________________
-
-    mydata = 42
-
-        def test_function(mydata):
-    >       assert mydata == 23
-    E       assert 42 == 23
-
-    test_caching.py:20: AssertionError
-    -------------------------- Captured stdout setup ---------------------------
-    running expensive computation...
-    ========================= short test summary info ==========================
-    FAILED test_caching.py::test_function - assert 42 == 23
-    1 failed in 0.12s
-
-If you run it a second time, the value will be retrieved from
-the cache and nothing will be printed:
-
-.. code-block:: pytest
-
-    $ pytest -q
-    F                                                                    [100%]
-    ================================= FAILURES =================================
-    ______________________________ test_function _______________________________
-
-    mydata = 42
-
-        def test_function(mydata):
-    >       assert mydata == 23
-    E       assert 42 == 23
-
-    test_caching.py:20: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_caching.py::test_function - assert 42 == 23
-    1 failed in 0.12s
-
-See the :fixture:`config.cache fixture <cache>` for more details.
-
-
-Inspecting Cache content
-------------------------
-
-You can always peek at the content of the cache using the
-``--cache-show`` command line option:
-
-.. code-block:: pytest
-
-    $ pytest --cache-show
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    --------------------------- cache values for '*' ---------------------------
-    cache/lastfailed contains:
-      {'test_50.py::test_num[17]': True,
-       'test_50.py::test_num[25]': True,
-       'test_assert1.py::test_function': True,
-       'test_assert2.py::test_set_comparison': True,
-       'test_caching.py::test_function': True,
-       'test_foocompare.py::test_compare': True}
-    cache/nodeids contains:
-      ['test_50.py::test_num[0]',
-       'test_50.py::test_num[10]',
-       'test_50.py::test_num[11]',
-       'test_50.py::test_num[12]',
-       'test_50.py::test_num[13]',
-       'test_50.py::test_num[14]',
-       'test_50.py::test_num[15]',
-       'test_50.py::test_num[16]',
-       'test_50.py::test_num[17]',
-       'test_50.py::test_num[18]',
-       'test_50.py::test_num[19]',
-       'test_50.py::test_num[1]',
-       'test_50.py::test_num[20]',
-       'test_50.py::test_num[21]',
-       'test_50.py::test_num[22]',
-       'test_50.py::test_num[23]',
-       'test_50.py::test_num[24]',
-       'test_50.py::test_num[25]',
-       'test_50.py::test_num[26]',
-       'test_50.py::test_num[27]',
-       'test_50.py::test_num[28]',
-       'test_50.py::test_num[29]',
-       'test_50.py::test_num[2]',
-       'test_50.py::test_num[30]',
-       'test_50.py::test_num[31]',
-       'test_50.py::test_num[32]',
-       'test_50.py::test_num[33]',
-       'test_50.py::test_num[34]',
-       'test_50.py::test_num[35]',
-       'test_50.py::test_num[36]',
-       'test_50.py::test_num[37]',
-       'test_50.py::test_num[38]',
-       'test_50.py::test_num[39]',
-       'test_50.py::test_num[3]',
-       'test_50.py::test_num[40]',
-       'test_50.py::test_num[41]',
-       'test_50.py::test_num[42]',
-       'test_50.py::test_num[43]',
-       'test_50.py::test_num[44]',
-       'test_50.py::test_num[45]',
-       'test_50.py::test_num[46]',
-       'test_50.py::test_num[47]',
-       'test_50.py::test_num[48]',
-       'test_50.py::test_num[49]',
-       'test_50.py::test_num[4]',
-       'test_50.py::test_num[5]',
-       'test_50.py::test_num[6]',
-       'test_50.py::test_num[7]',
-       'test_50.py::test_num[8]',
-       'test_50.py::test_num[9]',
-       'test_assert1.py::test_function',
-       'test_assert2.py::test_set_comparison',
-       'test_caching.py::test_function',
-       'test_foocompare.py::test_compare']
-    cache/stepwise contains:
-      []
-    example/value contains:
-      42
-
-    ========================== no tests ran in 0.12s ===========================
-
-``--cache-show`` takes an optional argument to specify a glob pattern for
-filtering:
-
-.. code-block:: pytest
-
-    $ pytest --cache-show example/*
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    ----------------------- cache values for 'example/*' -----------------------
-    example/value contains:
-      42
-
-    ========================== no tests ran in 0.12s ===========================
-
-Clearing Cache content
-----------------------
-
-You can instruct pytest to clear all cache files and values
-by adding the ``--cache-clear`` option like this:
-
-.. code-block:: bash
-
-    pytest --cache-clear
-
-This is recommended for invocations from Continuous Integration
-servers where isolation and correctness is more important
-than speed.
-
-
-Stepwise
---------
-
-As an alternative to ``--lf -x``, especially for cases where you expect a large part of the test suite will fail, ``--sw``, ``--stepwise`` allows you to fix them one at a time. The test suite will run until the first failure and then stop. At the next invocation, tests will continue from the last failing test and then run until the next failing test. You may use the ``--stepwise-skip`` option to ignore one failing test and stop the test execution on the second failing test instead. This is useful if you get stuck on a failing test and just want to ignore it until later.
diff --git a/doc/en/capture.rst b/doc/en/capture.rst
deleted file mode 100644 (file)
index caaebdf..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-
-.. _`captures`:
-
-Capturing of the stdout/stderr output
-=========================================================
-
-Default stdout/stderr/stdin capturing behaviour
----------------------------------------------------------
-
-During test execution any output sent to ``stdout`` and ``stderr`` is
-captured.  If a test or a setup method fails its according captured
-output will usually be shown along with the failure traceback. (this
-behavior can be configured by the ``--show-capture`` command-line option).
-
-In addition, ``stdin`` is set to a "null" object which will
-fail on attempts to read from it because it is rarely desired
-to wait for interactive input when running automated tests.
-
-By default capturing is done by intercepting writes to low level
-file descriptors.  This allows to capture output from simple
-print statements as well as output from a subprocess started by
-a test.
-
-.. _capture-method:
-
-Setting capturing methods or disabling capturing
--------------------------------------------------
-
-There are three ways in which ``pytest`` can perform capturing:
-
-* ``fd`` (file descriptor) level capturing (default): All writes going to the
-  operating system file descriptors 1 and 2 will be captured.
-
-* ``sys`` level capturing: Only writes to Python files ``sys.stdout``
-  and ``sys.stderr`` will be captured.  No capturing of writes to
-  filedescriptors is performed.
-
-* ``tee-sys`` capturing: Python writes to ``sys.stdout`` and ``sys.stderr``
-  will be captured, however the writes will also be passed-through to
-  the actual ``sys.stdout`` and ``sys.stderr``. This allows output to be
-  'live printed' and captured for plugin use, such as junitxml (new in pytest 5.4).
-
-.. _`disable capturing`:
-
-You can influence output capturing mechanisms from the command line:
-
-.. code-block:: bash
-
-    pytest -s                  # disable all capturing
-    pytest --capture=sys       # replace sys.stdout/stderr with in-mem files
-    pytest --capture=fd        # also point filedescriptors 1 and 2 to temp file
-    pytest --capture=tee-sys   # combines 'sys' and '-s', capturing sys.stdout/stderr
-                               # and passing it along to the actual sys.stdout/stderr
-
-.. _printdebugging:
-
-Using print statements for debugging
----------------------------------------------------
-
-One primary benefit of the default capturing of stdout/stderr output
-is that you can use print statements for debugging:
-
-.. code-block:: python
-
-    # content of test_module.py
-
-
-    def setup_function(function):
-        print("setting up", function)
-
-
-    def test_func1():
-        assert True
-
-
-    def test_func2():
-        assert False
-
-and running this module will show you precisely the output
-of the failing function and hide the other one:
-
-.. code-block:: pytest
-
-    $ pytest
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 2 items
-
-    test_module.py .F                                                    [100%]
-
-    ================================= FAILURES =================================
-    ________________________________ test_func2 ________________________________
-
-        def test_func2():
-    >       assert False
-    E       assert False
-
-    test_module.py:12: AssertionError
-    -------------------------- Captured stdout setup ---------------------------
-    setting up <function test_func2 at 0xdeadbeef>
-    ========================= short test summary info ==========================
-    FAILED test_module.py::test_func2 - assert False
-    ======================= 1 failed, 1 passed in 0.12s ========================
-
-Accessing captured output from a test function
----------------------------------------------------
-
-The ``capsys``, ``capsysbinary``, ``capfd``, and ``capfdbinary`` fixtures
-allow access to stdout/stderr output created during test execution.  Here is
-an example test function that performs some output related checks:
-
-.. code-block:: python
-
-    def test_myoutput(capsys):  # or use "capfd" for fd-level
-        print("hello")
-        sys.stderr.write("world\n")
-        captured = capsys.readouterr()
-        assert captured.out == "hello\n"
-        assert captured.err == "world\n"
-        print("next")
-        captured = capsys.readouterr()
-        assert captured.out == "next\n"
-
-The ``readouterr()`` call snapshots the output so far -
-and capturing will be continued.  After the test
-function finishes the original streams will
-be restored.  Using ``capsys`` this way frees your
-test from having to care about setting/resetting
-output streams and also interacts well with pytest's
-own per-test capturing.
-
-If you want to capture on filedescriptor level you can use
-the ``capfd`` fixture which offers the exact
-same interface but allows to also capture output from
-libraries or subprocesses that directly write to operating
-system level output streams (FD1 and FD2).
-
-
-
-The return value from ``readouterr`` changed to a ``namedtuple`` with two attributes, ``out`` and ``err``.
-
-
-
-If the code under test writes non-textual data, you can capture this using
-the ``capsysbinary`` fixture which instead returns ``bytes`` from
-the ``readouterr`` method.
-
-
-
-
-If the code under test writes non-textual data, you can capture this using
-the ``capfdbinary`` fixture which instead returns ``bytes`` from
-the ``readouterr`` method.  The ``capfdbinary`` fixture operates on the
-filedescriptor level.
-
-
-
-
-To temporarily disable capture within a test, both ``capsys``
-and ``capfd`` have a ``disabled()`` method that can be used
-as a context manager, disabling capture inside the ``with`` block:
-
-.. code-block:: python
-
-    def test_disabling_capturing(capsys):
-        print("this output is captured")
-        with capsys.disabled():
-            print("output not captured, going directly to sys.stdout")
-        print("this output is also captured")
index 3e854f59971187b4e85f440a41a9536c759c969d..121d1708da730376c44d002b66bc11de0347aa56 100644 (file)
@@ -28,16 +28,1242 @@ with advance notice in the **Deprecations** section of releases.
 
 .. towncrier release notes start
 
+pytest 7.4.3 (2023-10-24)
+=========================
+
+Bug Fixes
+---------
+
+- `#10447 <https://github.com/pytest-dev/pytest/issues/10447>`_: Markers are now considered in the reverse mro order to ensure base  class markers are considered first -- this resolves a regression.
+
+
+- `#11239 <https://github.com/pytest-dev/pytest/issues/11239>`_: Fixed ``:=`` in asserts impacting unrelated test cases.
+
+
+- `#11439 <https://github.com/pytest-dev/pytest/issues/11439>`_: Handled an edge case where :data:`sys.stderr` might already be closed when :ref:`faulthandler` is tearing down.
+
+
+pytest 7.4.2 (2023-09-07)
+=========================
+
+Bug Fixes
+---------
+
+- `#11237 <https://github.com/pytest-dev/pytest/issues/11237>`_: Fix doctest collection of `functools.cached_property` objects.
+
+
+- `#11306 <https://github.com/pytest-dev/pytest/issues/11306>`_: Fixed bug using ``--importmode=importlib`` which would cause package ``__init__.py`` files to be imported more than once in some cases.
+
+
+- `#11367 <https://github.com/pytest-dev/pytest/issues/11367>`_: Fixed bug where `user_properties` where not being saved in the JUnit XML file if a fixture failed during teardown.
+
+
+- `#11394 <https://github.com/pytest-dev/pytest/issues/11394>`_: Fixed crash when parsing long command line arguments that might be interpreted as files.
+
+
+
+Improved Documentation
+----------------------
+
+- `#11391 <https://github.com/pytest-dev/pytest/issues/11391>`_: Improved disclaimer on pytest plugin reference page to better indicate this is an automated, non-curated listing.
+
+
+pytest 7.4.1 (2023-09-02)
+=========================
+
+Bug Fixes
+---------
+
+- `#10337 <https://github.com/pytest-dev/pytest/issues/10337>`_: Fixed bug where fake intermediate modules generated by ``--import-mode=importlib`` would not include the
+  child modules as attributes of the parent modules.
+
+
+- `#10702 <https://github.com/pytest-dev/pytest/issues/10702>`_: Fixed error assertion handling in :func:`pytest.approx` when ``None`` is an expected or received value when comparing dictionaries.
+
+
+- `#10811 <https://github.com/pytest-dev/pytest/issues/10811>`_: Fixed issue when using ``--import-mode=importlib`` together with ``--doctest-modules`` that caused modules
+  to be imported more than once, causing problems with modules that have import side effects.
+
+
+pytest 7.4.0 (2023-06-23)
+=========================
+
+Features
+--------
+
+- `#10901 <https://github.com/pytest-dev/pytest/issues/10901>`_: Added :func:`ExceptionInfo.from_exception() <pytest.ExceptionInfo.from_exception>`, a simpler way to create an :class:`~pytest.ExceptionInfo` from an exception.
+  This can replace :func:`ExceptionInfo.from_exc_info() <pytest.ExceptionInfo.from_exc_info()>` for most uses.
+
+
+
+Improvements
+------------
+
+- `#10872 <https://github.com/pytest-dev/pytest/issues/10872>`_: Update test log report annotation to named tuple and fixed inconsistency in docs for :hook:`pytest_report_teststatus` hook.
+
+
+- `#10907 <https://github.com/pytest-dev/pytest/issues/10907>`_: When an exception traceback to be displayed is completely filtered out (by mechanisms such as ``__tracebackhide__``, internal frames, and similar), now only the exception string and the following message are shown:
+
+  "All traceback entries are hidden. Pass `--full-trace` to see hidden and internal frames.".
+
+  Previously, the last frame of the traceback was shown, even though it was hidden.
+
+
+- `#10940 <https://github.com/pytest-dev/pytest/issues/10940>`_: Improved verbose output (``-vv``) of ``skip`` and ``xfail`` reasons by performing text wrapping while leaving a clear margin for progress output.
+
+  Added ``TerminalReporter.wrap_write()`` as a helper for that.
+
+
+- `#10991 <https://github.com/pytest-dev/pytest/issues/10991>`_: Added handling of ``%f`` directive to print microseconds in log format options, such as ``log-date-format``.
+
+
+- `#11005 <https://github.com/pytest-dev/pytest/issues/11005>`_: Added the underlying exception to the cache provider's path creation and write warning messages.
+
+
+- `#11013 <https://github.com/pytest-dev/pytest/issues/11013>`_: Added warning when :confval:`testpaths` is set, but paths are not found by glob. In this case, pytest will fall back to searching from the current directory.
+
+
+- `#11043 <https://github.com/pytest-dev/pytest/issues/11043>`_: When `--confcutdir` is not specified, and there is no config file present, the conftest cutoff directory (`--confcutdir`) is now set to the :ref:`rootdir <rootdir>`.
+  Previously in such cases, `conftest.py` files would be probed all the way to the root directory of the filesystem.
+  If you are badly affected by this change, consider adding an empty config file to your desired cutoff directory, or explicitly set `--confcutdir`.
+
+
+- `#11081 <https://github.com/pytest-dev/pytest/issues/11081>`_: The :confval:`norecursedirs` check is now performed in a :hook:`pytest_ignore_collect` implementation, so plugins can affect it.
+
+  If after updating to this version you see that your `norecursedirs` setting is not being respected,
+  it means that a conftest or a plugin you use has a bad `pytest_ignore_collect` implementation.
+  Most likely, your hook returns `False` for paths it does not want to ignore,
+  which ends the processing and doesn't allow other plugins, including pytest itself, to ignore the path.
+  The fix is to return `None` instead of `False` for paths your hook doesn't want to ignore.
+
+
+- `#8711 <https://github.com/pytest-dev/pytest/issues/8711>`_: :func:`caplog.set_level() <pytest.LogCaptureFixture.set_level>` and :func:`caplog.at_level() <pytest.LogCaptureFixture.at_level>`
+  will temporarily enable the requested ``level`` if ``level`` was disabled globally via
+  ``logging.disable(LEVEL)``.
+
+
+
+Bug Fixes
+---------
+
+- `#10831 <https://github.com/pytest-dev/pytest/issues/10831>`_: Terminal Reporting: Fixed bug when running in ``--tb=line`` mode where ``pytest.fail(pytrace=False)`` tests report ``None``.
+
+
+- `#11068 <https://github.com/pytest-dev/pytest/issues/11068>`_: Fixed the ``--last-failed`` whole-file skipping functionality ("skipped N files") for :ref:`non-python test files <non-python tests>`.
+
+
+- `#11104 <https://github.com/pytest-dev/pytest/issues/11104>`_: Fixed a regression in pytest 7.3.2 which caused to :confval:`testpaths` to be considered for loading initial conftests,
+  even when it was not utilized (e.g. when explicit paths were given on the command line).
+  Now the ``testpaths`` are only considered when they are in use.
+
+
+- `#1904 <https://github.com/pytest-dev/pytest/issues/1904>`_: Fixed traceback entries hidden with ``__tracebackhide__ = True`` still being shown for chained exceptions (parts after "... the above exception ..." message).
+
+
+- `#7781 <https://github.com/pytest-dev/pytest/issues/7781>`_: Fix writing non-encodable text to log file when using ``--debug``.
+
+
+
+Improved Documentation
+----------------------
+
+- `#9146 <https://github.com/pytest-dev/pytest/issues/9146>`_: Improved documentation for :func:`caplog.set_level() <pytest.LogCaptureFixture.set_level>`.
+
+
+
+Trivial/Internal Changes
+------------------------
+
+- `#11031 <https://github.com/pytest-dev/pytest/issues/11031>`_: Enhanced the CLI flag for ``-c`` to now include ``--config-file`` to make it clear that this flag applies to the usage of a custom config file.
+
+
+pytest 7.3.2 (2023-06-10)
+=========================
+
+Bug Fixes
+---------
+
+- `#10169 <https://github.com/pytest-dev/pytest/issues/10169>`_: Fix bug where very long option names could cause pytest to break with ``OSError: [Errno 36] File name too long`` on some systems.
+
+
+- `#10894 <https://github.com/pytest-dev/pytest/issues/10894>`_: Support for Python 3.12 (beta at the time of writing).
+
+
+- `#10987 <https://github.com/pytest-dev/pytest/issues/10987>`_: :confval:`testpaths` is now honored to load root ``conftests``.
+
+
+- `#10999 <https://github.com/pytest-dev/pytest/issues/10999>`_: The `monkeypatch` `setitem`/`delitem` type annotations now allow `TypedDict` arguments.
+
+
+- `#11028 <https://github.com/pytest-dev/pytest/issues/11028>`_: Fixed bug in assertion rewriting where a variable assigned with the walrus operator could not be used later in a function call.
+
+
+- `#11054 <https://github.com/pytest-dev/pytest/issues/11054>`_: Fixed ``--last-failed``'s "(skipped N files)" functionality for files inside of packages (directories with `__init__.py` files).
+
+
+pytest 7.3.1 (2023-04-14)
+=========================
+
+Improvements
+------------
+
+- `#10875 <https://github.com/pytest-dev/pytest/issues/10875>`_: Python 3.12 support: fixed ``RuntimeError: TestResult has no addDuration method`` when running ``unittest`` tests.
+
+
+- `#10890 <https://github.com/pytest-dev/pytest/issues/10890>`_: Python 3.12 support: fixed ``shutil.rmtree(onerror=...)`` deprecation warning when using :fixture:`tmp_path`.
+
+
+
+Bug Fixes
+---------
+
+- `#10896 <https://github.com/pytest-dev/pytest/issues/10896>`_: Fixed performance regression related to :fixture:`tmp_path` and the new :confval:`tmp_path_retention_policy` option.
+
+
+- `#10903 <https://github.com/pytest-dev/pytest/issues/10903>`_: Fix crash ``INTERNALERROR IndexError: list index out of range`` which happens when displaying an exception where all entries are hidden.
+  This reverts the change "Correctly handle ``__tracebackhide__`` for chained exceptions." introduced in version 7.3.0.
+
+
+pytest 7.3.0 (2023-04-08)
+=========================
+
+Features
+--------
+
+- `#10525 <https://github.com/pytest-dev/pytest/issues/10525>`_: Test methods decorated with ``@classmethod`` can now be discovered as tests, following the same rules as normal methods. This fills the gap that static methods were discoverable as tests but not class methods.
+
+
+- `#10755 <https://github.com/pytest-dev/pytest/issues/10755>`_: :confval:`console_output_style` now supports ``progress-even-when-capture-no`` to force the use of the progress output even when capture is disabled. This is useful in large test suites where capture may have significant performance impact.
+
+
+- `#7431 <https://github.com/pytest-dev/pytest/issues/7431>`_: ``--log-disable`` CLI option added to disable individual loggers.
+
+
+- `#8141 <https://github.com/pytest-dev/pytest/issues/8141>`_: Added :confval:`tmp_path_retention_count` and :confval:`tmp_path_retention_policy` configuration options to control how directories created by the :fixture:`tmp_path` fixture are kept.
+
+
+
+Improvements
+------------
+
+- `#10226 <https://github.com/pytest-dev/pytest/issues/10226>`_: If multiple errors are raised in teardown, we now re-raise an ``ExceptionGroup`` of them instead of discarding all but the last.
+
+
+- `#10658 <https://github.com/pytest-dev/pytest/issues/10658>`_: Allow ``-p`` arguments to include spaces (eg: ``-p no:logging`` instead of
+  ``-pno:logging``). Mostly useful in the ``addopts`` section of the configuration
+  file.
+
+
+- `#10710 <https://github.com/pytest-dev/pytest/issues/10710>`_: Added ``start`` and ``stop`` timestamps to ``TestReport`` objects.
+
+
+- `#10727 <https://github.com/pytest-dev/pytest/issues/10727>`_: Split the report header for ``rootdir``, ``config file`` and ``testpaths`` so each has its own line.
+
+
+- `#10840 <https://github.com/pytest-dev/pytest/issues/10840>`_: pytest should no longer crash on AST with pathological position attributes, for example testing AST produced by `Hylang <https://github.com/hylang/hy>__`.
+
+
+- `#6267 <https://github.com/pytest-dev/pytest/issues/6267>`_: The full output of a test is no longer truncated if the truncation message would be longer than
+  the hidden text. The line number shown has also been fixed.
+
+
+
+Bug Fixes
+---------
+
+- `#10743 <https://github.com/pytest-dev/pytest/issues/10743>`_: The assertion rewriting mechanism now works correctly when assertion expressions contain the walrus operator.
+
+
+- `#10765 <https://github.com/pytest-dev/pytest/issues/10765>`_: Fixed :fixture:`tmp_path` fixture always raising :class:`OSError` on ``emscripten`` platform due to missing :func:`os.getuid`.
+
+
+- `#1904 <https://github.com/pytest-dev/pytest/issues/1904>`_: Correctly handle ``__tracebackhide__`` for chained exceptions.
+  NOTE: This change was reverted in version 7.3.1.
+
+
+
+Improved Documentation
+----------------------
+
+- `#10782 <https://github.com/pytest-dev/pytest/issues/10782>`_: Fixed the minimal example in :ref:`goodpractices`: ``pip install -e .`` requires a ``version`` entry in ``pyproject.toml`` to run successfully.
+
+
+
+Trivial/Internal Changes
+------------------------
+
+- `#10669 <https://github.com/pytest-dev/pytest/issues/10669>`_: pytest no longer directly depends on the `attrs <https://www.attrs.org/en/stable/>`__ package. While
+  we at pytest all love the package dearly and would like to thank the ``attrs`` team for many years of cooperation and support,
+  it makes sense for ``pytest`` to have as little external dependencies as possible, as this helps downstream projects.
+  With that in mind, we have replaced the pytest's limited internal usage to use the standard library's ``dataclasses`` instead.
+
+  Nice diffs for ``attrs`` classes are still supported though.
+
+
+pytest 7.2.2 (2023-03-03)
+=========================
+
+Bug Fixes
+---------
+
+- `#10533 <https://github.com/pytest-dev/pytest/issues/10533>`_: Fixed :func:`pytest.approx` handling of dictionaries containing one or more values of `0.0`.
+
+
+- `#10592 <https://github.com/pytest-dev/pytest/issues/10592>`_: Fixed crash if `--cache-show` and `--help` are passed at the same time.
+
+
+- `#10597 <https://github.com/pytest-dev/pytest/issues/10597>`_: Fixed bug where a fixture method named ``teardown`` would be called as part of ``nose`` teardown stage.
+
+
+- `#10626 <https://github.com/pytest-dev/pytest/issues/10626>`_: Fixed crash if ``--fixtures`` and ``--help`` are passed at the same time.
+
+
+- `#10660 <https://github.com/pytest-dev/pytest/issues/10660>`_: Fixed :py:func:`pytest.raises` to return a 'ContextManager' so that type-checkers could narrow
+  :code:`pytest.raises(...) if ... else nullcontext()` down to 'ContextManager' rather than 'object'.
+
+
+
+Improved Documentation
+----------------------
+
+- `#10690 <https://github.com/pytest-dev/pytest/issues/10690>`_: Added `CI` and `BUILD_NUMBER` environment variables to the documentation.
+
+
+- `#10721 <https://github.com/pytest-dev/pytest/issues/10721>`_: Fixed entry-points declaration in the documentation example using Hatch.
+
+
+- `#10753 <https://github.com/pytest-dev/pytest/issues/10753>`_: Changed wording of the module level skip to be very explicit
+  about not collecting tests and not executing the rest of the module.
+
+
+pytest 7.2.1 (2023-01-13)
+=========================
+
+Bug Fixes
+---------
+
+- `#10452 <https://github.com/pytest-dev/pytest/issues/10452>`_: Fix 'importlib.abc.TraversableResources' deprecation warning in Python 3.12.
+
+
+- `#10457 <https://github.com/pytest-dev/pytest/issues/10457>`_: If a test is skipped from inside a fixture, the test summary now shows the test location instead of the fixture location.
+
+
+- `#10506 <https://github.com/pytest-dev/pytest/issues/10506>`_: Fix bug where sometimes pytest would use the file system root directory as :ref:`rootdir <rootdir>` on Windows.
+
+
+- `#10607 <https://github.com/pytest-dev/pytest/issues/10607>`_: Fix a race condition when creating junitxml reports, which could occur when multiple instances of pytest execute in parallel.
+
+
+- `#10641 <https://github.com/pytest-dev/pytest/issues/10641>`_: Fix a race condition when creating or updating the stepwise plugin's cache, which could occur when multiple xdist worker nodes try to simultaneously update the stepwise plugin's cache.
+
+
+pytest 7.2.0 (2022-10-23)
+=========================
+
+Deprecations
+------------
+
+- `#10012 <https://github.com/pytest-dev/pytest/issues/10012>`_: Update :class:`pytest.PytestUnhandledCoroutineWarning` to a deprecation; it will raise an error in pytest 8.
+
+
+- `#10396 <https://github.com/pytest-dev/pytest/issues/10396>`_: pytest no longer depends on the ``py`` library.  ``pytest`` provides a vendored copy of ``py.error`` and ``py.path`` modules but will use the ``py`` library if it is installed.  If you need other ``py.*`` modules, continue to install the deprecated ``py`` library separately, otherwise it can usually be removed as a dependency.
+
+
+- `#4562 <https://github.com/pytest-dev/pytest/issues/4562>`_: Deprecate configuring hook specs/impls using attributes/marks.
+
+  Instead use :py:func:`pytest.hookimpl` and :py:func:`pytest.hookspec`.
+  For more details, see the :ref:`docs <legacy-path-hooks-deprecated>`.
+
+
+- `#9886 <https://github.com/pytest-dev/pytest/issues/9886>`_: The functionality for running tests written for ``nose`` has been officially deprecated.
+
+  This includes:
+
+  * Plain ``setup`` and ``teardown`` functions and methods: this might catch users by surprise, as ``setup()`` and ``teardown()`` are not pytest idioms, but part of the ``nose`` support.
+  * Setup/teardown using the `@with_setup <with-setup-nose>`_ decorator.
+
+  For more details, consult the :ref:`deprecation docs <nose-deprecation>`.
+
+  .. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
+
+- `#7337 <https://github.com/pytest-dev/pytest/issues/7337>`_: A deprecation warning is now emitted if a test function returns something other than `None`. This prevents a common mistake among beginners that expect that returning a `bool` (for example `return foo(a, b) == result`) would cause a test to pass or fail, instead of using `assert`. The plan is to make returning non-`None` from tests an error in the future.
+
+
+Features
+--------
+
+- `#9897 <https://github.com/pytest-dev/pytest/issues/9897>`_: Added shell-style wildcard support to ``testpaths``.
+
+
+
+Improvements
+------------
+
+- `#10218 <https://github.com/pytest-dev/pytest/issues/10218>`_: ``@pytest.mark.parametrize()`` (and similar functions) now accepts any ``Sequence[str]`` for the argument names,
+  instead of just ``list[str]`` and ``tuple[str, ...]``.
+
+  (Note that ``str``, which is itself a ``Sequence[str]``, is still treated as a
+  comma-delimited name list, as before).
+
+
+- `#10381 <https://github.com/pytest-dev/pytest/issues/10381>`_: The ``--no-showlocals`` flag has been added. This can be passed directly to tests to override ``--showlocals`` declared through ``addopts``.
+
+
+- `#3426 <https://github.com/pytest-dev/pytest/issues/3426>`_: Assertion failures with strings in NFC and NFD forms that normalize to the same string now have a dedicated error message detailing the issue, and their utf-8 representation is expressed instead.
+
+
+- `#8508 <https://github.com/pytest-dev/pytest/issues/8508>`_: Introduce multiline display for warning matching  via :py:func:`pytest.warns` and
+  enhance match comparison for :py:func:`_pytest._code.ExceptionInfo.match` as returned by :py:func:`pytest.raises`.
+
+
+- `#8646 <https://github.com/pytest-dev/pytest/issues/8646>`_: Improve :py:func:`pytest.raises`. Previously passing an empty tuple would give a confusing
+  error. We now raise immediately with a more helpful message.
+
+
+- `#9741 <https://github.com/pytest-dev/pytest/issues/9741>`_: On Python 3.11, use the standard library's :mod:`tomllib` to parse TOML.
+
+  :mod:`tomli` is no longer a dependency on Python 3.11.
+
+
+- `#9742 <https://github.com/pytest-dev/pytest/issues/9742>`_: Display assertion message without escaped newline characters with ``-vv``.
+
+
+- `#9823 <https://github.com/pytest-dev/pytest/issues/9823>`_: Improved error message that is shown when no collector is found for a given file.
+
+
+- `#9873 <https://github.com/pytest-dev/pytest/issues/9873>`_: Some coloring has been added to the short test summary.
+
+
+- `#9883 <https://github.com/pytest-dev/pytest/issues/9883>`_: Normalize the help description of all command-line options.
+
+
+- `#9920 <https://github.com/pytest-dev/pytest/issues/9920>`_: Display full crash messages in ``short test summary info``, when running in a CI environment.
+
+
+- `#9987 <https://github.com/pytest-dev/pytest/issues/9987>`_: Added support for hidden configuration file by allowing ``.pytest.ini`` as an alternative to ``pytest.ini``.
+
+
+
+Bug Fixes
+---------
+
+- `#10150 <https://github.com/pytest-dev/pytest/issues/10150>`_: :data:`sys.stdin` now contains all expected methods of a file-like object when capture is enabled.
+
+
+- `#10382 <https://github.com/pytest-dev/pytest/issues/10382>`_: Do not break into pdb when ``raise unittest.SkipTest()`` appears top-level in a file.
+
+
+- `#7792 <https://github.com/pytest-dev/pytest/issues/7792>`_: Marks are now inherited according to the full MRO in test classes. Previously, if a test class inherited from two or more classes, only marks from the first super-class would apply.
+
+  When inheriting marks from super-classes, marks from the sub-classes are now ordered before marks from the super-classes, in MRO order. Previously it was the reverse.
+
+  When inheriting marks from super-classes, the `pytestmark` attribute of the sub-class now only contains the marks directly applied to it. Previously, it also contained marks from its super-classes. Please note that this attribute should not normally be accessed directly; use :func:`pytest.Node.iter_markers` instead.
+
+
+- `#9159 <https://github.com/pytest-dev/pytest/issues/9159>`_: Showing inner exceptions by forcing native display in ``ExceptionGroups`` even when using display options other than ``--tb=native``. A temporary step before full implementation of pytest-native display for inner exceptions in ``ExceptionGroups``.
+
+
+- `#9877 <https://github.com/pytest-dev/pytest/issues/9877>`_: Ensure ``caplog.get_records(when)`` returns current/correct data after invoking ``caplog.clear()``.
+
+
+
+Improved Documentation
+----------------------
+
+- `#10344 <https://github.com/pytest-dev/pytest/issues/10344>`_: Update information on writing plugins to use ``pyproject.toml`` instead of ``setup.py``.
+
+
+- `#9248 <https://github.com/pytest-dev/pytest/issues/9248>`_: The documentation is now built using Sphinx 5.x (up from 3.x previously).
+
+
+- `#9291 <https://github.com/pytest-dev/pytest/issues/9291>`_: Update documentation on how :func:`pytest.warns` affects :class:`DeprecationWarning`.
+
+
+
+Trivial/Internal Changes
+------------------------
+
+- `#10313 <https://github.com/pytest-dev/pytest/issues/10313>`_: Made ``_pytest.doctest.DoctestItem`` export ``pytest.DoctestItem`` for
+  type check and runtime purposes. Made `_pytest.doctest` use internal APIs
+  to avoid circular imports.
+
+
+- `#9906 <https://github.com/pytest-dev/pytest/issues/9906>`_: Made ``_pytest.compat`` re-export ``importlib_metadata`` in the eyes of type checkers.
+
+
+- `#9910 <https://github.com/pytest-dev/pytest/issues/9910>`_: Fix default encoding warning (``EncodingWarning``) in ``cacheprovider``
+
+
+- `#9984 <https://github.com/pytest-dev/pytest/issues/9984>`_: Improve the error message when we attempt to access a fixture that has been
+  torn down.
+  Add an additional sentence to the docstring explaining when it's not a good
+  idea to call ``getfixturevalue``.
+
+
+pytest 7.1.3 (2022-08-31)
+=========================
+
+Bug Fixes
+---------
+
+- `#10060 <https://github.com/pytest-dev/pytest/issues/10060>`_: When running with ``--pdb``, ``TestCase.tearDown`` is no longer called for tests when the *class* has been skipped via ``unittest.skip`` or ``pytest.mark.skip``.
+
+
+- `#10190 <https://github.com/pytest-dev/pytest/issues/10190>`_: Invalid XML characters in setup or teardown error messages are now properly escaped for JUnit XML reports.
+
+
+- `#10230 <https://github.com/pytest-dev/pytest/issues/10230>`_: Ignore ``.py`` files created by ``pyproject.toml``-based editable builds introduced in `pip 21.3 <https://pip.pypa.io/en/stable/news/#v21-3>`__.
+
+
+- `#3396 <https://github.com/pytest-dev/pytest/issues/3396>`_: Doctests now respect the ``--import-mode`` flag.
+
+
+- `#9514 <https://github.com/pytest-dev/pytest/issues/9514>`_: Type-annotate ``FixtureRequest.param`` as ``Any`` as a stop gap measure until :issue:`8073` is fixed.
+
+
+- `#9791 <https://github.com/pytest-dev/pytest/issues/9791>`_: Fixed a path handling code in ``rewrite.py`` that seems to work fine, but was incorrect and fails in some systems.
+
+
+- `#9917 <https://github.com/pytest-dev/pytest/issues/9917>`_: Fixed string representation for :func:`pytest.approx` when used to compare tuples.
+
+
+
+Improved Documentation
+----------------------
+
+- `#9937 <https://github.com/pytest-dev/pytest/issues/9937>`_: Explicit note that :fixture:`tmpdir` fixture is discouraged in favour of :fixture:`tmp_path`.
+
+
+
+Trivial/Internal Changes
+------------------------
+
+- `#10114 <https://github.com/pytest-dev/pytest/issues/10114>`_: Replace `atomicwrites <https://github.com/untitaker/python-atomicwrites>`__ dependency on windows with `os.replace`.
+
+
+pytest 7.1.2 (2022-04-23)
+=========================
+
+Bug Fixes
+---------
+
+- `#9726 <https://github.com/pytest-dev/pytest/issues/9726>`_: An unnecessary ``numpy`` import inside :func:`pytest.approx` was removed.
+
+
+- `#9820 <https://github.com/pytest-dev/pytest/issues/9820>`_: Fix comparison of  ``dataclasses`` with ``InitVar``.
+
+
+- `#9869 <https://github.com/pytest-dev/pytest/issues/9869>`_: Increase ``stacklevel`` for the ``NODE_CTOR_FSPATH_ARG`` deprecation to point to the
+  user's code, not pytest.
+
+
+- `#9871 <https://github.com/pytest-dev/pytest/issues/9871>`_: Fix a bizarre (and fortunately rare) bug where the `temp_path` fixture could raise
+  an internal error while attempting to get the current user's username.
+
+
+pytest 7.1.1 (2022-03-17)
+=========================
+
+Bug Fixes
+---------
+
+- `#9767 <https://github.com/pytest-dev/pytest/issues/9767>`_: Fixed a regression in pytest 7.1.0 where some conftest.py files outside of the source tree (e.g. in the `site-packages` directory) were not picked up.
+
+
+pytest 7.1.0 (2022-03-13)
+=========================
+
+Breaking Changes
+----------------
+
+- `#8838 <https://github.com/pytest-dev/pytest/issues/8838>`_: As per our policy, the following features have been deprecated in the 6.X series and are now
+  removed:
+
+  * ``pytest._fillfuncargs`` function.
+
+  * ``pytest_warning_captured`` hook - use ``pytest_warning_recorded`` instead.
+
+  * ``-k -foobar`` syntax - use ``-k 'not foobar'`` instead.
+
+  * ``-k foobar:`` syntax.
+
+  * ``pytest.collect`` module - import from ``pytest`` directly.
+
+  For more information consult
+  `Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ in the docs.
+
+
+- `#9437 <https://github.com/pytest-dev/pytest/issues/9437>`_: Dropped support for Python 3.6, which reached `end-of-life <https://devguide.python.org/#status-of-python-branches>`__ at 2021-12-23.
+
+
+
+Improvements
+------------
+
+- `#5192 <https://github.com/pytest-dev/pytest/issues/5192>`_: Fixed test output for some data types where ``-v`` would show less information.
+
+  Also, when showing diffs for sequences, ``-q`` would produce full diffs instead of the expected diff.
+
+
+- `#9362 <https://github.com/pytest-dev/pytest/issues/9362>`_: pytest now avoids specialized assert formatting when it is detected that the default ``__eq__`` is overridden in ``attrs`` or ``dataclasses``.
+
+
+- `#9536 <https://github.com/pytest-dev/pytest/issues/9536>`_: When ``-vv`` is given on command line, show skipping and xfail reasons in full instead of truncating them to fit the terminal width.
+
+
+- `#9644 <https://github.com/pytest-dev/pytest/issues/9644>`_: More information about the location of resources that led Python to raise :class:`ResourceWarning` can now
+  be obtained by enabling :mod:`tracemalloc`.
+
+  See :ref:`resource-warnings` for more information.
+
+
+- `#9678 <https://github.com/pytest-dev/pytest/issues/9678>`_: More types are now accepted in the ``ids`` argument to ``@pytest.mark.parametrize``.
+  Previously only `str`, `float`, `int` and `bool` were accepted;
+  now `bytes`, `complex`, `re.Pattern`, `Enum` and anything with a `__name__` are also accepted.
+
+
+- `#9692 <https://github.com/pytest-dev/pytest/issues/9692>`_: :func:`pytest.approx` now raises a :class:`TypeError` when given an unordered sequence (such as :class:`set`).
+
+  Note that this implies that custom classes which only implement ``__iter__`` and ``__len__`` are no longer supported as they don't guarantee order.
+
+
+
+Bug Fixes
+---------
+
+- `#8242 <https://github.com/pytest-dev/pytest/issues/8242>`_: The deprecation of raising :class:`unittest.SkipTest` to skip collection of
+  tests during the pytest collection phase is reverted - this is now a supported
+  feature again.
+
+
+- `#9493 <https://github.com/pytest-dev/pytest/issues/9493>`_: Symbolic link components are no longer resolved in conftest paths.
+  This means that if a conftest appears twice in collection tree, using symlinks, it will be executed twice.
+  For example, given
+
+      tests/real/conftest.py
+      tests/real/test_it.py
+      tests/link -> tests/real
+
+  running ``pytest tests`` now imports the conftest twice, once as ``tests/real/conftest.py`` and once as ``tests/link/conftest.py``.
+  This is a fix to match a similar change made to test collection itself in pytest 6.0 (see :pull:`6523` for details).
+
+
+- `#9626 <https://github.com/pytest-dev/pytest/issues/9626>`_: Fixed count of selected tests on terminal collection summary when there were errors or skipped modules.
+
+  If there were errors or skipped modules on collection, pytest would mistakenly subtract those from the selected count.
+
+
+- `#9645 <https://github.com/pytest-dev/pytest/issues/9645>`_: Fixed regression where ``--import-mode=importlib`` used together with :envvar:`PYTHONPATH` or :confval:`pythonpath` would cause import errors in test suites.
+
+
+- `#9708 <https://github.com/pytest-dev/pytest/issues/9708>`_: :fixture:`pytester` now requests a :fixture:`monkeypatch` fixture instead of creating one internally. This solves some issues with tests that involve pytest environment variables.
+
+
+- `#9730 <https://github.com/pytest-dev/pytest/issues/9730>`_: Malformed ``pyproject.toml`` files now produce a clearer error message.
+
+
+pytest 7.0.1 (2022-02-11)
+=========================
+
+Bug Fixes
+---------
+
+- `#9608 <https://github.com/pytest-dev/pytest/issues/9608>`_: Fix invalid importing of ``importlib.readers`` in Python 3.9.
+
+
+- `#9610 <https://github.com/pytest-dev/pytest/issues/9610>`_: Restore `UnitTestFunction.obj` to return unbound rather than bound method.
+  Fixes a crash during a failed teardown in unittest TestCases with non-default `__init__`.
+  Regressed in pytest 7.0.0.
+
+
+- `#9636 <https://github.com/pytest-dev/pytest/issues/9636>`_: The ``pythonpath`` plugin was renamed to ``python_path``. This avoids a conflict with the ``pytest-pythonpath`` plugin.
+
+
+- `#9642 <https://github.com/pytest-dev/pytest/issues/9642>`_: Fix running tests by id with ``::`` in the parametrize portion.
+
+
+- `#9643 <https://github.com/pytest-dev/pytest/issues/9643>`_: Delay issuing a :class:`~pytest.PytestWarning` about diamond inheritance involving :class:`~pytest.Item` and
+  :class:`~pytest.Collector` so it can be filtered using :ref:`standard warning filters <warnings>`.
+
+
+pytest 7.0.0 (2022-02-03)
+=========================
+
+(**Please see the full set of changes for this release also in the 7.0.0rc1 notes below**)
+
+Deprecations
+------------
+
+- `#9488 <https://github.com/pytest-dev/pytest/issues/9488>`_: If custom subclasses of nodes like :class:`pytest.Item` override the
+  ``__init__`` method, they should take ``**kwargs``. See
+  :ref:`uncooperative-constructors-deprecated` for details.
+
+  Note that a deprection warning is only emitted when there is a conflict in the
+  arguments pytest expected to pass. This deprecation was already part of pytest
+  7.0.0rc1 but wasn't documented.
+
+
+
+Bug Fixes
+---------
+
+- `#9355 <https://github.com/pytest-dev/pytest/issues/9355>`_: Fixed error message prints function decorators when using assert in Python 3.8 and above.
+
+
+- `#9396 <https://github.com/pytest-dev/pytest/issues/9396>`_: Ensure :attr:`pytest.Config.inifile` is available during the :func:`pytest_cmdline_main <_pytest.hookspec.pytest_cmdline_main>` hook (regression during ``7.0.0rc1``).
+
+
+
+Improved Documentation
+----------------------
+
+- `#9404 <https://github.com/pytest-dev/pytest/issues/9404>`_: Added extra documentation on alternatives to common misuses of `pytest.warns(None)` ahead of its deprecation.
+
+
+- `#9505 <https://github.com/pytest-dev/pytest/issues/9505>`_: Clarify where the configuration files are located. To avoid confusions documentation mentions
+  that configuration file is located in the root of the repository.
+
+
+
+Trivial/Internal Changes
+------------------------
+
+- `#9521 <https://github.com/pytest-dev/pytest/issues/9521>`_: Add test coverage to assertion rewrite path.
+
+
+pytest 7.0.0rc1 (2021-12-06)
+============================
+
+Breaking Changes
+----------------
+
+- `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: The :ref:`Node.reportinfo() <non-python tests>` function first return value type has been expanded from `py.path.local | str` to `os.PathLike[str] | str`.
+
+  Most plugins which refer to `reportinfo()` only define it as part of a custom :class:`pytest.Item` implementation.
+  Since `py.path.local` is an `os.PathLike[str]`, these plugins are unaffacted.
+
+  Plugins and users which call `reportinfo()`, use the first return value and interact with it as a `py.path.local`, would need to adjust by calling `py.path.local(fspath)`.
+  Although preferably, avoid the legacy `py.path.local` and use `pathlib.Path`, or use `item.location` or `item.path`, instead.
+
+  Note: pytest was not able to provide a deprecation period for this change.
+
+
+- `#8246 <https://github.com/pytest-dev/pytest/issues/8246>`_: ``--version`` now writes version information to ``stdout`` rather than ``stderr``.
+
+
+- `#8733 <https://github.com/pytest-dev/pytest/issues/8733>`_: Drop a workaround for `pyreadline <https://github.com/pyreadline/pyreadline>`__ that made it work with ``--pdb``.
+
+  The workaround was introduced in `#1281 <https://github.com/pytest-dev/pytest/pull/1281>`__ in 2015, however since then
+  `pyreadline seems to have gone unmaintained <https://github.com/pyreadline/pyreadline/issues/58>`__, is `generating
+  warnings <https://github.com/pytest-dev/pytest/issues/8847>`__, and will stop working on Python 3.10.
+
+
+- `#9061 <https://github.com/pytest-dev/pytest/issues/9061>`_: Using :func:`pytest.approx` in a boolean context now raises an error hinting at the proper usage.
+
+  It is apparently common for users to mistakenly use ``pytest.approx`` like this:
+
+  .. code-block:: python
+
+      assert pytest.approx(actual, expected)
+
+  While the correct usage is:
+
+  .. code-block:: python
+
+      assert actual == pytest.approx(expected)
+
+  The new error message helps catch those mistakes.
+
+
+- `#9277 <https://github.com/pytest-dev/pytest/issues/9277>`_: The ``pytest.Instance`` collector type has been removed.
+  Importing ``pytest.Instance`` or ``_pytest.python.Instance`` returns a dummy type and emits a deprecation warning.
+  See :ref:`instance-collector-deprecation` for details.
+
+
+- `#9308 <https://github.com/pytest-dev/pytest/issues/9308>`_: **PytestRemovedIn7Warning deprecation warnings are now errors by default.**
+
+  Following our plan to remove deprecated features with as little disruption as
+  possible, all warnings of type ``PytestRemovedIn7Warning`` now generate errors
+  instead of warning messages by default.
+
+  **The affected features will be effectively removed in pytest 7.1**, so please consult the
+  :ref:`deprecations` section in the docs for directions on how to update existing code.
+
+  In the pytest ``7.0.X`` series, it is possible to change the errors back into warnings as a
+  stopgap measure by adding this to your ``pytest.ini`` file:
+
+  .. code-block:: ini
+
+      [pytest]
+      filterwarnings =
+          ignore::pytest.PytestRemovedIn7Warning
+
+  But this will stop working when pytest ``7.1`` is released.
+
+  **If you have concerns** about the removal of a specific feature, please add a
+  comment to :issue:`9308`.
+
+
+
+Deprecations
+------------
+
+- `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: ``py.path.local`` arguments for hooks have been deprecated. See :ref:`the deprecation note <legacy-path-hooks-deprecated>` for full details.
+
+  ``py.path.local`` arguments to Node constructors have been deprecated. See :ref:`the deprecation note <node-ctor-fspath-deprecation>` for full details.
+
+  .. note::
+      The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
+      new attribute being ``path``) is **the opposite** of the situation for hooks
+      (the old argument being ``path``).
+
+      This is an unfortunate artifact due to historical reasons, which should be
+      resolved in future versions as we slowly get rid of the :pypi:`py`
+      dependency (see :issue:`9283` for a longer discussion).
+
+
+- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: Directly constructing the following classes is now deprecated:
+
+  - ``_pytest.mark.structures.Mark``
+  - ``_pytest.mark.structures.MarkDecorator``
+  - ``_pytest.mark.structures.MarkGenerator``
+  - ``_pytest.python.Metafunc``
+  - ``_pytest.runner.CallInfo``
+  - ``_pytest._code.ExceptionInfo``
+  - ``_pytest.config.argparsing.Parser``
+  - ``_pytest.config.argparsing.OptionGroup``
+  - ``_pytest.pytester.HookRecorder``
+
+  These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.
+
+
+- `#8242 <https://github.com/pytest-dev/pytest/issues/8242>`_: Raising :class:`unittest.SkipTest` to skip collection of tests during the
+  pytest collection phase is deprecated. Use :func:`pytest.skip` instead.
+
+  Note: This deprecation only relates to using :class:`unittest.SkipTest` during test
+  collection. You are probably not doing that. Ordinary usage of
+  :class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` /
+  :func:`unittest.skip` in unittest test cases is fully supported.
+
+  .. note:: This deprecation has been reverted in pytest 7.1.0.
+
+
+- `#8315 <https://github.com/pytest-dev/pytest/issues/8315>`_: Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
+  scheduled for removal in pytest 8 (deprecated since pytest 2.4.0):
+
+  - ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
+  - ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
+
+
+- `#8447 <https://github.com/pytest-dev/pytest/issues/8447>`_: Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` (e.g. :class:`pytest.File <File>`) now issues a warning.
+  It was never sanely supported and triggers hard to debug errors.
+
+  See :ref:`the deprecation note <diamond-inheritance-deprecated>` for full details.
+
+
+- `#8592 <https://github.com/pytest-dev/pytest/issues/8592>`_: :hook:`pytest_cmdline_preparse` has been officially deprecated.  It will be removed in a future release.  Use :hook:`pytest_load_initial_conftests` instead.
+
+  See :ref:`the deprecation note <cmdline-preparse-deprecated>` for full details.
+
+
+- `#8645 <https://github.com/pytest-dev/pytest/issues/8645>`_: :func:`pytest.warns(None) <pytest.warns>` is now deprecated because many people used
+  it to mean "this code does not emit warnings", but it actually had the effect of
+  checking that the code emits at least one warning of any type - like ``pytest.warns()``
+  or ``pytest.warns(Warning)``.
+
+
+- `#8948 <https://github.com/pytest-dev/pytest/issues/8948>`_: :func:`pytest.skip(msg=...) <pytest.skip>`, :func:`pytest.fail(msg=...) <pytest.fail>` and :func:`pytest.exit(msg=...) <pytest.exit>`
+  signatures now accept a ``reason`` argument instead of ``msg``.  Using ``msg`` still works, but is deprecated and will be removed in a future release.
+
+  This was changed for consistency with :func:`pytest.mark.skip <pytest.mark.skip>` and  :func:`pytest.mark.xfail <pytest.mark.xfail>` which both accept
+  ``reason`` as an argument.
+
+- `#8174 <https://github.com/pytest-dev/pytest/issues/8174>`_: The following changes have been made to types reachable through :attr:`pytest.ExceptionInfo.traceback`:
+
+  - The ``path`` property of ``_pytest.code.Code`` returns ``Path`` instead of ``py.path.local``.
+  - The ``path`` property of ``_pytest.code.TracebackEntry`` returns ``Path`` instead of ``py.path.local``.
+
+  There was no deprecation period for this change (sorry!).
+
+
+Features
+--------
+
+- `#5196 <https://github.com/pytest-dev/pytest/issues/5196>`_: Tests are now ordered by definition order in more cases.
+
+  In a class hierarchy, tests from base classes are now consistently ordered before tests defined on their subclasses (reverse MRO order).
+
+
+- `#7132 <https://github.com/pytest-dev/pytest/issues/7132>`_: Added two environment variables :envvar:`PYTEST_THEME` and :envvar:`PYTEST_THEME_MODE` to let the users customize the pygments theme used.
+
+
+- `#7259 <https://github.com/pytest-dev/pytest/issues/7259>`_: Added :meth:`cache.mkdir() <pytest.Cache.mkdir>`, which is similar to the existing :meth:`cache.makedir() <pytest.Cache.makedir>`,
+  but returns a :class:`pathlib.Path` instead of a legacy ``py.path.local``.
+
+  Added a ``paths`` type to :meth:`parser.addini() <pytest.Parser.addini>`,
+  as in ``parser.addini("mypaths", "my paths", type="paths")``,
+  which is similar to the existing ``pathlist``,
+  but returns a list of :class:`pathlib.Path` instead of legacy ``py.path.local``.
+
+
+- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: The types of objects used in pytest's API are now exported so they may be used in type annotations.
+
+  The newly-exported types are:
+
+  - ``pytest.Config`` for :class:`Config <pytest.Config>`.
+  - ``pytest.Mark`` for :class:`marks <pytest.Mark>`.
+  - ``pytest.MarkDecorator`` for :class:`mark decorators <pytest.MarkDecorator>`.
+  - ``pytest.MarkGenerator`` for the :class:`pytest.mark <pytest.MarkGenerator>` singleton.
+  - ``pytest.Metafunc`` for the :class:`metafunc <pytest.MarkGenerator>` argument to the :hook:`pytest_generate_tests` hook.
+  - ``pytest.CallInfo`` for the :class:`CallInfo <pytest.CallInfo>` type passed to various hooks.
+  - ``pytest.PytestPluginManager`` for :class:`PytestPluginManager <pytest.PytestPluginManager>`.
+  - ``pytest.ExceptionInfo`` for the :class:`ExceptionInfo <pytest.ExceptionInfo>` type returned from :func:`pytest.raises` and passed to various hooks.
+  - ``pytest.Parser`` for the :class:`Parser <pytest.Parser>` type passed to the :hook:`pytest_addoption` hook.
+  - ``pytest.OptionGroup`` for the :class:`OptionGroup <pytest.OptionGroup>` type returned from the :func:`parser.addgroup <pytest.Parser.getgroup>` method.
+  - ``pytest.HookRecorder`` for the :class:`HookRecorder <pytest.HookRecorder>` type returned from :class:`~pytest.Pytester`.
+  - ``pytest.RecordedHookCall`` for the :class:`RecordedHookCall <pytest.HookRecorder>` type returned from :class:`~pytest.HookRecorder`.
+  - ``pytest.RunResult`` for the :class:`RunResult <pytest.RunResult>` type returned from :class:`~pytest.Pytester`.
+  - ``pytest.LineMatcher`` for the :class:`LineMatcher <pytest.RunResult>` type used in :class:`~pytest.RunResult` and others.
+  - ``pytest.TestReport`` for the :class:`TestReport <pytest.TestReport>` type used in various hooks.
+  - ``pytest.CollectReport`` for the :class:`CollectReport <pytest.CollectReport>` type used in various hooks.
+
+  Constructing most of them directly is not supported; they are only meant for use in type annotations.
+  Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
+
+  Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.
+
+
+- `#7856 <https://github.com/pytest-dev/pytest/issues/7856>`_: :ref:`--import-mode=importlib <import-modes>` now works with features that
+  depend on modules being on :py:data:`sys.modules`, such as :mod:`pickle` and :mod:`dataclasses`.
+
+
+- `#8144 <https://github.com/pytest-dev/pytest/issues/8144>`_: The following hooks now receive an additional ``pathlib.Path`` argument, equivalent to an existing ``py.path.local`` argument:
+
+  - :hook:`pytest_ignore_collect` - The ``collection_path`` parameter (equivalent to existing ``path`` parameter).
+  - :hook:`pytest_collect_file` - The ``file_path`` parameter (equivalent to existing ``path`` parameter).
+  - :hook:`pytest_pycollect_makemodule` - The ``module_path`` parameter (equivalent to existing ``path`` parameter).
+  - :hook:`pytest_report_header` - The ``start_path`` parameter (equivalent to existing ``startdir`` parameter).
+  - :hook:`pytest_report_collectionfinish` - The ``start_path`` parameter (equivalent to existing ``startdir`` parameter).
+
+  .. note::
+      The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
+      new attribute being ``path``) is **the opposite** of the situation for hooks
+      (the old argument being ``path``).
+
+      This is an unfortunate artifact due to historical reasons, which should be
+      resolved in future versions as we slowly get rid of the :pypi:`py`
+      dependency (see :issue:`9283` for a longer discussion).
+
+
+- `#8251 <https://github.com/pytest-dev/pytest/issues/8251>`_: Implement ``Node.path`` as a ``pathlib.Path``. Both the old ``fspath`` and this new attribute gets set no matter whether ``path`` or ``fspath`` (deprecated) is passed to the constructor. It is a replacement for the ``fspath`` attribute (which represents the same path as ``py.path.local``). While ``fspath`` is not deprecated yet
+  due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`, we expect to deprecate it in a future release.
+
+  .. note::
+      The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
+      new attribute being ``path``) is **the opposite** of the situation for hooks
+      (the old argument being ``path``).
+
+      This is an unfortunate artifact due to historical reasons, which should be
+      resolved in future versions as we slowly get rid of the :pypi:`py`
+      dependency (see :issue:`9283` for a longer discussion).
+
+
+- `#8421 <https://github.com/pytest-dev/pytest/issues/8421>`_: :func:`pytest.approx` now works on :class:`~decimal.Decimal` within mappings/dicts and sequences/lists.
+
+
+- `#8606 <https://github.com/pytest-dev/pytest/issues/8606>`_: pytest invocations with ``--fixtures-per-test`` and ``--fixtures`` have been enriched with:
+
+  - Fixture location path printed with the fixture name.
+  - First section of the fixture's docstring printed under the fixture name.
+  - Whole of fixture's docstring printed under the fixture name using ``--verbose`` option.
+
+
+- `#8761 <https://github.com/pytest-dev/pytest/issues/8761>`_: New :ref:`version-tuple` attribute, which makes it simpler for users to do something depending on the pytest version (such as declaring hooks which are introduced in later versions).
+
+
+- `#8789 <https://github.com/pytest-dev/pytest/issues/8789>`_: Switch TOML parser from ``toml`` to ``tomli`` for TOML v1.0.0 support in ``pyproject.toml``.
+
+
+- `#8920 <https://github.com/pytest-dev/pytest/issues/8920>`_: Added :class:`pytest.Stash`, a facility for plugins to store their data on :class:`~pytest.Config` and :class:`~_pytest.nodes.Node`\s in a type-safe and conflict-free manner.
+  See :ref:`plugin-stash` for details.
+
+
+- `#8953 <https://github.com/pytest-dev/pytest/issues/8953>`_: :class:`RunResult <_pytest.pytester.RunResult>` method :meth:`assert_outcomes <_pytest.pytester.RunResult.assert_outcomes>` now accepts a
+  ``warnings`` argument to assert the total number of warnings captured.
+
+
+- `#8954 <https://github.com/pytest-dev/pytest/issues/8954>`_: ``--debug`` flag now accepts a :class:`str` file to route debug logs into, remains defaulted to `pytestdebug.log`.
+
+
+- `#9023 <https://github.com/pytest-dev/pytest/issues/9023>`_: Full diffs are now always shown for equality assertions of iterables when
+  `CI` or ``BUILD_NUMBER`` is found in the environment, even when ``-v`` isn't
+  used.
+
+
+- `#9113 <https://github.com/pytest-dev/pytest/issues/9113>`_: :class:`RunResult <_pytest.pytester.RunResult>` method :meth:`assert_outcomes <_pytest.pytester.RunResult.assert_outcomes>` now accepts a
+  ``deselected`` argument to assert the total number of deselected tests.
+
+
+- `#9114 <https://github.com/pytest-dev/pytest/issues/9114>`_: Added :confval:`pythonpath` setting that adds listed paths to :data:`sys.path` for the duration of the test session. If you currently use the pytest-pythonpath or pytest-srcpaths plugins, you should be able to replace them with built-in `pythonpath` setting.
+
+
+
+Improvements
+------------
+
+- `#7480 <https://github.com/pytest-dev/pytest/issues/7480>`_: A deprecation scheduled to be removed in a major version X (e.g. pytest 7, 8, 9, ...) now uses warning category `PytestRemovedInXWarning`,
+  a subclass of :class:`~pytest.PytestDeprecationWarning`,
+  instead of :class:`PytestDeprecationWarning` directly.
+
+  See :ref:`backwards-compatibility` for more details.
+
+
+- `#7864 <https://github.com/pytest-dev/pytest/issues/7864>`_: Improved error messages when parsing warning filters.
+
+  Previously pytest would show an internal traceback, which besides being ugly sometimes would hide the cause
+  of the problem (for example an ``ImportError`` while importing a specific warning type).
+
+
+- `#8335 <https://github.com/pytest-dev/pytest/issues/8335>`_: Improved :func:`pytest.approx` assertion messages for sequences of numbers.
+
+  The assertion messages now dumps a table with the index and the error of each diff.
+  Example::
+
+      >       assert [1, 2, 3, 4] == pytest.approx([1, 3, 3, 5])
+      E       assert comparison failed for 2 values:
+      E         Index | Obtained | Expected
+      E         1     | 2        | 3 +- 3.0e-06
+      E         3     | 4        | 5 +- 5.0e-06
+
+
+- `#8403 <https://github.com/pytest-dev/pytest/issues/8403>`_: By default, pytest will truncate long strings in assert errors so they don't clutter the output too much,
+  currently at ``240`` characters by default.
+
+  However, in some cases the longer output helps, or is even crucial, to diagnose a failure. Using ``-v`` will
+  now increase the truncation threshold to ``2400`` characters, and ``-vv`` or higher will disable truncation entirely.
+
+
+- `#8509 <https://github.com/pytest-dev/pytest/issues/8509>`_: Fixed issue where :meth:`unittest.TestCase.setUpClass` is not called when a test has `/` in its name since pytest 6.2.0.
+
+  This refers to the path part in pytest node IDs, e.g. ``TestClass::test_it`` in the node ID ``tests/test_file.py::TestClass::test_it``.
+
+  Now, instead of assuming that the test name does not contain ``/``, it is assumed that test path does not contain ``::``. We plan to hopefully make both of these work in the future.
+
+
+- `#8803 <https://github.com/pytest-dev/pytest/issues/8803>`_: It is now possible to add colors to custom log levels on cli log.
+
+  By using :func:`add_color_level <_pytest.logging.add_color_level>` from a ``pytest_configure`` hook, colors can be added::
+
+      logging_plugin = config.pluginmanager.get_plugin('logging-plugin')
+      logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, 'cyan')
+      logging_plugin.log_cli_handler.formatter.add_color_level(logging.SPAM, 'blue')
+
+  See :ref:`log_colors` for more information.
+
+
+- `#8822 <https://github.com/pytest-dev/pytest/issues/8822>`_: When showing fixture paths in `--fixtures` or `--fixtures-by-test`, fixtures coming from pytest itself now display an elided path, rather than the full path to the file in the `site-packages` directory.
+
+
+- `#8898 <https://github.com/pytest-dev/pytest/issues/8898>`_: Complex numbers are now treated like floats and integers when generating parameterization IDs.
+
+
+- `#9062 <https://github.com/pytest-dev/pytest/issues/9062>`_: ``--stepwise-skip`` now implicitly enables ``--stepwise`` and can be used on its own.
+
+
+- `#9205 <https://github.com/pytest-dev/pytest/issues/9205>`_: :meth:`pytest.Cache.set` now preserves key order when saving dicts.
+
+
+
+Bug Fixes
+---------
+
+- `#7124 <https://github.com/pytest-dev/pytest/issues/7124>`_: Fixed an issue where ``__main__.py`` would raise an ``ImportError`` when ``--doctest-modules`` was provided.
+
+
+- `#8061 <https://github.com/pytest-dev/pytest/issues/8061>`_: Fixed failing ``staticmethod`` test cases if they are inherited from a parent test class.
+
+
+- `#8192 <https://github.com/pytest-dev/pytest/issues/8192>`_: ``testdir.makefile`` now silently accepts values which don't start with ``.`` to maintain backward compatibility with older pytest versions.
+
+  ``pytester.makefile`` now issues a clearer error if the ``.`` is missing in the ``ext`` argument.
+
+
+- `#8258 <https://github.com/pytest-dev/pytest/issues/8258>`_: Fixed issue where pytest's ``faulthandler`` support would not dump traceback on crashes
+  if the :mod:`faulthandler` module was already enabled during pytest startup (using
+  ``python -X dev -m pytest`` for example).
+
+
+- `#8317 <https://github.com/pytest-dev/pytest/issues/8317>`_: Fixed an issue where illegal directory characters derived from ``getpass.getuser()`` raised an ``OSError``.
+
+
+- `#8367 <https://github.com/pytest-dev/pytest/issues/8367>`_: Fix ``Class.from_parent`` so it forwards extra keyword arguments to the constructor.
+
+
+- `#8377 <https://github.com/pytest-dev/pytest/issues/8377>`_: The test selection options ``pytest -k`` and ``pytest -m`` now support matching
+  names containing forward slash (``/``) characters.
+
+
+- `#8384 <https://github.com/pytest-dev/pytest/issues/8384>`_: The ``@pytest.mark.skip`` decorator now correctly handles its arguments. When the ``reason`` argument is accidentally given both positional and as a keyword (e.g. because it was confused with ``skipif``), a ``TypeError`` now occurs. Before, such tests were silently skipped, and the positional argument ignored. Additionally, ``reason`` is now documented correctly as positional or keyword (rather than keyword-only).
+
+
+- `#8394 <https://github.com/pytest-dev/pytest/issues/8394>`_: Use private names for internal fixtures that handle classic setup/teardown so that they don't show up with the default ``--fixtures`` invocation (but they still show up with ``--fixtures -v``).
+
+
+- `#8456 <https://github.com/pytest-dev/pytest/issues/8456>`_: The :confval:`required_plugins` config option now works correctly when pre-releases of plugins are installed, rather than falsely claiming that those plugins aren't installed at all.
+
+
+- `#8464 <https://github.com/pytest-dev/pytest/issues/8464>`_: ``-c <config file>`` now also properly defines ``rootdir`` as the directory that contains ``<config file>``.
+
+
+- `#8503 <https://github.com/pytest-dev/pytest/issues/8503>`_: :meth:`pytest.MonkeyPatch.syspath_prepend` no longer fails when
+  ``setuptools`` is not installed.
+  It now only calls :func:`pkg_resources.fixup_namespace_packages` if
+  ``pkg_resources`` was previously imported, because it is not needed otherwise.
+
+
+- `#8548 <https://github.com/pytest-dev/pytest/issues/8548>`_: Introduce fix to handle precision width in ``log-cli-format`` in turn to fix output coloring for certain formats.
+
+
+- `#8796 <https://github.com/pytest-dev/pytest/issues/8796>`_: Fixed internal error when skipping doctests.
+
+
+- `#8983 <https://github.com/pytest-dev/pytest/issues/8983>`_: The test selection options ``pytest -k`` and ``pytest -m`` now support matching names containing backslash (`\\`) characters.
+  Backslashes are treated literally, not as escape characters (the values being matched against are already escaped).
+
+
+- `#8990 <https://github.com/pytest-dev/pytest/issues/8990>`_: Fix `pytest -vv` crashing with an internal exception `AttributeError: 'str' object has no attribute 'relative_to'` in some cases.
+
+
+- `#9077 <https://github.com/pytest-dev/pytest/issues/9077>`_: Fixed confusing error message when ``request.fspath`` / ``request.path`` was accessed from a session-scoped fixture.
+
+
+- `#9131 <https://github.com/pytest-dev/pytest/issues/9131>`_: Fixed the URL used by ``--pastebin`` to use `bpa.st <http://bpa.st>`__.
+
+
+- `#9163 <https://github.com/pytest-dev/pytest/issues/9163>`_: The end line number and end column offset are now properly set for rewritten assert statements.
+
+
+- `#9169 <https://github.com/pytest-dev/pytest/issues/9169>`_: Support for the ``files`` API from ``importlib.resources`` within rewritten files.
+
+
+- `#9272 <https://github.com/pytest-dev/pytest/issues/9272>`_: The nose compatibility module-level fixtures `setup()` and `teardown()` are now only called once per module, instead of for each test function.
+  They are now called even if object-level `setup`/`teardown` is defined.
+
+
+
+Improved Documentation
+----------------------
+
+- `#4320 <https://github.com/pytest-dev/pytest/issues/4320>`_: Improved docs for `pytester.copy_example`.
+
+
+- `#5105 <https://github.com/pytest-dev/pytest/issues/5105>`_: Add automatically generated :ref:`plugin-list`. The list is updated on a periodic schedule.
+
+
+- `#8337 <https://github.com/pytest-dev/pytest/issues/8337>`_: Recommend `numpy.testing <https://numpy.org/doc/stable/reference/routines.testing.html>`__ module on :func:`pytest.approx` documentation.
+
+
+- `#8655 <https://github.com/pytest-dev/pytest/issues/8655>`_: Help text for ``--pdbcls`` more accurately reflects the option's behavior.
+
+
+- `#9210 <https://github.com/pytest-dev/pytest/issues/9210>`_: Remove incorrect docs about ``confcutdir`` being a configuration option: it can only be set through the ``--confcutdir`` command-line option.
+
+
+- `#9242 <https://github.com/pytest-dev/pytest/issues/9242>`_: Upgrade readthedocs configuration to use a `newer Ubuntu version <https://blog.readthedocs.com/new-build-specification/>`__` with better unicode support for PDF docs.
+
+
+- `#9341 <https://github.com/pytest-dev/pytest/issues/9341>`_: Various methods commonly used for :ref:`non-python tests` are now correctly documented in the reference docs. They were undocumented previously.
+
+
+
+Trivial/Internal Changes
+------------------------
+
+- `#8133 <https://github.com/pytest-dev/pytest/issues/8133>`_: Migrate to ``setuptools_scm`` 6.x to use ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST`` for more robust release tooling.
+
+
+- `#8174 <https://github.com/pytest-dev/pytest/issues/8174>`_: The following changes have been made to internal pytest types/functions:
+
+  - The ``_pytest.code.getfslineno()`` function returns ``Path`` instead of ``py.path.local``.
+  - The ``_pytest.python.path_matches_patterns()`` function takes ``Path`` instead of ``py.path.local``.
+  - The ``_pytest._code.Traceback.cut()`` function accepts any ``os.PathLike[str]``, not just ``py.path.local``.
+
+
+- `#8248 <https://github.com/pytest-dev/pytest/issues/8248>`_: Internal Restructure: let ``python.PyObjMixin`` inherit from ``nodes.Node`` to carry over typing information.
+
+
+- `#8432 <https://github.com/pytest-dev/pytest/issues/8432>`_: Improve error message when :func:`pytest.skip` is used at module level without passing `allow_module_level=True`.
+
+
+- `#8818 <https://github.com/pytest-dev/pytest/issues/8818>`_: Ensure ``regendoc`` opts out of ``TOX_ENV`` cachedir selection to ensure independent example test runs.
+
+
+- `#8913 <https://github.com/pytest-dev/pytest/issues/8913>`_: The private ``CallSpec2._arg2scopenum`` attribute has been removed after an internal refactoring.
+
+
+- `#8967 <https://github.com/pytest-dev/pytest/issues/8967>`_: :hook:`pytest_assertion_pass` is no longer considered experimental and
+  future changes to it will be considered more carefully.
+
+
+- `#9202 <https://github.com/pytest-dev/pytest/issues/9202>`_: Add github action to upload coverage report to codecov instead of bash uploader.
+
+
+- `#9225 <https://github.com/pytest-dev/pytest/issues/9225>`_: Changed the command used to create sdist and wheel artifacts: using the build package instead of setup.py.
+
+
+- `#9351 <https://github.com/pytest-dev/pytest/issues/9351>`_: Correct minor typos in doc/en/example/special.rst.
+
+
+pytest 6.2.5 (2021-08-29)
+=========================
+
+
+Trivial/Internal Changes
+------------------------
+
+- :issue:`8494`: Python 3.10 is now supported.
+
+
+- :issue:`9040`: Enable compatibility with ``pluggy 1.0`` or later.
+
+
+pytest 6.2.4 (2021-05-04)
+=========================
+
+Bug Fixes
+---------
+
+- :issue:`8539`: Fixed assertion rewriting on Python 3.10.
+
+
+pytest 6.2.3 (2021-04-03)
+=========================
+
+Bug Fixes
+---------
+
+- :issue:`8414`: pytest used to create directories under ``/tmp`` with world-readable
+  permissions. This means that any user in the system was able to read
+  information written by tests in temporary directories (such as those created by
+  the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with
+  private permissions.
+
+  pytest used to silently use a pre-existing ``/tmp/pytest-of-<username>`` directory,
+  even if owned by another user. This means another user could pre-create such a
+  directory and gain control of another user's temporary directory. Now such a
+  condition results in an error.
+
+
 pytest 6.2.2 (2021-01-25)
 =========================
 
 Bug Fixes
 ---------
 
-- `#8152 <https://github.com/pytest-dev/pytest/issues/8152>`_: Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty.
+- :issue:`8152`: Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty.
 
 
-- `#8249 <https://github.com/pytest-dev/pytest/issues/8249>`_: Fix the ``faulthandler`` plugin for occasions when running with ``twisted.logger`` and using ``pytest --capture=no``.
+- :issue:`8249`: Fix the ``faulthandler`` plugin for occasions when running with ``twisted.logger`` and using ``pytest --capture=no``.
 
 
 pytest 6.2.1 (2020-12-15)
@@ -46,11 +1272,11 @@ pytest 6.2.1 (2020-12-15)
 Bug Fixes
 ---------
 
-- `#7678 <https://github.com/pytest-dev/pytest/issues/7678>`_: Fixed bug where ``ImportPathMismatchError`` would be raised for files compiled in
+- :issue:`7678`: Fixed bug where ``ImportPathMismatchError`` would be raised for files compiled in
   the host and loaded later from an UNC mounted path (Windows).
 
 
-- `#8132 <https://github.com/pytest-dev/pytest/issues/8132>`_: Fixed regression in ``approx``: in 6.2.0 ``approx`` no longer raises
+- :issue:`8132`: Fixed regression in ``approx``: in 6.2.0 ``approx`` no longer raises
   ``TypeError`` when dealing with non-numeric types, falling back to normal comparison.
   Before 6.2.0, array types like tf.DeviceArray fell through to the scalar case,
   and happened to compare correctly to a scalar if they had only one element.
@@ -68,14 +1294,14 @@ pytest 6.2.0 (2020-12-12)
 Breaking Changes
 ----------------
 
-- `#7808 <https://github.com/pytest-dev/pytest/issues/7808>`_: pytest now supports python3.6+ only.
+- :issue:`7808`: pytest now supports python3.6+ only.
 
 
 
 Deprecations
 ------------
 
-- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: Directly constructing/calling the following classes/functions is now deprecated:
+- :issue:`7469`: Directly constructing/calling the following classes/functions is now deprecated:
 
   - ``_pytest.cacheprovider.Cache``
   - ``_pytest.cacheprovider.Cache.for_config()``
@@ -92,16 +1318,16 @@ Deprecations
   - ``_pytest.tmpdir.TempPathFactory``
   - ``_pytest.tmpdir.TempdirFactory``
 
-  These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 7.0.0.
+  These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.0.0.
 
 
-- `#7530 <https://github.com/pytest-dev/pytest/issues/7530>`_: The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead.
+- :issue:`7530`: The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead.
 
   We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing flag for all strictness
   related options (``--strict-markers`` and ``--strict-config`` at the moment, more might be introduced in the future).
 
 
-- `#7988 <https://github.com/pytest-dev/pytest/issues/7988>`_: The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead.
+- :issue:`7988`: The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead.
 
   ``yield_fixture`` has been an alias for ``fixture`` for a very long time, so can be search/replaced safely.
 
@@ -110,18 +1336,18 @@ Deprecations
 Features
 --------
 
-- `#5299 <https://github.com/pytest-dev/pytest/issues/5299>`_: pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8.
+- :issue:`5299`: pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8.
   See :ref:`unraisable` for more information.
 
 
-- `#7425 <https://github.com/pytest-dev/pytest/issues/7425>`_: New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``.
+- :issue:`7425`: New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``.
 
   This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
 
   Internally, the old :class:`Testdir <_pytest.pytester.Testdir>` is now a thin wrapper around :class:`Pytester <_pytest.pytester.Pytester>`, preserving the old interface.
 
 
-- `#7695 <https://github.com/pytest-dev/pytest/issues/7695>`_: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
+- :issue:`7695`: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
   This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers.
 
   Pseudo example
@@ -142,7 +1368,7 @@ Features
          assert False
 
 
-- `#8006 <https://github.com/pytest-dev/pytest/issues/8006>`_: It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``,
+- :issue:`8006`: It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``,
   in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it
   from the private `_pytest.monkeypatch.MonkeyPatch` namespace.
 
@@ -156,13 +1382,13 @@ Features
 Improvements
 ------------
 
-- `#1265 <https://github.com/pytest-dev/pytest/issues/1265>`_: Added an ``__str__`` implementation to the :class:`~pytest.pytester.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method.
+- :issue:`1265`: Added an ``__str__`` implementation to the :class:`~pytest.pytester.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method.
 
 
-- `#2044 <https://github.com/pytest-dev/pytest/issues/2044>`_: Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS".
+- :issue:`2044`: Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS".
 
 
-- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_ The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions.
+- :issue:`7469` The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions.
   The newly-exported types are:
 
   - ``pytest.FixtureRequest`` for the :fixture:`request` fixture.
@@ -178,84 +1404,84 @@ Improvements
   - ``pytest.WarningsRecorder`` for the :fixture:`recwarn` fixture.
 
   Constructing them is not supported (except for `MonkeyPatch`); they are only meant for use in type annotations.
-  Doing so will emit a deprecation warning, and may become a hard-error in pytest 7.0.
+  Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
 
   Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.
 
 
-- `#7527 <https://github.com/pytest-dev/pytest/issues/7527>`_: When a comparison between :func:`namedtuple <collections.namedtuple>` instances of the same type fails, pytest now shows the differing field names (possibly nested) instead of their indexes.
+- :issue:`7527`: When a comparison between :func:`namedtuple <collections.namedtuple>` instances of the same type fails, pytest now shows the differing field names (possibly nested) instead of their indexes.
 
 
-- `#7615 <https://github.com/pytest-dev/pytest/issues/7615>`_: :meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning <pytest.PytestWarning>`.
+- :issue:`7615`: :meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning <pytest.PytestWarning>`.
 
 
-- `#7701 <https://github.com/pytest-dev/pytest/issues/7701>`_: Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats.
+- :issue:`7701`: Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats.
 
 
-- `#7710 <https://github.com/pytest-dev/pytest/issues/7710>`_: Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of
+- :issue:`7710`: Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of
   raising :class:`TypeError`.
 
   This was the undocumented behavior before 3.7, but is now officially a supported feature.
 
 
-- `#7938 <https://github.com/pytest-dev/pytest/issues/7938>`_: New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``.
+- :issue:`7938`: New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``.
 
 
-- `#8023 <https://github.com/pytest-dev/pytest/issues/8023>`_: Added ``'node_modules'`` to default value for :confval:`norecursedirs`.
+- :issue:`8023`: Added ``'node_modules'`` to default value for :confval:`norecursedirs`.
 
 
-- `#8032 <https://github.com/pytest-dev/pytest/issues/8032>`_: :meth:`doClassCleanups <unittest.TestCase.doClassCleanups>` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately.
+- :issue:`8032`: :meth:`doClassCleanups <unittest.TestCase.doClassCleanups>` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately.
 
 
 
 Bug Fixes
 ---------
 
-- `#4824 <https://github.com/pytest-dev/pytest/issues/4824>`_: Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures.
+- :issue:`4824`: Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures.
 
 
-- `#7758 <https://github.com/pytest-dev/pytest/issues/7758>`_: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
+- :issue:`7758`: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
 
 
-- `#7911 <https://github.com/pytest-dev/pytest/issues/7911>`_: Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
+- :issue:`7911`: Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
 
 
-- `#7913 <https://github.com/pytest-dev/pytest/issues/7913>`_: Fixed a crash or hang in :meth:`pytester.spawn <_pytest.pytester.Pytester.spawn>` when the :mod:`readline` module is involved.
+- :issue:`7913`: Fixed a crash or hang in :meth:`pytester.spawn <_pytest.pytester.Pytester.spawn>` when the :mod:`readline` module is involved.
 
 
-- `#7951 <https://github.com/pytest-dev/pytest/issues/7951>`_: Fixed handling of recursive symlinks when collecting tests.
+- :issue:`7951`: Fixed handling of recursive symlinks when collecting tests.
 
 
-- `#7981 <https://github.com/pytest-dev/pytest/issues/7981>`_: Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0.
+- :issue:`7981`: Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0.
 
 
-- `#8016 <https://github.com/pytest-dev/pytest/issues/8016>`_: Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``.
+- :issue:`8016`: Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#7429 <https://github.com/pytest-dev/pytest/issues/7429>`_: Add more information and use cases about skipping doctests.
+- :issue:`7429`: Add more information and use cases about skipping doctests.
 
 
-- `#7780 <https://github.com/pytest-dev/pytest/issues/7780>`_: Classes which should not be inherited from are now marked ``final class`` in the API reference.
+- :issue:`7780`: Classes which should not be inherited from are now marked ``final class`` in the API reference.
 
 
-- `#7872 <https://github.com/pytest-dev/pytest/issues/7872>`_: ``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``.
+- :issue:`7872`: ``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``.
 
 
-- `#7878 <https://github.com/pytest-dev/pytest/issues/7878>`_: In pull request section, ask to commit after editing changelog and authors file.
+- :issue:`7878`: In pull request section, ask to commit after editing changelog and authors file.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#7802 <https://github.com/pytest-dev/pytest/issues/7802>`_: The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.
+- :issue:`7802`: The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.
 
 
-- `#8014 <https://github.com/pytest-dev/pytest/issues/8014>`_: `.pyc` files created by pytest's assertion rewriting now conform to the newer PEP-552 format on Python>=3.7.
+- :issue:`8014`: `.pyc` files created by pytest's assertion rewriting now conform to the newer :pep:`552` format on Python>=3.7.
   (These files are internal and only interpreted by pytest itself.)
 
 
@@ -265,17 +1491,17 @@ pytest 6.1.2 (2020-10-28)
 Bug Fixes
 ---------
 
-- `#7758 <https://github.com/pytest-dev/pytest/issues/7758>`_: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
+- :issue:`7758`: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
 
 
-- `#7911 <https://github.com/pytest-dev/pytest/issues/7911>`_: Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
+- :issue:`7911`: Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#7815 <https://github.com/pytest-dev/pytest/issues/7815>`_: Improve deprecation warning message for ``pytest._fillfuncargs()``.
+- :issue:`7815`: Improve deprecation warning message for ``pytest._fillfuncargs()``.
 
 
 pytest 6.1.1 (2020-10-03)
@@ -284,10 +1510,10 @@ pytest 6.1.1 (2020-10-03)
 Bug Fixes
 ---------
 
-- `#7807 <https://github.com/pytest-dev/pytest/issues/7807>`_: Fixed regression in pytest 6.1.0 causing incorrect rootdir to be determined in some non-trivial cases where parent directories have config files as well.
+- :issue:`7807`: Fixed regression in pytest 6.1.0 causing incorrect rootdir to be determined in some non-trivial cases where parent directories have config files as well.
 
 
-- `#7814 <https://github.com/pytest-dev/pytest/issues/7814>`_: Fixed crash in header reporting when :confval:`testpaths` is used and contains absolute paths (regression in 6.1.0).
+- :issue:`7814`: Fixed crash in header reporting when :confval:`testpaths` is used and contains absolute paths (regression in 6.1.0).
 
 
 pytest 6.1.0 (2020-09-26)
@@ -296,7 +1522,7 @@ pytest 6.1.0 (2020-09-26)
 Breaking Changes
 ----------------
 
-- `#5585 <https://github.com/pytest-dev/pytest/issues/5585>`_: As per our policy, the following features which have been deprecated in the 5.X series are now
+- :issue:`5585`: As per our policy, the following features which have been deprecated in the 5.X series are now
   removed:
 
   * The ``funcargnames`` read-only property of ``FixtureRequest``, ``Metafunc``, and ``Function`` classes. Use ``fixturenames`` attribute.
@@ -312,18 +1538,17 @@ Breaking Changes
   * The ``--result-log`` option has been removed. Users are recommended to use the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin instead.
 
 
-  For more information consult
-  `Deprecations and Removals <https://docs.pytest.org/en/stable/deprecations.html>`__ in the docs.
+  For more information consult :std:doc:`deprecations` in the docs.
 
 
 
 Deprecations
 ------------
 
-- `#6981 <https://github.com/pytest-dev/pytest/issues/6981>`_: The ``pytest.collect`` module is deprecated: all its names can be imported from ``pytest`` directly.
+- :issue:`6981`: The ``pytest.collect`` module is deprecated: all its names can be imported from ``pytest`` directly.
 
 
-- `#7097 <https://github.com/pytest-dev/pytest/issues/7097>`_: The ``pytest._fillfuncargs`` function is deprecated. This function was kept
+- :issue:`7097`: The ``pytest._fillfuncargs`` function is deprecated. This function was kept
   for backward compatibility with an older plugin.
 
   It's functionality is not meant to be used directly, but if you must replace
@@ -331,18 +1556,18 @@ Deprecations
   a public API and may break in the future.
 
 
-- `#7210 <https://github.com/pytest-dev/pytest/issues/7210>`_: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
+- :issue:`7210`: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
   instead.
 
   The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue
   if you use this and want a replacement.
 
 
-- `#7255 <https://github.com/pytest-dev/pytest/issues/7255>`_: The :func:`pytest_warning_captured <_pytest.hookspec.pytest_warning_captured>` hook is deprecated in favor
-  of :func:`pytest_warning_recorded <_pytest.hookspec.pytest_warning_recorded>`, and will be removed in a future version.
+- :issue:`7255`: The :hook:`pytest_warning_captured` hook is deprecated in favor
+  of :hook:`pytest_warning_recorded`, and will be removed in a future version.
 
 
-- `#7648 <https://github.com/pytest-dev/pytest/issues/7648>`_: The ``gethookproxy()`` and ``isinitpath()`` methods of ``FSCollector`` and ``Package`` are deprecated;
+- :issue:`7648`: The ``gethookproxy()`` and ``isinitpath()`` methods of ``FSCollector`` and ``Package`` are deprecated;
   use ``self.session.gethookproxy()`` and ``self.session.isinitpath()`` instead.
   This should work on all pytest versions.
 
@@ -351,27 +1576,27 @@ Deprecations
 Features
 --------
 
-- `#7667 <https://github.com/pytest-dev/pytest/issues/7667>`_: New ``--durations-min`` command-line flag controls the minimal duration for inclusion in the slowest list of tests shown by ``--durations``. Previously this was hard-coded to ``0.005s``.
+- :issue:`7667`: New ``--durations-min`` command-line flag controls the minimal duration for inclusion in the slowest list of tests shown by ``--durations``. Previously this was hard-coded to ``0.005s``.
 
 
 
 Improvements
 ------------
 
-- `#6681 <https://github.com/pytest-dev/pytest/issues/6681>`_: Internal pytest warnings issued during the early stages of initialization are now properly handled and can filtered through :confval:`filterwarnings` or ``--pythonwarnings/-W``.
+- :issue:`6681`: Internal pytest warnings issued during the early stages of initialization are now properly handled and can filtered through :confval:`filterwarnings` or ``--pythonwarnings/-W``.
 
-  This also fixes a number of long standing issues: `#2891 <https://github.com/pytest-dev/pytest/issues/2891>`__, `#7620 <https://github.com/pytest-dev/pytest/issues/7620>`__, `#7426 <https://github.com/pytest-dev/pytest/issues/7426>`__.
+  This also fixes a number of long standing issues: :issue:`2891`, :issue:`7620`, :issue:`7426`.
 
 
-- `#7572 <https://github.com/pytest-dev/pytest/issues/7572>`_: When a plugin listed in ``required_plugins`` is missing or an unknown config key is used with ``--strict-config``, a simple error message is now shown instead of a stacktrace.
+- :issue:`7572`: When a plugin listed in ``required_plugins`` is missing or an unknown config key is used with ``--strict-config``, a simple error message is now shown instead of a stacktrace.
 
 
-- `#7685 <https://github.com/pytest-dev/pytest/issues/7685>`_: Added two new attributes :attr:`rootpath <_pytest.config.Config.rootpath>` and :attr:`inipath <_pytest.config.Config.inipath>` to :class:`Config <_pytest.config.Config>`.
+- :issue:`7685`: Added two new attributes :attr:`rootpath <_pytest.config.Config.rootpath>` and :attr:`inipath <_pytest.config.Config.inipath>` to :class:`Config <_pytest.config.Config>`.
   These attributes are :class:`pathlib.Path` versions of the existing :attr:`rootdir <_pytest.config.Config.rootdir>` and :attr:`inifile <_pytest.config.Config.inifile>` attributes,
   and should be preferred over them when possible.
 
 
-- `#7780 <https://github.com/pytest-dev/pytest/issues/7780>`_: Public classes which are not designed to be inherited from are now marked `@final <https://docs.python.org/3/library/typing.html#typing.final>`_.
+- :issue:`7780`: Public classes which are not designed to be inherited from are now marked :func:`@final <typing.final>`.
   Code which inherits from these classes will trigger a type-checking (e.g. mypy) error, but will still work in runtime.
   Currently the ``final`` designation does not appear in the API Reference but hopefully will in the future.
 
@@ -380,7 +1605,7 @@ Improvements
 Bug Fixes
 ---------
 
-- `#1953 <https://github.com/pytest-dev/pytest/issues/1953>`_: Fixed error when overwriting a parametrized fixture, while also reusing the super fixture value.
+- :issue:`1953`: Fixed error when overwriting a parametrized fixture, while also reusing the super fixture value.
 
   .. code-block:: python
 
@@ -402,52 +1627,52 @@ Bug Fixes
           return foo * 2
 
 
-- `#4984 <https://github.com/pytest-dev/pytest/issues/4984>`_: Fixed an internal error crash with ``IndexError: list index out of range`` when
+- :issue:`4984`: Fixed an internal error crash with ``IndexError: list index out of range`` when
   collecting a module which starts with a decorated function, the decorator
   raises, and assertion rewriting is enabled.
 
 
-- `#7591 <https://github.com/pytest-dev/pytest/issues/7591>`_: pylint shouldn't complain anymore about unimplemented abstract methods when inheriting from :ref:`File <non-python tests>`.
+- :issue:`7591`: pylint shouldn't complain anymore about unimplemented abstract methods when inheriting from :ref:`File <non-python tests>`.
 
 
-- `#7628 <https://github.com/pytest-dev/pytest/issues/7628>`_: Fixed test collection when a full path without a drive letter was passed to pytest on Windows (for example ``\projects\tests\test.py`` instead of ``c:\projects\tests\pytest.py``).
+- :issue:`7628`: Fixed test collection when a full path without a drive letter was passed to pytest on Windows (for example ``\projects\tests\test.py`` instead of ``c:\projects\tests\pytest.py``).
 
 
-- `#7638 <https://github.com/pytest-dev/pytest/issues/7638>`_: Fix handling of command-line options that appear as paths but trigger an OS-level syntax error on Windows, such as the options used internally by ``pytest-xdist``.
+- :issue:`7638`: Fix handling of command-line options that appear as paths but trigger an OS-level syntax error on Windows, such as the options used internally by ``pytest-xdist``.
 
 
-- `#7742 <https://github.com/pytest-dev/pytest/issues/7742>`_: Fixed INTERNALERROR when accessing locals / globals with faulty ``exec``.
+- :issue:`7742`: Fixed INTERNALERROR when accessing locals / globals with faulty ``exec``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#1477 <https://github.com/pytest-dev/pytest/issues/1477>`_: Removed faq.rst and its reference in contents.rst.
+- :issue:`1477`: Removed faq.rst and its reference in contents.rst.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#7536 <https://github.com/pytest-dev/pytest/issues/7536>`_: The internal ``junitxml`` plugin has rewritten to use ``xml.etree.ElementTree``.
+- :issue:`7536`: The internal ``junitxml`` plugin has rewritten to use ``xml.etree.ElementTree``.
   The order of attributes in XML elements might differ. Some unneeded escaping is
   no longer performed.
 
 
-- `#7587 <https://github.com/pytest-dev/pytest/issues/7587>`_: The dependency on the ``more-itertools`` package has been removed.
+- :issue:`7587`: The dependency on the ``more-itertools`` package has been removed.
 
 
-- `#7631 <https://github.com/pytest-dev/pytest/issues/7631>`_: The result type of :meth:`capfd.readouterr() <_pytest.capture.CaptureFixture.readouterr>` (and similar) is no longer a namedtuple,
+- :issue:`7631`: The result type of :meth:`capfd.readouterr() <_pytest.capture.CaptureFixture.readouterr>` (and similar) is no longer a namedtuple,
   but should behave like one in all respects. This was done for technical reasons.
 
 
-- `#7671 <https://github.com/pytest-dev/pytest/issues/7671>`_: When collecting tests, pytest finds test classes and functions by examining the
+- :issue:`7671`: When collecting tests, pytest finds test classes and functions by examining the
   attributes of python objects (modules, classes and instances). To speed up this
   process, pytest now ignores builtin attributes (like ``__class__``,
   ``__delattr__`` and ``__new__``) without consulting the :confval:`python_classes` and
   :confval:`python_functions` configuration options and without passing them to plugins
-  using the :func:`pytest_pycollect_makeitem <_pytest.hookspec.pytest_pycollect_makeitem>` hook.
+  using the :hook:`pytest_pycollect_makeitem` hook.
 
 
 pytest 6.0.2 (2020-09-04)
@@ -456,17 +1681,17 @@ pytest 6.0.2 (2020-09-04)
 Bug Fixes
 ---------
 
-- `#7148 <https://github.com/pytest-dev/pytest/issues/7148>`_: Fixed ``--log-cli`` potentially causing unrelated ``print`` output to be swallowed.
+- :issue:`7148`: Fixed ``--log-cli`` potentially causing unrelated ``print`` output to be swallowed.
 
 
-- `#7672 <https://github.com/pytest-dev/pytest/issues/7672>`_: Fixed log-capturing level restored incorrectly if ``caplog.set_level`` is called more than once.
+- :issue:`7672`: Fixed log-capturing level restored incorrectly if ``caplog.set_level`` is called more than once.
 
 
-- `#7686 <https://github.com/pytest-dev/pytest/issues/7686>`_: Fixed `NotSetType.token` being used as the parameter ID when the parametrization list is empty.
+- :issue:`7686`: Fixed `NotSetType.token` being used as the parameter ID when the parametrization list is empty.
   Regressed in pytest 6.0.0.
 
 
-- `#7707 <https://github.com/pytest-dev/pytest/issues/7707>`_: Fix internal error when handling some exceptions that contain multiple lines or the style uses multiple lines (``--tb=line`` for example).
+- :issue:`7707`: Fix internal error when handling some exceptions that contain multiple lines or the style uses multiple lines (``--tb=line`` for example).
 
 
 pytest 6.0.1 (2020-07-30)
@@ -475,18 +1700,18 @@ pytest 6.0.1 (2020-07-30)
 Bug Fixes
 ---------
 
-- `#7394 <https://github.com/pytest-dev/pytest/issues/7394>`_: Passing an empty ``help`` value to ``Parser.add_option`` is now accepted instead of crashing when running ``pytest --help``.
+- :issue:`7394`: Passing an empty ``help`` value to ``Parser.add_option`` is now accepted instead of crashing when running ``pytest --help``.
   Passing ``None`` raises a more informative ``TypeError``.
 
 
-- `#7558 <https://github.com/pytest-dev/pytest/issues/7558>`_: Fix pylint ``not-callable`` lint on ``pytest.mark.parametrize()`` and the other builtin marks:
+- :issue:`7558`: Fix pylint ``not-callable`` lint on ``pytest.mark.parametrize()`` and the other builtin marks:
   ``skip``, ``skipif``, ``xfail``, ``usefixtures``, ``filterwarnings``.
 
 
-- `#7559 <https://github.com/pytest-dev/pytest/issues/7559>`_: Fix regression in plugins using ``TestReport.longreprtext`` (such as ``pytest-html``) when ``TestReport.longrepr`` is not a string.
+- :issue:`7559`: Fix regression in plugins using ``TestReport.longreprtext`` (such as ``pytest-html``) when ``TestReport.longrepr`` is not a string.
 
 
-- `#7569 <https://github.com/pytest-dev/pytest/issues/7569>`_: Fix logging capture handler's level not reset on teardown after a call to ``caplog.set_level()``.
+- :issue:`7569`: Fix logging capture handler's level not reset on teardown after a call to ``caplog.set_level()``.
 
 
 pytest 6.0.0 (2020-07-28)
@@ -497,15 +1722,14 @@ pytest 6.0.0 (2020-07-28)
 Breaking Changes
 ----------------
 
-- `#5584 <https://github.com/pytest-dev/pytest/issues/5584>`_: **PytestDeprecationWarning are now errors by default.**
+- :issue:`5584`: **PytestDeprecationWarning are now errors by default.**
 
   Following our plan to remove deprecated features with as little disruption as
   possible, all warnings of type ``PytestDeprecationWarning`` now generate errors
   instead of warning messages.
 
   **The affected features will be effectively removed in pytest 6.1**, so please consult the
-  `Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__
-  section in the docs for directions on how to update existing code.
+  :std:doc:`deprecations` section in the docs for directions on how to update existing code.
 
   In the pytest ``6.0.X`` series, it is possible to change the errors back into warnings as a
   stopgap measure by adding this to your ``pytest.ini`` file:
@@ -519,61 +1743,61 @@ Breaking Changes
   But this will stop working when pytest ``6.1`` is released.
 
   **If you have concerns** about the removal of a specific feature, please add a
-  comment to `#5584 <https://github.com/pytest-dev/pytest/issues/5584>`__.
+  comment to :issue:`5584`.
 
 
-- `#7472 <https://github.com/pytest-dev/pytest/issues/7472>`_: The ``exec_()`` and ``is_true()`` methods of ``_pytest._code.Frame`` have been removed.
+- :issue:`7472`: The ``exec_()`` and ``is_true()`` methods of ``_pytest._code.Frame`` have been removed.
 
 
 
 Features
 --------
 
-- `#7464 <https://github.com/pytest-dev/pytest/issues/7464>`_: Added support for :envvar:`NO_COLOR` and :envvar:`FORCE_COLOR` environment variables to control colored output.
+- :issue:`7464`: Added support for :envvar:`NO_COLOR` and :envvar:`FORCE_COLOR` environment variables to control colored output.
 
 
 
 Improvements
 ------------
 
-- `#7467 <https://github.com/pytest-dev/pytest/issues/7467>`_: ``--log-file`` CLI option and ``log_file`` ini marker now create subdirectories if needed.
+- :issue:`7467`: ``--log-file`` CLI option and ``log_file`` ini marker now create subdirectories if needed.
 
 
-- `#7489 <https://github.com/pytest-dev/pytest/issues/7489>`_: The :func:`pytest.raises` function has a clearer error message when ``match`` equals the obtained string but is not a regex match. In this case it is suggested to escape the regex.
+- :issue:`7489`: The :func:`pytest.raises` function has a clearer error message when ``match`` equals the obtained string but is not a regex match. In this case it is suggested to escape the regex.
 
 
 
 Bug Fixes
 ---------
 
-- `#7392 <https://github.com/pytest-dev/pytest/issues/7392>`_: Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used.
+- :issue:`7392`: Fix the reported location of tests skipped with ``@pytest.mark.skip`` when ``--runxfail`` is used.
 
 
-- `#7491 <https://github.com/pytest-dev/pytest/issues/7491>`_: :fixture:`tmpdir` and :fixture:`tmp_path` no longer raise an error if the lock to check for
+- :issue:`7491`: :fixture:`tmpdir` and :fixture:`tmp_path` no longer raise an error if the lock to check for
   stale temporary directories is not accessible.
 
 
-- `#7517 <https://github.com/pytest-dev/pytest/issues/7517>`_: Preserve line endings when captured via ``capfd``.
+- :issue:`7517`: Preserve line endings when captured via ``capfd``.
 
 
-- `#7534 <https://github.com/pytest-dev/pytest/issues/7534>`_: Restored the previous formatting of ``TracebackEntry.__str__`` which was changed by accident.
+- :issue:`7534`: Restored the previous formatting of ``TracebackEntry.__str__`` which was changed by accident.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#7422 <https://github.com/pytest-dev/pytest/issues/7422>`_: Clarified when the ``usefixtures`` mark can apply fixtures to test.
+- :issue:`7422`: Clarified when the ``usefixtures`` mark can apply fixtures to test.
 
 
-- `#7441 <https://github.com/pytest-dev/pytest/issues/7441>`_: Add a note about ``-q`` option used in getting started guide.
+- :issue:`7441`: Add a note about ``-q`` option used in getting started guide.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#7389 <https://github.com/pytest-dev/pytest/issues/7389>`_: Fixture scope ``package`` is no longer considered experimental.
+- :issue:`7389`: Fixture scope ``package`` is no longer considered experimental.
 
 
 pytest 6.0.0rc1 (2020-07-08)
@@ -582,21 +1806,21 @@ pytest 6.0.0rc1 (2020-07-08)
 Breaking Changes
 ----------------
 
-- `#1316 <https://github.com/pytest-dev/pytest/issues/1316>`_: ``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was a ``str`` when a test failed with ``pytest.fail(..., pytrace=False)``.
+- :issue:`1316`: ``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was a ``str`` when a test failed with ``pytest.fail(..., pytrace=False)``.
 
 
-- `#5965 <https://github.com/pytest-dev/pytest/issues/5965>`_: symlinks are no longer resolved during collection and matching `conftest.py` files with test file paths.
+- :issue:`5965`: symlinks are no longer resolved during collection and matching `conftest.py` files with test file paths.
 
   Resolving symlinks for the current directory and during collection was introduced as a bugfix in 3.9.0, but it actually is a new feature which had unfortunate consequences in Windows and surprising results in other platforms.
 
   The team decided to step back on resolving symlinks at all, planning to review this in the future with a more solid solution (see discussion in
-  `#6523 <https://github.com/pytest-dev/pytest/pull/6523>`__ for details).
+  :pull:`6523` for details).
 
   This might break test suites which made use of this feature; the fix is to create a symlink
   for the entire test tree, and not only to partial files/tress as it was possible previously.
 
 
-- `#6505 <https://github.com/pytest-dev/pytest/issues/6505>`_: ``Testdir.run().parseoutcomes()`` now always returns the parsed nouns in plural form.
+- :issue:`6505`: ``Testdir.run().parseoutcomes()`` now always returns the parsed nouns in plural form.
 
   Originally ``parseoutcomes()`` would always returns the nouns in plural form, but a change
   meant to improve the terminal summary by using singular form single items (``1 warning`` or ``1 error``)
@@ -618,11 +1842,11 @@ Breaking Changes
       result.assert_outcomes(errors=1)
 
 
-- `#6903 <https://github.com/pytest-dev/pytest/issues/6903>`_: The ``os.dup()`` function is now assumed to exist. We are not aware of any
+- :issue:`6903`: The ``os.dup()`` function is now assumed to exist. We are not aware of any
   supported Python 3 implementations which do not provide it.
 
 
-- `#7040 <https://github.com/pytest-dev/pytest/issues/7040>`_: ``-k`` no longer matches against the names of the directories outside the test session root.
+- :issue:`7040`: ``-k`` no longer matches against the names of the directories outside the test session root.
 
   Also, ``pytest.Package.name`` is now just the name of the directory containing the package's
   ``__init__.py`` file, instead of the full path. This is consistent with how the other nodes
@@ -630,12 +1854,12 @@ Breaking Changes
   the test suite.
 
 
-- `#7122 <https://github.com/pytest-dev/pytest/issues/7122>`_: Expressions given to the ``-m`` and ``-k`` options are no longer evaluated using Python's :func:`eval`.
+- :issue:`7122`: Expressions given to the ``-m`` and ``-k`` options are no longer evaluated using Python's :func:`eval`.
   The format supports ``or``, ``and``, ``not``, parenthesis and general identifiers to match against.
   Python constants, keywords or other operators are no longer evaluated differently.
 
 
-- `#7135 <https://github.com/pytest-dev/pytest/issues/7135>`_: Pytest now uses its own ``TerminalWriter`` class instead of using the one from the ``py`` library.
+- :issue:`7135`: Pytest now uses its own ``TerminalWriter`` class instead of using the one from the ``py`` library.
   Plugins generally access this class through ``TerminalReporter.writer``, ``TerminalReporter.write()``
   (and similar methods), or ``_pytest.config.create_terminal_writer()``.
 
@@ -652,20 +1876,20 @@ Breaking Changes
   - Support for passing a callable instead of a file was removed.
 
 
-- `#7224 <https://github.com/pytest-dev/pytest/issues/7224>`_: The `item.catch_log_handler` and `item.catch_log_handlers` attributes, set by the
+- :issue:`7224`: The `item.catch_log_handler` and `item.catch_log_handlers` attributes, set by the
   logging plugin and never meant to be public, are no longer available.
 
   The deprecated ``--no-print-logs`` option and ``log_print`` ini option are removed. Use ``--show-capture`` instead.
 
 
-- `#7226 <https://github.com/pytest-dev/pytest/issues/7226>`_: Removed the unused ``args`` parameter from ``pytest.Function.__init__``.
+- :issue:`7226`: Removed the unused ``args`` parameter from ``pytest.Function.__init__``.
 
 
-- `#7418 <https://github.com/pytest-dev/pytest/issues/7418>`_: Removed the `pytest_doctest_prepare_content` hook specification. This hook
+- :issue:`7418`: Removed the `pytest_doctest_prepare_content` hook specification. This hook
   hasn't been triggered by pytest for at least 10 years.
 
 
-- `#7438 <https://github.com/pytest-dev/pytest/issues/7438>`_: Some changes were made to the internal ``_pytest._code.source``, listed here
+- :issue:`7438`: Some changes were made to the internal ``_pytest._code.source``, listed here
   for the benefit of plugin authors who may be using it:
 
   - The ``deindent`` argument to ``Source()`` has been removed, now it is always true.
@@ -682,19 +1906,19 @@ Breaking Changes
 Deprecations
 ------------
 
-- `#7210 <https://github.com/pytest-dev/pytest/issues/7210>`_: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
+- :issue:`7210`: The special ``-k '-expr'`` syntax to ``-k`` is deprecated. Use ``-k 'not expr'``
   instead.
 
   The special ``-k 'expr:'`` syntax to ``-k`` is deprecated. Please open an issue
   if you use this and want a replacement.
 
-- `#4049 <https://github.com/pytest-dev/pytest/issues/4049>`_: ``pytest_warning_captured`` is deprecated in favor of the ``pytest_warning_recorded`` hook.
+- :issue:`4049`: ``pytest_warning_captured`` is deprecated in favor of the ``pytest_warning_recorded`` hook.
 
 
 Features
 --------
 
-- `#1556 <https://github.com/pytest-dev/pytest/issues/1556>`_: pytest now supports ``pyproject.toml`` files for configuration.
+- :issue:`1556`: pytest now supports ``pyproject.toml`` files for configuration.
 
   The configuration options is similar to the one available in other formats, but must be defined
   in a ``[tool.pytest.ini_options]`` table to be picked up by pytest:
@@ -710,10 +1934,10 @@ Features
           "integration",
       ]
 
-  More information can be found `in the docs <https://docs.pytest.org/en/stable/customize.html#configuration-file-formats>`__.
+  More information can be found :ref:`in the docs <config file formats>`.
 
 
-- `#3342 <https://github.com/pytest-dev/pytest/issues/3342>`_: pytest now includes inline type annotations and exposes them to user programs.
+- :issue:`3342`: pytest now includes inline type annotations and exposes them to user programs.
   Most of the user-facing API is covered, as well as internal code.
 
   If you are running a type checker such as mypy on your tests, you may start
@@ -726,26 +1950,26 @@ Features
   pytest yet.
 
 
-- `#4049 <https://github.com/pytest-dev/pytest/issues/4049>`_: Introduced a new hook named `pytest_warning_recorded` to convey information about warnings captured by the internal `pytest` warnings plugin.
+- :issue:`4049`: Introduced a new hook named `pytest_warning_recorded` to convey information about warnings captured by the internal `pytest` warnings plugin.
 
   This hook is meant to replace `pytest_warning_captured`, which is deprecated and will be removed in a future release.
 
 
-- `#6471 <https://github.com/pytest-dev/pytest/issues/6471>`_: New command-line flags:
+- :issue:`6471`: New command-line flags:
 
   * `--no-header`: disables the initial header, including platform, version, and plugins.
   * `--no-summary`: disables the final test summary, including warnings.
 
 
-- `#6856 <https://github.com/pytest-dev/pytest/issues/6856>`_: A warning is now shown when an unknown key is read from a config INI file.
+- :issue:`6856`: A warning is now shown when an unknown key is read from a config INI file.
 
   The `--strict-config` flag has been added to treat these warnings as errors.
 
 
-- `#6906 <https://github.com/pytest-dev/pytest/issues/6906>`_: Added `--code-highlight` command line option to enable/disable code highlighting in terminal output.
+- :issue:`6906`: Added `--code-highlight` command line option to enable/disable code highlighting in terminal output.
 
 
-- `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`_: New ``--import-mode=importlib`` option that uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules.
+- :issue:`7245`: New ``--import-mode=importlib`` option that uses :mod:`importlib` to import test modules.
 
   Traditionally pytest used ``__import__`` while changing ``sys.path`` to import test modules (which
   also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules
@@ -756,33 +1980,33 @@ Features
   of the previous mode.
 
   We intend to make ``--import-mode=importlib`` the default in future versions, so users are encouraged
-  to try the new mode and provide feedback (both positive or negative) in issue `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`__.
+  to try the new mode and provide feedback (both positive or negative) in issue :issue:`7245`.
 
-  You can read more about this option in `the documentation <https://docs.pytest.org/en/latest/pythonpath.html#import-modes>`__.
+  You can read more about this option in :std:ref:`the documentation <import-modes>`.
 
 
-- `#7305 <https://github.com/pytest-dev/pytest/issues/7305>`_: New ``required_plugins`` configuration option allows the user to specify a list of plugins, including version information, that are required for pytest to run. An error is raised if any required plugins are not found when running pytest.
+- :issue:`7305`: New ``required_plugins`` configuration option allows the user to specify a list of plugins, including version information, that are required for pytest to run. An error is raised if any required plugins are not found when running pytest.
 
 
 Improvements
 ------------
 
-- `#4375 <https://github.com/pytest-dev/pytest/issues/4375>`_: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that
+- :issue:`4375`: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that
   is printed to stderr when the output of ``pytest`` is piped and and the pipe is
   closed by the piped-to program (common examples are ``less`` and ``head``).
 
 
-- `#4391 <https://github.com/pytest-dev/pytest/issues/4391>`_: Improved precision of test durations measurement. ``CallInfo`` items now have a new ``<CallInfo>.duration`` attribute, created using ``time.perf_counter()``. This attribute is used to fill the ``<TestReport>.duration`` attribute, which is more accurate than the previous ``<CallInfo>.stop - <CallInfo>.start`` (as these are based on ``time.time()``).
+- :issue:`4391`: Improved precision of test durations measurement. ``CallInfo`` items now have a new ``<CallInfo>.duration`` attribute, created using ``time.perf_counter()``. This attribute is used to fill the ``<TestReport>.duration`` attribute, which is more accurate than the previous ``<CallInfo>.stop - <CallInfo>.start`` (as these are based on ``time.time()``).
 
 
-- `#4675 <https://github.com/pytest-dev/pytest/issues/4675>`_: Rich comparison for dataclasses and `attrs`-classes is now recursive.
+- :issue:`4675`: Rich comparison for dataclasses and `attrs`-classes is now recursive.
 
 
-- `#6285 <https://github.com/pytest-dev/pytest/issues/6285>`_: Exposed the `pytest.FixtureLookupError` exception which is raised by `request.getfixturevalue()`
+- :issue:`6285`: Exposed the `pytest.FixtureLookupError` exception which is raised by `request.getfixturevalue()`
   (where `request` is a `FixtureRequest` fixture) when a fixture with the given name cannot be returned.
 
 
-- `#6433 <https://github.com/pytest-dev/pytest/issues/6433>`_: If an error is encountered while formatting the message in a logging call, for
+- :issue:`6433`: If an error is encountered while formatting the message in a logging call, for
   example ``logging.warning("oh no!: %s: %s", "first")`` (a second argument is
   missing), pytest now propagates the error, likely causing the test to fail.
 
@@ -790,44 +2014,44 @@ Improvements
   is not displayed by default for passing tests. This change makes the mistake
   visible during testing.
 
-  You may supress this behavior temporarily or permanently by setting
+  You may suppress this behavior temporarily or permanently by setting
   ``logging.raiseExceptions = False``.
 
 
-- `#6817 <https://github.com/pytest-dev/pytest/issues/6817>`_: Explicit new-lines in help texts of command-line options are preserved, allowing plugins better control
+- :issue:`6817`: Explicit new-lines in help texts of command-line options are preserved, allowing plugins better control
   of the help displayed to users.
 
 
-- `#6940 <https://github.com/pytest-dev/pytest/issues/6940>`_: When using the ``--duration`` option, the terminal message output is now more precise about the number and duration of hidden items.
+- :issue:`6940`: When using the ``--duration`` option, the terminal message output is now more precise about the number and duration of hidden items.
 
 
-- `#6991 <https://github.com/pytest-dev/pytest/issues/6991>`_: Collected files are displayed after any reports from hooks, e.g. the status from ``--lf``.
+- :issue:`6991`: Collected files are displayed after any reports from hooks, e.g. the status from ``--lf``.
 
 
-- `#7091 <https://github.com/pytest-dev/pytest/issues/7091>`_: When ``fd`` capturing is used, through ``--capture=fd`` or the ``capfd`` and
+- :issue:`7091`: When ``fd`` capturing is used, through ``--capture=fd`` or the ``capfd`` and
   ``capfdbinary`` fixtures, and the file descriptor (0, 1, 2) cannot be
   duplicated, FD capturing is still performed. Previously, direct writes to the
   file descriptors would fail or be lost in this case.
 
 
-- `#7119 <https://github.com/pytest-dev/pytest/issues/7119>`_: Exit with an error if the ``--basetemp`` argument is empty, is the current working directory or is one of the parent directories.
+- :issue:`7119`: Exit with an error if the ``--basetemp`` argument is empty, is the current working directory or is one of the parent directories.
   This is done to protect against accidental data loss, as any directory passed to this argument is cleared.
 
 
-- `#7128 <https://github.com/pytest-dev/pytest/issues/7128>`_: `pytest --version` now displays just the pytest version, while `pytest --version --version` displays more verbose information including plugins. This is more consistent with how other tools show `--version`.
+- :issue:`7128`: `pytest --version` now displays just the pytest version, while `pytest --version --version` displays more verbose information including plugins. This is more consistent with how other tools show `--version`.
 
 
-- `#7133 <https://github.com/pytest-dev/pytest/issues/7133>`_: :meth:`caplog.set_level() <_pytest.logging.LogCaptureFixture.set_level>` will now override any :confval:`log_level` set via the CLI or configuration file.
+- :issue:`7133`: :meth:`caplog.set_level() <_pytest.logging.LogCaptureFixture.set_level>` will now override any :confval:`log_level` set via the CLI or configuration file.
 
 
-- `#7159 <https://github.com/pytest-dev/pytest/issues/7159>`_: :meth:`caplog.set_level() <_pytest.logging.LogCaptureFixture.set_level>` and :meth:`caplog.at_level() <_pytest.logging.LogCaptureFixture.at_level>` no longer affect
+- :issue:`7159`: :meth:`caplog.set_level() <_pytest.logging.LogCaptureFixture.set_level>` and :meth:`caplog.at_level() <_pytest.logging.LogCaptureFixture.at_level>` no longer affect
   the level of logs that are shown in the *Captured log report* report section.
 
 
-- `#7348 <https://github.com/pytest-dev/pytest/issues/7348>`_: Improve recursive diff report for comparison asserts on dataclasses / attrs.
+- :issue:`7348`: Improve recursive diff report for comparison asserts on dataclasses / attrs.
 
 
-- `#7385 <https://github.com/pytest-dev/pytest/issues/7385>`_: ``--junitxml`` now includes the exception cause in the ``message`` XML attribute for failures during setup and teardown.
+- :issue:`7385`: ``--junitxml`` now includes the exception cause in the ``message`` XML attribute for failures during setup and teardown.
 
   Previously:
 
@@ -846,136 +2070,136 @@ Improvements
 Bug Fixes
 ---------
 
-- `#1120 <https://github.com/pytest-dev/pytest/issues/1120>`_: Fix issue where directories from :fixture:`tmpdir` are not removed properly when multiple instances of pytest are running in parallel.
+- :issue:`1120`: Fix issue where directories from :fixture:`tmpdir` are not removed properly when multiple instances of pytest are running in parallel.
 
 
-- `#4583 <https://github.com/pytest-dev/pytest/issues/4583>`_: Prevent crashing and provide a user-friendly error when a marker expression (`-m`) invoking of :func:`eval` raises any exception.
+- :issue:`4583`: Prevent crashing and provide a user-friendly error when a marker expression (`-m`) invoking of :func:`eval` raises any exception.
 
 
-- `#4677 <https://github.com/pytest-dev/pytest/issues/4677>`_: The path shown in the summary report for SKIPPED tests is now always relative. Previously it was sometimes absolute.
+- :issue:`4677`: The path shown in the summary report for SKIPPED tests is now always relative. Previously it was sometimes absolute.
 
 
-- `#5456 <https://github.com/pytest-dev/pytest/issues/5456>`_: Fix a possible race condition when trying to remove lock files used to control access to folders
+- :issue:`5456`: Fix a possible race condition when trying to remove lock files used to control access to folders
   created by :fixture:`tmp_path` and :fixture:`tmpdir`.
 
 
-- `#6240 <https://github.com/pytest-dev/pytest/issues/6240>`_: Fixes an issue where logging during collection step caused duplication of log
+- :issue:`6240`: Fixes an issue where logging during collection step caused duplication of log
   messages to stderr.
 
 
-- `#6428 <https://github.com/pytest-dev/pytest/issues/6428>`_: Paths appearing in error messages are now correct in case the current working directory has
+- :issue:`6428`: Paths appearing in error messages are now correct in case the current working directory has
   changed since the start of the session.
 
 
-- `#6755 <https://github.com/pytest-dev/pytest/issues/6755>`_: Support deleting paths longer than 260 characters on windows created inside :fixture:`tmpdir`.
+- :issue:`6755`: Support deleting paths longer than 260 characters on windows created inside :fixture:`tmpdir`.
 
 
-- `#6871 <https://github.com/pytest-dev/pytest/issues/6871>`_: Fix crash with captured output when using :fixture:`capsysbinary`.
+- :issue:`6871`: Fix crash with captured output when using :fixture:`capsysbinary`.
 
 
-- `#6909 <https://github.com/pytest-dev/pytest/issues/6909>`_: Revert the change introduced by `#6330 <https://github.com/pytest-dev/pytest/pull/6330>`_, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature.
+- :issue:`6909`: Revert the change introduced by :pull:`6330`, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature.
 
   The intention of the original change was to remove what was expected to be an unintended/surprising behavior, but it turns out many people relied on it, so the restriction has been reverted.
 
 
-- `#6910 <https://github.com/pytest-dev/pytest/issues/6910>`_: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option.
+- :issue:`6910`: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option.
 
 
-- `#6924 <https://github.com/pytest-dev/pytest/issues/6924>`_: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited.
+- :issue:`6924`: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited.
 
 
-- `#6925 <https://github.com/pytest-dev/pytest/issues/6925>`_: Fix `TerminalRepr` instances to be hashable again.
+- :issue:`6925`: Fix `TerminalRepr` instances to be hashable again.
 
 
-- `#6947 <https://github.com/pytest-dev/pytest/issues/6947>`_: Fix regression where functions registered with :meth:`unittest.TestCase.addCleanup` were not being called on test failures.
+- :issue:`6947`: Fix regression where functions registered with :meth:`unittest.TestCase.addCleanup` were not being called on test failures.
 
 
-- `#6951 <https://github.com/pytest-dev/pytest/issues/6951>`_: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute.
+- :issue:`6951`: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute.
 
 
-- `#6956 <https://github.com/pytest-dev/pytest/issues/6956>`_: Prevent pytest from printing `ConftestImportFailure` traceback to stdout.
+- :issue:`6956`: Prevent pytest from printing `ConftestImportFailure` traceback to stdout.
 
 
-- `#6991 <https://github.com/pytest-dev/pytest/issues/6991>`_: Fix regressions with `--lf` filtering too much since pytest 5.4.
+- :issue:`6991`: Fix regressions with `--lf` filtering too much since pytest 5.4.
 
 
-- `#6992 <https://github.com/pytest-dev/pytest/issues/6992>`_: Revert "tmpdir: clean up indirection via config for factories" `#6767 <https://github.com/pytest-dev/pytest/issues/6767>`_ as it breaks pytest-xdist.
+- :issue:`6992`: Revert "tmpdir: clean up indirection via config for factories" :issue:`6767` as it breaks pytest-xdist.
 
 
-- `#7061 <https://github.com/pytest-dev/pytest/issues/7061>`_: When a yielding fixture fails to yield a value, report a test setup error instead of crashing.
+- :issue:`7061`: When a yielding fixture fails to yield a value, report a test setup error instead of crashing.
 
 
-- `#7076 <https://github.com/pytest-dev/pytest/issues/7076>`_: The path of file skipped by ``@pytest.mark.skip`` in the SKIPPED report is now relative to invocation directory. Previously it was relative to root directory.
+- :issue:`7076`: The path of file skipped by ``@pytest.mark.skip`` in the SKIPPED report is now relative to invocation directory. Previously it was relative to root directory.
 
 
-- `#7110 <https://github.com/pytest-dev/pytest/issues/7110>`_: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
+- :issue:`7110`: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
 
 
-- `#7126 <https://github.com/pytest-dev/pytest/issues/7126>`_: ``--setup-show`` now doesn't raise an error when a bytes value is used as a ``parametrize``
+- :issue:`7126`: ``--setup-show`` now doesn't raise an error when a bytes value is used as a ``parametrize``
   parameter when Python is called with the ``-bb`` flag.
 
 
-- `#7143 <https://github.com/pytest-dev/pytest/issues/7143>`_: Fix :meth:`pytest.File.from_parent` so it forwards extra keyword arguments to the constructor.
+- :issue:`7143`: Fix :meth:`pytest.File.from_parent` so it forwards extra keyword arguments to the constructor.
 
 
-- `#7145 <https://github.com/pytest-dev/pytest/issues/7145>`_: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
+- :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
 
 
-- `#7150 <https://github.com/pytest-dev/pytest/issues/7150>`_: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.
+- :issue:`7150`: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.
 
 
-- `#7180 <https://github.com/pytest-dev/pytest/issues/7180>`_: Fix ``_is_setup_py`` for files encoded differently than locale.
+- :issue:`7180`: Fix ``_is_setup_py`` for files encoded differently than locale.
 
 
-- `#7215 <https://github.com/pytest-dev/pytest/issues/7215>`_: Fix regression where running with ``--pdb`` would call :meth:`unittest.TestCase.tearDown` for skipped tests.
+- :issue:`7215`: Fix regression where running with ``--pdb`` would call :meth:`unittest.TestCase.tearDown` for skipped tests.
 
 
-- `#7253 <https://github.com/pytest-dev/pytest/issues/7253>`_: When using ``pytest.fixture`` on a function directly, as in ``pytest.fixture(func)``,
+- :issue:`7253`: When using ``pytest.fixture`` on a function directly, as in ``pytest.fixture(func)``,
   if the ``autouse`` or ``params`` arguments are also passed, the function is no longer
   ignored, but is marked as a fixture.
 
 
-- `#7360 <https://github.com/pytest-dev/pytest/issues/7360>`_: Fix possibly incorrect evaluation of string expressions passed to ``pytest.mark.skipif`` and ``pytest.mark.xfail``,
+- :issue:`7360`: Fix possibly incorrect evaluation of string expressions passed to ``pytest.mark.skipif`` and ``pytest.mark.xfail``,
   in rare circumstances where the exact same string is used but refers to different global values.
 
 
-- `#7383 <https://github.com/pytest-dev/pytest/issues/7383>`_: Fixed exception causes all over the codebase, i.e. use `raise new_exception from old_exception` when wrapping an exception.
+- :issue:`7383`: Fixed exception causes all over the codebase, i.e. use `raise new_exception from old_exception` when wrapping an exception.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#7202 <https://github.com/pytest-dev/pytest/issues/7202>`_: The development guide now links to the contributing section of the docs and `RELEASING.rst` on GitHub.
+- :issue:`7202`: The development guide now links to the contributing section of the docs and `RELEASING.rst` on GitHub.
 
 
-- `#7233 <https://github.com/pytest-dev/pytest/issues/7233>`_: Add a note about ``--strict`` and ``--strict-markers`` and the preference for the latter one.
+- :issue:`7233`: Add a note about ``--strict`` and ``--strict-markers`` and the preference for the latter one.
 
 
-- `#7345 <https://github.com/pytest-dev/pytest/issues/7345>`_: Explain indirect parametrization and markers for fixtures.
+- :issue:`7345`: Explain indirect parametrization and markers for fixtures.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#7035 <https://github.com/pytest-dev/pytest/issues/7035>`_: The ``originalname`` attribute of ``_pytest.python.Function`` now defaults to ``name`` if not
+- :issue:`7035`: The ``originalname`` attribute of ``_pytest.python.Function`` now defaults to ``name`` if not
   provided explicitly, and is always set.
 
 
-- `#7264 <https://github.com/pytest-dev/pytest/issues/7264>`_: The dependency on the ``wcwidth`` package has been removed.
+- :issue:`7264`: The dependency on the ``wcwidth`` package has been removed.
 
 
-- `#7291 <https://github.com/pytest-dev/pytest/issues/7291>`_: Replaced ``py.iniconfig`` with `iniconfig <https://pypi.org/project/iniconfig/>`__.
+- :issue:`7291`: Replaced ``py.iniconfig`` with :pypi:`iniconfig`.
 
 
-- `#7295 <https://github.com/pytest-dev/pytest/issues/7295>`_: ``src/_pytest/config/__init__.py`` now uses the ``warnings`` module to report warnings instead of ``sys.stderr.write``.
+- :issue:`7295`: ``src/_pytest/config/__init__.py`` now uses the ``warnings`` module to report warnings instead of ``sys.stderr.write``.
 
 
-- `#7356 <https://github.com/pytest-dev/pytest/issues/7356>`_: Remove last internal uses of deprecated *slave* term from old ``pytest-xdist``.
+- :issue:`7356`: Remove last internal uses of deprecated *slave* term from old ``pytest-xdist``.
 
 
-- `#7357 <https://github.com/pytest-dev/pytest/issues/7357>`_: ``py``>=1.8.2 is now required.
+- :issue:`7357`: ``py``>=1.8.2 is now required.
 
 
 pytest 5.4.3 (2020-06-02)
@@ -984,20 +2208,20 @@ pytest 5.4.3 (2020-06-02)
 Bug Fixes
 ---------
 
-- `#6428 <https://github.com/pytest-dev/pytest/issues/6428>`_: Paths appearing in error messages are now correct in case the current working directory has
+- :issue:`6428`: Paths appearing in error messages are now correct in case the current working directory has
   changed since the start of the session.
 
 
-- `#6755 <https://github.com/pytest-dev/pytest/issues/6755>`_: Support deleting paths longer than 260 characters on windows created inside tmpdir.
+- :issue:`6755`: Support deleting paths longer than 260 characters on windows created inside tmpdir.
 
 
-- `#6956 <https://github.com/pytest-dev/pytest/issues/6956>`_: Prevent pytest from printing ConftestImportFailure traceback to stdout.
+- :issue:`6956`: Prevent pytest from printing ConftestImportFailure traceback to stdout.
 
 
-- `#7150 <https://github.com/pytest-dev/pytest/issues/7150>`_: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.
+- :issue:`7150`: Prevent hiding the underlying exception when ``ConfTestImportFailure`` is raised.
 
 
-- `#7215 <https://github.com/pytest-dev/pytest/issues/7215>`_: Fix regression where running with ``--pdb`` would call the ``tearDown`` methods of ``unittest.TestCase``
+- :issue:`7215`: Fix regression where running with ``--pdb`` would call the ``tearDown`` methods of ``unittest.TestCase``
   subclasses for skipped tests.
 
 
@@ -1007,34 +2231,34 @@ pytest 5.4.2 (2020-05-08)
 Bug Fixes
 ---------
 
-- `#6871 <https://github.com/pytest-dev/pytest/issues/6871>`_: Fix crash with captured output when using the :fixture:`capsysbinary fixture <capsysbinary>`.
+- :issue:`6871`: Fix crash with captured output when using the :fixture:`capsysbinary fixture <capsysbinary>`.
 
 
-- `#6924 <https://github.com/pytest-dev/pytest/issues/6924>`_: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited.
+- :issue:`6924`: Ensure a ``unittest.IsolatedAsyncioTestCase`` is actually awaited.
 
 
-- `#6925 <https://github.com/pytest-dev/pytest/issues/6925>`_: Fix TerminalRepr instances to be hashable again.
+- :issue:`6925`: Fix TerminalRepr instances to be hashable again.
 
 
-- `#6947 <https://github.com/pytest-dev/pytest/issues/6947>`_: Fix regression where functions registered with ``TestCase.addCleanup`` were not being called on test failures.
+- :issue:`6947`: Fix regression where functions registered with ``TestCase.addCleanup`` were not being called on test failures.
 
 
-- `#6951 <https://github.com/pytest-dev/pytest/issues/6951>`_: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute.
+- :issue:`6951`: Allow users to still set the deprecated ``TerminalReporter.writer`` attribute.
 
 
-- `#6992 <https://github.com/pytest-dev/pytest/issues/6992>`_: Revert "tmpdir: clean up indirection via config for factories" #6767 as it breaks pytest-xdist.
+- :issue:`6992`: Revert "tmpdir: clean up indirection via config for factories" #6767 as it breaks pytest-xdist.
 
 
-- `#7110 <https://github.com/pytest-dev/pytest/issues/7110>`_: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
+- :issue:`7110`: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
 
 
-- `#7143 <https://github.com/pytest-dev/pytest/issues/7143>`_: Fix ``File.from_constructor`` so it forwards extra keyword arguments to the constructor.
+- :issue:`7143`: Fix ``File.from_parent`` so it forwards extra keyword arguments to the constructor.
 
 
-- `#7145 <https://github.com/pytest-dev/pytest/issues/7145>`_: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
+- :issue:`7145`: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
 
 
-- `#7180 <https://github.com/pytest-dev/pytest/issues/7180>`_: Fix ``_is_setup_py`` for files encoded differently than locale.
+- :issue:`7180`: Fix ``_is_setup_py`` for files encoded differently than locale.
 
 
 pytest 5.4.1 (2020-03-13)
@@ -1043,12 +2267,12 @@ pytest 5.4.1 (2020-03-13)
 Bug Fixes
 ---------
 
-- `#6909 <https://github.com/pytest-dev/pytest/issues/6909>`_: Revert the change introduced by `#6330 <https://github.com/pytest-dev/pytest/pull/6330>`_, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature.
+- :issue:`6909`: Revert the change introduced by :pull:`6330`, which required all arguments to ``@pytest.mark.parametrize`` to be explicitly defined in the function signature.
 
   The intention of the original change was to remove what was expected to be an unintended/surprising behavior, but it turns out many people relied on it, so the restriction has been reverted.
 
 
-- `#6910 <https://github.com/pytest-dev/pytest/issues/6910>`_: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option.
+- :issue:`6910`: Fix crash when plugins return an unknown stats while using the ``--reportlog`` option.
 
 
 pytest 5.4.0 (2020-03-12)
@@ -1057,23 +2281,23 @@ pytest 5.4.0 (2020-03-12)
 Breaking Changes
 ----------------
 
-- `#6316 <https://github.com/pytest-dev/pytest/issues/6316>`_: Matching of ``-k EXPRESSION`` to test names is now case-insensitive.
+- :issue:`6316`: Matching of ``-k EXPRESSION`` to test names is now case-insensitive.
 
 
-- `#6443 <https://github.com/pytest-dev/pytest/issues/6443>`_: Plugins specified with ``-p`` are now loaded after internal plugins, which results in their hooks being called *before* the internal ones.
+- :issue:`6443`: Plugins specified with ``-p`` are now loaded after internal plugins, which results in their hooks being called *before* the internal ones.
 
   This makes the ``-p`` behavior consistent with ``PYTEST_PLUGINS``.
 
 
-- `#6637 <https://github.com/pytest-dev/pytest/issues/6637>`_: Removed the long-deprecated ``pytest_itemstart`` hook.
+- :issue:`6637`: Removed the long-deprecated ``pytest_itemstart`` hook.
 
   This hook has been marked as deprecated and not been even called by pytest for over 10 years now.
 
 
-- `#6673 <https://github.com/pytest-dev/pytest/issues/6673>`_: Reversed / fix meaning of "+/-" in error diffs.  "-" means that sth. expected is missing in the result and "+" means that there are unexpected extras in the result.
+- :issue:`6673`: Reversed / fix meaning of "+/-" in error diffs.  "-" means that sth. expected is missing in the result and "+" means that there are unexpected extras in the result.
 
 
-- `#6737 <https://github.com/pytest-dev/pytest/issues/6737>`_: The ``cached_result`` attribute of ``FixtureDef`` is now set to ``None`` when
+- :issue:`6737`: The ``cached_result`` attribute of ``FixtureDef`` is now set to ``None`` when
   the result is unavailable, instead of being deleted.
 
   If your plugin performs checks like ``hasattr(fixturedef, 'cached_result')``,
@@ -1086,19 +2310,19 @@ Breaking Changes
 Deprecations
 ------------
 
-- `#3238 <https://github.com/pytest-dev/pytest/issues/3238>`_: Option ``--no-print-logs`` is deprecated and meant to be removed in a future release. If you use ``--no-print-logs``, please try out ``--show-capture`` and
+- :issue:`3238`: Option ``--no-print-logs`` is deprecated and meant to be removed in a future release. If you use ``--no-print-logs``, please try out ``--show-capture`` and
   provide feedback.
 
   ``--show-capture`` command-line option was added in ``pytest 3.5.0`` and allows to specify how to
   display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
 
 
-- `#571 <https://github.com/pytest-dev/pytest/issues/571>`_: Deprecate the unused/broken `pytest_collect_directory` hook.
+- :issue:`571`: Deprecate the unused/broken `pytest_collect_directory` hook.
   It was misaligned since the removal of the ``Directory`` collector in 2010
   and incorrect/unusable as soon as collection was split from test execution.
 
 
-- `#5975 <https://github.com/pytest-dev/pytest/issues/5975>`_: Deprecate using direct constructors for ``Nodes``.
+- :issue:`5975`: Deprecate using direct constructors for ``Nodes``.
 
   Instead they are now constructed via ``Node.from_parent``.
 
@@ -1110,7 +2334,7 @@ Deprecations
   Subclasses are expected to use `super().from_parent` if they intend to expand the creation of `Nodes`.
 
 
-- `#6779 <https://github.com/pytest-dev/pytest/issues/6779>`_: The ``TerminalReporter.writer`` attribute has been deprecated and should no longer be used. This
+- :issue:`6779`: The ``TerminalReporter.writer`` attribute has been deprecated and should no longer be used. This
   was inadvertently exposed as part of the public API of that plugin and ties it too much
   with ``py.io.TerminalWriter``.
 
@@ -1119,153 +2343,153 @@ Deprecations
 Features
 --------
 
-- `#4597 <https://github.com/pytest-dev/pytest/issues/4597>`_: New :ref:`--capture=tee-sys <capture-method>` option to allow both live printing and capturing of test output.
+- :issue:`4597`: New :ref:`--capture=tee-sys <capture-method>` option to allow both live printing and capturing of test output.
 
 
-- `#5712 <https://github.com/pytest-dev/pytest/issues/5712>`_: Now all arguments to ``@pytest.mark.parametrize`` need to be explicitly declared in the function signature or via ``indirect``.
+- :issue:`5712`: Now all arguments to ``@pytest.mark.parametrize`` need to be explicitly declared in the function signature or via ``indirect``.
   Previously it was possible to omit an argument if a fixture with the same name existed, which was just an accident of implementation and was not meant to be a part of the API.
 
 
-- `#6454 <https://github.com/pytest-dev/pytest/issues/6454>`_: Changed default for `-r` to `fE`, which displays failures and errors in the :ref:`short test summary <pytest.detailed_failed_tests_usage>`.  `-rN` can be used to disable it (the old behavior).
+- :issue:`6454`: Changed default for `-r` to `fE`, which displays failures and errors in the :ref:`short test summary <pytest.detailed_failed_tests_usage>`.  `-rN` can be used to disable it (the old behavior).
 
 
-- `#6469 <https://github.com/pytest-dev/pytest/issues/6469>`_: New options have been added to the :confval:`junit_logging` option: ``log``, ``out-err``, and ``all``.
+- :issue:`6469`: New options have been added to the :confval:`junit_logging` option: ``log``, ``out-err``, and ``all``.
 
 
-- `#6834 <https://github.com/pytest-dev/pytest/issues/6834>`_: Excess warning summaries are now collapsed per file to ensure readable display of warning summaries.
+- :issue:`6834`: Excess warning summaries are now collapsed per file to ensure readable display of warning summaries.
 
 
 
 Improvements
 ------------
 
-- `#1857 <https://github.com/pytest-dev/pytest/issues/1857>`_: ``pytest.mark.parametrize`` accepts integers for ``ids`` again, converting it to strings.
+- :issue:`1857`: ``pytest.mark.parametrize`` accepts integers for ``ids`` again, converting it to strings.
 
 
-- `#449 <https://github.com/pytest-dev/pytest/issues/449>`_: Use "yellow" main color with any XPASSED tests.
+- :issue:`449`: Use "yellow" main color with any XPASSED tests.
 
 
-- `#4639 <https://github.com/pytest-dev/pytest/issues/4639>`_: Revert "A warning is now issued when assertions are made for ``None``".
+- :issue:`4639`: Revert "A warning is now issued when assertions are made for ``None``".
 
   The warning proved to be less useful than initially expected and had quite a
   few false positive cases.
 
 
-- `#5686 <https://github.com/pytest-dev/pytest/issues/5686>`_: ``tmpdir_factory.mktemp`` now fails when given absolute and non-normalized paths.
+- :issue:`5686`: ``tmpdir_factory.mktemp`` now fails when given absolute and non-normalized paths.
 
 
-- `#5984 <https://github.com/pytest-dev/pytest/issues/5984>`_: The ``pytest_warning_captured`` hook now receives a ``location`` parameter with the code location that generated the warning.
+- :issue:`5984`: The ``pytest_warning_captured`` hook now receives a ``location`` parameter with the code location that generated the warning.
 
 
-- `#6213 <https://github.com/pytest-dev/pytest/issues/6213>`_: pytester: the ``testdir`` fixture respects environment settings from the ``monkeypatch`` fixture for inner runs.
+- :issue:`6213`: pytester: the ``testdir`` fixture respects environment settings from the ``monkeypatch`` fixture for inner runs.
 
 
-- `#6247 <https://github.com/pytest-dev/pytest/issues/6247>`_: ``--fulltrace`` is honored with collection errors.
+- :issue:`6247`: ``--fulltrace`` is honored with collection errors.
 
 
-- `#6384 <https://github.com/pytest-dev/pytest/issues/6384>`_: Make `--showlocals` work also with `--tb=short`.
+- :issue:`6384`: Make `--showlocals` work also with `--tb=short`.
 
 
-- `#6653 <https://github.com/pytest-dev/pytest/issues/6653>`_: Add support for matching lines consecutively with :attr:`LineMatcher <_pytest.pytester.LineMatcher>`'s :func:`~_pytest.pytester.LineMatcher.fnmatch_lines` and :func:`~_pytest.pytester.LineMatcher.re_match_lines`.
+- :issue:`6653`: Add support for matching lines consecutively with :attr:`LineMatcher <_pytest.pytester.LineMatcher>`'s :func:`~_pytest.pytester.LineMatcher.fnmatch_lines` and :func:`~_pytest.pytester.LineMatcher.re_match_lines`.
 
 
-- `#6658 <https://github.com/pytest-dev/pytest/issues/6658>`_: Code is now highlighted in tracebacks when ``pygments`` is installed.
+- :issue:`6658`: Code is now highlighted in tracebacks when ``pygments`` is installed.
 
   Users are encouraged to install ``pygments`` into their environment and provide feedback, because
   the plan is to make ``pygments`` a regular dependency in the future.
 
 
-- `#6795 <https://github.com/pytest-dev/pytest/issues/6795>`_: Import usage error message with invalid `-o` option.
+- :issue:`6795`: Import usage error message with invalid `-o` option.
 
 
-- `#759 <https://github.com/pytest-dev/pytest/issues/759>`_: ``pytest.mark.parametrize`` supports iterators and generators for ``ids``.
+- :issue:`759`: ``pytest.mark.parametrize`` supports iterators and generators for ``ids``.
 
 
 
 Bug Fixes
 ---------
 
-- `#310 <https://github.com/pytest-dev/pytest/issues/310>`_: Add support for calling `pytest.xfail()` and `pytest.importorskip()` with doctests.
+- :issue:`310`: Add support for calling `pytest.xfail()` and `pytest.importorskip()` with doctests.
 
 
-- `#3823 <https://github.com/pytest-dev/pytest/issues/3823>`_: ``--trace`` now works with unittests.
+- :issue:`3823`: ``--trace`` now works with unittests.
 
 
-- `#4445 <https://github.com/pytest-dev/pytest/issues/4445>`_: Fixed some warning reports produced by pytest to point to the correct location of the warning in the user's code.
+- :issue:`4445`: Fixed some warning reports produced by pytest to point to the correct location of the warning in the user's code.
 
 
-- `#5301 <https://github.com/pytest-dev/pytest/issues/5301>`_: Fix ``--last-failed`` to collect new tests from files with known failures.
+- :issue:`5301`: Fix ``--last-failed`` to collect new tests from files with known failures.
 
 
-- `#5928 <https://github.com/pytest-dev/pytest/issues/5928>`_: Report ``PytestUnknownMarkWarning`` at the level of the user's code, not ``pytest``'s.
+- :issue:`5928`: Report ``PytestUnknownMarkWarning`` at the level of the user's code, not ``pytest``'s.
 
 
-- `#5991 <https://github.com/pytest-dev/pytest/issues/5991>`_: Fix interaction with ``--pdb`` and unittests: do not use unittest's ``TestCase.debug()``.
+- :issue:`5991`: Fix interaction with ``--pdb`` and unittests: do not use unittest's ``TestCase.debug()``.
 
 
-- `#6334 <https://github.com/pytest-dev/pytest/issues/6334>`_: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
+- :issue:`6334`: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
 
   The upper case variants were never documented and the preferred form should be the lower case.
 
 
-- `#6409 <https://github.com/pytest-dev/pytest/issues/6409>`_: Fallback to green (instead of yellow) for non-last items without previous passes with colored terminal progress indicator.
+- :issue:`6409`: Fallback to green (instead of yellow) for non-last items without previous passes with colored terminal progress indicator.
 
 
-- `#6454 <https://github.com/pytest-dev/pytest/issues/6454>`_: `--disable-warnings` is honored with `-ra` and `-rA`.
+- :issue:`6454`: `--disable-warnings` is honored with `-ra` and `-rA`.
 
 
-- `#6497 <https://github.com/pytest-dev/pytest/issues/6497>`_: Fix bug in the comparison of request key with cached key in fixture.
+- :issue:`6497`: Fix bug in the comparison of request key with cached key in fixture.
 
-  A construct ``if key == cached_key:`` can fail either because ``==`` is explicitly disallowed, or for, e.g., NumPy arrays, where the result of ``a == b`` cannot generally be converted to `bool`.
+  A construct ``if key == cached_key:`` can fail either because ``==`` is explicitly disallowed, or for, e.g., NumPy arrays, where the result of ``a == b`` cannot generally be converted to :class:`bool`.
   The implemented fix replaces `==` with ``is``.
 
 
-- `#6557 <https://github.com/pytest-dev/pytest/issues/6557>`_: Make capture output streams ``.write()`` method return the same return value from original streams.
+- :issue:`6557`: Make capture output streams ``.write()`` method return the same return value from original streams.
 
 
-- `#6566 <https://github.com/pytest-dev/pytest/issues/6566>`_: Fix ``EncodedFile.writelines`` to call the underlying buffer's ``writelines`` method.
+- :issue:`6566`: Fix ``EncodedFile.writelines`` to call the underlying buffer's ``writelines`` method.
 
 
-- `#6575 <https://github.com/pytest-dev/pytest/issues/6575>`_: Fix internal crash when ``faulthandler`` starts initialized
+- :issue:`6575`: Fix internal crash when ``faulthandler`` starts initialized
   (for example with ``PYTHONFAULTHANDLER=1`` environment variable set) and ``faulthandler_timeout`` defined
   in the configuration file.
 
 
-- `#6597 <https://github.com/pytest-dev/pytest/issues/6597>`_: Fix node ids which contain a parametrized empty-string variable.
+- :issue:`6597`: Fix node ids which contain a parametrized empty-string variable.
 
 
-- `#6646 <https://github.com/pytest-dev/pytest/issues/6646>`_: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's :func:`testdir.runpytest <_pytest.pytester.Testdir.runpytest>` etc.
+- :issue:`6646`: Assertion rewriting hooks are (re)stored for the current item, which fixes them being still used after e.g. pytester's :func:`testdir.runpytest <_pytest.pytester.Testdir.runpytest>` etc.
 
 
-- `#6660 <https://github.com/pytest-dev/pytest/issues/6660>`_: :py:func:`pytest.exit` is handled when emitted from the :func:`pytest_sessionfinish <_pytest.hookspec.pytest_sessionfinish>` hook.  This includes quitting from a debugger.
+- :issue:`6660`: :py:func:`pytest.exit` is handled when emitted from the :hook:`pytest_sessionfinish` hook.  This includes quitting from a debugger.
 
 
-- `#6752 <https://github.com/pytest-dev/pytest/issues/6752>`_: When :py:func:`pytest.raises` is used as a function (as opposed to a context manager),
+- :issue:`6752`: When :py:func:`pytest.raises` is used as a function (as opposed to a context manager),
   a `match` keyword argument is now passed through to the tested function. Previously
   it was swallowed and ignored (regression in pytest 5.1.0).
 
 
-- `#6801 <https://github.com/pytest-dev/pytest/issues/6801>`_: Do not display empty lines inbetween traceback for unexpected exceptions with doctests.
+- :issue:`6801`: Do not display empty lines in between traceback for unexpected exceptions with doctests.
 
 
-- `#6802 <https://github.com/pytest-dev/pytest/issues/6802>`_: The :fixture:`testdir fixture <testdir>` works within doctests now.
+- :issue:`6802`: The :fixture:`testdir fixture <testdir>` works within doctests now.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#6696 <https://github.com/pytest-dev/pytest/issues/6696>`_: Add list of fixtures to start of fixture chapter.
+- :issue:`6696`: Add list of fixtures to start of fixture chapter.
 
 
-- `#6742 <https://github.com/pytest-dev/pytest/issues/6742>`_: Expand first sentence on fixtures into a paragraph.
+- :issue:`6742`: Expand first sentence on fixtures into a paragraph.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#6404 <https://github.com/pytest-dev/pytest/issues/6404>`_: Remove usage of ``parser`` module, deprecated in Python 3.9.
+- :issue:`6404`: Remove usage of ``parser`` module, deprecated in Python 3.9.
 
 
 pytest 5.3.5 (2020-01-29)
@@ -1274,7 +2498,7 @@ pytest 5.3.5 (2020-01-29)
 Bug Fixes
 ---------
 
-- `#6517 <https://github.com/pytest-dev/pytest/issues/6517>`_: Fix regression in pytest 5.3.4 causing an INTERNALERROR due to a wrong assertion.
+- :issue:`6517`: Fix regression in pytest 5.3.4 causing an INTERNALERROR due to a wrong assertion.
 
 
 pytest 5.3.4 (2020-01-20)
@@ -1283,7 +2507,7 @@ pytest 5.3.4 (2020-01-20)
 Bug Fixes
 ---------
 
-- `#6496 <https://github.com/pytest-dev/pytest/issues/6496>`_: Revert `#6436 <https://github.com/pytest-dev/pytest/issues/6436>`__: unfortunately this change has caused a number of regressions in many suites,
+- :issue:`6496`: Revert :issue:`6436`: unfortunately this change has caused a number of regressions in many suites,
   so the team decided to revert this change and make a new release while we continue to look for a solution.
 
 
@@ -1293,26 +2517,26 @@ pytest 5.3.3 (2020-01-16)
 Bug Fixes
 ---------
 
-- `#2780 <https://github.com/pytest-dev/pytest/issues/2780>`_: Captured output during teardown is shown with ``-rP``.
+- :issue:`2780`: Captured output during teardown is shown with ``-rP``.
 
 
-- `#5971 <https://github.com/pytest-dev/pytest/issues/5971>`_: Fix a ``pytest-xdist`` crash when dealing with exceptions raised in subprocesses created by the
+- :issue:`5971`: Fix a ``pytest-xdist`` crash when dealing with exceptions raised in subprocesses created by the
   ``multiprocessing`` module.
 
 
-- `#6436 <https://github.com/pytest-dev/pytest/issues/6436>`_: :class:`FixtureDef <_pytest.fixtures.FixtureDef>` objects now properly register their finalizers with autouse and
+- :issue:`6436`: :class:`FixtureDef <_pytest.fixtures.FixtureDef>` objects now properly register their finalizers with autouse and
   parameterized fixtures that execute before them in the fixture stack so they are torn
   down at the right times, and in the right order.
 
 
-- `#6532 <https://github.com/pytest-dev/pytest/issues/6532>`_: Fix parsing of outcomes containing multiple errors with ``testdir`` results (regression in 5.3.0).
+- :issue:`6532`: Fix parsing of outcomes containing multiple errors with ``testdir`` results (regression in 5.3.0).
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#6350 <https://github.com/pytest-dev/pytest/issues/6350>`_: Optimized automatic renaming of test parameter IDs.
+- :issue:`6350`: Optimized automatic renaming of test parameter IDs.
 
 
 pytest 5.3.2 (2019-12-13)
@@ -1321,7 +2545,7 @@ pytest 5.3.2 (2019-12-13)
 Improvements
 ------------
 
-- `#4639 <https://github.com/pytest-dev/pytest/issues/4639>`_: Revert "A warning is now issued when assertions are made for ``None``".
+- :issue:`4639`: Revert "A warning is now issued when assertions are made for ``None``".
 
   The warning proved to be less useful than initially expected and had quite a
   few false positive cases.
@@ -1331,13 +2555,13 @@ Improvements
 Bug Fixes
 ---------
 
-- `#5430 <https://github.com/pytest-dev/pytest/issues/5430>`_: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
+- :issue:`5430`: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
 
 
-- `#6290 <https://github.com/pytest-dev/pytest/issues/6290>`_: The supporting files in the ``.pytest_cache`` directory are kept with ``--cache-clear``, which only clears cached values now.
+- :issue:`6290`: The supporting files in the ``.pytest_cache`` directory are kept with ``--cache-clear``, which only clears cached values now.
 
 
-- `#6301 <https://github.com/pytest-dev/pytest/issues/6301>`_: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``).
+- :issue:`6301`: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``).
 
 
 pytest 5.3.1 (2019-11-25)
@@ -1346,26 +2570,26 @@ pytest 5.3.1 (2019-11-25)
 Improvements
 ------------
 
-- `#6231 <https://github.com/pytest-dev/pytest/issues/6231>`_: Improve check for misspelling of :ref:`pytest.mark.parametrize ref`.
+- :issue:`6231`: Improve check for misspelling of :ref:`pytest.mark.parametrize ref`.
 
 
-- `#6257 <https://github.com/pytest-dev/pytest/issues/6257>`_: Handle :py:func:`pytest.exit` being used via :py:func:`~_pytest.hookspec.pytest_internalerror`, e.g. when quitting pdb from post mortem.
+- :issue:`6257`: Handle :func:`pytest.exit` being used via :hook:`pytest_internalerror`, e.g. when quitting pdb from post mortem.
 
 
 
 Bug Fixes
 ---------
 
-- `#5914 <https://github.com/pytest-dev/pytest/issues/5914>`_: pytester: fix :py:func:`~_pytest.pytester.LineMatcher.no_fnmatch_line` when used after positive matching.
+- :issue:`5914`: pytester: fix :py:func:`~_pytest.pytester.LineMatcher.no_fnmatch_line` when used after positive matching.
 
 
-- `#6082 <https://github.com/pytest-dev/pytest/issues/6082>`_: Fix line detection for doctest samples inside :py:class:`python:property` docstrings, as a workaround to `bpo-17446 <https://bugs.python.org/issue17446>`__.
+- :issue:`6082`: Fix line detection for doctest samples inside :py:class:`python:property` docstrings, as a workaround to :bpo:`17446`.
 
 
-- `#6254 <https://github.com/pytest-dev/pytest/issues/6254>`_: Fix compatibility with pytest-parallel (regression in pytest 5.3.0).
+- :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0).
 
 
-- `#6255 <https://github.com/pytest-dev/pytest/issues/6255>`_: Clear the :py:data:`sys.last_traceback`, :py:data:`sys.last_type`
+- :issue:`6255`: Clear the :py:data:`sys.last_traceback`, :py:data:`sys.last_type`
   and :py:data:`sys.last_value` attributes by deleting them instead
   of setting them to ``None``. This better matches the behaviour of
   the Python standard library.
@@ -1377,20 +2601,20 @@ pytest 5.3.0 (2019-11-19)
 Deprecations
 ------------
 
-- `#6179 <https://github.com/pytest-dev/pytest/issues/6179>`_: The default value of :confval:`junit_family` option will change to ``"xunit2"`` in pytest 6.0, given
+- :issue:`6179`: The default value of :confval:`junit_family` option will change to ``"xunit2"`` in pytest 6.0, given
   that this is the version supported by default in modern tools that manipulate this type of file.
 
   In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option
   is given in the command line but :confval:`junit_family` is not explicitly configured in ``pytest.ini``.
 
-  For more information, `see the docs <https://docs.pytest.org/en/stable/deprecations.html#junit-family-default-value-change-to-xunit2>`__.
+  For more information, :ref:`see the docs <junit-family changed default value>`.
 
 
 
 Features
 --------
 
-- `#4488 <https://github.com/pytest-dev/pytest/issues/4488>`_: The pytest team has created the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__
+- :issue:`4488`: The pytest team has created the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__
   plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes.
 
   Each line of the report log contains a self contained JSON object corresponding to a testing event,
@@ -1402,12 +2626,12 @@ Features
   provide feedback.
 
 
-- `#4730 <https://github.com/pytest-dev/pytest/issues/4730>`_: When :py:data:`sys.pycache_prefix` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism.
+- :issue:`4730`: When :py:data:`sys.pycache_prefix` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism.
 
   This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions.
 
 
-- `#5515 <https://github.com/pytest-dev/pytest/issues/5515>`_: Allow selective auto-indentation of multiline log messages.
+- :issue:`5515`: Allow selective auto-indentation of multiline log messages.
 
   Adds command line option ``--log-auto-indent``, config option
   :confval:`log_auto_indent` and support for per-entry configuration of
@@ -1420,7 +2644,7 @@ Features
   rather than implicitly.
 
 
-- `#5914 <https://github.com/pytest-dev/pytest/issues/5914>`_: :fixture:`testdir` learned two new functions, :py:func:`~_pytest.pytester.LineMatcher.no_fnmatch_line` and
+- :issue:`5914`: :fixture:`testdir` learned two new functions, :py:func:`~_pytest.pytester.LineMatcher.no_fnmatch_line` and
   :py:func:`~_pytest.pytester.LineMatcher.no_re_match_line`.
 
   The functions are used to ensure the captured text *does not* match the given
@@ -1443,12 +2667,12 @@ Features
   But the new functions produce best output on failure.
 
 
-- `#6057 <https://github.com/pytest-dev/pytest/issues/6057>`_: Added tolerances to complex values when printing ``pytest.approx``.
+- :issue:`6057`: Added tolerances to complex values when printing ``pytest.approx``.
 
   For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle.
 
 
-- `#6061 <https://github.com/pytest-dev/pytest/issues/6061>`_: Added the pluginmanager as an argument to ``pytest_addoption``
+- :issue:`6061`: Added the pluginmanager as an argument to ``pytest_addoption``
   so that hooks can be invoked when setting up command line options. This is
   useful for having one plugin communicate things to another plugin,
   such as default values or which set of command line options to add.
@@ -1458,13 +2682,13 @@ Features
 Improvements
 ------------
 
-- `#5061 <https://github.com/pytest-dev/pytest/issues/5061>`_: Use multiple colors with terminal summary statistics.
+- :issue:`5061`: Use multiple colors with terminal summary statistics.
 
 
-- `#5630 <https://github.com/pytest-dev/pytest/issues/5630>`_: Quitting from debuggers is now properly handled in ``doctest`` items.
+- :issue:`5630`: Quitting from debuggers is now properly handled in ``doctest`` items.
 
 
-- `#5924 <https://github.com/pytest-dev/pytest/issues/5924>`_: Improved verbose diff output with sequences.
+- :issue:`5924`: Improved verbose diff output with sequences.
 
   Before:
 
@@ -1500,80 +2724,80 @@ Improvements
       E       ]
 
 
-- `#5934 <https://github.com/pytest-dev/pytest/issues/5934>`_: ``repr`` of ``ExceptionInfo`` objects has been improved to honor the ``__repr__`` method of the underlying exception.
+- :issue:`5934`: ``repr`` of ``ExceptionInfo`` objects has been improved to honor the ``__repr__`` method of the underlying exception.
 
-- `#5936 <https://github.com/pytest-dev/pytest/issues/5936>`_: Display untruncated assertion message with ``-vv``.
+- :issue:`5936`: Display untruncated assertion message with ``-vv``.
 
 
-- `#5990 <https://github.com/pytest-dev/pytest/issues/5990>`_: Fixed plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors").
+- :issue:`5990`: Fixed plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors").
 
 
-- `#6008 <https://github.com/pytest-dev/pytest/issues/6008>`_: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be
+- :issue:`6008`: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be
   immutable and avoid accidental modifications.
 
 
-- `#6023 <https://github.com/pytest-dev/pytest/issues/6023>`_: ``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still).
+- :issue:`6023`: ``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still).
 
 
-- `#6026 <https://github.com/pytest-dev/pytest/issues/6026>`_: Align prefixes in output of pytester's ``LineMatcher``.
+- :issue:`6026`: Align prefixes in output of pytester's ``LineMatcher``.
 
 
-- `#6059 <https://github.com/pytest-dev/pytest/issues/6059>`_: Collection errors are reported as errors (and not failures like before) in the terminal's short test summary.
+- :issue:`6059`: Collection errors are reported as errors (and not failures like before) in the terminal's short test summary.
 
 
-- `#6069 <https://github.com/pytest-dev/pytest/issues/6069>`_: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally.
+- :issue:`6069`: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally.
 
 
-- `#6097 <https://github.com/pytest-dev/pytest/issues/6097>`_: The "[...%]" indicator in the test summary is now colored according to the final (new) multi-colored line's main color.
+- :issue:`6097`: The "[...%]" indicator in the test summary is now colored according to the final (new) multi-colored line's main color.
 
 
-- `#6116 <https://github.com/pytest-dev/pytest/issues/6116>`_: Added ``--co`` as a synonym to ``--collect-only``.
+- :issue:`6116`: Added ``--co`` as a synonym to ``--collect-only``.
 
 
-- `#6148 <https://github.com/pytest-dev/pytest/issues/6148>`_: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix.
+- :issue:`6148`: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix.
 
 
-- `#6152 <https://github.com/pytest-dev/pytest/issues/6152>`_: Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes.
+- :issue:`6152`: Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes.
 
 
-- `#6176 <https://github.com/pytest-dev/pytest/issues/6176>`_: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``.
+- :issue:`6176`: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``.
 
 
-- `#6181 <https://github.com/pytest-dev/pytest/issues/6181>`_: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x``, now gets reported in the test summary.
+- :issue:`6181`: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x``, now gets reported in the test summary.
 
 
-- `#6206 <https://github.com/pytest-dev/pytest/issues/6206>`_: Improved ``cache.set`` robustness and performance.
+- :issue:`6206`: Improved ``cache.set`` robustness and performance.
 
 
 
 Bug Fixes
 ---------
 
-- `#2049 <https://github.com/pytest-dev/pytest/issues/2049>`_: Fixed ``--setup-plan`` showing inaccurate information about fixture lifetimes.
+- :issue:`2049`: Fixed ``--setup-plan`` showing inaccurate information about fixture lifetimes.
 
 
-- `#2548 <https://github.com/pytest-dev/pytest/issues/2548>`_: Fixed line offset mismatch of skipped tests in terminal summary.
+- :issue:`2548`: Fixed line offset mismatch of skipped tests in terminal summary.
 
 
-- `#6039 <https://github.com/pytest-dev/pytest/issues/6039>`_: The ``PytestDoctestRunner`` is now properly invalidated when unconfiguring the doctest plugin.
+- :issue:`6039`: The ``PytestDoctestRunner`` is now properly invalidated when unconfiguring the doctest plugin.
 
   This is important when used with ``pytester``'s ``runpytest_inprocess``.
 
 
-- `#6047 <https://github.com/pytest-dev/pytest/issues/6047>`_: BaseExceptions are now handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc.
+- :issue:`6047`: BaseExceptions are now handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc.
 
 
-- `#6074 <https://github.com/pytest-dev/pytest/issues/6074>`_: pytester: fixed order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``.
+- :issue:`6074`: pytester: fixed order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``.
 
 
-- `#6189 <https://github.com/pytest-dev/pytest/issues/6189>`_: Fixed result of ``getmodpath`` method.
+- :issue:`6189`: Fixed result of ``getmodpath`` method.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4901 <https://github.com/pytest-dev/pytest/issues/4901>`_: ``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a
+- :issue:`4901`: ``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a
   valid ``pytest.ExitCode`` value.
 
 
@@ -1583,10 +2807,10 @@ pytest 5.2.4 (2019-11-15)
 Bug Fixes
 ---------
 
-- `#6194 <https://github.com/pytest-dev/pytest/issues/6194>`_: Fix incorrect discovery of non-test ``__init__.py`` files.
+- :issue:`6194`: Fix incorrect discovery of non-test ``__init__.py`` files.
 
 
-- `#6197 <https://github.com/pytest-dev/pytest/issues/6197>`_: Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
+- :issue:`6197`: Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
 
 
 pytest 5.2.3 (2019-11-14)
@@ -1595,13 +2819,13 @@ pytest 5.2.3 (2019-11-14)
 Bug Fixes
 ---------
 
-- `#5830 <https://github.com/pytest-dev/pytest/issues/5830>`_: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.
+- :issue:`5830`: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.
 
 
-- `#6099 <https://github.com/pytest-dev/pytest/issues/6099>`_: Fix ``--trace`` when used with parametrized functions.
+- :issue:`6099`: Fix ``--trace`` when used with parametrized functions.
 
 
-- `#6183 <https://github.com/pytest-dev/pytest/issues/6183>`_: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
+- :issue:`6183`: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
   user-friendly error.
 
 
@@ -1611,16 +2835,16 @@ pytest 5.2.2 (2019-10-24)
 Bug Fixes
 ---------
 
-- `#5206 <https://github.com/pytest-dev/pytest/issues/5206>`_: Fix ``--nf`` to not forget about known nodeids with partial test selection.
+- :issue:`5206`: Fix ``--nf`` to not forget about known nodeids with partial test selection.
 
 
-- `#5906 <https://github.com/pytest-dev/pytest/issues/5906>`_: Fix crash with ``KeyboardInterrupt`` during ``--setup-show``.
+- :issue:`5906`: Fix crash with ``KeyboardInterrupt`` during ``--setup-show``.
 
 
-- `#5946 <https://github.com/pytest-dev/pytest/issues/5946>`_: Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types).
+- :issue:`5946`: Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types).
 
 
-- `#6044 <https://github.com/pytest-dev/pytest/issues/6044>`_: Properly ignore ``FileNotFoundError`` exceptions when trying to remove old temporary directories,
+- :issue:`6044`: Properly ignore ``FileNotFoundError`` exceptions when trying to remove old temporary directories,
   for instance when multiple processes try to remove the same directory (common with ``pytest-xdist``
   for example).
 
@@ -1631,7 +2855,7 @@ pytest 5.2.1 (2019-10-06)
 Bug Fixes
 ---------
 
-- `#5902 <https://github.com/pytest-dev/pytest/issues/5902>`_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
+- :issue:`5902`: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
 
 
 pytest 5.2.0 (2019-09-28)
@@ -1640,7 +2864,7 @@ pytest 5.2.0 (2019-09-28)
 Deprecations
 ------------
 
-- `#1682 <https://github.com/pytest-dev/pytest/issues/1682>`_: Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them
+- :issue:`1682`: Passing arguments to pytest.fixture() as positional arguments is deprecated - pass them
   as a keyword argument instead.
 
 
@@ -1648,29 +2872,29 @@ Deprecations
 Features
 --------
 
-- `#1682 <https://github.com/pytest-dev/pytest/issues/1682>`_: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives
+- :issue:`1682`: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives
   the fixture name and the ``config`` object as keyword-only parameters.
-  See `the docs <https://docs.pytest.org/en/stable/fixture.html#dynamic-scope>`__ for more information.
+  See :ref:`the docs <dynamic scope>` for more information.
 
 
-- `#5764 <https://github.com/pytest-dev/pytest/issues/5764>`_: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run
+- :issue:`5764`: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run
 
 
 
 Bug Fixes
 ---------
 
-- `#5806 <https://github.com/pytest-dev/pytest/issues/5806>`_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
+- :issue:`5806`: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
 
 
-- `#5884 <https://github.com/pytest-dev/pytest/issues/5884>`_: Fix ``--setup-only`` and ``--setup-show`` for custom pytest items.
+- :issue:`5884`: Fix ``--setup-only`` and ``--setup-show`` for custom pytest items.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#5056 <https://github.com/pytest-dev/pytest/issues/5056>`_: The HelpFormatter uses ``py.io.get_terminal_width`` for better width detection.
+- :issue:`5056`: The HelpFormatter uses ``py.io.get_terminal_width`` for better width detection.
 
 
 pytest 5.1.3 (2019-09-18)
@@ -1679,13 +2903,13 @@ pytest 5.1.3 (2019-09-18)
 Bug Fixes
 ---------
 
-- `#5807 <https://github.com/pytest-dev/pytest/issues/5807>`_: Fix pypy3.6 (nightly) on windows.
+- :issue:`5807`: Fix pypy3.6 (nightly) on windows.
 
 
-- `#5811 <https://github.com/pytest-dev/pytest/issues/5811>`_: Handle ``--fulltrace`` correctly with ``pytest.raises``.
+- :issue:`5811`: Handle ``--fulltrace`` correctly with ``pytest.raises``.
 
 
-- `#5819 <https://github.com/pytest-dev/pytest/issues/5819>`_: Windows: Fix regression with conftest whose qualified name contains uppercase
+- :issue:`5819`: Windows: Fix regression with conftest whose qualified name contains uppercase
   characters (introduced by #5792).
 
 
@@ -1695,22 +2919,22 @@ pytest 5.1.2 (2019-08-30)
 Bug Fixes
 ---------
 
-- `#2270 <https://github.com/pytest-dev/pytest/issues/2270>`_: Fixed ``self`` reference in function-scoped fixtures defined plugin classes: previously ``self``
+- :issue:`2270`: Fixed ``self`` reference in function-scoped fixtures defined plugin classes: previously ``self``
   would be a reference to a *test* class, not the *plugin* class.
 
 
-- `#570 <https://github.com/pytest-dev/pytest/issues/570>`_: Fixed long standing issue where fixture scope was not respected when indirect fixtures were used during
+- :issue:`570`: Fixed long standing issue where fixture scope was not respected when indirect fixtures were used during
   parametrization.
 
 
-- `#5782 <https://github.com/pytest-dev/pytest/issues/5782>`_: Fix decoding error when printing an error response from ``--pastebin``.
+- :issue:`5782`: Fix decoding error when printing an error response from ``--pastebin``.
 
 
-- `#5786 <https://github.com/pytest-dev/pytest/issues/5786>`_: Chained exceptions in test and collection reports are now correctly serialized, allowing plugins like
+- :issue:`5786`: Chained exceptions in test and collection reports are now correctly serialized, allowing plugins like
   ``pytest-xdist`` to display them properly.
 
 
-- `#5792 <https://github.com/pytest-dev/pytest/issues/5792>`_: Windows: Fix error that occurs in certain circumstances when loading
+- :issue:`5792`: Windows: Fix error that occurs in certain circumstances when loading
   ``conftest.py`` from a working directory that has casing other than the one stored
   in the filesystem (e.g., ``c:\test`` instead of ``C:\test``).
 
@@ -1721,7 +2945,7 @@ pytest 5.1.1 (2019-08-20)
 Bug Fixes
 ---------
 
-- `#5751 <https://github.com/pytest-dev/pytest/issues/5751>`_: Fixed ``TypeError`` when importing pytest on Python 3.5.0 and 3.5.1.
+- :issue:`5751`: Fixed ``TypeError`` when importing pytest on Python 3.5.0 and 3.5.1.
 
 
 pytest 5.1.0 (2019-08-15)
@@ -1730,7 +2954,7 @@ pytest 5.1.0 (2019-08-15)
 Removals
 --------
 
-- `#5180 <https://github.com/pytest-dev/pytest/issues/5180>`_: As per our policy, the following features have been deprecated in the 4.X series and are now
+- :issue:`5180`: As per our policy, the following features have been deprecated in the 4.X series and are now
   removed:
 
   * ``Request.getfuncargvalue``: use ``Request.getfixturevalue`` instead.
@@ -1754,11 +2978,10 @@ Removals
   * ``request`` is now a reserved name for fixtures.
 
 
-  For more information consult
-  `Deprecations and Removals <https://docs.pytest.org/en/stable/deprecations.html>`__ in the docs.
+  For more information consult :std:doc:`deprecations` in the docs.
 
 
-- `#5565 <https://github.com/pytest-dev/pytest/issues/5565>`_: Removed unused support code for `unittest2 <https://pypi.org/project/unittest2/>`__.
+- :issue:`5565`: Removed unused support code for :pypi:`unittest2`.
 
   The ``unittest2`` backport module is no longer
   necessary since Python 3.3+, and the small amount of code in pytest to support it also doesn't seem
@@ -1769,11 +2992,10 @@ Removals
   at all (even if ``unittest2`` is used by a test suite executed by pytest), it was decided to
   remove it in this release.
 
-  If you experience a regression because of this, please
-  `file an issue <https://github.com/pytest-dev/pytest/issues/new>`__.
+  If you experience a regression because of this, please :issue:`file an issue <new>`.
 
 
-- `#5615 <https://github.com/pytest-dev/pytest/issues/5615>`_: ``pytest.fail``, ``pytest.xfail`` and ``pytest.skip`` no longer support bytes for the message argument.
+- :issue:`5615`: ``pytest.fail``, ``pytest.xfail`` and ``pytest.skip`` no longer support bytes for the message argument.
 
   This was supported for Python 2 where it was tempting to use ``"message"``
   instead of ``u"message"``.
@@ -1786,10 +3008,10 @@ Removals
 Features
 --------
 
-- `#5564 <https://github.com/pytest-dev/pytest/issues/5564>`_: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
+- :issue:`5564`: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
 
 
-- `#5576 <https://github.com/pytest-dev/pytest/issues/5576>`_: New `NUMBER <https://docs.pytest.org/en/stable/doctest.html#using-doctest-options>`__
+- :issue:`5576`: New :ref:`NUMBER <using doctest options>`
   option for doctests to ignore irrelevant differences in floating-point numbers.
   Inspired by Sébastien Boisgérault's `numtest <https://github.com/boisgera/numtest>`__
   extension for doctest.
@@ -1799,10 +3021,10 @@ Features
 Improvements
 ------------
 
-- `#5471 <https://github.com/pytest-dev/pytest/issues/5471>`_: JUnit XML now includes a timestamp and hostname in the testsuite tag.
+- :issue:`5471`: JUnit XML now includes a timestamp and hostname in the testsuite tag.
 
 
-- `#5707 <https://github.com/pytest-dev/pytest/issues/5707>`_: Time taken to run the test suite now includes a human-readable representation when it takes over
+- :issue:`5707`: Time taken to run the test suite now includes a human-readable representation when it takes over
   60 seconds, for example::
 
       ===== 2 failed in 102.70s (0:01:42) =====
@@ -1812,71 +3034,71 @@ Improvements
 Bug Fixes
 ---------
 
-- `#4344 <https://github.com/pytest-dev/pytest/issues/4344>`_: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
+- :issue:`4344`: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
 
 
-- `#5115 <https://github.com/pytest-dev/pytest/issues/5115>`_: Warnings issued during ``pytest_configure`` are explicitly not treated as errors, even if configured as such, because it otherwise completely breaks pytest.
+- :issue:`5115`: Warnings issued during ``pytest_configure`` are explicitly not treated as errors, even if configured as such, because it otherwise completely breaks pytest.
 
 
-- `#5477 <https://github.com/pytest-dev/pytest/issues/5477>`_: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
+- :issue:`5477`: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
 
 
-- `#5524 <https://github.com/pytest-dev/pytest/issues/5524>`_: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
+- :issue:`5524`: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
   which could lead to pytest crashing when executed a second time with the ``--basetemp`` option.
 
 
-- `#5537 <https://github.com/pytest-dev/pytest/issues/5537>`_: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
+- :issue:`5537`: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
   standard library on Python 3.8+.
 
 
-- `#5578 <https://github.com/pytest-dev/pytest/issues/5578>`_: Improve type checking for some exception-raising functions (``pytest.xfail``, ``pytest.skip``, etc)
+- :issue:`5578`: Improve type checking for some exception-raising functions (``pytest.xfail``, ``pytest.skip``, etc)
   so they provide better error messages when users meant to use marks (for example ``@pytest.xfail``
   instead of ``@pytest.mark.xfail``).
 
 
-- `#5606 <https://github.com/pytest-dev/pytest/issues/5606>`_: Fixed internal error when test functions were patched with objects that cannot be compared
+- :issue:`5606`: Fixed internal error when test functions were patched with objects that cannot be compared
   for truth values against others, like ``numpy`` arrays.
 
 
-- `#5634 <https://github.com/pytest-dev/pytest/issues/5634>`_: ``pytest.exit`` is now correctly handled in ``unittest`` cases.
+- :issue:`5634`: ``pytest.exit`` is now correctly handled in ``unittest`` cases.
   This makes ``unittest`` cases handle ``quit`` from pytest's pdb correctly.
 
 
-- `#5650 <https://github.com/pytest-dev/pytest/issues/5650>`_: Improved output when parsing an ini configuration file fails.
+- :issue:`5650`: Improved output when parsing an ini configuration file fails.
 
 
-- `#5701 <https://github.com/pytest-dev/pytest/issues/5701>`_: Fix collection of ``staticmethod`` objects defined with ``functools.partial``.
+- :issue:`5701`: Fix collection of ``staticmethod`` objects defined with ``functools.partial``.
 
 
-- `#5734 <https://github.com/pytest-dev/pytest/issues/5734>`_: Skip async generator test functions, and update the warning message to refer to ``async def`` functions.
+- :issue:`5734`: Skip async generator test functions, and update the warning message to refer to ``async def`` functions.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#5669 <https://github.com/pytest-dev/pytest/issues/5669>`_: Add docstring for ``Testdir.copy_example``.
+- :issue:`5669`: Add docstring for ``Testdir.copy_example``.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#5095 <https://github.com/pytest-dev/pytest/issues/5095>`_: XML files of the ``xunit2`` family are now validated against the schema by pytest's own test suite
+- :issue:`5095`: XML files of the ``xunit2`` family are now validated against the schema by pytest's own test suite
   to avoid future regressions.
 
 
-- `#5516 <https://github.com/pytest-dev/pytest/issues/5516>`_: Cache node splitting function which can improve collection performance in very large test suites.
+- :issue:`5516`: Cache node splitting function which can improve collection performance in very large test suites.
 
 
-- `#5603 <https://github.com/pytest-dev/pytest/issues/5603>`_: Simplified internal ``SafeRepr`` class and removed some dead code.
+- :issue:`5603`: Simplified internal ``SafeRepr`` class and removed some dead code.
 
 
-- `#5664 <https://github.com/pytest-dev/pytest/issues/5664>`_: When invoking pytest's own testsuite with ``PYTHONDONTWRITEBYTECODE=1``,
+- :issue:`5664`: When invoking pytest's own testsuite with ``PYTHONDONTWRITEBYTECODE=1``,
   the ``test_xfail_handling`` test no longer fails.
 
 
-- `#5684 <https://github.com/pytest-dev/pytest/issues/5684>`_: Replace manual handling of ``OSError.errno`` in the codebase by new ``OSError`` subclasses (``PermissionError``, ``FileNotFoundError``, etc.).
+- :issue:`5684`: Replace manual handling of ``OSError.errno`` in the codebase by new ``OSError`` subclasses (``PermissionError``, ``FileNotFoundError``, etc.).
 
 
 pytest 5.0.1 (2019-07-04)
@@ -1885,20 +3107,20 @@ pytest 5.0.1 (2019-07-04)
 Bug Fixes
 ---------
 
-- `#5479 <https://github.com/pytest-dev/pytest/issues/5479>`_: Improve quoting in ``raises`` match failure message.
+- :issue:`5479`: Improve quoting in ``raises`` match failure message.
 
 
-- `#5523 <https://github.com/pytest-dev/pytest/issues/5523>`_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
+- :issue:`5523`: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
 
 
-- `#5547 <https://github.com/pytest-dev/pytest/issues/5547>`_: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.
+- :issue:`5547`: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#5517 <https://github.com/pytest-dev/pytest/issues/5517>`_: Improve "Declaring new hooks" section in chapter "Writing Plugins"
+- :issue:`5517`: Improve "Declaring new hooks" section in chapter "Writing Plugins"
 
 
 pytest 5.0.0 (2019-06-28)
@@ -1909,29 +3131,29 @@ Important
 
 This release is a Python3.5+ only release.
 
-For more details, see our `Python 2.7 and 3.4 support plan <https://docs.pytest.org/en/stable/py27-py34-deprecation.html>`__.
+For more details, see our `Python 2.7 and 3.4 support plan
+<https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html>`_.
 
 Removals
 --------
 
-- `#1149 <https://github.com/pytest-dev/pytest/issues/1149>`_: Pytest no longer accepts prefixes of command-line arguments, for example
+- :issue:`1149`: Pytest no longer accepts prefixes of command-line arguments, for example
   typing ``pytest --doctest-mod`` inplace of ``--doctest-modules``.
   This was previously allowed where the ``ArgumentParser`` thought it was unambiguous,
   but this could be incorrect due to delayed parsing of options for plugins.
-  See for example issues `#1149 <https://github.com/pytest-dev/pytest/issues/1149>`__,
-  `#3413 <https://github.com/pytest-dev/pytest/issues/3413>`__, and
-  `#4009 <https://github.com/pytest-dev/pytest/issues/4009>`__.
+  See for example issues :issue:`1149`,
+  :issue:`3413`, and
+  :issue:`4009`.
 
 
-- `#5402 <https://github.com/pytest-dev/pytest/issues/5402>`_: **PytestDeprecationWarning are now errors by default.**
+- :issue:`5402`: **PytestDeprecationWarning are now errors by default.**
 
   Following our plan to remove deprecated features with as little disruption as
   possible, all warnings of type ``PytestDeprecationWarning`` now generate errors
   instead of warning messages.
 
   **The affected features will be effectively removed in pytest 5.1**, so please consult the
-  `Deprecations and Removals <https://docs.pytest.org/en/stable/deprecations.html>`__
-  section in the docs for directions on how to update existing code.
+  :std:doc:`deprecations` section in the docs for directions on how to update existing code.
 
   In the pytest ``5.0.X`` series, it is possible to change the errors back into warnings as a stop
   gap measure by adding this to your ``pytest.ini`` file:
@@ -1945,10 +3167,10 @@ Removals
   But this will stop working when pytest ``5.1`` is released.
 
   **If you have concerns** about the removal of a specific feature, please add a
-  comment to `#5402 <https://github.com/pytest-dev/pytest/issues/5402>`__.
+  comment to :issue:`5402`.
 
 
-- `#5412 <https://github.com/pytest-dev/pytest/issues/5412>`_: ``ExceptionInfo`` objects (returned by ``pytest.raises``) now have the same ``str`` representation as ``repr``, which
+- :issue:`5412`: ``ExceptionInfo`` objects (returned by ``pytest.raises``) now have the same ``str`` representation as ``repr``, which
   avoids some confusion when users use ``print(e)`` to inspect the object.
 
   This means code like:
@@ -1974,11 +3196,11 @@ Removals
 Deprecations
 ------------
 
-- `#4488 <https://github.com/pytest-dev/pytest/issues/4488>`_: The removal of the ``--result-log`` option and module has been postponed to (tentatively) pytest 6.0 as
+- :issue:`4488`: The removal of the ``--result-log`` option and module has been postponed to (tentatively) pytest 6.0 as
   the team has not yet got around to implement a good alternative for it.
 
 
-- `#466 <https://github.com/pytest-dev/pytest/issues/466>`_: The ``funcargnames`` attribute has been an alias for ``fixturenames`` since
+- :issue:`466`: The ``funcargnames`` attribute has been an alias for ``fixturenames`` since
   pytest 2.3, and is now deprecated in code too.
 
 
@@ -1986,26 +3208,26 @@ Deprecations
 Features
 --------
 
-- `#3457 <https://github.com/pytest-dev/pytest/issues/3457>`_: New `pytest_assertion_pass <https://docs.pytest.org/en/stable/reference.html#_pytest.hookspec.pytest_assertion_pass>`__
+- :issue:`3457`: New :hook:`pytest_assertion_pass`
   hook, called with context information when an assertion *passes*.
 
   This hook is still **experimental** so use it with caution.
 
 
-- `#5440 <https://github.com/pytest-dev/pytest/issues/5440>`_: The `faulthandler <https://docs.python.org/3/library/faulthandler.html>`__ standard library
+- :issue:`5440`: The :mod:`faulthandler` standard library
   module is now enabled by default to help users diagnose crashes in C modules.
 
   This functionality was provided by integrating the external
   `pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin into the core,
   so users should remove that plugin from their requirements if used.
 
-  For more information see the docs: https://docs.pytest.org/en/stable/usage.html#fault-handler
+  For more information see the docs: :ref:`faulthandler`.
 
 
-- `#5452 <https://github.com/pytest-dev/pytest/issues/5452>`_: When warnings are configured as errors, pytest warnings now appear as originating from ``pytest.`` instead of the internal ``_pytest.warning_types.`` module.
+- :issue:`5452`: When warnings are configured as errors, pytest warnings now appear as originating from ``pytest.`` instead of the internal ``_pytest.warning_types.`` module.
 
 
-- `#5125 <https://github.com/pytest-dev/pytest/issues/5125>`_: ``Session.exitcode`` values are now coded in ``pytest.ExitCode``, an ``IntEnum``. This makes the exit code available for consumer code and are more explicit other than just documentation. User defined exit codes are still valid, but should be used with caution.
+- :issue:`5125`: ``Session.exitcode`` values are now coded in ``pytest.ExitCode``, an ``IntEnum``. This makes the exit code available for consumer code and are more explicit other than just documentation. User defined exit codes are still valid, but should be used with caution.
 
   The team doesn't expect this change to break test suites or plugins in general, except in esoteric/specific scenarios.
 
@@ -2016,20 +3238,20 @@ Features
 Bug Fixes
 ---------
 
-- `#1403 <https://github.com/pytest-dev/pytest/issues/1403>`_: Switch from ``imp`` to ``importlib``.
+- :issue:`1403`: Switch from ``imp`` to ``importlib``.
 
 
-- `#1671 <https://github.com/pytest-dev/pytest/issues/1671>`_: The name of the ``.pyc`` files cached by the assertion writer now includes the pytest version
+- :issue:`1671`: The name of the ``.pyc`` files cached by the assertion writer now includes the pytest version
   to avoid stale caches.
 
 
-- `#2761 <https://github.com/pytest-dev/pytest/issues/2761>`_: Honor PEP 235 on case-insensitive file systems.
+- :issue:`2761`: Honor :pep:`235` on case-insensitive file systems.
 
 
-- `#5078 <https://github.com/pytest-dev/pytest/issues/5078>`_: Test module is no longer double-imported when using ``--pyargs``.
+- :issue:`5078`: Test module is no longer double-imported when using ``--pyargs``.
 
 
-- `#5260 <https://github.com/pytest-dev/pytest/issues/5260>`_: Improved comparison of byte strings.
+- :issue:`5260`: Improved comparison of byte strings.
 
   When comparing bytes, the assertion message used to show the byte numeric value when showing the differences::
 
@@ -2048,60 +3270,60 @@ Bug Fixes
       E         Use -v to get the full diff
 
 
-- `#5335 <https://github.com/pytest-dev/pytest/issues/5335>`_: Colorize level names when the level in the logging format is formatted using
+- :issue:`5335`: Colorize level names when the level in the logging format is formatted using
   '%(levelname).Xs' (truncated fixed width alignment), where X is an integer.
 
 
-- `#5354 <https://github.com/pytest-dev/pytest/issues/5354>`_: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator.
+- :issue:`5354`: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator.
 
 
-- `#5370 <https://github.com/pytest-dev/pytest/issues/5370>`_: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions.
+- :issue:`5370`: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions.
 
 
-- `#5371 <https://github.com/pytest-dev/pytest/issues/5371>`_: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``.
+- :issue:`5371`: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``.
 
 
-- `#5372 <https://github.com/pytest-dev/pytest/issues/5372>`_: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression.
+- :issue:`5372`: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression.
 
 
-- `#5383 <https://github.com/pytest-dev/pytest/issues/5383>`_: ``-q`` has again an impact on the style of the collected items
+- :issue:`5383`: ``-q`` has again an impact on the style of the collected items
   (``--collect-only``) when ``--log-cli-level`` is used.
 
 
-- `#5389 <https://github.com/pytest-dev/pytest/issues/5389>`_: Fix regressions of `#5063 <https://github.com/pytest-dev/pytest/pull/5063>`__ for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
+- :issue:`5389`: Fix regressions of :pull:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
 
 
-- `#5390 <https://github.com/pytest-dev/pytest/issues/5390>`_: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
+- :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
 
 
-- `#5404 <https://github.com/pytest-dev/pytest/issues/5404>`_: Emit a warning when attempting to unwrap a broken object raises an exception,
-  for easier debugging (`#5080 <https://github.com/pytest-dev/pytest/issues/5080>`__).
+- :issue:`5404`: Emit a warning when attempting to unwrap a broken object raises an exception,
+  for easier debugging (:issue:`5080`).
 
 
-- `#5432 <https://github.com/pytest-dev/pytest/issues/5432>`_: Prevent "already imported" warnings from assertion rewriter when invoking pytest in-process multiple times.
+- :issue:`5432`: Prevent "already imported" warnings from assertion rewriter when invoking pytest in-process multiple times.
 
 
-- `#5433 <https://github.com/pytest-dev/pytest/issues/5433>`_: Fix assertion rewriting in packages (``__init__.py``).
+- :issue:`5433`: Fix assertion rewriting in packages (``__init__.py``).
 
 
-- `#5444 <https://github.com/pytest-dev/pytest/issues/5444>`_: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
+- :issue:`5444`: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
 
 
-- `#5482 <https://github.com/pytest-dev/pytest/issues/5482>`_: Fix bug introduced in 4.6.0 causing collection errors when passing
+- :issue:`5482`: Fix bug introduced in 4.6.0 causing collection errors when passing
   more than 2 positional arguments to ``pytest.mark.parametrize``.
 
 
-- `#5505 <https://github.com/pytest-dev/pytest/issues/5505>`_: Fix crash when discovery fails while using ``-p no:terminal``.
+- :issue:`5505`: Fix crash when discovery fails while using ``-p no:terminal``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#5315 <https://github.com/pytest-dev/pytest/issues/5315>`_: Expand docs on mocking classes and dictionaries with ``monkeypatch``.
+- :issue:`5315`: Expand docs on mocking classes and dictionaries with ``monkeypatch``.
 
 
-- `#5416 <https://github.com/pytest-dev/pytest/issues/5416>`_: Fix PytestUnknownMarkWarning in run/skip example.
+- :issue:`5416`: Fix PytestUnknownMarkWarning in run/skip example.
 
 
 pytest 4.6.11 (2020-06-04)
@@ -2110,12 +3332,12 @@ pytest 4.6.11 (2020-06-04)
 Bug Fixes
 ---------
 
-- `#6334 <https://github.com/pytest-dev/pytest/issues/6334>`_: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
+- :issue:`6334`: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
 
   The upper case variants were never documented and the preferred form should be the lower case.
 
 
-- `#7310 <https://github.com/pytest-dev/pytest/issues/7310>`_: Fix ``UnboundLocalError: local variable 'letter' referenced before
+- :issue:`7310`: Fix ``UnboundLocalError: local variable 'letter' referenced before
   assignment`` in ``_pytest.terminal.pytest_report_teststatus()``
   when plugins return report objects in an unconventional state.
 
@@ -2132,14 +3354,18 @@ pytest 4.6.10 (2020-05-08)
 Features
 --------
 
-- `#6870 <https://github.com/pytest-dev/pytest/issues/6870>`_: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
+- :issue:`6870`: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
 
-  Remark: while this is technically a new feature and according to our `policy <https://docs.pytest.org/en/latest/py27-py34-deprecation.html#what-goes-into-4-6-x-releases>`_ it should not have been backported, we have opened an exception in this particular case because it fixes a serious interaction with ``pytest-xdist``, so it can also be considered a bugfix.
+  Remark: while this is technically a new feature and according to our
+  `policy <https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html#what-goes-into-4-6-x-releases>`_
+  it should not have been backported, we have opened an exception in this
+  particular case because it fixes a serious interaction with ``pytest-xdist``,
+  so it can also be considered a bugfix.
 
 Trivial/Internal Changes
 ------------------------
 
-- `#6404 <https://github.com/pytest-dev/pytest/issues/6404>`_: Remove usage of ``parser`` module, deprecated in Python 3.9.
+- :issue:`6404`: Remove usage of ``parser`` module, deprecated in Python 3.9.
 
 
 pytest 4.6.9 (2020-01-04)
@@ -2148,7 +3374,7 @@ pytest 4.6.9 (2020-01-04)
 Bug Fixes
 ---------
 
-- `#6301 <https://github.com/pytest-dev/pytest/issues/6301>`_: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``).
+- :issue:`6301`: Fix assertion rewriting for egg-based distributions and ``editable`` installs (``pip install --editable``).
 
 
 pytest 4.6.8 (2019-12-19)
@@ -2157,21 +3383,21 @@ pytest 4.6.8 (2019-12-19)
 Features
 --------
 
-- `#5471 <https://github.com/pytest-dev/pytest/issues/5471>`_: JUnit XML now includes a timestamp and hostname in the testsuite tag.
+- :issue:`5471`: JUnit XML now includes a timestamp and hostname in the testsuite tag.
 
 
 
 Bug Fixes
 ---------
 
-- `#5430 <https://github.com/pytest-dev/pytest/issues/5430>`_: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
+- :issue:`5430`: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#6345 <https://github.com/pytest-dev/pytest/issues/6345>`_: Pin ``colorama`` to ``0.4.1`` only for Python 3.4 so newer Python versions can still receive colorama updates.
+- :issue:`6345`: Pin ``colorama`` to ``0.4.1`` only for Python 3.4 so newer Python versions can still receive colorama updates.
 
 
 pytest 4.6.7 (2019-12-05)
@@ -2180,10 +3406,10 @@ pytest 4.6.7 (2019-12-05)
 Bug Fixes
 ---------
 
-- `#5477 <https://github.com/pytest-dev/pytest/issues/5477>`_: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
+- :issue:`5477`: The XML file produced by ``--junitxml`` now correctly contain a ``<testsuites>`` root element.
 
 
-- `#6044 <https://github.com/pytest-dev/pytest/issues/6044>`_: Properly ignore ``FileNotFoundError`` (``OSError.errno == NOENT`` in Python 2) exceptions when trying to remove old temporary directories,
+- :issue:`6044`: Properly ignore ``FileNotFoundError`` (``OSError.errno == NOENT`` in Python 2) exceptions when trying to remove old temporary directories,
   for instance when multiple processes try to remove the same directory (common with ``pytest-xdist``
   for example).
 
@@ -2194,24 +3420,24 @@ pytest 4.6.6 (2019-10-11)
 Bug Fixes
 ---------
 
-- `#5523 <https://github.com/pytest-dev/pytest/issues/5523>`_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
+- :issue:`5523`: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+.
 
 
-- `#5537 <https://github.com/pytest-dev/pytest/issues/5537>`_: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
+- :issue:`5537`: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the
   standard library on Python 3.8+.
 
 
-- `#5806 <https://github.com/pytest-dev/pytest/issues/5806>`_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
+- :issue:`5806`: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text".
 
 
-- `#5902 <https://github.com/pytest-dev/pytest/issues/5902>`_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
+- :issue:`5902`: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#5801 <https://github.com/pytest-dev/pytest/issues/5801>`_: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing.
+- :issue:`5801`: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing.
 
 
 pytest 4.6.5 (2019-08-05)
@@ -2220,20 +3446,20 @@ pytest 4.6.5 (2019-08-05)
 Bug Fixes
 ---------
 
-- `#4344 <https://github.com/pytest-dev/pytest/issues/4344>`_: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
+- :issue:`4344`: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
 
 
-- `#5478 <https://github.com/pytest-dev/pytest/issues/5478>`_: Fix encode error when using unicode strings in exceptions with ``pytest.raises``.
+- :issue:`5478`: Fix encode error when using unicode strings in exceptions with ``pytest.raises``.
 
 
-- `#5524 <https://github.com/pytest-dev/pytest/issues/5524>`_: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
+- :issue:`5524`: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only,
   which could lead to pytest crashing when executed a second time with the ``--basetemp`` option.
 
 
-- `#5547 <https://github.com/pytest-dev/pytest/issues/5547>`_: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.
+- :issue:`5547`: ``--step-wise`` now handles ``xfail(strict=True)`` markers properly.
 
 
-- `#5650 <https://github.com/pytest-dev/pytest/issues/5650>`_: Improved output when parsing an ini configuration file fails.
+- :issue:`5650`: Improved output when parsing an ini configuration file fails.
 
 pytest 4.6.4 (2019-06-28)
 =========================
@@ -2241,18 +3467,18 @@ pytest 4.6.4 (2019-06-28)
 Bug Fixes
 ---------
 
-- `#5404 <https://github.com/pytest-dev/pytest/issues/5404>`_: Emit a warning when attempting to unwrap a broken object raises an exception,
-  for easier debugging (`#5080 <https://github.com/pytest-dev/pytest/issues/5080>`__).
+- :issue:`5404`: Emit a warning when attempting to unwrap a broken object raises an exception,
+  for easier debugging (:issue:`5080`).
 
 
-- `#5444 <https://github.com/pytest-dev/pytest/issues/5444>`_: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
+- :issue:`5444`: Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
 
 
-- `#5482 <https://github.com/pytest-dev/pytest/issues/5482>`_: Fix bug introduced in 4.6.0 causing collection errors when passing
+- :issue:`5482`: Fix bug introduced in 4.6.0 causing collection errors when passing
   more than 2 positional arguments to ``pytest.mark.parametrize``.
 
 
-- `#5505 <https://github.com/pytest-dev/pytest/issues/5505>`_: Fix crash when discovery fails while using ``-p no:terminal``.
+- :issue:`5505`: Fix crash when discovery fails while using ``-p no:terminal``.
 
 
 pytest 4.6.3 (2019-06-11)
@@ -2261,14 +3487,14 @@ pytest 4.6.3 (2019-06-11)
 Bug Fixes
 ---------
 
-- `#5383 <https://github.com/pytest-dev/pytest/issues/5383>`_: ``-q`` has again an impact on the style of the collected items
+- :issue:`5383`: ``-q`` has again an impact on the style of the collected items
   (``--collect-only``) when ``--log-cli-level`` is used.
 
 
-- `#5389 <https://github.com/pytest-dev/pytest/issues/5389>`_: Fix regressions of `#5063 <https://github.com/pytest-dev/pytest/pull/5063>`__ for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
+- :issue:`5389`: Fix regressions of :pull:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
 
 
-- `#5390 <https://github.com/pytest-dev/pytest/issues/5390>`_: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
+- :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
 
 
 pytest 4.6.2 (2019-06-03)
@@ -2277,13 +3503,13 @@ pytest 4.6.2 (2019-06-03)
 Bug Fixes
 ---------
 
-- `#5370 <https://github.com/pytest-dev/pytest/issues/5370>`_: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions.
+- :issue:`5370`: Revert unrolling of ``all()`` to fix ``NameError`` on nested comprehensions.
 
 
-- `#5371 <https://github.com/pytest-dev/pytest/issues/5371>`_: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``.
+- :issue:`5371`: Revert unrolling of ``all()`` to fix incorrect handling of generators with ``if``.
 
 
-- `#5372 <https://github.com/pytest-dev/pytest/issues/5372>`_: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression.
+- :issue:`5372`: Revert unrolling of ``all()`` to fix incorrect assertion when using ``all()`` in an expression.
 
 
 pytest 4.6.1 (2019-06-02)
@@ -2292,10 +3518,10 @@ pytest 4.6.1 (2019-06-02)
 Bug Fixes
 ---------
 
-- `#5354 <https://github.com/pytest-dev/pytest/issues/5354>`_: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator.
+- :issue:`5354`: Fix ``pytest.mark.parametrize`` when the argvalues is an iterator.
 
 
-- `#5358 <https://github.com/pytest-dev/pytest/issues/5358>`_: Fix assertion rewriting of ``all()`` calls to deal with non-generators.
+- :issue:`5358`: Fix assertion rewriting of ``all()`` calls to deal with non-generators.
 
 
 pytest 4.6.0 (2019-05-31)
@@ -2306,74 +3532,75 @@ Important
 
 The ``4.6.X`` series will be the last series to support **Python 2 and Python 3.4**.
 
-For more details, see our `Python 2.7 and 3.4 support plan <https://docs.pytest.org/en/stable/py27-py34-deprecation.html>`__.
+For more details, see our `Python 2.7 and 3.4 support plan
+<https://docs.pytest.org/en/7.0.x/py27-py34-deprecation.html>`_.
 
 
 Features
 --------
 
-- `#4559 <https://github.com/pytest-dev/pytest/issues/4559>`_: Added the ``junit_log_passing_tests`` ini value which can be used to enable or disable logging of passing test output in the Junit XML file.
+- :issue:`4559`: Added the ``junit_log_passing_tests`` ini value which can be used to enable or disable logging of passing test output in the Junit XML file.
 
 
-- `#4956 <https://github.com/pytest-dev/pytest/issues/4956>`_: pytester's ``testdir.spawn`` uses ``tmpdir`` as HOME/USERPROFILE directory.
+- :issue:`4956`: pytester's ``testdir.spawn`` uses ``tmpdir`` as HOME/USERPROFILE directory.
 
 
-- `#5062 <https://github.com/pytest-dev/pytest/issues/5062>`_: Unroll calls to ``all`` to full for-loops with assertion rewriting for better failure messages, especially when using Generator Expressions.
+- :issue:`5062`: Unroll calls to ``all`` to full for-loops with assertion rewriting for better failure messages, especially when using Generator Expressions.
 
 
-- `#5063 <https://github.com/pytest-dev/pytest/issues/5063>`_: Switch from ``pkg_resources`` to ``importlib-metadata`` for entrypoint detection for improved performance and import time.
+- :issue:`5063`: Switch from ``pkg_resources`` to ``importlib-metadata`` for entrypoint detection for improved performance and import time.
 
 
-- `#5091 <https://github.com/pytest-dev/pytest/issues/5091>`_: The output for ini options in ``--help`` has been improved.
+- :issue:`5091`: The output for ini options in ``--help`` has been improved.
 
 
-- `#5269 <https://github.com/pytest-dev/pytest/issues/5269>`_: ``pytest.importorskip`` includes the ``ImportError`` now in the default ``reason``.
+- :issue:`5269`: ``pytest.importorskip`` includes the ``ImportError`` now in the default ``reason``.
 
 
-- `#5311 <https://github.com/pytest-dev/pytest/issues/5311>`_: Captured logs that are output for each failing test are formatted using the
+- :issue:`5311`: Captured logs that are output for each failing test are formatted using the
   ColoredLevelFormatter.
 
 
-- `#5312 <https://github.com/pytest-dev/pytest/issues/5312>`_: Improved formatting of multiline log messages in Python 3.
+- :issue:`5312`: Improved formatting of multiline log messages in Python 3.
 
 
 
 Bug Fixes
 ---------
 
-- `#2064 <https://github.com/pytest-dev/pytest/issues/2064>`_: The debugging plugin imports the wrapped ``Pdb`` class (``--pdbcls``) on-demand now.
+- :issue:`2064`: The debugging plugin imports the wrapped ``Pdb`` class (``--pdbcls``) on-demand now.
 
 
-- `#4908 <https://github.com/pytest-dev/pytest/issues/4908>`_: The ``pytest_enter_pdb`` hook gets called with post-mortem (``--pdb``).
+- :issue:`4908`: The ``pytest_enter_pdb`` hook gets called with post-mortem (``--pdb``).
 
 
-- `#5036 <https://github.com/pytest-dev/pytest/issues/5036>`_: Fix issue where fixtures dependent on other parametrized fixtures would be erroneously parametrized.
+- :issue:`5036`: Fix issue where fixtures dependent on other parametrized fixtures would be erroneously parametrized.
 
 
-- `#5256 <https://github.com/pytest-dev/pytest/issues/5256>`_: Handle internal error due to a lone surrogate unicode character not being representable in Jython.
+- :issue:`5256`: Handle internal error due to a lone surrogate unicode character not being representable in Jython.
 
 
-- `#5257 <https://github.com/pytest-dev/pytest/issues/5257>`_: Ensure that ``sys.stdout.mode`` does not include ``'b'`` as it is a text stream.
+- :issue:`5257`: Ensure that ``sys.stdout.mode`` does not include ``'b'`` as it is a text stream.
 
 
-- `#5278 <https://github.com/pytest-dev/pytest/issues/5278>`_: Pytest's internal python plugin can be disabled using ``-p no:python`` again.
+- :issue:`5278`: Pytest's internal python plugin can be disabled using ``-p no:python`` again.
 
 
-- `#5286 <https://github.com/pytest-dev/pytest/issues/5286>`_: Fix issue with ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option not working when using a list of test IDs in parametrized tests.
+- :issue:`5286`: Fix issue with ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option not working when using a list of test IDs in parametrized tests.
 
 
-- `#5330 <https://github.com/pytest-dev/pytest/issues/5330>`_: Show the test module being collected when emitting ``PytestCollectionWarning`` messages for
+- :issue:`5330`: Show the test module being collected when emitting ``PytestCollectionWarning`` messages for
   test classes with ``__init__`` and ``__new__`` methods to make it easier to pin down the problem.
 
 
-- `#5333 <https://github.com/pytest-dev/pytest/issues/5333>`_: Fix regression in 4.5.0 with ``--lf`` not re-running all tests with known failures from non-selected tests.
+- :issue:`5333`: Fix regression in 4.5.0 with ``--lf`` not re-running all tests with known failures from non-selected tests.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#5250 <https://github.com/pytest-dev/pytest/issues/5250>`_: Expand docs on use of ``setenv`` and ``delenv`` with ``monkeypatch``.
+- :issue:`5250`: Expand docs on use of ``setenv`` and ``delenv`` with ``monkeypatch``.
 
 
 pytest 4.5.0 (2019-05-11)
@@ -2382,46 +3609,44 @@ pytest 4.5.0 (2019-05-11)
 Features
 --------
 
-- `#4826 <https://github.com/pytest-dev/pytest/issues/4826>`_: A warning is now emitted when unknown marks are used as a decorator.
+- :issue:`4826`: A warning is now emitted when unknown marks are used as a decorator.
   This is often due to a typo, which can lead to silently broken tests.
 
 
-- `#4907 <https://github.com/pytest-dev/pytest/issues/4907>`_: Show XFail reason as part of JUnitXML message field.
+- :issue:`4907`: Show XFail reason as part of JUnitXML message field.
 
 
-- `#5013 <https://github.com/pytest-dev/pytest/issues/5013>`_: Messages from crash reports are displayed within test summaries now, truncated to the terminal width.
+- :issue:`5013`: Messages from crash reports are displayed within test summaries now, truncated to the terminal width.
 
 
-- `#5023 <https://github.com/pytest-dev/pytest/issues/5023>`_: New flag ``--strict-markers`` that triggers an error when unknown markers (e.g. those not registered using the `markers option`_ in the configuration file) are used in the test suite.
+- :issue:`5023`: New flag ``--strict-markers`` that triggers an error when unknown markers (e.g. those not registered using the :confval:`markers` option in the configuration file) are used in the test suite.
 
   The existing ``--strict`` option has the same behavior currently, but can be augmented in the future for additional checks.
 
-  .. _`markers option`: https://docs.pytest.org/en/stable/reference.html#confval-markers
 
+- :issue:`5026`: Assertion failure messages for sequences and dicts contain the number of different items now.
 
-- `#5026 <https://github.com/pytest-dev/pytest/issues/5026>`_: Assertion failure messages for sequences and dicts contain the number of different items now.
 
+- :issue:`5034`: Improve reporting with ``--lf`` and ``--ff`` (run-last-failure).
 
-- `#5034 <https://github.com/pytest-dev/pytest/issues/5034>`_: Improve reporting with ``--lf`` and ``--ff`` (run-last-failure).
 
+- :issue:`5035`: The ``--cache-show`` option/action accepts an optional glob to show only matching cache entries.
 
-- `#5035 <https://github.com/pytest-dev/pytest/issues/5035>`_: The ``--cache-show`` option/action accepts an optional glob to show only matching cache entries.
 
+- :issue:`5059`: Standard input (stdin) can be given to pytester's ``Testdir.run()`` and ``Testdir.popen()``.
 
-- `#5059 <https://github.com/pytest-dev/pytest/issues/5059>`_: Standard input (stdin) can be given to pytester's ``Testdir.run()`` and ``Testdir.popen()``.
 
+- :issue:`5068`: The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.
 
-- `#5068 <https://github.com/pytest-dev/pytest/issues/5068>`_: The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.
 
+- :issue:`5108`: The short test summary is displayed after passes with output (``-rP``).
 
-- `#5108 <https://github.com/pytest-dev/pytest/issues/5108>`_: The short test summary is displayed after passes with output (``-rP``).
 
-
-- `#5172 <https://github.com/pytest-dev/pytest/issues/5172>`_: The ``--last-failed`` (``--lf``) option got smarter and will now skip entire files if all tests
+- :issue:`5172`: The ``--last-failed`` (``--lf``) option got smarter and will now skip entire files if all tests
   of that test file have passed in previous runs, greatly speeding up collection.
 
 
-- `#5177 <https://github.com/pytest-dev/pytest/issues/5177>`_: Introduce new specific warning ``PytestWarning`` subclasses to make it easier to filter warnings based on the class, rather than on the message. The new subclasses are:
+- :issue:`5177`: Introduce new specific warning ``PytestWarning`` subclasses to make it easier to filter warnings based on the class, rather than on the message. The new subclasses are:
 
 
   * ``PytestAssertRewriteWarning``
@@ -2437,14 +3662,14 @@ Features
   * ``PytestUnknownMarkWarning``
 
 
-- `#5202 <https://github.com/pytest-dev/pytest/issues/5202>`_: New ``record_testsuite_property`` session-scoped fixture allows users to log ``<property>`` tags at the ``testsuite``
+- :issue:`5202`: New ``record_testsuite_property`` session-scoped fixture allows users to log ``<property>`` tags at the ``testsuite``
   level with the ``junitxml`` plugin.
 
   The generated XML is compatible with the latest xunit standard, contrary to
   the properties recorded by ``record_property`` and ``record_xml_attribute``.
 
 
-- `#5214 <https://github.com/pytest-dev/pytest/issues/5214>`_: The default logging format has been changed to improve readability. Here is an
+- :issue:`5214`: The default logging format has been changed to improve readability. Here is an
   example of a previous logging message::
 
       test_log_cli_enabled_disabled.py    3 CRITICAL critical message logged by test
@@ -2453,58 +3678,58 @@ Features
 
       CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test
 
-  The formatting can be changed through the `log_format <https://docs.pytest.org/en/stable/reference.html#confval-log_format>`__ configuration option.
+  The formatting can be changed through the :confval:`log_format` configuration option.
 
 
-- `#5220 <https://github.com/pytest-dev/pytest/issues/5220>`_: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``.
+- :issue:`5220`: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``.
 
 
 
 Bug Fixes
 ---------
 
-- `#5113 <https://github.com/pytest-dev/pytest/issues/5113>`_: Deselected items from plugins using ``pytest_collect_modifyitems`` as a hookwrapper are correctly reported now.
+- :issue:`5113`: Deselected items from plugins using ``pytest_collect_modifyitems`` as a hookwrapper are correctly reported now.
 
 
-- `#5144 <https://github.com/pytest-dev/pytest/issues/5144>`_: With usage errors ``exitstatus`` is set to ``EXIT_USAGEERROR`` in the ``pytest_sessionfinish`` hook now as expected.
+- :issue:`5144`: With usage errors ``exitstatus`` is set to ``EXIT_USAGEERROR`` in the ``pytest_sessionfinish`` hook now as expected.
 
 
-- `#5235 <https://github.com/pytest-dev/pytest/issues/5235>`_: ``outcome.exit`` is not used with ``EOF`` in the pdb wrapper anymore, but only with ``quit``.
+- :issue:`5235`: ``outcome.exit`` is not used with ``EOF`` in the pdb wrapper anymore, but only with ``quit``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#4935 <https://github.com/pytest-dev/pytest/issues/4935>`_: Expand docs on registering marks and the effect of ``--strict``.
+- :issue:`4935`: Expand docs on registering marks and the effect of ``--strict``.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4942 <https://github.com/pytest-dev/pytest/issues/4942>`_: ``logging.raiseExceptions`` is not set to ``False`` anymore.
+- :issue:`4942`: ``logging.raiseExceptions`` is not set to ``False`` anymore.
 
 
-- `#5013 <https://github.com/pytest-dev/pytest/issues/5013>`_: pytest now depends on `wcwidth <https://pypi.org/project/wcwidth>`__ to properly track unicode character sizes for more precise terminal output.
+- :issue:`5013`: pytest now depends on :pypi:`wcwidth` to properly track unicode character sizes for more precise terminal output.
 
 
-- `#5059 <https://github.com/pytest-dev/pytest/issues/5059>`_: pytester's ``Testdir.popen()`` uses ``stdout`` and ``stderr`` via keyword arguments with defaults now (``subprocess.PIPE``).
+- :issue:`5059`: pytester's ``Testdir.popen()`` uses ``stdout`` and ``stderr`` via keyword arguments with defaults now (``subprocess.PIPE``).
 
 
-- `#5069 <https://github.com/pytest-dev/pytest/issues/5069>`_: The code for the short test summary in the terminal was moved to the terminal plugin.
+- :issue:`5069`: The code for the short test summary in the terminal was moved to the terminal plugin.
 
 
-- `#5082 <https://github.com/pytest-dev/pytest/issues/5082>`_: Improved validation of kwargs for various methods in the pytester plugin.
+- :issue:`5082`: Improved validation of kwargs for various methods in the pytester plugin.
 
 
-- `#5202 <https://github.com/pytest-dev/pytest/issues/5202>`_: ``record_property`` now emits a ``PytestWarning`` when used with ``junit_family=xunit2``: the fixture generates
+- :issue:`5202`: ``record_property`` now emits a ``PytestWarning`` when used with ``junit_family=xunit2``: the fixture generates
   ``property`` tags as children of ``testcase``, which is not permitted according to the most
   `recent schema <https://github.com/jenkinsci/xunit-plugin/blob/master/
   src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__.
 
 
-- `#5239 <https://github.com/pytest-dev/pytest/issues/5239>`_: Pin ``pluggy`` to ``< 1.0`` so we don't update to ``1.0`` automatically when
+- :issue:`5239`: Pin ``pluggy`` to ``< 1.0`` so we don't update to ``1.0`` automatically when
   it gets released: there are planned breaking changes, and we want to ensure
   pytest properly supports ``pluggy 1.0``.
 
@@ -2515,13 +3740,13 @@ pytest 4.4.2 (2019-05-08)
 Bug Fixes
 ---------
 
-- `#5089 <https://github.com/pytest-dev/pytest/issues/5089>`_: Fix crash caused by error in ``__repr__`` function with both ``showlocals`` and verbose output enabled.
+- :issue:`5089`: Fix crash caused by error in ``__repr__`` function with both ``showlocals`` and verbose output enabled.
 
 
-- `#5139 <https://github.com/pytest-dev/pytest/issues/5139>`_: Eliminate core dependency on 'terminal' plugin.
+- :issue:`5139`: Eliminate core dependency on 'terminal' plugin.
 
 
-- `#5229 <https://github.com/pytest-dev/pytest/issues/5229>`_: Require ``pluggy>=0.11.0`` which reverts a dependency to ``importlib-metadata`` added in ``0.10.0``.
+- :issue:`5229`: Require ``pluggy>=0.11.0`` which reverts a dependency to ``importlib-metadata`` added in ``0.10.0``.
   The ``importlib-metadata`` package cannot be imported when installed as an egg and causes issues when relying on ``setup.py`` to install test dependencies.
 
 
@@ -2529,17 +3754,17 @@ Bug Fixes
 Improved Documentation
 ----------------------
 
-- `#5171 <https://github.com/pytest-dev/pytest/issues/5171>`_: Doc: ``pytest_ignore_collect``, ``pytest_collect_directory``, ``pytest_collect_file`` and ``pytest_pycollect_makemodule`` hooks's 'path' parameter documented type is now ``py.path.local``
+- :issue:`5171`: Doc: ``pytest_ignore_collect``, ``pytest_collect_directory``, ``pytest_collect_file`` and ``pytest_pycollect_makemodule`` hooks's 'path' parameter documented type is now ``py.path.local``
 
 
-- `#5188 <https://github.com/pytest-dev/pytest/issues/5188>`_: Improve help for ``--runxfail`` flag.
+- :issue:`5188`: Improve help for ``--runxfail`` flag.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#5182 <https://github.com/pytest-dev/pytest/issues/5182>`_: Removed internal and unused ``_pytest.deprecated.MARK_INFO_ATTRIBUTE``.
+- :issue:`5182`: Removed internal and unused ``_pytest.deprecated.MARK_INFO_ATTRIBUTE``.
 
 
 pytest 4.4.1 (2019-04-15)
@@ -2548,16 +3773,16 @@ pytest 4.4.1 (2019-04-15)
 Bug Fixes
 ---------
 
-- `#5031 <https://github.com/pytest-dev/pytest/issues/5031>`_: Environment variables are properly restored when using pytester's ``testdir`` fixture.
+- :issue:`5031`: Environment variables are properly restored when using pytester's ``testdir`` fixture.
 
 
-- `#5039 <https://github.com/pytest-dev/pytest/issues/5039>`_: Fix regression with ``--pdbcls``, which stopped working with local modules in 4.0.0.
+- :issue:`5039`: Fix regression with ``--pdbcls``, which stopped working with local modules in 4.0.0.
 
 
-- `#5092 <https://github.com/pytest-dev/pytest/issues/5092>`_: Produce a warning when unknown keywords are passed to ``pytest.param(...)``.
+- :issue:`5092`: Produce a warning when unknown keywords are passed to ``pytest.param(...)``.
 
 
-- `#5098 <https://github.com/pytest-dev/pytest/issues/5098>`_: Invalidate import caches with ``monkeypatch.syspath_prepend``, which is required with namespace packages being used.
+- :issue:`5098`: Invalidate import caches with ``monkeypatch.syspath_prepend``, which is required with namespace packages being used.
 
 
 pytest 4.4.0 (2019-03-29)
@@ -2566,16 +3791,16 @@ pytest 4.4.0 (2019-03-29)
 Features
 --------
 
-- `#2224 <https://github.com/pytest-dev/pytest/issues/2224>`_: ``async`` test functions are skipped and a warning is emitted when a suitable
+- :issue:`2224`: ``async`` test functions are skipped and a warning is emitted when a suitable
   async plugin is not installed (such as ``pytest-asyncio`` or ``pytest-trio``).
 
   Previously ``async`` functions would not execute at all but still be marked as "passed".
 
 
-- `#2482 <https://github.com/pytest-dev/pytest/issues/2482>`_: Include new ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk.
+- :issue:`2482`: Include new ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk.
 
 
-- `#4718 <https://github.com/pytest-dev/pytest/issues/4718>`_: The ``-p`` option can now be used to early-load plugins also by entry-point name, instead of just
+- :issue:`4718`: The ``-p`` option can now be used to early-load plugins also by entry-point name, instead of just
   by module name.
 
   This makes it possible to early load external plugins like ``pytest-cov`` in the command-line::
@@ -2583,54 +3808,52 @@ Features
       pytest -p pytest_cov
 
 
-- `#4855 <https://github.com/pytest-dev/pytest/issues/4855>`_: The ``--pdbcls`` option handles classes via module attributes now (e.g.
-  ``pdb:pdb.Pdb`` with `pdb++`_), and its validation was improved.
-
-  .. _pdb++: https://pypi.org/project/pdbpp/
+- :issue:`4855`: The ``--pdbcls`` option handles classes via module attributes now (e.g.
+  ``pdb:pdb.Pdb`` with :pypi:`pdbpp`), and its validation was improved.
 
 
-- `#4875 <https://github.com/pytest-dev/pytest/issues/4875>`_: The `testpaths <https://docs.pytest.org/en/stable/reference.html#confval-testpaths>`__ configuration option is now displayed next
+- :issue:`4875`: The :confval:`testpaths` configuration option is now displayed next
   to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were
   not explicitly passed in the command line.
 
   Also, ``inifile`` is only displayed if there's a configuration file, instead of an empty ``inifile:`` string.
 
 
-- `#4911 <https://github.com/pytest-dev/pytest/issues/4911>`_: Doctests can be skipped now dynamically using ``pytest.skip()``.
+- :issue:`4911`: Doctests can be skipped now dynamically using ``pytest.skip()``.
 
 
-- `#4920 <https://github.com/pytest-dev/pytest/issues/4920>`_: Internal refactorings have been made in order to make the implementation of the
+- :issue:`4920`: Internal refactorings have been made in order to make the implementation of the
   `pytest-subtests <https://github.com/pytest-dev/pytest-subtests>`__ plugin
   possible, which adds unittest sub-test support and a new ``subtests`` fixture as discussed in
-  `#1367 <https://github.com/pytest-dev/pytest/issues/1367>`__.
+  :issue:`1367`.
 
   For details on the internal refactorings, please see the details on the related PR.
 
 
-- `#4931 <https://github.com/pytest-dev/pytest/issues/4931>`_: pytester's ``LineMatcher`` asserts that the passed lines are a sequence.
+- :issue:`4931`: pytester's ``LineMatcher`` asserts that the passed lines are a sequence.
 
 
-- `#4936 <https://github.com/pytest-dev/pytest/issues/4936>`_: Handle ``-p plug`` after ``-p no:plug``.
+- :issue:`4936`: Handle ``-p plug`` after ``-p no:plug``.
 
   This can be used to override a blocked plugin (e.g. in "addopts") from the
   command line etc.
 
 
-- `#4951 <https://github.com/pytest-dev/pytest/issues/4951>`_: Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with ``pdb.set_trace()``.
+- :issue:`4951`: Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with ``pdb.set_trace()``.
 
 
-- `#4956 <https://github.com/pytest-dev/pytest/issues/4956>`_: ``pytester`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory during test runs.
+- :issue:`4956`: ``pytester`` sets ``$HOME`` and ``$USERPROFILE`` to the temporary directory during test runs.
 
   This ensures to not load configuration files from the real user's home directory.
 
 
-- `#4980 <https://github.com/pytest-dev/pytest/issues/4980>`_: Namespace packages are handled better with ``monkeypatch.syspath_prepend`` and ``testdir.syspathinsert`` (via ``pkg_resources.fixup_namespace_packages``).
+- :issue:`4980`: Namespace packages are handled better with ``monkeypatch.syspath_prepend`` and ``testdir.syspathinsert`` (via ``pkg_resources.fixup_namespace_packages``).
 
 
-- `#4993 <https://github.com/pytest-dev/pytest/issues/4993>`_: The stepwise plugin reports status information now.
+- :issue:`4993`: The stepwise plugin reports status information now.
 
 
-- `#5008 <https://github.com/pytest-dev/pytest/issues/5008>`_: If a ``setup.cfg`` file contains ``[tool:pytest]`` and also the no longer supported ``[pytest]`` section, pytest will use ``[tool:pytest]`` ignoring ``[pytest]``. Previously it would unconditionally error out.
+- :issue:`5008`: If a ``setup.cfg`` file contains ``[tool:pytest]`` and also the no longer supported ``[pytest]`` section, pytest will use ``[tool:pytest]`` ignoring ``[pytest]``. Previously it would unconditionally error out.
 
   This makes it simpler for plugins to support old pytest versions.
 
@@ -2639,72 +3862,70 @@ Features
 Bug Fixes
 ---------
 
-- `#1895 <https://github.com/pytest-dev/pytest/issues/1895>`_: Fix bug where fixtures requested dynamically via ``request.getfixturevalue()`` might be teardown
+- :issue:`1895`: Fix bug where fixtures requested dynamically via ``request.getfixturevalue()`` might be teardown
   before the requesting fixture.
 
 
-- `#4851 <https://github.com/pytest-dev/pytest/issues/4851>`_: pytester unsets ``PYTEST_ADDOPTS`` now to not use outer options with ``testdir.runpytest()``.
+- :issue:`4851`: pytester unsets ``PYTEST_ADDOPTS`` now to not use outer options with ``testdir.runpytest()``.
 
 
-- `#4903 <https://github.com/pytest-dev/pytest/issues/4903>`_: Use the correct modified time for years after 2038 in rewritten ``.pyc`` files.
+- :issue:`4903`: Use the correct modified time for years after 2038 in rewritten ``.pyc`` files.
 
 
-- `#4928 <https://github.com/pytest-dev/pytest/issues/4928>`_: Fix line offsets with ``ScopeMismatch`` errors.
+- :issue:`4928`: Fix line offsets with ``ScopeMismatch`` errors.
 
 
-- `#4957 <https://github.com/pytest-dev/pytest/issues/4957>`_: ``-p no:plugin`` is handled correctly for default (internal) plugins now, e.g. with ``-p no:capture``.
+- :issue:`4957`: ``-p no:plugin`` is handled correctly for default (internal) plugins now, e.g. with ``-p no:capture``.
 
   Previously they were loaded (imported) always, making e.g. the ``capfd`` fixture available.
 
 
-- `#4968 <https://github.com/pytest-dev/pytest/issues/4968>`_: The pdb ``quit`` command is handled properly when used after the ``debug`` command with `pdb++`_.
+- :issue:`4968`: The pdb ``quit`` command is handled properly when used after the ``debug`` command with :pypi:`pdbpp`.
 
-  .. _pdb++: https://pypi.org/project/pdbpp/
 
+- :issue:`4975`: Fix the interpretation of ``-qq`` option where it was being considered as ``-v`` instead.
 
-- `#4975 <https://github.com/pytest-dev/pytest/issues/4975>`_: Fix the interpretation of ``-qq`` option where it was being considered as ``-v`` instead.
 
+- :issue:`4978`: ``outcomes.Exit`` is not swallowed in ``assertrepr_compare`` anymore.
 
-- `#4978 <https://github.com/pytest-dev/pytest/issues/4978>`_: ``outcomes.Exit`` is not swallowed in ``assertrepr_compare`` anymore.
 
+- :issue:`4988`: Close logging's file handler explicitly when the session finishes.
 
-- `#4988 <https://github.com/pytest-dev/pytest/issues/4988>`_: Close logging's file handler explicitly when the session finishes.
 
-
-- `#5003 <https://github.com/pytest-dev/pytest/issues/5003>`_: Fix line offset with mark collection error (off by one).
+- :issue:`5003`: Fix line offset with mark collection error (off by one).
 
 
 
 Improved Documentation
 ----------------------
 
-- `#4974 <https://github.com/pytest-dev/pytest/issues/4974>`_: Update docs for ``pytest_cmdline_parse`` hook to note availability liminations
+- :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability liminations
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4718 <https://github.com/pytest-dev/pytest/issues/4718>`_: ``pluggy>=0.9`` is now required.
+- :issue:`4718`: ``pluggy>=0.9`` is now required.
 
 
-- `#4815 <https://github.com/pytest-dev/pytest/issues/4815>`_: ``funcsigs>=1.0`` is now required for Python 2.7.
+- :issue:`4815`: ``funcsigs>=1.0`` is now required for Python 2.7.
 
 
-- `#4829 <https://github.com/pytest-dev/pytest/issues/4829>`_: Some left-over internal code related to ``yield`` tests has been removed.
+- :issue:`4829`: Some left-over internal code related to ``yield`` tests has been removed.
 
 
-- `#4890 <https://github.com/pytest-dev/pytest/issues/4890>`_: Remove internally unused ``anypython`` fixture from the pytester plugin.
+- :issue:`4890`: Remove internally unused ``anypython`` fixture from the pytester plugin.
 
 
-- `#4912 <https://github.com/pytest-dev/pytest/issues/4912>`_: Remove deprecated Sphinx directive, ``add_description_unit()``,
+- :issue:`4912`: Remove deprecated Sphinx directive, ``add_description_unit()``,
   pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0.
 
 
-- `#4913 <https://github.com/pytest-dev/pytest/issues/4913>`_: Fix pytest tests invocation with custom ``PYTHONPATH``.
+- :issue:`4913`: Fix pytest tests invocation with custom ``PYTHONPATH``.
 
 
-- `#4965 <https://github.com/pytest-dev/pytest/issues/4965>`_: New ``pytest_report_to_serializable`` and ``pytest_report_from_serializable`` **experimental** hooks.
+- :issue:`4965`: New ``pytest_report_to_serializable`` and ``pytest_report_from_serializable`` **experimental** hooks.
 
   These hooks will be used by ``pytest-xdist``, ``pytest-subtests``, and the replacement for
   resultlog to serialize and customize reports.
@@ -2715,7 +3936,7 @@ Trivial/Internal Changes
   Feedback is welcome from plugin authors and users alike.
 
 
-- `#4987 <https://github.com/pytest-dev/pytest/issues/4987>`_: ``Collector.repr_failure`` respects the ``--tb`` option, but only defaults to ``short`` now (with ``auto``).
+- :issue:`4987`: ``Collector.repr_failure`` respects the ``--tb`` option, but only defaults to ``short`` now (with ``auto``).
 
 
 pytest 4.3.1 (2019-03-11)
@@ -2724,20 +3945,20 @@ pytest 4.3.1 (2019-03-11)
 Bug Fixes
 ---------
 
-- `#4810 <https://github.com/pytest-dev/pytest/issues/4810>`_: Logging messages inside ``pytest_runtest_logreport()`` are now properly captured and displayed.
+- :issue:`4810`: Logging messages inside ``pytest_runtest_logreport()`` are now properly captured and displayed.
 
 
-- `#4861 <https://github.com/pytest-dev/pytest/issues/4861>`_: Improve validation of contents written to captured output so it behaves the same as when capture is disabled.
+- :issue:`4861`: Improve validation of contents written to captured output so it behaves the same as when capture is disabled.
 
 
-- `#4898 <https://github.com/pytest-dev/pytest/issues/4898>`_: Fix ``AttributeError: FixtureRequest has no 'confg' attribute`` bug in ``testdir.copy_example``.
+- :issue:`4898`: Fix ``AttributeError: FixtureRequest has no 'confg' attribute`` bug in ``testdir.copy_example``.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4768 <https://github.com/pytest-dev/pytest/issues/4768>`_: Avoid pkg_resources import at the top-level.
+- :issue:`4768`: Avoid pkg_resources import at the top-level.
 
 
 pytest 4.3.0 (2019-02-16)
@@ -2746,7 +3967,7 @@ pytest 4.3.0 (2019-02-16)
 Deprecations
 ------------
 
-- `#4724 <https://github.com/pytest-dev/pytest/issues/4724>`_: ``pytest.warns()`` now emits a warning when it receives unknown keyword arguments.
+- :issue:`4724`: ``pytest.warns()`` now emits a warning when it receives unknown keyword arguments.
 
   This will be changed into an error in the future.
 
@@ -2755,31 +3976,31 @@ Deprecations
 Features
 --------
 
-- `#2753 <https://github.com/pytest-dev/pytest/issues/2753>`_: Usage errors from argparse are mapped to pytest's ``UsageError``.
+- :issue:`2753`: Usage errors from argparse are mapped to pytest's ``UsageError``.
 
 
-- `#3711 <https://github.com/pytest-dev/pytest/issues/3711>`_: Add the ``--ignore-glob`` parameter to exclude test-modules with Unix shell-style wildcards.
+- :issue:`3711`: Add the ``--ignore-glob`` parameter to exclude test-modules with Unix shell-style wildcards.
   Add the :globalvar:`collect_ignore_glob` for ``conftest.py`` to exclude test-modules with Unix shell-style wildcards.
 
 
-- `#4698 <https://github.com/pytest-dev/pytest/issues/4698>`_: The warning about Python 2.7 and 3.4 not being supported in pytest 5.0 has been removed.
+- :issue:`4698`: The warning about Python 2.7 and 3.4 not being supported in pytest 5.0 has been removed.
 
   In the end it was considered to be more
   of a nuisance than actual utility and users of those Python versions shouldn't have problems as ``pip`` will not
   install pytest 5.0 on those interpreters.
 
 
-- `#4707 <https://github.com/pytest-dev/pytest/issues/4707>`_: With the help of new ``set_log_path()`` method there is a way to set ``log_file`` paths from hooks.
+- :issue:`4707`: With the help of new ``set_log_path()`` method there is a way to set ``log_file`` paths from hooks.
 
 
 
 Bug Fixes
 ---------
 
-- `#4651 <https://github.com/pytest-dev/pytest/issues/4651>`_: ``--help`` and ``--version`` are handled with ``UsageError``.
+- :issue:`4651`: ``--help`` and ``--version`` are handled with ``UsageError``.
 
 
-- `#4782 <https://github.com/pytest-dev/pytest/issues/4782>`_: Fix ``AssertionError`` with collection of broken symlinks with packages.
+- :issue:`4782`: Fix ``AssertionError`` with collection of broken symlinks with packages.
 
 
 pytest 4.2.1 (2019-02-12)
@@ -2788,45 +4009,45 @@ pytest 4.2.1 (2019-02-12)
 Bug Fixes
 ---------
 
-- `#2895 <https://github.com/pytest-dev/pytest/issues/2895>`_: The ``pytest_report_collectionfinish`` hook now is also called with ``--collect-only``.
+- :issue:`2895`: The ``pytest_report_collectionfinish`` hook now is also called with ``--collect-only``.
 
 
-- `#3899 <https://github.com/pytest-dev/pytest/issues/3899>`_: Do not raise ``UsageError`` when an imported package has a ``pytest_plugins.py`` child module.
+- :issue:`3899`: Do not raise ``UsageError`` when an imported package has a ``pytest_plugins.py`` child module.
 
 
-- `#4347 <https://github.com/pytest-dev/pytest/issues/4347>`_: Fix output capturing when using pdb++ with recursive debugging.
+- :issue:`4347`: Fix output capturing when using pdb++ with recursive debugging.
 
 
-- `#4592 <https://github.com/pytest-dev/pytest/issues/4592>`_: Fix handling of ``collect_ignore`` via parent ``conftest.py``.
+- :issue:`4592`: Fix handling of ``collect_ignore`` via parent ``conftest.py``.
 
 
-- `#4700 <https://github.com/pytest-dev/pytest/issues/4700>`_: Fix regression where ``setUpClass`` would always be called in subclasses even if all tests
+- :issue:`4700`: Fix regression where ``setUpClass`` would always be called in subclasses even if all tests
   were skipped by a ``unittest.skip()`` decorator applied in the subclass.
 
 
-- `#4739 <https://github.com/pytest-dev/pytest/issues/4739>`_: Fix ``parametrize(... ids=<function>)`` when the function returns non-strings.
+- :issue:`4739`: Fix ``parametrize(... ids=<function>)`` when the function returns non-strings.
 
 
-- `#4745 <https://github.com/pytest-dev/pytest/issues/4745>`_: Fix/improve collection of args when passing in ``__init__.py`` and a test file.
+- :issue:`4745`: Fix/improve collection of args when passing in ``__init__.py`` and a test file.
 
 
-- `#4770 <https://github.com/pytest-dev/pytest/issues/4770>`_: ``more_itertools`` is now constrained to <6.0.0 when required for Python 2.7 compatibility.
+- :issue:`4770`: ``more_itertools`` is now constrained to <6.0.0 when required for Python 2.7 compatibility.
 
 
-- `#526 <https://github.com/pytest-dev/pytest/issues/526>`_: Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source.
+- :issue:`526`: Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3899 <https://github.com/pytest-dev/pytest/issues/3899>`_: Add note to ``plugins.rst`` that ``pytest_plugins`` should not be used as a name for a user module containing plugins.
+- :issue:`3899`: Add note to ``plugins.rst`` that ``pytest_plugins`` should not be used as a name for a user module containing plugins.
 
 
-- `#4324 <https://github.com/pytest-dev/pytest/issues/4324>`_: Document how to use ``raises`` and ``does_not_raise`` to write parametrized tests with conditional raises.
+- :issue:`4324`: Document how to use ``raises`` and ``does_not_raise`` to write parametrized tests with conditional raises.
 
 
-- `#4709 <https://github.com/pytest-dev/pytest/issues/4709>`_: Document how to customize test failure messages when using
+- :issue:`4709`: Document how to customize test failure messages when using
   ``pytest.warns``.
 
 
@@ -2834,7 +4055,7 @@ Improved Documentation
 Trivial/Internal Changes
 ------------------------
 
-- `#4741 <https://github.com/pytest-dev/pytest/issues/4741>`_: Some verbosity related attributes of the TerminalReporter plugin are now
+- :issue:`4741`: Some verbosity related attributes of the TerminalReporter plugin are now
   read only properties.
 
 
@@ -2844,79 +4065,79 @@ pytest 4.2.0 (2019-01-30)
 Features
 --------
 
-- `#3094 <https://github.com/pytest-dev/pytest/issues/3094>`_: `Classic xunit-style <https://docs.pytest.org/en/stable/xunit_setup.html>`__ functions and methods
+- :issue:`3094`: :doc:`Classic xunit-style <how-to/xunit_setup>` functions and methods
   now obey the scope of *autouse* fixtures.
 
   This fixes a number of surprising issues like ``setup_method`` being called before session-scoped
-  autouse fixtures (see `#517 <https://github.com/pytest-dev/pytest/issues/517>`__ for an example).
+  autouse fixtures (see :issue:`517` for an example).
 
 
-- `#4627 <https://github.com/pytest-dev/pytest/issues/4627>`_: Display a message at the end of the test session when running under Python 2.7 and 3.4 that pytest 5.0 will no longer
+- :issue:`4627`: Display a message at the end of the test session when running under Python 2.7 and 3.4 that pytest 5.0 will no longer
   support those Python versions.
 
 
-- `#4660 <https://github.com/pytest-dev/pytest/issues/4660>`_: The number of *selected* tests now are also displayed when the ``-k`` or ``-m`` flags are used.
+- :issue:`4660`: The number of *selected* tests now are also displayed when the ``-k`` or ``-m`` flags are used.
 
 
-- `#4688 <https://github.com/pytest-dev/pytest/issues/4688>`_: ``pytest_report_teststatus`` hook now can also receive a ``config`` parameter.
+- :issue:`4688`: ``pytest_report_teststatus`` hook now can also receive a ``config`` parameter.
 
 
-- `#4691 <https://github.com/pytest-dev/pytest/issues/4691>`_: ``pytest_terminal_summary`` hook now can also receive a ``config`` parameter.
+- :issue:`4691`: ``pytest_terminal_summary`` hook now can also receive a ``config`` parameter.
 
 
 
 Bug Fixes
 ---------
 
-- `#3547 <https://github.com/pytest-dev/pytest/issues/3547>`_: ``--junitxml`` can emit XML compatible with Jenkins xUnit.
+- :issue:`3547`: ``--junitxml`` can emit XML compatible with Jenkins xUnit.
   ``junit_family`` INI option accepts ``legacy|xunit1``, which produces old style output, and ``xunit2`` that conforms more strictly to https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
 
 
-- `#4280 <https://github.com/pytest-dev/pytest/issues/4280>`_: Improve quitting from pdb, especially with ``--trace``.
+- :issue:`4280`: Improve quitting from pdb, especially with ``--trace``.
 
   Using ``q[quit]`` after ``pdb.set_trace()`` will quit pytest also.
 
 
-- `#4402 <https://github.com/pytest-dev/pytest/issues/4402>`_: Warning summary now groups warnings by message instead of by test id.
+- :issue:`4402`: Warning summary now groups warnings by message instead of by test id.
 
   This makes the output more compact and better conveys the general idea of how much code is
   actually generating warnings, instead of how many tests call that code.
 
 
-- `#4536 <https://github.com/pytest-dev/pytest/issues/4536>`_: ``monkeypatch.delattr`` handles class descriptors like ``staticmethod``/``classmethod``.
+- :issue:`4536`: ``monkeypatch.delattr`` handles class descriptors like ``staticmethod``/``classmethod``.
 
 
-- `#4649 <https://github.com/pytest-dev/pytest/issues/4649>`_: Restore marks being considered keywords for keyword expressions.
+- :issue:`4649`: Restore marks being considered keywords for keyword expressions.
 
 
-- `#4653 <https://github.com/pytest-dev/pytest/issues/4653>`_: ``tmp_path`` fixture and other related ones provides resolved path (a.k.a real path)
+- :issue:`4653`: ``tmp_path`` fixture and other related ones provides resolved path (a.k.a real path)
 
 
-- `#4667 <https://github.com/pytest-dev/pytest/issues/4667>`_: ``pytest_terminal_summary`` uses result from ``pytest_report_teststatus`` hook, rather than hardcoded strings.
+- :issue:`4667`: ``pytest_terminal_summary`` uses result from ``pytest_report_teststatus`` hook, rather than hardcoded strings.
 
 
-- `#4669 <https://github.com/pytest-dev/pytest/issues/4669>`_: Correctly handle ``unittest.SkipTest`` exception containing non-ascii characters on Python 2.
+- :issue:`4669`: Correctly handle ``unittest.SkipTest`` exception containing non-ascii characters on Python 2.
 
 
-- `#4680 <https://github.com/pytest-dev/pytest/issues/4680>`_: Ensure the ``tmpdir`` and the ``tmp_path`` fixtures are the same folder.
+- :issue:`4680`: Ensure the ``tmpdir`` and the ``tmp_path`` fixtures are the same folder.
 
 
-- `#4681 <https://github.com/pytest-dev/pytest/issues/4681>`_: Ensure ``tmp_path`` is always a real path.
+- :issue:`4681`: Ensure ``tmp_path`` is always a real path.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4643 <https://github.com/pytest-dev/pytest/issues/4643>`_: Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``.
+- :issue:`4643`: Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``.
 
-  ``np.asscalar`` has been `deprecated <https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations>`__ in ``numpy 1.16.``.
+  ``np.asscalar`` has been :doc:`deprecated <numpy:release/1.16.0-notes>` in ``numpy 1.16.``.
 
 
-- `#4657 <https://github.com/pytest-dev/pytest/issues/4657>`_: Copy saferepr from pylib
+- :issue:`4657`: Copy saferepr from pylib
 
 
-- `#4668 <https://github.com/pytest-dev/pytest/issues/4668>`_: The verbose word for expected failures in the teststatus report changes from ``xfail`` to ``XFAIL`` to be consistent with other test outcomes.
+- :issue:`4668`: The verbose word for expected failures in the teststatus report changes from ``xfail`` to ``XFAIL`` to be consistent with other test outcomes.
 
 
 pytest 4.1.1 (2019-01-12)
@@ -2925,30 +4146,30 @@ pytest 4.1.1 (2019-01-12)
 Bug Fixes
 ---------
 
-- `#2256 <https://github.com/pytest-dev/pytest/issues/2256>`_: Show full repr with ``assert a==b`` and ``-vv``.
+- :issue:`2256`: Show full repr with ``assert a==b`` and ``-vv``.
 
 
-- `#3456 <https://github.com/pytest-dev/pytest/issues/3456>`_: Extend Doctest-modules to ignore mock objects.
+- :issue:`3456`: Extend Doctest-modules to ignore mock objects.
 
 
-- `#4617 <https://github.com/pytest-dev/pytest/issues/4617>`_: Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization).
+- :issue:`4617`: Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization).
 
 
-- `#4631 <https://github.com/pytest-dev/pytest/issues/4631>`_: Don't rewrite assertion when ``__getattr__`` is broken
+- :issue:`4631`: Don't rewrite assertion when ``__getattr__`` is broken
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3375 <https://github.com/pytest-dev/pytest/issues/3375>`_: Document that using ``setup.cfg`` may crash other tools or cause hard to track down problems because it uses a different parser than ``pytest.ini`` or ``tox.ini`` files.
+- :issue:`3375`: Document that using ``setup.cfg`` may crash other tools or cause hard to track down problems because it uses a different parser than ``pytest.ini`` or ``tox.ini`` files.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4602 <https://github.com/pytest-dev/pytest/issues/4602>`_: Uninstall ``hypothesis`` in regen tox env.
+- :issue:`4602`: Uninstall ``hypothesis`` in regen tox env.
 
 
 pytest 4.1.0 (2019-01-05)
@@ -2957,115 +4178,115 @@ pytest 4.1.0 (2019-01-05)
 Removals
 --------
 
-- `#2169 <https://github.com/pytest-dev/pytest/issues/2169>`_: ``pytest.mark.parametrize``: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred.
+- :issue:`2169`: ``pytest.mark.parametrize``: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred.
 
 
-- `#3078 <https://github.com/pytest-dev/pytest/issues/3078>`_: Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented.
+- :issue:`3078`: Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#config-warn-and-node-warn>`__ on information on how to update your code.
+  See our :ref:`docs <config.warn and node.warn deprecated>` on information on how to update your code.
 
 
-- `#3079 <https://github.com/pytest-dev/pytest/issues/3079>`_: Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated.
+- :issue:`3079`: Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#yield-tests>`__ on information on how to update your code.
+  See our :ref:`docs <yield tests deprecated>` on information on how to update your code.
 
 
-- `#3082 <https://github.com/pytest-dev/pytest/issues/3082>`_: Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead.
+- :issue:`3082`: Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#marks-in-pytest-mark-parametrize>`__ on information on how to update your code.
+  See our :ref:`docs <marks in pytest.parametrize deprecated>` on information on how to update your code.
 
 
-- `#3083 <https://github.com/pytest-dev/pytest/issues/3083>`_: Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``.
+- :issue:`3083`: Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#metafunc-addcall>`__ on information on how to update your code.
+  See our :ref:`docs <metafunc.addcall deprecated>` on information on how to update your code.
 
 
-- `#3085 <https://github.com/pytest-dev/pytest/issues/3085>`_: Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead.
+- :issue:`3085`: Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#passing-command-line-string-to-pytest-main>`__ on information on how to update your code.
+  See our :ref:`docs <passing command-line string to pytest.main deprecated>` on information on how to update your code.
 
 
-- `#3086 <https://github.com/pytest-dev/pytest/issues/3086>`_: ``[pytest]`` section in **setup.cfg** files is no longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files
+- :issue:`3086`: ``[pytest]`` section in **setup.cfg** files is no longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files
   are meant for use with ``distutils``, and a section named ``pytest`` has notoriously been a source of conflicts and bugs.
 
   Note that for **pytest.ini** and **tox.ini** files the section remains ``[pytest]``.
 
 
-- `#3616 <https://github.com/pytest-dev/pytest/issues/3616>`_: Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now.
+- :issue:`3616`: Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#internal-classes-accessed-through-node>`__ on information on how to update your code.
+  See our :ref:`docs <internal classes accessed through node deprecated>` on information on how to update your code.
 
 
-- `#4421 <https://github.com/pytest-dev/pytest/issues/4421>`_: Removed the implementation of the ``pytest_namespace`` hook.
+- :issue:`4421`: Removed the implementation of the ``pytest_namespace`` hook.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#pytest-namespace>`__ on information on how to update your code.
+  See our :ref:`docs <pytest.namespace deprecated>` on information on how to update your code.
 
 
-- `#4489 <https://github.com/pytest-dev/pytest/issues/4489>`_: Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures.
+- :issue:`4489`: Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#cached-setup>`__ on information on how to update your code.
+  See our :ref:`docs <cached_setup deprecated>` on information on how to update your code.
 
 
-- `#4535 <https://github.com/pytest-dev/pytest/issues/4535>`_: Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago.
+- :issue:`4535`: Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago.
 
 
-- `#4543 <https://github.com/pytest-dev/pytest/issues/4543>`_: Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead.
+- :issue:`4543`: Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#pytest-funcarg-prefix>`__ on information on how to update your code.
+  See our :ref:`docs <pytest_funcarg__ prefix deprecated>` on information on how to update your code.
 
 
-- `#4545 <https://github.com/pytest-dev/pytest/issues/4545>`_: Calling fixtures directly is now always an error instead of a warning.
+- :issue:`4545`: Calling fixtures directly is now always an error instead of a warning.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directly>`__ on information on how to update your code.
+  See our :ref:`docs <calling fixtures directly deprecated>` on information on how to update your code.
 
 
-- `#4546 <https://github.com/pytest-dev/pytest/issues/4546>`_: Remove ``Node.get_marker(name)`` the return value was not usable for more than a existence check.
+- :issue:`4546`: Remove ``Node.get_marker(name)`` the return value was not usable for more than an existence check.
 
   Use ``Node.get_closest_marker(name)`` as a replacement.
 
 
-- `#4547 <https://github.com/pytest-dev/pytest/issues/4547>`_: The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead.
+- :issue:`4547`: The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead.
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#record-xml-property>`__ for more information.
+  See our :ref:`docs <record_xml_property deprecated>` for more information.
 
 
-- `#4548 <https://github.com/pytest-dev/pytest/issues/4548>`_: An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``).
+- :issue:`4548`: An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``).
 
-  See our `docs <https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files>`__ for more information.
+  See our :ref:`docs <pytest_plugins in non-top-level conftest files deprecated>` for more information.
 
 
-- `#891 <https://github.com/pytest-dev/pytest/issues/891>`_: Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them.
+- :issue:`891`: Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them.
 
 
 
 Deprecations
 ------------
 
-- `#3050 <https://github.com/pytest-dev/pytest/issues/3050>`_: Deprecated the ``pytest.config`` global.
+- :issue:`3050`: Deprecated the ``pytest.config`` global.
 
-  See https://docs.pytest.org/en/stable/deprecations.html#pytest-config-global for rationale.
+  See :ref:`pytest.config global deprecated` for rationale.
 
 
-- `#3974 <https://github.com/pytest-dev/pytest/issues/3974>`_: Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``.
+- :issue:`3974`: Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``.
 
   It is a common mistake to think this parameter will match the exception message, while in fact
   it only serves to provide a custom message in case the ``pytest.raises`` check fails. To avoid this
   mistake and because it is believed to be little used, pytest is deprecating it without providing
   an alternative for the moment.
 
-  If you have concerns about this, please comment on `issue #3974 <https://github.com/pytest-dev/pytest/issues/3974>`__.
+  If you have concerns about this, please comment on :issue:`3974`.
 
 
-- `#4435 <https://github.com/pytest-dev/pytest/issues/4435>`_: Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``.
+- :issue:`4435`: Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``.
 
-  See https://docs.pytest.org/en/stable/deprecations.html#raises-warns-exec for rationale and examples.
+  See :std:ref:`raises-warns-exec` for rationale and examples.
 
 
 
 Features
 --------
 
-- `#3191 <https://github.com/pytest-dev/pytest/issues/3191>`_: A warning is now issued when assertions are made for ``None``.
+- :issue:`3191`: A warning is now issued when assertions are made for ``None``.
 
   This is a common source of confusion among new users, which write:
 
@@ -3090,25 +4311,25 @@ Features
   will not issue the warning.
 
 
-- `#3632 <https://github.com/pytest-dev/pytest/issues/3632>`_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <http://www.attrs.org/en/stable/>`__ or `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (Python 3.7+, `backported to 3.6 <https://pypi.org/project/dataclasses>`__).
+- :issue:`3632`: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <https://www.attrs.org/en/stable/>`__ or :mod:`dataclasses` (Python 3.7+, :pypi:`backported to 3.6 <dataclasses>`).
 
 
-- `#4278 <https://github.com/pytest-dev/pytest/issues/4278>`_: ``CACHEDIR.TAG`` files are now created inside cache directories.
+- :issue:`4278`: ``CACHEDIR.TAG`` files are now created inside cache directories.
 
-  Those files are part of the `Cache Directory Tagging Standard <http://www.bford.info/cachedir/spec.html>`__, and can
+  Those files are part of the `Cache Directory Tagging Standard <https://bford.info/cachedir/spec.html>`__, and can
   be used by backup or synchronization programs to identify pytest's cache directory as such.
 
 
-- `#4292 <https://github.com/pytest-dev/pytest/issues/4292>`_: ``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting.
+- :issue:`4292`: ``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting.
 
 
-- `#4371 <https://github.com/pytest-dev/pytest/issues/4371>`_: Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``.
+- :issue:`4371`: Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``.
 
 
-- `#4386 <https://github.com/pytest-dev/pytest/issues/4386>`_: Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``.
+- :issue:`4386`: Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``.
 
 
-- `#4416 <https://github.com/pytest-dev/pytest/issues/4416>`_: pdb: added support for keyword arguments with ``pdb.set_trace``.
+- :issue:`4416`: pdb: added support for keyword arguments with ``pdb.set_trace``.
 
   It handles ``header`` similar to Python 3.7 does it, and forwards any
   other keyword arguments to the ``Pdb`` constructor.
@@ -3116,7 +4337,7 @@ Features
   This allows for ``__import__("pdb").set_trace(skip=["foo.*"])``.
 
 
-- `#4483 <https://github.com/pytest-dev/pytest/issues/4483>`_: Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times.
+- :issue:`4483`: Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times.
 
   The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration
   report. You can include just the call durations instead (excluding setup and teardown) by adding this to your ``pytest.ini`` file:
@@ -3127,12 +4348,12 @@ Features
       junit_duration_report = call
 
 
-- `#4532 <https://github.com/pytest-dev/pytest/issues/4532>`_: ``-ra`` now will show errors and failures last, instead of as the first items in the summary.
+- :issue:`4532`: ``-ra`` now will show errors and failures last, instead of as the first items in the summary.
 
   This makes it easier to obtain a list of errors and failures to run tests selectively.
 
 
-- `#4599 <https://github.com/pytest-dev/pytest/issues/4599>`_: ``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the
+- :issue:`4599`: ``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the
   requested module cannot be imported.
 
 
@@ -3140,39 +4361,39 @@ Features
 Bug Fixes
 ---------
 
-- `#3532 <https://github.com/pytest-dev/pytest/issues/3532>`_: ``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``.
+- :issue:`3532`: ``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``.
 
 
-- `#4327 <https://github.com/pytest-dev/pytest/issues/4327>`_: ``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``.
+- :issue:`4327`: ``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``.
 
 
-- `#4397 <https://github.com/pytest-dev/pytest/issues/4397>`_: Ensure that node ids are printable.
+- :issue:`4397`: Ensure that node ids are printable.
 
 
-- `#4435 <https://github.com/pytest-dev/pytest/issues/4435>`_: Fixed ``raises(..., 'code(string)')`` frame filename.
+- :issue:`4435`: Fixed ``raises(..., 'code(string)')`` frame filename.
 
 
-- `#4458 <https://github.com/pytest-dev/pytest/issues/4458>`_: Display actual test ids in ``--collect-only``.
+- :issue:`4458`: Display actual test ids in ``--collect-only``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#4557 <https://github.com/pytest-dev/pytest/issues/4557>`_: Markers example documentation page updated to support latest pytest version.
+- :issue:`4557`: Markers example documentation page updated to support latest pytest version.
 
 
-- `#4558 <https://github.com/pytest-dev/pytest/issues/4558>`_: Update cache documentation example to correctly show cache hit and miss.
+- :issue:`4558`: Update cache documentation example to correctly show cache hit and miss.
 
 
-- `#4580 <https://github.com/pytest-dev/pytest/issues/4580>`_: Improved detailed summary report documentation.
+- :issue:`4580`: Improved detailed summary report documentation.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4447 <https://github.com/pytest-dev/pytest/issues/4447>`_: Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``.
+- :issue:`4447`: Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``.
 
   It was decided to remove this feature at the next major revision.
 
@@ -3183,23 +4404,23 @@ pytest 4.0.2 (2018-12-13)
 Bug Fixes
 ---------
 
-- `#4265 <https://github.com/pytest-dev/pytest/issues/4265>`_: Validate arguments from the ``PYTEST_ADDOPTS`` environment variable and the ``addopts`` ini option separately.
+- :issue:`4265`: Validate arguments from the ``PYTEST_ADDOPTS`` environment variable and the ``addopts`` ini option separately.
 
 
-- `#4435 <https://github.com/pytest-dev/pytest/issues/4435>`_: Fix ``raises(..., 'code(string)')`` frame filename.
+- :issue:`4435`: Fix ``raises(..., 'code(string)')`` frame filename.
 
 
-- `#4500 <https://github.com/pytest-dev/pytest/issues/4500>`_: When a fixture yields and a log call is made after the test runs, and, if the test is interrupted, capture attributes are ``None``.
+- :issue:`4500`: When a fixture yields and a log call is made after the test runs, and, if the test is interrupted, capture attributes are ``None``.
 
 
-- `#4538 <https://github.com/pytest-dev/pytest/issues/4538>`_: Raise ``TypeError`` for ``with raises(..., match=<non-None falsey value>)``.
+- :issue:`4538`: Raise ``TypeError`` for ``with raises(..., match=<non-None falsey value>)``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#1495 <https://github.com/pytest-dev/pytest/issues/1495>`_: Document common doctest fixture directory tree structure pitfalls
+- :issue:`1495`: Document common doctest fixture directory tree structure pitfalls
 
 
 pytest 4.0.1 (2018-11-23)
@@ -3208,35 +4429,35 @@ pytest 4.0.1 (2018-11-23)
 Bug Fixes
 ---------
 
-- `#3952 <https://github.com/pytest-dev/pytest/issues/3952>`_: Display warnings before "short test summary info" again, but still later warnings in the end.
+- :issue:`3952`: Display warnings before "short test summary info" again, but still later warnings in the end.
 
 
-- `#4386 <https://github.com/pytest-dev/pytest/issues/4386>`_: Handle uninitialized exceptioninfo in repr/str.
+- :issue:`4386`: Handle uninitialized exceptioninfo in repr/str.
 
 
-- `#4393 <https://github.com/pytest-dev/pytest/issues/4393>`_: Do not create ``.gitignore``/``README.md`` files in existing cache directories.
+- :issue:`4393`: Do not create ``.gitignore``/``README.md`` files in existing cache directories.
 
 
-- `#4400 <https://github.com/pytest-dev/pytest/issues/4400>`_: Rearrange warning handling for the yield test errors so the opt-out in 4.0.x correctly works.
+- :issue:`4400`: Rearrange warning handling for the yield test errors so the opt-out in 4.0.x correctly works.
 
 
-- `#4405 <https://github.com/pytest-dev/pytest/issues/4405>`_: Fix collection of testpaths with ``--pyargs``.
+- :issue:`4405`: Fix collection of testpaths with ``--pyargs``.
 
 
-- `#4412 <https://github.com/pytest-dev/pytest/issues/4412>`_: Fix assertion rewriting involving ``Starred`` + side-effects.
+- :issue:`4412`: Fix assertion rewriting involving ``Starred`` + side-effects.
 
 
-- `#4425 <https://github.com/pytest-dev/pytest/issues/4425>`_: Ensure we resolve the absolute path when the given ``--basetemp`` is a relative path.
+- :issue:`4425`: Ensure we resolve the absolute path when the given ``--basetemp`` is a relative path.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4315 <https://github.com/pytest-dev/pytest/issues/4315>`_: Use ``pkg_resources.parse_version`` instead of ``LooseVersion`` in minversion check.
+- :issue:`4315`: Use ``pkg_resources.parse_version`` instead of ``LooseVersion`` in minversion check.
 
 
-- `#4440 <https://github.com/pytest-dev/pytest/issues/4440>`_: Adjust the stack level of some internal pytest warnings.
+- :issue:`4440`: Adjust the stack level of some internal pytest warnings.
 
 
 pytest 4.0.0 (2018-11-13)
@@ -3245,15 +4466,14 @@ pytest 4.0.0 (2018-11-13)
 Removals
 --------
 
-- `#3737 <https://github.com/pytest-dev/pytest/issues/3737>`_: **RemovedInPytest4Warnings are now errors by default.**
+- :issue:`3737`: **RemovedInPytest4Warnings are now errors by default.**
 
   Following our plan to remove deprecated features with as little disruption as
   possible, all warnings of type ``RemovedInPytest4Warnings`` now generate errors
   instead of warning messages.
 
   **The affected features will be effectively removed in pytest 4.1**, so please consult the
-  `Deprecations and Removals <https://docs.pytest.org/en/stable/deprecations.html>`__
-  section in the docs for directions on how to update existing code.
+  :std:doc:`deprecations` section in the docs for directions on how to update existing code.
 
   In the pytest ``4.0.X`` series, it is possible to change the errors back into warnings as a stop
   gap measure by adding this to your ``pytest.ini`` file:
@@ -3267,10 +4487,10 @@ Removals
   But this will stop working when pytest ``4.1`` is released.
 
   **If you have concerns** about the removal of a specific feature, please add a
-  comment to `#4348 <https://github.com/pytest-dev/pytest/issues/4348>`__.
+  comment to :issue:`4348`.
 
 
-- `#4358 <https://github.com/pytest-dev/pytest/issues/4358>`_: Remove the ``::()`` notation to denote a test class instance in node ids.
+- :issue:`4358`: Remove the ``::()`` notation to denote a test class instance in node ids.
 
   Previously, node ids that contain test instances would use ``::()`` to denote the instance like this::
 
@@ -3285,7 +4505,7 @@ Removals
 
   The extra ``::()`` might have been removed in some places internally already,
   which then led to confusion in places where it was expected, e.g. with
-  ``--deselect`` (`#4127 <https://github.com/pytest-dev/pytest/issues/4127>`_).
+  ``--deselect`` (:issue:`4127`).
 
   Test class instances are also not listed with ``--collect-only`` anymore.
 
@@ -3294,7 +4514,7 @@ Removals
 Features
 --------
 
-- `#4270 <https://github.com/pytest-dev/pytest/issues/4270>`_: The ``cache_dir`` option uses ``$TOX_ENV_DIR`` as prefix (if set in the environment).
+- :issue:`4270`: The ``cache_dir`` option uses ``$TOX_ENV_DIR`` as prefix (if set in the environment).
 
   This uses a different cache per tox environment by default.
 
@@ -3303,7 +4523,7 @@ Features
 Bug Fixes
 ---------
 
-- `#3554 <https://github.com/pytest-dev/pytest/issues/3554>`_: Fix ``CallInfo.__repr__`` for when the call is not finished yet.
+- :issue:`3554`: Fix ``CallInfo.__repr__`` for when the call is not finished yet.
 
 
 pytest 3.10.1 (2018-11-11)
@@ -3312,32 +4532,32 @@ pytest 3.10.1 (2018-11-11)
 Bug Fixes
 ---------
 
-- `#4287 <https://github.com/pytest-dev/pytest/issues/4287>`_: Fix nested usage of debugging plugin (pdb), e.g. with pytester's ``testdir.runpytest``.
+- :issue:`4287`: Fix nested usage of debugging plugin (pdb), e.g. with pytester's ``testdir.runpytest``.
 
 
-- `#4304 <https://github.com/pytest-dev/pytest/issues/4304>`_: Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.
+- :issue:`4304`: Block the ``stepwise`` plugin if ``cacheprovider`` is also blocked, as one depends on the other.
 
 
-- `#4306 <https://github.com/pytest-dev/pytest/issues/4306>`_: Parse ``minversion`` as an actual version and not as dot-separated strings.
+- :issue:`4306`: Parse ``minversion`` as an actual version and not as dot-separated strings.
 
 
-- `#4310 <https://github.com/pytest-dev/pytest/issues/4310>`_: Fix duplicate collection due to multiple args matching the same packages.
+- :issue:`4310`: Fix duplicate collection due to multiple args matching the same packages.
 
 
-- `#4321 <https://github.com/pytest-dev/pytest/issues/4321>`_: Fix ``item.nodeid`` with resolved symlinks.
+- :issue:`4321`: Fix ``item.nodeid`` with resolved symlinks.
 
 
-- `#4325 <https://github.com/pytest-dev/pytest/issues/4325>`_: Fix collection of direct symlinked files, where the target does not match ``python_files``.
+- :issue:`4325`: Fix collection of direct symlinked files, where the target does not match ``python_files``.
 
 
-- `#4329 <https://github.com/pytest-dev/pytest/issues/4329>`_: Fix TypeError in report_collect with _collect_report_last_write.
+- :issue:`4329`: Fix TypeError in report_collect with _collect_report_last_write.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4305 <https://github.com/pytest-dev/pytest/issues/4305>`_: Replace byte/unicode helpers in test_capture with python level syntax.
+- :issue:`4305`: Replace byte/unicode helpers in test_capture with python level syntax.
 
 
 pytest 3.10.0 (2018-11-03)
@@ -3346,19 +4566,19 @@ pytest 3.10.0 (2018-11-03)
 Features
 --------
 
-- `#2619 <https://github.com/pytest-dev/pytest/issues/2619>`_: Resume capturing output after ``continue`` with ``__import__("pdb").set_trace()``.
+- :issue:`2619`: Resume capturing output after ``continue`` with ``__import__("pdb").set_trace()``.
 
   This also adds a new ``pytest_leave_pdb`` hook, and passes in ``pdb`` to the
   existing ``pytest_enter_pdb`` hook.
 
 
-- `#4147 <https://github.com/pytest-dev/pytest/issues/4147>`_: Add ``--sw``, ``--stepwise`` as an alternative to ``--lf -x`` for stopping at the first failure, but starting the next test invocation from that test.  See `the documentation <https://docs.pytest.org/en/stable/cache.html#stepwise>`__ for more info.
+- :issue:`4147`: Add ``--sw``, ``--stepwise`` as an alternative to ``--lf -x`` for stopping at the first failure, but starting the next test invocation from that test.  See :ref:`the documentation <cache stepwise>` for more info.
 
 
-- `#4188 <https://github.com/pytest-dev/pytest/issues/4188>`_: Make ``--color`` emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if ``--verbose`` was also passed.
+- :issue:`4188`: Make ``--color`` emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if ``--verbose`` was also passed.
 
 
-- `#4225 <https://github.com/pytest-dev/pytest/issues/4225>`_: Improve performance with collection reporting in non-quiet mode with terminals.
+- :issue:`4225`: Improve performance with collection reporting in non-quiet mode with terminals.
 
   The "collecting …" message is only printed/updated every 0.5s.
 
@@ -3367,45 +4587,45 @@ Features
 Bug Fixes
 ---------
 
-- `#2701 <https://github.com/pytest-dev/pytest/issues/2701>`_: Fix false ``RemovedInPytest4Warning: usage of Session... is deprecated, please use pytest`` warnings.
+- :issue:`2701`: Fix false ``RemovedInPytest4Warning: usage of Session... is deprecated, please use pytest`` warnings.
 
 
-- `#4046 <https://github.com/pytest-dev/pytest/issues/4046>`_: Fix problems with running tests in package ``__init__.py`` files.
+- :issue:`4046`: Fix problems with running tests in package ``__init__.py`` files.
 
 
-- `#4260 <https://github.com/pytest-dev/pytest/issues/4260>`_: Swallow warnings during anonymous compilation of source.
+- :issue:`4260`: Swallow warnings during anonymous compilation of source.
 
 
-- `#4262 <https://github.com/pytest-dev/pytest/issues/4262>`_: Fix access denied error when deleting stale directories created by ``tmpdir`` / ``tmp_path``.
+- :issue:`4262`: Fix access denied error when deleting stale directories created by ``tmpdir`` / ``tmp_path``.
 
 
-- `#611 <https://github.com/pytest-dev/pytest/issues/611>`_: Naming a fixture ``request`` will now raise a warning: the ``request`` fixture is internal and
+- :issue:`611`: Naming a fixture ``request`` will now raise a warning: the ``request`` fixture is internal and
   should not be overwritten as it will lead to internal errors.
 
-- `#4266 <https://github.com/pytest-dev/pytest/issues/4266>`_: Handle (ignore) exceptions raised during collection, e.g. with Django's LazySettings proxy class.
+- :issue:`4266`: Handle (ignore) exceptions raised during collection, e.g. with Django's LazySettings proxy class.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#4255 <https://github.com/pytest-dev/pytest/issues/4255>`_: Added missing documentation about the fact that module names passed to filter warnings are not regex-escaped.
+- :issue:`4255`: Added missing documentation about the fact that module names passed to filter warnings are not regex-escaped.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4272 <https://github.com/pytest-dev/pytest/issues/4272>`_: Display cachedir also in non-verbose mode if non-default.
+- :issue:`4272`: Display cachedir also in non-verbose mode if non-default.
 
 
-- `#4277 <https://github.com/pytest-dev/pytest/issues/4277>`_: pdb: improve message about output capturing with ``set_trace``.
+- :issue:`4277`: pdb: improve message about output capturing with ``set_trace``.
 
   Do not display "IO-capturing turned off/on" when ``-s`` is used to avoid
   confusion.
 
 
-- `#4279 <https://github.com/pytest-dev/pytest/issues/4279>`_: Improve message and stack level of warnings issued by ``monkeypatch.setenv`` when the value of the environment variable is not a ``str``.
+- :issue:`4279`: Improve message and stack level of warnings issued by ``monkeypatch.setenv`` when the value of the environment variable is not a ``str``.
 
 
 pytest 3.9.3 (2018-10-27)
@@ -3414,36 +4634,36 @@ pytest 3.9.3 (2018-10-27)
 Bug Fixes
 ---------
 
-- `#4174 <https://github.com/pytest-dev/pytest/issues/4174>`_: Fix "ValueError: Plugin already registered" with conftest plugins via symlink.
+- :issue:`4174`: Fix "ValueError: Plugin already registered" with conftest plugins via symlink.
 
 
-- `#4181 <https://github.com/pytest-dev/pytest/issues/4181>`_: Handle race condition between creation and deletion of temporary folders.
+- :issue:`4181`: Handle race condition between creation and deletion of temporary folders.
 
 
-- `#4221 <https://github.com/pytest-dev/pytest/issues/4221>`_: Fix bug where the warning summary at the end of the test session was not showing the test where the warning was originated.
+- :issue:`4221`: Fix bug where the warning summary at the end of the test session was not showing the test where the warning was originated.
 
 
-- `#4243 <https://github.com/pytest-dev/pytest/issues/4243>`_: Fix regression when ``stacklevel`` for warnings was passed as positional argument on python2.
+- :issue:`4243`: Fix regression when ``stacklevel`` for warnings was passed as positional argument on python2.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3851 <https://github.com/pytest-dev/pytest/issues/3851>`_: Add reference to ``empty_parameter_set_mark`` ini option in documentation of ``@pytest.mark.parametrize``
+- :issue:`3851`: Add reference to ``empty_parameter_set_mark`` ini option in documentation of ``@pytest.mark.parametrize``
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#4028 <https://github.com/pytest-dev/pytest/issues/4028>`_: Revert patching of ``sys.breakpointhook`` since it appears to do nothing.
+- :issue:`4028`: Revert patching of ``sys.breakpointhook`` since it appears to do nothing.
 
 
-- `#4233 <https://github.com/pytest-dev/pytest/issues/4233>`_: Apply an import sorter (``reorder-python-imports``) to the codebase.
+- :issue:`4233`: Apply an import sorter (``reorder-python-imports``) to the codebase.
 
 
-- `#4248 <https://github.com/pytest-dev/pytest/issues/4248>`_: Remove use of unnecessary compat shim, six.binary_type
+- :issue:`4248`: Remove use of unnecessary compat shim, six.binary_type
 
 
 pytest 3.9.2 (2018-10-22)
@@ -3452,29 +4672,29 @@ pytest 3.9.2 (2018-10-22)
 Bug Fixes
 ---------
 
-- `#2909 <https://github.com/pytest-dev/pytest/issues/2909>`_: Improve error message when a recursive dependency between fixtures is detected.
+- :issue:`2909`: Improve error message when a recursive dependency between fixtures is detected.
 
 
-- `#3340 <https://github.com/pytest-dev/pytest/issues/3340>`_: Fix logging messages not shown in hooks ``pytest_sessionstart()`` and ``pytest_sessionfinish()``.
+- :issue:`3340`: Fix logging messages not shown in hooks ``pytest_sessionstart()`` and ``pytest_sessionfinish()``.
 
 
-- `#3533 <https://github.com/pytest-dev/pytest/issues/3533>`_: Fix unescaped XML raw objects in JUnit report for skipped tests
+- :issue:`3533`: Fix unescaped XML raw objects in JUnit report for skipped tests
 
 
-- `#3691 <https://github.com/pytest-dev/pytest/issues/3691>`_: Python 2: safely format warning message about passing unicode strings to ``warnings.warn``, which may cause
+- :issue:`3691`: Python 2: safely format warning message about passing unicode strings to ``warnings.warn``, which may cause
   surprising ``MemoryError`` exception when monkey patching ``warnings.warn`` itself.
 
 
-- `#4026 <https://github.com/pytest-dev/pytest/issues/4026>`_: Improve error message when it is not possible to determine a function's signature.
+- :issue:`4026`: Improve error message when it is not possible to determine a function's signature.
 
 
-- `#4177 <https://github.com/pytest-dev/pytest/issues/4177>`_: Pin ``setuptools>=40.0`` to support ``py_modules`` in ``setup.cfg``
+- :issue:`4177`: Pin ``setuptools>=40.0`` to support ``py_modules`` in ``setup.cfg``
 
 
-- `#4179 <https://github.com/pytest-dev/pytest/issues/4179>`_: Restore the tmpdir behaviour of symlinking the current test run.
+- :issue:`4179`: Restore the tmpdir behaviour of symlinking the current test run.
 
 
-- `#4192 <https://github.com/pytest-dev/pytest/issues/4192>`_: Fix filename reported by ``warnings.warn`` when using ``recwarn`` under python2.
+- :issue:`4192`: Fix filename reported by ``warnings.warn`` when using ``recwarn`` under python2.
 
 
 pytest 3.9.1 (2018-10-16)
@@ -3483,7 +4703,7 @@ pytest 3.9.1 (2018-10-16)
 Features
 --------
 
-- `#4159 <https://github.com/pytest-dev/pytest/issues/4159>`_: For test-suites containing test classes, the information about the subclassed
+- :issue:`4159`: For test-suites containing test classes, the information about the subclassed
   module is now output only if a higher verbosity level is specified (at least
   "-vv").
 
@@ -3494,7 +4714,7 @@ pytest 3.9.0 (2018-10-15 - not published due to a release automation bug)
 Deprecations
 ------------
 
-- `#3616 <https://github.com/pytest-dev/pytest/issues/3616>`_: The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings.
+- :issue:`3616`: The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings.
 
   * Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances. Now
     users will this warning::
@@ -3504,7 +4724,7 @@ Deprecations
     Users should just ``import pytest`` and access those objects using the ``pytest`` module.
 
   * ``request.cached_setup``, this was the precursor of the setup/teardown mechanism available to fixtures. You can
-    consult `funcarg comparison section in the docs <https://docs.pytest.org/en/stable/funcarg_compare.html>`_.
+    consult :std:doc:`funcarg comparison section in the docs <funcarg_compare>`.
 
   * Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
     subclasses has been deprecated. Users instead should use ``pytest_collect_make_item`` to customize node types during
@@ -3518,121 +4738,121 @@ Deprecations
           getfuncargvalue is deprecated, use getfixturevalue
 
 
-- `#3988 <https://github.com/pytest-dev/pytest/issues/3988>`_: Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while.
+- :issue:`3988`: Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while.
 
 
 
 Features
 --------
 
-- `#2293 <https://github.com/pytest-dev/pytest/issues/2293>`_: Improve usage errors messages by hiding internal details which can be distracting and noisy.
+- :issue:`2293`: Improve usage errors messages by hiding internal details which can be distracting and noisy.
 
   This has the side effect that some error conditions that previously raised generic errors (such as
   ``ValueError`` for unregistered marks) are now raising ``Failed`` exceptions.
 
 
-- `#3332 <https://github.com/pytest-dev/pytest/issues/3332>`_: Improve the error displayed when a ``conftest.py`` file could not be imported.
+- :issue:`3332`: Improve the error displayed when a ``conftest.py`` file could not be imported.
 
   In order to implement this, a new ``chain`` parameter was added to ``ExceptionInfo.getrepr``
   to show or hide chained tracebacks in Python 3 (defaults to ``True``).
 
 
-- `#3849 <https://github.com/pytest-dev/pytest/issues/3849>`_: Add ``empty_parameter_set_mark=fail_at_collect`` ini option for raising an exception when parametrize collects an empty set.
+- :issue:`3849`: Add ``empty_parameter_set_mark=fail_at_collect`` ini option for raising an exception when parametrize collects an empty set.
 
 
-- `#3964 <https://github.com/pytest-dev/pytest/issues/3964>`_: Log messages generated in the collection phase are shown when
+- :issue:`3964`: Log messages generated in the collection phase are shown when
   live-logging is enabled and/or when they are logged to a file.
 
 
-- `#3985 <https://github.com/pytest-dev/pytest/issues/3985>`_: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as
+- :issue:`3985`: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as
   a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test.
 
 
-- `#4013 <https://github.com/pytest-dev/pytest/issues/4013>`_: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version
+- :issue:`4013`: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version
   any customization would override pytest's filters and deprecation warnings would fall back to being hidden by default.
 
 
-- `#4073 <https://github.com/pytest-dev/pytest/issues/4073>`_: Allow specification of timeout for ``Testdir.runpytest_subprocess()`` and ``Testdir.run()``.
+- :issue:`4073`: Allow specification of timeout for ``Testdir.runpytest_subprocess()`` and ``Testdir.run()``.
 
 
-- `#4098 <https://github.com/pytest-dev/pytest/issues/4098>`_: Add returncode argument to pytest.exit() to exit pytest with a specific return code.
+- :issue:`4098`: Add returncode argument to pytest.exit() to exit pytest with a specific return code.
 
 
-- `#4102 <https://github.com/pytest-dev/pytest/issues/4102>`_: Reimplement ``pytest.deprecated_call`` using ``pytest.warns`` so it supports the ``match='...'`` keyword argument.
+- :issue:`4102`: Reimplement ``pytest.deprecated_call`` using ``pytest.warns`` so it supports the ``match='...'`` keyword argument.
 
   This has the side effect that ``pytest.deprecated_call`` now raises ``pytest.fail.Exception`` instead
   of ``AssertionError``.
 
 
-- `#4149 <https://github.com/pytest-dev/pytest/issues/4149>`_: Require setuptools>=30.3 and move most of the metadata to ``setup.cfg``.
+- :issue:`4149`: Require setuptools>=30.3 and move most of the metadata to ``setup.cfg``.
 
 
 
 Bug Fixes
 ---------
 
-- `#2535 <https://github.com/pytest-dev/pytest/issues/2535>`_: Improve error message when test functions of ``unittest.TestCase`` subclasses use a parametrized fixture.
+- :issue:`2535`: Improve error message when test functions of ``unittest.TestCase`` subclasses use a parametrized fixture.
 
 
-- `#3057 <https://github.com/pytest-dev/pytest/issues/3057>`_: ``request.fixturenames`` now correctly returns the name of fixtures created by ``request.getfixturevalue()``.
+- :issue:`3057`: ``request.fixturenames`` now correctly returns the name of fixtures created by ``request.getfixturevalue()``.
 
 
-- `#3946 <https://github.com/pytest-dev/pytest/issues/3946>`_: Warning filters passed as command line options using ``-W`` now take precedence over filters defined in ``ini``
+- :issue:`3946`: Warning filters passed as command line options using ``-W`` now take precedence over filters defined in ``ini``
   configuration files.
 
 
-- `#4066 <https://github.com/pytest-dev/pytest/issues/4066>`_: Fix source reindenting by using ``textwrap.dedent`` directly.
+- :issue:`4066`: Fix source reindenting by using ``textwrap.dedent`` directly.
 
 
-- `#4102 <https://github.com/pytest-dev/pytest/issues/4102>`_: ``pytest.warn`` will capture previously-warned warnings in Python 2. Previously they were never raised.
+- :issue:`4102`: ``pytest.warn`` will capture previously-warned warnings in Python 2. Previously they were never raised.
 
 
-- `#4108 <https://github.com/pytest-dev/pytest/issues/4108>`_: Resolve symbolic links for args.
+- :issue:`4108`: Resolve symbolic links for args.
 
   This fixes running ``pytest tests/test_foo.py::test_bar``, where ``tests``
   is a symlink to ``project/app/tests``:
   previously ``project/app/conftest.py`` would be ignored for fixtures then.
 
 
-- `#4132 <https://github.com/pytest-dev/pytest/issues/4132>`_: Fix duplicate printing of internal errors when using ``--pdb``.
+- :issue:`4132`: Fix duplicate printing of internal errors when using ``--pdb``.
 
 
-- `#4135 <https://github.com/pytest-dev/pytest/issues/4135>`_: pathlib based tmpdir cleanup now correctly handles symlinks in the folder.
+- :issue:`4135`: pathlib based tmpdir cleanup now correctly handles symlinks in the folder.
 
 
-- `#4152 <https://github.com/pytest-dev/pytest/issues/4152>`_: Display the filename when encountering ``SyntaxWarning``.
+- :issue:`4152`: Display the filename when encountering ``SyntaxWarning``.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3713 <https://github.com/pytest-dev/pytest/issues/3713>`_: Update usefixtures documentation to clarify that it can't be used with fixture functions.
+- :issue:`3713`: Update usefixtures documentation to clarify that it can't be used with fixture functions.
 
 
-- `#4058 <https://github.com/pytest-dev/pytest/issues/4058>`_: Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for.
+- :issue:`4058`: Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for.
 
 
-- `#4064 <https://github.com/pytest-dev/pytest/issues/4064>`_: According to unittest.rst, setUpModule and tearDownModule were not implemented, but it turns out they are. So updated the documentation for unittest.
+- :issue:`4064`: According to unittest.rst, setUpModule and tearDownModule were not implemented, but it turns out they are. So updated the documentation for unittest.
 
 
-- `#4151 <https://github.com/pytest-dev/pytest/issues/4151>`_: Add tempir testing example to CONTRIBUTING.rst guide
+- :issue:`4151`: Add tempir testing example to CONTRIBUTING.rst guide
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#2293 <https://github.com/pytest-dev/pytest/issues/2293>`_: The internal ``MarkerError`` exception has been removed.
+- :issue:`2293`: The internal ``MarkerError`` exception has been removed.
 
 
-- `#3988 <https://github.com/pytest-dev/pytest/issues/3988>`_: Port the implementation of tmpdir to pathlib.
+- :issue:`3988`: Port the implementation of tmpdir to pathlib.
 
 
-- `#4063 <https://github.com/pytest-dev/pytest/issues/4063>`_: Exclude 0.00 second entries from ``--duration`` output unless ``-vv`` is passed on the command-line.
+- :issue:`4063`: Exclude 0.00 second entries from ``--duration`` output unless ``-vv`` is passed on the command-line.
 
 
-- `#4093 <https://github.com/pytest-dev/pytest/issues/4093>`_: Fixed formatting of string literals in internal tests.
+- :issue:`4093`: Fixed formatting of string literals in internal tests.
 
 
 pytest 3.8.2 (2018-10-02)
@@ -3641,7 +4861,7 @@ pytest 3.8.2 (2018-10-02)
 Deprecations and Removals
 -------------------------
 
-- `#4036 <https://github.com/pytest-dev/pytest/issues/4036>`_: The ``item`` parameter of ``pytest_warning_captured`` hook is now documented as deprecated. We realized only after
+- :issue:`4036`: The ``item`` parameter of ``pytest_warning_captured`` hook is now documented as deprecated. We realized only after
   the ``3.8`` release that this parameter is incompatible with ``pytest-xdist``.
 
   Our policy is to not deprecate features during bug-fix releases, but in this case we believe it makes sense as we are
@@ -3656,25 +4876,25 @@ Deprecations and Removals
 Bug Fixes
 ---------
 
-- `#3539 <https://github.com/pytest-dev/pytest/issues/3539>`_: Fix reload on assertion rewritten modules.
+- :issue:`3539`: Fix reload on assertion rewritten modules.
 
 
-- `#4034 <https://github.com/pytest-dev/pytest/issues/4034>`_: The ``.user_properties`` attribute of ``TestReport`` objects is a list
+- :issue:`4034`: The ``.user_properties`` attribute of ``TestReport`` objects is a list
   of (name, value) tuples, but could sometimes be instantiated as a tuple
   of tuples.  It is now always a list.
 
 
-- `#4039 <https://github.com/pytest-dev/pytest/issues/4039>`_: No longer issue warnings about using ``pytest_plugins`` in non-top-level directories when using ``--pyargs``: the
+- :issue:`4039`: No longer issue warnings about using ``pytest_plugins`` in non-top-level directories when using ``--pyargs``: the
   current ``--pyargs`` mechanism is not reliable and might give false negatives.
 
 
-- `#4040 <https://github.com/pytest-dev/pytest/issues/4040>`_: Exclude empty reports for passed tests when ``-rP`` option is used.
+- :issue:`4040`: Exclude empty reports for passed tests when ``-rP`` option is used.
 
 
-- `#4051 <https://github.com/pytest-dev/pytest/issues/4051>`_: Improve error message when an invalid Python expression is passed to the ``-m`` option.
+- :issue:`4051`: Improve error message when an invalid Python expression is passed to the ``-m`` option.
 
 
-- `#4056 <https://github.com/pytest-dev/pytest/issues/4056>`_: ``MonkeyPatch.setenv`` and ``MonkeyPatch.delenv`` issue a warning if the environment variable name is not ``str`` on Python 2.
+- :issue:`4056`: ``MonkeyPatch.setenv`` and ``MonkeyPatch.delenv`` issue a warning if the environment variable name is not ``str`` on Python 2.
 
   In Python 2, adding ``unicode`` keys to ``os.environ`` causes problems with ``subprocess`` (and possible other modules),
   making this a subtle bug specially susceptible when used with ``from __future__ import unicode_literals``.
@@ -3684,7 +4904,7 @@ Bug Fixes
 Improved Documentation
 ----------------------
 
-- `#3928 <https://github.com/pytest-dev/pytest/issues/3928>`_: Add possible values for fixture scope to docs.
+- :issue:`3928`: Add possible values for fixture scope to docs.
 
 
 pytest 3.8.1 (2018-09-22)
@@ -3693,31 +4913,31 @@ pytest 3.8.1 (2018-09-22)
 Bug Fixes
 ---------
 
-- `#3286 <https://github.com/pytest-dev/pytest/issues/3286>`_: ``.pytest_cache`` directory is now automatically ignored by Git. Users who would like to contribute a solution for other SCMs please consult/comment on this issue.
+- :issue:`3286`: ``.pytest_cache`` directory is now automatically ignored by Git. Users who would like to contribute a solution for other SCMs please consult/comment on this issue.
 
 
-- `#3749 <https://github.com/pytest-dev/pytest/issues/3749>`_: Fix the following error during collection of tests inside packages::
+- :issue:`3749`: Fix the following error during collection of tests inside packages::
 
       TypeError: object of type 'Package' has no len()
 
 
-- `#3941 <https://github.com/pytest-dev/pytest/issues/3941>`_: Fix bug where indirect parametrization would consider the scope of all fixtures used by the test function to determine the parametrization scope, and not only the scope of the fixtures being parametrized.
+- :issue:`3941`: Fix bug where indirect parametrization would consider the scope of all fixtures used by the test function to determine the parametrization scope, and not only the scope of the fixtures being parametrized.
 
 
-- `#3973 <https://github.com/pytest-dev/pytest/issues/3973>`_: Fix crash of the assertion rewriter if a test changed the current working directory without restoring it afterwards.
+- :issue:`3973`: Fix crash of the assertion rewriter if a test changed the current working directory without restoring it afterwards.
 
 
-- `#3998 <https://github.com/pytest-dev/pytest/issues/3998>`_: Fix issue that prevented some caplog properties (for example ``record_tuples``) from being available when entering the debugger with ``--pdb``.
+- :issue:`3998`: Fix issue that prevented some caplog properties (for example ``record_tuples``) from being available when entering the debugger with ``--pdb``.
 
 
-- `#3999 <https://github.com/pytest-dev/pytest/issues/3999>`_: Fix ``UnicodeDecodeError`` in python2.x when a class returns a non-ascii binary ``__repr__`` in an assertion which also contains non-ascii text.
+- :issue:`3999`: Fix ``UnicodeDecodeError`` in python2.x when a class returns a non-ascii binary ``__repr__`` in an assertion which also contains non-ascii text.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3996 <https://github.com/pytest-dev/pytest/issues/3996>`_: New `Deprecations and Removals <https://docs.pytest.org/en/stable/deprecations.html>`_ page shows all currently
+- :issue:`3996`: New :std:doc:`deprecations` page shows all currently
   deprecated features, the rationale to do so, and alternatives to update your code. It also list features removed
   from pytest in past major releases to help those with ancient pytest versions to upgrade.
 
@@ -3726,10 +4946,10 @@ Improved Documentation
 Trivial/Internal Changes
 ------------------------
 
-- `#3955 <https://github.com/pytest-dev/pytest/issues/3955>`_: Improve pre-commit detection for changelog filenames
+- :issue:`3955`: Improve pre-commit detection for changelog filenames
 
 
-- `#3975 <https://github.com/pytest-dev/pytest/issues/3975>`_: Remove legacy code around im_func as that was python2 only
+- :issue:`3975`: Remove legacy code around im_func as that was python2 only
 
 
 pytest 3.8.0 (2018-09-05)
@@ -3738,11 +4958,11 @@ pytest 3.8.0 (2018-09-05)
 Deprecations and Removals
 -------------------------
 
-- `#2452 <https://github.com/pytest-dev/pytest/issues/2452>`_: ``Config.warn`` and ``Node.warn`` have been
-  deprecated, see `<https://docs.pytest.org/en/stable/deprecations.html#config-warn-and-node-warn>`_ for rationale and
+- :issue:`2452`: ``Config.warn`` and ``Node.warn`` have been
+  deprecated, see :ref:`config.warn and node.warn deprecated` for rationale and
   examples.
 
-- `#3936 <https://github.com/pytest-dev/pytest/issues/3936>`_: ``@pytest.mark.filterwarnings`` second parameter is no longer regex-escaped,
+- :issue:`3936`: ``@pytest.mark.filterwarnings`` second parameter is no longer regex-escaped,
   making it possible to actually use regular expressions to check the warning message.
 
   **Note**: regex-escaping the match string was an implementation oversight that might break test suites which depend
@@ -3753,60 +4973,60 @@ Deprecations and Removals
 Features
 --------
 
-- `#2452 <https://github.com/pytest-dev/pytest/issues/2452>`_: Internal pytest warnings are now issued using the standard ``warnings`` module, making it possible to use
+- :issue:`2452`: Internal pytest warnings are now issued using the standard ``warnings`` module, making it possible to use
   the standard warnings filters to manage those warnings. This introduces ``PytestWarning``,
   ``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API.
 
-  Consult `the documentation <https://docs.pytest.org/en/stable/warnings.html#internal-pytest-warnings>`__ for more info.
+  Consult :ref:`the documentation <internal-warnings>` for more info.
 
 
-- `#2908 <https://github.com/pytest-dev/pytest/issues/2908>`_: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
+- :issue:`2908`: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
   configured. This makes pytest more compliant with
-  `PEP-0506 <https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners>`_. See
-  `the docs <https://docs.pytest.org/en/stable/warnings.html#deprecationwarning-and-pendingdeprecationwarning>`_ for
+  :pep:`506#recommended-filter-settings-for-test-runners`. See
+  :ref:`the docs <deprecation-warnings>` for
   more info.
 
 
-- `#3251 <https://github.com/pytest-dev/pytest/issues/3251>`_: Warnings are now captured and displayed during test collection.
+- :issue:`3251`: Warnings are now captured and displayed during test collection.
 
 
-- `#3784 <https://github.com/pytest-dev/pytest/issues/3784>`_: ``PYTEST_DISABLE_PLUGIN_AUTOLOAD`` environment variable disables plugin auto-loading when set.
+- :issue:`3784`: ``PYTEST_DISABLE_PLUGIN_AUTOLOAD`` environment variable disables plugin auto-loading when set.
 
 
-- `#3829 <https://github.com/pytest-dev/pytest/issues/3829>`_: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.
+- :issue:`3829`: Added the ``count`` option to ``console_output_style`` to enable displaying the progress as a count instead of a percentage.
 
 
-- `#3837 <https://github.com/pytest-dev/pytest/issues/3837>`_: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature.
+- :issue:`3837`: Added support for 'xfailed' and 'xpassed' outcomes to the ``pytester.RunResult.assert_outcomes`` signature.
 
 
 
 Bug Fixes
 ---------
 
-- `#3911 <https://github.com/pytest-dev/pytest/issues/3911>`_: Terminal writer now takes into account unicode character width when writing out progress.
+- :issue:`3911`: Terminal writer now takes into account unicode character width when writing out progress.
 
 
-- `#3913 <https://github.com/pytest-dev/pytest/issues/3913>`_: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.
+- :issue:`3913`: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.
 
 
-- `#3918 <https://github.com/pytest-dev/pytest/issues/3918>`_: Improve performance of assertion rewriting.
+- :issue:`3918`: Improve performance of assertion rewriting.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3566 <https://github.com/pytest-dev/pytest/issues/3566>`_: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.
+- :issue:`3566`: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.
 
 
-- `#3907 <https://github.com/pytest-dev/pytest/issues/3907>`_: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``.
+- :issue:`3907`: Corrected type of the exceptions collection passed to ``xfail``: ``raises`` argument accepts a ``tuple`` instead of ``list``.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#3853 <https://github.com/pytest-dev/pytest/issues/3853>`_: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.
+- :issue:`3853`: Removed ``"run all (no recorded failures)"`` message printed with ``--failed-first`` and ``--last-failed`` when there are no failed tests.
 
 
 pytest 3.7.4 (2018-08-29)
@@ -3815,23 +5035,23 @@ pytest 3.7.4 (2018-08-29)
 Bug Fixes
 ---------
 
-- `#3506 <https://github.com/pytest-dev/pytest/issues/3506>`_: Fix possible infinite recursion when writing ``.pyc`` files.
+- :issue:`3506`: Fix possible infinite recursion when writing ``.pyc`` files.
 
 
-- `#3853 <https://github.com/pytest-dev/pytest/issues/3853>`_: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.
+- :issue:`3853`: Cache plugin now obeys the ``-q`` flag when ``--last-failed`` and ``--failed-first`` flags are used.
 
 
-- `#3883 <https://github.com/pytest-dev/pytest/issues/3883>`_: Fix bad console output when using ``console_output_style=classic``.
+- :issue:`3883`: Fix bad console output when using ``console_output_style=classic``.
 
 
-- `#3888 <https://github.com/pytest-dev/pytest/issues/3888>`_: Fix macOS specific code using ``capturemanager`` plugin in doctests.
+- :issue:`3888`: Fix macOS specific code using ``capturemanager`` plugin in doctests.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3902 <https://github.com/pytest-dev/pytest/issues/3902>`_: Fix pytest.org links
+- :issue:`3902`: Fix pytest.org links
 
 
 pytest 3.7.3 (2018-08-26)
@@ -3840,52 +5060,52 @@ pytest 3.7.3 (2018-08-26)
 Bug Fixes
 ---------
 
-- `#3033 <https://github.com/pytest-dev/pytest/issues/3033>`_: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests.
+- :issue:`3033`: Fixtures during teardown can again use ``capsys`` and ``capfd`` to inspect output captured during tests.
 
 
-- `#3773 <https://github.com/pytest-dev/pytest/issues/3773>`_: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option.
+- :issue:`3773`: Fix collection of tests from ``__init__.py`` files if they match the ``python_files`` configuration option.
 
 
-- `#3796 <https://github.com/pytest-dev/pytest/issues/3796>`_: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer
+- :issue:`3796`: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer
   package.
 
 
-- `#3816 <https://github.com/pytest-dev/pytest/issues/3816>`_: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown.
+- :issue:`3816`: Fix bug where ``--show-capture=no`` option would still show logs printed during fixture teardown.
 
 
-- `#3819 <https://github.com/pytest-dev/pytest/issues/3819>`_: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active.
+- :issue:`3819`: Fix ``stdout/stderr`` not getting captured when real-time cli logging is active.
 
 
-- `#3843 <https://github.com/pytest-dev/pytest/issues/3843>`_: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``.
+- :issue:`3843`: Fix collection error when specifying test functions directly in the command line using ``test.py::test`` syntax together with ``--doctest-modules``.
 
 
-- `#3848 <https://github.com/pytest-dev/pytest/issues/3848>`_: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2.
+- :issue:`3848`: Fix bugs where unicode arguments could not be passed to ``testdir.runpytest`` on Python 2.
 
 
-- `#3854 <https://github.com/pytest-dev/pytest/issues/3854>`_: Fix double collection of tests within packages when the filename starts with a capital letter.
+- :issue:`3854`: Fix double collection of tests within packages when the filename starts with a capital letter.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3824 <https://github.com/pytest-dev/pytest/issues/3824>`_: Added example for multiple glob pattern matches in ``python_files``.
+- :issue:`3824`: Added example for multiple glob pattern matches in ``python_files``.
 
 
-- `#3833 <https://github.com/pytest-dev/pytest/issues/3833>`_: Added missing docs for ``pytester.Testdir``.
+- :issue:`3833`: Added missing docs for ``pytester.Testdir``.
 
 
-- `#3870 <https://github.com/pytest-dev/pytest/issues/3870>`_: Correct documentation for setuptools integration.
+- :issue:`3870`: Correct documentation for setuptools integration.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#3826 <https://github.com/pytest-dev/pytest/issues/3826>`_: Replace broken type annotations with type comments.
+- :issue:`3826`: Replace broken type annotations with type comments.
 
 
-- `#3845 <https://github.com/pytest-dev/pytest/issues/3845>`_: Remove a reference to issue `#568 <https://github.com/pytest-dev/pytest/issues/568>`_ from the documentation, which has since been
+- :issue:`3845`: Remove a reference to issue :issue:`568` from the documentation, which has since been
   fixed.
 
 
@@ -3895,32 +5115,32 @@ pytest 3.7.2 (2018-08-16)
 Bug Fixes
 ---------
 
-- `#3671 <https://github.com/pytest-dev/pytest/issues/3671>`_: Fix ``filterwarnings`` not being registered as a builtin mark.
+- :issue:`3671`: Fix ``filterwarnings`` not being registered as a builtin mark.
 
 
-- `#3768 <https://github.com/pytest-dev/pytest/issues/3768>`_, `#3789 <https://github.com/pytest-dev/pytest/issues/3789>`_: Fix test collection from packages mixed with normal directories.
+- :issue:`3768`, :issue:`3789`: Fix test collection from packages mixed with normal directories.
 
 
-- `#3771 <https://github.com/pytest-dev/pytest/issues/3771>`_: Fix infinite recursion during collection if a ``pytest_ignore_collect`` hook returns ``False`` instead of ``None``.
+- :issue:`3771`: Fix infinite recursion during collection if a ``pytest_ignore_collect`` hook returns ``False`` instead of ``None``.
 
 
-- `#3774 <https://github.com/pytest-dev/pytest/issues/3774>`_: Fix bug where decorated fixtures would lose functionality (for example ``@mock.patch``).
+- :issue:`3774`: Fix bug where decorated fixtures would lose functionality (for example ``@mock.patch``).
 
 
-- `#3775 <https://github.com/pytest-dev/pytest/issues/3775>`_: Fix bug where importing modules or other objects with prefix ``pytest_`` prefix would raise a ``PluginValidationError``.
+- :issue:`3775`: Fix bug where importing modules or other objects with prefix ``pytest_`` prefix would raise a ``PluginValidationError``.
 
 
-- `#3788 <https://github.com/pytest-dev/pytest/issues/3788>`_: Fix ``AttributeError`` during teardown of ``TestCase`` subclasses which raise an exception during ``__init__``.
+- :issue:`3788`: Fix ``AttributeError`` during teardown of ``TestCase`` subclasses which raise an exception during ``__init__``.
 
 
-- `#3804 <https://github.com/pytest-dev/pytest/issues/3804>`_: Fix traceback reporting for exceptions with ``__cause__`` cycles.
+- :issue:`3804`: Fix traceback reporting for exceptions with ``__cause__`` cycles.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3746 <https://github.com/pytest-dev/pytest/issues/3746>`_: Add documentation for ``metafunc.config`` that had been mistakenly hidden.
+- :issue:`3746`: Add documentation for ``metafunc.config`` that had been mistakenly hidden.
 
 
 pytest 3.7.1 (2018-08-02)
@@ -3929,26 +5149,26 @@ pytest 3.7.1 (2018-08-02)
 Bug Fixes
 ---------
 
-- `#3473 <https://github.com/pytest-dev/pytest/issues/3473>`_: Raise immediately if ``approx()`` is given an expected value of a type it doesn't understand (e.g. strings, nested dicts, etc.).
+- :issue:`3473`: Raise immediately if ``approx()`` is given an expected value of a type it doesn't understand (e.g. strings, nested dicts, etc.).
 
 
-- `#3712 <https://github.com/pytest-dev/pytest/issues/3712>`_: Correctly represent the dimensions of a numpy array when calling ``repr()`` on ``approx()``.
+- :issue:`3712`: Correctly represent the dimensions of a numpy array when calling ``repr()`` on ``approx()``.
 
-- `#3742 <https://github.com/pytest-dev/pytest/issues/3742>`_: Fix incompatibility with third party plugins during collection, which produced the error ``object has no attribute '_collectfile'``.
+- :issue:`3742`: Fix incompatibility with third party plugins during collection, which produced the error ``object has no attribute '_collectfile'``.
 
-- `#3745 <https://github.com/pytest-dev/pytest/issues/3745>`_: Display the absolute path if ``cache_dir`` is not relative to the ``rootdir`` instead of failing.
+- :issue:`3745`: Display the absolute path if ``cache_dir`` is not relative to the ``rootdir`` instead of failing.
 
 
-- `#3747 <https://github.com/pytest-dev/pytest/issues/3747>`_: Fix compatibility problem with plugins and the warning code issued by fixture functions when they are called directly.
+- :issue:`3747`: Fix compatibility problem with plugins and the warning code issued by fixture functions when they are called directly.
 
 
-- `#3748 <https://github.com/pytest-dev/pytest/issues/3748>`_: Fix infinite recursion in ``pytest.approx`` with arrays in ``numpy<1.13``.
+- :issue:`3748`: Fix infinite recursion in ``pytest.approx`` with arrays in ``numpy<1.13``.
 
 
-- `#3757 <https://github.com/pytest-dev/pytest/issues/3757>`_: Pin pathlib2 to ``>=2.2.0`` as we require ``__fspath__`` support.
+- :issue:`3757`: Pin pathlib2 to ``>=2.2.0`` as we require ``__fspath__`` support.
 
 
-- `#3763 <https://github.com/pytest-dev/pytest/issues/3763>`_: Fix ``TypeError`` when the assertion message is ``bytes`` in python 3.
+- :issue:`3763`: Fix ``TypeError`` when the assertion message is ``bytes`` in python 3.
 
 
 pytest 3.7.0 (2018-07-30)
@@ -3957,57 +5177,57 @@ pytest 3.7.0 (2018-07-30)
 Deprecations and Removals
 -------------------------
 
-- `#2639 <https://github.com/pytest-dev/pytest/issues/2639>`_: ``pytest_namespace`` has been `deprecated <https://docs.pytest.org/en/stable/deprecations.html#pytest-namespace>`_.
+- :issue:`2639`: ``pytest_namespace`` has been :ref:`deprecated <pytest.namespace deprecated>`.
 
 
-- `#3661 <https://github.com/pytest-dev/pytest/issues/3661>`_: Calling a fixture function directly, as opposed to request them in a test function, now issues a ``RemovedInPytest4Warning``. See `the documentation for rationale and examples <https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directly>`_.
+- :issue:`3661`: Calling a fixture function directly, as opposed to request them in a test function, now issues a ``RemovedInPytest4Warning``. See :ref:`the documentation for rationale and examples <calling fixtures directly deprecated>`.
 
 
 
 Features
 --------
 
-- `#2283 <https://github.com/pytest-dev/pytest/issues/2283>`_: New ``package`` fixture scope: fixtures are finalized when the last test of a *package* finishes. This feature is considered **experimental**, so use it sparingly.
+- :issue:`2283`: New ``package`` fixture scope: fixtures are finalized when the last test of a *package* finishes. This feature is considered **experimental**, so use it sparingly.
 
 
-- `#3576 <https://github.com/pytest-dev/pytest/issues/3576>`_: ``Node.add_marker`` now supports an ``append=True/False`` parameter to determine whether the mark comes last (default) or first.
+- :issue:`3576`: ``Node.add_marker`` now supports an ``append=True/False`` parameter to determine whether the mark comes last (default) or first.
 
 
-- `#3579 <https://github.com/pytest-dev/pytest/issues/3579>`_: Fixture ``caplog`` now has a ``messages`` property, providing convenient access to the format-interpolated log messages without the extra data provided by the formatter/handler.
+- :issue:`3579`: Fixture ``caplog`` now has a ``messages`` property, providing convenient access to the format-interpolated log messages without the extra data provided by the formatter/handler.
 
 
-- `#3610 <https://github.com/pytest-dev/pytest/issues/3610>`_: New ``--trace`` option to enter the debugger at the start of a test.
+- :issue:`3610`: New ``--trace`` option to enter the debugger at the start of a test.
 
 
-- `#3623 <https://github.com/pytest-dev/pytest/issues/3623>`_: Introduce ``pytester.copy_example`` as helper to do acceptance tests against examples from the project.
+- :issue:`3623`: Introduce ``pytester.copy_example`` as helper to do acceptance tests against examples from the project.
 
 
 
 Bug Fixes
 ---------
 
-- `#2220 <https://github.com/pytest-dev/pytest/issues/2220>`_: Fix a bug where fixtures overridden by direct parameters (for example parametrization) were being instantiated even if they were not being used by a test.
+- :issue:`2220`: Fix a bug where fixtures overridden by direct parameters (for example parametrization) were being instantiated even if they were not being used by a test.
 
 
-- `#3695 <https://github.com/pytest-dev/pytest/issues/3695>`_: Fix ``ApproxNumpy`` initialisation argument mixup, ``abs`` and ``rel`` tolerances were flipped causing strange comparison results.
+- :issue:`3695`: Fix ``ApproxNumpy`` initialisation argument mixup, ``abs`` and ``rel`` tolerances were flipped causing strange comparison results.
   Add tests to check ``abs`` and ``rel`` tolerances for ``np.array`` and test for expecting ``nan`` with ``np.array()``
 
 
-- `#980 <https://github.com/pytest-dev/pytest/issues/980>`_: Fix truncated locals output in verbose mode.
+- :issue:`980`: Fix truncated locals output in verbose mode.
 
 
 
 Improved Documentation
 ----------------------
 
-- `#3295 <https://github.com/pytest-dev/pytest/issues/3295>`_: Correct the usage documentation of ``--last-failed-no-failures`` by adding the missing ``--last-failed`` argument in the presented examples, because they are misleading and lead to think that the missing argument is not needed.
+- :issue:`3295`: Correct the usage documentation of ``--last-failed-no-failures`` by adding the missing ``--last-failed`` argument in the presented examples, because they are misleading and lead to think that the missing argument is not needed.
 
 
 
 Trivial/Internal Changes
 ------------------------
 
-- `#3519 <https://github.com/pytest-dev/pytest/issues/3519>`_: Now a ``README.md`` file is created in ``.pytest_cache`` to make it clear why the directory exists.
+- :issue:`3519`: Now a ``README.md`` file is created in ``.pytest_cache`` to make it clear why the directory exists.
 
 
 pytest 3.6.4 (2018-07-28)
@@ -4016,25 +5236,25 @@ pytest 3.6.4 (2018-07-28)
 Bug Fixes
 ---------
 
-- Invoke pytest using ``-mpytest`` so ``sys.path`` does not get polluted by packages installed in ``site-packages``. (`#742 <https://github.com/pytest-dev/pytest/issues/742>`_)
+- Invoke pytest using ``-mpytest`` so ``sys.path`` does not get polluted by packages installed in ``site-packages``. (:issue:`742`)
 
 
 Improved Documentation
 ----------------------
 
-- Use ``smtp_connection`` instead of ``smtp`` in fixtures documentation to avoid possible confusion. (`#3592 <https://github.com/pytest-dev/pytest/issues/3592>`_)
+- Use ``smtp_connection`` instead of ``smtp`` in fixtures documentation to avoid possible confusion. (:issue:`3592`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Remove obsolete ``__future__`` imports. (`#2319 <https://github.com/pytest-dev/pytest/issues/2319>`_)
+- Remove obsolete ``__future__`` imports. (:issue:`2319`)
 
-- Add CITATION to provide information on how to formally cite pytest. (`#3402 <https://github.com/pytest-dev/pytest/issues/3402>`_)
+- Add CITATION to provide information on how to formally cite pytest. (:issue:`3402`)
 
-- Replace broken type annotations with type comments. (`#3635 <https://github.com/pytest-dev/pytest/issues/3635>`_)
+- Replace broken type annotations with type comments. (:issue:`3635`)
 
-- Pin ``pluggy`` to ``<0.8``. (`#3727 <https://github.com/pytest-dev/pytest/issues/3727>`_)
+- Pin ``pluggy`` to ``<0.8``. (:issue:`3727`)
 
 
 pytest 3.6.3 (2018-07-04)
@@ -4044,43 +5264,37 @@ Bug Fixes
 ---------
 
 - Fix ``ImportWarning`` triggered by explicit relative imports in
-  assertion-rewritten package modules. (`#3061
-  <https://github.com/pytest-dev/pytest/issues/3061>`_)
+  assertion-rewritten package modules. (:issue:`3061`)
 
 - Fix error in ``pytest.approx`` when dealing with 0-dimension numpy
-  arrays. (`#3593 <https://github.com/pytest-dev/pytest/issues/3593>`_)
+  arrays. (:issue:`3593`)
 
-- No longer raise ``ValueError`` when using the ``get_marker`` API. (`#3605
-  <https://github.com/pytest-dev/pytest/issues/3605>`_)
+- No longer raise ``ValueError`` when using the ``get_marker`` API. (:issue:`3605`)
 
 - Fix problem where log messages with non-ascii characters would not
   appear in the output log file.
-  (`#3630 <https://github.com/pytest-dev/pytest/issues/3630>`_)
+  (:issue:`3630`)
 
 - No longer raise ``AttributeError`` when legacy marks can't be stored in
-  functions. (`#3631 <https://github.com/pytest-dev/pytest/issues/3631>`_)
+  functions. (:issue:`3631`)
 
 
 Improved Documentation
 ----------------------
 
 - The description above the example for ``@pytest.mark.skipif`` now better
-  matches the code. (`#3611
-  <https://github.com/pytest-dev/pytest/issues/3611>`_)
+  matches the code. (:issue:`3611`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - Internal refactoring: removed unused ``CallSpec2tox ._globalid_args``
-  attribute and ``metafunc`` parameter from ``CallSpec2.copy()``. (`#3598
-  <https://github.com/pytest-dev/pytest/issues/3598>`_)
+  attribute and ``metafunc`` parameter from ``CallSpec2.copy()``. (:issue:`3598`)
 
-- Silence usage of ``reduce`` warning in Python 2 (`#3609
-  <https://github.com/pytest-dev/pytest/issues/3609>`_)
+- Silence usage of ``reduce`` warning in Python 2 (:issue:`3609`)
 
-- Fix usage of ``attr.ib`` deprecated ``convert`` parameter. (`#3653
-  <https://github.com/pytest-dev/pytest/issues/3653>`_)
+- Fix usage of ``attr.ib`` deprecated ``convert`` parameter. (:issue:`3653`)
 
 
 pytest 3.6.2 (2018-06-20)
@@ -4090,43 +5304,35 @@ Bug Fixes
 ---------
 
 - Fix regression in ``Node.add_marker`` by extracting the mark object of a
-  ``MarkDecorator``. (`#3555
-  <https://github.com/pytest-dev/pytest/issues/3555>`_)
+  ``MarkDecorator``. (:issue:`3555`)
 
 - Warnings without ``location`` were reported as ``None``. This is corrected to
-  now report ``<undetermined location>``. (`#3563
-  <https://github.com/pytest-dev/pytest/issues/3563>`_)
+  now report ``<undetermined location>``. (:issue:`3563`)
 
 - Continue to call finalizers in the stack when a finalizer in a former scope
-  raises an exception. (`#3569
-  <https://github.com/pytest-dev/pytest/issues/3569>`_)
+  raises an exception. (:issue:`3569`)
 
-- Fix encoding error with ``print`` statements in doctests (`#3583
-  <https://github.com/pytest-dev/pytest/issues/3583>`_)
+- Fix encoding error with ``print`` statements in doctests (:issue:`3583`)
 
 
 Improved Documentation
 ----------------------
 
-- Add documentation for the ``--strict`` flag. (`#3549
-  <https://github.com/pytest-dev/pytest/issues/3549>`_)
+- Add documentation for the ``--strict`` flag. (:issue:`3549`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Update old quotation style to parens in fixture.rst documentation. (`#3525
-  <https://github.com/pytest-dev/pytest/issues/3525>`_)
+- Update old quotation style to parens in fixture.rst documentation. (:issue:`3525`)
 
 - Improve display of hint about ``--fulltrace`` with ``KeyboardInterrupt``.
-  (`#3545 <https://github.com/pytest-dev/pytest/issues/3545>`_)
+  (:issue:`3545`)
 
 - pytest's testsuite is no longer runnable through ``python setup.py test`` --
-  instead invoke ``pytest`` or ``tox`` directly. (`#3552
-  <https://github.com/pytest-dev/pytest/issues/3552>`_)
+  instead invoke ``pytest`` or ``tox`` directly. (:issue:`3552`)
 
-- Fix typo in documentation (`#3567
-  <https://github.com/pytest-dev/pytest/issues/3567>`_)
+- Fix typo in documentation (:issue:`3567`)
 
 
 pytest 3.6.1 (2018-06-05)
@@ -4136,41 +5342,35 @@ Bug Fixes
 ---------
 
 - Fixed a bug where stdout and stderr were logged twice by junitxml when a test
-  was marked xfail. (`#3491
-  <https://github.com/pytest-dev/pytest/issues/3491>`_)
+  was marked xfail. (:issue:`3491`)
 
-- Fix ``usefixtures`` mark applyed to unittest tests by correctly instantiating
-  ``FixtureInfo``. (`#3498
-  <https://github.com/pytest-dev/pytest/issues/3498>`_)
+- Fix ``usefixtures`` mark applied to unittest tests by correctly instantiating
+  ``FixtureInfo``. (:issue:`3498`)
 
 - Fix assertion rewriter compatibility with libraries that monkey patch
-  ``file`` objects. (`#3503
-  <https://github.com/pytest-dev/pytest/issues/3503>`_)
+  ``file`` objects. (:issue:`3503`)
 
 
 Improved Documentation
 ----------------------
 
 - Added a section on how to use fixtures as factories to the fixture
-  documentation. (`#3461 <https://github.com/pytest-dev/pytest/issues/3461>`_)
+  documentation. (:issue:`3461`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - Enable caching for pip/pre-commit in order to reduce build time on
-  travis/appveyor. (`#3502
-  <https://github.com/pytest-dev/pytest/issues/3502>`_)
+  travis/appveyor. (:issue:`3502`)
 
 - Switch pytest to the src/ layout as we already suggested it for good practice
-  - now we implement it as well. (`#3513
-  <https://github.com/pytest-dev/pytest/issues/3513>`_)
+  - now we implement it as well. (:issue:`3513`)
 
 - Fix if in tests to support 3.7.0b5, where a docstring handling in AST got
-  reverted. (`#3530 <https://github.com/pytest-dev/pytest/issues/3530>`_)
+  reverted. (:issue:`3530`)
 
-- Remove some python2.5 compatibility code. (`#3529
-  <https://github.com/pytest-dev/pytest/issues/3529>`_)
+- Remove some python2.5 compatibility code. (:issue:`3529`)
 
 
 pytest 3.6.0 (2018-05-23)
@@ -4183,80 +5383,71 @@ Features
   node handling which fixes a number of long standing bugs caused by the old
   design. This introduces new ``Node.iter_markers(name)`` and
   ``Node.get_closest_marker(name)`` APIs. Users are **strongly encouraged** to
-  read the `reasons for the revamp in the docs
-  <https://docs.pytest.org/en/stable/historical-notes.html#marker-revamp-and-iteration>`_,
-  or jump over to details about `updating existing code to use the new APIs
-  <https://docs.pytest.org/en/stable/historical-notes.html#updating-code>`_.
-  (`#3317 <https://github.com/pytest-dev/pytest/issues/3317>`_)
+  read the :ref:`reasons for the revamp in the docs <marker-revamp>`,
+  or jump over to details about :ref:`updating existing code to use the new APIs
+  <update marker code>`.
+  (:issue:`3317`)
 
 - Now when ``@pytest.fixture`` is applied more than once to the same function a
   ``ValueError`` is raised. This buggy behavior would cause surprising problems
-  and if was working for a test suite it was mostly by accident. (`#2334
-  <https://github.com/pytest-dev/pytest/issues/2334>`_)
+  and if was working for a test suite it was mostly by accident. (:issue:`2334`)
 
-- Support for Python 3.7's builtin ``breakpoint()`` method, see `Using the
-  builtin breakpoint function
-  <https://docs.pytest.org/en/stable/usage.html#breakpoint-builtin>`_ for
-  details. (`#3180 <https://github.com/pytest-dev/pytest/issues/3180>`_)
+- Support for Python 3.7's builtin ``breakpoint()`` method, see
+  :ref:`Using the builtin breakpoint function <breakpoint-builtin>` for
+  details. (:issue:`3180`)
 
 - ``monkeypatch`` now supports a ``context()`` function which acts as a context
-  manager which undoes all patching done within the ``with`` block. (`#3290
-  <https://github.com/pytest-dev/pytest/issues/3290>`_)
+  manager which undoes all patching done within the ``with`` block. (:issue:`3290`)
 
 - The ``--pdb`` option now causes KeyboardInterrupt to enter the debugger,
   instead of stopping the test session. On python 2.7, hitting CTRL+C again
-  exits the debugger. On python 3.2 and higher, use CTRL+D. (`#3299
-  <https://github.com/pytest-dev/pytest/issues/3299>`_)
+  exits the debugger. On python 3.2 and higher, use CTRL+D. (:issue:`3299`)
 
 - pytest no longer changes the log level of the root logger when the
   ``log-level`` parameter has greater numeric value than that of the level of
   the root logger, which makes it play better with custom logging configuration
-  in user code. (`#3307 <https://github.com/pytest-dev/pytest/issues/3307>`_)
+  in user code. (:issue:`3307`)
 
 
 Bug Fixes
 ---------
 
 - A rare race-condition which might result in corrupted ``.pyc`` files on
-  Windows has been hopefully solved. (`#3008
-  <https://github.com/pytest-dev/pytest/issues/3008>`_)
+  Windows has been hopefully solved. (:issue:`3008`)
 
 - Also use iter_marker for discovering the marks applying for marker
   expressions from the cli to avoid the bad data from the legacy mark storage.
-  (`#3441 <https://github.com/pytest-dev/pytest/issues/3441>`_)
+  (:issue:`3441`)
 
 - When showing diffs of failed assertions where the contents contain only
   whitespace, escape them using ``repr()`` first to make it easy to spot the
-  differences. (`#3443 <https://github.com/pytest-dev/pytest/issues/3443>`_)
+  differences. (:issue:`3443`)
 
 
 Improved Documentation
 ----------------------
 
 - Change documentation copyright year to a range which auto-updates itself each
-  time it is published. (`#3303
-  <https://github.com/pytest-dev/pytest/issues/3303>`_)
+  time it is published. (:issue:`3303`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - ``pytest`` now depends on the `python-atomicwrites
-  <https://github.com/untitaker/python-atomicwrites>`_ library. (`#3008
-  <https://github.com/pytest-dev/pytest/issues/3008>`_)
+  <https://github.com/untitaker/python-atomicwrites>`_ library. (:issue:`3008`)
 
-- Update all pypi.python.org URLs to pypi.org. (`#3431
-  <https://github.com/pytest-dev/pytest/issues/3431>`_)
+- Update all pypi.python.org URLs to pypi.org. (:issue:`3431`)
 
 - Detect `pytest_` prefixed hooks using the internal plugin manager since
   ``pluggy`` is deprecating the ``implprefix`` argument to ``PluginManager``.
-  (`#3487 <https://github.com/pytest-dev/pytest/issues/3487>`_)
+  (:issue:`3487`)
 
 - Import ``Mapping`` and ``Sequence`` from ``_pytest.compat`` instead of
   directly from ``collections`` in ``python_api.py::approx``. Add ``Mapping``
   to ``_pytest.compat``, import it from ``collections`` on python 2, but from
   ``collections.abc`` on Python 3 to avoid a ``DeprecationWarning`` on Python
-  3.7 or newer. (`#3497 <https://github.com/pytest-dev/pytest/issues/3497>`_)
+  3.7 or newer. (:issue:`3497`)
 
 
 pytest 3.5.1 (2018-04-23)
@@ -4270,45 +5461,39 @@ Bug Fixes
   each test executes. Those attributes are added by pytest during the test run
   to aid debugging, but were never reset so they would create a leaking
   reference to the last failing test's frame which in turn could never be
-  reclaimed by the garbage collector. (`#2798
-  <https://github.com/pytest-dev/pytest/issues/2798>`_)
+  reclaimed by the garbage collector. (:issue:`2798`)
 
 - ``pytest.raises`` now raises ``TypeError`` when receiving an unknown keyword
-  argument. (`#3348 <https://github.com/pytest-dev/pytest/issues/3348>`_)
+  argument. (:issue:`3348`)
 
 - ``pytest.raises`` now works with exception classes that look like iterables.
-  (`#3372 <https://github.com/pytest-dev/pytest/issues/3372>`_)
+  (:issue:`3372`)
 
 
 Improved Documentation
 ----------------------
 
 - Fix typo in ``caplog`` fixture documentation, which incorrectly identified
-  certain attributes as methods. (`#3406
-  <https://github.com/pytest-dev/pytest/issues/3406>`_)
+  certain attributes as methods. (:issue:`3406`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - Added a more indicative error message when parametrizing a function whose
-  argument takes a default value. (`#3221
-  <https://github.com/pytest-dev/pytest/issues/3221>`_)
+  argument takes a default value. (:issue:`3221`)
 
 - Remove internal ``_pytest.terminal.flatten`` function in favor of
-  ``more_itertools.collapse``. (`#3330
-  <https://github.com/pytest-dev/pytest/issues/3330>`_)
+  ``more_itertools.collapse``. (:issue:`3330`)
 
 - Import some modules from ``collections.abc`` instead of ``collections`` as
-  the former modules trigger ``DeprecationWarning`` in Python 3.7. (`#3339
-  <https://github.com/pytest-dev/pytest/issues/3339>`_)
+  the former modules trigger ``DeprecationWarning`` in Python 3.7. (:issue:`3339`)
 
 - record_property is no longer experimental, removing the warnings was
-  forgotten. (`#3360 <https://github.com/pytest-dev/pytest/issues/3360>`_)
+  forgotten. (:issue:`3360`)
 
 - Mention in documentation and CLI help that fixtures with leading ``_`` are
-  printed by ``pytest --fixtures`` only if the ``-v`` option is added. (`#3398
-  <https://github.com/pytest-dev/pytest/issues/3398>`_)
+  printed by ``pytest --fixtures`` only if the ``-v`` option is added. (:issue:`3398`)
 
 
 pytest 3.5.0 (2018-03-21)
@@ -4318,12 +5503,12 @@ Deprecations and Removals
 -------------------------
 
 - ``record_xml_property`` fixture is now deprecated in favor of the more
-  generic ``record_property``. (`#2770
-  <https://github.com/pytest-dev/pytest/issues/2770>`_)
+  generic ``record_property``. (:issue:`2770`)
 
 - Defining ``pytest_plugins`` is now deprecated in non-top-level conftest.py
-  files, because they "leak" to the entire directory tree. `See the docs <https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files>`_ for the rationale behind this decision (`#3084
-  <https://github.com/pytest-dev/pytest/issues/3084>`_)
+  files, because they "leak" to the entire directory tree.
+  :ref:`See the docs <pytest_plugins in non-top-level conftest files deprecated>`
+  for the rationale behind this decision (:issue:`3084`)
 
 
 Features
@@ -4331,136 +5516,114 @@ Features
 
 - New ``--show-capture`` command-line option that allows to specify how to
   display captured output when tests fail: ``no``, ``stdout``, ``stderr``,
-  ``log`` or ``all`` (the default). (`#1478
-  <https://github.com/pytest-dev/pytest/issues/1478>`_)
+  ``log`` or ``all`` (the default). (:issue:`1478`)
 
 - New ``--rootdir`` command-line option to override the rules for discovering
-  the root directory. See `customize
-  <https://docs.pytest.org/en/stable/customize.html>`_ in the documentation for
-  details. (`#1642 <https://github.com/pytest-dev/pytest/issues/1642>`_)
+  the root directory. See :doc:`customize <reference/customize>` in the documentation for
+  details. (:issue:`1642`)
 
 - Fixtures are now instantiated based on their scopes, with higher-scoped
   fixtures (such as ``session``) being instantiated first than lower-scoped
   fixtures (such as ``function``). The relative order of fixtures of the same
   scope is kept unchanged, based in their declaration order and their
-  dependencies. (`#2405 <https://github.com/pytest-dev/pytest/issues/2405>`_)
+  dependencies. (:issue:`2405`)
 
 - ``record_xml_property`` renamed to ``record_property`` and is now compatible
   with xdist, markers and any reporter. ``record_xml_property`` name is now
-  deprecated. (`#2770 <https://github.com/pytest-dev/pytest/issues/2770>`_)
+  deprecated. (:issue:`2770`)
 
 - New ``--nf``, ``--new-first`` options: run new tests first followed by the
   rest of the tests, in both cases tests are also sorted by the file modified
-  time, with more recent files coming first. (`#3034
-  <https://github.com/pytest-dev/pytest/issues/3034>`_)
+  time, with more recent files coming first. (:issue:`3034`)
 
 - New ``--last-failed-no-failures`` command-line option that allows to specify
   the behavior of the cache plugin's ```--last-failed`` feature when no tests
   failed in the last run (or no cache was found): ``none`` or ``all`` (the
-  default). (`#3139 <https://github.com/pytest-dev/pytest/issues/3139>`_)
+  default). (:issue:`3139`)
 
 - New ``--doctest-continue-on-failure`` command-line option to enable doctests
   to show multiple failures for each snippet, instead of stopping at the first
-  failure. (`#3149 <https://github.com/pytest-dev/pytest/issues/3149>`_)
+  failure. (:issue:`3149`)
 
 - Captured log messages are added to the ``<system-out>`` tag in the generated
   junit xml file if the ``junit_logging`` ini option is set to ``system-out``.
   If the value of this ini option is ``system-err``, the logs are written to
   ``<system-err>``. The default value for ``junit_logging`` is ``no``, meaning
-  captured logs are not written to the output file. (`#3156
-  <https://github.com/pytest-dev/pytest/issues/3156>`_)
+  captured logs are not written to the output file. (:issue:`3156`)
 
 - Allow the logging plugin to handle ``pytest_runtest_logstart`` and
-  ``pytest_runtest_logfinish`` hooks when live logs are enabled. (`#3189
-  <https://github.com/pytest-dev/pytest/issues/3189>`_)
+  ``pytest_runtest_logfinish`` hooks when live logs are enabled. (:issue:`3189`)
 
 - Passing ``--log-cli-level`` in the command-line now automatically activates
-  live logging. (`#3190 <https://github.com/pytest-dev/pytest/issues/3190>`_)
+  live logging. (:issue:`3190`)
 
 - Add command line option ``--deselect`` to allow deselection of individual
-  tests at collection time. (`#3198
-  <https://github.com/pytest-dev/pytest/issues/3198>`_)
+  tests at collection time. (:issue:`3198`)
 
-- Captured logs are printed before entering pdb. (`#3204
-  <https://github.com/pytest-dev/pytest/issues/3204>`_)
+- Captured logs are printed before entering pdb. (:issue:`3204`)
 
 - Deselected item count is now shown before tests are run, e.g. ``collected X
-  items / Y deselected``. (`#3213
-  <https://github.com/pytest-dev/pytest/issues/3213>`_)
+  items / Y deselected``. (:issue:`3213`)
 
 - The builtin module ``platform`` is now available for use in expressions in
-  ``pytest.mark``. (`#3236
-  <https://github.com/pytest-dev/pytest/issues/3236>`_)
+  ``pytest.mark``. (:issue:`3236`)
 
 - The *short test summary info* section now is displayed after tracebacks and
-  warnings in the terminal. (`#3255
-  <https://github.com/pytest-dev/pytest/issues/3255>`_)
+  warnings in the terminal. (:issue:`3255`)
 
-- New ``--verbosity`` flag to set verbosity level explicitly. (`#3296
-  <https://github.com/pytest-dev/pytest/issues/3296>`_)
+- New ``--verbosity`` flag to set verbosity level explicitly. (:issue:`3296`)
 
-- ``pytest.approx`` now accepts comparing a numpy array with a scalar. (`#3312
-  <https://github.com/pytest-dev/pytest/issues/3312>`_)
+- ``pytest.approx`` now accepts comparing a numpy array with a scalar. (:issue:`3312`)
 
 
 Bug Fixes
 ---------
 
 - Suppress ``IOError`` when closing the temporary file used for capturing
-  streams in Python 2.7. (`#2370
-  <https://github.com/pytest-dev/pytest/issues/2370>`_)
+  streams in Python 2.7. (:issue:`2370`)
 
 - Fixed ``clear()`` method on ``caplog`` fixture which cleared ``records``, but
-  not the ``text`` property. (`#3297
-  <https://github.com/pytest-dev/pytest/issues/3297>`_)
+  not the ``text`` property. (:issue:`3297`)
 
 - During test collection, when stdin is not allowed to be read, the
   ``DontReadFromStdin`` object still allow itself to be iterable and resolved
-  to an iterator without crashing. (`#3314
-  <https://github.com/pytest-dev/pytest/issues/3314>`_)
+  to an iterator without crashing. (:issue:`3314`)
 
 
 Improved Documentation
 ----------------------
 
-- Added a `reference <https://docs.pytest.org/en/stable/reference.html>`_ page
-  to the docs. (`#1713 <https://github.com/pytest-dev/pytest/issues/1713>`_)
+- Added a :doc:`reference <reference/reference>` page
+  to the docs. (:issue:`1713`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Change minimum requirement of ``attrs`` to ``17.4.0``. (`#3228
-  <https://github.com/pytest-dev/pytest/issues/3228>`_)
+- Change minimum requirement of ``attrs`` to ``17.4.0``. (:issue:`3228`)
 
 - Renamed example directories so all tests pass when ran from the base
-  directory. (`#3245 <https://github.com/pytest-dev/pytest/issues/3245>`_)
+  directory. (:issue:`3245`)
 
-- Internal ``mark.py`` module has been turned into a package. (`#3250
-  <https://github.com/pytest-dev/pytest/issues/3250>`_)
+- Internal ``mark.py`` module has been turned into a package. (:issue:`3250`)
 
 - ``pytest`` now depends on the `more-itertools
-  <https://github.com/erikrose/more-itertools>`_ package. (`#3265
-  <https://github.com/pytest-dev/pytest/issues/3265>`_)
+  <https://github.com/erikrose/more-itertools>`_ package. (:issue:`3265`)
 
 - Added warning when ``[pytest]`` section is used in a ``.cfg`` file passed
-  with ``-c`` (`#3268 <https://github.com/pytest-dev/pytest/issues/3268>`_)
+  with ``-c`` (:issue:`3268`)
 
 - ``nodeids`` can now be passed explicitly to ``FSCollector`` and ``Node``
-  constructors. (`#3291 <https://github.com/pytest-dev/pytest/issues/3291>`_)
+  constructors. (:issue:`3291`)
 
 - Internal refactoring of ``FormattedExcinfo`` to use ``attrs`` facilities and
-  remove old support code for legacy Python versions. (`#3292
-  <https://github.com/pytest-dev/pytest/issues/3292>`_)
+  remove old support code for legacy Python versions. (:issue:`3292`)
 
-- Refactoring to unify how verbosity is handled internally. (`#3296
-  <https://github.com/pytest-dev/pytest/issues/3296>`_)
+- Refactoring to unify how verbosity is handled internally. (:issue:`3296`)
 
-- Internal refactoring to better integrate with argparse. (`#3304
-  <https://github.com/pytest-dev/pytest/issues/3304>`_)
+- Internal refactoring to better integrate with argparse. (:issue:`3304`)
 
-- Fix a python example when calling a fixture in doc/en/usage.rst (`#3308
-  <https://github.com/pytest-dev/pytest/issues/3308>`_)
+- Fix a python example when calling a fixture in doc/en/usage.rst (:issue:`3308`)
 
 
 pytest 3.4.2 (2018-03-04)
@@ -4469,35 +5632,29 @@ pytest 3.4.2 (2018-03-04)
 Bug Fixes
 ---------
 
-- Removed progress information when capture option is ``no``. (`#3203
-  <https://github.com/pytest-dev/pytest/issues/3203>`_)
+- Removed progress information when capture option is ``no``. (:issue:`3203`)
 
-- Refactor check of bindir from ``exists`` to ``isdir``. (`#3241
-  <https://github.com/pytest-dev/pytest/issues/3241>`_)
+- Refactor check of bindir from ``exists`` to ``isdir``. (:issue:`3241`)
 
 - Fix ``TypeError`` issue when using ``approx`` with a ``Decimal`` value.
-  (`#3247 <https://github.com/pytest-dev/pytest/issues/3247>`_)
+  (:issue:`3247`)
 
-- Fix reference cycle generated when using the ``request`` fixture. (`#3249
-  <https://github.com/pytest-dev/pytest/issues/3249>`_)
+- Fix reference cycle generated when using the ``request`` fixture. (:issue:`3249`)
 
 - ``[tool:pytest]`` sections in ``*.cfg`` files passed by the ``-c`` option are
-  now properly recognized. (`#3260
-  <https://github.com/pytest-dev/pytest/issues/3260>`_)
+  now properly recognized. (:issue:`3260`)
 
 
 Improved Documentation
 ----------------------
 
-- Add logging plugin to plugins list. (`#3209
-  <https://github.com/pytest-dev/pytest/issues/3209>`_)
+- Add logging plugin to plugins list. (:issue:`3209`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Fix minor typo in fixture.rst (`#3259
-  <https://github.com/pytest-dev/pytest/issues/3259>`_)
+- Fix minor typo in fixture.rst (:issue:`3259`)
 
 
 pytest 3.4.1 (2018-02-20)
@@ -4507,58 +5664,47 @@ Bug Fixes
 ---------
 
 - Move import of ``doctest.UnexpectedException`` to top-level to avoid possible
-  errors when using ``--pdb``. (`#1810
-  <https://github.com/pytest-dev/pytest/issues/1810>`_)
+  errors when using ``--pdb``. (:issue:`1810`)
 
 - Added printing of captured stdout/stderr before entering pdb, and improved a
-  test which was giving false negatives about output capturing. (`#3052
-  <https://github.com/pytest-dev/pytest/issues/3052>`_)
+  test which was giving false negatives about output capturing. (:issue:`3052`)
 
 - Fix ordering of tests using parametrized fixtures which can lead to fixtures
-  being created more than necessary. (`#3161
-  <https://github.com/pytest-dev/pytest/issues/3161>`_)
+  being created more than necessary. (:issue:`3161`)
 
 - Fix bug where logging happening at hooks outside of "test run" hooks would
-  cause an internal error. (`#3184
-  <https://github.com/pytest-dev/pytest/issues/3184>`_)
+  cause an internal error. (:issue:`3184`)
 
 - Detect arguments injected by ``unittest.mock.patch`` decorator correctly when
-  pypi ``mock.patch`` is installed and imported. (`#3206
-  <https://github.com/pytest-dev/pytest/issues/3206>`_)
+  pypi ``mock.patch`` is installed and imported. (:issue:`3206`)
 
 - Errors shown when a ``pytest.raises()`` with ``match=`` fails are now cleaner
   on what happened: When no exception was raised, the "matching '...'" part got
   removed as it falsely implies that an exception was raised but it didn't
   match. When a wrong exception was raised, it's now thrown (like
   ``pytest.raised()`` without ``match=`` would) instead of complaining about
-  the unmatched text. (`#3222
-  <https://github.com/pytest-dev/pytest/issues/3222>`_)
+  the unmatched text. (:issue:`3222`)
 
-- Fixed output capture handling in doctests on macOS. (`#985
-  <https://github.com/pytest-dev/pytest/issues/985>`_)
+- Fixed output capture handling in doctests on macOS. (:issue:`985`)
 
 
 Improved Documentation
 ----------------------
 
 - Add Sphinx parameter docs for ``match`` and ``message`` args to
-  ``pytest.raises``. (`#3202
-  <https://github.com/pytest-dev/pytest/issues/3202>`_)
+  ``pytest.raises``. (:issue:`3202`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - pytest has changed the publication procedure and is now being published to
-  PyPI directly from Travis. (`#3060
-  <https://github.com/pytest-dev/pytest/issues/3060>`_)
+  PyPI directly from Travis. (:issue:`3060`)
 
 - Rename ``ParameterSet._for_parameterize()`` to ``_for_parametrize()`` in
-  order to comply with the naming convention. (`#3166
-  <https://github.com/pytest-dev/pytest/issues/3166>`_)
+  order to comply with the naming convention. (:issue:`3166`)
 
-- Skip failing pdb/doctest test on mac. (`#985
-  <https://github.com/pytest-dev/pytest/issues/985>`_)
+- Skip failing pdb/doctest test on mac. (:issue:`985`)
 
 
 pytest 3.4.0 (2018-01-30)
@@ -4568,8 +5714,7 @@ Deprecations and Removals
 -------------------------
 
 - All pytest classes now subclass ``object`` for better Python 2/3 compatibility.
-  This should not affect user code except in very rare edge cases. (`#2147
-  <https://github.com/pytest-dev/pytest/issues/2147>`_)
+  This should not affect user code except in very rare edge cases. (:issue:`2147`)
 
 
 Features
@@ -4579,99 +5724,81 @@ Features
   apply when ``@pytest.mark.parametrize`` is given an empty set of parameters.
   Valid options are ``skip`` (default) and ``xfail``. Note that it is planned
   to change the default to ``xfail`` in future releases as this is considered
-  less error prone. (`#2527
-  <https://github.com/pytest-dev/pytest/issues/2527>`_)
+  less error prone. (:issue:`2527`)
 
-- **Incompatible change**: after community feedback the `logging
-  <https://docs.pytest.org/en/stable/logging.html>`_ functionality has
-  undergone some changes. Please consult the `logging documentation
-  <https://docs.pytest.org/en/stable/logging.html#incompatible-changes-in-pytest-3-4>`_
-  for details. (`#3013 <https://github.com/pytest-dev/pytest/issues/3013>`_)
+- **Incompatible change**: after community feedback the :doc:`logging <how-to/logging>` functionality has
+  undergone some changes. Please consult the :ref:`logging documentation <log_changes_3_4>`
+  for details. (:issue:`3013`)
 
 - Console output falls back to "classic" mode when capturing is disabled (``-s``),
-  otherwise the output gets garbled to the point of being useless. (`#3038
-  <https://github.com/pytest-dev/pytest/issues/3038>`_)
+  otherwise the output gets garbled to the point of being useless. (:issue:`3038`)
 
-- New `pytest_runtest_logfinish
-  <https://docs.pytest.org/en/stable/reference.html#_pytest.hookspec.pytest_runtest_logfinish>`_
+- New :hook:`pytest_runtest_logfinish`
   hook which is called when a test item has finished executing, analogous to
-  `pytest_runtest_logstart
-  <https://docs.pytest.org/en/stable/reference.html#_pytest.hookspec.pytest_runtest_logstart>`_.
-  (`#3101 <https://github.com/pytest-dev/pytest/issues/3101>`_)
+  :hook:`pytest_runtest_logstart`.
+  (:issue:`3101`)
 
-- Improve performance when collecting tests using many fixtures. (`#3107
-  <https://github.com/pytest-dev/pytest/issues/3107>`_)
+- Improve performance when collecting tests using many fixtures. (:issue:`3107`)
 
 - New ``caplog.get_records(when)`` method which provides access to the captured
   records for the ``"setup"``, ``"call"`` and ``"teardown"``
-  testing stages. (`#3117 <https://github.com/pytest-dev/pytest/issues/3117>`_)
+  testing stages. (:issue:`3117`)
 
 - New fixture ``record_xml_attribute`` that allows modifying and inserting
-  attributes on the ``<testcase>`` xml node in JUnit reports. (`#3130
-  <https://github.com/pytest-dev/pytest/issues/3130>`_)
+  attributes on the ``<testcase>`` xml node in JUnit reports. (:issue:`3130`)
 
 - The default cache directory has been renamed from ``.cache`` to
   ``.pytest_cache`` after community feedback that the name ``.cache`` did not
-  make it clear that it was used by pytest. (`#3138
-  <https://github.com/pytest-dev/pytest/issues/3138>`_)
+  make it clear that it was used by pytest. (:issue:`3138`)
 
-- Colorize the levelname column in the live-log output. (`#3142
-  <https://github.com/pytest-dev/pytest/issues/3142>`_)
+- Colorize the levelname column in the live-log output. (:issue:`3142`)
 
 
 Bug Fixes
 ---------
 
 - Fix hanging pexpect test on MacOS by using flush() instead of wait().
-  (`#2022 <https://github.com/pytest-dev/pytest/issues/2022>`_)
+  (:issue:`2022`)
 
 - Fix restoring Python state after in-process pytest runs with the
   ``pytester`` plugin; this may break tests using multiple inprocess
   pytest runs if later ones depend on earlier ones leaking global interpreter
-  changes. (`#3016 <https://github.com/pytest-dev/pytest/issues/3016>`_)
+  changes. (:issue:`3016`)
 
 - Fix skipping plugin reporting hook when test aborted before plugin setup
-  hook. (`#3074 <https://github.com/pytest-dev/pytest/issues/3074>`_)
+  hook. (:issue:`3074`)
 
-- Fix progress percentage reported when tests fail during teardown. (`#3088
-  <https://github.com/pytest-dev/pytest/issues/3088>`_)
+- Fix progress percentage reported when tests fail during teardown. (:issue:`3088`)
 
 - **Incompatible change**: ``-o/--override`` option no longer eats all the
   remaining options, which can lead to surprising behavior: for example,
   ``pytest -o foo=1 /path/to/test.py`` would fail because ``/path/to/test.py``
   would be considered as part of the ``-o`` command-line argument. One
   consequence of this is that now multiple configuration overrides need
-  multiple ``-o`` flags: ``pytest -o foo=1 -o bar=2``. (`#3103
-  <https://github.com/pytest-dev/pytest/issues/3103>`_)
+  multiple ``-o`` flags: ``pytest -o foo=1 -o bar=2``. (:issue:`3103`)
 
 
 Improved Documentation
 ----------------------
 
 - Document hooks (defined with ``historic=True``) which cannot be used with
-  ``hookwrapper=True``. (`#2423
-  <https://github.com/pytest-dev/pytest/issues/2423>`_)
+  ``hookwrapper=True``. (:issue:`2423`)
 
 - Clarify that warning capturing doesn't change the warning filter by default.
-  (`#2457 <https://github.com/pytest-dev/pytest/issues/2457>`_)
+  (:issue:`2457`)
 
 - Clarify a possible confusion when using pytest_fixture_setup with fixture
-  functions that return None. (`#2698
-  <https://github.com/pytest-dev/pytest/issues/2698>`_)
+  functions that return None. (:issue:`2698`)
 
-- Fix the wording of a sentence on doctest flags used in pytest. (`#3076
-  <https://github.com/pytest-dev/pytest/issues/3076>`_)
+- Fix the wording of a sentence on doctest flags used in pytest. (:issue:`3076`)
 
 - Prefer ``https://*.readthedocs.io`` over ``http://*.rtfd.org`` for links in
-  the documentation. (`#3092
-  <https://github.com/pytest-dev/pytest/issues/3092>`_)
+  the documentation. (:issue:`3092`)
 
-- Improve readability (wording, grammar) of Getting Started guide (`#3131
-  <https://github.com/pytest-dev/pytest/issues/3131>`_)
+- Improve readability (wording, grammar) of Getting Started guide (:issue:`3131`)
 
 - Added note that calling pytest.main multiple times from the same process is
-  not recommended because of import caching. (`#3143
-  <https://github.com/pytest-dev/pytest/issues/3143>`_)
+  not recommended because of import caching. (:issue:`3143`)
 
 
 Trivial/Internal Changes
@@ -4679,18 +5806,15 @@ Trivial/Internal Changes
 
 - Show a simple and easy error when keyword expressions trigger a syntax error
   (for example, ``"-k foo and import"`` will show an error that you can not use
-  the ``import`` keyword in expressions). (`#2953
-  <https://github.com/pytest-dev/pytest/issues/2953>`_)
+  the ``import`` keyword in expressions). (:issue:`2953`)
 
 - Change parametrized automatic test id generation to use the ``__name__``
   attribute of functions instead of the fallback argument name plus counter.
-  (`#2976 <https://github.com/pytest-dev/pytest/issues/2976>`_)
+  (:issue:`2976`)
 
-- Replace py.std with stdlib imports. (`#3067
-  <https://github.com/pytest-dev/pytest/issues/3067>`_)
+- Replace py.std with stdlib imports. (:issue:`3067`)
 
-- Corrected 'you' to 'your' in logging docs. (`#3129
-  <https://github.com/pytest-dev/pytest/issues/3129>`_)
+- Corrected 'you' to 'your' in logging docs. (:issue:`3129`)
 
 
 pytest 3.3.2 (2017-12-25)
@@ -4700,34 +5824,31 @@ Bug Fixes
 ---------
 
 - pytester: ignore files used to obtain current user metadata in the fd leak
-  detector. (`#2784 <https://github.com/pytest-dev/pytest/issues/2784>`_)
+  detector. (:issue:`2784`)
 
 - Fix **memory leak** where objects returned by fixtures were never destructed
-  by the garbage collector. (`#2981
-  <https://github.com/pytest-dev/pytest/issues/2981>`_)
+  by the garbage collector. (:issue:`2981`)
 
-- Fix conversion of pyargs to filename to not convert symlinks on Python 2. (`#2985
-  <https://github.com/pytest-dev/pytest/issues/2985>`_)
+- Fix conversion of pyargs to filename to not convert symlinks on Python 2. (:issue:`2985`)
 
 - ``PYTEST_DONT_REWRITE`` is now checked for plugins too rather than only for
-  test modules. (`#2995 <https://github.com/pytest-dev/pytest/issues/2995>`_)
+  test modules. (:issue:`2995`)
 
 
 Improved Documentation
 ----------------------
 
-- Add clarifying note about behavior of multiple parametrized arguments (`#3001
-  <https://github.com/pytest-dev/pytest/issues/3001>`_)
+- Add clarifying note about behavior of multiple parametrized arguments (:issue:`3001`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Code cleanup. (`#3015 <https://github.com/pytest-dev/pytest/issues/3015>`_,
-  `#3021 <https://github.com/pytest-dev/pytest/issues/3021>`_)
+- Code cleanup. (:issue:`3015`,
+  :issue:`3021`)
 
 - Clean up code by replacing imports and references of ``_ast`` to ``ast``.
-  (`#3018 <https://github.com/pytest-dev/pytest/issues/3018>`_)
+  (:issue:`3018`)
 
 
 pytest 3.3.1 (2017-12-05)
@@ -4736,40 +5857,34 @@ pytest 3.3.1 (2017-12-05)
 Bug Fixes
 ---------
 
-- Fix issue about ``-p no:<plugin>`` having no effect. (`#2920
-  <https://github.com/pytest-dev/pytest/issues/2920>`_)
+- Fix issue about ``-p no:<plugin>`` having no effect. (:issue:`2920`)
 
 - Fix regression with warnings that contained non-strings in their arguments in
-  Python 2. (`#2956 <https://github.com/pytest-dev/pytest/issues/2956>`_)
+  Python 2. (:issue:`2956`)
 
-- Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (`#2957
-  <https://github.com/pytest-dev/pytest/issues/2957>`_)
+- Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (:issue:`2957`)
 
 - Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests
-  were actually collected. (`#2971
-  <https://github.com/pytest-dev/pytest/issues/2971>`_)
+  were actually collected. (:issue:`2971`)
 
 - Bring back ``TerminalReporter.writer`` as an alias to
   ``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0``
-  release. (`#2984 <https://github.com/pytest-dev/pytest/issues/2984>`_)
+  release. (:issue:`2984`)
 
 - The ``pytest-capturelog`` plugin is now also blacklisted, avoiding errors when
-  running pytest with it still installed. (`#3004
-  <https://github.com/pytest-dev/pytest/issues/3004>`_)
+  running pytest with it still installed. (:issue:`3004`)
 
 
 Improved Documentation
 ----------------------
 
-- Fix broken link to plugin ``pytest-localserver``. (`#2963
-  <https://github.com/pytest-dev/pytest/issues/2963>`_)
+- Fix broken link to plugin ``pytest-localserver``. (:issue:`2963`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Update github "bugs" link in ``CONTRIBUTING.rst`` (`#2949
-  <https://github.com/pytest-dev/pytest/issues/2949>`_)
+- Update github "bugs" link in ``CONTRIBUTING.rst`` (:issue:`2949`)
 
 
 pytest 3.3.0 (2017-11-23)
@@ -4782,171 +5897,142 @@ Deprecations and Removals
   are EOL for some time now and incur maintenance and compatibility costs on
   the pytest core team, and following up with the rest of the community we
   decided that they will no longer be supported starting on this version. Users
-  which still require those versions should pin pytest to ``<3.3``. (`#2812
-  <https://github.com/pytest-dev/pytest/issues/2812>`_)
+  which still require those versions should pin pytest to ``<3.3``. (:issue:`2812`)
 
 - Remove internal ``_preloadplugins()`` function. This removal is part of the
-  ``pytest_namespace()`` hook deprecation. (`#2636
-  <https://github.com/pytest-dev/pytest/issues/2636>`_)
+  ``pytest_namespace()`` hook deprecation. (:issue:`2636`)
 
 - Internally change ``CallSpec2`` to have a list of marks instead of a broken
   mapping of keywords. This removes the keywords attribute of the internal
-  ``CallSpec2`` class. (`#2672
-  <https://github.com/pytest-dev/pytest/issues/2672>`_)
+  ``CallSpec2`` class. (:issue:`2672`)
 
 - Remove ParameterSet.deprecated_arg_dict - its not a public api and the lack
-  of the underscore was a naming error. (`#2675
-  <https://github.com/pytest-dev/pytest/issues/2675>`_)
+  of the underscore was a naming error. (:issue:`2675`)
 
 - Remove the internal multi-typed attribute ``Node._evalskip`` and replace it
-  with the boolean ``Node._skipped_by_mark``. (`#2767
-  <https://github.com/pytest-dev/pytest/issues/2767>`_)
+  with the boolean ``Node._skipped_by_mark``. (:issue:`2767`)
 
 - The ``params`` list passed to ``pytest.fixture`` is now for
   all effects considered immutable and frozen at the moment of the ``pytest.fixture``
   call. Previously the list could be changed before the first invocation of the fixture
   allowing for a form of dynamic parametrization (for example, updated from command-line options),
   but this was an unwanted implementation detail which complicated the internals and prevented
-  some internal cleanup. See issue `#2959 <https://github.com/pytest-dev/pytest/issues/2959>`_
+  some internal cleanup. See issue :issue:`2959`
   for details and a recommended workaround.
 
 Features
 --------
 
 - ``pytest_fixture_post_finalizer`` hook can now receive a ``request``
-  argument. (`#2124 <https://github.com/pytest-dev/pytest/issues/2124>`_)
+  argument. (:issue:`2124`)
 
 - Replace the old introspection code in compat.py that determines the available
   arguments of fixtures with inspect.signature on Python 3 and
   funcsigs.signature on Python 2. This should respect ``__signature__``
-  declarations on functions. (`#2267
-  <https://github.com/pytest-dev/pytest/issues/2267>`_)
+  declarations on functions. (:issue:`2267`)
 
-- Report tests with global ``pytestmark`` variable only once. (`#2549
-  <https://github.com/pytest-dev/pytest/issues/2549>`_)
+- Report tests with global ``pytestmark`` variable only once. (:issue:`2549`)
 
 - Now pytest displays the total progress percentage while running tests. The
   previous output style can be set by configuring the ``console_output_style``
-  setting to ``classic``. (`#2657 <https://github.com/pytest-dev/pytest/issues/2657>`_)
+  setting to ``classic``. (:issue:`2657`)
 
-- Match ``warns`` signature to ``raises`` by adding ``match`` keyword. (`#2708
-  <https://github.com/pytest-dev/pytest/issues/2708>`_)
+- Match ``warns`` signature to ``raises`` by adding ``match`` keyword. (:issue:`2708`)
 
 - pytest now captures and displays output from the standard ``logging`` module.
   The user can control the logging level to be captured by specifying options
   in ``pytest.ini``, the command line and also during individual tests using
   markers. Also, a ``caplog`` fixture is available that enables users to test
   the captured log during specific tests (similar to ``capsys`` for example).
-  For more information, please see the `logging docs
-  <https://docs.pytest.org/en/stable/logging.html>`_. This feature was
-  introduced by merging the popular `pytest-catchlog
-  <https://pypi.org/project/pytest-catchlog/>`_ plugin, thanks to `Thomas Hisch
-  <https://github.com/thisch>`_. Be advised that during the merging the
+  For more information, please see the :doc:`logging docs <how-to/logging>`. This feature was
+  introduced by merging the popular :pypi:`pytest-catchlog` plugin, thanks to :user:`thisch`.
+  Be advised that during the merging the
   backward compatibility interface with the defunct ``pytest-capturelog`` has
-  been dropped. (`#2794 <https://github.com/pytest-dev/pytest/issues/2794>`_)
+  been dropped. (:issue:`2794`)
 
 - Add ``allow_module_level`` kwarg to ``pytest.skip()``, enabling to skip the
-  whole module. (`#2808 <https://github.com/pytest-dev/pytest/issues/2808>`_)
+  whole module. (:issue:`2808`)
 
-- Allow setting ``file_or_dir``, ``-c``, and ``-o`` in PYTEST_ADDOPTS. (`#2824
-  <https://github.com/pytest-dev/pytest/issues/2824>`_)
+- Allow setting ``file_or_dir``, ``-c``, and ``-o`` in PYTEST_ADDOPTS. (:issue:`2824`)
 
 - Return stdout/stderr capture results as a ``namedtuple``, so ``out`` and
-  ``err`` can be accessed by attribute. (`#2879
-  <https://github.com/pytest-dev/pytest/issues/2879>`_)
+  ``err`` can be accessed by attribute. (:issue:`2879`)
 
 - Add ``capfdbinary``, a version of ``capfd`` which returns bytes from
-  ``readouterr()``. (`#2923
-  <https://github.com/pytest-dev/pytest/issues/2923>`_)
+  ``readouterr()``. (:issue:`2923`)
 
 - Add ``capsysbinary`` a version of ``capsys`` which returns bytes from
-  ``readouterr()``. (`#2934
-  <https://github.com/pytest-dev/pytest/issues/2934>`_)
+  ``readouterr()``. (:issue:`2934`)
 
 - Implement feature to skip ``setup.py`` files when run with
-  ``--doctest-modules``. (`#502
-  <https://github.com/pytest-dev/pytest/issues/502>`_)
+  ``--doctest-modules``. (:issue:`502`)
 
 
 Bug Fixes
 ---------
 
 - Resume output capturing after ``capsys/capfd.disabled()`` context manager.
-  (`#1993 <https://github.com/pytest-dev/pytest/issues/1993>`_)
+  (:issue:`1993`)
 
 - ``pytest_fixture_setup`` and ``pytest_fixture_post_finalizer`` hooks are now
-  called for all ``conftest.py`` files. (`#2124
-  <https://github.com/pytest-dev/pytest/issues/2124>`_)
+  called for all ``conftest.py`` files. (:issue:`2124`)
 
 - If an exception happens while loading a plugin, pytest no longer hides the
   original traceback. In Python 2 it will show the original traceback with a new
   message that explains in which plugin. In Python 3 it will show 2 canonized
   exceptions, the original exception while loading the plugin in addition to an
-  exception that pytest throws about loading a plugin. (`#2491
-  <https://github.com/pytest-dev/pytest/issues/2491>`_)
+  exception that pytest throws about loading a plugin. (:issue:`2491`)
 
-- ``capsys`` and ``capfd`` can now be used by other fixtures. (`#2709
-  <https://github.com/pytest-dev/pytest/issues/2709>`_)
+- ``capsys`` and ``capfd`` can now be used by other fixtures. (:issue:`2709`)
 
 - Internal ``pytester`` plugin properly encodes ``bytes`` arguments to
-  ``utf-8``. (`#2738 <https://github.com/pytest-dev/pytest/issues/2738>`_)
+  ``utf-8``. (:issue:`2738`)
 
 - ``testdir`` now uses use the same method used by ``tmpdir`` to create its
   temporary directory. This changes the final structure of the ``testdir``
   directory slightly, but should not affect usage in normal scenarios and
-  avoids a number of potential problems. (`#2751
-  <https://github.com/pytest-dev/pytest/issues/2751>`_)
+  avoids a number of potential problems. (:issue:`2751`)
 
 - pytest no longer complains about warnings with unicode messages being
   non-ascii compatible even for ascii-compatible messages. As a result of this,
   warnings with unicode messages are converted first to an ascii representation
-  for safety. (`#2809 <https://github.com/pytest-dev/pytest/issues/2809>`_)
+  for safety. (:issue:`2809`)
 
 - Change return value of pytest command when ``--maxfail`` is reached from
-  ``2`` (interrupted) to ``1`` (failed). (`#2845
-  <https://github.com/pytest-dev/pytest/issues/2845>`_)
+  ``2`` (interrupted) to ``1`` (failed). (:issue:`2845`)
 
 - Fix issue in assertion rewriting which could lead it to rewrite modules which
-  should not be rewritten. (`#2939
-  <https://github.com/pytest-dev/pytest/issues/2939>`_)
+  should not be rewritten. (:issue:`2939`)
 
-- Handle marks without description in ``pytest.ini``. (`#2942
-  <https://github.com/pytest-dev/pytest/issues/2942>`_)
+- Handle marks without description in ``pytest.ini``. (:issue:`2942`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- pytest now depends on `attrs <https://pypi.org/project/attrs/>`__ for internal
-  structures to ease code maintainability. (`#2641
-  <https://github.com/pytest-dev/pytest/issues/2641>`_)
+- pytest now depends on :pypi:`attrs` for internal
+  structures to ease code maintainability. (:issue:`2641`)
 
-- Refactored internal Python 2/3 compatibility code to use ``six``. (`#2642
-  <https://github.com/pytest-dev/pytest/issues/2642>`_)
+- Refactored internal Python 2/3 compatibility code to use ``six``. (:issue:`2642`)
 
 - Stop vendoring ``pluggy`` - we're missing out on its latest changes for not
-  much benefit (`#2719 <https://github.com/pytest-dev/pytest/issues/2719>`_)
+  much benefit (:issue:`2719`)
 
 - Internal refactor: simplify ascii string escaping by using the
-  backslashreplace error handler in newer Python 3 versions. (`#2734
-  <https://github.com/pytest-dev/pytest/issues/2734>`_)
+  backslashreplace error handler in newer Python 3 versions. (:issue:`2734`)
 
-- Remove unnecessary mark evaluator in unittest plugin (`#2767
-  <https://github.com/pytest-dev/pytest/issues/2767>`_)
+- Remove unnecessary mark evaluator in unittest plugin (:issue:`2767`)
 
 - Calls to ``Metafunc.addcall`` now emit a deprecation warning. This function
-  is scheduled to be removed in ``pytest-4.0``. (`#2876
-  <https://github.com/pytest-dev/pytest/issues/2876>`_)
+  is scheduled to be removed in ``pytest-4.0``. (:issue:`2876`)
 
 - Internal move of the parameterset extraction to a more maintainable place.
-  (`#2877 <https://github.com/pytest-dev/pytest/issues/2877>`_)
+  (:issue:`2877`)
 
-- Internal refactoring to simplify scope node lookup. (`#2910
-  <https://github.com/pytest-dev/pytest/issues/2910>`_)
+- Internal refactoring to simplify scope node lookup. (:issue:`2910`)
 
 - Configure ``pytest`` to prevent pip from installing pytest in unsupported
-  Python versions. (`#2922
-  <https://github.com/pytest-dev/pytest/issues/2922>`_)
+  Python versions. (:issue:`2922`)
 
 
 pytest 3.2.5 (2017-11-15)
@@ -4956,8 +6042,7 @@ Bug Fixes
 ---------
 
 - Remove ``py<1.5`` restriction from ``pytest`` as this can cause version
-  conflicts in some installations. (`#2926
-  <https://github.com/pytest-dev/pytest/issues/2926>`_)
+  conflicts in some installations. (:issue:`2926`)
 
 
 pytest 3.2.4 (2017-11-13)
@@ -4967,46 +6052,37 @@ Bug Fixes
 ---------
 
 - Fix the bug where running with ``--pyargs`` will result in items with
-  empty ``parent.nodeid`` if run from a different root directory. (`#2775
-  <https://github.com/pytest-dev/pytest/issues/2775>`_)
+  empty ``parent.nodeid`` if run from a different root directory. (:issue:`2775`)
 
 - Fix issue with ``@pytest.parametrize`` if argnames was specified as keyword arguments.
-  (`#2819 <https://github.com/pytest-dev/pytest/issues/2819>`_)
+  (:issue:`2819`)
 
-- Strip whitespace from marker names when reading them from INI config. (`#2856
-  <https://github.com/pytest-dev/pytest/issues/2856>`_)
+- Strip whitespace from marker names when reading them from INI config. (:issue:`2856`)
 
 - Show full context of doctest source in the pytest output, if the line number of
-  failed example in the docstring is < 9. (`#2882
-  <https://github.com/pytest-dev/pytest/issues/2882>`_)
+  failed example in the docstring is < 9. (:issue:`2882`)
 
 - Match fixture paths against actual path segments in order to avoid matching folders which share a prefix.
-  (`#2836 <https://github.com/pytest-dev/pytest/issues/2836>`_)
+  (:issue:`2836`)
 
 Improved Documentation
 ----------------------
 
-- Introduce a dedicated section about conftest.py. (`#1505
-  <https://github.com/pytest-dev/pytest/issues/1505>`_)
+- Introduce a dedicated section about conftest.py. (:issue:`1505`)
 
-- Explicitly mention ``xpass`` in the documentation of ``xfail``. (`#1997
-  <https://github.com/pytest-dev/pytest/issues/1997>`_)
+- Explicitly mention ``xpass`` in the documentation of ``xfail``. (:issue:`1997`)
 
-- Append example for pytest.param in the example/parametrize document. (`#2658
-  <https://github.com/pytest-dev/pytest/issues/2658>`_)
+- Append example for pytest.param in the example/parametrize document. (:issue:`2658`)
 
-- Clarify language of proposal for fixtures parameters (`#2893
-  <https://github.com/pytest-dev/pytest/issues/2893>`_)
+- Clarify language of proposal for fixtures parameters (:issue:`2893`)
 
 - List python 3.6 in the documented supported versions in the getting started
-  document. (`#2903 <https://github.com/pytest-dev/pytest/issues/2903>`_)
+  document. (:issue:`2903`)
 
-- Clarify the documentation of available fixture scopes. (`#538
-  <https://github.com/pytest-dev/pytest/issues/538>`_)
+- Clarify the documentation of available fixture scopes. (:issue:`538`)
 
 - Add documentation about the ``python -m pytest`` invocation adding the
-  current directory to sys.path. (`#911
-  <https://github.com/pytest-dev/pytest/issues/911>`_)
+  current directory to sys.path. (:issue:`911`)
 
 
 pytest 3.2.3 (2017-10-03)
@@ -5015,38 +6091,33 @@ pytest 3.2.3 (2017-10-03)
 Bug Fixes
 ---------
 
-- Fix crash in tab completion when no prefix is given. (`#2748
-  <https://github.com/pytest-dev/pytest/issues/2748>`_)
+- Fix crash in tab completion when no prefix is given. (:issue:`2748`)
 
 - The equality checking function (``__eq__``) of ``MarkDecorator`` returns
-  ``False`` if one object is not an instance of ``MarkDecorator``. (`#2758
-  <https://github.com/pytest-dev/pytest/issues/2758>`_)
+  ``False`` if one object is not an instance of ``MarkDecorator``. (:issue:`2758`)
 
 - When running ``pytest --fixtures-per-test``: don't crash if an item has no
-  _fixtureinfo attribute (e.g. doctests) (`#2788
-  <https://github.com/pytest-dev/pytest/issues/2788>`_)
+  _fixtureinfo attribute (e.g. doctests) (:issue:`2788`)
 
 
 Improved Documentation
 ----------------------
 
 - In help text of ``-k`` option, add example of using ``not`` to not select
-  certain tests whose names match the provided expression. (`#1442
-  <https://github.com/pytest-dev/pytest/issues/1442>`_)
+  certain tests whose names match the provided expression. (:issue:`1442`)
 
 - Add note in ``parametrize.rst`` about calling ``metafunc.parametrize``
-  multiple times. (`#1548 <https://github.com/pytest-dev/pytest/issues/1548>`_)
+  multiple times. (:issue:`1548`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - Set ``xfail_strict=True`` in pytest's own test suite to catch expected
-  failures as soon as they start to pass. (`#2722
-  <https://github.com/pytest-dev/pytest/issues/2722>`_)
+  failures as soon as they start to pass. (:issue:`2722`)
 
 - Fix typo in example of passing a callable to markers (in example/markers.rst)
-  (`#2765 <https://github.com/pytest-dev/pytest/issues/2765>`_)
+  (:issue:`2765`)
 
 
 pytest 3.2.2 (2017-09-06)
@@ -5056,17 +6127,14 @@ Bug Fixes
 ---------
 
 - Calling the deprecated ``request.getfuncargvalue()`` now shows the source of
-  the call. (`#2681 <https://github.com/pytest-dev/pytest/issues/2681>`_)
+  the call. (:issue:`2681`)
 
-- Allow tests declared as ``@staticmethod`` to use fixtures. (`#2699
-  <https://github.com/pytest-dev/pytest/issues/2699>`_)
+- Allow tests declared as ``@staticmethod`` to use fixtures. (:issue:`2699`)
 
 - Fixed edge-case during collection: attributes which raised ``pytest.fail``
-  when accessed would abort the entire collection. (`#2707
-  <https://github.com/pytest-dev/pytest/issues/2707>`_)
+  when accessed would abort the entire collection. (:issue:`2707`)
 
-- Fix ``ReprFuncArgs`` with mixed unicode and UTF-8 args. (`#2731
-  <https://github.com/pytest-dev/pytest/issues/2731>`_)
+- Fix ``ReprFuncArgs`` with mixed unicode and UTF-8 args. (:issue:`2731`)
 
 
 Improved Documentation
@@ -5074,26 +6142,23 @@ Improved Documentation
 
 - In examples on working with custom markers, add examples demonstrating the
   usage of ``pytest.mark.MARKER_NAME.with_args`` in comparison with
-  ``pytest.mark.MARKER_NAME.__call__`` (`#2604
-  <https://github.com/pytest-dev/pytest/issues/2604>`_)
+  ``pytest.mark.MARKER_NAME.__call__`` (:issue:`2604`)
 
 - In one of the simple examples, use ``pytest_collection_modifyitems()`` to skip
   tests based on a command-line option, allowing its sharing while preventing a
-  user error when acessing ``pytest.config`` before the argument parsing.
-  (`#2653 <https://github.com/pytest-dev/pytest/issues/2653>`_)
+  user error when accessing ``pytest.config`` before the argument parsing.
+  (:issue:`2653`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - Fixed minor error in 'Good Practices/Manual Integration' code snippet.
-  (`#2691 <https://github.com/pytest-dev/pytest/issues/2691>`_)
+  (:issue:`2691`)
 
-- Fixed typo in goodpractices.rst. (`#2721
-  <https://github.com/pytest-dev/pytest/issues/2721>`_)
+- Fixed typo in goodpractices.rst. (:issue:`2721`)
 
-- Improve user guidance regarding ``--resultlog`` deprecation. (`#2739
-  <https://github.com/pytest-dev/pytest/issues/2739>`_)
+- Improve user guidance regarding ``--resultlog`` deprecation. (:issue:`2739`)
 
 
 pytest 3.2.1 (2017-08-08)
@@ -5102,28 +6167,24 @@ pytest 3.2.1 (2017-08-08)
 Bug Fixes
 ---------
 
-- Fixed small terminal glitch when collecting a single test item. (`#2579
-  <https://github.com/pytest-dev/pytest/issues/2579>`_)
+- Fixed small terminal glitch when collecting a single test item. (:issue:`2579`)
 
 - Correctly consider ``/`` as the file separator to automatically mark plugin
-  files for rewrite on Windows. (`#2591 <https://github.com/pytest-
-  dev/pytest/issues/2591>`_)
+  files for rewrite on Windows. (:issue:`2591`)
 
 - Properly escape test names when setting ``PYTEST_CURRENT_TEST`` environment
-  variable. (`#2644 <https://github.com/pytest-dev/pytest/issues/2644>`_)
+  variable. (:issue:`2644`)
 
 - Fix error on Windows and Python 3.6+ when ``sys.stdout`` has been replaced
   with a stream-like object which does not implement the full ``io`` module
   buffer protocol. In particular this affects ``pytest-xdist`` users on the
-  aforementioned platform. (`#2666 <https://github.com/pytest-
-  dev/pytest/issues/2666>`_)
+  aforementioned platform. (:issue:`2666`)
 
 
 Improved Documentation
 ----------------------
 
-- Explicitly document which pytest features work with ``unittest``. (`#2626
-  <https://github.com/pytest-dev/pytest/issues/2626>`_)
+- Explicitly document which pytest features work with ``unittest``. (:issue:`2626`)
 
 
 pytest 3.2.0 (2017-07-30)
@@ -5133,163 +6194,134 @@ Deprecations and Removals
 -------------------------
 
 - ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=``
-  operators to avoid surprising/inconsistent behavior. See `the approx docs
-  <https://docs.pytest.org/en/stable/reference.html#pytest-approx>`_ for more
-  information. (`#2003 <https://github.com/pytest-dev/pytest/issues/2003>`_)
+  operators to avoid surprising/inconsistent behavior. See the :func:`~pytest.approx` docs for more
+  information. (:issue:`2003`)
 
 - All old-style specific behavior in current classes in the pytest's API is
   considered deprecated at this point and will be removed in a future release.
-  This affects Python 2 users only and in rare situations. (`#2147
-  <https://github.com/pytest-dev/pytest/issues/2147>`_)
+  This affects Python 2 users only and in rare situations. (:issue:`2147`)
 
 - A deprecation warning is now raised when using marks for parameters
   in ``pytest.mark.parametrize``. Use ``pytest.param`` to apply marks to
-  parameters instead. (`#2427 <https://github.com/pytest-dev/pytest/issues/2427>`_)
+  parameters instead. (:issue:`2427`)
 
 
 Features
 --------
 
-- Add support for numpy arrays (and dicts) to approx. (`#1994
-  <https://github.com/pytest-dev/pytest/issues/1994>`_)
+- Add support for numpy arrays (and dicts) to approx. (:issue:`1994`)
 
 - Now test function objects have a ``pytestmark`` attribute containing a list
   of marks applied directly to the test function, as opposed to marks inherited
-  from parent classes or modules. (`#2516 <https://github.com/pytest-
-  dev/pytest/issues/2516>`_)
+  from parent classes or modules. (:issue:`2516`)
 
 - Collection ignores local virtualenvs by default; ``--collect-in-virtualenv``
-  overrides this behavior. (`#2518 <https://github.com/pytest-
-  dev/pytest/issues/2518>`_)
+  overrides this behavior. (:issue:`2518`)
 
 - Allow class methods decorated as ``@staticmethod`` to be candidates for
   collection as a test function. (Only for Python 2.7 and above. Python 2.6
-  will still ignore static methods.) (`#2528 <https://github.com/pytest-
-  dev/pytest/issues/2528>`_)
+  will still ignore static methods.) (:issue:`2528`)
 
 - Introduce ``mark.with_args`` in order to allow passing functions/classes as
-  sole argument to marks. (`#2540 <https://github.com/pytest-
-  dev/pytest/issues/2540>`_)
+  sole argument to marks. (:issue:`2540`)
 
 - New ``cache_dir`` ini option: sets the directory where the contents of the
   cache plugin are stored. Directory may be relative or absolute path: if relative path, then
   directory is created relative to ``rootdir``, otherwise it is used as is.
   Additionally path may contain environment variables which are expanded during
-  runtime. (`#2543 <https://github.com/pytest-dev/pytest/issues/2543>`_)
+  runtime. (:issue:`2543`)
 
 - Introduce the ``PYTEST_CURRENT_TEST`` environment variable that is set with
   the ``nodeid`` and stage (``setup``, ``call`` and ``teardown``) of the test
-  being currently executed. See the `documentation
-  <https://docs.pytest.org/en/stable/example/simple.html#pytest-current-test-
-  environment-variable>`_ for more info. (`#2583 <https://github.com/pytest-
-  dev/pytest/issues/2583>`_)
+  being currently executed. See the :ref:`documentation <pytest current test env>`
+  for more info. (:issue:`2583`)
 
 - Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the
-  warnings filter on a per test, class or module level. See the `docs
-  <https://docs.pytest.org/en/stable/warnings.html#pytest-mark-
-  filterwarnings>`_ for more information. (`#2598 <https://github.com/pytest-
-  dev/pytest/issues/2598>`_)
+  warnings filter on a per test, class or module level. See the :ref:`docs <filterwarnings>`
+  for more information. (:issue:`2598`)
 
 - ``--last-failed`` now remembers forever when a test has failed and only
   forgets it if it passes again. This makes it easy to fix a test suite by
-  selectively running files and fixing tests incrementally. (`#2621
-  <https://github.com/pytest-dev/pytest/issues/2621>`_)
+  selectively running files and fixing tests incrementally. (:issue:`2621`)
 
 - New ``pytest_report_collectionfinish`` hook which allows plugins to add
   messages to the terminal reporting after collection has been finished
-  successfully. (`#2622 <https://github.com/pytest-dev/pytest/issues/2622>`_)
+  successfully. (:issue:`2622`)
 
-- Added support for `PEP-415's <https://www.python.org/dev/peps/pep-0415/>`_
+- Added support for :pep:`415`\'s
   ``Exception.__suppress_context__``. Now if a ``raise exception from None`` is
   caught by pytest, pytest will no longer chain the context in the test report.
-  The behavior now matches Python's traceback behavior. (`#2631
-  <https://github.com/pytest-dev/pytest/issues/2631>`_)
+  The behavior now matches Python's traceback behavior. (:issue:`2631`)
 
 - Exceptions raised by ``pytest.fail``, ``pytest.skip`` and ``pytest.xfail``
   now subclass BaseException, making them harder to be caught unintentionally
-  by normal code. (`#580 <https://github.com/pytest-dev/pytest/issues/580>`_)
+  by normal code. (:issue:`580`)
 
 
 Bug Fixes
 ---------
 
 - Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for
-  avoid unwanted interactive ``pdb`` (`#2023 <https://github.com/pytest-
-  dev/pytest/issues/2023>`_)
+  avoid unwanted interactive ``pdb`` (:issue:`2023`)
 
 - Add missing ``encoding`` attribute to ``sys.std*`` streams when using
-  ``capsys`` capture mode. (`#2375 <https://github.com/pytest-
-  dev/pytest/issues/2375>`_)
+  ``capsys`` capture mode. (:issue:`2375`)
 
 - Fix terminal color changing to black on Windows if ``colorama`` is imported
-  in a ``conftest.py`` file. (`#2510 <https://github.com/pytest-
-  dev/pytest/issues/2510>`_)
+  in a ``conftest.py`` file. (:issue:`2510`)
 
-- Fix line number when reporting summary of skipped tests. (`#2548
-  <https://github.com/pytest-dev/pytest/issues/2548>`_)
+- Fix line number when reporting summary of skipped tests. (:issue:`2548`)
 
-- capture: ensure that EncodedFile.name is a string. (`#2555
-  <https://github.com/pytest-dev/pytest/issues/2555>`_)
+- capture: ensure that EncodedFile.name is a string. (:issue:`2555`)
 
 - The options ``--fixtures`` and ``--fixtures-per-test`` will now keep
-  indentation within docstrings. (`#2574 <https://github.com/pytest-
-  dev/pytest/issues/2574>`_)
+  indentation within docstrings. (:issue:`2574`)
 
 - doctests line numbers are now reported correctly, fixing `pytest-sugar#122
-  <https://github.com/Frozenball/pytest-sugar/issues/122>`_. (`#2610
-  <https://github.com/pytest-dev/pytest/issues/2610>`_)
+  <https://github.com/Frozenball/pytest-sugar/issues/122>`_. (:issue:`2610`)
 
 - Fix non-determinism in order of fixture collection. Adds new dependency
-  (ordereddict) for Python 2.6. (`#920 <https://github.com/pytest-
-  dev/pytest/issues/920>`_)
+  (ordereddict) for Python 2.6. (:issue:`920`)
 
 
 Improved Documentation
 ----------------------
 
-- Clarify ``pytest_configure`` hook call order. (`#2539
-  <https://github.com/pytest-dev/pytest/issues/2539>`_)
+- Clarify ``pytest_configure`` hook call order. (:issue:`2539`)
 
 - Extend documentation for testing plugin code with the ``pytester`` plugin.
-  (`#971 <https://github.com/pytest-dev/pytest/issues/971>`_)
+  (:issue:`971`)
 
 
 Trivial/Internal Changes
 ------------------------
 
 - Update help message for ``--strict`` to make it clear it only deals with
-  unregistered markers, not warnings. (`#2444 <https://github.com/pytest-
-  dev/pytest/issues/2444>`_)
+  unregistered markers, not warnings. (:issue:`2444`)
 
 - Internal code move: move code for pytest.approx/pytest.raises to own files in
-  order to cut down the size of python.py (`#2489 <https://github.com/pytest-
-  dev/pytest/issues/2489>`_)
+  order to cut down the size of python.py (:issue:`2489`)
 
 - Renamed the utility function ``_pytest.compat._escape_strings`` to
-  ``_ascii_escaped`` to better communicate the function's purpose. (`#2533
-  <https://github.com/pytest-dev/pytest/issues/2533>`_)
+  ``_ascii_escaped`` to better communicate the function's purpose. (:issue:`2533`)
 
-- Improve error message for CollectError with skip/skipif. (`#2546
-  <https://github.com/pytest-dev/pytest/issues/2546>`_)
+- Improve error message for CollectError with skip/skipif. (:issue:`2546`)
 
 - Emit warning about ``yield`` tests being deprecated only once per generator.
-  (`#2562 <https://github.com/pytest-dev/pytest/issues/2562>`_)
+  (:issue:`2562`)
 
 - Ensure final collected line doesn't include artifacts of previous write.
-  (`#2571 <https://github.com/pytest-dev/pytest/issues/2571>`_)
+  (:issue:`2571`)
 
-- Fixed all flake8 errors and warnings. (`#2581 <https://github.com/pytest-
-  dev/pytest/issues/2581>`_)
+- Fixed all flake8 errors and warnings. (:issue:`2581`)
 
 - Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code.
-  (`#2582 <https://github.com/pytest-dev/pytest/issues/2582>`_)
+  (:issue:`2582`)
 
 - Turn warnings into errors in pytest's own test suite in order to catch
-  regressions due to deprecations more promptly. (`#2588
-  <https://github.com/pytest-dev/pytest/issues/2588>`_)
+  regressions due to deprecations more promptly. (:issue:`2588`)
 
-- Show multiple issue links in CHANGELOG entries. (`#2620
-  <https://github.com/pytest-dev/pytest/issues/2620>`_)
+- Show multiple issue links in CHANGELOG entries. (:issue:`2620`)
 
 
 pytest 3.1.3 (2017-07-03)
@@ -5298,44 +6330,40 @@ pytest 3.1.3 (2017-07-03)
 Bug Fixes
 ---------
 
-- Fix decode error in Python 2 for doctests in docstrings. (`#2434
-  <https://github.com/pytest-dev/pytest/issues/2434>`_)
+- Fix decode error in Python 2 for doctests in docstrings. (:issue:`2434`)
 
 - Exceptions raised during teardown by finalizers are now suppressed until all
-  finalizers are called, with the initial exception reraised. (`#2440
-  <https://github.com/pytest-dev/pytest/issues/2440>`_)
+  finalizers are called, with the initial exception reraised. (:issue:`2440`)
 
 - Fix incorrect "collected items" report when specifying tests on the command-
-  line. (`#2464 <https://github.com/pytest-dev/pytest/issues/2464>`_)
+  line. (:issue:`2464`)
 
 - ``deprecated_call`` in context-manager form now captures deprecation warnings
   even if the same warning has already been raised. Also, ``deprecated_call``
   will always produce the same error message (previously it would produce
-  different messages in context-manager vs. function-call mode). (`#2469
-  <https://github.com/pytest-dev/pytest/issues/2469>`_)
+  different messages in context-manager vs. function-call mode). (:issue:`2469`)
 
 - Fix issue where paths collected by pytest could have triple leading ``/``
-  characters. (`#2475 <https://github.com/pytest-dev/pytest/issues/2475>`_)
+  characters. (:issue:`2475`)
 
 - Fix internal error when trying to detect the start of a recursive traceback.
-  (`#2486 <https://github.com/pytest-dev/pytest/issues/2486>`_)
+  (:issue:`2486`)
 
 
 Improved Documentation
 ----------------------
 
 - Explicitly state for which hooks the calls stop after the first non-None
-  result. (`#2493 <https://github.com/pytest-dev/pytest/issues/2493>`_)
+  result. (:issue:`2493`)
 
 
 Trivial/Internal Changes
 ------------------------
 
-- Create invoke tasks for updating the vendored packages. (`#2474
-  <https://github.com/pytest-dev/pytest/issues/2474>`_)
+- Create invoke tasks for updating the vendored packages. (:issue:`2474`)
 
 - Update copyright dates in LICENSE, README.rst and in the documentation.
-  (`#2499 <https://github.com/pytest-dev/pytest/issues/2499>`_)
+  (:issue:`2499`)
 
 
 pytest 3.1.2 (2017-06-08)
@@ -5416,24 +6444,24 @@ New Features
       [pytest]
       addopts = -p no:warnings
 
-    See the `warnings documentation page <https://docs.pytest.org/en/stable/warnings.html>`_ for more
+    See the :doc:`warnings documentation page <how-to/capture-warnings>` for more
     information.
 
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
-* Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (`#533`_).
+* Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (:issue:`533`).
 
 * Added an ini option ``doctest_encoding`` to specify which encoding to use for doctest files.
-  Thanks `@wheerd`_ for the PR (`#2101`_).
+  Thanks :user:`wheerd` for the PR (:pull:`2101`).
 
 * ``pytest.warns`` now checks for subclass relationship rather than
-  class equality. Thanks `@lesteve`_ for the PR (`#2166`_)
+  class equality. Thanks :user:`lesteve` for the PR (:pull:`2166`)
 
 * ``pytest.raises`` now asserts that the error message matches a text or regex
-  with the ``match`` keyword argument. Thanks `@Kriechi`_ for the PR.
+  with the ``match`` keyword argument. Thanks :user:`Kriechi` for the PR.
 
 * ``pytest.param`` can be used to declare test parameter sets with marks and test ids.
-  Thanks `@RonnyPfannschmidt`_ for the PR.
+  Thanks :user:`RonnyPfannschmidt` for the PR.
 
 
 Changes
@@ -5441,127 +6469,87 @@ Changes
 
 * remove all internal uses of pytest_namespace hooks,
   this is to prepare the removal of preloadconfig in pytest 4.0
-  Thanks to `@RonnyPfannschmidt`_ for the PR.
+  Thanks to :user:`RonnyPfannschmidt` for the PR.
 
-* pytest now warns when a callable ids raises in a parametrized test. Thanks `@fogo`_ for the PR.
+* pytest now warns when a callable ids raises in a parametrized test. Thanks :user:`fogo` for the PR.
 
 * It is now possible to skip test classes from being collected by setting a
-  ``__test__`` attribute to ``False`` in the class body (`#2007`_). Thanks
-  to `@syre`_ for the report and `@lwm`_ for the PR.
+  ``__test__`` attribute to ``False`` in the class body (:issue:`2007`). Thanks
+  to :user:`syre` for the report and :user:`lwm` for the PR.
 
 * Change junitxml.py to produce reports that comply with Junitxml schema.
   If the same test fails with failure in call and then errors in teardown
   we split testcase element into two, one containing the error and the other
-  the failure. (`#2228`_) Thanks to `@kkoukiou`_ for the PR.
+  the failure. (:issue:`2228`) Thanks to :user:`kkoukiou` for the PR.
 
 * Testcase reports with a ``url`` attribute will now properly write this to junitxml.
-  Thanks `@fushi`_ for the PR (`#1874`_).
+  Thanks :user:`fushi` for the PR (:pull:`1874`).
 
 * Remove common items from dict comparison output when verbosity=1. Also update
   the truncation message to make it clearer that pytest truncates all
-  assertion messages if verbosity < 2 (`#1512`_).
-  Thanks `@mattduck`_ for the PR
+  assertion messages if verbosity < 2 (:issue:`1512`).
+  Thanks :user:`mattduck` for the PR
 
 * ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use
-  ``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks `@davidszotten`_ for
-  the PR (`#1952`_).
+  ``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for
+  the PR (:pull:`1952`).
 
-* fix `#2013`_: turn RecordedWarning into ``namedtuple``,
+* fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
   to give it a comprehensible repr while preventing unwarranted modification.
 
-* fix `#2208`_: ensure an iteration limit for _pytest.compat.get_real_func.
-  Thanks `@RonnyPfannschmidt`_ for the report and PR.
+* fix :issue:`2208`: ensure an iteration limit for _pytest.compat.get_real_func.
+  Thanks :user:`RonnyPfannschmidt` for the report and PR.
 
 * Hooks are now verified after collection is complete, rather than right after loading installed plugins. This
   makes it easy to write hooks for plugins which will be loaded during collection, for example using the
-  ``pytest_plugins`` special variable (`#1821`_).
-  Thanks `@nicoddemus`_ for the PR.
+  ``pytest_plugins`` special variable (:issue:`1821`).
+  Thanks :user:`nicoddemus` for the PR.
 
 * Modify ``pytest_make_parametrize_id()`` hook to accept ``argname`` as an
   additional parameter.
-  Thanks `@unsignedint`_ for the PR.
+  Thanks :user:`unsignedint` for the PR.
 
 * Add ``venv`` to the default ``norecursedirs`` setting.
-  Thanks `@The-Compiler`_ for the PR.
+  Thanks :user:`The-Compiler` for the PR.
 
 * ``PluginManager.import_plugin`` now accepts unicode plugin names in Python 2.
-  Thanks `@reutsharabani`_ for the PR.
+  Thanks :user:`reutsharabani` for the PR.
 
-* fix `#2308`_: When using both ``--lf`` and ``--ff``, only the last failed tests are run.
-  Thanks `@ojii`_ for the PR.
+* fix :issue:`2308`: When using both ``--lf`` and ``--ff``, only the last failed tests are run.
+  Thanks :user:`ojii` for the PR.
 
 * Replace minor/patch level version numbers in the documentation with placeholders.
-  This significantly reduces change-noise as different contributors regnerate
+  This significantly reduces change-noise as different contributors regenerate
   the documentation on different platforms.
-  Thanks `@RonnyPfannschmidt`_ for the PR.
+  Thanks :user:`RonnyPfannschmidt` for the PR.
 
-* fix `#2391`_: consider pytest_plugins on all plugin modules
-  Thanks `@RonnyPfannschmidt`_ for the PR.
+* fix :issue:`2391`: consider pytest_plugins on all plugin modules
+  Thanks :user:`RonnyPfannschmidt` for the PR.
 
 
 Bug Fixes
 ---------
 
 * Fix ``AttributeError`` on ``sys.stdout.buffer`` / ``sys.stderr.buffer``
-  while using ``capsys`` fixture in python 3. (`#1407`_).
-  Thanks to `@asottile`_.
+  while using ``capsys`` fixture in python 3. (:issue:`1407`).
+  Thanks to :user:`asottile`.
 
 * Change capture.py's ``DontReadFromInput`` class to throw ``io.UnsupportedOperation`` errors rather
-  than ValueErrors in the ``fileno`` method (`#2276`_).
-  Thanks `@metasyn`_ and `@vlad-dragos`_ for the PR.
+  than ValueErrors in the ``fileno`` method (:issue:`2276`).
+  Thanks :user:`metasyn` and :user:`vlad-dragos` for the PR.
 
 * Fix exception formatting while importing modules when the exception message
-  contains non-ascii characters (`#2336`_).
-  Thanks `@fabioz`_ for the report and `@nicoddemus`_ for the PR.
-
-* Added documentation related to issue (`#1937`_)
-  Thanks `@skylarjhdownes`_ for the PR.
-
-* Allow collecting files with any file extension as Python modules (`#2369`_).
-  Thanks `@Kodiologist`_ for the PR.
-
-* Show the correct error message when collect "parametrize" func with wrong args (`#2383`_).
-  Thanks `@The-Compiler`_ for the report and `@robin0371`_ for the PR.
-
-
-.. _@davidszotten: https://github.com/davidszotten
-.. _@fabioz: https://github.com/fabioz
-.. _@fogo: https://github.com/fogo
-.. _@fushi: https://github.com/fushi
-.. _@Kodiologist: https://github.com/Kodiologist
-.. _@Kriechi: https://github.com/Kriechi
-.. _@mandeep: https://github.com/mandeep
-.. _@mattduck: https://github.com/mattduck
-.. _@metasyn: https://github.com/metasyn
-.. _@MichalTHEDUDE: https://github.com/MichalTHEDUDE
-.. _@ojii: https://github.com/ojii
-.. _@reutsharabani: https://github.com/reutsharabani
-.. _@robin0371: https://github.com/robin0371
-.. _@skylarjhdownes: https://github.com/skylarjhdownes
-.. _@unsignedint: https://github.com/unsignedint
-.. _@wheerd: https://github.com/wheerd
-
-
-.. _#1407: https://github.com/pytest-dev/pytest/issues/1407
-.. _#1512: https://github.com/pytest-dev/pytest/issues/1512
-.. _#1821: https://github.com/pytest-dev/pytest/issues/1821
-.. _#1874: https://github.com/pytest-dev/pytest/pull/1874
-.. _#1937: https://github.com/pytest-dev/pytest/issues/1937
-.. _#1952: https://github.com/pytest-dev/pytest/pull/1952
-.. _#2007: https://github.com/pytest-dev/pytest/issues/2007
-.. _#2013: https://github.com/pytest-dev/pytest/issues/2013
-.. _#2101: https://github.com/pytest-dev/pytest/pull/2101
-.. _#2166: https://github.com/pytest-dev/pytest/pull/2166
-.. _#2208: https://github.com/pytest-dev/pytest/issues/2208
-.. _#2228: https://github.com/pytest-dev/pytest/issues/2228
-.. _#2276: https://github.com/pytest-dev/pytest/issues/2276
-.. _#2308: https://github.com/pytest-dev/pytest/issues/2308
-.. _#2336: https://github.com/pytest-dev/pytest/issues/2336
-.. _#2369: https://github.com/pytest-dev/pytest/issues/2369
-.. _#2383: https://github.com/pytest-dev/pytest/issues/2383
-.. _#2391: https://github.com/pytest-dev/pytest/issues/2391
-.. _#533: https://github.com/pytest-dev/pytest/issues/533
+  contains non-ascii characters (:issue:`2336`).
+  Thanks :user:`fabioz` for the report and :user:`nicoddemus` for the PR.
+
+* Added documentation related to issue (:issue:`1937`)
+  Thanks :user:`skylarjhdownes` for the PR.
 
+* Allow collecting files with any file extension as Python modules (:issue:`2369`).
+  Thanks :user:`Kodiologist` for the PR.
+
+* Show the correct error message when collect "parametrize" func with wrong args (:issue:`2383`).
+  Thanks :user:`The-Compiler` for the report and :user:`robin0371` for the PR.
 
 
 3.0.7 (2017-03-14)
@@ -5570,334 +6558,224 @@ Bug Fixes
 
 * Fix issue in assertion rewriting breaking due to modules silently discarding
   other modules when importing fails
-  Notably, importing the ``anydbm`` module is fixed. (`#2248`_).
-  Thanks `@pfhayes`_ for the PR.
+  Notably, importing the ``anydbm`` module is fixed. (:issue:`2248`).
+  Thanks :user:`pfhayes` for the PR.
 
 * junitxml: Fix problematic case where system-out tag occurred twice per testcase
-  element in the XML report. Thanks `@kkoukiou`_ for the PR.
+  element in the XML report. Thanks :user:`kkoukiou` for the PR.
 
 * Fix regression, pytest now skips unittest correctly if run with ``--pdb``
-  (`#2137`_). Thanks to `@gst`_ for the report and `@mbyt`_ for the PR.
+  (:issue:`2137`). Thanks to :user:`gst` for the report and :user:`mbyt` for the PR.
 
-* Ignore exceptions raised from descriptors (e.g. properties) during Python test collection (`#2234`_).
-  Thanks to `@bluetech`_.
+* Ignore exceptions raised from descriptors (e.g. properties) during Python test collection (:issue:`2234`).
+  Thanks to :user:`bluetech`.
 
-* ``--override-ini`` now correctly overrides some fundamental options like ``python_files`` (`#2238`_).
-  Thanks `@sirex`_ for the report and `@nicoddemus`_ for the PR.
+* ``--override-ini`` now correctly overrides some fundamental options like ``python_files`` (:issue:`2238`).
+  Thanks :user:`sirex` for the report and :user:`nicoddemus` for the PR.
 
-* Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to `PEP-479`_ (`#2160`_).
-  Thanks to `@nicoddemus`_ for the PR.
+* Replace ``raise StopIteration`` usages in the code by simple ``returns`` to finish generators, in accordance to :pep:`479` (:issue:`2160`).
+  Thanks to :user:`nicoddemus` for the PR.
 
 * Fix internal errors when an unprintable ``AssertionError`` is raised inside a test.
-  Thanks `@omerhadari`_ for the PR.
+  Thanks :user:`omerhadari` for the PR.
 
-* Skipping plugin now also works with test items generated by custom collectors (`#2231`_).
-  Thanks to `@vidartf`_.
+* Skipping plugin now also works with test items generated by custom collectors (:issue:`2231`).
+  Thanks to :user:`vidartf`.
 
-* Fix trailing whitespace in console output if no .ini file presented (`#2281`_). Thanks `@fbjorn`_ for the PR.
+* Fix trailing whitespace in console output if no .ini file presented (:issue:`2281`). Thanks :user:`fbjorn` for the PR.
 
 * Conditionless ``xfail`` markers no longer rely on the underlying test item
   being an instance of ``PyobjMixin``, and can therefore apply to tests not
-  collected by the built-in python test collector. Thanks `@barneygale`_ for the
+  collected by the built-in python test collector. Thanks :user:`barneygale` for the
   PR.
 
 
-.. _@pfhayes: https://github.com/pfhayes
-.. _@bluetech: https://github.com/bluetech
-.. _@gst: https://github.com/gst
-.. _@sirex: https://github.com/sirex
-.. _@vidartf: https://github.com/vidartf
-.. _@kkoukiou: https://github.com/KKoukiou
-.. _@omerhadari: https://github.com/omerhadari
-.. _@fbjorn: https://github.com/fbjorn
-
-.. _#2248: https://github.com/pytest-dev/pytest/issues/2248
-.. _#2137: https://github.com/pytest-dev/pytest/issues/2137
-.. _#2160: https://github.com/pytest-dev/pytest/issues/2160
-.. _#2231: https://github.com/pytest-dev/pytest/issues/2231
-.. _#2234: https://github.com/pytest-dev/pytest/issues/2234
-.. _#2238: https://github.com/pytest-dev/pytest/issues/2238
-.. _#2281: https://github.com/pytest-dev/pytest/issues/2281
-
-.. _PEP-479: https://www.python.org/dev/peps/pep-0479/
-
-
 3.0.6 (2017-01-22)
 ==================
 
-* pytest no longer generates ``PendingDeprecationWarning`` from its own operations, which was introduced by mistake in version ``3.0.5`` (`#2118`_).
-  Thanks to `@nicoddemus`_ for the report and `@RonnyPfannschmidt`_ for the PR.
+* pytest no longer generates ``PendingDeprecationWarning`` from its own operations, which was introduced by mistake in version ``3.0.5`` (:issue:`2118`).
+  Thanks to :user:`nicoddemus` for the report and :user:`RonnyPfannschmidt` for the PR.
 
 
-* pytest no longer recognizes coroutine functions as yield tests (`#2129`_).
-  Thanks to `@malinoff`_ for the PR.
+* pytest no longer recognizes coroutine functions as yield tests (:issue:`2129`).
+  Thanks to :user:`malinoff` for the PR.
 
 * Plugins loaded by the ``PYTEST_PLUGINS`` environment variable are now automatically
-  considered for assertion rewriting (`#2185`_).
-  Thanks `@nicoddemus`_ for the PR.
+  considered for assertion rewriting (:issue:`2185`).
+  Thanks :user:`nicoddemus` for the PR.
 
-* Improve error message when pytest.warns fails (`#2150`_). The type(s) of the
+* Improve error message when pytest.warns fails (:issue:`2150`). The type(s) of the
   expected warnings and the list of caught warnings is added to the
-  error message. Thanks `@lesteve`_ for the PR.
+  error message. Thanks :user:`lesteve` for the PR.
 
 * Fix ``pytester`` internal plugin to work correctly with latest versions of
-  ``zope.interface`` (`#1989`_). Thanks `@nicoddemus`_ for the PR.
+  ``zope.interface`` (:issue:`1989`). Thanks :user:`nicoddemus` for the PR.
 
-* Assert statements of the ``pytester`` plugin again benefit from assertion rewriting (`#1920`_).
-  Thanks `@RonnyPfannschmidt`_ for the report and `@nicoddemus`_ for the PR.
+* Assert statements of the ``pytester`` plugin again benefit from assertion rewriting (:issue:`1920`).
+  Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR.
 
 * Specifying tests with colons like ``test_foo.py::test_bar`` for tests in
   subdirectories with ini configuration files now uses the correct ini file
-  (`#2148`_).  Thanks `@pelme`_.
+  (:issue:`2148`).  Thanks :user:`pelme`.
 
 * Fail ``testdir.runpytest().assert_outcomes()`` explicitly if the pytest
-  terminal output it relies on is missing. Thanks to `@eli-b`_ for the PR.
-
-
-.. _@barneygale: https://github.com/barneygale
-.. _@lesteve: https://github.com/lesteve
-.. _@malinoff: https://github.com/malinoff
-.. _@pelme: https://github.com/pelme
-.. _@eli-b: https://github.com/eli-b
-
-.. _#2118: https://github.com/pytest-dev/pytest/issues/2118
-
-.. _#1989: https://github.com/pytest-dev/pytest/issues/1989
-.. _#1920: https://github.com/pytest-dev/pytest/issues/1920
-.. _#2129: https://github.com/pytest-dev/pytest/issues/2129
-.. _#2148: https://github.com/pytest-dev/pytest/issues/2148
-.. _#2150: https://github.com/pytest-dev/pytest/issues/2150
-.. _#2185: https://github.com/pytest-dev/pytest/issues/2185
+  terminal output it relies on is missing. Thanks to :user:`eli-b` for the PR.
 
 
 3.0.5 (2016-12-05)
 ==================
 
-* Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (`#2105`_).
-  Also improved the help documentation. Thanks to `@mbukatov`_ for the report and
-  `@lwm`_ for the PR.
+* Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (:issue:`2105`).
+  Also improved the help documentation. Thanks to :user:`mbukatov` for the report and
+  :user:`lwm` for the PR.
 
 * Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories
-  and filenames, respectively (`#2089`_ and `#2078`_). Thanks to `@lwm`_ for the PR.
+  and filenames, respectively (:issue:`2089` and :issue:`2078`). Thanks to :user:`lwm` for the PR.
 
-* Add hint to error message hinting possible missing ``__init__.py`` (`#478`_). Thanks `@DuncanBetts`_.
+* Add hint to error message hinting possible missing ``__init__.py`` (:issue:`478`). Thanks :user:`DuncanBetts`.
 
-* More accurately describe when fixture finalization occurs in documentation (`#687`_). Thanks `@DuncanBetts`_.
+* More accurately describe when fixture finalization occurs in documentation (:issue:`687`). Thanks :user:`DuncanBetts`.
 
 * Provide ``:ref:`` targets for ``recwarn.rst`` so we can use intersphinx referencing.
-  Thanks to `@dupuy`_ for the report and `@lwm`_ for the PR.
+  Thanks to :user:`dupuy` for the report and :user:`lwm` for the PR.
 
 * In Python 2, use a simple ``+-`` ASCII string in the string representation of ``pytest.approx`` (for example ``"4 +- 4.0e-06"``)
   because it is brittle to handle that in different contexts and representations internally in pytest
-  which can result in bugs such as `#2111`_. In Python 3, the representation still uses ``±`` (for example ``4 ± 4.0e-06``).
-  Thanks `@kerrick-lyft`_ for the report and `@nicoddemus`_ for the PR.
+  which can result in bugs such as :issue:`2111`. In Python 3, the representation still uses ``±`` (for example ``4 ± 4.0e-06``).
+  Thanks :user:`kerrick-lyft` for the report and :user:`nicoddemus` for the PR.
 
 * Using ``item.Function``, ``item.Module``, etc., is now issuing deprecation warnings, prefer
-  ``pytest.Function``, ``pytest.Module``, etc., instead (`#2034`_).
-  Thanks `@nmundar`_ for the PR.
+  ``pytest.Function``, ``pytest.Module``, etc., instead (:issue:`2034`).
+  Thanks :user:`nmundar` for the PR.
 
-* Fix error message using ``approx`` with complex numbers (`#2082`_).
-  Thanks `@adler-j`_ for the report and `@nicoddemus`_ for the PR.
+* Fix error message using ``approx`` with complex numbers (:issue:`2082`).
+  Thanks :user:`adler-j` for the report and :user:`nicoddemus` for the PR.
 
 * Fixed false-positives warnings from assertion rewrite hook for modules imported more than
   once by the ``pytest_plugins`` mechanism.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * Remove an internal cache which could cause hooks from ``conftest.py`` files in
-  sub-directories to be called in other directories incorrectly (`#2016`_).
-  Thanks `@d-b-w`_ for the report and `@nicoddemus`_ for the PR.
+  sub-directories to be called in other directories incorrectly (:issue:`2016`).
+  Thanks :user:`d-b-w` for the report and :user:`nicoddemus` for the PR.
 
 * Remove internal code meant to support earlier Python 3 versions that produced the side effect
   of leaving ``None`` in ``sys.modules`` when expressions were evaluated by pytest (for example passing a condition
-  as a string to ``pytest.mark.skipif``)(`#2103`_).
-  Thanks `@jaraco`_ for the report and `@nicoddemus`_ for the PR.
-
-* Cope gracefully with a .pyc file with no matching .py file (`#2038`_). Thanks
-  `@nedbat`_.
-
-.. _@syre: https://github.com/syre
-.. _@adler-j: https://github.com/adler-j
-.. _@d-b-w: https://github.com/d-b-w
-.. _@DuncanBetts: https://github.com/DuncanBetts
-.. _@dupuy: https://bitbucket.org/dupuy/
-.. _@kerrick-lyft: https://github.com/kerrick-lyft
-.. _@lwm: https://github.com/lwm
-.. _@mbukatov: https://github.com/mbukatov
-.. _@nedbat: https://github.com/nedbat
-.. _@nmundar: https://github.com/nmundar
-
-.. _#2016: https://github.com/pytest-dev/pytest/issues/2016
-.. _#2034: https://github.com/pytest-dev/pytest/issues/2034
-.. _#2038: https://github.com/pytest-dev/pytest/issues/2038
-.. _#2078: https://github.com/pytest-dev/pytest/issues/2078
-.. _#2082: https://github.com/pytest-dev/pytest/issues/2082
-.. _#2089: https://github.com/pytest-dev/pytest/issues/2089
-.. _#2103: https://github.com/pytest-dev/pytest/issues/2103
-.. _#2105: https://github.com/pytest-dev/pytest/issues/2105
-.. _#2111: https://github.com/pytest-dev/pytest/issues/2111
-.. _#478: https://github.com/pytest-dev/pytest/issues/478
-.. _#687: https://github.com/pytest-dev/pytest/issues/687
+  as a string to ``pytest.mark.skipif``)(:issue:`2103`).
+  Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR.
+
+* Cope gracefully with a .pyc file with no matching .py file (:issue:`2038`). Thanks
+  :user:`nedbat`.
 
 
 3.0.4 (2016-11-09)
 ==================
 
-* Import errors when collecting test modules now display the full traceback (`#1976`_).
-  Thanks `@cwitty`_ for the report and `@nicoddemus`_ for the PR.
+* Import errors when collecting test modules now display the full traceback (:issue:`1976`).
+  Thanks :user:`cwitty` for the report and :user:`nicoddemus` for the PR.
 
-* Fix confusing command-line help message for custom options with two or more ``metavar`` properties (`#2004`_).
-  Thanks `@okulynyak`_ and `@davehunt`_ for the report and `@nicoddemus`_ for the PR.
+* Fix confusing command-line help message for custom options with two or more ``metavar`` properties (:issue:`2004`).
+  Thanks :user:`okulynyak` and :user:`davehunt` for the report and :user:`nicoddemus` for the PR.
 
-* When loading plugins, import errors which contain non-ascii messages are now properly handled in Python 2 (`#1998`_).
-  Thanks `@nicoddemus`_ for the PR.
+* When loading plugins, import errors which contain non-ascii messages are now properly handled in Python 2 (:issue:`1998`).
+  Thanks :user:`nicoddemus` for the PR.
 
-* Fixed cyclic reference when ``pytest.raises`` is used in context-manager form (`#1965`_). Also as a
+* Fixed cyclic reference when ``pytest.raises`` is used in context-manager form (:issue:`1965`). Also as a
   result of this fix, ``sys.exc_info()`` is left empty in both context-manager and function call usages.
   Previously, ``sys.exc_info`` would contain the exception caught by the context manager,
   even when the expected exception occurred.
-  Thanks `@MSeifert04`_ for the report and the PR.
+  Thanks :user:`MSeifert04` for the report and the PR.
 
 * Fixed false-positives warnings from assertion rewrite hook for modules that were rewritten but
   were later marked explicitly by ``pytest.register_assert_rewrite``
-  or implicitly as a plugin (`#2005`_).
-  Thanks `@RonnyPfannschmidt`_ for the report and `@nicoddemus`_ for the PR.
+  or implicitly as a plugin (:issue:`2005`).
+  Thanks :user:`RonnyPfannschmidt` for the report and :user:`nicoddemus` for the PR.
 
-* Report teardown output on test failure (`#442`_).
-  Thanks `@matclab`_ for the PR.
+* Report teardown output on test failure (:issue:`442`).
+  Thanks :user:`matclab` for the PR.
 
 * Fix teardown error message in generated xUnit XML.
-  Thanks `@gdyuldin`_ for the PR.
+  Thanks :user:`gdyuldin` for the PR.
 
-* Properly handle exceptions in ``multiprocessing`` tasks (`#1984`_).
-  Thanks `@adborden`_ for the report and `@nicoddemus`_ for the PR.
+* Properly handle exceptions in ``multiprocessing`` tasks (:issue:`1984`).
+  Thanks :user:`adborden` for the report and :user:`nicoddemus` for the PR.
 
-* Clean up unittest TestCase objects after tests are complete (`#1649`_).
-  Thanks `@d_b_w`_ for the report and PR.
-
-
-.. _@adborden: https://github.com/adborden
-.. _@cwitty: https://github.com/cwitty
-.. _@d_b_w: https://github.com/d-b-w
-.. _@gdyuldin: https://github.com/gdyuldin
-.. _@matclab: https://github.com/matclab
-.. _@MSeifert04: https://github.com/MSeifert04
-.. _@okulynyak: https://github.com/okulynyak
-
-.. _#442: https://github.com/pytest-dev/pytest/issues/442
-.. _#1965: https://github.com/pytest-dev/pytest/issues/1965
-.. _#1976: https://github.com/pytest-dev/pytest/issues/1976
-.. _#1984: https://github.com/pytest-dev/pytest/issues/1984
-.. _#1998: https://github.com/pytest-dev/pytest/issues/1998
-.. _#2004: https://github.com/pytest-dev/pytest/issues/2004
-.. _#2005: https://github.com/pytest-dev/pytest/issues/2005
-.. _#1649: https://github.com/pytest-dev/pytest/issues/1649
+* Clean up unittest TestCase objects after tests are complete (:issue:`1649`).
+  Thanks :user:`d-b-w` for the report and PR.
 
 
 3.0.3 (2016-09-28)
 ==================
 
 * The ``ids`` argument to ``parametrize`` again accepts ``unicode`` strings
-  in Python 2 (`#1905`_).
-  Thanks `@philpep`_ for the report and `@nicoddemus`_ for the PR.
+  in Python 2 (:issue:`1905`).
+  Thanks :user:`philpep` for the report and :user:`nicoddemus` for the PR.
 
 * Assertions are now being rewritten for plugins in development mode
-  (``pip install -e``) (`#1934`_).
-  Thanks `@nicoddemus`_ for the PR.
+  (``pip install -e``) (:issue:`1934`).
+  Thanks :user:`nicoddemus` for the PR.
 
-* Fix pkg_resources import error in Jython projects (`#1853`_).
-  Thanks `@raquel-ucl`_ for the PR.
+* Fix pkg_resources import error in Jython projects (:issue:`1853`).
+  Thanks :user:`raquelalegre` for the PR.
 
 * Got rid of ``AttributeError: 'Module' object has no attribute '_obj'`` exception
-  in Python 3 (`#1944`_).
-  Thanks `@axil`_ for the PR.
+  in Python 3 (:issue:`1944`).
+  Thanks :user:`axil` for the PR.
 
 * Explain a bad scope value passed to ``@fixture`` declarations or
   a ``MetaFunc.parametrize()`` call.
 
 * This version includes ``pluggy-0.4.0``, which correctly handles
-  ``VersionConflict`` errors in plugins (`#704`_).
-  Thanks `@nicoddemus`_ for the PR.
-
-
-.. _@philpep: https://github.com/philpep
-.. _@raquel-ucl: https://github.com/raquel-ucl
-.. _@axil: https://github.com/axil
-.. _@vlad-dragos: https://github.com/vlad-dragos
-
-.. _#1853: https://github.com/pytest-dev/pytest/issues/1853
-.. _#1905: https://github.com/pytest-dev/pytest/issues/1905
-.. _#1934: https://github.com/pytest-dev/pytest/issues/1934
-.. _#1944: https://github.com/pytest-dev/pytest/issues/1944
-.. _#704: https://github.com/pytest-dev/pytest/issues/704
-
-
+  ``VersionConflict`` errors in plugins (:issue:`704`).
+  Thanks :user:`nicoddemus` for the PR.
 
 
 3.0.2 (2016-09-01)
 ==================
 
-* Improve error message when passing non-string ids to ``pytest.mark.parametrize`` (`#1857`_).
-  Thanks `@okken`_ for the report and `@nicoddemus`_ for the PR.
+* Improve error message when passing non-string ids to ``pytest.mark.parametrize`` (:issue:`1857`).
+  Thanks :user:`okken` for the report and :user:`nicoddemus` for the PR.
 
 * Add ``buffer`` attribute to stdin stub class ``pytest.capture.DontReadFromInput``
-  Thanks `@joguSD`_ for the PR.
+  Thanks :user:`joguSD` for the PR.
 
-* Fix ``UnicodeEncodeError`` when string comparison with unicode has failed. (`#1864`_)
-  Thanks `@AiOO`_ for the PR.
+* Fix ``UnicodeEncodeError`` when string comparison with unicode has failed. (:issue:`1864`)
+  Thanks :user:`AiOO` for the PR.
 
 * ``pytest_plugins`` is now handled correctly if defined as a string (as opposed as
   a sequence of strings) when modules are considered for assertion rewriting.
   Due to this bug, much more modules were being rewritten than necessary
-  if a test suite uses ``pytest_plugins`` to load internal plugins (`#1888`_).
-  Thanks `@jaraco`_ for the report and `@nicoddemus`_ for the PR (`#1891`_).
+  if a test suite uses ``pytest_plugins`` to load internal plugins (:issue:`1888`).
+  Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR (:pull:`1891`).
 
 * Do not call tearDown and cleanups when running tests from
   ``unittest.TestCase`` subclasses with ``--pdb``
   enabled. This allows proper post mortem debugging for all applications
-  which have significant logic in their tearDown machinery (`#1890`_). Thanks
-  `@mbyt`_ for the PR.
+  which have significant logic in their tearDown machinery (:issue:`1890`). Thanks
+  :user:`mbyt` for the PR.
 
 * Fix use of deprecated ``getfuncargvalue`` method in the internal doctest plugin.
-  Thanks `@ViviCoder`_ for the report (`#1898`_).
-
-.. _@joguSD: https://github.com/joguSD
-.. _@AiOO: https://github.com/AiOO
-.. _@mbyt: https://github.com/mbyt
-.. _@ViviCoder: https://github.com/ViviCoder
-
-.. _#1857: https://github.com/pytest-dev/pytest/issues/1857
-.. _#1864: https://github.com/pytest-dev/pytest/issues/1864
-.. _#1888: https://github.com/pytest-dev/pytest/issues/1888
-.. _#1891: https://github.com/pytest-dev/pytest/pull/1891
-.. _#1890: https://github.com/pytest-dev/pytest/issues/1890
-.. _#1898: https://github.com/pytest-dev/pytest/issues/1898
+  Thanks :user:`ViviCoder` for the report (:issue:`1898`).
 
 
 3.0.1 (2016-08-23)
 ==================
 
-* Fix regression when ``importorskip`` is used at module level (`#1822`_).
-  Thanks `@jaraco`_ and `@The-Compiler`_ for the report and `@nicoddemus`_ for the PR.
+* Fix regression when ``importorskip`` is used at module level (:issue:`1822`).
+  Thanks :user:`jaraco` and :user:`The-Compiler` for the report and :user:`nicoddemus` for the PR.
 
 * Fix parametrization scope when session fixtures are used in conjunction
-  with normal parameters in the same call (`#1832`_).
-  Thanks `@The-Compiler`_ for the report, `@Kingdread`_ and `@nicoddemus`_ for the PR.
+  with normal parameters in the same call (:issue:`1832`).
+  Thanks :user:`The-Compiler` for the report, :user:`Kingdread` and :user:`nicoddemus` for the PR.
 
-* Fix internal error when parametrizing tests or fixtures using an empty ``ids`` argument (`#1849`_).
-  Thanks `@OPpuolitaival`_ for the report and `@nicoddemus`_ for the PR.
+* Fix internal error when parametrizing tests or fixtures using an empty ``ids`` argument (:issue:`1849`).
+  Thanks :user:`OPpuolitaival` for the report and :user:`nicoddemus` for the PR.
 
 * Fix loader error when running ``pytest`` embedded in a zipfile.
-  Thanks `@mbachry`_ for the PR.
-
-
-.. _@Kingdread: https://github.com/Kingdread
-.. _@mbachry: https://github.com/mbachry
-.. _@OPpuolitaival: https://github.com/OPpuolitaival
+  Thanks :user:`mbachry` for the PR.
 
-.. _#1822: https://github.com/pytest-dev/pytest/issues/1822
-.. _#1832: https://github.com/pytest-dev/pytest/issues/1832
-.. _#1849: https://github.com/pytest-dev/pytest/issues/1849
 
+.. _release-3.0.0:
 
 3.0.0 (2016-08-18)
 ==================
@@ -5914,7 +6792,7 @@ time or change existing behaviors in order to make them less surprising/more use
   ``conftest.py`` will not benefit from improved assertions by
   default, you should use ``pytest.register_assert_rewrite()`` to
   explicitly turn on assertion rewriting for those files.  Thanks
-  `@flub`_ for the PR.
+  :user:`flub` for the PR.
 
 * The following deprecated commandline options were removed:
 
@@ -5923,36 +6801,36 @@ time or change existing behaviors in order to make them less surprising/more use
   * ``--nomagic``: use ``--assert=plain`` instead;
   * ``--report``: use ``-r`` instead;
 
-  Thanks to `@RedBeardCode`_ for the PR (`#1664`_).
+  Thanks to :user:`RedBeardCode` for the PR (:pull:`1664`).
 
 * ImportErrors in plugins now are a fatal error instead of issuing a
-  pytest warning (`#1479`_). Thanks to `@The-Compiler`_ for the PR.
+  pytest warning (:issue:`1479`). Thanks to :user:`The-Compiler` for the PR.
 
-* Removed support code for Python 3 versions < 3.3 (`#1627`_).
+* Removed support code for Python 3 versions < 3.3 (:pull:`1627`).
 
 * Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points
   were never documented and a leftover from a pre-virtualenv era. These entry
   points also created broken entry points in wheels, so removing them also
-  removes a source of confusion for users (`#1632`_).
-  Thanks `@obestwalter`_ for the PR.
+  removes a source of confusion for users (:issue:`1632`).
+  Thanks :user:`obestwalter` for the PR.
 
 * ``pytest.skip()`` now raises an error when used to decorate a test function,
   as opposed to its original intent (to imperatively skip a test inside a test function). Previously
-  this usage would cause the entire module to be skipped (`#607`_).
-  Thanks `@omarkohl`_ for the complete PR (`#1519`_).
+  this usage would cause the entire module to be skipped (:issue:`607`).
+  Thanks :user:`omarkohl` for the complete PR (:pull:`1519`).
 
 * Exit tests if a collection error occurs. A poll indicated most users will hit CTRL-C
-  anyway as soon as they see collection errors, so pytest might as well make that the default behavior (`#1421`_).
+  anyway as soon as they see collection errors, so pytest might as well make that the default behavior (:issue:`1421`).
   A ``--continue-on-collection-errors`` option has been added to restore the previous behaviour.
-  Thanks `@olegpidsadnyi`_ and `@omarkohl`_ for the complete PR (`#1628`_).
+  Thanks :user:`olegpidsadnyi` and :user:`omarkohl` for the complete PR (:pull:`1628`).
 
 * Renamed the pytest ``pdb`` module (plugin) into ``debugging`` to avoid clashes with the builtin ``pdb`` module.
 
 * Raise a helpful failure message when requesting a parametrized fixture at runtime,
   e.g. with ``request.getfixturevalue``. Previously these parameters were simply
   never defined, so a fixture decorated like ``@pytest.fixture(params=[0, 1, 2])``
-  only ran once (`#460`_).
-  Thanks to `@nikratio`_ for the bug report, `@RedBeardCode`_ and `@tomviner`_ for the PR.
+  only ran once (:pull:`460`).
+  Thanks to :user:`nikratio` for the bug report, :user:`RedBeardCode` and :user:`tomviner` for the PR.
 
 * ``_pytest.monkeypatch.monkeypatch`` class has been renamed to ``_pytest.monkeypatch.MonkeyPatch``
   so it doesn't conflict with the ``monkeypatch`` fixture.
@@ -5969,49 +6847,49 @@ time or change existing behaviors in order to make them less surprising/more use
 
 * New ``doctest_namespace`` fixture for injecting names into the
   namespace in which doctests run.
-  Thanks `@milliams`_ for the complete PR (`#1428`_).
+  Thanks :user:`milliams` for the complete PR (:pull:`1428`).
 
 * New ``--doctest-report`` option available to change the output format of diffs
-  when running (failing) doctests (implements `#1749`_).
-  Thanks `@hartym`_ for the PR.
+  when running (failing) doctests (implements :issue:`1749`).
+  Thanks :user:`hartym` for the PR.
 
 * New ``name`` argument to ``pytest.fixture`` decorator which allows a custom name
   for a fixture (to solve the funcarg-shadowing-fixture problem).
-  Thanks `@novas0x2a`_ for the complete PR (`#1444`_).
+  Thanks :user:`novas0x2a` for the complete PR (:pull:`1444`).
 
 * New ``approx()`` function for easily comparing floating-point numbers in
   tests.
-  Thanks `@kalekundert`_ for the complete PR (`#1441`_).
+  Thanks :user:`kalekundert` for the complete PR (:pull:`1441`).
 
 * Ability to add global properties in the final xunit output file by accessing
   the internal ``junitxml`` plugin (experimental).
-  Thanks `@tareqalayan`_ for the complete PR `#1454`_).
+  Thanks :user:`tareqalayan` for the complete PR :pull:`1454`).
 
 * New ``ExceptionInfo.match()`` method to match a regular expression on the
-  string representation of an exception (`#372`_).
-  Thanks `@omarkohl`_ for the complete PR (`#1502`_).
+  string representation of an exception (:issue:`372`).
+  Thanks :user:`omarkohl` for the complete PR (:pull:`1502`).
 
 * ``__tracebackhide__`` can now also be set to a callable which then can decide
   whether to filter the traceback based on the ``ExceptionInfo`` object passed
-  to it. Thanks `@The-Compiler`_ for the complete PR (`#1526`_).
+  to it. Thanks :user:`The-Compiler` for the complete PR (:pull:`1526`).
 
 * New ``pytest_make_parametrize_id(config, val)`` hook which can be used by plugins to provide
   friendly strings for custom types.
-  Thanks `@palaviv`_ for the PR.
+  Thanks :user:`palaviv` for the PR.
 
 * ``capsys`` and ``capfd`` now have a ``disabled()`` context-manager method, which
   can be used to temporarily disable capture within a test.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * New cli flag ``--fixtures-per-test``: shows which fixtures are being used
   for each selected test item. Features doc strings of fixtures by default.
   Can also show where fixtures are defined if combined with ``-v``.
-  Thanks `@hackebrot`_ for the PR.
+  Thanks :user:`hackebrot` for the PR.
 
 * Introduce ``pytest`` command as recommended entry point. Note that ``py.test``
   still works and is not scheduled for removal. Closes proposal
-  `#1629`_. Thanks `@obestwalter`_ and `@davehunt`_ for the complete PR
-  (`#1633`_).
+  :issue:`1629`. Thanks :user:`obestwalter` and :user:`davehunt` for the complete PR
+  (:pull:`1633`).
 
 * New cli flags:
 
@@ -6024,13 +6902,13 @@ time or change existing behaviors in order to make them less surprising/more use
   + ``--keep-duplicates``: py.test now ignores duplicated paths given in the command
     line. To retain the previous behavior where the same test could be run multiple
     times by specifying it in the command-line multiple times, pass the ``--keep-duplicates``
-    argument (`#1609`_);
+    argument (:issue:`1609`);
 
-  Thanks `@d6e`_, `@kvas-it`_, `@sallner`_, `@ioggstream`_ and `@omarkohl`_ for the PRs.
+  Thanks :user:`d6e`, :user:`kvas-it`, :user:`sallner`, :user:`ioggstream` and :user:`omarkohl` for the PRs.
 
 * New CLI flag ``--override-ini``/``-o``: overrides values from the ini file.
   For example: ``"-o xfail_strict=True"``'.
-  Thanks `@blueyed`_ and `@fengxx`_ for the PR.
+  Thanks :user:`blueyed` and :user:`fengxx` for the PR.
 
 * New hooks:
 
@@ -6038,148 +6916,148 @@ time or change existing behaviors in order to make them less surprising/more use
   + ``pytest_fixture_post_finalizer(fixturedef)``: called after the fixture's
     finalizer and has access to the fixture's result cache.
 
-  Thanks `@d6e`_, `@sallner`_.
+  Thanks :user:`d6e`, :user:`sallner`.
 
 * Issue warnings for asserts whose test is a tuple literal. Such asserts will
   never fail because tuples are always truthy and are usually a mistake
-  (see `#1562`_). Thanks `@kvas-it`_, for the PR.
+  (see :issue:`1562`). Thanks :user:`kvas-it`, for the PR.
 
 * Allow passing a custom debugger class (e.g. ``--pdbcls=IPython.core.debugger:Pdb``).
-  Thanks to `@anntzer`_ for the PR.
+  Thanks to :user:`anntzer` for the PR.
 
 
 **Changes**
 
 * Plugins now benefit from assertion rewriting.  Thanks
-  `@sober7`_, `@nicoddemus`_ and `@flub`_ for the PR.
+  :user:`sober7`, :user:`nicoddemus` and :user:`flub` for the PR.
 
 * Change ``report.outcome`` for ``xpassed`` tests to ``"passed"`` in non-strict
-  mode and ``"failed"`` in strict mode. Thanks to `@hackebrot`_ for the PR
-  (`#1795`_) and `@gprasad84`_ for report (`#1546`_).
+  mode and ``"failed"`` in strict mode. Thanks to :user:`hackebrot` for the PR
+  (:pull:`1795`) and :user:`gprasad84` for report (:issue:`1546`).
 
 * Tests marked with ``xfail(strict=False)`` (the default) now appear in
   JUnitXML reports as passing tests instead of skipped.
-  Thanks to `@hackebrot`_ for the PR (`#1795`_).
+  Thanks to :user:`hackebrot` for the PR (:pull:`1795`).
 
 * Highlight path of the file location in the error report to make it easier to copy/paste.
-  Thanks `@suzaku`_ for the PR (`#1778`_).
+  Thanks :user:`suzaku` for the PR (:pull:`1778`).
 
 * Fixtures marked with ``@pytest.fixture`` can now use ``yield`` statements exactly like
   those marked with the ``@pytest.yield_fixture`` decorator. This change renders
   ``@pytest.yield_fixture`` deprecated and makes ``@pytest.fixture`` with ``yield`` statements
-  the preferred way to write teardown code (`#1461`_).
-  Thanks `@csaftoiu`_ for bringing this to attention and `@nicoddemus`_ for the PR.
+  the preferred way to write teardown code (:pull:`1461`).
+  Thanks :user:`csaftoiu` for bringing this to attention and :user:`nicoddemus` for the PR.
 
-* Explicitly passed parametrize ids do not get escaped to ascii (`#1351`_).
-  Thanks `@ceridwen`_ for the PR.
+* Explicitly passed parametrize ids do not get escaped to ascii (:issue:`1351`).
+  Thanks :user:`ceridwen` for the PR.
 
 * Fixtures are now sorted in the error message displayed when an unknown
   fixture is declared in a test function.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * ``pytest_terminal_summary`` hook now receives the ``exitstatus``
-  of the test session as argument. Thanks `@blueyed`_ for the PR (`#1809`_).
+  of the test session as argument. Thanks :user:`blueyed` for the PR (:pull:`1809`).
 
 * Parametrize ids can accept ``None`` as specific test id, in which case the
   automatically generated id for that argument will be used.
-  Thanks `@palaviv`_ for the complete PR (`#1468`_).
+  Thanks :user:`palaviv` for the complete PR (:pull:`1468`).
 
 * The parameter to xunit-style setup/teardown methods (``setup_method``,
   ``setup_module``, etc.) is now optional and may be omitted.
-  Thanks `@okken`_ for bringing this to attention and `@nicoddemus`_ for the PR.
+  Thanks :user:`okken` for bringing this to attention and :user:`nicoddemus` for the PR.
 
 * Improved automatic id generation selection in case of duplicate ids in
   parametrize.
-  Thanks `@palaviv`_ for the complete PR (`#1474`_).
+  Thanks :user:`palaviv` for the complete PR (:pull:`1474`).
 
 * Now pytest warnings summary is shown up by default. Added a new flag
-  ``--disable-pytest-warnings`` to explicitly disable the warnings summary (`#1668`_).
+  ``--disable-pytest-warnings`` to explicitly disable the warnings summary (:issue:`1668`).
 
 * Make ImportError during collection more explicit by reminding
-  the user to check the name of the test module/package(s) (`#1426`_).
-  Thanks `@omarkohl`_ for the complete PR (`#1520`_).
+  the user to check the name of the test module/package(s) (:issue:`1426`).
+  Thanks :user:`omarkohl` for the complete PR (:pull:`1520`).
 
 * Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks
-  `@mikofski`_ for the report and `@tomviner`_ for the PR (`#1544`_).
+  :user:`mikofski` for the report and :user:`tomviner` for the PR (:issue:`1544`).
 
 * ``pytest.raises`` in the context manager form accepts a custom
   ``message`` to raise when no exception occurred.
-  Thanks `@palaviv`_ for the complete PR (`#1616`_).
+  Thanks :user:`palaviv` for the complete PR (:pull:`1616`).
 
 * ``conftest.py`` files now benefit from assertion rewriting; previously it
-  was only available for test modules. Thanks `@flub`_, `@sober7`_ and
-  `@nicoddemus`_ for the PR (`#1619`_).
+  was only available for test modules. Thanks :user:`flub`, :user:`sober7` and
+  :user:`nicoddemus` for the PR (:issue:`1619`).
 
 * Text documents without any doctests no longer appear as "skipped".
-  Thanks `@graingert`_ for reporting and providing a full PR (`#1580`_).
+  Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`).
 
 * Ensure that a module within a namespace package can be found when it
   is specified on the command line together with the ``--pyargs``
-  option.  Thanks to `@taschini`_ for the PR (`#1597`_).
+  option.  Thanks to :user:`taschini` for the PR (:pull:`1597`).
 
 * Always include full assertion explanation during assertion rewriting. The previous behaviour was hiding
   sub-expressions that happened to be ``False``, assuming this was redundant information.
-  Thanks `@bagerard`_ for reporting (`#1503`_). Thanks to `@davehunt`_ and
-  `@tomviner`_ for the PR.
+  Thanks :user:`bagerard` for reporting (:issue:`1503`). Thanks to :user:`davehunt` and
+  :user:`tomviner` for the PR.
 
 * ``OptionGroup.addoption()`` now checks if option names were already
-  added before, to make it easier to track down issues like `#1618`_.
+  added before, to make it easier to track down issues like :issue:`1618`.
   Before, you only got exceptions later from ``argparse`` library,
   giving no clue about the actual reason for double-added options.
 
 * ``yield``-based tests are considered deprecated and will be removed in pytest-4.0.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * ``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
-  to avoid conflicts with other distutils commands (see `#567`_). ``[pytest]`` sections in
+  to avoid conflicts with other distutils commands (see :pull:`567`). ``[pytest]`` sections in
   ``pytest.ini`` or ``tox.ini`` files are supported and unchanged.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * Using ``pytest_funcarg__`` prefix to declare fixtures is considered deprecated and will be
-  removed in pytest-4.0 (`#1684`_).
-  Thanks `@nicoddemus`_ for the PR.
+  removed in pytest-4.0 (:pull:`1684`).
+  Thanks :user:`nicoddemus` for the PR.
 
 * Passing a command-line string to ``pytest.main()`` is considered deprecated and scheduled
-  for removal in pytest-4.0. It is recommended to pass a list of arguments instead (`#1723`_).
+  for removal in pytest-4.0. It is recommended to pass a list of arguments instead (:pull:`1723`).
 
 * Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is
-  still present but is now considered deprecated. Thanks to `@RedBeardCode`_ and `@tomviner`_
-  for the PR (`#1626`_).
+  still present but is now considered deprecated. Thanks to :user:`RedBeardCode` and :user:`tomviner`
+  for the PR (:pull:`1626`).
 
-* ``optparse`` type usage now triggers DeprecationWarnings (`#1740`_).
+* ``optparse`` type usage now triggers DeprecationWarnings (:issue:`1740`).
 
 
-* ``optparse`` backward compatibility supports float/complex types (`#457`_).
+* ``optparse`` backward compatibility supports float/complex types (:issue:`457`).
 
 * Refined logic for determining the ``rootdir``, considering only valid
-  paths which fixes a number of issues: `#1594`_, `#1435`_ and `#1471`_.
+  paths which fixes a number of issues: :issue:`1594`, :issue:`1435` and :issue:`1471`.
   Updated the documentation according to current behavior. Thanks to
-  `@blueyed`_, `@davehunt`_ and `@matthiasha`_ for the PR.
+  :user:`blueyed`, :user:`davehunt` and :user:`matthiasha` for the PR.
 
 * Always include full assertion explanation. The previous behaviour was hiding
   sub-expressions that happened to be False, assuming this was redundant information.
-  Thanks `@bagerard`_ for reporting (`#1503`_). Thanks to `@davehunt`_ and
-  `@tomviner`_ for PR.
+  Thanks :user:`bagerard` for reporting (:issue:`1503`). Thanks to :user:`davehunt` and
+  :user:`tomviner` for PR.
 
-* Better message in case of not using parametrized variable (see `#1539`_).
-  Thanks to `@tramwaj29`_ for the PR.
+* Better message in case of not using parametrized variable (see :issue:`1539`).
+  Thanks to :user:`tramwaj29` for the PR.
 
 * Updated docstrings with a more uniform style.
 
 * Add stderr write for ``pytest.exit(msg)`` during startup. Previously the message was never shown.
-  Thanks `@BeyondEvil`_ for reporting `#1210`_. Thanks to @jgsonesen and
-  `@tomviner`_ for the PR.
+  Thanks :user:`BeyondEvil` for reporting :issue:`1210`. Thanks to @jgsonesen and
+  :user:`tomviner` for the PR.
 
-* No longer display the incorrect test deselection reason (`#1372`_).
-  Thanks `@ronnypfannschmidt`_ for the PR.
+* No longer display the incorrect test deselection reason (:issue:`1372`).
+  Thanks :user:`ronnypfannschmidt` for the PR.
 
 * The ``--resultlog`` command line option has been deprecated: it is little used
-  and there are more modern and better alternatives (see `#830`_).
-  Thanks `@nicoddemus`_ for the PR.
+  and there are more modern and better alternatives (see :issue:`830`).
+  Thanks :user:`nicoddemus` for the PR.
 
 * Improve error message with fixture lookup errors: add an 'E' to the first
-  line and '>' to the rest. Fixes `#717`_. Thanks `@blueyed`_ for reporting and
-  a PR, `@eolo999`_ for the initial PR and `@tomviner`_ for his guidance during
+  line and '>' to the rest. Fixes :issue:`717`. Thanks :user:`blueyed` for reporting and
+  a PR, :user:`eolo999` for the initial PR and :user:`tomviner` for his guidance during
   EuroPython2016 sprint.
 
 
@@ -6188,140 +7066,37 @@ time or change existing behaviors in order to make them less surprising/more use
 * Parametrize now correctly handles duplicated test ids.
 
 * Fix internal error issue when the ``method`` argument is missing for
-  ``teardown_method()`` (`#1605`_).
+  ``teardown_method()`` (:issue:`1605`).
 
 * Fix exception visualization in case the current working directory (CWD) gets
-  deleted during testing (`#1235`_). Thanks `@bukzor`_ for reporting. PR by
-  `@marscher`_.
+  deleted during testing (:issue:`1235`). Thanks :user:`bukzor` for reporting. PR by
+  :user:`marscher`.
 
-* Improve test output for logical expression with brackets (`#925`_).
-  Thanks `@DRMacIver`_ for reporting and `@RedBeardCode`_ for the PR.
+* Improve test output for logical expression with brackets (:issue:`925`).
+  Thanks :user:`DRMacIver` for reporting and :user:`RedBeardCode` for the PR.
 
-* Create correct diff for strings ending with newlines (`#1553`_).
-  Thanks `@Vogtinator`_ for reporting and `@RedBeardCode`_ and
-  `@tomviner`_ for the PR.
+* Create correct diff for strings ending with newlines (:issue:`1553`).
+  Thanks :user:`Vogtinator` for reporting and :user:`RedBeardCode` and
+  :user:`tomviner` for the PR.
 
 * ``ConftestImportFailure`` now shows the traceback making it easier to
-  identify bugs in ``conftest.py`` files (`#1516`_). Thanks `@txomon`_ for
+  identify bugs in ``conftest.py`` files (:pull:`1516`). Thanks :user:`txomon` for
   the PR.
 
 * Text documents without any doctests no longer appear as "skipped".
-  Thanks `@graingert`_ for reporting and providing a full PR (`#1580`_).
+  Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`).
 
 * Fixed collection of classes with custom ``__new__`` method.
-  Fixes `#1579`_. Thanks to `@Stranger6667`_ for the PR.
+  Fixes :issue:`1579`. Thanks to :user:`Stranger6667` for the PR.
 
-* Fixed scope overriding inside metafunc.parametrize (`#634`_).
-  Thanks to `@Stranger6667`_ for the PR.
+* Fixed scope overriding inside metafunc.parametrize (:issue:`634`).
+  Thanks to :user:`Stranger6667` for the PR.
 
-* Fixed the total tests tally in junit xml output (`#1798`_).
-  Thanks to `@cboelsen`_ for the PR.
+* Fixed the total tests tally in junit xml output (:pull:`1798`).
+  Thanks to :user:`cboelsen` for the PR.
 
 * Fixed off-by-one error with lines from ``request.node.warn``.
-  Thanks to `@blueyed`_ for the PR.
-
-
-.. _#1210: https://github.com/pytest-dev/pytest/issues/1210
-.. _#1235: https://github.com/pytest-dev/pytest/issues/1235
-.. _#1351: https://github.com/pytest-dev/pytest/issues/1351
-.. _#1372: https://github.com/pytest-dev/pytest/issues/1372
-.. _#1421: https://github.com/pytest-dev/pytest/issues/1421
-.. _#1426: https://github.com/pytest-dev/pytest/issues/1426
-.. _#1428: https://github.com/pytest-dev/pytest/pull/1428
-.. _#1435: https://github.com/pytest-dev/pytest/issues/1435
-.. _#1441: https://github.com/pytest-dev/pytest/pull/1441
-.. _#1444: https://github.com/pytest-dev/pytest/pull/1444
-.. _#1454: https://github.com/pytest-dev/pytest/pull/1454
-.. _#1461: https://github.com/pytest-dev/pytest/pull/1461
-.. _#1468: https://github.com/pytest-dev/pytest/pull/1468
-.. _#1471: https://github.com/pytest-dev/pytest/issues/1471
-.. _#1474: https://github.com/pytest-dev/pytest/pull/1474
-.. _#1479: https://github.com/pytest-dev/pytest/issues/1479
-.. _#1502: https://github.com/pytest-dev/pytest/pull/1502
-.. _#1503: https://github.com/pytest-dev/pytest/issues/1503
-.. _#1516: https://github.com/pytest-dev/pytest/pull/1516
-.. _#1519: https://github.com/pytest-dev/pytest/pull/1519
-.. _#1520: https://github.com/pytest-dev/pytest/pull/1520
-.. _#1526: https://github.com/pytest-dev/pytest/pull/1526
-.. _#1539: https://github.com/pytest-dev/pytest/issues/1539
-.. _#1544: https://github.com/pytest-dev/pytest/issues/1544
-.. _#1546: https://github.com/pytest-dev/pytest/issues/1546
-.. _#1553: https://github.com/pytest-dev/pytest/issues/1553
-.. _#1562: https://github.com/pytest-dev/pytest/issues/1562
-.. _#1579: https://github.com/pytest-dev/pytest/issues/1579
-.. _#1580: https://github.com/pytest-dev/pytest/pull/1580
-.. _#1594: https://github.com/pytest-dev/pytest/issues/1594
-.. _#1597: https://github.com/pytest-dev/pytest/pull/1597
-.. _#1605: https://github.com/pytest-dev/pytest/issues/1605
-.. _#1616: https://github.com/pytest-dev/pytest/pull/1616
-.. _#1618: https://github.com/pytest-dev/pytest/issues/1618
-.. _#1619: https://github.com/pytest-dev/pytest/issues/1619
-.. _#1626: https://github.com/pytest-dev/pytest/pull/1626
-.. _#1627: https://github.com/pytest-dev/pytest/pull/1627
-.. _#1628: https://github.com/pytest-dev/pytest/pull/1628
-.. _#1629: https://github.com/pytest-dev/pytest/issues/1629
-.. _#1632: https://github.com/pytest-dev/pytest/issues/1632
-.. _#1633: https://github.com/pytest-dev/pytest/pull/1633
-.. _#1664: https://github.com/pytest-dev/pytest/pull/1664
-.. _#1668: https://github.com/pytest-dev/pytest/issues/1668
-.. _#1684: https://github.com/pytest-dev/pytest/pull/1684
-.. _#1723: https://github.com/pytest-dev/pytest/pull/1723
-.. _#1740: https://github.com/pytest-dev/pytest/issues/1740
-.. _#1749: https://github.com/pytest-dev/pytest/issues/1749
-.. _#1778: https://github.com/pytest-dev/pytest/pull/1778
-.. _#1795: https://github.com/pytest-dev/pytest/pull/1795
-.. _#1798: https://github.com/pytest-dev/pytest/pull/1798
-.. _#1809: https://github.com/pytest-dev/pytest/pull/1809
-.. _#372: https://github.com/pytest-dev/pytest/issues/372
-.. _#457: https://github.com/pytest-dev/pytest/issues/457
-.. _#460: https://github.com/pytest-dev/pytest/pull/460
-.. _#567: https://github.com/pytest-dev/pytest/pull/567
-.. _#607: https://github.com/pytest-dev/pytest/issues/607
-.. _#634: https://github.com/pytest-dev/pytest/issues/634
-.. _#717: https://github.com/pytest-dev/pytest/issues/717
-.. _#830: https://github.com/pytest-dev/pytest/issues/830
-.. _#925: https://github.com/pytest-dev/pytest/issues/925
-
-
-.. _@anntzer: https://github.com/anntzer
-.. _@bagerard: https://github.com/bagerard
-.. _@BeyondEvil: https://github.com/BeyondEvil
-.. _@blueyed: https://github.com/blueyed
-.. _@ceridwen: https://github.com/ceridwen
-.. _@cboelsen: https://github.com/cboelsen
-.. _@csaftoiu: https://github.com/csaftoiu
-.. _@d6e: https://github.com/d6e
-.. _@davehunt: https://github.com/davehunt
-.. _@DRMacIver: https://github.com/DRMacIver
-.. _@eolo999: https://github.com/eolo999
-.. _@fengxx: https://github.com/fengxx
-.. _@flub: https://github.com/flub
-.. _@gprasad84: https://github.com/gprasad84
-.. _@graingert: https://github.com/graingert
-.. _@hartym: https://github.com/hartym
-.. _@kalekundert: https://github.com/kalekundert
-.. _@kvas-it: https://github.com/kvas-it
-.. _@marscher: https://github.com/marscher
-.. _@mikofski: https://github.com/mikofski
-.. _@milliams: https://github.com/milliams
-.. _@nikratio: https://github.com/nikratio
-.. _@novas0x2a: https://github.com/novas0x2a
-.. _@obestwalter: https://github.com/obestwalter
-.. _@okken: https://github.com/okken
-.. _@olegpidsadnyi: https://github.com/olegpidsadnyi
-.. _@omarkohl: https://github.com/omarkohl
-.. _@palaviv: https://github.com/palaviv
-.. _@RedBeardCode: https://github.com/RedBeardCode
-.. _@sallner: https://github.com/sallner
-.. _@sober7: https://github.com/sober7
-.. _@Stranger6667: https://github.com/Stranger6667
-.. _@suzaku: https://github.com/suzaku
-.. _@tareqalayan: https://github.com/tareqalayan
-.. _@taschini: https://github.com/taschini
-.. _@tramwaj29: https://github.com/tramwaj29
-.. _@txomon: https://github.com/txomon
-.. _@Vogtinator: https://github.com/Vogtinator
-.. _@matthiasha: https://github.com/matthiasha
+  Thanks to :user:`blueyed` for the PR.
 
 
 2.9.2 (2016-05-31)
@@ -6329,38 +7104,30 @@ time or change existing behaviors in order to make them less surprising/more use
 
 **Bug Fixes**
 
-* fix `#510`_: skip tests where one parameterize dimension was empty
-  thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR
+* fix :issue:`510`: skip tests where one parameterize dimension was empty
+  thanks Alex Stapleton for the Report and :user:`RonnyPfannschmidt` for the PR
 
 * Fix Xfail does not work with condition keyword argument.
-  Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_
-  for PR the (`#1524`_).
+  Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
+  for PR the (:pull:`1524`).
 
 * Fix win32 path issue when putting custom config file with absolute path
   in ``pytest.main("-c your_absolute_path")``.
 
 * Fix maximum recursion depth detection when raised error class is not aware
   of unicode/encoded bytes.
-  Thanks `@prusse-martin`_ for the PR (`#1506`_).
+  Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
 
 * Fix ``pytest.mark.skip`` mark when used in strict mode.
-  Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
+  Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
   showing how to fix the bug.
 
 * Minor improvements and fixes to the documentation.
-  Thanks `@omarkohl`_ for the PR.
+  Thanks :user:`omarkohl` for the PR.
 
 * Fix ``--fixtures`` to show all fixture definitions as opposed to just
   one per fixture name.
-  Thanks to `@hackebrot`_ for the PR.
-
-.. _#510: https://github.com/pytest-dev/pytest/issues/510
-.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
-.. _#1496: https://github.com/pytest-dev/pytest/issues/1496
-.. _#1524: https://github.com/pytest-dev/pytest/pull/1524
-
-.. _@prusse-martin: https://github.com/prusse-martin
-.. _@astraw38: https://github.com/astraw38
+  Thanks to :user:`hackebrot` for the PR.
 
 
 2.9.1 (2016-03-17)
@@ -6369,34 +7136,26 @@ time or change existing behaviors in order to make them less surprising/more use
 **Bug Fixes**
 
 * Improve error message when a plugin fails to load.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
-* Fix (`#1178 <https://github.com/pytest-dev/pytest/issues/1178>`_):
+* Fix (:issue:`1178`):
   ``pytest.fail`` with non-ascii characters raises an internal pytest error.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
-* Fix (`#469`_): junit parses report.nodeid incorrectly, when params IDs
-  contain ``::``. Thanks `@tomviner`_ for the PR (`#1431`_).
+* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
+  contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
 
-* Fix (`#578 <https://github.com/pytest-dev/pytest/issues/578>`_): SyntaxErrors
+* Fix (:issue:`578`): SyntaxErrors
   containing non-ascii lines at the point of failure generated an internal
   py.test error.
-  Thanks `@asottile`_ for the report and `@nicoddemus`_ for the PR.
+  Thanks :user:`asottile` for the report and :user:`nicoddemus` for the PR.
 
-* Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize
+* Fix (:issue:`1437`): When passing in a bytestring regex pattern to parameterize
   attempt to decode it as utf-8 ignoring errors.
 
-* Fix (`#649`_): parametrized test nodes cannot be specified to run on the command line.
-
-* Fix (`#138`_): better reporting for python 3.3+ chained exceptions
-
-.. _#1437: https://github.com/pytest-dev/pytest/issues/1437
-.. _#469: https://github.com/pytest-dev/pytest/issues/469
-.. _#1431: https://github.com/pytest-dev/pytest/pull/1431
-.. _#649: https://github.com/pytest-dev/pytest/issues/649
-.. _#138: https://github.com/pytest-dev/pytest/issues/138
+* Fix (:issue:`649`): parametrized test nodes cannot be specified to run on the command line.
 
-.. _@asottile: https://github.com/asottile
+* Fix (:issue:`138`): better reporting for python 3.3+ chained exceptions
 
 
 2.9.0 (2016-02-29)
@@ -6405,29 +7164,29 @@ time or change existing behaviors in order to make them less surprising/more use
 **New Features**
 
 * New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
-  Thanks `@MichaelAquilina`_ for the complete PR (`#1040`_).
+  Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
 
 * ``--doctest-glob`` may now be passed multiple times in the command-line.
-  Thanks `@jab`_ and `@nicoddemus`_ for the PR.
+  Thanks :user:`jab` and :user:`nicoddemus` for the PR.
 
 * New ``-rp`` and ``-rP`` reporting options give the summary and full output
-  of passing tests, respectively. Thanks to `@codewarrior0`_ for the PR.
+  of passing tests, respectively. Thanks to :user:`codewarrior0` for the PR.
 
 * ``pytest.mark.xfail`` now has a ``strict`` option, which makes ``XPASS``
   tests to fail the test suite (defaulting to ``False``). There's also a
   ``xfail_strict`` ini option that can be used to configure it project-wise.
-  Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_).
+  Thanks :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (:pull:`1355`).
 
 * ``Parser.addini`` now supports options of type ``bool``.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings
   in doctest output (similar to ``ALLOW_UNICODE``).
-  Thanks `@jaraco`_ for the request and `@nicoddemus`_ for the PR (`#1287`_).
+  Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:pull:`1287`).
 
 * Give a hint on ``KeyboardInterrupt`` to use the ``--fulltrace`` option to show the errors.
-  Fixes `#1366`_.
-  Thanks to `@hpk42`_ for the report and `@RonnyPfannschmidt`_ for the PR.
+  Fixes :issue:`1366`.
+  Thanks to :user:`hpk42` for the report and :user:`RonnyPfannschmidt` for the PR.
 
 * Catch ``IndexError`` exceptions when getting exception source location.
   Fixes a pytest internal error for dynamically generated code (fixtures and tests)
@@ -6451,74 +7210,45 @@ time or change existing behaviors in order to make them less surprising/more use
   `pylib <https://pylib.readthedocs.io>`_.
 
 * ``pytest_enter_pdb`` now optionally receives the pytest config object.
-  Thanks `@nicoddemus`_ for the PR.
+  Thanks :user:`nicoddemus` for the PR.
 
 * Removed code and documentation for Python 2.5 or lower versions,
   including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
-  Thanks `@nicoddemus`_ for the PR (`#1226`_).
+  Thanks :user:`nicoddemus` for the PR (:pull:`1226`).
 
 * Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is
   found in the environment, even when ``-vv`` isn't used.
-  Thanks `@The-Compiler`_ for the PR.
+  Thanks :user:`The-Compiler` for the PR.
 
 * ``--lf`` and ``--ff`` now support long names: ``--last-failed`` and
   ``--failed-first`` respectively.
-  Thanks `@MichaelAquilina`_ for the PR.
+  Thanks :user:`MichaelAquilina` for the PR.
 
 * Added expected exceptions to ``pytest.raises`` fail message.
 
 * Collection only displays progress ("collecting X items") when in a terminal.
   This avoids cluttering the output when using ``--color=yes`` to obtain
-  colors in CI integrations systems (`#1397`_).
+  colors in CI integrations systems (:issue:`1397`).
 
 **Bug Fixes**
 
 * The ``-s`` and ``-c`` options should now work under ``xdist``;
   ``Config.fromdictargs`` now represents its input much more faithfully.
-  Thanks to `@bukzor`_ for the complete PR (`#680`_).
+  Thanks to :user:`bukzor` for the complete PR (:issue:`680`).
 
-* Fix (`#1290`_): support Python 3.5's ``@`` operator in assertion rewriting.
-  Thanks `@Shinkenjoe`_ for report with test case and `@tomviner`_ for the PR.
+* Fix (:issue:`1290`): support Python 3.5's ``@`` operator in assertion rewriting.
+  Thanks :user:`Shinkenjoe` for report with test case and :user:`tomviner` for the PR.
 
-* Fix formatting utf-8 explanation messages (`#1379`_).
-  Thanks `@biern`_ for the PR.
+* Fix formatting utf-8 explanation messages (:issue:`1379`).
+  Thanks :user:`biern` for the PR.
 
-* Fix `traceback style docs`_ to describe all of the available options
+* Fix :ref:`traceback style docs <how-to-modifying-python-tb-printing>` to describe all of the available options
   (auto/long/short/line/native/no), with ``auto`` being the default since v2.6.
-  Thanks `@hackebrot`_ for the PR.
+  Thanks :user:`hackebrot` for the PR.
 
-* Fix (`#1422`_): junit record_xml_property doesn't allow multiple records
+* Fix (:issue:`1422`): junit record_xml_property doesn't allow multiple records
   with same name.
 
-.. _`traceback style docs`: https://pytest.org/en/stable/usage.html#modifying-python-traceback-printing
-
-.. _#1609: https://github.com/pytest-dev/pytest/issues/1609
-.. _#1422: https://github.com/pytest-dev/pytest/issues/1422
-.. _#1379: https://github.com/pytest-dev/pytest/issues/1379
-.. _#1366: https://github.com/pytest-dev/pytest/issues/1366
-.. _#1040: https://github.com/pytest-dev/pytest/pull/1040
-.. _#680: https://github.com/pytest-dev/pytest/issues/680
-.. _#1287: https://github.com/pytest-dev/pytest/pull/1287
-.. _#1226: https://github.com/pytest-dev/pytest/pull/1226
-.. _#1290: https://github.com/pytest-dev/pytest/pull/1290
-.. _#1355: https://github.com/pytest-dev/pytest/pull/1355
-.. _#1397: https://github.com/pytest-dev/pytest/issues/1397
-.. _@biern: https://github.com/biern
-.. _@MichaelAquilina: https://github.com/MichaelAquilina
-.. _@bukzor: https://github.com/bukzor
-.. _@hpk42: https://github.com/hpk42
-.. _@nicoddemus: https://github.com/nicoddemus
-.. _@jab: https://github.com/jab
-.. _@codewarrior0: https://github.com/codewarrior0
-.. _@jaraco: https://github.com/jaraco
-.. _@The-Compiler: https://github.com/The-Compiler
-.. _@Shinkenjoe: https://github.com/Shinkenjoe
-.. _@tomviner: https://github.com/tomviner
-.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
-.. _@rabbbit: https://github.com/rabbbit
-.. _@hackebrot: https://github.com/hackebrot
-.. _@pquentin: https://github.com/pquentin
-.. _@ioggstream: https://github.com/ioggstream
 
 2.8.7 (2016-01-24)
 ==================
@@ -6756,7 +7486,7 @@ time or change existing behaviors in order to make them less surprising/more use
   Thanks Bruno Oliveira for the PR.
 
 - fix issue808: pytest's internal assertion rewrite hook now implements the
-  optional PEP302 get_data API so tests can access data files next to them.
+  optional :pep:`302` get_data API so tests can access data files next to them.
   Thanks xmo-odoo for request and example and Bruno Oliveira for
   the PR.
 
@@ -7364,7 +8094,7 @@ time or change existing behaviors in order to make them less surprising/more use
 
 - close issue240 - document precisely how pytest module importing
   works, discuss the two common test directory layouts, and how it
-  interacts with PEP420-namespace packages.
+  interacts with :pep:`420`\-namespace packages.
 
 - fix issue246 fix finalizer order to be LIFO on independent fixtures
   depending on a parametrized higher-than-function scoped fixture.
@@ -7424,7 +8154,7 @@ time or change existing behaviors in order to make them less surprising/more use
   (it already did neutralize pytest.mark.xfail markers)
 
 - refine pytest / pkg_resources interactions: The AssertionRewritingHook
-  PEP302 compliant loader now registers itself with setuptools/pkg_resources
+  :pep:`302` compliant loader now registers itself with setuptools/pkg_resources
   properly so that the pkg_resources.resource_stream method works properly.
   Fixes issue366.  Thanks for the investigations and full PR to Jason R. Coombs.
 
@@ -7749,7 +8479,7 @@ Bug fixes:
 - yielded test functions will now have autouse-fixtures active but
   cannot accept fixtures as funcargs - it's anyway recommended to
   rather use the post-2.0 parametrize features instead of yield, see:
-  http://pytest.org/en/stable/example/parametrize.html
+  http://pytest.org/en/stable/example/how-to/parametrize.html
 - fix autouse-issue where autouse-fixtures would not be discovered
   if defined in an a/conftest.py file and tests in a/tests/test_some.py
 - fix issue226 - LIFO ordering for fixture teardowns
@@ -7995,7 +8725,7 @@ Bug fixes:
   or through plugin hooks.  Also introduce a "--strict" option which
   will treat unregistered markers as errors
   allowing to avoid typos and maintain a well described set of markers
-  for your test suite.  See exaples at http://pytest.org/en/stable/mark.html
+  for your test suite.  See examples at http://pytest.org/en/stable/how-to/mark.html
   and its links.
 - issue50: introduce "-m marker" option to select tests based on markers
   (this is a stricter and more predictable version of '-k' in that "-m"
@@ -8178,7 +8908,7 @@ Bug fixes:
 - refinements to "collecting" output on non-ttys
 - refine internal plugin registration and --traceconfig output
 - introduce a mechanism to prevent/unregister plugins from the
-  command line, see http://pytest.org/en/stable/plugins.html#cmdunregister
+  command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister
 - activate resultlog plugin by default
 - fix regression wrt yielded tests which due to the
   collection-before-running semantics were not
@@ -8307,7 +9037,7 @@ Bug fixes:
 - fix issue57 -f|--looponfail to work with xpassing tests (thanks Ronny)
 - fix issue92 collectonly reporter and --pastebin (thanks Benjamin Peterson)
 - fix py.code.compile(source) to generate unique filenames
-- fix assertion re-interp problems on PyPy, by defering code
+- fix assertion re-interp problems on PyPy, by deferring code
   compilation to the (overridable) Frame.eval class. (thanks Amaury Forgeot)
 - fix py.path.local.pyimport() to work with directories
 - streamline py.path.local.mkdtemp implementation and usage
@@ -8381,7 +9111,7 @@ Bug fixes:
 - improve support for raises and other dynamically compiled code by
   manipulating python's linecache.cache instead of the previous
   rather hacky way of creating custom code objects.  This makes
-  it seemlessly work on Jython and PyPy where it previously didn't.
+  it seamlessly work on Jython and PyPy where it previously didn't.
 
 - fix issue96: make capturing more resilient against Control-C
   interruptions (involved somewhat substantial refactoring
@@ -8448,7 +9178,7 @@ Bug fixes:
 
 - fixes for making the jython/win32 combination work, note however:
   jython2.5.1/win32 does not provide a command line launcher, see
-  http://bugs.jython.org/issue1491 . See pylib install documentation
+  https://bugs.jython.org/issue1491 . See pylib install documentation
   for how to work around.
 
 - fixes for handling of unicode exception values and unprintable objects
index 2f3a2baf44b041ee2ceca4013552b67f188ae60e..32f508219a63502dca8672cad7ba88f0a838d9ff 100644 (file)
@@ -17,7 +17,9 @@
 # The short X.Y version.
 import ast
 import os
+import shutil
 import sys
+from textwrap import dedent
 from typing import List
 from typing import TYPE_CHECKING
 
@@ -35,8 +37,27 @@ release = ".".join(version.split(".")[:2])
 # sys.path.insert(0, os.path.abspath('.'))
 
 autodoc_member_order = "bysource"
+autodoc_typehints = "description"
+autodoc_typehints_description_target = "documented"
 todo_include_todos = 1
 
+latex_engine = "lualatex"
+
+latex_elements = {
+    "preamble": dedent(
+        r"""
+        \directlua{
+            luaotfload.add_fallback("fallbacks", {
+                "Noto Serif CJK SC:style=Regular;",
+                "Symbola:Style=Regular;"
+            })
+        }
+
+        \setmainfont{FreeSerif}[RawFeature={fallback=fallbacks}]
+        """
+    )
+}
+
 # -- General configuration -----------------------------------------------------
 
 # If your documentation needs a minimal Sphinx version, state it here.
@@ -49,6 +70,7 @@ extensions = [
     "pygments_pytest",
     "sphinx.ext.autodoc",
     "sphinx.ext.autosummary",
+    "sphinx.ext.extlinks",
     "sphinx.ext.intersphinx",
     "sphinx.ext.todo",
     "sphinx.ext.viewcode",
@@ -56,6 +78,13 @@ extensions = [
     "sphinxcontrib_trio",
 ]
 
+# Building PDF docs on readthedocs requires inkscape for svg to pdf
+# conversion. The relevant plugin is not useful for normal HTML builds, but
+# it still raises warnings and fails CI if inkscape is not available. So
+# only use the plugin if inkscape is actually available.
+if shutil.which("inkscape"):
+    extensions.append("sphinxcontrib.inkscapeconverter")
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ["_templates"]
 
@@ -70,7 +99,7 @@ master_doc = "contents"
 
 # General information about the project.
 project = "pytest"
-copyright = "2015–2020, holger krekel and pytest-dev team"
+copyright = "2015, holger krekel and pytest-dev team"
 
 
 # The language for content autogenerated by Sphinx. Refer to documentation
@@ -122,7 +151,6 @@ pygments_style = "sphinx"
 # A list of regular expressions that match URIs that should not be checked when
 # doing a linkcheck.
 linkcheck_ignore = [
-    "https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations",
     "https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/",
     "http://pythontesting.net/framework/pytest-introduction/",
     r"https://github.com/pytest-dev/pytest/issues/\d+",
@@ -133,6 +161,16 @@ linkcheck_ignore = [
 linkcheck_workers = 5
 
 
+_repo = "https://github.com/pytest-dev/pytest"
+extlinks = {
+    "bpo": ("https://bugs.python.org/issue%s", "bpo-%s"),
+    "pypi": ("https://pypi.org/project/%s/", "%s"),
+    "issue": (f"{_repo}/issues/%s", "issue #%s"),
+    "pull": (f"{_repo}/pull/%s", "pull request #%s"),
+    "user": ("https://github.com/%s", "@%s"),
+}
+
+
 # -- Options for HTML output ---------------------------------------------------
 
 sys.path.append(os.path.abspath("_themes"))
@@ -159,7 +197,7 @@ html_short_title = "pytest-%s" % release
 
 # The name of an image file (relative to this directory) to place at the top
 # of the sidebar.
-html_logo = "img/pytest1.png"
+html_logo = "img/pytest_logo_curves.svg"
 
 # The name of an image file (within the static path) to use as favicon of the
 # docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
@@ -210,7 +248,7 @@ html_sidebars = {
 html_domain_indices = True
 
 # If false, no index is generated.
-html_use_index = True
+html_use_index = False
 
 # If true, the index is split into individual pages for each letter.
 # html_split_index = False
@@ -251,7 +289,7 @@ latex_documents = [
         "contents",
         "pytest.tex",
         "pytest Documentation",
-        "holger krekel, trainer and consultant, http://merlinux.eu",
+        "holger krekel, trainer and consultant, https://merlinux.eu/",
         "manual",
     )
 ]
@@ -283,7 +321,9 @@ latex_domain_indices = False
 
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
-man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]
+man_pages = [
+    ("how-to/usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)
+]
 
 
 # -- Options for Epub output ---------------------------------------------------
@@ -292,7 +332,7 @@ man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"
 epub_title = "pytest"
 epub_author = "holger krekel at merlinux eu"
 epub_publisher = "holger krekel at merlinux eu"
-epub_copyright = "2013-2020, holger krekel et alii"
+epub_copyright = "2013, holger krekel et alii"
 
 # The language of the text. It defaults to the language option
 # or en if the language is not set.
@@ -301,7 +341,7 @@ epub_copyright = "2013-2020, holger krekel et alii"
 # The scheme of the identifier. Typical schemes are ISBN or URL.
 # epub_scheme = ''
 
-# The unique identifier of the text. This can be a ISBN number
+# The unique identifier of the text. This can be an ISBN number
 # or the project homepage.
 # epub_identifier = ''
 
@@ -345,10 +385,15 @@ texinfo_documents = [
 ]
 
 
-# Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {
-    "pluggy": ("https://pluggy.readthedocs.io/en/latest", None),
+    "pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
     "python": ("https://docs.python.org/3", None),
+    "numpy": ("https://numpy.org/doc/stable", None),
+    "pip": ("https://pip.pypa.io/en/stable", None),
+    "tox": ("https://tox.wiki/en/stable", None),
+    "virtualenv": ("https://virtualenv.pypa.io/en/stable", None),
+    "setuptools": ("https://setuptools.pypa.io/en/stable", None),
+    "packaging": ("https://packaging.python.org/en/latest", None),
 }
 
 
@@ -376,8 +421,6 @@ def configure_logging(app: "sphinx.application.Sphinx") -> None:
 
 
 def setup(app: "sphinx.application.Sphinx") -> None:
-    # from sphinx.ext.autodoc import cut_lines
-    # app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
     app.add_crossref_type(
         "fixture",
         "fixture",
@@ -399,6 +442,13 @@ def setup(app: "sphinx.application.Sphinx") -> None:
         indextemplate="pair: %s; global variable interpreted by pytest",
     )
 
+    app.add_crossref_type(
+        directivename="hook",
+        rolename="hook",
+        objname="pytest hook",
+        indextemplate="pair: %s; hook",
+    )
+
     configure_logging(app)
 
     # Make Sphinx mark classes with "final" when decorated with @final.
@@ -419,3 +469,7 @@ def setup(app: "sphinx.application.Sphinx") -> None:
         )
 
     sphinx.pycode.parser.VariableCommentPicker.is_final = patched_is_final
+
+    # legacypath.py monkey-patches pytest.Testdir in. Import the file so
+    # that autodoc can discover references to it.
+    import _pytest.legacypath  # noqa: F401
index efc6a8f57d30abacf35f39393de2faf49a7ee36c..beed10d7f2725fdc004b30ce4279a4ef3dc5f472 100644 (file)
@@ -7,21 +7,24 @@ Contact channels
 
 - `pytest issue tracker`_ to report bugs or suggest features (for version
   2.0 and above).
-
+- `pytest discussions`_ at github for general questions.
+- `pytest discord server <https://discord.com/invite/pytest-dev>`_
+  for pytest development visibility and general assistance.
 - `pytest on stackoverflow.com <http://stackoverflow.com/search?q=pytest>`_
-  to post questions with the tag ``pytest``.  New Questions will usually
+  to post precise questions with the tag ``pytest``.  New Questions will usually
   be seen by pytest users or developers and answered quickly.
 
 - `Testing In Python`_: a mailing list for Python testing tools and discussion.
 
 - `pytest-dev at python.org (mailing list)`_ pytest specific announcements and discussions.
 
-- `pytest-commit at python.org (mailing list)`_: for commits and new issues
-
 - :doc:`contribution guide <contributing>` for help on submitting pull
   requests to GitHub.
 
-- ``#pylib`` on irc.freenode.net IRC channel for random questions.
+- ``#pytest`` `on irc.libera.chat <ircs://irc.libera.chat:6697/#pytest>`_ IRC
+  channel for random questions (using an IRC client, `via webchat
+  <https://web.libera.chat/#pytest>`_, or `via Matrix
+  <https://matrix.to/#/%23pytest:libera.chat>`_).
 
 - private mail to Holger.Krekel at gmail com if you want to communicate sensitive issues
 
@@ -30,19 +33,21 @@ Contact channels
   consulting.
 
 .. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues
-.. _`old issue tracker`: http://bitbucket.org/hpk42/py-trunk/issues/
+.. _`old issue tracker`: https://bitbucket.org/hpk42/py-trunk/issues/
+
+.. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions
 
-.. _`merlinux.eu`: http://merlinux.eu
+.. _`merlinux.eu`: https://merlinux.eu/
 
 .. _`get an account`:
 
-.. _tetamap: http://tetamap.wordpress.com
+.. _tetamap: https://tetamap.wordpress.com/
 
-.. _`@pylibcommit`: http://twitter.com/pylibcommit
+.. _`@pylibcommit`: https://twitter.com/pylibcommit
 
 
 .. _`Testing in Python`: http://lists.idyll.org/listinfo/testing-in-python
-.. _FOAF: http://en.wikipedia.org/wiki/FOAF
+.. _FOAF: https://en.wikipedia.org/wiki/FOAF
 .. _`py-dev`:
 .. _`development mailing list`:
 .. _`pytest-dev at python.org (mailing list)`: http://mail.python.org/mailman/listinfo/pytest-dev
index 58a08744ced2b5a7901effab281e47a5095fb5b5..ae42884f658466f8d18a12333e6c41e5fda2ed2b 100644 (file)
@@ -7,41 +7,84 @@ Full pytest documentation
 
 .. `Download latest version as EPUB <http://media.readthedocs.org/epub/pytest/latest/pytest.epub>`_
 
+
+Start here
+-----------
+
 .. toctree::
    :maxdepth: 2
 
    getting-started
-   usage
-   existingtestsuite
-   assert
-   fixture
-   mark
-   monkeypatch
-   tmpdir
-   capture
-   warnings
-   doctest
-   skipping
-   parametrize
-   cache
-   unittest
-   nose
-   xunit_setup
-   plugins
-   writing_plugins
-   logging
-   reference
-
-   goodpractices
-   flaky
-   pythonpath
-   customize
+
+
+How-to guides
+-------------
+
+.. toctree::
+   :maxdepth: 2
+
+   how-to/usage
+   how-to/assert
+   how-to/fixtures
+   how-to/mark
+   how-to/parametrize
+   how-to/tmp_path
+   how-to/monkeypatch
+   how-to/doctest
+   how-to/cache
+
+   how-to/logging
+   how-to/capture-stdout-stderr
+   how-to/capture-warnings
+   how-to/skipping
+
+   how-to/plugins
+   how-to/writing_plugins
+   how-to/writing_hook_functions
+
+   how-to/existingtestsuite
+   how-to/unittest
+   how-to/nose
+   how-to/xunit_setup
+
+   how-to/bash-completion
+
+
+Reference guides
+-----------------
+
+.. toctree::
+   :maxdepth: 2
+
+   reference/fixtures
+   reference/plugin_list
+   reference/customize
+   reference/reference
+
+
+Explanation
+-----------------
+
+.. toctree::
+   :maxdepth: 2
+
+   explanation/anatomy
+   explanation/fixtures
+   explanation/goodpractices
+   explanation/flaky
+   explanation/pythonpath
+
+
+Further topics
+-----------------
+
+.. toctree::
+   :maxdepth: 2
+
    example/index
-   bash-completion
 
    backwards-compatibility
    deprecations
-   py27-py34-deprecation
 
    contributing
    development_guide
@@ -51,9 +94,9 @@ Full pytest documentation
    license
    contact
 
+   history
    historical-notes
    talks
-   projects
 
 
 .. only:: html
diff --git a/doc/en/customize.rst b/doc/en/customize.rst
deleted file mode 100644 (file)
index 9f7c365..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-Configuration
-=============
-
-Command line options and configuration file settings
------------------------------------------------------------------
-
-You can get help on command line options and values in INI-style
-configurations files by using the general help option:
-
-.. code-block:: bash
-
-    pytest -h   # prints options _and_ config file settings
-
-This will display command line and configuration file settings
-which were registered by installed plugins.
-
-.. _`config file formats`:
-
-Configuration file formats
---------------------------
-
-Many :ref:`pytest settings <ini options ref>` can be set in a *configuration file*, which
-by convention resides on the root of your repository or in your
-tests folder.
-
-A quick example of the configuration files supported by pytest:
-
-pytest.ini
-~~~~~~~~~~
-
-``pytest.ini`` files take precedence over other files, even when empty.
-
-.. code-block:: ini
-
-    # pytest.ini
-    [pytest]
-    minversion = 6.0
-    addopts = -ra -q
-    testpaths =
-        tests
-        integration
-
-
-pyproject.toml
-~~~~~~~~~~~~~~
-
-.. versionadded:: 6.0
-
-``pyproject.toml`` are considered for configuration when they contain a ``tool.pytest.ini_options`` table.
-
-.. code-block:: toml
-
-    # pyproject.toml
-    [tool.pytest.ini_options]
-    minversion = "6.0"
-    addopts = "-ra -q"
-    testpaths = [
-        "tests",
-        "integration",
-    ]
-
-.. note::
-
-    One might wonder why ``[tool.pytest.ini_options]`` instead of ``[tool.pytest]`` as is the
-    case with other tools.
-
-    The reason is that the pytest team intends to fully utilize the rich TOML data format
-    for configuration in the future, reserving the ``[tool.pytest]`` table for that.
-    The ``ini_options`` table is being used, for now, as a bridge between the existing
-    ``.ini`` configuration system and the future configuration format.
-
-tox.ini
-~~~~~~~
-
-``tox.ini`` files are the configuration files of the `tox <https://tox.readthedocs.io>`__ project,
-and can also be used to hold pytest configuration if they have a ``[pytest]`` section.
-
-.. code-block:: ini
-
-    # tox.ini
-    [pytest]
-    minversion = 6.0
-    addopts = -ra -q
-    testpaths =
-        tests
-        integration
-
-
-setup.cfg
-~~~~~~~~~
-
-``setup.cfg`` files are general purpose configuration files, used originally by `distutils <https://docs.python.org/3/distutils/configfile.html>`__, and can also be used to hold pytest configuration
-if they have a ``[tool:pytest]`` section.
-
-.. code-block:: ini
-
-    # setup.cfg
-    [tool:pytest]
-    minversion = 6.0
-    addopts = -ra -q
-    testpaths =
-        tests
-        integration
-
-.. warning::
-
-    Usage of ``setup.cfg`` is not recommended unless for very simple use cases. ``.cfg``
-    files use a different parser than ``pytest.ini`` and ``tox.ini`` which might cause hard to track
-    down problems.
-    When possible, it is recommended to use the latter files, or ``pyproject.toml``, to hold your
-    pytest configuration.
-
-
-.. _rootdir:
-.. _configfiles:
-
-Initialization: determining rootdir and configfile
---------------------------------------------------
-
-pytest determines a ``rootdir`` for each test run which depends on
-the command line arguments (specified test files, paths) and on
-the existence of configuration files.  The determined ``rootdir`` and ``configfile`` are
-printed as part of the pytest header during startup.
-
-Here's a summary what ``pytest`` uses ``rootdir`` for:
-
-* Construct *nodeids* during collection; each test is assigned
-  a unique *nodeid* which is rooted at the ``rootdir`` and takes into account
-  the full path, class name, function name and parametrization (if any).
-
-* Is used by plugins as a stable location to store project/test run specific information;
-  for example, the internal :ref:`cache <cache>` plugin creates a ``.pytest_cache`` subdirectory
-  in ``rootdir`` to store its cross-test run state.
-
-``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
-influence how modules are imported. See :ref:`pythonpath` for more details.
-
-The ``--rootdir=path`` command-line option can be used to force a specific directory.
-Note that contrary to other command-line options, ``--rootdir`` cannot be used with
-:confval:`addopts` inside ``pytest.ini`` because the ``rootdir`` is used to *find* ``pytest.ini``
-already.
-
-Finding the ``rootdir``
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Here is the algorithm which finds the rootdir from ``args``:
-
-- Determine the common ancestor directory for the specified ``args`` that are
-  recognised as paths that exist in the file system. If no such paths are
-  found, the common ancestor directory is set to the current working directory.
-
-- Look for ``pytest.ini``, ``pyproject.toml``, ``tox.ini``, and ``setup.cfg`` files in the ancestor
-  directory and upwards.  If one is matched, it becomes the ``configfile`` and its
-  directory becomes the ``rootdir``.
-
-- If no configuration file was found, look for ``setup.py`` upwards from the common
-  ancestor directory to determine the ``rootdir``.
-
-- If no ``setup.py`` was found, look for ``pytest.ini``, ``pyproject.toml``, ``tox.ini``, and
-  ``setup.cfg`` in each of the specified ``args`` and upwards. If one is
-  matched, it becomes the ``configfile`` and its directory becomes the ``rootdir``.
-
-- If no ``configfile`` was found, use the already determined common ancestor as root
-  directory. This allows the use of pytest in structures that are not part of
-  a package and don't have any particular configuration file.
-
-If no ``args`` are given, pytest collects test below the current working
-directory and also starts determining the ``rootdir`` from there.
-
-Files will only be matched for configuration if:
-
-* ``pytest.ini``: will always match and take precedence, even if empty.
-* ``pyproject.toml``: contains a ``[tool.pytest.ini_options]`` table.
-* ``tox.ini``: contains a ``[pytest]`` section.
-* ``setup.cfg``: contains a ``[tool:pytest]`` section.
-
-The files are considered in the order above. Options from multiple ``configfiles`` candidates
-are never merged - the first match wins.
-
-The internal :class:`Config <_pytest.config.Config>` object (accessible via hooks or through the :fixture:`pytestconfig` fixture)
-will subsequently carry these attributes:
-
-- :attr:`config.rootpath <_pytest.config.Config.rootpath>`: the determined root directory, guaranteed to exist.
-
-- :attr:`config.inipath <_pytest.config.Config.inipath>`: the determined ``configfile``, may be ``None``
-  (it is named ``inipath`` for historical reasons).
-
-.. versionadded:: 6.1
-    The ``config.rootpath`` and ``config.inipath`` properties. They are :class:`pathlib.Path`
-    versions of the older ``config.rootdir`` and ``config.inifile``, which have type
-    ``py.path.local``, and still exist for backward compatibility.
-
-The ``rootdir`` is used as a reference directory for constructing test
-addresses ("nodeids") and can be used also by plugins for storing
-per-testrun information.
-
-Example:
-
-.. code-block:: bash
-
-    pytest path/to/testdir path/other/
-
-will determine the common ancestor as ``path`` and then
-check for configuration files as follows:
-
-.. code-block:: text
-
-    # first look for pytest.ini files
-    path/pytest.ini
-    path/pyproject.toml  # must contain a [tool.pytest.ini_options] table to match
-    path/tox.ini         # must contain [pytest] section to match
-    path/setup.cfg       # must contain [tool:pytest] section to match
-    pytest.ini
-    ... # all the way up to the root
-
-    # now look for setup.py
-    path/setup.py
-    setup.py
-    ... # all the way up to the root
-
-
-.. warning::
-
-    Custom pytest plugin commandline arguments may include a path, as in
-    ``pytest --log-output ../../test.log args``. Then ``args`` is mandatory,
-    otherwise pytest uses the folder of test.log for rootdir determination
-    (see also `issue 1435 <https://github.com/pytest-dev/pytest/issues/1435>`_).
-    A dot ``.`` for referencing to the current working directory is also
-    possible.
-
-
-.. _`how to change command line options defaults`:
-.. _`adding default options`:
-
-
-Builtin configuration file options
-----------------------------------------------
-
-For the full list of options consult the :ref:`reference documentation <ini options ref>`.
index 5ef1053e0b41fab77de51ae0b93fec82018475a6..4f7830a27913f6927811740bc6801c399e831f9c 100644 (file)
@@ -16,7 +16,433 @@ Deprecated Features
 -------------------
 
 Below is a complete list of all pytest features which are considered deprecated. Using those features will issue
-:class:`PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
+:class:`~pytest.PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
+
+
+.. _nose-deprecation:
+
+Support for tests written for nose
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.2
+
+Support for running tests written for `nose <https://nose.readthedocs.io/en/latest/>`__ is now deprecated.
+
+``nose`` has been in maintenance mode-only for years, and maintaining the plugin is not trivial as it spills
+over the code base (see :issue:`9886` for more details).
+
+setup/teardown
+^^^^^^^^^^^^^^
+
+One thing that might catch users by surprise is that plain ``setup`` and ``teardown`` methods are not pytest native,
+they are in fact part of the ``nose`` support.
+
+
+.. code-block:: python
+
+    class Test:
+        def setup(self):
+            self.resource = make_resource()
+
+        def teardown(self):
+            self.resource.close()
+
+        def test_foo(self):
+            ...
+
+        def test_bar(self):
+            ...
+
+
+
+Native pytest support uses ``setup_method`` and ``teardown_method`` (see :ref:`xunit-method-setup`), so the above should be changed to:
+
+.. code-block:: python
+
+    class Test:
+        def setup_method(self):
+            self.resource = make_resource()
+
+        def teardown_method(self):
+            self.resource.close()
+
+        def test_foo(self):
+            ...
+
+        def test_bar(self):
+            ...
+
+
+This is easy to do in an entire code base by doing a simple find/replace.
+
+@with_setup
+^^^^^^^^^^^
+
+Code using `@with_setup <with-setup-nose>`_ such as this:
+
+.. code-block:: python
+
+    from nose.tools import with_setup
+
+
+    def setup_some_resource():
+        ...
+
+
+    def teardown_some_resource():
+        ...
+
+
+    @with_setup(setup_some_resource, teardown_some_resource)
+    def test_foo():
+        ...
+
+Will also need to be ported to a supported pytest style. One way to do it is using a fixture:
+
+.. code-block:: python
+
+    import pytest
+
+
+    def setup_some_resource():
+        ...
+
+
+    def teardown_some_resource():
+        ...
+
+
+    @pytest.fixture
+    def some_resource():
+        setup_some_resource()
+        yield
+        teardown_some_resource()
+
+
+    def test_foo(some_resource):
+        ...
+
+
+.. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
+
+.. _instance-collector-deprecation:
+
+The ``pytest.Instance`` collector
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. versionremoved:: 7.0
+
+The ``pytest.Instance`` collector type has been removed.
+
+Previously, Python test methods were collected as :class:`~pytest.Class` -> ``Instance`` -> :class:`~pytest.Function`.
+Now :class:`~pytest.Class` collects the test methods directly.
+
+Most plugins which reference ``Instance`` do so in order to ignore or skip it,
+using a check such as ``if isinstance(node, Instance): return``.
+Such plugins should simply remove consideration of ``Instance`` on pytest>=7.
+However, to keep such uses working, a dummy type has been instanted in ``pytest.Instance`` and ``_pytest.python.Instance``,
+and importing it emits a deprecation warning. This will be removed in pytest 8.
+
+
+.. _node-ctor-fspath-deprecation:
+
+``fspath`` argument for Node constructors replaced with ``pathlib.Path``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+In order to support the transition from ``py.path.local`` to :mod:`pathlib`,
+the ``fspath`` argument to :class:`~_pytest.nodes.Node` constructors like
+:func:`pytest.Function.from_parent()` and :func:`pytest.Class.from_parent()`
+is now deprecated.
+
+Plugins which construct nodes should pass the ``path`` argument, of type
+:class:`pathlib.Path`, instead of the ``fspath`` argument.
+
+Plugins which implement custom items and collectors are encouraged to replace
+``fspath`` parameters (``py.path.local``) with ``path`` parameters
+(``pathlib.Path``), and drop any other usage of the ``py`` library if possible.
+
+If possible, plugins with custom items should use :ref:`cooperative
+constructors <uncooperative-constructors-deprecated>` to avoid hardcoding
+arguments they only pass on to the superclass.
+
+.. note::
+    The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
+    new attribute being ``path``) is **the opposite** of the situation for
+    hooks, :ref:`outlined below <legacy-path-hooks-deprecated>` (the old
+    argument being ``path``).
+
+    This is an unfortunate artifact due to historical reasons, which should be
+    resolved in future versions as we slowly get rid of the :pypi:`py`
+    dependency (see :issue:`9283` for a longer discussion).
+
+Due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`
+which still is expected to return a ``py.path.local`` object, nodes still have
+both ``fspath`` (``py.path.local``) and ``path`` (``pathlib.Path``) attributes,
+no matter what argument was used in the constructor. We expect to deprecate the
+``fspath`` attribute in a future release.
+
+.. _legacy-path-hooks-deprecated:
+
+Configuring hook specs/impls using markers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Before pluggy, pytest's plugin library, was its own package and had a clear API,
+pytest just used ``pytest.mark`` to configure hooks.
+
+The :py:func:`pytest.hookimpl` and :py:func:`pytest.hookspec` decorators
+have been available since years and should be used instead.
+
+.. code-block:: python
+
+    @pytest.mark.tryfirst
+    def pytest_runtest_call():
+        ...
+
+
+    # or
+    def pytest_runtest_call():
+        ...
+
+
+    pytest_runtest_call.tryfirst = True
+
+should be changed to:
+
+.. code-block:: python
+
+    @pytest.hookimpl(tryfirst=True)
+    def pytest_runtest_call():
+        ...
+
+Changed ``hookimpl`` attributes:
+
+* ``tryfirst``
+* ``trylast``
+* ``optionalhook``
+* ``hookwrapper``
+
+Changed ``hookwrapper`` attributes:
+
+* ``firstresult``
+* ``historic``
+
+
+``py.path.local`` arguments for hooks replaced with ``pathlib.Path``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+In order to support the transition from ``py.path.local`` to :mod:`pathlib`, the following hooks now receive additional arguments:
+
+*  :hook:`pytest_ignore_collect(collection_path: pathlib.Path) <pytest_ignore_collect>` as equivalent to ``path``
+*  :hook:`pytest_collect_file(file_path: pathlib.Path) <pytest_collect_file>` as equivalent to ``path``
+*  :hook:`pytest_pycollect_makemodule(module_path: pathlib.Path) <pytest_pycollect_makemodule>` as equivalent to ``path``
+*  :hook:`pytest_report_header(start_path: pathlib.Path) <pytest_report_header>` as equivalent to ``startdir``
+*  :hook:`pytest_report_collectionfinish(start_path: pathlib.Path) <pytest_report_collectionfinish>` as equivalent to ``startdir``
+
+The accompanying ``py.path.local`` based paths have been deprecated: plugins which manually invoke those hooks should only pass the new ``pathlib.Path`` arguments, and users should change their hook implementations to use the new ``pathlib.Path`` arguments.
+
+.. note::
+    The name of the :class:`~_pytest.nodes.Node` arguments and attributes,
+    :ref:`outlined above <node-ctor-fspath-deprecation>` (the new attribute
+    being ``path``) is **the opposite** of the situation for hooks (the old
+    argument being ``path``).
+
+    This is an unfortunate artifact due to historical reasons, which should be
+    resolved in future versions as we slowly get rid of the :pypi:`py`
+    dependency (see :issue:`9283` for a longer discussion).
+
+Directly constructing internal classes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+Directly constructing the following classes is now deprecated:
+
+- ``_pytest.mark.structures.Mark``
+- ``_pytest.mark.structures.MarkDecorator``
+- ``_pytest.mark.structures.MarkGenerator``
+- ``_pytest.python.Metafunc``
+- ``_pytest.runner.CallInfo``
+- ``_pytest._code.ExceptionInfo``
+- ``_pytest.config.argparsing.Parser``
+- ``_pytest.config.argparsing.OptionGroup``
+- ``_pytest.pytester.HookRecorder``
+
+These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.
+
+.. _cmdline-preparse-deprecated:
+
+Passing ``msg=`` to ``pytest.skip``, ``pytest.fail`` or ``pytest.exit``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+Passing the keyword argument ``msg`` to :func:`pytest.skip`, :func:`pytest.fail` or :func:`pytest.exit`
+is now deprecated and ``reason`` should be used instead.  This change is to bring consistency between these
+functions and the ``@pytest.mark.skip`` and ``@pytest.mark.xfail`` markers which already accept a ``reason`` argument.
+
+.. code-block:: python
+
+    def test_fail_example():
+        # old
+        pytest.fail(msg="foo")
+        # new
+        pytest.fail(reason="bar")
+
+
+    def test_skip_example():
+        # old
+        pytest.skip(msg="foo")
+        # new
+        pytest.skip(reason="bar")
+
+
+    def test_exit_example():
+        # old
+        pytest.exit(msg="foo")
+        # new
+        pytest.exit(reason="bar")
+
+
+Implementing the ``pytest_cmdline_preparse`` hook
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+Implementing the :hook:`pytest_cmdline_preparse` hook has been officially deprecated.
+Implement the :hook:`pytest_load_initial_conftests` hook instead.
+
+.. code-block:: python
+
+    def pytest_cmdline_preparse(config: Config, args: List[str]) -> None:
+        ...
+
+
+    # becomes:
+
+
+    def pytest_load_initial_conftests(
+        early_config: Config, parser: Parser, args: List[str]
+    ) -> None:
+        ...
+
+.. _diamond-inheritance-deprecated:
+
+Diamond inheritance between :class:`pytest.Collector` and :class:`pytest.Item`
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` (e.g. :class:`pytest.File <File>`) now issues a warning.
+It was never sanely supported and triggers hard to debug errors.
+
+Some plugins providing linting/code analysis have been using this as a hack.
+Instead, a separate collector node should be used, which collects the item. See
+:ref:`non-python tests` for an example, as well as an `example pr fixing inheritance`_.
+
+.. _example pr fixing inheritance: https://github.com/asmeurer/pytest-flakes/pull/40/files
+
+
+.. _uncooperative-constructors-deprecated:
+
+Constructors of custom :class:`pytest.Node` subclasses should take ``**kwargs``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+If custom subclasses of nodes like :class:`pytest.Item` override the
+``__init__`` method, they should take ``**kwargs``. Thus,
+
+.. code-block:: python
+
+    class CustomItem(pytest.Item):
+        def __init__(self, name, parent, additional_arg):
+            super().__init__(name, parent)
+            self.additional_arg = additional_arg
+
+should be turned into:
+
+.. code-block:: python
+
+    class CustomItem(pytest.Item):
+        def __init__(self, *, additional_arg, **kwargs):
+            super().__init__(**kwargs)
+            self.additional_arg = additional_arg
+
+to avoid hard-coding the arguments pytest can pass to the superclass.
+See :ref:`non-python tests` for a full example.
+
+For cases without conflicts, no deprecation warning is emitted. For cases with
+conflicts (such as :class:`pytest.File` now taking ``path`` instead of
+``fspath``, as :ref:`outlined above <node-ctor-fspath-deprecation>`), a
+deprecation warning is now raised.
+
+Backward compatibilities in ``Parser.addoption``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 2.4
+
+Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
+scheduled for removal in pytest 8 (deprecated since pytest 2.4.0):
+
+- ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
+- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
+
+
+Using ``pytest.warns(None)``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.0
+
+:func:`pytest.warns(None) <pytest.warns>` is now deprecated because it was frequently misused.
+Its correct usage was checking that the code emits at least one warning of any type - like ``pytest.warns()``
+or ``pytest.warns(Warning)``.
+
+See :ref:`warns use cases` for examples.
+
+
+Returning non-None value in test functions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 7.2
+
+A :class:`pytest.PytestReturnNotNoneWarning` is now emitted if a test function returns something other than `None`.
+
+This prevents a common mistake among beginners that expect that returning a `bool` would cause a test to pass or fail, for example:
+
+.. code-block:: python
+
+    @pytest.mark.parametrize(
+        ["a", "b", "result"],
+        [
+            [1, 2, 5],
+            [2, 3, 8],
+            [5, 3, 18],
+        ],
+    )
+    def test_foo(a, b, result):
+        return foo(a, b) == result
+
+Given that pytest ignores the return value, this might be surprising that it will never fail.
+
+The proper fix is to change the `return` to an `assert`:
+
+.. code-block:: python
+
+    @pytest.mark.parametrize(
+        ["a", "b", "result"],
+        [
+            [1, 2, 5],
+            [2, 3, 8],
+            [5, 3, 18],
+        ],
+    )
+    def test_foo(a, b, result):
+        assert foo(a, b) == result
+
 
 The ``--strict`` command-line option
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -41,29 +467,42 @@ The ``yield_fixture`` function/decorator
 It has been so for a very long time, so can be search/replaced safely.
 
 
-The ``pytest_warning_captured`` hook
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. deprecated:: 6.0
+Removed Features
+----------------
 
-This hook has an `item` parameter which cannot be serialized by ``pytest-xdist``.
+As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
+an appropriate period of deprecation has passed.
 
-Use the ``pytest_warning_recored`` hook instead, which replaces the ``item`` parameter
-by a ``nodeid`` parameter.
 
 The ``pytest.collect`` module
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. deprecated:: 6.0
+.. versionremoved:: 7.0
 
 The ``pytest.collect`` module is no longer part of the public API, all its names
 should now be imported from ``pytest`` directly instead.
 
 
+
+The ``pytest_warning_captured`` hook
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. deprecated:: 6.0
+.. versionremoved:: 7.0
+
+This hook has an `item` parameter which cannot be serialized by ``pytest-xdist``.
+
+Use the ``pytest_warning_recorded`` hook instead, which replaces the ``item`` parameter
+by a ``nodeid`` parameter.
+
+
+
 The ``pytest._fillfuncargs`` function
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 .. deprecated:: 6.0
+.. versionremoved:: 7.0
 
 This function was kept for backward compatibility with an older plugin.
 
@@ -72,12 +511,6 @@ it, use `function._request._fillfixtures()` instead, though note this is not
 a public API and may break in the future.
 
 
-Removed Features
-----------------
-
-As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
-an appropriate period of deprecation has passed.
-
 ``--no-print-logs`` command-line option
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -92,6 +525,7 @@ A ``--show-capture`` command-line option was added in ``pytest 3.5.0`` which all
 display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
 
 
+.. _resultlog deprecated:
 
 Result log (``--result-log``)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -114,8 +548,8 @@ at some point, depending on the plans for the plugins and number of users using
 
 .. versionremoved:: 6.0
 
-The ``pytest_collect_directory`` has not worked properly for years (it was called
-but the results were ignored). Users may consider using :func:`pytest_collection_modifyitems <_pytest.hookspec.pytest_collection_modifyitems>` instead.
+The ``pytest_collect_directory`` hook has not worked properly for years (it was called
+but the results were ignored). Users may consider using :hook:`pytest_collection_modifyitems` instead.
 
 TerminalReporter.writer
 ~~~~~~~~~~~~~~~~~~~~~~~
@@ -129,6 +563,8 @@ with ``py.io.TerminalWriter``.
 Plugins that used ``TerminalReporter.writer`` directly should instead use ``TerminalReporter``
 methods that provide the same functionality.
 
+.. _junit-family changed default value:
+
 ``junit_family`` default value change to "xunit2"
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -216,6 +652,8 @@ in places where we or plugin authors must distinguish between fixture names and
 names supplied by non-fixture things such as ``pytest.mark.parametrize``.
 
 
+.. _pytest.config global deprecated:
+
 ``pytest.config`` global
 ~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -260,7 +698,7 @@ Becomes:
 
 
 If you still have concerns about this deprecation and future removal, please comment on
-`issue #3974 <https://github.com/pytest-dev/pytest/issues/3974>`__.
+:issue:`3974`.
 
 
 .. _raises-warns-exec:
@@ -313,6 +751,8 @@ This issue should affect only advanced plugins who create new collection types,
 message please contact the authors so they can change the code.
 
 
+.. _marks in pytest.parametrize deprecated:
+
 marks in ``pytest.mark.parametrize``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -361,6 +801,8 @@ To update the code, use ``pytest.param``:
         ...
 
 
+.. _pytest_funcarg__ prefix deprecated:
+
 ``pytest_funcarg__`` prefix
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -392,13 +834,15 @@ Switch over to the ``@pytest.fixture`` decorator:
 to avoid conflicts with other distutils commands.
 
 
+.. _metafunc.addcall deprecated:
+
 Metafunc.addcall
 ~~~~~~~~~~~~~~~~
 
 .. versionremoved:: 4.0
 
-``_pytest.python.Metafunc.addcall`` was a precursor to the current parametrized mechanism. Users should use
-:meth:`_pytest.python.Metafunc.parametrize` instead.
+``Metafunc.addcall`` was a precursor to the current parametrized mechanism. Users should use
+:meth:`pytest.Metafunc.parametrize` instead.
 
 Example:
 
@@ -416,6 +860,8 @@ Becomes:
         metafunc.parametrize("i", [1, 2], ids=["1", "2"])
 
 
+.. _cached_setup deprecated:
+
 ``cached_setup``
 ~~~~~~~~~~~~~~~~
 
@@ -444,10 +890,12 @@ This should be updated to make use of standard fixture mechanisms:
         session.close()
 
 
-You can consult `funcarg comparison section in the docs <https://docs.pytest.org/en/stable/funcarg_compare.html>`_ for
+You can consult :std:doc:`funcarg comparison section in the docs <funcarg_compare>` for
 more information.
 
 
+.. _pytest_plugins in non-top-level conftest files deprecated:
+
 pytest_plugins in non-top-level conftest files
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -458,6 +906,8 @@ files because they will activate referenced plugins *globally*, which is surpris
 features ``conftest.py`` files are only *active* for tests at or below it.
 
 
+.. _config.warn and node.warn deprecated:
+
 ``Config.warn`` and ``Node.warn``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -485,6 +935,8 @@ Becomes:
 
 * ``node.warn("CI", "some message")``: this code/message form has been **removed** and should be converted to the warning instance form above.
 
+.. _record_xml_property deprecated:
+
 record_xml_property
 ~~~~~~~~~~~~~~~~~~~
 
@@ -508,6 +960,8 @@ Change to:
         ...
 
 
+.. _passing command-line string to pytest.main deprecated:
+
 Passing command-line string to ``pytest.main()``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -530,6 +984,8 @@ By passing a string, users expect that pytest will interpret that command-line u
 on (for example ``bash`` or ``Powershell``), but this is very hard/impossible to do in a portable way.
 
 
+.. _calling fixtures directly deprecated:
+
 Calling fixtures directly
 ~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -583,6 +1039,8 @@ with the ``name`` parameter:
         return cell()
 
 
+.. _yield tests deprecated:
+
 ``yield`` tests
 ~~~~~~~~~~~~~~~
 
@@ -594,7 +1052,7 @@ that are then turned into proper test methods. Example:
 .. code-block:: python
 
     def check(x, y):
-        assert x ** x == y
+        assert x**x == y
 
 
     def test_squared():
@@ -609,7 +1067,9 @@ This form of test function doesn't support fixtures properly, and users should s
 
     @pytest.mark.parametrize("x, y", [(2, 4), (3, 9)])
     def test_squared(x, y):
-        assert x ** x == y
+        assert x**x == y
+
+.. _internal classes accessed through node deprecated:
 
 Internal classes accessed through ``Node``
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -645,6 +1105,8 @@ As part of a large :ref:`marker-revamp` we already deprecated using ``MarkInfo``
 the only correct way to get markers of an element is via ``node.iter_markers(name)``.
 
 
+.. _pytest.namespace deprecated:
+
 ``pytest_namespace``
 ~~~~~~~~~~~~~~~~~~~~
 
index 77076d4834ef0bd3689673a0e4cc696e47e60474..3ee0ebbc239243ed0ad45d0f711ed516a4b10c77 100644 (file)
@@ -4,4 +4,4 @@ Development Guide
 
 The contributing guidelines are to be found :ref:`here <contributing>`.
 The release procedure for pytest is documented on
-`GitHub <https://github.com/pytest-dev/pytest/blob/master/RELEASING.rst>`_.
+`GitHub <https://github.com/pytest-dev/pytest/blob/main/RELEASING.rst>`_.
diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst
deleted file mode 100644 (file)
index f8d0106..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-
-Doctest integration for modules and test files
-=========================================================
-
-By default, all files matching the ``test*.txt`` pattern will
-be run through the python standard ``doctest`` module.  You
-can change the pattern by issuing:
-
-.. code-block:: bash
-
-    pytest --doctest-glob="*.rst"
-
-on the command line. ``--doctest-glob`` can be given multiple times in the command-line.
-
-If you then have a text file like this:
-
-.. code-block:: text
-
-    # content of test_example.txt
-
-    hello this is a doctest
-    >>> x = 3
-    >>> x
-    3
-
-then you can just invoke ``pytest`` directly:
-
-.. code-block:: pytest
-
-    $ pytest
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 1 item
-
-    test_example.txt .                                                   [100%]
-
-    ============================ 1 passed in 0.12s =============================
-
-By default, pytest will collect ``test*.txt`` files looking for doctest directives, but you
-can pass additional globs using the ``--doctest-glob`` option (multi-allowed).
-
-In addition to text files, you can also execute doctests directly from docstrings of your classes
-and functions, including from test modules:
-
-.. code-block:: python
-
-    # content of mymodule.py
-    def something():
-        """ a doctest in a docstring
-        >>> something()
-        42
-        """
-        return 42
-
-.. code-block:: bash
-
-    $ pytest --doctest-modules
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 2 items
-
-    mymodule.py .                                                        [ 50%]
-    test_example.txt .                                                   [100%]
-
-    ============================ 2 passed in 0.12s =============================
-
-You can make these changes permanent in your project by
-putting them into a pytest.ini file like this:
-
-.. code-block:: ini
-
-    # content of pytest.ini
-    [pytest]
-    addopts = --doctest-modules
-
-
-Encoding
---------
-
-The default encoding is **UTF-8**, but you can specify the encoding
-that will be used for those doctest files using the
-``doctest_encoding`` ini option:
-
-.. code-block:: ini
-
-    # content of pytest.ini
-    [pytest]
-    doctest_encoding = latin1
-
-Using 'doctest' options
------------------------
-
-Python's standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
-to configure the strictness of doctest tests. In pytest, you can enable those flags using the
-configuration file.
-
-For example, to make pytest ignore trailing whitespaces and ignore
-lengthy exception stack traces you can just write:
-
-.. code-block:: ini
-
-    [pytest]
-    doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
-
-Alternatively, options can be enabled by an inline comment in the doc test
-itself:
-
-.. code-block:: rst
-
-    >>> something_that_raises()  # doctest: +IGNORE_EXCEPTION_DETAIL
-    Traceback (most recent call last):
-    ValueError: ...
-
-pytest also introduces new options:
-
-* ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode
-  strings in expected doctest output. This allows doctests to run in Python 2
-  and Python 3 unchanged.
-
-* ``ALLOW_BYTES``: similarly, the ``b`` prefix is stripped from byte strings
-  in expected doctest output.
-
-* ``NUMBER``: when enabled, floating-point numbers only need to match as far as
-  the precision you have written in the expected doctest output. For example,
-  the following output would only need to match to 2 decimal places::
-
-      >>> math.pi
-      3.14
-
-  If you wrote ``3.1416`` then the actual output would need to match to 4
-  decimal places; and so on.
-
-  This avoids false positives caused by limited floating-point precision, like
-  this::
-
-      Expected:
-          0.233
-      Got:
-          0.23300000000000001
-
-  ``NUMBER`` also supports lists of floating-point numbers -- in fact, it
-  matches floating-point numbers appearing anywhere in the output, even inside
-  a string! This means that it may not be appropriate to enable globally in
-  ``doctest_optionflags`` in your configuration file.
-
-  .. versionadded:: 5.1
-
-
-Continue on failure
--------------------
-
-By default, pytest would report only the first failure for a given doctest. If
-you want to continue the test even when you have failures, do:
-
-.. code-block:: bash
-
-    pytest --doctest-modules --doctest-continue-on-failure
-
-
-Output format
--------------
-
-You can change the diff output format on failure for your doctests
-by using one of standard doctest modules format in options
-(see :data:`python:doctest.REPORT_UDIFF`, :data:`python:doctest.REPORT_CDIFF`,
-:data:`python:doctest.REPORT_NDIFF`, :data:`python:doctest.REPORT_ONLY_FIRST_FAILURE`):
-
-.. code-block:: bash
-
-    pytest --doctest-modules --doctest-report none
-    pytest --doctest-modules --doctest-report udiff
-    pytest --doctest-modules --doctest-report cdiff
-    pytest --doctest-modules --doctest-report ndiff
-    pytest --doctest-modules --doctest-report only_first_failure
-
-
-pytest-specific features
-------------------------
-
-Some features are provided to make writing doctests easier or with better integration with
-your existing test suite. Keep in mind however that by using those features you will make
-your doctests incompatible with the standard ``doctests`` module.
-
-Using fixtures
-^^^^^^^^^^^^^^
-
-It is possible to use fixtures using the ``getfixture`` helper:
-
-.. code-block:: text
-
-    # content of example.rst
-    >>> tmp = getfixture('tmpdir')
-    >>> ...
-    >>>
-
-Note that the fixture needs to be defined in a place visible by pytest, for example, a `conftest.py`
-file or plugin; normal python files containing docstrings are not normally scanned for fixtures
-unless explicitly configured by :confval:`python_files`.
-
-Also, the :ref:`usefixtures <usefixtures>` mark and fixtures marked as :ref:`autouse <autouse>` are supported
-when executing text doctest files.
-
-
-.. _`doctest_namespace`:
-
-'doctest_namespace' fixture
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``doctest_namespace`` fixture can be used to inject items into the
-namespace in which your doctests run. It is intended to be used within
-your own fixtures to provide the tests that use them with context.
-
-``doctest_namespace`` is a standard ``dict`` object into which you
-place the objects you want to appear in the doctest namespace:
-
-.. code-block:: python
-
-    # content of conftest.py
-    import numpy
-
-
-    @pytest.fixture(autouse=True)
-    def add_np(doctest_namespace):
-        doctest_namespace["np"] = numpy
-
-which can then be used in your doctests directly:
-
-.. code-block:: python
-
-    # content of numpy.py
-    def arange():
-        """
-        >>> a = np.arange(10)
-        >>> len(a)
-        10
-        """
-        pass
-
-Note that like the normal ``conftest.py``, the fixtures are discovered in the directory tree conftest is in.
-Meaning that if you put your doctest with your source code, the relevant conftest.py needs to be in the same directory tree.
-Fixtures will not be discovered in a sibling directory tree!
-
-Skipping tests
-^^^^^^^^^^^^^^
-
-For the same reasons one might want to skip normal tests, it is also possible to skip
-tests inside doctests.
-
-To skip a single check inside a doctest you can use the standard
-`doctest.SKIP <https://docs.python.org/3/library/doctest.html#doctest.SKIP>`__ directive:
-
-.. code-block:: python
-
-    def test_random(y):
-        """
-        >>> random.random()  # doctest: +SKIP
-        0.156231223
-
-        >>> 1 + 1
-        2
-        """
-
-This will skip the first check, but not the second.
-
-pytest also allows using the standard pytest functions :func:`pytest.skip` and
-:func:`pytest.xfail` inside doctests, which might be useful because you can
-then skip/xfail tests based on external conditions:
-
-
-.. code-block:: text
-
-    >>> import sys, pytest
-    >>> if sys.platform.startswith('win'):
-    ...     pytest.skip('this doctest does not work on Windows')
-    ...
-    >>> import fcntl
-    >>> ...
-
-However using those functions is discouraged because it reduces the readability of the
-docstring.
-
-.. note::
-
-    :func:`pytest.skip` and :func:`pytest.xfail` behave differently depending
-    if the doctests are in a Python file (in docstrings) or a text file containing
-    doctests intermingled with text:
-
-    * Python modules (docstrings): the functions only act in that specific docstring,
-      letting the other docstrings in the same module execute as normal.
-
-    * Text files: the functions will skip/xfail the checks for the rest of the entire
-      file.
-
-
-Alternatives
-------------
-
-While the built-in pytest support provides a good set of functionalities for using
-doctests, if you use them extensively you might be interested in those external packages
-which add many more features, and include pytest integration:
-
-* `pytest-doctestplus <https://github.com/astropy/pytest-doctestplus>`__: provides
-  advanced doctest support and enables the testing of reStructuredText (".rst") files.
-
-* `Sybil <https://sybil.readthedocs.io>`__: provides a way to test examples in
-  your documentation by parsing them from the documentation source and evaluating
-  the parsed examples as part of your normal test run.
index eda06dfc5984ae586cfb29a53896524e4f53056c..350518b43c76af35adc9fd56a403a7dbfd49671d 100644 (file)
@@ -5,9 +5,9 @@ failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py")
 pytest_plugins = ("pytester",)
 
 
-def test_failure_demo_fails_properly(testdir):
-    target = testdir.tmpdir.join(os.path.basename(failure_demo))
+def test_failure_demo_fails_properly(pytester):
+    target = pytester.path.joinpath(os.path.basename(failure_demo))
     shutil.copy(failure_demo, target)
-    result = testdir.runpytest(target, syspathinsert=True)
+    result = pytester.runpytest(target, syspathinsert=True)
     result.stdout.fnmatch_lines(["*44 failed*"])
     assert result.ret != 0
index 2ea870062043591c0910cc50000016e76e1cbdbf..2b1f2766dce789ce59f31abd1c47b8ce5a32e688 100644 (file)
@@ -25,7 +25,7 @@ example: specifying and selecting acceptance tests
             self.tmpdir = request.config.mktemp(request.function.__name__, numbered=True)
 
         def run(self, *cmd):
-            """ called by test code to execute an acceptance test. """
+            """called by test code to execute an acceptance test."""
             self.tmpdir.chdir()
             return subprocess.check_output(cmd).decode()
 
index 3ca28447c45c8680a0810f5e018c42bedfd96f6d..066caac344909f56c8691e8e245ca3e01f7d995b 100644 (file)
@@ -1,4 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="572" height="542">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="572" height="542">
     <style>
         text {
             font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
@@ -37,7 +37,7 @@
         <path d="M 26,271 A 260 260 0 0 1 546 271" id="testp"/>
     </defs>
     <text class="package">
-        <textPath href="#testp" startOffset="50%">tests</textPath>
+        <textPath xlink:href="#testp" startOffset="50%">tests</textPath>
     </text>
 
     <!-- subpackage -->
@@ -47,7 +47,7 @@
         <path d="M 56,271 A 130 130 0 0 1 316 271" id="subpackage"/>
     </defs>
     <text class="package">
-        <textPath href="#subpackage" startOffset="50%">subpackage</textPath>
+        <textPath xlink:href="#subpackage" startOffset="50%">subpackage</textPath>
     </text>
 
     <!-- test_subpackage.py -->
@@ -57,7 +57,7 @@
         <path d="M 106,311 A 80 80 0 0 1 266 311" id="testSubpackage"/>
     </defs>
     <text class="module">
-        <textPath href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
+        <textPath xlink:href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
     </text>
     <!-- innermost -->
     <line x1="186" x2="186" y1="271" y2="351"/>
         <path d="M 366,271 A 75 75 0 0 1 516 271" id="testTop"/>
     </defs>
     <text class="module">
-        <textPath href="#testTop" startOffset="50%">test_top.py</textPath>
+        <textPath xlink:href="#testTop" startOffset="50%">test_top.py</textPath>
     </text>
     <!-- innermost -->
     <line x1="441" x2="441" y1="306" y2="236"/>
index 88e32d90809c849ab4e9180fb65f336e4388ea87..36e3005507d47c87e42ed8b1e60c8fdcd5f09d7b 100644 (file)
@@ -1,4 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="587" height="382">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="587" height="382">
     <style>
         text {
             font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
@@ -38,7 +38,7 @@
         <path d="M 411,86 A 75 75 0 0 1 561 86" id="pluginA"/>
     </defs>
     <text class="plugin">
-        <textPath href="#pluginA" startOffset="50%">plugin_a</textPath>
+        <textPath xlink:href="#pluginA" startOffset="50%">plugin_a</textPath>
     </text>
     <!-- scope order number -->
     <mask id="pluginAOrderMask">
@@ -55,7 +55,7 @@
         <path d="M 411,296 A 75 75 0 0 1 561 296" id="pluginB"/>
     </defs>
     <text class="plugin">
-        <textPath href="#pluginB" startOffset="50%">plugin_b</textPath>
+        <textPath xlink:href="#pluginB" startOffset="50%">plugin_b</textPath>
     </text>
     <!-- scope order number -->
     <mask id="pluginBOrderMask">
@@ -72,7 +72,7 @@
         <path d="M 11,191 A 180 180 0 0 1 371 191" id="testp"/>
     </defs>
     <text class="package">
-        <textPath href="#testp" startOffset="50%">tests</textPath>
+        <textPath xlink:href="#testp" startOffset="50%">tests</textPath>
     </text>
     <!-- scope order number -->
     <mask id="mainOrderMask">
@@ -89,7 +89,7 @@
         <path d="M 61,231 A 130 130 0 0 1 321 231" id="subpackage"/>
     </defs>
     <text class="package">
-        <textPath href="#subpackage" startOffset="50%">subpackage</textPath>
+        <textPath xlink:href="#subpackage" startOffset="50%">subpackage</textPath>
     </text>
     <!-- scope order number -->
     <mask id="subpackageOrderMask">
         <path d="M 111,271 A 80 80 0 0 1 271 271" id="testSubpackage"/>
     </defs>
     <text class="module">
-        <textPath href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
+        <textPath xlink:href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
     </text>
     <!-- scope order number -->
     <mask id="testSubpackageOrderMask">
diff --git a/doc/en/example/fixtures/test_fixtures_order_autouse_flat.svg b/doc/en/example/fixtures/test_fixtures_order_autouse_flat.svg
new file mode 100644 (file)
index 0000000..03c4598
--- /dev/null
@@ -0,0 +1,56 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="112" height="682">
+    <style>
+        text {
+            font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
+            dominant-baseline: middle;
+            text-anchor: middle;
+            fill: #062886;
+            font-size: medium;
+        }
+        ellipse.fixture, rect.test {
+            fill: #eeffcc;
+            stroke: #007020;
+            stroke-width: 2;
+        }
+        text.fixture {
+            color: #06287e;
+        }
+        circle.class {
+            fill: #c3e0ec;
+            stroke: #0e84b5;
+            stroke-width: 2;
+        }
+        text.class {
+            fill: #0e84b5;
+        }
+        path, line {
+            stroke: black;
+            stroke-width: 2;
+            fill: none;
+        }
+        rect.autouse {
+            fill: #ca7f3d;
+        }
+    </style>
+    <line x1="56" x2="56" y1="681" y2="26" />
+    <ellipse class="fixture" rx="50" ry="25" cx="56" cy="26" />
+    <text x="56" y="26">order</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="96" />
+    <text x="56" y="96">a</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="166" />
+    <text x="56" y="166">b</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="236" />
+    <text x="56" y="236">c</text>
+    <rect class="autouse" width="112" height="40" x="0" y="286" />
+    <text x="56" y="306">autouse</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="376" />
+    <text x="56" y="376">d</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="446" />
+    <text x="56" y="446">e</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="516" />
+    <text x="56" y="516">f</text>
+    <ellipse class="fixture" rx="25" ry="25" cx="56" cy="586" />
+    <text x="56" y="586">g</text>
+    <rect class="test" width="110" height="50" x="1" y="631" />
+    <text x="56" y="656">test_order</text>
+</svg>
index 9f2180fe548ee3b8e8b0e19b9eefb7e9a024c5ac..fe5772993e37fca6258c961dd474349827aaf0fe 100644 (file)
@@ -1,4 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="862" height="402">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="862" height="402">
     <style>
         text {
             font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
@@ -48,7 +48,7 @@
         <path d="M31,201 A 190 190 0 0 1 411 201" id="testClassWith"/>
     </defs>
     <text class="class">
-        <textPath href="#testClassWith" startOffset="50%">TestWithC1Request</textPath>
+        <textPath xlink:href="#testClassWith" startOffset="50%">TestWithC1Request</textPath>
     </text>
 
     <!-- TestWithoutC1Request -->
@@ -67,7 +67,7 @@
         <path d="M451,201 A 190 190 0 0 1 831 201" id="testClassWithout"/>
     </defs>
     <text class="class">
-        <textPath href="#testClassWithout" startOffset="50%">TestWithoutC1Request</textPath>
+        <textPath xlink:href="#testClassWithout" startOffset="50%">TestWithoutC1Request</textPath>
     </text>
 
     <rect class="autouse" width="862" height="40" x="1" y="181" />
index ac62ae46b403897374bc9af8f905b279e9a1a9d1..2a9f51673f6ae0d068898eebdb758df74f37cdbd 100644 (file)
@@ -1,4 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="862" height="502">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="862" height="502">
     <style>
         text {
             font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
@@ -39,7 +39,7 @@
         <path d="M11,251 A 240 240 0 0 1 491 251" id="testClassWith"/>
     </defs>
     <text class="class">
-        <textPath href="#testClassWith" startOffset="50%">TestWithAutouse</textPath>
+        <textPath xlink:href="#testClassWith" startOffset="50%">TestWithAutouse</textPath>
     </text>
     <mask id="autouseScope">
         <circle fill="white" r="249" cx="251" cy="251" />
@@ -79,7 +79,7 @@
         <path d="M 531,251 A 160 160 0 0 1 851 251" id="testClassWithout"/>
     </defs>
     <text class="class">
-        <textPath href="#testClassWithout" startOffset="50%">TestWithoutAutouse</textPath>
+        <textPath xlink:href="#testClassWithout" startOffset="50%">TestWithoutAutouse</textPath>
     </text>
 
     <!-- TestWithoutAutouse.test_req -->
index b3512c2a64dbd4f79d446f4cc6c664acc20d7e4e..e76e3f93c622f3f8085bac318efa485b0acb2eb7 100644 (file)
@@ -17,7 +17,7 @@ def b(a, order):
 
 
 @pytest.fixture
-def c(a, b, order):
+def c(b, order):
     order.append("c")
 
 
index ebaf7e4e245b58282b3c8a6537976d271c7c5035..f38ee60f1fdee5beea879ac02ebfaba7a3c0384a 100644 (file)
@@ -1,4 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="262" height="537">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="262" height="537">
     <style>
         text {
             font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
@@ -50,6 +50,6 @@
         <path d="M131,526 A 120 120 0 0 1 136 286" id="testClass"/>
     </defs>
     <text class="class">
-        <textPath href="#testClass" startOffset="50%">TestClass</textPath>
+        <textPath xlink:href="#testClass" startOffset="50%">TestClass</textPath>
     </text>
 </svg>
index ad98469ced069e6854acc7a74ddb09b176e0391f..0a78a889fd63327649e0327fa5ace7a3380e4126 100644 (file)
@@ -1,4 +1,4 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="562" height="532">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="562" height="532">
     <style>
         text {
             font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
@@ -41,7 +41,7 @@
         <path d="M 26,266 A 255 255 0 0 1 536 266" id="testModule"/>
     </defs>
     <text class="module">
-        <textPath href="#testModule" startOffset="50%">test_fixtures_request_different_scope.py</textPath>
+        <textPath xlink:href="#testModule" startOffset="50%">test_fixtures_request_different_scope.py</textPath>
     </text>
 
     <!-- TestOne -->
@@ -61,7 +61,7 @@
         <path d="M 51,266 A 90 90 0 0 1 231 266" id="testOne"/>
     </defs>
     <text class="class">
-        <textPath href="#testOne" startOffset="50%">TestOne</textPath>
+        <textPath xlink:href="#testOne" startOffset="50%">TestOne</textPath>
     </text>
     <!-- scope order number -->
     <mask id="testOneOrderMask">
@@ -95,7 +95,7 @@
         <path d="M 331,266 A 90 90 0 0 1 511 266" id="testTwo"/>
     </defs>
     <text class="class">
-        <textPath href="#testTwo" startOffset="50%">TestTwo</textPath>
+        <textPath xlink:href="#testTwo" startOffset="50%">TestTwo</textPath>
     </text>
     <!-- scope order number -->
     <mask id="testTwoOrderMask">
index 6876082d41816594b4157b27c37f03b66e88481c..71e855534ff947dca1d86096e8786417f8bcb4c9 100644 (file)
@@ -13,12 +13,12 @@ answers.
 
 For basic examples, see
 
-- :doc:`../getting-started` for basic introductory examples
+- :ref:`get-started` for basic introductory examples
 - :ref:`assert` for basic assertion examples
 - :ref:`Fixtures <fixtures>` for basic fixture/setup examples
 - :ref:`parametrize` for basic test function parametrization
-- :doc:`../unittest` for basic unittest integration
-- :doc:`../nose` for basic nosetests integration
+- :ref:`unittest` for basic unittest integration
+- :ref:`noseintegration` for basic nosetests integration
 
 The following examples aim at various use cases you might encounter.
 
index f0effa0263110524b01e78029c9c13d09afa80a0..55fd1f576cfa9f6d7361896a4b24ea82ddadc521 100644 (file)
@@ -45,9 +45,9 @@ You can then restrict a test run to only run tests marked with ``webtest``:
 
     $ pytest -v -m webtest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 4 items / 3 deselected / 1 selected
 
     test_server.py::test_send_http PASSED                                [100%]
@@ -60,9 +60,9 @@ Or the inverse, running all tests except the webtest ones:
 
     $ pytest -v -m "not webtest"
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 4 items / 1 deselected / 3 selected
 
     test_server.py::test_something_quick PASSED                          [ 33%]
@@ -82,9 +82,9 @@ tests based on their module, class, method, or function name:
 
     $ pytest -v test_server.py::TestClass::test_method
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 1 item
 
     test_server.py::TestClass::test_method PASSED                        [100%]
@@ -97,9 +97,9 @@ You can also select on the class:
 
     $ pytest -v test_server.py::TestClass
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 1 item
 
     test_server.py::TestClass::test_method PASSED                        [100%]
@@ -112,9 +112,9 @@ Or select multiple nodes:
 
     $ pytest -v test_server.py::TestClass test_server.py::test_send_http
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 2 items
 
     test_server.py::TestClass::test_method PASSED                        [ 50%]
@@ -156,9 +156,9 @@ The expression matching is now case-insensitive.
 
     $ pytest -v -k http  # running with the above defined example module
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 4 items / 3 deselected / 1 selected
 
     test_server.py::test_send_http PASSED                                [100%]
@@ -171,9 +171,9 @@ And you can also run all tests except the ones that match the keyword:
 
     $ pytest -k "not send_http" -v
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 4 items / 1 deselected / 3 selected
 
     test_server.py::test_something_quick PASSED                          [ 33%]
@@ -188,9 +188,9 @@ Or to select "http" and "quick" tests:
 
     $ pytest -k "http or quick" -v
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 4 items / 2 deselected / 2 selected
 
     test_server.py::test_send_http PASSED                                [ 50%]
@@ -234,21 +234,21 @@ You can ask which markers exist for your test suite - the list includes our just
 
     @pytest.mark.slow: mark test as slow.
 
-    @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/warnings.html#pytest-mark-filterwarnings
+    @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings
 
     @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.
 
-    @pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipif
+    @pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif
 
-    @pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail
+    @pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail
 
-    @pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/parametrize.html for more info and examples.
+    @pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
 
-    @pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/fixture.html#usefixtures
+    @pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
 
-    @pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.
+    @pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible. DEPRECATED, use @pytest.hookimpl(tryfirst=True) instead.
 
-    @pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible.
+    @pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible. DEPRECATED, use @pytest.hookimpl(trylast=True) instead.
 
 
 For an example on how to add and work with markers from a plugin, see
@@ -346,7 +346,7 @@ Custom marker and command line option to control test runs
 Plugins can provide custom markers and implement specific behaviour
 based on it. This is a self-contained example which adds a command
 line option and a parametrized test function marker to run tests
-specifies via named environments:
+specified via named environments:
 
 .. code-block:: python
 
@@ -375,7 +375,7 @@ specifies via named environments:
         envnames = [mark.args[0] for mark in item.iter_markers(name="env")]
         if envnames:
             if item.config.getoption("-E") not in envnames:
-                pytest.skip("test requires env in {!r}".format(envnames))
+                pytest.skip(f"test requires env in {envnames!r}")
 
 A test file using this local plugin:
 
@@ -397,9 +397,8 @@ the test needs:
 
     $ pytest -E stage2
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 1 item
 
     test_someenv.py s                                                    [100%]
@@ -412,9 +411,8 @@ and here is one that specifies exactly the environment needed:
 
     $ pytest -E stage1
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 1 item
 
     test_someenv.py .                                                    [100%]
@@ -428,21 +426,21 @@ The ``--markers`` option always gives you a list of available markers:
     $ pytest --markers
     @pytest.mark.env(name): mark test to run only on named environment
 
-    @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/warnings.html#pytest-mark-filterwarnings
+    @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings
 
     @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.
 
-    @pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipif
+    @pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif
 
-    @pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail
+    @pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail
 
-    @pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/parametrize.html for more info and examples.
+    @pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
 
-    @pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/fixture.html#usefixtures
+    @pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
 
-    @pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.
+    @pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible. DEPRECATED, use @pytest.hookimpl(tryfirst=True) instead.
 
-    @pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible.
+    @pytest.mark.trylast: mark a hook implementation function such that the plugin machinery will try to call it last/as late as possible. DEPRECATED, use @pytest.hookimpl(trylast=True) instead.
 
 
 .. _`passing callables to custom markers`:
@@ -488,7 +486,7 @@ The output is as follows:
 .. code-block:: pytest
 
     $ pytest -q -s
-    Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef>,), kwargs={})
+    Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef0001>,), kwargs={})
     .
     1 passed in 0.12s
 
@@ -530,7 +528,7 @@ test function.  From a conftest file we can read it like this:
 
     def pytest_runtest_setup(item):
         for mark in item.iter_markers(name="glob"):
-            print("glob args={} kwargs={}".format(mark.args, mark.kwargs))
+            print(f"glob args={mark.args} kwargs={mark.kwargs}")
             sys.stdout.flush()
 
 Let's run this without capturing output and see what we get:
@@ -560,6 +558,7 @@ for your particular platform, you could use the following plugin:
     # content of conftest.py
     #
     import sys
+
     import pytest
 
     ALL = set("darwin linux win32".split())
@@ -569,7 +568,7 @@ for your particular platform, you could use the following plugin:
         supported_platforms = ALL.intersection(mark.name for mark in item.iter_markers())
         plat = sys.platform
         if supported_platforms and plat not in supported_platforms:
-            pytest.skip("cannot run on platform {}".format(plat))
+            pytest.skip(f"cannot run on platform {plat}")
 
 then tests will be skipped if they were specified for a different platform.
 Let's do a little test file to show how this looks like:
@@ -605,15 +604,14 @@ then you will see two tests skipped and two executed tests as expected:
 
     $ pytest -rs # this option reports skip reasons
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items
 
     test_plat.py s.s.                                                    [100%]
 
     ========================= short test summary info ==========================
-    SKIPPED [2] conftest.py:12: cannot run on platform linux
+    SKIPPED [2] conftest.py:13: cannot run on platform linux
     ======================= 2 passed, 2 skipped in 0.12s =======================
 
 Note that if you specify a platform via the marker-command line option like this:
@@ -622,9 +620,8 @@ Note that if you specify a platform via the marker-command line option like this
 
     $ pytest -m linux
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items / 3 deselected / 1 selected
 
     test_plat.py .                                                       [100%]
@@ -686,9 +683,8 @@ We can now use the ``-m option`` to select one set:
 
     $ pytest -m interface --tb=short
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items / 2 deselected / 2 selected
 
     test_module.py FF                                                    [100%]
@@ -713,9 +709,8 @@ or to select both "event" and "interface" tests:
 
     $ pytest -m "interface or event" --tb=short
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items / 1 deselected / 3 selected
 
     test_module.py FFF                                                   [100%]
index 21bddcd0353f05c747dad6295458f842b7e5314c..9005d31adddcd912ea0e1187c9d4234c8b97c04c 100644 (file)
@@ -12,8 +12,8 @@ pythonlist = ["python3.5", "python3.6", "python3.7"]
 
 
 @pytest.fixture(params=pythonlist)
-def python1(request, tmpdir):
-    picklefile = tmpdir.join("data.pickle")
+def python1(request, tmp_path):
+    picklefile = tmp_path / "data.pickle"
     return Python(request.param, picklefile)
 
 
@@ -30,8 +30,8 @@ class Python:
         self.picklefile = picklefile
 
     def dumps(self, obj):
-        dumpfile = self.picklefile.dirpath("dump.py")
-        dumpfile.write(
+        dumpfile = self.picklefile.with_name("dump.py")
+        dumpfile.write_text(
             textwrap.dedent(
                 r"""
                 import pickle
@@ -46,8 +46,8 @@ class Python:
         subprocess.check_call((self.pythonpath, str(dumpfile)))
 
     def load_and_is_true(self, expression):
-        loadfile = self.picklefile.dirpath("load.py")
-        loadfile.write(
+        loadfile = self.picklefile.with_name("load.py")
+        loadfile.write_text(
             textwrap.dedent(
                 r"""
                 import pickle
index a3477fe1e1dcc53c2f0ab0f59b02457b33c672ce..efb701b1f16e78b6724649ea20ddd36dd375af2b 100644 (file)
@@ -9,8 +9,7 @@ Working with non-python tests
 A basic example for specifying tests in Yaml files
 --------------------------------------------------------------
 
-.. _`pytest-yamlwsgi`: http://bitbucket.org/aafshar/pytest-yamlwsgi/src/tip/pytest_yamlwsgi.py
-.. _`PyYAML`: https://pypi.org/project/PyYAML/
+.. _`pytest-yamlwsgi`: https://pypi.org/project/pytest-yamlwsgi/
 
 Here is an example ``conftest.py`` (extracted from Ali Afshar's special purpose `pytest-yamlwsgi`_ plugin).   This ``conftest.py`` will  collect ``test*.yaml`` files and will execute the yaml-formatted content as custom tests:
 
@@ -22,16 +21,15 @@ You can create a simple example file:
 .. include:: nonpython/test_simple.yaml
     :literal:
 
-and if you installed `PyYAML`_ or a compatible YAML-parser you can
+and if you installed :pypi:`PyYAML` or a compatible YAML-parser you can
 now execute the test specification:
 
 .. code-block:: pytest
 
     nonpython $ pytest test_simple.yaml
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR/nonpython
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project/nonpython
     collected 2 items
 
     test_simple.yaml F.                                                  [100%]
@@ -66,9 +64,9 @@ consulted when reporting in ``verbose`` mode:
 
     nonpython $ pytest -v
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR/nonpython
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project/nonpython
     collecting ... collected 2 items
 
     test_simple.yaml::hello FAILED                                       [ 50%]
@@ -92,9 +90,8 @@ interesting to just look at the collection tree:
 
     nonpython $ pytest --collect-only
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR/nonpython
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project/nonpython
     collected 2 items
 
     <Package nonpython>
index bdcc8b76222e2d28d4c1ea771984218d31d25a4f..e969e3e25187c80202bd52af5b78b258a8d7423e 100644 (file)
@@ -2,9 +2,9 @@
 import pytest
 
 
-def pytest_collect_file(parent, path):
-    if path.ext == ".yaml" and path.basename.startswith("test"):
-        return YamlFile.from_parent(parent, fspath=path)
+def pytest_collect_file(parent, file_path):
+    if file_path.suffix == ".yaml" and file_path.name.startswith("test"):
+        return YamlFile.from_parent(parent, path=file_path)
 
 
 class YamlFile(pytest.File):
@@ -12,14 +12,14 @@ class YamlFile(pytest.File):
         # We need a yaml parser, e.g. PyYAML.
         import yaml
 
-        raw = yaml.safe_load(self.fspath.open())
+        raw = yaml.safe_load(self.path.open(encoding="utf-8"))
         for name, spec in sorted(raw.items()):
             yield YamlItem.from_parent(self, name=name, spec=spec)
 
 
 class YamlItem(pytest.Item):
-    def __init__(self, name, parent, spec):
-        super().__init__(name, parent)
+    def __init__(self, *, spec, **kwargs):
+        super().__init__(**kwargs)
         self.spec = spec
 
     def runtest(self):
@@ -38,9 +38,10 @@ class YamlItem(pytest.Item):
                     "   no further details known at this point.",
                 ]
             )
+        return super().repr_failure(excinfo)
 
     def reportinfo(self):
-        return self.fspath, 0, f"usecase: {self.name}"
+        return self.path, 0, f"usecase: {self.name}"
 
 
 class YamlException(Exception):
index 1ab89f2956f10ffe75e6c491206c681562e18b06..df2859b14e0d660e59719663f963f3e9a884ab5c 100644 (file)
@@ -97,10 +97,10 @@ the argument name:
 
     # content of test_time.py
 
-    import pytest
-
     from datetime import datetime, timedelta
 
+    import pytest
+
     testdata = [
         (datetime(2001, 12, 12), datetime(2001, 12, 11), timedelta(1)),
         (datetime(2001, 12, 11), datetime(2001, 12, 12), timedelta(-1)),
@@ -160,9 +160,8 @@ objects, they are still using the default pytest representation:
 
     $ pytest test_time.py --collect-only
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 8 items
 
     <Module test_time.py>
@@ -183,9 +182,7 @@ together with the actual data, instead of listing them separately.
 A quick port of "testscenarios"
 ------------------------------------
 
-.. _`test scenarios`: https://pypi.org/project/testscenarios/
-
-Here is a quick port to run tests configured with `test scenarios`_,
+Here is a quick port to run tests configured with :pypi:`testscenarios`,
 an add-on from Robert Collins for the standard unittest framework. We
 only have to work a bit to construct the correct arguments for pytest's
 :py:func:`Metafunc.parametrize`:
@@ -225,9 +222,8 @@ this is a fully self-contained example which you can run with:
 
     $ pytest test_scenarios.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items
 
     test_scenarios.py ....                                               [100%]
@@ -240,17 +236,16 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia
 
     $ pytest --collect-only test_scenarios.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items
 
     <Module test_scenarios.py>
       <Class TestSampleWithScenarios>
-          <Function test_demo1[basic]>
-          <Function test_demo2[basic]>
-          <Function test_demo1[advanced]>
-          <Function test_demo2[advanced]>
+        <Function test_demo1[basic]>
+        <Function test_demo2[basic]>
+        <Function test_demo1[advanced]>
+        <Function test_demo2[advanced]>
 
     ======================== 4 tests collected in 0.12s ========================
 
@@ -319,9 +314,8 @@ Let's first see how it looks like at collection time:
 
     $ pytest test_backends.py --collect-only
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 2 items
 
     <Module test_backends.py>
@@ -339,7 +333,7 @@ And then when we run the test:
     ================================= FAILURES =================================
     _________________________ test_db_initialized[d2] __________________________
 
-    db = <conftest.DB2 object at 0xdeadbeef>
+    db = <conftest.DB2 object at 0xdeadbeef0001>
 
         def test_db_initialized(db):
             # a dummy test
@@ -418,9 +412,9 @@ The result of this test will be successful:
 
     $ pytest -v test_indirect_list.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 1 item
 
     test_indirect_list.py::test_indirect[a-b] PASSED                     [100%]
@@ -478,7 +472,7 @@ argument sets to use for each test function.  Let's run it:
     ================================= FAILURES =================================
     ________________________ TestClass.test_equals[1-2] ________________________
 
-    self = <test_parametrize.TestClass object at 0xdeadbeef>, a = 1, b = 2
+    self = <test_parametrize.TestClass object at 0xdeadbeef0002>, a = 1, b = 2
 
         def test_equals(self, a, b):
     >       assert a == b
@@ -508,11 +502,12 @@ Running it results in some skips if we don't have all the python interpreters in
 .. code-block:: pytest
 
    . $ pytest -rs -q multipython.py
-   ssssssssssss...ssssssssssss                                          [100%]
+   sssssssssssssssssssssssssss                                          [100%]
    ========================= short test summary info ==========================
-   SKIPPED [12] multipython.py:29: 'python3.5' not found
-   SKIPPED [12] multipython.py:29: 'python3.7' not found
-   3 passed, 24 skipped in 0.12s
+   SKIPPED [9] multipython.py:69: 'python3.5' not found
+   SKIPPED [9] multipython.py:69: 'python3.6' not found
+   SKIPPED [9] multipython.py:69: 'python3.7' not found
+   27 skipped in 0.12s
 
 Indirect parametrization of optional implementations/imports
 --------------------------------------------------------------------
@@ -572,15 +567,14 @@ If you run this with reporting for skips enabled:
 
     $ pytest -rs test_module.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 2 items
 
     test_module.py .s                                                    [100%]
 
     ========================= short test summary info ==========================
-    SKIPPED [1] conftest.py:12: could not import 'opt2': No module named 'opt2'
+    SKIPPED [1] test_module.py:3: could not import 'opt2': No module named 'opt2'
     ======================= 1 passed, 1 skipped in 0.12s =======================
 
 You'll see that we don't have an ``opt2`` module and thus the second test run
@@ -634,9 +628,9 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker:
 
     $ pytest -v -m basic
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
     collecting ... collected 24 items / 21 deselected / 3 selected
 
     test_pytest_param_example.py::test_eval[1+7-8] PASSED                [ 33%]
@@ -663,18 +657,15 @@ Use :func:`pytest.raises` with the
 :ref:`pytest.mark.parametrize ref` decorator to write parametrized tests
 in which some tests raise exceptions and others do not.
 
-It is helpful to define a no-op context manager ``does_not_raise`` to serve
-as a complement to ``raises``. For example:
+It may be helpful to use ``nullcontext`` as a complement to ``raises``.
 
-.. code-block:: python
+For example:
 
-    from contextlib import contextmanager
-    import pytest
+.. code-block:: python
 
+    from contextlib import nullcontext as does_not_raise
 
-    @contextmanager
-    def does_not_raise():
-        yield
+    import pytest
 
 
     @pytest.mark.parametrize(
@@ -693,22 +684,3 @@ as a complement to ``raises``. For example:
 
 In the example above, the first three test cases should run unexceptionally,
 while the fourth should raise ``ZeroDivisionError``.
-
-If you're only supporting Python 3.7+, you can simply use ``nullcontext``
-to define ``does_not_raise``:
-
-.. code-block:: python
-
-    from contextlib import nullcontext as does_not_raise
-
-Or, if you're supporting Python 3.3+ you can use:
-
-.. code-block:: python
-
-    from contextlib import ExitStack as does_not_raise
-
-Or, if desired, you can ``pip install contextlib2`` and use:
-
-.. code-block:: python
-
-    from contextlib2 import nullcontext as does_not_raise
index a6ce2e742e5e68ae307a6c190642618a4d05f4bd..2451e3cab492dae419f87f534c8685a45f2b50ae 100644 (file)
@@ -147,15 +147,15 @@ The test collection would look like this:
 
     $ pytest --collect-only
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    configfile: pytest.ini
     collected 2 items
 
     <Module check_myapp.py>
       <Class CheckMyApp>
-          <Function simple_check>
-          <Function complex_check>
+        <Function simple_check>
+        <Function complex_check>
 
     ======================== 2 tests collected in 0.12s ========================
 
@@ -209,16 +209,16 @@ You can always peek at the collection tree without running tests like this:
 
     . $ pytest --collect-only pythoncollection.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    configfile: pytest.ini
     collected 3 items
 
     <Module CWD/pythoncollection.py>
       <Function test_function>
       <Class TestClass>
-          <Function test_method>
-          <Function test_anothermethod>
+        <Function test_method>
+        <Function test_anothermethod>
 
     ======================== 3 tests collected in 0.12s ========================
 
@@ -291,9 +291,9 @@ file will be left out:
 
     $ pytest --collect-only
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    configfile: pytest.ini
     collected 0 items
 
     ======================= no tests collected in 0.12s ========================
index 6e7dbe496833cc0f56fbcc01ba1108bd89c12252..cb59c4b42e1404e8cd622f25950aa69495889e01 100644 (file)
@@ -9,9 +9,8 @@ Here is a nice run of several failures and how ``pytest`` presents things:
 
     assertion $ pytest failure_demo.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR/assertion
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project/assertion
     collected 44 items
 
     failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF         [100%]
@@ -29,7 +28,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:19: AssertionError
     _________________________ TestFailing.test_simple __________________________
 
-    self = <failure_demo.TestFailing object at 0xdeadbeef>
+    self = <failure_demo.TestFailing object at 0xdeadbeef0001>
 
         def test_simple(self):
             def f():
@@ -40,13 +39,13 @@ Here is a nice run of several failures and how ``pytest`` presents things:
 
     >       assert f() == g()
     E       assert 42 == 43
-    E        +  where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef>()
-    E        +  and   43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef>()
+    E        +  where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef0002>()
+    E        +  and   43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef0003>()
 
     failure_demo.py:30: AssertionError
     ____________________ TestFailing.test_simple_multiline _____________________
 
-    self = <failure_demo.TestFailing object at 0xdeadbeef>
+    self = <failure_demo.TestFailing object at 0xdeadbeef0004>
 
         def test_simple_multiline(self):
     >       otherfunc_multi(42, 6 * 9)
@@ -63,7 +62,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:14: AssertionError
     ___________________________ TestFailing.test_not ___________________________
 
-    self = <failure_demo.TestFailing object at 0xdeadbeef>
+    self = <failure_demo.TestFailing object at 0xdeadbeef0005>
 
         def test_not(self):
             def f():
@@ -71,12 +70,12 @@ Here is a nice run of several failures and how ``pytest`` presents things:
 
     >       assert not f()
     E       assert not 42
-    E        +  where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef>()
+    E        +  where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef0006>()
 
     failure_demo.py:39: AssertionError
     _________________ TestSpecialisedExplanations.test_eq_text _________________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0007>
 
         def test_eq_text(self):
     >       assert "spam" == "eggs"
@@ -87,7 +86,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:44: AssertionError
     _____________ TestSpecialisedExplanations.test_eq_similar_text _____________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0008>
 
         def test_eq_similar_text(self):
     >       assert "foo 1 bar" == "foo 2 bar"
@@ -100,7 +99,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:47: AssertionError
     ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0009>
 
         def test_eq_multiline_text(self):
     >       assert "foo\nspam\nbar" == "foo\neggs\nbar"
@@ -113,7 +112,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:50: AssertionError
     ______________ TestSpecialisedExplanations.test_eq_long_text _______________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000a>
 
         def test_eq_long_text(self):
             a = "1" * 100 + "a" + "2" * 100
@@ -130,7 +129,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:55: AssertionError
     _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000b>
 
         def test_eq_long_text_multiline(self):
             a = "1\n" * 100 + "a" + "2\n" * 100
@@ -145,23 +144,23 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     E           1
     E           1...
     E
-    E         ...Full output truncated (7 lines hidden), use '-vv' to show
+    E         ...Full output truncated (6 lines hidden), use '-vv' to show
 
     failure_demo.py:60: AssertionError
     _________________ TestSpecialisedExplanations.test_eq_list _________________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000c>
 
         def test_eq_list(self):
     >       assert [0, 1, 2] == [0, 1, 3]
     E       assert [0, 1, 2] == [0, 1, 3]
     E         At index 2 diff: 2 != 3
-    E         Use -v to get the full diff
+    E         Use -v to get more diff
 
     failure_demo.py:63: AssertionError
     ______________ TestSpecialisedExplanations.test_eq_list_long _______________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000d>
 
         def test_eq_list_long(self):
             a = [0] * 100 + [1] + [3] * 100
@@ -169,12 +168,12 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     >       assert a == b
     E       assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...]
     E         At index 100 diff: 1 != 2
-    E         Use -v to get the full diff
+    E         Use -v to get more diff
 
     failure_demo.py:68: AssertionError
     _________________ TestSpecialisedExplanations.test_eq_dict _________________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000e>
 
         def test_eq_dict(self):
     >       assert {"a": 0, "b": 1, "c": 0} == {"a": 0, "b": 2, "d": 0}
@@ -185,43 +184,41 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     E         Left contains 1 more item:
     E         {'c': 0}
     E         Right contains 1 more item:
-    E         {'d': 0}...
-    E
-    E         ...Full output truncated (2 lines hidden), use '-vv' to show
+    E         {'d': 0}
+    E         Use -v to get more diff
 
     failure_demo.py:71: AssertionError
     _________________ TestSpecialisedExplanations.test_eq_set __________________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000f>
 
         def test_eq_set(self):
     >       assert {0, 10, 11, 12} == {0, 20, 21}
-    E       AssertionError: assert {0, 10, 11, 12} == {0, 20, 21}
+    E       assert {0, 10, 11, 12} == {0, 20, 21}
     E         Extra items in the left set:
     E         10
     E         11
     E         12
     E         Extra items in the right set:
     E         20
-    E         21...
-    E
-    E         ...Full output truncated (2 lines hidden), use '-vv' to show
+    E         21
+    E         Use -v to get more diff
 
     failure_demo.py:74: AssertionError
     _____________ TestSpecialisedExplanations.test_eq_longer_list ______________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0010>
 
         def test_eq_longer_list(self):
     >       assert [1, 2] == [1, 2, 3]
     E       assert [1, 2] == [1, 2, 3]
     E         Right contains one more item: 3
-    E         Use -v to get the full diff
+    E         Use -v to get more diff
 
     failure_demo.py:77: AssertionError
     _________________ TestSpecialisedExplanations.test_in_list _________________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0011>
 
         def test_in_list(self):
     >       assert 1 in [0, 2, 3, 4, 5]
@@ -230,7 +227,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:80: AssertionError
     __________ TestSpecialisedExplanations.test_not_in_text_multiline __________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0012>
 
         def test_not_in_text_multiline(self):
             text = "some multiline\ntext\nwhich\nincludes foo\nand a\ntail"
@@ -242,14 +239,13 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     E           which
     E           includes foo
     E         ?          +++
-    E           and a...
-    E
-    E         ...Full output truncated (2 lines hidden), use '-vv' to show
+    E           and a
+    E           tail
 
     failure_demo.py:84: AssertionError
     ___________ TestSpecialisedExplanations.test_not_in_text_single ____________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0013>
 
         def test_not_in_text_single(self):
             text = "single foo line"
@@ -262,7 +258,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:88: AssertionError
     _________ TestSpecialisedExplanations.test_not_in_text_single_long _________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0014>
 
         def test_not_in_text_single_long(self):
             text = "head " * 50 + "foo " + "tail " * 20
@@ -275,7 +271,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:92: AssertionError
     ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0015>
 
         def test_not_in_text_single_long_term(self):
             text = "head " * 50 + "f" * 70 + "tail " * 20
@@ -288,7 +284,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:96: AssertionError
     ______________ TestSpecialisedExplanations.test_eq_dataclass _______________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0016>
 
         def test_eq_dataclass(self):
             from dataclasses import dataclass
@@ -308,14 +304,14 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     E         ['b']
     E
     E         Drill down into differing attribute b:
-    E           b: 'b' != 'c'...
-    E
-    E         ...Full output truncated (3 lines hidden), use '-vv' to show
+    E           b: 'b' != 'c'
+    E           - c
+    E           + b
 
     failure_demo.py:108: AssertionError
     ________________ TestSpecialisedExplanations.test_eq_attrs _________________
 
-    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
+    self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0017>
 
         def test_eq_attrs(self):
             import attr
@@ -335,9 +331,9 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     E         ['b']
     E
     E         Drill down into differing attribute b:
-    E           b: 'b' != 'c'...
-    E
-    E         ...Full output truncated (3 lines hidden), use '-vv' to show
+    E           b: 'b' != 'c'
+    E           - c
+    E           + b
 
     failure_demo.py:120: AssertionError
     ______________________________ test_attribute ______________________________
@@ -349,7 +345,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
             i = Foo()
     >       assert i.b == 2
     E       assert 1 == 2
-    E        +  where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef>.b
+    E        +  where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef0018>.b
 
     failure_demo.py:128: AssertionError
     _________________________ test_attribute_instance __________________________
@@ -360,8 +356,8 @@ Here is a nice run of several failures and how ``pytest`` presents things:
 
     >       assert Foo().b == 2
     E       AssertionError: assert 1 == 2
-    E        +  where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef>.b
-    E        +    where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
+    E        +  where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef0019>.b
+    E        +    where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef0019> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
 
     failure_demo.py:135: AssertionError
     __________________________ test_attribute_failure __________________________
@@ -379,7 +375,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:146:
     _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
 
-    self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef>
+    self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef001a>
 
         def _get_b(self):
     >       raise Exception("Failed to get attrib")
@@ -397,15 +393,15 @@ Here is a nice run of several failures and how ``pytest`` presents things:
 
     >       assert Foo().b == Bar().b
     E       AssertionError: assert 1 == 2
-    E        +  where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef>.b
-    E        +    where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
-    E        +  and   2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef>.b
-    E        +    where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
+    E        +  where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef001b>.b
+    E        +    where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef001b> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
+    E        +  and   2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef001c>.b
+    E        +    where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef001c> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
 
     failure_demo.py:156: AssertionError
     __________________________ TestRaises.test_raises __________________________
 
-    self = <failure_demo.TestRaises object at 0xdeadbeef>
+    self = <failure_demo.TestRaises object at 0xdeadbeef001d>
 
         def test_raises(self):
             s = "qwe"
@@ -415,7 +411,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:166: ValueError
     ______________________ TestRaises.test_raises_doesnt _______________________
 
-    self = <failure_demo.TestRaises object at 0xdeadbeef>
+    self = <failure_demo.TestRaises object at 0xdeadbeef001e>
 
         def test_raises_doesnt(self):
     >       raises(OSError, int, "3")
@@ -424,7 +420,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:169: Failed
     __________________________ TestRaises.test_raise ___________________________
 
-    self = <failure_demo.TestRaises object at 0xdeadbeef>
+    self = <failure_demo.TestRaises object at 0xdeadbeef001f>
 
         def test_raise(self):
     >       raise ValueError("demo error")
@@ -433,7 +429,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:172: ValueError
     ________________________ TestRaises.test_tupleerror ________________________
 
-    self = <failure_demo.TestRaises object at 0xdeadbeef>
+    self = <failure_demo.TestRaises object at 0xdeadbeef0020>
 
         def test_tupleerror(self):
     >       a, b = [1]  # NOQA
@@ -442,7 +438,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:175: ValueError
     ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
 
-    self = <failure_demo.TestRaises object at 0xdeadbeef>
+    self = <failure_demo.TestRaises object at 0xdeadbeef0021>
 
         def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
             items = [1, 2, 3]
@@ -455,7 +451,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     items is [1, 2, 3]
     ________________________ TestRaises.test_some_error ________________________
 
-    self = <failure_demo.TestRaises object at 0xdeadbeef>
+    self = <failure_demo.TestRaises object at 0xdeadbeef0022>
 
         def test_some_error(self):
     >       if namenotexi:  # NOQA
@@ -486,7 +482,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     abc-123:2: AssertionError
     ____________________ TestMoreErrors.test_complex_error _____________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef0023>
 
         def test_complex_error(self):
             def f():
@@ -512,7 +508,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:6: AssertionError
     ___________________ TestMoreErrors.test_z1_unpack_error ____________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef0024>
 
         def test_z1_unpack_error(self):
             items = []
@@ -522,7 +518,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:217: ValueError
     ____________________ TestMoreErrors.test_z2_type_error _____________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef0025>
 
         def test_z2_type_error(self):
             items = 3
@@ -532,20 +528,20 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:221: TypeError
     ______________________ TestMoreErrors.test_startswith ______________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef0026>
 
         def test_startswith(self):
             s = "123"
             g = "456"
     >       assert s.startswith(g)
     E       AssertionError: assert False
-    E        +  where False = <built-in method startswith of str object at 0xdeadbeef>('456')
-    E        +    where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
+    E        +  where False = <built-in method startswith of str object at 0xdeadbeef0027>('456')
+    E        +    where <built-in method startswith of str object at 0xdeadbeef0027> = '123'.startswith
 
     failure_demo.py:226: AssertionError
     __________________ TestMoreErrors.test_startswith_nested ___________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef0028>
 
         def test_startswith_nested(self):
             def f():
@@ -556,15 +552,15 @@ Here is a nice run of several failures and how ``pytest`` presents things:
 
     >       assert f().startswith(g())
     E       AssertionError: assert False
-    E        +  where False = <built-in method startswith of str object at 0xdeadbeef>('456')
-    E        +    where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
-    E        +      where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef>()
-    E        +    and   '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef>()
+    E        +  where False = <built-in method startswith of str object at 0xdeadbeef0027>('456')
+    E        +    where <built-in method startswith of str object at 0xdeadbeef0027> = '123'.startswith
+    E        +      where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef0029>()
+    E        +    and   '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef002a>()
 
     failure_demo.py:235: AssertionError
     _____________________ TestMoreErrors.test_global_func ______________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef002b>
 
         def test_global_func(self):
     >       assert isinstance(globf(42), float)
@@ -575,18 +571,18 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:238: AssertionError
     _______________________ TestMoreErrors.test_instance _______________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef002c>
 
         def test_instance(self):
             self.x = 6 * 7
     >       assert self.x != 42
     E       assert 42 != 42
-    E        +  where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef>.x
+    E        +  where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef002c>.x
 
     failure_demo.py:242: AssertionError
     _______________________ TestMoreErrors.test_compare ________________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef002d>
 
         def test_compare(self):
     >       assert globf(10) < 5
@@ -596,7 +592,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:245: AssertionError
     _____________________ TestMoreErrors.test_try_finally ______________________
 
-    self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
+    self = <failure_demo.TestMoreErrors object at 0xdeadbeef002e>
 
         def test_try_finally(self):
             x = 1
@@ -607,7 +603,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:250: AssertionError
     ___________________ TestCustomAssertMsg.test_single_line ___________________
 
-    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
+    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef002f>
 
         def test_single_line(self):
             class A:
@@ -622,7 +618,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:261: AssertionError
     ____________________ TestCustomAssertMsg.test_multiline ____________________
 
-    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
+    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef0030>
 
         def test_multiline(self):
             class A:
@@ -641,7 +637,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     failure_demo.py:268: AssertionError
     ___________________ TestCustomAssertMsg.test_custom_repr ___________________
 
-    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
+    self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef0031>
 
         def test_custom_repr(self):
             class JSON:
@@ -674,7 +670,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
     FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list - asser...
     FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_list_long - ...
     FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_dict - Asser...
-    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_set - Assert...
+    FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_set - assert...
     FAILED failure_demo.py::TestSpecialisedExplanations::test_eq_longer_list
     FAILED failure_demo.py::TestSpecialisedExplanations::test_in_list - asser...
     FAILED failure_demo.py::TestSpecialisedExplanations::test_not_in_text_multiline
index b641e61f718041bfd15733e7d77b69eff309cf8b..32e5188b741e12bb8f22e323881c497af2674ed9 100644 (file)
@@ -69,7 +69,7 @@ Here is a basic pattern to achieve this:
 
 
 For this to work we need to add a command line option and
-provide the ``cmdopt`` through a :ref:`fixture function <fixture function>`:
+provide the ``cmdopt`` through a :ref:`fixture function <fixture>`:
 
 .. code-block:: python
 
@@ -139,10 +139,67 @@ And now with supplying a command line option:
     FAILED test_sample.py::test_answer - assert 0
     1 failed in 0.12s
 
-You can see that the command line option arrived in our test.  This
-completes the basic pattern.  However, one often rather wants to process
-command line options outside of the test and rather pass in different or
-more complex objects.
+You can see that the command line option arrived in our test.
+
+We could add simple validation for the input by listing the choices:
+
+.. code-block:: python
+
+    # content of conftest.py
+    import pytest
+
+
+    def pytest_addoption(parser):
+        parser.addoption(
+            "--cmdopt",
+            action="store",
+            default="type1",
+            help="my option: type1 or type2",
+            choices=("type1", "type2"),
+        )
+
+Now we'll get feedback on a bad argument:
+
+.. code-block:: pytest
+
+    $ pytest -q --cmdopt=type3
+    ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
+    pytest: error: argument --cmdopt: invalid choice: 'type3' (choose from 'type1', 'type2')
+
+
+If you need to provide more detailed error messages, you can use the
+``type`` parameter and raise ``pytest.UsageError``:
+
+.. code-block:: python
+
+    # content of conftest.py
+    import pytest
+
+
+    def type_checker(value):
+        msg = "cmdopt must specify a numeric type as typeNNN"
+        if not value.startswith("type"):
+            raise pytest.UsageError(msg)
+        try:
+            int(value[4:])
+        except ValueError:
+            raise pytest.UsageError(msg)
+
+        return value
+
+
+    def pytest_addoption(parser):
+        parser.addoption(
+            "--cmdopt",
+            action="store",
+            default="type1",
+            help="my option: type1 or type2",
+            type=type_checker,
+        )
+
+This completes the basic pattern.  However, one often rather wants to
+process command line options outside of the test and rather pass in
+different or more complex objects.
 
 Dynamically adding command line options
 --------------------------------------------------------------
@@ -166,7 +223,7 @@ the command line arguments before they get processed:
             num = max(multiprocessing.cpu_count() / 2, 1)
             args[:] = ["-n", str(num)] + args
 
-If you have the `xdist plugin <https://pypi.org/project/pytest-xdist/>`_ installed
+If you have the :pypi:`xdist plugin <pytest-xdist>` installed
 you will now always perform test runs using a number
 of subprocesses close to your CPU. Running in an empty
 directory with the above conftest.py:
@@ -175,9 +232,8 @@ directory with the above conftest.py:
 
     $ pytest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 0 items
 
     ========================== no tests ran in 0.12s ===========================
@@ -240,9 +296,8 @@ and when running it will see a skipped "slow" test:
 
     $ pytest -rs    # "-rs" means report details on the little 's'
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 2 items
 
     test_module.py .s                                                    [100%]
@@ -257,9 +312,8 @@ Or run it including the ``slow`` marked test:
 
     $ pytest --runslow
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 2 items
 
     test_module.py ..                                                    [100%]
@@ -288,7 +342,7 @@ Example:
     def checkconfig(x):
         __tracebackhide__ = True
         if not hasattr(x, "config"):
-            pytest.fail("not configured: {}".format(x))
+            pytest.fail(f"not configured: {x}")
 
 
     def test_something():
@@ -322,6 +376,7 @@ this to make sure unexpected exception types aren't hidden:
 .. code-block:: python
 
     import operator
+
     import pytest
 
 
@@ -332,7 +387,7 @@ this to make sure unexpected exception types aren't hidden:
     def checkconfig(x):
         __tracebackhide__ = operator.methodcaller("errisinstance", ConfigException)
         if not hasattr(x, "config"):
-            raise ConfigException("not configured: {}".format(x))
+            raise ConfigException(f"not configured: {x}")
 
 
     def test_something():
@@ -401,10 +456,9 @@ which will add the string to the test header accordingly:
 
     $ pytest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
     project deps: mylib-1.1
-    rootdir: $REGENDOC_TMPDIR
+    rootdir: /home/sweet/project
     collected 0 items
 
     ========================== no tests ran in 0.12s ===========================
@@ -430,11 +484,11 @@ which will add info only when run with "--v":
 
     $ pytest -v
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
     info1: did you know that ...
     did you?
-    rootdir: $REGENDOC_TMPDIR
+    rootdir: /home/sweet/project
     collecting ... collected 0 items
 
     ========================== no tests ran in 0.12s ===========================
@@ -445,9 +499,8 @@ and nothing when run plainly:
 
     $ pytest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 0 items
 
     ========================== no tests ran in 0.12s ===========================
@@ -485,9 +538,8 @@ Now we can profile which test functions execute the slowest:
 
     $ pytest --durations=3
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 3 items
 
     test_some_are_slow.py ...                                            [100%]
@@ -514,6 +566,7 @@ an ``incremental`` marker which is to be used on classes:
     # content of conftest.py
 
     from typing import Dict, Tuple
+
     import pytest
 
     # store history of failures per test class name and per index in parametrize (if parametrize used)
@@ -557,7 +610,7 @@ an ``incremental`` marker which is to be used on classes:
                 test_name = _test_failed_incremental[cls_name].get(parametrize_index, None)
                 # if name found, test has failed for the combination of class name & test name
                 if test_name is not None:
-                    pytest.xfail("previous test failed ({})".format(test_name))
+                    pytest.xfail(f"previous test failed ({test_name})")
 
 
 These two hook implementations work together to abort incremental-marked
@@ -591,9 +644,8 @@ If we run this:
 
     $ pytest -rx
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 4 items
 
     test_step.py .Fx.                                                    [100%]
@@ -601,7 +653,7 @@ If we run this:
     ================================= FAILURES =================================
     ____________________ TestUserHandling.test_modification ____________________
 
-    self = <test_step.TestUserHandling object at 0xdeadbeef>
+    self = <test_step.TestUserHandling object at 0xdeadbeef0001>
 
         def test_modification(self):
     >       assert 0
@@ -609,8 +661,7 @@ If we run this:
 
     test_step.py:11: AssertionError
     ========================= short test summary info ==========================
-    XFAIL test_step.py::TestUserHandling::test_deletion
-      reason: previous test failed (test_modification)
+    XFAIL test_step.py::TestUserHandling::test_deletion - reason: previous test failed (test_modification)
     ================== 1 failed, 2 passed, 1 xfailed in 0.12s ==================
 
 We'll see that ``test_deletion`` was not executed because ``test_modification``
@@ -621,7 +672,7 @@ Package/Directory-level fixtures (setups)
 -------------------------------------------------------
 
 If you have nested test directories, you can have per-directory fixture scopes
-by placing fixture functions in a ``conftest.py`` file in that directory
+by placing fixture functions in a ``conftest.py`` file in that directory.
 You can use all types of fixtures including :ref:`autouse fixtures
 <autouse fixtures>` which are the equivalent of xUnit's setup/teardown
 concept.  It's however recommended to have explicit fixture references in your
@@ -640,7 +691,7 @@ Here is an example for making a ``db`` fixture available in a directory:
         pass
 
 
-    @pytest.fixture(scope="session")
+    @pytest.fixture(scope="package")
     def db():
         return DB()
 
@@ -675,9 +726,8 @@ We can run this:
 
     $ pytest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 7 items
 
     test_step.py .Fx.                                                    [ 57%]
@@ -687,17 +737,17 @@ We can run this:
 
     ================================== ERRORS ==================================
     _______________________ ERROR at setup of test_root ________________________
-    file $REGENDOC_TMPDIR/b/test_error.py, line 1
+    file /home/sweet/project/b/test_error.py, line 1
       def test_root(db):  # no db here, will error out
     E       fixture 'db' not found
     >       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
     >       use 'pytest --fixtures [testpath]' for help on them.
 
-    $REGENDOC_TMPDIR/b/test_error.py:1
+    /home/sweet/project/b/test_error.py:1
     ================================= FAILURES =================================
     ____________________ TestUserHandling.test_modification ____________________
 
-    self = <test_step.TestUserHandling object at 0xdeadbeef>
+    self = <test_step.TestUserHandling object at 0xdeadbeef0002>
 
         def test_modification(self):
     >       assert 0
@@ -706,21 +756,21 @@ We can run this:
     test_step.py:11: AssertionError
     _________________________________ test_a1 __________________________________
 
-    db = <conftest.DB object at 0xdeadbeef>
+    db = <conftest.DB object at 0xdeadbeef0003>
 
         def test_a1(db):
     >       assert 0, db  # to show value
-    E       AssertionError: <conftest.DB object at 0xdeadbeef>
+    E       AssertionError: <conftest.DB object at 0xdeadbeef0003>
     E       assert 0
 
     a/test_db.py:2: AssertionError
     _________________________________ test_a2 __________________________________
 
-    db = <conftest.DB object at 0xdeadbeef>
+    db = <conftest.DB object at 0xdeadbeef0003>
 
         def test_a2(db):
     >       assert 0, db  # to show value
-    E       AssertionError: <conftest.DB object at 0xdeadbeef>
+    E       AssertionError: <conftest.DB object at 0xdeadbeef0003>
     E       assert 0
 
     a/test_db2.py:2: AssertionError
@@ -753,9 +803,10 @@ case we just write some information out to a ``failures`` file:
 
     # content of conftest.py
 
-    import pytest
     import os.path
 
+    import pytest
+
 
     @pytest.hookimpl(tryfirst=True, hookwrapper=True)
     def pytest_runtest_makereport(item, call):
@@ -766,10 +817,10 @@ case we just write some information out to a ``failures`` file:
         # we only look at actual failing test calls, not setup/teardown
         if rep.when == "call" and rep.failed:
             mode = "a" if os.path.exists("failures") else "w"
-            with open("failures", mode) as f:
+            with open("failures", mode, encoding="utf-8") as f:
                 # let's also access a fixture for the fun of it
-                if "tmpdir" in item.fixturenames:
-                    extra = " ({})".format(item.funcargs["tmpdir"])
+                if "tmp_path" in item.fixturenames:
+                    extra = " ({})".format(item.funcargs["tmp_path"])
                 else:
                     extra = ""
 
@@ -781,7 +832,7 @@ if you then have failing tests:
 .. code-block:: python
 
     # content of test_module.py
-    def test_fail1(tmpdir):
+    def test_fail1(tmp_path):
         assert 0
 
 
@@ -794,9 +845,8 @@ and run them:
 
     $ pytest test_module.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 2 items
 
     test_module.py FF                                                    [100%]
@@ -804,9 +854,9 @@ and run them:
     ================================= FAILURES =================================
     ________________________________ test_fail1 ________________________________
 
-    tmpdir = local('PYTEST_TMPDIR/test_fail10')
+    tmp_path = PosixPath('PYTEST_TMPDIR/test_fail10')
 
-        def test_fail1(tmpdir):
+        def test_fail1(tmp_path):
     >       assert 0
     E       assert 0
 
@@ -842,8 +892,11 @@ here is a little example implemented via a local plugin:
 .. code-block:: python
 
     # content of conftest.py
-
+    from typing import Dict
     import pytest
+    from pytest import StashKey, CollectReport
+
+    phase_report_key = StashKey[Dict[str, CollectReport]]()
 
 
     @pytest.hookimpl(tryfirst=True, hookwrapper=True)
@@ -852,10 +905,9 @@ here is a little example implemented via a local plugin:
         outcome = yield
         rep = outcome.get_result()
 
-        # set a report attribute for each phase of a call, which can
+        # store test results for each phase of a call, which can
         # be "setup", "call", "teardown"
-
-        setattr(item, "rep_" + rep.when, rep)
+        item.stash.setdefault(phase_report_key, {})[rep.when] = rep
 
 
     @pytest.fixture
@@ -863,11 +915,11 @@ here is a little example implemented via a local plugin:
         yield
         # request.node is an "item" because we use the default
         # "function" scope
-        if request.node.rep_setup.failed:
-            print("setting up a test failed!", request.node.nodeid)
-        elif request.node.rep_setup.passed:
-            if request.node.rep_call.failed:
-                print("executing test failed", request.node.nodeid)
+        report = request.node.stash[phase_report_key]
+        if report["setup"].failed:
+            print("setting up a test failed or skipped", request.node.nodeid)
+        elif ("call" not in report) or report["call"].failed:
+            print("executing test failed or skipped", request.node.nodeid)
 
 
 if you then have failing tests:
@@ -901,13 +953,12 @@ and run it:
 
     $ pytest -s test_module.py
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 3 items
 
-    test_module.py Esetting up a test failed! test_module.py::test_setup_fails
-    Fexecuting test failed test_module.py::test_call_fails
+    test_module.py Esetting up a test failed or skipped test_module.py::test_setup_fails
+    Fexecuting test failed or skipped test_module.py::test_call_fails
     F
 
     ================================== ERRORS ==================================
@@ -957,8 +1008,7 @@ which test got stuck, for example if pytest was run in quiet mode (``-q``) or yo
 output. This is particularly a problem if the problem happens only sporadically, the famous "flaky" kind of tests.
 
 ``pytest`` sets the :envvar:`PYTEST_CURRENT_TEST` environment variable when running tests, which can be inspected
-by process monitoring utilities or libraries like `psutil <https://pypi.org/project/psutil/>`_ to discover which
-test got stuck if necessary:
+by process monitoring utilities or libraries like :pypi:`psutil` to discover which test got stuck if necessary:
 
 .. code-block:: python
 
@@ -1012,7 +1062,7 @@ your frozen program work as the pytest runner by some clever
 argument handling during program startup. This allows you to
 have a single executable, which is usually more convenient.
 Please note that the mechanism for plugin discovery used by pytest
-(setupttools entry points) doesn't work with frozen executables so pytest
+(setuptools entry points) doesn't work with frozen executables so pytest
 can't find any third party plugins automatically. To include third party plugins
 like ``pytest-timeout`` they must be imported explicitly and passed on to pytest.main.
 
@@ -1020,6 +1070,7 @@ like ``pytest-timeout`` they must be imported explicitly and passed on to pytest
 
     # contents of app_main.py
     import sys
+
     import pytest_timeout  # Third party plugin
 
     if len(sys.argv) > 1 and sys.argv[1] == "--pytest":
index 6886b6268a2f80fca5b0ab64f848e000290d0008..ace37c7278430aedd07a21a57c3c5f61d1c60ed9 100644 (file)
@@ -43,7 +43,7 @@ will be called ahead of running any tests:
             print("test_method1 called")
 
         def test_method2(self):
-            print("test_method1 called")
+            print("test_method2 called")
 
 
     class TestOther:
@@ -77,7 +77,7 @@ If you run this without output capturing:
     callme other called
     SomeTest callme called
     test_method1 called
-    .test_method1 called
+    .test_method2 called
     .test other
     .test_unit1 method called
     .
diff --git a/doc/en/existingtestsuite.rst b/doc/en/existingtestsuite.rst
deleted file mode 100644 (file)
index 1e3e192..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-.. _existingtestsuite:
-
-Using pytest with an existing test suite
-===========================================
-
-Pytest can be used with most existing test suites, but its
-behavior differs from other test runners such as :ref:`nose <noseintegration>` or
-Python's default unittest framework.
-
-Before using this section you will want to :ref:`install pytest <getstarted>`.
-
-Running an existing test suite with pytest
----------------------------------------------
-
-Say you want to contribute to an existing repository somewhere.
-After pulling the code into your development space using some
-flavor of version control and (optionally) setting up a virtualenv
-you will want to run:
-
-.. code-block:: bash
-
-    cd <repository>
-    pip install -e .  # Environment dependent alternatives include
-                      # 'python setup.py develop' and 'conda develop'
-
-in your project root.  This will set up a symlink to your code in
-site-packages, allowing you to edit your code while your tests
-run against it as if it were installed.
-
-Setting up your project in development mode lets you avoid having to
-reinstall every time you want to run your tests, and is less brittle than
-mucking about with sys.path to point your tests at local code.
-
-Also consider using :ref:`tox <use tox>`.
diff --git a/doc/en/explanation/anatomy.rst b/doc/en/explanation/anatomy.rst
new file mode 100644 (file)
index 0000000..e86dd74
--- /dev/null
@@ -0,0 +1,46 @@
+.. _test-anatomy:
+
+Anatomy of a test
+=================
+
+In the simplest terms, a test is meant to look at the result of a particular
+behavior, and make sure that result aligns with what you would expect.
+Behavior is not something that can be empirically measured, which is why writing
+tests can be challenging.
+
+"Behavior" is the way in which some system **acts in response** to a particular
+situation and/or stimuli. But exactly *how* or *why* something is done is not
+quite as important as *what* was done.
+
+You can think of a test as being broken down into four steps:
+
+1. **Arrange**
+2. **Act**
+3. **Assert**
+4. **Cleanup**
+
+**Arrange** is where we prepare everything for our test. This means pretty
+much everything except for the "**act**". It's lining up the dominoes so that
+the **act** can do its thing in one, state-changing step. This can mean
+preparing objects, starting/killing services, entering records into a database,
+or even things like defining a URL to query, generating some credentials for a
+user that doesn't exist yet, or just waiting for some process to finish.
+
+**Act** is the singular, state-changing action that kicks off the **behavior**
+we want to test. This behavior is what carries out the changing of the state of
+the system under test (SUT), and it's the resulting changed state that we can
+look at to make a judgement about the behavior. This typically takes the form of
+a function/method call.
+
+**Assert** is where we look at that resulting state and check if it looks how
+we'd expect after the dust has settled. It's where we gather evidence to say the
+behavior does or does not aligns with what we expect. The ``assert`` in our test
+is where we take that measurement/observation and apply our judgement to it. If
+something should be green, we'd say ``assert thing == "green"``.
+
+**Cleanup** is where the test picks up after itself, so other tests aren't being
+accidentally influenced by it.
+
+At its core, the test is ultimately the **act** and **assert** steps, with the
+**arrange** step only providing the context. **Behavior** exists between **act**
+and **assert**.
diff --git a/doc/en/explanation/fixtures.rst b/doc/en/explanation/fixtures.rst
new file mode 100644 (file)
index 0000000..194e576
--- /dev/null
@@ -0,0 +1,174 @@
+.. _about-fixtures:
+
+About fixtures
+===============
+
+.. seealso:: :ref:`how-to-fixtures`
+.. seealso:: :ref:`Fixtures reference <reference-fixtures>`
+
+pytest fixtures are designed to be explicit, modular and scalable.
+
+What fixtures are
+-----------------
+
+In testing, a `fixture <https://en.wikipedia.org/wiki/Test_fixture#Software>`_
+provides a defined, reliable and consistent context for the tests. This could
+include environment (for example a database configured with known parameters)
+or content (such as a dataset).
+
+Fixtures define the steps and data that constitute the *arrange* phase of a
+test (see :ref:`test-anatomy`). In pytest, they are functions you define that
+serve this purpose. They can also be used to define a test's *act* phase; this
+is a powerful technique for designing more complex tests.
+
+The services, state, or other operating environments set up by fixtures are
+accessed by test functions through arguments. For each fixture used by a test
+function there is typically a parameter (named after the fixture) in the test
+function's definition.
+
+We can tell pytest that a particular function is a fixture by decorating it with
+:py:func:`@pytest.fixture <pytest.fixture>`. Here's a simple example of
+what a fixture in pytest might look like:
+
+.. code-block:: python
+
+    import pytest
+
+
+    class Fruit:
+        def __init__(self, name):
+            self.name = name
+
+        def __eq__(self, other):
+            return self.name == other.name
+
+
+    @pytest.fixture
+    def my_fruit():
+        return Fruit("apple")
+
+
+    @pytest.fixture
+    def fruit_basket(my_fruit):
+        return [Fruit("banana"), my_fruit]
+
+
+    def test_my_fruit_in_basket(my_fruit, fruit_basket):
+        assert my_fruit in fruit_basket
+
+Tests don't have to be limited to a single fixture, either. They can depend on
+as many fixtures as you want, and fixtures can use other fixtures, as well. This
+is where pytest's fixture system really shines.
+
+
+Improvements over xUnit-style setup/teardown functions
+-----------------------------------------------------------
+
+pytest fixtures offer dramatic improvements over the classic xUnit
+style of setup/teardown functions:
+
+* fixtures have explicit names and are activated by declaring their use
+  from test functions, modules, classes or whole projects.
+
+* fixtures are implemented in a modular manner, as each fixture name
+  triggers a *fixture function* which can itself use other fixtures.
+
+* fixture management scales from simple unit to complex
+  functional testing, allowing to parametrize fixtures and tests according
+  to configuration and component options, or to re-use fixtures
+  across function, class, module or whole test session scopes.
+
+* teardown logic can be easily, and safely managed, no matter how many fixtures
+  are used, without the need to carefully handle errors by hand or micromanage
+  the order that cleanup steps are added.
+
+In addition, pytest continues to support :ref:`xunitsetup`.  You can mix
+both styles, moving incrementally from classic to new style, as you
+prefer.  You can also start out from existing :ref:`unittest.TestCase
+style <unittest.TestCase>` or :ref:`nose based <nosestyle>` projects.
+
+
+
+Fixture errors
+--------------
+
+pytest does its best to put all the fixtures for a given test in a linear order
+so that it can see which fixture happens first, second, third, and so on. If an
+earlier fixture has a problem, though, and raises an exception, pytest will stop
+executing fixtures for that test and mark the test as having an error.
+
+When a test is marked as having an error, it doesn't mean the test failed,
+though. It just means the test couldn't even be attempted because one of the
+things it depends on had a problem.
+
+This is one reason why it's a good idea to cut out as many unnecessary
+dependencies as possible for a given test. That way a problem in something
+unrelated isn't causing us to have an incomplete picture of what may or may not
+have issues.
+
+Here's a quick example to help explain:
+
+.. code-block:: python
+
+    import pytest
+
+
+    @pytest.fixture
+    def order():
+        return []
+
+
+    @pytest.fixture
+    def append_first(order):
+        order.append(1)
+
+
+    @pytest.fixture
+    def append_second(order, append_first):
+        order.extend([2])
+
+
+    @pytest.fixture(autouse=True)
+    def append_third(order, append_second):
+        order += [3]
+
+
+    def test_order(order):
+        assert order == [1, 2, 3]
+
+
+If, for whatever reason, ``order.append(1)`` had a bug and it raises an exception,
+we wouldn't be able to know if ``order.extend([2])`` or ``order += [3]`` would
+also have problems. After ``append_first`` throws an exception, pytest won't run
+any more fixtures for ``test_order``, and it won't even try to run
+``test_order`` itself. The only things that would've run would be ``order`` and
+``append_first``.
+
+
+Sharing test data
+-----------------
+
+If you want to make test data from files available to your tests, a good way
+to do this is by loading these data in a fixture for use by your tests.
+This makes use of the automatic caching mechanisms of pytest.
+
+Another good approach is by adding the data files in the ``tests`` folder.
+There are also community plugins available to help to manage this aspect of
+testing, e.g. :pypi:`pytest-datadir` and :pypi:`pytest-datafiles`.
+
+.. _fixtures-signal-cleanup:
+
+A note about fixture cleanup
+----------------------------
+
+pytest does not do any special processing for :data:`SIGTERM <signal.SIGTERM>` and
+:data:`SIGQUIT <signal.SIGQUIT>` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
+by the Python runtime via :class:`KeyboardInterrupt`), so fixtures that manage external resources which are important
+to be cleared when the Python process is terminated (by those signals) might leak resources.
+
+The reason pytest does not handle those signals to perform fixture cleanup is that signal handlers are global,
+and changing them might interfere with the code under execution.
+
+If fixtures in your suite need special care regarding termination in those scenarios,
+see :issue:`this comment <5243#issuecomment-491522595>` in the issue
+tracker for a possible workaround.
diff --git a/doc/en/explanation/flaky.rst b/doc/en/explanation/flaky.rst
new file mode 100644 (file)
index 0000000..ccf3fbb
--- /dev/null
@@ -0,0 +1,126 @@
+
+Flaky tests
+-----------
+
+A "flaky" test is one that exhibits intermittent or sporadic failure, that seems to have non-deterministic behaviour. Sometimes it passes, sometimes it fails, and it's not clear why. This page discusses pytest features that can help and other general strategies for identifying, fixing or mitigating them.
+
+Why flaky tests are a problem
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Flaky tests are particularly troublesome when a continuous integration (CI) server is being used, so that all tests must pass before a new code change can be merged. If the test result is not a reliable signal -- that a test failure means the code change broke the test -- developers can become mistrustful of the test results, which can lead to overlooking genuine failures. It is also a source of wasted time as developers must re-run test suites and investigate spurious failures.
+
+
+Potential root causes
+^^^^^^^^^^^^^^^^^^^^^
+
+System state
+~~~~~~~~~~~~
+
+Broadly speaking, a flaky test indicates that the test relies on some system state that is not being appropriately controlled - the test environment is not sufficiently isolated. Higher level tests are more likely to be flaky as they rely on more state.
+
+Flaky tests sometimes appear when a test suite is run in parallel (such as use of pytest-xdist). This can indicate a test is reliant on test ordering.
+
+-  Perhaps a different test is failing to clean up after itself and leaving behind data which causes the flaky test to fail.
+- The flaky test is reliant on data from a previous test that doesn't clean up after itself, and in parallel runs that previous test is not always present
+- Tests that modify global state typically cannot be run in parallel.
+
+
+Overly strict assertion
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Overly strict assertions can cause problems with floating point comparison as well as timing issues. :func:`pytest.approx` is useful here.
+
+
+Pytest features
+^^^^^^^^^^^^^^^
+
+Xfail strict
+~~~~~~~~~~~~
+
+:ref:`pytest.mark.xfail ref` with ``strict=False`` can be used to mark a test so that its failure does not cause the whole build to break. This could be considered like a manual quarantine, and is rather dangerous to use permanently.
+
+
+PYTEST_CURRENT_TEST
+~~~~~~~~~~~~~~~~~~~
+
+:envvar:`PYTEST_CURRENT_TEST` may be useful for figuring out "which test got stuck".
+See :ref:`pytest current test env` for more details.
+
+
+Plugins
+~~~~~~~
+
+Rerunning any failed tests can mitigate the negative effects of flaky tests by giving them additional chances to pass, so that the overall build does not fail. Several pytest plugins support this:
+
+* `flaky <https://github.com/box/flaky>`_
+* `pytest-flakefinder <https://github.com/dropbox/pytest-flakefinder>`_ - `blog post <https://blogs.dropbox.com/tech/2016/03/open-sourcing-pytest-tools/>`_
+* `pytest-rerunfailures <https://github.com/pytest-dev/pytest-rerunfailures>`_
+* `pytest-replay <https://github.com/ESSS/pytest-replay>`_: This plugin helps to reproduce locally crashes or flaky tests observed during CI runs.
+
+Plugins to deliberately randomize tests can help expose tests with state problems:
+
+* `pytest-random-order <https://github.com/jbasko/pytest-random-order>`_
+* `pytest-randomly <https://github.com/pytest-dev/pytest-randomly>`_
+
+
+Other general strategies
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+Split up test suites
+~~~~~~~~~~~~~~~~~~~~
+
+It can be common to split a single test suite into two, such as unit vs integration, and only use the unit test suite as a CI gate. This also helps keep build times manageable as high level tests tend to be slower. However, it means it does become possible for code that breaks the build to be merged, so extra vigilance is needed for monitoring the integration test results.
+
+
+Video/screenshot on failure
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For UI tests these are important for understanding what the state of the UI was when the test failed. pytest-splinter can be used with plugins like pytest-bdd and can `save a screenshot on test failure <https://pytest-splinter.readthedocs.io/en/latest/#automatic-screenshots-on-test-failure>`_, which can help to isolate the cause.
+
+
+Delete or rewrite the test
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+If the functionality is covered by other tests, perhaps the test can be removed. If not, perhaps it can be rewritten at a lower level which will remove the flakiness or make its source more apparent.
+
+
+Quarantine
+~~~~~~~~~~
+
+Mark Lapierre discusses the `Pros and Cons of Quarantined Tests <https://dev.to/mlapierre/pros-and-cons-of-quarantined-tests-2emj>`_ in a post from 2018.
+
+
+
+CI tools that rerun on failure
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Azure Pipelines (the Azure cloud CI/CD tool, formerly Visual Studio Team Services or VSTS) has a feature to `identify flaky tests <https://docs.microsoft.com/en-us/previous-versions/azure/devops/2017/dec-11-vsts?view=tfs-2017#identify-flaky-tests>`_ and rerun failed tests.
+
+
+
+Research
+^^^^^^^^
+
+This is a limited list, please submit an issue or pull request to expand it!
+
+* Gao, Zebao, Yalan Liang, Myra B. Cohen, Atif M. Memon, and Zhen Wang. "Making system user interactive tests repeatable: When and what should we control?." In *Software Engineering (ICSE), 2015 IEEE/ACM 37th IEEE International Conference on*, vol. 1, pp. 55-65. IEEE, 2015.  `PDF <http://www.cs.umd.edu/~atif/pubs/gao-icse15.pdf>`__
+* Palomba, Fabio, and Andy Zaidman. "Does refactoring of test smells induce fixing flaky tests?." In *Software Maintenance and Evolution (ICSME), 2017 IEEE International Conference on*, pp. 1-12. IEEE, 2017. `PDF in Google Drive <https://drive.google.com/file/d/10HdcCQiuQVgW3yYUJD-TSTq1NbYEprl0/view>`__
+*  Bell, Jonathan, Owolabi Legunsen, Michael Hilton, Lamyaa Eloussi, Tifany Yung, and Darko Marinov. "DeFlaker: Automatically detecting flaky tests." In *Proceedings of the 2018 International Conference on Software Engineering*. 2018. `PDF <https://www.jonbell.net/icse18-deflaker.pdf>`__
+
+
+Resources
+^^^^^^^^^
+
+* `Eradicating Non-Determinism in Tests <https://martinfowler.com/articles/nonDeterminism.html>`_ by Martin Fowler, 2011
+* `No more flaky tests on the Go team <https://www.thoughtworks.com/insights/blog/no-more-flaky-tests-go-team>`_ by Pavan Sudarshan, 2012
+* `The Build That Cried Broken: Building Trust in your Continuous Integration Tests <https://www.youtube.com/embed/VotJqV4n8ig>`_ talk (video) by `Angie Jones <https://angiejones.tech/>`_ at SeleniumConf Austin 2017
+* `Test and Code Podcast: Flaky Tests and How to Deal with Them <https://testandcode.com/50>`_ by Brian Okken and Anthony Shaw, 2018
+* Microsoft:
+
+  * `How we approach testing VSTS to enable continuous delivery <https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/>`_ by Brian Harry MS, 2017
+  * `Eliminating Flaky Tests <https://docs.microsoft.com/en-us/azure/devops/learn/devops-at-microsoft/eliminating-flaky-tests>`_ blog and talk (video) by Munil Shah, 2017
+
+* Google:
+
+  * `Flaky Tests at Google and How We Mitigate Them <https://testing.googleblog.com/2016/05/flaky-tests-at-google-and-how-we.html>`_ by John Micco, 2016
+  * `Where do Google's flaky tests come from? <https://testing.googleblog.com/2017/04/where-do-our-flaky-tests-come-from.html>`_  by Jeff Listfield, 2017
diff --git a/doc/en/explanation/goodpractices.rst b/doc/en/explanation/goodpractices.rst
new file mode 100644 (file)
index 0000000..efde420
--- /dev/null
@@ -0,0 +1,313 @@
+.. highlight:: python
+.. _`goodpractices`:
+
+Good Integration Practices
+=================================================
+
+Install package with pip
+-------------------------------------------------
+
+For development, we recommend you use :mod:`venv` for virtual environments and
+:doc:`pip:index` for installing your application and any dependencies,
+as well as the ``pytest`` package itself.
+This ensures your code and dependencies are isolated from your system Python installation.
+
+Create a ``pyproject.toml`` file in the root of your repository as described in
+:doc:`packaging:tutorials/packaging-projects`.
+The first few lines should look like this:
+
+.. code-block:: toml
+
+    [build-system]
+    requires = ["hatchling"]
+    build-backend = "hatchling.build"
+
+    [project]
+    name = "PACKAGENAME"
+    version = "PACKAGEVERSION"
+
+where ``PACKAGENAME`` and ``PACKAGEVERSION`` are the name and version of your package respectively.
+
+You can then install your package in "editable" mode by running from the same directory:
+
+.. code-block:: bash
+
+    pip install -e .
+
+which lets you change your source code (both tests and application) and rerun tests at will.
+
+.. _`test discovery`:
+.. _`Python test discovery`:
+
+Conventions for Python test discovery
+-------------------------------------------------
+
+``pytest`` implements the following standard test discovery:
+
+* If no arguments are specified then collection starts from :confval:`testpaths`
+  (if configured) or the current directory. Alternatively, command line arguments
+  can be used in any combination of directories, file names or node ids.
+* Recurse into directories, unless they match :confval:`norecursedirs`.
+* In those directories, search for ``test_*.py`` or ``*_test.py`` files, imported by their `test package name`_.
+* From those files, collect test items:
+
+  * ``test`` prefixed test functions or methods outside of class.
+  * ``test`` prefixed test functions or methods inside ``Test`` prefixed test classes (without an ``__init__`` method). Methods decorated with ``@staticmethod`` and ``@classmethods`` are also considered.
+
+For examples of how to customize your test discovery :doc:`/example/pythoncollection`.
+
+Within Python modules, ``pytest`` also discovers tests using the standard
+:ref:`unittest.TestCase <unittest.TestCase>` subclassing technique.
+
+
+Choosing a test layout / import rules
+-------------------------------------
+
+``pytest`` supports two common test layouts:
+
+Tests outside application code
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Putting tests into an extra directory outside your actual application code
+might be useful if you have many functional tests or for other reasons want
+to keep tests separate from actual application code (often a good idea):
+
+.. code-block:: text
+
+    pyproject.toml
+    src/
+        mypkg/
+            __init__.py
+            app.py
+            view.py
+    tests/
+        test_app.py
+        test_view.py
+        ...
+
+This has the following benefits:
+
+* Your tests can run against an installed version after executing ``pip install .``.
+* Your tests can run against the local copy with an editable install after executing ``pip install --editable .``.
+
+For new projects, we recommend to use ``importlib`` :ref:`import mode <import-modes>`
+(see which-import-mode_ for a detailed explanation).
+To this end, add the following to your ``pyproject.toml``:
+
+.. code-block:: toml
+
+    [tool.pytest.ini_options]
+    addopts = [
+        "--import-mode=importlib",
+    ]
+
+.. _src-layout:
+
+Generally, but especially if you use the default import mode ``prepend``,
+it is **strongly** suggested to use a ``src`` layout.
+Here, your application root package resides in a sub-directory of your root,
+i.e. ``src/mypkg/`` instead of ``mypkg``.
+
+This layout prevents a lot of common pitfalls and has many benefits,
+which are better explained in this excellent `blog post`_ by Ionel Cristian Mărieș.
+
+.. _blog post: https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure>
+
+.. note::
+
+    If you do not use an editable install and use the ``src`` layout as above you need to extend the Python's
+    search path for module files to execute the tests against the local copy directly. You can do it in an
+    ad-hoc manner by setting the ``PYTHONPATH`` environment variable:
+
+    .. code-block:: bash
+
+       PYTHONPATH=src pytest
+
+    or in a permanent manner by using the :confval:`pythonpath` configuration variable and adding the
+    following to your ``pyproject.toml``:
+
+    .. code-block:: toml
+
+        [tool.pytest.ini_options]
+        pythonpath = "src"
+
+.. note::
+
+    If you do not use an editable install and not use the ``src`` layout (``mypkg`` directly in the root
+    directory) you can rely on the fact that Python by default puts the current directory in ``sys.path`` to
+    import your package and run ``python -m pytest`` to execute the tests against the local copy directly.
+
+    See :ref:`pytest vs python -m pytest` for more information about the difference between calling ``pytest`` and
+    ``python -m pytest``.
+
+Tests as part of application code
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Inlining test directories into your application package
+is useful if you have direct relation between tests and application modules and
+want to distribute them along with your application:
+
+.. code-block:: text
+
+    pyproject.toml
+    [src/]mypkg/
+        __init__.py
+        app.py
+        view.py
+        tests/
+            __init__.py
+            test_app.py
+            test_view.py
+            ...
+
+In this scheme, it is easy to run your tests using the ``--pyargs`` option:
+
+.. code-block:: bash
+
+    pytest --pyargs mypkg
+
+``pytest`` will discover where ``mypkg`` is installed and collect tests from there.
+
+Note that this layout also works in conjunction with the ``src`` layout mentioned in the previous section.
+
+
+.. note::
+
+    You can use namespace packages (PEP420) for your application
+    but pytest will still perform `test package name`_ discovery based on the
+    presence of ``__init__.py`` files.  If you use one of the
+    two recommended file system layouts above but leave away the ``__init__.py``
+    files from your directories, it should just work.  From
+    "inlined tests", however, you will need to use absolute imports for
+    getting at your application code.
+
+.. _`test package name`:
+
+.. note::
+
+    In ``prepend`` and ``append`` import-modes, if pytest finds a ``"a/b/test_module.py"``
+    test file while recursing into the filesystem it determines the import name
+    as follows:
+
+    * determine ``basedir``: this is the first "upward" (towards the root)
+      directory not containing an ``__init__.py``.  If e.g. both ``a``
+      and ``b`` contain an ``__init__.py`` file then the parent directory
+      of ``a`` will become the ``basedir``.
+
+    * perform ``sys.path.insert(0, basedir)`` to make the test module
+      importable under the fully qualified import name.
+
+    * ``import a.b.test_module`` where the path is determined
+      by converting path separators ``/`` into "." characters.  This means
+      you must follow the convention of having directory and file
+      names map directly to the import names.
+
+    The reason for this somewhat evolved importing technique is
+    that in larger projects multiple test modules might import
+    from each other and thus deriving a canonical import name helps
+    to avoid surprises such as a test module getting imported twice.
+
+    With ``--import-mode=importlib`` things are less convoluted because
+    pytest doesn't need to change ``sys.path`` or ``sys.modules``, making things
+    much less surprising.
+
+
+.. _which-import-mode:
+
+Choosing an import mode
+^^^^^^^^^^^^^^^^^^^^^^^
+
+For historical reasons, pytest defaults to the ``prepend`` :ref:`import mode <import-modes>`
+instead of the ``importlib`` import mode we recommend for new projects.
+The reason lies in the way the ``prepend`` mode works:
+
+Since there are no packages to derive a full package name from,
+``pytest`` will import your test files as *top-level* modules.
+The test files in the first example (:ref:`src layout <src-layout>`) would be imported as
+``test_app`` and ``test_view`` top-level modules by adding ``tests/`` to ``sys.path``.
+
+This results in a drawback compared to the import mode ``importlib``:
+your test files must have **unique names**.
+
+If you need to have test modules with the same name,
+as a workaround you might add ``__init__.py`` files to your ``tests`` folder and subfolders,
+changing them to packages:
+
+.. code-block:: text
+
+    pyproject.toml
+    mypkg/
+        ...
+    tests/
+        __init__.py
+        foo/
+            __init__.py
+            test_view.py
+        bar/
+            __init__.py
+            test_view.py
+
+Now pytest will load the modules as ``tests.foo.test_view`` and ``tests.bar.test_view``,
+allowing you to have modules with the same name.
+But now this introduces a subtle problem:
+in order to load the test modules from the ``tests`` directory,
+pytest prepends the root of the repository to ``sys.path``,
+which adds the side-effect that now ``mypkg`` is also importable.
+
+This is problematic if you are using a tool like tox_ to test your package in a virtual environment,
+because you want to test the *installed* version of your package,
+not the local code from the repository.
+
+The ``importlib`` import mode does not have any of the drawbacks above,
+because ``sys.path`` is not changed when importing test modules.
+
+
+.. _`buildout`: http://www.buildout.org/en/latest/
+
+.. _`use tox`:
+
+tox
+---
+
+Once you are done with your work and want to make sure that your actual
+package passes all tests you may want to look into :doc:`tox <tox:index>`, the
+virtualenv test automation tool.
+``tox`` helps you to setup virtualenv environments with pre-defined
+dependencies and then executing a pre-configured test command with
+options.  It will run tests against the installed package and not
+against your source code checkout, helping to detect packaging
+glitches.
+
+Do not run via setuptools
+-------------------------
+
+Integration with setuptools is **not recommended**,
+i.e. you should not be using ``python setup.py test`` or ``pytest-runner``,
+and may stop working in the future.
+
+This is deprecated since it depends on deprecated features of setuptools
+and relies on features that break security mechanisms in pip.
+For example 'setup_requires' and 'tests_require' bypass ``pip --require-hashes``.
+For more information and migration instructions,
+see the `pytest-runner notice <https://github.com/pytest-dev/pytest-runner#deprecation-notice>`_.
+See also `pypa/setuptools#1684 <https://github.com/pypa/setuptools/issues/1684>`_.
+
+setuptools intends to
+`remove the test command <https://github.com/pypa/setuptools/issues/931>`_.
+
+Checking with flake8-pytest-style
+---------------------------------
+
+In order to ensure that pytest is being used correctly in your project,
+it can be helpful to use the `flake8-pytest-style <https://github.com/m-burst/flake8-pytest-style>`_ flake8 plugin.
+
+flake8-pytest-style checks for common mistakes and coding style violations in pytest code,
+such as incorrect use of fixtures, test function names, and markers.
+By using this plugin, you can catch these errors early in the development process
+and ensure that your pytest code is consistent and easy to maintain.
+
+A list of the lints detected by flake8-pytest-style can be found on its `PyPI page <https://pypi.org/project/flake8-pytest-style/>`_.
+
+.. note::
+
+    flake8-pytest-style is not an official pytest project. Some of the rules enforce certain style choices, such as using `@pytest.fixture()` over `@pytest.fixture`, but you can configure the plugin to fit your preferred style.
diff --git a/doc/en/explanation/index.rst b/doc/en/explanation/index.rst
new file mode 100644 (file)
index 0000000..53910f1
--- /dev/null
@@ -0,0 +1,15 @@
+:orphan:
+
+.. _explanation:
+
+Explanation
+================
+
+.. toctree::
+   :maxdepth: 1
+
+   anatomy
+   fixtures
+   goodpractices
+   flaky
+   pythonpath
diff --git a/doc/en/explanation/pythonpath.rst b/doc/en/explanation/pythonpath.rst
new file mode 100644 (file)
index 0000000..5b533f4
--- /dev/null
@@ -0,0 +1,142 @@
+.. _pythonpath:
+
+pytest import mechanisms and ``sys.path``/``PYTHONPATH``
+========================================================
+
+.. _`import-modes`:
+
+Import modes
+------------
+
+pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution.
+
+Importing files in Python (at least until recently) is a non-trivial processes, often requiring
+changing :data:`sys.path`. Some aspects of the
+import process can be controlled through the ``--import-mode`` command-line flag, which can assume
+these values:
+
+* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
+  of :py:data:`sys.path` if not already there, and then imported with the :func:`importlib.import_module <importlib.import_module>` function.
+
+  This requires test module names to be unique when the test directory tree is not arranged in
+  packages, because the modules will put in :py:data:`sys.modules` after importing.
+
+  This is the classic mechanism, dating back from the time Python 2 was still supported.
+
+* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
+  there, and imported with :func:`importlib.import_module <importlib.import_module>`.
+
+  This better allows to run test modules against installed versions of a package even if the
+  package under test has the same import root. For example:
+
+  ::
+
+        testing/__init__.py
+        testing/test_pkg_under_test.py
+        pkg_under_test/
+
+  the tests will run against the installed version
+  of ``pkg_under_test`` when ``--import-mode=append`` is used whereas
+  with ``prepend`` they would pick up the local version. This kind of confusion is why
+  we advocate for using :ref:`src <src-layout>` layouts.
+
+  Same as ``prepend``, requires test module names to be unique when the test directory tree is
+  not arranged in packages, because the modules will put in :py:data:`sys.modules` after importing.
+
+* ``importlib``: new in pytest-6.0, this mode uses more fine control mechanisms provided by :mod:`importlib` to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
+
+  For this reason this doesn't require test module names to be unique.
+
+  One drawback however is that test modules are non-importable by each other. Also,  utility
+  modules in the tests directories are not automatically importable because the tests directory is no longer
+  added to :py:data:`sys.path`.
+
+  Initially we intended to make ``importlib`` the default in future releases, however it is clear now that
+  it has its own set of drawbacks so the default will remain ``prepend`` for the foreseeable future.
+
+.. seealso::
+
+    The :confval:`pythonpath` configuration variable.
+
+
+``prepend`` and ``append`` import modes scenarios
+-------------------------------------------------
+
+Here's a list of scenarios when using ``prepend`` or ``append`` import modes where pytest needs to
+change ``sys.path`` in order to import test modules or ``conftest.py`` files, and the issues users
+might encounter because of that.
+
+Test modules / ``conftest.py`` files inside packages
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Consider this file and directory layout::
+
+    root/
+    |- foo/
+       |- __init__.py
+       |- conftest.py
+       |- bar/
+          |- __init__.py
+          |- tests/
+             |- __init__.py
+             |- test_foo.py
+
+
+When executing:
+
+.. code-block:: bash
+
+    pytest root/
+
+pytest will find ``foo/bar/tests/test_foo.py`` and realize it is part of a package given that
+there's an ``__init__.py`` file in the same folder. It will then search upwards until it can find the
+last folder which still contains an ``__init__.py`` file in order to find the package *root* (in
+this case ``foo/``). To load the module, it will insert ``root/``  to the front of
+``sys.path`` (if not there already) in order to load
+``test_foo.py`` as the *module* ``foo.bar.tests.test_foo``.
+
+The same logic applies to the ``conftest.py`` file: it will be imported as ``foo.conftest`` module.
+
+Preserving the full package name is important when tests live in a package to avoid problems
+and allow test modules to have duplicated names. This is also discussed in details in
+:ref:`test discovery`.
+
+Standalone test modules / ``conftest.py`` files
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Consider this file and directory layout::
+
+    root/
+    |- foo/
+       |- conftest.py
+       |- bar/
+          |- tests/
+             |- test_foo.py
+
+
+When executing:
+
+.. code-block:: bash
+
+    pytest root/
+
+pytest will find ``foo/bar/tests/test_foo.py`` and realize it is NOT part of a package given that
+there's no ``__init__.py`` file in the same folder. It will then add ``root/foo/bar/tests`` to
+``sys.path`` in order to import ``test_foo.py`` as the *module* ``test_foo``. The same is done
+with the ``conftest.py`` file by adding ``root/foo`` to ``sys.path`` to import it as ``conftest``.
+
+For this reason this layout cannot have test modules with the same name, as they all will be
+imported in the global import namespace.
+
+This is also discussed in details in :ref:`test discovery`.
+
+.. _`pytest vs python -m pytest`:
+
+Invoking ``pytest`` versus ``python -m pytest``
+-----------------------------------------------
+
+Running pytest with ``pytest [...]`` instead of ``python -m pytest [...]`` yields nearly
+equivalent behaviour, except that the latter will add the current directory to ``sys.path``, which
+is standard ``python`` behavior.
+
+See also :ref:`invoke-python`.
diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst
deleted file mode 100644 (file)
index c749845..0000000
+++ /dev/null
@@ -1,2486 +0,0 @@
-.. _fixture:
-.. _fixtures:
-.. _`fixture functions`:
-
-pytest fixtures: explicit, modular, scalable
-========================================================
-
-.. currentmodule:: _pytest.python
-
-
-
-.. _`xUnit`: https://en.wikipedia.org/wiki/XUnit
-.. _`Software test fixtures`: https://en.wikipedia.org/wiki/Test_fixture#Software
-.. _`Dependency injection`: https://en.wikipedia.org/wiki/Dependency_injection
-.. _`Transaction`: https://en.wikipedia.org/wiki/Transaction_processing
-.. _`linearizable`: https://en.wikipedia.org/wiki/Linearizability
-
-`Software test fixtures`_ initialize test functions.  They provide a
-fixed baseline so that tests execute reliably and produce consistent,
-repeatable, results.  Initialization may setup services, state, or
-other operating environments.  These are accessed by test functions
-through arguments; for each fixture used by a test function there is
-typically a parameter (named after the fixture) in the test function's
-definition.
-
-pytest fixtures offer dramatic improvements over the classic xUnit
-style of setup/teardown functions:
-
-* fixtures have explicit names and are activated by declaring their use
-  from test functions, modules, classes or whole projects.
-
-* fixtures are implemented in a modular manner, as each fixture name
-  triggers a *fixture function* which can itself use other fixtures.
-
-* fixture management scales from simple unit to complex
-  functional testing, allowing to parametrize fixtures and tests according
-  to configuration and component options, or to re-use fixtures
-  across function, class, module or whole test session scopes.
-
-* teardown logic can be easily, and safely managed, no matter how many fixtures
-  are used, without the need to carefully handle errors by hand or micromanage
-  the order that cleanup steps are added.
-
-In addition, pytest continues to support :ref:`xunitsetup`.  You can mix
-both styles, moving incrementally from classic to new style, as you
-prefer.  You can also start out from existing :ref:`unittest.TestCase
-style <unittest.TestCase>` or :ref:`nose based <nosestyle>` projects.
-
-:ref:`Fixtures <fixtures-api>` are defined using the
-:ref:`@pytest.fixture <pytest.fixture-api>` decorator, :ref:`described
-below <funcargs>`. Pytest has useful built-in fixtures, listed here
-for reference:
-
-   :fixture:`capfd`
-        Capture, as text, output to file descriptors ``1`` and ``2``.
-
-   :fixture:`capfdbinary`
-        Capture, as bytes, output to file descriptors ``1`` and ``2``.
-
-   :fixture:`caplog`
-        Control logging and access log entries.
-
-   :fixture:`capsys`
-        Capture, as text, output to ``sys.stdout`` and ``sys.stderr``.
-
-   :fixture:`capsysbinary`
-        Capture, as bytes, output to ``sys.stdout`` and ``sys.stderr``.
-
-   :fixture:`cache`
-        Store and retrieve values across pytest runs.
-
-   :fixture:`doctest_namespace`
-        Provide a dict injected into the docstests namespace.
-
-   :fixture:`monkeypatch`
-       Temporarily modify classes, functions, dictionaries,
-       ``os.environ``, and other objects.
-
-   :fixture:`pytestconfig`
-        Access to configuration values, pluginmanager and plugin hooks.
-
-   :fixture:`record_property`
-       Add extra properties to the test.
-
-   :fixture:`record_testsuite_property`
-       Add extra properties to the test suite.
-
-   :fixture:`recwarn`
-        Record warnings emitted by test functions.
-
-   :fixture:`request`
-       Provide information on the executing test function.
-
-   :fixture:`testdir`
-        Provide a temporary test directory to aid in running, and
-        testing, pytest plugins.
-
-   :fixture:`tmp_path`
-       Provide a :class:`pathlib.Path` object to a temporary directory
-       which is unique to each test function.
-
-   :fixture:`tmp_path_factory`
-        Make session-scoped temporary directories and return
-        :class:`pathlib.Path` objects.
-
-   :fixture:`tmpdir`
-        Provide a :class:`py.path.local` object to a temporary
-        directory which is unique to each test function;
-        replaced by :fixture:`tmp_path`.
-
-        .. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
-
-   :fixture:`tmpdir_factory`
-        Make session-scoped temporary directories and return
-        :class:`py.path.local` objects;
-        replaced by :fixture:`tmp_path_factory`.
-
-.. _`funcargs`:
-.. _`funcarg mechanism`:
-.. _`fixture function`:
-.. _`@pytest.fixture`:
-.. _`pytest.fixture`:
-
-What fixtures are
------------------
-
-Before we dive into what fixtures are, let's first look at what a test is.
-
-In the simplest terms, a test is meant to look at the result of a particular
-behavior, and make sure that result aligns with what you would expect.
-Behavior is not something that can be empirically measured, which is why writing
-tests can be challenging.
-
-"Behavior" is the way in which some system **acts in response** to a particular
-situation and/or stimuli. But exactly *how* or *why* something is done is not
-quite as important as *what* was done.
-
-You can think of a test as being broken down into four steps:
-
-1. **Arrange**
-2. **Act**
-3. **Assert**
-4. **Cleanup**
-
-**Arrange** is where we prepare everything for our test. This means pretty
-much everything except for the "**act**". It's lining up the dominoes so that
-the **act** can do its thing in one, state-changing step. This can mean
-preparing objects, starting/killing services, entering records into a database,
-or even things like defining a URL to query, generating some credentials for a
-user that doesn't exist yet, or just waiting for some process to finish.
-
-**Act** is the singular, state-changing action that kicks off the **behavior**
-we want to test. This behavior is what carries out the changing of the state of
-the system under test (SUT), and it's the resulting changed state that we can
-look at to make a judgement about the behavior. This typically takes the form of
-a function/method call.
-
-**Assert** is where we look at that resulting state and check if it looks how
-we'd expect after the dust has settled. It's where we gather evidence to say the
-behavior does or does not aligns with what we expect. The ``assert`` in our test
-is where we take that measurement/observation and apply our judgement to it. If
-something should be green, we'd say ``assert thing == "green"``.
-
-**Cleanup** is where the test picks up after itself, so other tests aren't being
-accidentally influenced by it.
-
-At it's core, the test is ultimately the **act** and **assert** steps, with the
-**arrange** step only providing the context. **Behavior** exists between **act**
-and **assert**.
-
-Back to fixtures
-^^^^^^^^^^^^^^^^
-
-"Fixtures", in the literal sense, are each of the **arrange** steps and data. They're
-everything that test needs to do its thing.
-
-At a basic level, test functions request fixtures by declaring them as
-arguments, as in the ``test_ehlo(smtp_connection):`` in the previous example.
-
-In pytest, "fixtures" are functions you define that serve this purpose. But they
-don't have to be limited to just the **arrange** steps. They can provide the
-**act** step, as well, and this can be a powerful technique for designing more
-complex tests, especially given how pytest's fixture system works. But we'll get
-into that further down.
-
-We can tell pytest that a particular function is a fixture by decorating it with
-:py:func:`@pytest.fixture <pytest.fixture>`. Here's a simple example of
-what a fixture in pytest might look like:
-
-.. code-block:: python
-
-    import pytest
-
-
-    class Fruit:
-        def __init__(self, name):
-            self.name = name
-
-        def __eq__(self, other):
-            return self.name == other.name
-
-
-    @pytest.fixture
-    def my_fruit():
-        return Fruit("apple")
-
-
-    @pytest.fixture
-    def fruit_basket(my_fruit):
-        return [Fruit("banana"), my_fruit]
-
-
-    def test_my_fruit_in_basket(my_fruit, fruit_basket):
-        assert my_fruit in fruit_basket
-
-
-
-Tests don't have to be limited to a single fixture, either. They can depend on
-as many fixtures as you want, and fixtures can use other fixtures, as well. This
-is where pytest's fixture system really shines.
-
-Don't be afraid to break things up if it makes things cleaner.
-
-"Requesting" fixtures
----------------------
-
-So fixtures are how we *prepare* for a test, but how do we tell pytest what
-tests and fixtures need which fixtures?
-
-At a basic level, test functions request fixtures by declaring them as
-arguments, as in the ``test_my_fruit_in_basket(my_fruit, fruit_basket):`` in the
-previous example.
-
-At a basic level, pytest depends on a test to tell it what fixtures it needs, so
-we have to build that information into the test itself. We have to make the test
-"**request**" the fixtures it depends on, and to do this, we have to
-list those fixtures as parameters in the test function's "signature" (which is
-the ``def test_something(blah, stuff, more):`` line).
-
-When pytest goes to run a test, it looks at the parameters in that test
-function's signature, and then searches for fixtures that have the same names as
-those parameters. Once pytest finds them, it runs those fixtures, captures what
-they returned (if anything), and passes those objects into the test function as
-arguments.
-
-Quick example
-^^^^^^^^^^^^^
-
-.. code-block:: python
-
-    import pytest
-
-
-    class Fruit:
-        def __init__(self, name):
-            self.name = name
-            self.cubed = False
-
-        def cube(self):
-            self.cubed = True
-
-
-    class FruitSalad:
-        def __init__(self, *fruit_bowl):
-            self.fruit = fruit_bowl
-            self._cube_fruit()
-
-        def _cube_fruit(self):
-            for fruit in self.fruit:
-                fruit.cube()
-
-
-    # Arrange
-    @pytest.fixture
-    def fruit_bowl():
-        return [Fruit("apple"), Fruit("banana")]
-
-
-    def test_fruit_salad(fruit_bowl):
-        # Act
-        fruit_salad = FruitSalad(*fruit_bowl)
-
-        # Assert
-        assert all(fruit.cubed for fruit in fruit_salad.fruit)
-
-In this example, ``test_fruit_salad`` "**requests**" ``fruit_bowl`` (i.e.
-``def test_fruit_salad(fruit_bowl):``), and when pytest sees this, it will
-execute the ``fruit_bowl`` fixture function and pass the object it returns into
-``test_fruit_salad`` as the ``fruit_bowl`` argument.
-
-Here's roughly
-what's happening if we were to do it by hand:
-
-.. code-block:: python
-
-    def fruit_bowl():
-        return [Fruit("apple"), Fruit("banana")]
-
-
-    def test_fruit_salad(fruit_bowl):
-        # Act
-        fruit_salad = FruitSalad(*fruit_bowl)
-
-        # Assert
-        assert all(fruit.cubed for fruit in fruit_salad.fruit)
-
-
-    # Arrange
-    bowl = fruit_bowl()
-    test_fruit_salad(fruit_bowl=bowl)
-
-Fixtures can **request** other fixtures
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-One of pytest's greatest strengths is its extremely flexible fixture system. It
-allows us to boil down complex requirements for tests into more simple and
-organized functions, where we only need to have each one describe the things
-they are dependent on. We'll get more into this further down, but for now,
-here's a quick example to demonstrate how fixtures can use other fixtures:
-
-.. code-block:: python
-
-    # contents of test_append.py
-    import pytest
-
-
-    # Arrange
-    @pytest.fixture
-    def first_entry():
-        return "a"
-
-
-    # Arrange
-    @pytest.fixture
-    def order(first_entry):
-        return [first_entry]
-
-
-    def test_string(order):
-        # Act
-        order.append("b")
-
-        # Assert
-        assert order == ["a", "b"]
-
-
-Notice that this is the same example from above, but very little changed. The
-fixtures in pytest **request** fixtures just like tests. All the same
-**requesting** rules apply to fixtures that do for tests. Here's how this
-example would work if we did it by hand:
-
-.. code-block:: python
-
-    def first_entry():
-        return "a"
-
-
-    def order(first_entry):
-        return [first_entry]
-
-
-    def test_string(order):
-        # Act
-        order.append("b")
-
-        # Assert
-        assert order == ["a", "b"]
-
-
-    entry = first_entry()
-    the_list = order(first_entry=entry)
-    test_string(order=the_list)
-
-Fixtures are reusable
-^^^^^^^^^^^^^^^^^^^^^
-
-One of the things that makes pytest's fixture system so powerful, is that it
-gives us the abilty to define a generic setup step that can reused over and
-over, just like a normal function would be used. Two different tests can request
-the same fixture and have pytest give each test their own result from that
-fixture.
-
-This is extremely useful for making sure tests aren't affected by each other. We
-can use this system to make sure each test gets its own fresh batch of data and
-is starting from a clean state so it can provide consistent, repeatable results.
-
-Here's an example of how this can come in handy:
-
-.. code-block:: python
-
-    # contents of test_append.py
-    import pytest
-
-
-    # Arrange
-    @pytest.fixture
-    def first_entry():
-        return "a"
-
-
-    # Arrange
-    @pytest.fixture
-    def order(first_entry):
-        return [first_entry]
-
-
-    def test_string(order):
-        # Act
-        order.append("b")
-
-        # Assert
-        assert order == ["a", "b"]
-
-
-    def test_int(order):
-        # Act
-        order.append(2)
-
-        # Assert
-        assert order == ["a", 2]
-
-
-Each test here is being given its own copy of that ``list`` object,
-which means the ``order`` fixture is getting executed twice (the same
-is true for the ``first_entry`` fixture). If we were to do this by hand as
-well, it would look something like this:
-
-.. code-block:: python
-
-    def first_entry():
-        return "a"
-
-
-    def order(first_entry):
-        return [first_entry]
-
-
-    def test_string(order):
-        # Act
-        order.append("b")
-
-        # Assert
-        assert order == ["a", "b"]
-
-
-    def test_int(order):
-        # Act
-        order.append(2)
-
-        # Assert
-        assert order == ["a", 2]
-
-
-    entry = first_entry()
-    the_list = order(first_entry=entry)
-    test_string(order=the_list)
-
-    entry = first_entry()
-    the_list = order(first_entry=entry)
-    test_int(order=the_list)
-
-A test/fixture can **request** more than one fixture at a time
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Tests and fixtures aren't limited to **requesting** a single fixture at a time.
-They can request as many as they like. Here's another quick example to
-demonstrate:
-
-.. code-block:: python
-
-    # contents of test_append.py
-    import pytest
-
-
-    # Arrange
-    @pytest.fixture
-    def first_entry():
-        return "a"
-
-
-    # Arrange
-    @pytest.fixture
-    def second_entry():
-        return 2
-
-
-    # Arrange
-    @pytest.fixture
-    def order(first_entry, second_entry):
-        return [first_entry, second_entry]
-
-
-    # Arrange
-    @pytest.fixture
-    def expected_list():
-        return ["a", 2, 3.0]
-
-
-    def test_string(order, expected_list):
-        # Act
-        order.append(3.0)
-
-        # Assert
-        assert order == expected_list
-
-Fixtures can be **requested** more than once per test (return values are cached)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Fixtures can also be **requested** more than once during the same test, and
-pytest won't execute them again for that test. This means we can **request**
-fixtures in multiple fixtures that are dependent on them (and even again in the
-test itself) without those fixtures being executed more than once.
-
-.. code-block:: python
-
-    # contents of test_append.py
-    import pytest
-
-
-    # Arrange
-    @pytest.fixture
-    def first_entry():
-        return "a"
-
-
-    # Arrange
-    @pytest.fixture
-    def order():
-        return []
-
-
-    # Act
-    @pytest.fixture
-    def append_first(order, first_entry):
-        return order.append(first_entry)
-
-
-    def test_string_only(append_first, order, first_entry):
-        # Assert
-        assert order == [first_entry]
-
-If a **requested** fixture was executed once for every time it was **requested**
-during a test, then this test would fail because both ``append_first`` and
-``test_string_only`` would see ``order`` as an empty list (i.e. ``[]``), but
-since the return value of ``order`` was cached (along with any side effects
-executing it may have had) after the first time it was called, both the test and
-``append_first`` were referencing the same object, and the test saw the effect
-``append_first`` had on that object.
-
-.. _`autouse`:
-.. _`autouse fixtures`:
-
-Autouse fixtures (fixtures you don't have to request)
------------------------------------------------------
-
-Sometimes you may want to have a fixture (or even several) that you know all
-your tests will depend on. "Autouse" fixtures are a convenient way to make all
-tests automatically **request** them. This can cut out a
-lot of redundant **requests**, and can even provide more advanced fixture usage
-(more on that further down).
-
-We can make a fixture an autouse fixture by passing in ``autouse=True`` to the
-fixture's decorator. Here's a simple example for how they can be used:
-
-.. code-block:: python
-
-    # contents of test_append.py
-    import pytest
-
-
-    @pytest.fixture
-    def first_entry():
-        return "a"
-
-
-    @pytest.fixture
-    def order(first_entry):
-        return []
-
-
-    @pytest.fixture(autouse=True)
-    def append_first(order, first_entry):
-        return order.append(first_entry)
-
-
-    def test_string_only(order, first_entry):
-        assert order == [first_entry]
-
-
-    def test_string_and_int(order, first_entry):
-        order.append(2)
-        assert order == [first_entry, 2]
-
-In this example, the ``append_first`` fixture is an autouse fixture. Because it
-happens automatically, both tests are affected by it, even though neither test
-**requested** it. That doesn't mean they *can't* be **requested** though; just
-that it isn't *necessary*.
-
-.. _smtpshared:
-
-Scope: sharing fixtures across classes, modules, packages or session
---------------------------------------------------------------------
-
-.. regendoc:wipe
-
-Fixtures requiring network access depend on connectivity and are
-usually time-expensive to create.  Extending the previous example, we
-can add a ``scope="module"`` parameter to the
-:py:func:`@pytest.fixture <pytest.fixture>` invocation
-to cause a ``smtp_connection`` fixture function, responsible to create a connection to a preexisting SMTP server, to only be invoked
-once per test *module* (the default is to invoke once per test *function*).
-Multiple test functions in a test module will thus
-each receive the same ``smtp_connection`` fixture instance, thus saving time.
-Possible values for ``scope`` are: ``function``, ``class``, ``module``, ``package`` or ``session``.
-
-The next example puts the fixture function into a separate ``conftest.py`` file
-so that tests from multiple test modules in the directory can
-access the fixture function:
-
-.. code-block:: python
-
-    # content of conftest.py
-    import pytest
-    import smtplib
-
-
-    @pytest.fixture(scope="module")
-    def smtp_connection():
-        return smtplib.SMTP("smtp.gmail.com", 587, timeout=5)
-
-
-.. code-block:: python
-
-    # content of test_module.py
-
-
-    def test_ehlo(smtp_connection):
-        response, msg = smtp_connection.ehlo()
-        assert response == 250
-        assert b"smtp.gmail.com" in msg
-        assert 0  # for demo purposes
-
-
-    def test_noop(smtp_connection):
-        response, msg = smtp_connection.noop()
-        assert response == 250
-        assert 0  # for demo purposes
-
-Here, the ``test_ehlo`` needs the ``smtp_connection`` fixture value.  pytest
-will discover and call the :py:func:`@pytest.fixture <pytest.fixture>`
-marked ``smtp_connection`` fixture function.  Running the test looks like this:
-
-.. code-block:: pytest
-
-    $ pytest test_module.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 2 items
-
-    test_module.py FF                                                    [100%]
-
-    ================================= FAILURES =================================
-    ________________________________ test_ehlo _________________________________
-
-    smtp_connection = <smtplib.SMTP object at 0xdeadbeef>
-
-        def test_ehlo(smtp_connection):
-            response, msg = smtp_connection.ehlo()
-            assert response == 250
-            assert b"smtp.gmail.com" in msg
-    >       assert 0  # for demo purposes
-    E       assert 0
-
-    test_module.py:7: AssertionError
-    ________________________________ test_noop _________________________________
-
-    smtp_connection = <smtplib.SMTP object at 0xdeadbeef>
-
-        def test_noop(smtp_connection):
-            response, msg = smtp_connection.noop()
-            assert response == 250
-    >       assert 0  # for demo purposes
-    E       assert 0
-
-    test_module.py:13: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_module.py::test_ehlo - assert 0
-    FAILED test_module.py::test_noop - assert 0
-    ============================ 2 failed in 0.12s =============================
-
-You see the two ``assert 0`` failing and more importantly you can also see
-that the **exactly same** ``smtp_connection`` object was passed into the
-two test functions because pytest shows the incoming argument values in the
-traceback.  As a result, the two test functions using ``smtp_connection`` run
-as quick as a single one because they reuse the same instance.
-
-If you decide that you rather want to have a session-scoped ``smtp_connection``
-instance, you can simply declare it:
-
-.. code-block:: python
-
-    @pytest.fixture(scope="session")
-    def smtp_connection():
-        # the returned fixture value will be shared for
-        # all tests requesting it
-        ...
-
-
-Fixture scopes
-^^^^^^^^^^^^^^
-
-Fixtures are created when first requested by a test, and are destroyed based on their ``scope``:
-
-* ``function``: the default scope, the fixture is destroyed at the end of the test.
-* ``class``: the fixture is destroyed during teardown of the last test in the class.
-* ``module``: the fixture is destroyed during teardown of the last test in the module.
-* ``package``: the fixture is destroyed during teardown of the last test in the package.
-* ``session``: the fixture is destroyed at the end of the test session.
-
-.. note::
-
-    Pytest only caches one instance of a fixture at a time, which
-    means that when using a parametrized fixture, pytest may invoke a fixture more than once in
-    the given scope.
-
-.. _dynamic scope:
-
-Dynamic scope
-^^^^^^^^^^^^^
-
-.. versionadded:: 5.2
-
-In some cases, you might want to change the scope of the fixture without changing the code.
-To do that, pass a callable to ``scope``. The callable must return a string with a valid scope
-and will be executed only once - during the fixture definition. It will be called with two
-keyword arguments - ``fixture_name`` as a string and ``config`` with a configuration object.
-
-This can be especially useful when dealing with fixtures that need time for setup, like spawning
-a docker container. You can use the command-line argument to control the scope of the spawned
-containers for different environments. See the example below.
-
-.. code-block:: python
-
-    def determine_scope(fixture_name, config):
-        if config.getoption("--keep-containers", None):
-            return "session"
-        return "function"
-
-
-    @pytest.fixture(scope=determine_scope)
-    def docker_container():
-        yield spawn_container()
-
-Fixture errors
---------------
-
-pytest does its best to put all the fixtures for a given test in a linear order
-so that it can see which fixture happens first, second, third, and so on. If an
-earlier fixture has a problem, though, and raises an exception, pytest will stop
-executing fixtures for that test and mark the test as having an error.
-
-When a test is marked as having an error, it doesn't mean the test failed,
-though. It just means the test couldn't even be attempted because one of the
-things it depends on had a problem.
-
-This is one reason why it's a good idea to cut out as many unnecessary
-dependencies as possible for a given test. That way a problem in something
-unrelated isn't causing us to have an incomplete picture of what may or may not
-have issues.
-
-Here's a quick example to help explain:
-
-.. code-block:: python
-
-    import pytest
-
-
-    @pytest.fixture
-    def order():
-        return []
-
-
-    @pytest.fixture
-    def append_first(order):
-        order.append(1)
-
-
-    @pytest.fixture
-    def append_second(order, append_first):
-        order.extend([2])
-
-
-    @pytest.fixture(autouse=True)
-    def append_third(order, append_second):
-        order += [3]
-
-
-    def test_order(order):
-        assert order == [1, 2, 3]
-
-
-If, for whatever reason, ``order.append(1)`` had a bug and it raises an exception,
-we wouldn't be able to know if ``order.extend([2])`` or ``order += [3]`` would
-also have problems. After ``append_first`` throws an exception, pytest won't run
-any more fixtures for ``test_order``, and it won't even try to run
-``test_order`` itself. The only things that would've run would be ``order`` and
-``append_first``.
-
-
-
-
-.. _`finalization`:
-
-Teardown/Cleanup (AKA Fixture finalization)
--------------------------------------------
-
-When we run our tests, we'll want to make sure they clean up after themselves so
-they don't mess with any other tests (and also so that we don't leave behind a
-mountain of test data to bloat the system). Fixtures in pytest offer a very
-useful teardown system, which allows us to define the specific steps necessary
-for each fixture to clean up after itself.
-
-This system can be leveraged in two ways.
-
-.. _`yield fixtures`:
-
-1. ``yield`` fixtures (recommended)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-"Yield" fixtures ``yield`` instead of ``return``. With these
-fixtures, we can run some code and pass an object back to the requesting
-fixture/test, just like with the other fixtures. The only differences are:
-
-1. ``return`` is swapped out for ``yield``.
-2. Any teardown code for that fixture is placed *after* the ``yield``.
-
-Once pytest figures out a linear order for the fixtures, it will run each one up
-until it returns or yields, and then move on to the next fixture in the list to
-do the same thing.
-
-Once the test is finished, pytest will go back down the list of fixtures, but in
-the *reverse order*, taking each one that yielded, and running the code inside
-it that was *after* the ``yield`` statement.
-
-As a simple example, let's say we want to test sending email from one user to
-another. We'll have to first make each user, then send the email from one user
-to the other, and finally assert that the other user received that message in
-their inbox. If we want to clean up after the test runs, we'll likely have to
-make sure the other user's mailbox is emptied before deleting that user,
-otherwise the system may complain.
-
-Here's what that might look like:
-
-.. code-block:: python
-
-    import pytest
-
-    from emaillib import Email, MailAdminClient
-
-
-    @pytest.fixture
-    def mail_admin():
-        return MailAdminClient()
-
-
-    @pytest.fixture
-    def sending_user(mail_admin):
-        user = mail_admin.create_user()
-        yield user
-        admin_client.delete_user(user)
-
-
-    @pytest.fixture
-    def receiving_user(mail_admin):
-        user = mail_admin.create_user()
-        yield user
-        admin_client.delete_user(user)
-
-
-    def test_email_received(receiving_user, email):
-        email = Email(subject="Hey!", body="How's it going?")
-        sending_user.send_email(_email, receiving_user)
-        assert email in receiving_user.inbox
-
-Because ``receiving_user`` is the last fixture to run during setup, it's the first to run
-during teardown.
-
-There is a risk that even having the order right on the teardown side of things
-doesn't guarantee a safe cleanup. That's covered in a bit more detail in
-:ref:`safe teardowns`.
-
-Handling errors for yield fixture
-"""""""""""""""""""""""""""""""""
-
-If a yield fixture raises an exception before yielding, pytest won't try to run
-the teardown code after that yield fixture's ``yield`` statement. But, for every
-fixture that has already run successfully for that test, pytest will still
-attempt to tear them down as it normally would.
-
-2. Adding finalizers directly
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-While yield fixtures are considered to be the cleaner and more straighforward
-option, there is another choice, and that is to add "finalizer" functions
-directly to the test's `request-context`_ object. It brings a similar result as
-yield fixtures, but requires a bit more verbosity.
-
-In order to use this approach, we have to request the `request-context`_ object
-(just like we would request another fixture) in the fixture we need to add
-teardown code for, and then pass a callable, containing that teardown code, to
-its ``addfinalizer`` method.
-
-We have to be careful though, because pytest will run that finalizer once it's
-been added, even if that fixture raises an exception after adding the finalizer.
-So to make sure we don't run the finalizer code when we wouldn't need to, we
-would only add the finalizer once the fixture would have done something that
-we'd need to teardown.
-
-Here's how the previous example would look using the ``addfinalizer`` method:
-
-.. code-block:: python
-
-    import pytest
-
-    from emaillib import Email, MailAdminClient
-
-
-    @pytest.fixture
-    def mail_admin():
-        return MailAdminClient()
-
-
-    @pytest.fixture
-    def sending_user(mail_admin):
-        user = mail_admin.create_user()
-        yield user
-        admin_client.delete_user(user)
-
-
-    @pytest.fixture
-    def receiving_user(mail_admin, request):
-        user = mail_admin.create_user()
-
-        def delete_user():
-            admin_client.delete_user(user)
-
-        request.addfinalizer(delete_user)
-        return user
-
-
-    @pytest.fixture
-    def email(sending_user, receiving_user, request):
-        _email = Email(subject="Hey!", body="How's it going?")
-        sending_user.send_email(_email, receiving_user)
-
-        def empty_mailbox():
-            receiving_user.delete_email(_email)
-
-        request.addfinalizer(empty_mailbox)
-        return _email
-
-
-    def test_email_received(receiving_user, email):
-        assert email in receiving_user.inbox
-
-
-It's a bit longer than yield fixtures and a bit more complex, but it
-does offer some nuances for when you're in a pinch.
-
-.. _`safe teardowns`:
-
-Safe teardowns
---------------
-
-The fixture system of pytest is *very* powerful, but it's still being run by a
-computer, so it isn't able to figure out how to safely teardown everything we
-throw at it. If we aren't careful, an error in the wrong spot might leave stuff
-from our tests behind, and that can cause further issues pretty quickly.
-
-For example, consider the following tests (based off of the mail example from
-above):
-
-.. code-block:: python
-
-    import pytest
-
-    from emaillib import Email, MailAdminClient
-
-
-    @pytest.fixture
-    def setup():
-        mail_admin = MailAdminClient()
-        sending_user = mail_admin.create_user()
-        receiving_user = mail_admin.create_user()
-        email = Email(subject="Hey!", body="How's it going?")
-        sending_user.send_emai(email, receiving_user)
-        yield receiving_user, email
-        receiving_user.delete_email(email)
-        admin_client.delete_user(sending_user)
-        admin_client.delete_user(receiving_user)
-
-
-    def test_email_received(setup):
-        receiving_user, email = setup
-        assert email in receiving_user.inbox
-
-This version is a lot more compact, but it's also harder to read, doesn't have a
-very descriptive fixture name, and none of the fixtures can be reused easily.
-
-There's also a more serious issue, which is that if any of those steps in the
-setup raise an exception, none of the teardown code will run.
-
-One option might be to go with the ``addfinalizer`` method instead of yield
-fixtures, but that might get pretty complex and difficult to maintain (and it
-wouldn't be compact anymore).
-
-.. _`safe fixture structure`:
-
-Safe fixture structure
-^^^^^^^^^^^^^^^^^^^^^^
-
-The safest and simplest fixture structure requires limiting fixtures to only
-making one state-changing action each, and then bundling them together with
-their teardown code, as :ref:`the email examples above <yield fixtures>` showed.
-
-The chance that a state-changing operation can fail but still modify state is
-neglibible, as most of these operations tend to be `transaction`_-based (at
-least at the level of testing where state could be left behind). So if we make
-sure that any successful state-changing action gets torn down by moving it to a
-separate fixture function and separating it from other, potentially failing
-state-changing actions, then our tests will stand the best chance at leaving the
-test environment the way they found it.
-
-For an example, let's say we have a website with a login page, and we have
-access to an admin API where we can generate users. For our test, we want to:
-
-1. Create a user through that admin API
-2. Launch a browser using Selenium
-3. Go to the login page of our site
-4. Log in as the user we created
-5. Assert that their name is in the header of the landing page
-
-We wouldn't want to leave that user in the system, nor would we want to leave
-that browser session running, so we'll want to make sure the fixtures that
-create those things clean up after themselves.
-
-Here's what that might look like:
-
-.. note::
-
-    For this example, certain fixtures (i.e. ``base_url`` and
-    ``admin_credentials``) are implied to exist elsewhere. So for now, let's
-    assume they exist, and we're just not looking at them.
-
-.. code-block:: python
-
-    from uuid import uuid4
-    from urllib.parse import urljoin
-
-    from selenium.webdriver import Chrome
-    import pytest
-
-    from src.utils.pages import LoginPage, LandingPage
-    from src.utils import AdminApiClient
-    from src.utils.data_types import User
-
-
-    @pytest.fixture
-    def admin_client(base_url, admin_credentials):
-        return AdminApiClient(base_url, **admin_credentials)
-
-
-    @pytest.fixture
-    def user(admin_client):
-        _user = User(name="Susan", username=f"testuser-{uuid4()}", password="P4$$word")
-        admin_client.create_user(_user)
-        yield _user
-        admin_client.delete_user(_user)
-
-
-    @pytest.fixture
-    def driver():
-        _driver = Chrome()
-        yield _driver
-        _driver.quit()
-
-
-    @pytest.fixture
-    def login(driver, base_url, user):
-        driver.get(urljoin(base_url, "/login"))
-        page = LoginPage(driver)
-        page.login(user)
-
-
-    @pytest.fixture
-    def landing_page(driver, login):
-        return LandingPage(driver)
-
-
-    def test_name_on_landing_page_after_login(landing_page, user):
-        assert landing_page.header == f"Welcome, {user.name}!"
-
-The way the dependencies are laid out means it's unclear if the ``user`` fixture
-would execute before the ``driver`` fixture. But that's ok, because those are
-atomic operations, and so it doesn't matter which one runs first because the
-sequence of events for the test is still `linearizable`_. But what *does* matter
-is that, no matter which one runs first, if the one raises an exception while
-the other would not have, neither will have left anything behind. If ``driver``
-executes before ``user``, and ``user`` raises an exception, the driver will
-still quit, and the user was never made. And if ``driver`` was the one to raise
-the exception, then the driver would never have been started and the user would
-never have been made.
-
-.. note:
-
-    While the ``user`` fixture doesn't *actually* need to happen before the
-    ``driver`` fixture, if we made ``driver`` request ``user``, it might save
-    some time in the event that making the user raises an exception, since it
-    won't bother trying to start the driver, which is a fairly expensive
-    operation.
-
-.. _`conftest.py`:
-.. _`conftest`:
-
-Fixture availabiility
----------------------
-
-Fixture availability is determined from the perspective of the test. A fixture
-is only available for tests to request if they are in the scope that fixture is
-defined in. If a fixture is defined inside a class, it can only be requested by
-tests inside that class. But if a fixture is defined inside the global scope of
-the module, than every test in that module, even if it's defined inside a class,
-can request it.
-
-Similarly, a test can also only be affected by an autouse fixture if that test
-is in the same scope that autouse fixture is defined in (see
-:ref:`autouse order`).
-
-A fixture can also request any other fixture, no matter where it's defined, so
-long as the test requesting them can see all fixtures involved.
-
-For example, here's a test file with a fixture (``outer``) that requests a
-fixture (``inner``) from a scope it wasn't defined in:
-
-.. literalinclude:: example/fixtures/test_fixtures_request_different_scope.py
-
-From the tests' perspectives, they have no problem seeing each of the fixtures
-they're dependent on:
-
-.. image:: example/fixtures/test_fixtures_request_different_scope.svg
-    :align: center
-
-So when they run, ``outer`` will have no problem finding ``inner``, because
-pytest searched from the tests' perspectives.
-
-.. note::
-    The scope a fixture is defined in has no bearing on the order it will be
-    instantiated in: the order is mandated by the logic described
-    :ref:`here <fixture order>`.
-
-``conftest.py``: sharing fixtures across multiple files
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-The ``conftest.py`` file serves as a means of providing fixtures for an entire
-directory. Fixtures defined in a ``conftest.py`` can be used by any test
-in that package without needing to import them (pytest will automatically
-discover them).
-
-You can have multiple nested directories/packages containing your tests, and
-each directory can have its own ``conftest.py`` with its own fixtures, adding on
-to the ones provided by the ``conftest.py`` files in parent directories.
-
-For example, given a test file structure like this:
-
-::
-
-    tests/
-        __init__.py
-
-        conftest.py
-            # content of tests/conftest.py
-            import pytest
-
-            @pytest.fixture
-            def order():
-                return []
-
-            @pytest.fixture
-            def top(order, innermost):
-                order.append("top")
-
-        test_top.py
-            # content of tests/test_top.py
-            import pytest
-
-            @pytest.fixture
-            def innermost(order):
-                order.append("innermost top")
-
-            def test_order(order, top):
-                assert order == ["innermost top", "top"]
-
-        subpackage/
-            __init__.py
-
-            conftest.py
-                # content of tests/subpackage/conftest.py
-                import pytest
-
-                @pytest.fixture
-                def mid(order):
-                    order.append("mid subpackage")
-
-            test_subpackage.py
-                # content of tests/subpackage/test_subpackage.py
-                import pytest
-
-                @pytest.fixture
-                def innermost(order, mid):
-                    order.append("innermost subpackage")
-
-                def test_order(order, top):
-                    assert order == ["mid subpackage", "innermost subpackage", "top"]
-
-The boundaries of the scopes can be visualized like this:
-
-.. image:: example/fixtures/fixture_availability.svg
-    :align: center
-
-The directories become their own sort of scope where fixtures that are defined
-in a ``conftest.py`` file in that directory become available for that whole
-scope.
-
-Tests are allowed to search upward (stepping outside a circle) for fixtures, but
-can never go down (stepping inside a circle) to continue their search. So
-``tests/subpackage/test_subpackage.py::test_order`` would be able to find the
-``innermost`` fixture defined in ``tests/subpackage/test_subpackage.py``, but
-the one defined in ``tests/test_top.py`` would be unavailable to it because it
-would have to step down a level (step inside a circle) to find it.
-
-The first fixture the test finds is the one that will be used, so
-:ref:`fixtures can be overriden <override fixtures>` if you need to change or
-extend what one does for a particular scope.
-
-You can also use the ``conftest.py`` file to implement
-:ref:`local per-directory plugins <conftest.py plugins>`.
-
-Fixtures from third-party plugins
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Fixtures don't have to be defined in this structure to be available for tests,
-though. They can also be provided by third-party plugins that are installed, and
-this is how many pytest plugins operate. As long as those plugins are installed,
-the fixtures they provide can be requested from anywhere in your test suite.
-
-Because they're provided from outside the structure of your test suite,
-third-party plugins don't really provide a scope like `conftest.py` files and
-the directories in your test suite do. As a result, pytest will search for
-fixtures stepping out through scopes as explained previously, only reaching
-fixtures defined in plugins *last*.
-
-For example, given the following file structure:
-
-::
-
-    tests/
-        __init__.py
-
-        conftest.py
-            # content of tests/conftest.py
-            import pytest
-
-            @pytest.fixture
-            def order():
-                return []
-
-        subpackage/
-            __init__.py
-
-            conftest.py
-                # content of tests/subpackage/conftest.py
-                import pytest
-
-                @pytest.fixture(autouse=True)
-                def mid(order, b_fix):
-                    order.append("mid subpackage")
-
-            test_subpackage.py
-                # content of tests/subpackage/test_subpackage.py
-                import pytest
-
-                @pytest.fixture
-                def inner(order, mid, a_fix):
-                    order.append("inner subpackage")
-
-                def test_order(order, inner):
-                    assert order == ["b_fix", "mid subpackage", "a_fix", "inner subpackage"]
-
-If ``plugin_a`` is installed and provides the fixture ``a_fix``, and
-``plugin_b`` is installed and provides the fixture ``b_fix``, then this is what
-the test's search for fixtures would look like:
-
-.. image:: example/fixtures/fixture_availability_plugins.svg
-    :align: center
-
-pytest will only search for ``a_fix`` and ``b_fix`` in the plugins after
-searching for them first in the scopes inside ``tests/``.
-
-.. note:
-
-    pytest can tell you what fixtures are available for a given test if you call
-    ``pytests`` along with the test's name (or the scope it's in), and provide
-    the ``--fixtures`` flag, e.g. ``pytest --fixtures test_something.py``
-    (fixtures with names that start with ``_`` will only be shown if you also
-    provide the ``-v`` flag).
-
-Sharing test data
------------------
-
-If you want to make test data from files available to your tests, a good way
-to do this is by loading these data in a fixture for use by your tests.
-This makes use of the automatic caching mechanisms of pytest.
-
-Another good approach is by adding the data files in the ``tests`` folder.
-There are also community plugins available to help managing this aspect of
-testing, e.g. `pytest-datadir <https://pypi.org/project/pytest-datadir/>`__
-and `pytest-datafiles <https://pypi.org/project/pytest-datafiles/>`__.
-
-.. _`fixture order`:
-
-Fixture instantiation order
----------------------------
-
-When pytest wants to execute a test, once it knows what fixtures will be
-executed, it has to figure out the order they'll be executed in. To do this, it
-considers 3 factors:
-
-1. scope
-2. dependencies
-3. autouse
-
-Names of fixtures or tests, where they're defined, the order they're defined in,
-and the order fixtures are requested in have no bearing on execution order
-beyond coincidence. While pytest will try to make sure coincidences like these
-stay consistent from run to run, it's not something that should be depended on.
-If you want to control the order, it's safest to rely on these 3 things and make
-sure dependencies are clearly established.
-
-Higher-scoped fixtures are executed first
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Within a function request for fixtures, those of higher-scopes (such as
-``session``) are executed before lower-scoped fixtures (such as ``function`` or
-``class``).
-
-Here's an example:
-
-.. literalinclude:: example/fixtures/test_fixtures_order_scope.py
-
-The test will pass because the larger scoped fixtures are executing first.
-
-The order breaks down to this:
-
-.. image:: example/fixtures/test_fixtures_order_scope.svg
-    :align: center
-
-Fixtures of the same order execute based on dependencies
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-When a fixture requests another fixture, the other fixture is executed first.
-So if fixture ``a`` requests fixture ``b``, fixture ``b`` will execute first,
-because ``a`` depends on ``b`` and can't operate without it. Even if ``a``
-doesn't need the result of ``b``, it can still request ``b`` if it needs to make
-sure it is executed after ``b``.
-
-For example:
-
-.. literalinclude:: example/fixtures/test_fixtures_order_dependencies.py
-
-If we map out what depends on what, we get something that look like this:
-
-.. image:: example/fixtures/test_fixtures_order_dependencies.svg
-    :align: center
-
-The rules provided by each fixture (as to what fixture(s) each one has to come
-after) are comprehensive enough that it can be flattened to this:
-
-.. image:: example/fixtures/test_fixtures_order_dependencies_flat.svg
-    :align: center
-
-Enough information has to be provided through these requests in order for pytest
-to be able to figure out a clear, linear chain of dependencies, and as a result,
-an order of operations for a given test. If there's any ambiguity, and the order
-of operations can be interpreted more than one way, you should assume pytest
-could go with any one of those interpretations at any point.
-
-For example, if ``d`` didn't request ``c``, i.e.the graph would look like this:
-
-.. image:: example/fixtures/test_fixtures_order_dependencies_unclear.svg
-    :align: center
-
-Because nothing requested ``c`` other than ``g``, and ``g`` also requests ``f``,
-it's now unclear if ``c`` should go before/after ``f``, ``e``, or ``d``. The
-only rules that were set for ``c`` is that it must execute after ``b`` and
-before ``g``.
-
-pytest doesn't know where ``c`` should go in the case, so it should be assumed
-that it could go anywhere between ``g`` and ``b``.
-
-This isn't necessarily bad, but it's something to keep in mind. If the order
-they execute in could affect the behavior a test is targetting, or could
-otherwise influence the result of a test, then the order should be defined
-explicitely in a way that allows pytest to linearize/"flatten" that order.
-
-.. _`autouse order`:
-
-Autouse fixtures are executed first within their scope
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Autouse fixtures are assumed to apply to every test that could reference them,
-so they are executed before other fixtures in that scope. Fixtures that are
-requested by autouse fixtures effectively become autouse fixtures themselves for
-the tests that the real autouse fixture applies to.
-
-So if fixture ``a`` is autouse and fixture ``b`` is not, but fixture ``a``
-requests fixture ``b``, then fixture ``b`` will effectively be an autouse
-fixture as well, but only for the tests that ``a`` applies to.
-
-In the last example, the graph became unclear if ``d`` didn't request ``c``. But
-if ``c`` was autouse, then ``b`` and ``a`` would effectively also be autouse
-because ``c`` depends on them. As a result, they would all be shifted above
-non-autouse fixtures within that scope.
-
-So if the test file looked like this:
-
-.. literalinclude:: example/fixtures/test_fixtures_order_autouse.py
-
-the graph would look like this:
-
-.. image:: example/fixtures/test_fixtures_order_autouse.svg
-    :align: center
-
-Because ``c`` can now be put above ``d`` in the graph, pytest can once again
-linearize the graph to this:
-
-In this example, ``c`` makes ``b`` and ``a`` effectively autouse fixtures as
-well.
-
-Be careful with autouse, though, as an autouse fixture will automatically
-execute for every test that can reach it, even if they don't request it. For
-example, consider this file:
-
-.. literalinclude:: example/fixtures/test_fixtures_order_autouse_multiple_scopes.py
-
-Even though nothing in ``TestClassWithC1Request`` is requesting ``c1``, it still
-is executed for the tests inside it anyway:
-
-.. image:: example/fixtures/test_fixtures_order_autouse_multiple_scopes.svg
-    :align: center
-
-But just because one autouse fixture requested a non-autouse fixture, that
-doesn't mean the non-autouse fixture becomes an autouse fixture for all contexts
-that it can apply to. It only effectively becomes an auotuse fixture for the
-contexts the real autouse fixture (the one that requested the non-autouse
-fixture) can apply to.
-
-For example, take a look at this test file:
-
-.. literalinclude:: example/fixtures/test_fixtures_order_autouse_temp_effects.py
-
-It would break down to something like this:
-
-.. image:: example/fixtures/test_fixtures_order_autouse_temp_effects.svg
-    :align: center
-
-For ``test_req`` and ``test_no_req`` inside ``TestClassWithAutouse``, ``c3``
-effectively makes ``c2`` an autouse fixture, which is why ``c2`` and ``c3`` are
-executed for both tests, despite not being requested, and why ``c2`` and ``c3``
-are executed before ``c1`` for ``test_req``.
-
-If this made ``c2`` an *actual* autouse fixture, then ``c2`` would also execute
-for the tests inside ``TestClassWithoutAutouse``, since they can reference
-``c2`` if they wanted to. But it doesn't, because from the perspective of the
-``TestClassWithoutAutouse`` tests, ``c2`` isn't an autouse fixture, since they
-can't see ``c3``.
-
-
-.. note:
-
-    pytest can tell you what order the fixtures will execute in for a given test
-    if you call ``pytests`` along with the test's name (or the scope it's in),
-    and provide the ``--setup-plan`` flag, e.g.
-    ``pytest --setup-plan test_something.py`` (fixtures with names that start
-    with ``_`` will only be shown if you also provide the ``-v`` flag).
-
-
-Running multiple ``assert`` statements safely
----------------------------------------------
-
-Sometimes you may want to run multiple asserts after doing all that setup, which
-makes sense as, in more complex systems, a single action can kick off multiple
-behaviors. pytest has a convenient way of handling this and it combines a bunch
-of what we've gone over so far.
-
-All that's needed is stepping up to a larger scope, then having the **act**
-step defined as an autouse fixture, and finally, making sure all the fixtures
-are targetting that highler level scope.
-
-Let's pull :ref:`an example from above <safe fixture structure>`, and tweak it a
-bit. Let's say that in addition to checking for a welcome message in the header,
-we also want to check for a sign out button, and a link to the user's profile.
-
-Let's take a look at how we can structure that so we can run multiple asserts
-without having to repeat all those steps again.
-
-.. note::
-
-    For this example, certain fixtures (i.e. ``base_url`` and
-    ``admin_credentials``) are implied to exist elsewhere. So for now, let's
-    assume they exist, and we're just not looking at them.
-
-.. code-block:: python
-
-    # contents of tests/end_to_end/test_login.py
-    from uuid import uuid4
-    from urllib.parse import urljoin
-
-    from selenium.webdriver import Chrome
-    import pytest
-
-    from src.utils.pages import LoginPage, LandingPage
-    from src.utils import AdminApiClient
-    from src.utils.data_types import User
-
-
-    @pytest.fixture(scope="class")
-    def admin_client(base_url, admin_credentials):
-        return AdminApiClient(base_url, **admin_credentials)
-
-
-    @pytest.fixture(scope="class")
-    def user(admin_client):
-        _user = User(name="Susan", username=f"testuser-{uuid4()}", password="P4$$word")
-        admin_client.create_user(_user)
-        yield _user
-        admin_client.delete_user(_user)
-
-
-    @pytest.fixture(scope="class")
-    def driver():
-        _driver = Chrome()
-        yield _driver
-        _driver.quit()
-
-
-    @pytest.fixture(scope="class")
-    def landing_page(driver, login):
-        return LandingPage(driver)
-
-
-    class TestLandingPageSuccess:
-        @pytest.fixture(scope="class", autouse=True)
-        def login(self, driver, base_url, user):
-            driver.get(urljoin(base_url, "/login"))
-            page = LoginPage(driver)
-            page.login(user)
-
-        def test_name_in_header(self, landing_page, user):
-            assert landing_page.header == f"Welcome, {user.name}!"
-
-        def test_sign_out_button(self, landing_page):
-            assert landing_page.sign_out_button.is_displayed()
-
-        def test_profile_link(self, landing_page, user):
-            profile_href = urljoin(base_url, f"/profile?id={user.profile_id}")
-            assert landing_page.profile_link.get_attribute("href") == profile_href
-
-Notice that the methods are only referencing ``self`` in the signature as a
-formality. No state is tied to the actual test class as it might be in the
-``unittest.TestCase`` framework. Everything is managed by the pytest fixture
-system.
-
-Each method only has to request the fixtures that it actually needs without
-worrying about order. This is because the **act** fixture is an autouse fixture,
-and it made sure all the other fixtures executed before it. There's no more
-changes of state that need to take place, so the tests are free to make as many
-non-state-changing queries as they want without risking stepping on the toes of
-the other tests.
-
-The ``login`` fixture is defined inside the class as well, because not every one
-of the other tests in the module will be expecting a successful login, and the **act** may need to
-be handled a little differently for another test class. For example, if we
-wanted to write another test scenario around submitting bad credentials, we
-could handle it by adding something like this to the test file:
-
-.. note:
-
-    It's assumed that the page object for this (i.e. ``LoginPage``) raises a
-    custom exception, ``BadCredentialsException``, when it recognizes text
-    signifying that on the login form after attempting to log in.
-
-.. code-block:: python
-
-    class TestLandingPageBadCredentials:
-        @pytest.fixture(scope="class")
-        def faux_user(self, user):
-            _user = deepcopy(user)
-            _user.password = "badpass"
-            return _user
-
-        def test_raises_bad_credentials_exception(self, login_page, faux_user):
-            with pytest.raises(BadCredentialsException):
-                login_page.login(faux_user)
-
-
-.. _`request-context`:
-
-Fixtures can introspect the requesting test context
--------------------------------------------------------------
-
-Fixture functions can accept the :py:class:`request <_pytest.fixtures.FixtureRequest>` object
-to introspect the "requesting" test function, class or module context.
-Further extending the previous ``smtp_connection`` fixture example, let's
-read an optional server URL from the test module which uses our fixture:
-
-.. code-block:: python
-
-    # content of conftest.py
-    import pytest
-    import smtplib
-
-
-    @pytest.fixture(scope="module")
-    def smtp_connection(request):
-        server = getattr(request.module, "smtpserver", "smtp.gmail.com")
-        smtp_connection = smtplib.SMTP(server, 587, timeout=5)
-        yield smtp_connection
-        print("finalizing {} ({})".format(smtp_connection, server))
-        smtp_connection.close()
-
-We use the ``request.module`` attribute to optionally obtain an
-``smtpserver`` attribute from the test module.  If we just execute
-again, nothing much has changed:
-
-.. code-block:: pytest
-
-    $ pytest -s -q --tb=no
-    FFfinalizing <smtplib.SMTP object at 0xdeadbeef> (smtp.gmail.com)
-
-    ========================= short test summary info ==========================
-    FAILED test_module.py::test_ehlo - assert 0
-    FAILED test_module.py::test_noop - assert 0
-    2 failed in 0.12s
-
-Let's quickly create another test module that actually sets the
-server URL in its module namespace:
-
-.. code-block:: python
-
-    # content of test_anothersmtp.py
-
-    smtpserver = "mail.python.org"  # will be read by smtp fixture
-
-
-    def test_showhelo(smtp_connection):
-        assert 0, smtp_connection.helo()
-
-Running it:
-
-.. code-block:: pytest
-
-    $ pytest -qq --tb=short test_anothersmtp.py
-    F                                                                    [100%]
-    ================================= FAILURES =================================
-    ______________________________ test_showhelo _______________________________
-    test_anothersmtp.py:6: in test_showhelo
-        assert 0, smtp_connection.helo()
-    E   AssertionError: (250, b'mail.python.org')
-    E   assert 0
-    ------------------------- Captured stdout teardown -------------------------
-    finalizing <smtplib.SMTP object at 0xdeadbeef> (mail.python.org)
-    ========================= short test summary info ==========================
-    FAILED test_anothersmtp.py::test_showhelo - AssertionError: (250, b'mail....
-
-voila! The ``smtp_connection`` fixture function picked up our mail server name
-from the module namespace.
-
-.. _`using-markers`:
-
-Using markers to pass data to fixtures
--------------------------------------------------------------
-
-Using the :py:class:`request <_pytest.fixtures.FixtureRequest>` object, a fixture can also access
-markers which are applied to a test function. This can be useful to pass data
-into a fixture from a test:
-
-.. code-block:: python
-
-    import pytest
-
-
-    @pytest.fixture
-    def fixt(request):
-        marker = request.node.get_closest_marker("fixt_data")
-        if marker is None:
-            # Handle missing marker in some way...
-            data = None
-        else:
-            data = marker.args[0]
-
-        # Do something with the data
-        return data
-
-
-    @pytest.mark.fixt_data(42)
-    def test_fixt(fixt):
-        assert fixt == 42
-
-.. _`fixture-factory`:
-
-Factories as fixtures
--------------------------------------------------------------
-
-The "factory as fixture" pattern can help in situations where the result
-of a fixture is needed multiple times in a single test. Instead of returning
-data directly, the fixture instead returns a function which generates the data.
-This function can then be called multiple times in the test.
-
-Factories can have parameters as needed:
-
-.. code-block:: python
-
-    @pytest.fixture
-    def make_customer_record():
-        def _make_customer_record(name):
-            return {"name": name, "orders": []}
-
-        return _make_customer_record
-
-
-    def test_customer_records(make_customer_record):
-        customer_1 = make_customer_record("Lisa")
-        customer_2 = make_customer_record("Mike")
-        customer_3 = make_customer_record("Meredith")
-
-If the data created by the factory requires managing, the fixture can take care of that:
-
-.. code-block:: python
-
-    @pytest.fixture
-    def make_customer_record():
-
-        created_records = []
-
-        def _make_customer_record(name):
-            record = models.Customer(name=name, orders=[])
-            created_records.append(record)
-            return record
-
-        yield _make_customer_record
-
-        for record in created_records:
-            record.destroy()
-
-
-    def test_customer_records(make_customer_record):
-        customer_1 = make_customer_record("Lisa")
-        customer_2 = make_customer_record("Mike")
-        customer_3 = make_customer_record("Meredith")
-
-
-.. _`fixture-parametrize`:
-
-Parametrizing fixtures
------------------------------------------------------------------
-
-Fixture functions can be parametrized in which case they will be called
-multiple times, each time executing the set of dependent tests, i. e. the
-tests that depend on this fixture.  Test functions usually do not need
-to be aware of their re-running.  Fixture parametrization helps to
-write exhaustive functional tests for components which themselves can be
-configured in multiple ways.
-
-Extending the previous example, we can flag the fixture to create two
-``smtp_connection`` fixture instances which will cause all tests using the fixture
-to run twice.  The fixture function gets access to each parameter
-through the special :py:class:`request <FixtureRequest>` object:
-
-.. code-block:: python
-
-    # content of conftest.py
-    import pytest
-    import smtplib
-
-
-    @pytest.fixture(scope="module", params=["smtp.gmail.com", "mail.python.org"])
-    def smtp_connection(request):
-        smtp_connection = smtplib.SMTP(request.param, 587, timeout=5)
-        yield smtp_connection
-        print("finalizing {}".format(smtp_connection))
-        smtp_connection.close()
-
-The main change is the declaration of ``params`` with
-:py:func:`@pytest.fixture <pytest.fixture>`, a list of values
-for each of which the fixture function will execute and can access
-a value via ``request.param``.  No test function code needs to change.
-So let's just do another run:
-
-.. code-block:: pytest
-
-    $ pytest -q test_module.py
-    FFFF                                                                 [100%]
-    ================================= FAILURES =================================
-    ________________________ test_ehlo[smtp.gmail.com] _________________________
-
-    smtp_connection = <smtplib.SMTP object at 0xdeadbeef>
-
-        def test_ehlo(smtp_connection):
-            response, msg = smtp_connection.ehlo()
-            assert response == 250
-            assert b"smtp.gmail.com" in msg
-    >       assert 0  # for demo purposes
-    E       assert 0
-
-    test_module.py:7: AssertionError
-    ________________________ test_noop[smtp.gmail.com] _________________________
-
-    smtp_connection = <smtplib.SMTP object at 0xdeadbeef>
-
-        def test_noop(smtp_connection):
-            response, msg = smtp_connection.noop()
-            assert response == 250
-    >       assert 0  # for demo purposes
-    E       assert 0
-
-    test_module.py:13: AssertionError
-    ________________________ test_ehlo[mail.python.org] ________________________
-
-    smtp_connection = <smtplib.SMTP object at 0xdeadbeef>
-
-        def test_ehlo(smtp_connection):
-            response, msg = smtp_connection.ehlo()
-            assert response == 250
-    >       assert b"smtp.gmail.com" in msg
-    E       AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8\nCHUNKING'
-
-    test_module.py:6: AssertionError
-    -------------------------- Captured stdout setup ---------------------------
-    finalizing <smtplib.SMTP object at 0xdeadbeef>
-    ________________________ test_noop[mail.python.org] ________________________
-
-    smtp_connection = <smtplib.SMTP object at 0xdeadbeef>
-
-        def test_noop(smtp_connection):
-            response, msg = smtp_connection.noop()
-            assert response == 250
-    >       assert 0  # for demo purposes
-    E       assert 0
-
-    test_module.py:13: AssertionError
-    ------------------------- Captured stdout teardown -------------------------
-    finalizing <smtplib.SMTP object at 0xdeadbeef>
-    ========================= short test summary info ==========================
-    FAILED test_module.py::test_ehlo[smtp.gmail.com] - assert 0
-    FAILED test_module.py::test_noop[smtp.gmail.com] - assert 0
-    FAILED test_module.py::test_ehlo[mail.python.org] - AssertionError: asser...
-    FAILED test_module.py::test_noop[mail.python.org] - assert 0
-    4 failed in 0.12s
-
-We see that our two test functions each ran twice, against the different
-``smtp_connection`` instances.  Note also, that with the ``mail.python.org``
-connection the second test fails in ``test_ehlo`` because a
-different server string is expected than what arrived.
-
-pytest will build a string that is the test ID for each fixture value
-in a parametrized fixture, e.g. ``test_ehlo[smtp.gmail.com]`` and
-``test_ehlo[mail.python.org]`` in the above examples.  These IDs can
-be used with ``-k`` to select specific cases to run, and they will
-also identify the specific case when one is failing.  Running pytest
-with ``--collect-only`` will show the generated IDs.
-
-Numbers, strings, booleans and ``None`` will have their usual string
-representation used in the test ID. For other objects, pytest will
-make a string based on the argument name.  It is possible to customise
-the string used in a test ID for a certain fixture value by using the
-``ids`` keyword argument:
-
-.. code-block:: python
-
-   # content of test_ids.py
-   import pytest
-
-
-   @pytest.fixture(params=[0, 1], ids=["spam", "ham"])
-   def a(request):
-       return request.param
-
-
-   def test_a(a):
-       pass
-
-
-   def idfn(fixture_value):
-       if fixture_value == 0:
-           return "eggs"
-       else:
-           return None
-
-
-   @pytest.fixture(params=[0, 1], ids=idfn)
-   def b(request):
-       return request.param
-
-
-   def test_b(b):
-       pass
-
-The above shows how ``ids`` can be either a list of strings to use or
-a function which will be called with the fixture value and then
-has to return a string to use.  In the latter case if the function
-returns ``None`` then pytest's auto-generated ID will be used.
-
-Running the above tests results in the following test IDs being used:
-
-.. code-block:: pytest
-
-   $ pytest --collect-only
-   =========================== test session starts ============================
-   platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-   cachedir: $PYTHON_PREFIX/.pytest_cache
-   rootdir: $REGENDOC_TMPDIR
-   collected 10 items
-
-   <Module test_anothersmtp.py>
-     <Function test_showhelo[smtp.gmail.com]>
-     <Function test_showhelo[mail.python.org]>
-   <Module test_ids.py>
-     <Function test_a[spam]>
-     <Function test_a[ham]>
-     <Function test_b[eggs]>
-     <Function test_b[1]>
-   <Module test_module.py>
-     <Function test_ehlo[smtp.gmail.com]>
-     <Function test_noop[smtp.gmail.com]>
-     <Function test_ehlo[mail.python.org]>
-     <Function test_noop[mail.python.org]>
-
-   ======================= 10 tests collected in 0.12s ========================
-
-.. _`fixture-parametrize-marks`:
-
-Using marks with parametrized fixtures
---------------------------------------
-
-:func:`pytest.param` can be used to apply marks in values sets of parametrized fixtures in the same way
-that they can be used with :ref:`@pytest.mark.parametrize <@pytest.mark.parametrize>`.
-
-Example:
-
-.. code-block:: python
-
-    # content of test_fixture_marks.py
-    import pytest
-
-
-    @pytest.fixture(params=[0, 1, pytest.param(2, marks=pytest.mark.skip)])
-    def data_set(request):
-        return request.param
-
-
-    def test_data(data_set):
-        pass
-
-Running this test will *skip* the invocation of ``data_set`` with value ``2``:
-
-.. code-block::
-
-    $ pytest test_fixture_marks.py -v
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collecting ... collected 3 items
-
-    test_fixture_marks.py::test_data[0] PASSED                           [ 33%]
-    test_fixture_marks.py::test_data[1] PASSED                           [ 66%]
-    test_fixture_marks.py::test_data[2] SKIPPED (unconditional skip)     [100%]
-
-    ======================= 2 passed, 1 skipped in 0.12s =======================
-
-.. _`interdependent fixtures`:
-
-Modularity: using fixtures from a fixture function
-----------------------------------------------------------
-
-In addition to using fixtures in test functions, fixture functions
-can use other fixtures themselves.  This contributes to a modular design
-of your fixtures and allows re-use of framework-specific fixtures across
-many projects.  As a simple example, we can extend the previous example
-and instantiate an object ``app`` where we stick the already defined
-``smtp_connection`` resource into it:
-
-.. code-block:: python
-
-    # content of test_appsetup.py
-
-    import pytest
-
-
-    class App:
-        def __init__(self, smtp_connection):
-            self.smtp_connection = smtp_connection
-
-
-    @pytest.fixture(scope="module")
-    def app(smtp_connection):
-        return App(smtp_connection)
-
-
-    def test_smtp_connection_exists(app):
-        assert app.smtp_connection
-
-Here we declare an ``app`` fixture which receives the previously defined
-``smtp_connection`` fixture and instantiates an ``App`` object with it.  Let's run it:
-
-.. code-block:: pytest
-
-    $ pytest -v test_appsetup.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collecting ... collected 2 items
-
-    test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%]
-    test_appsetup.py::test_smtp_connection_exists[mail.python.org] PASSED [100%]
-
-    ============================ 2 passed in 0.12s =============================
-
-Due to the parametrization of ``smtp_connection``, the test will run twice with two
-different ``App`` instances and respective smtp servers.  There is no
-need for the ``app`` fixture to be aware of the ``smtp_connection``
-parametrization because pytest will fully analyse the fixture dependency graph.
-
-Note that the ``app`` fixture has a scope of ``module`` and uses a
-module-scoped ``smtp_connection`` fixture.  The example would still work if
-``smtp_connection`` was cached on a ``session`` scope: it is fine for fixtures to use
-"broader" scoped fixtures but not the other way round:
-A session-scoped fixture could not use a module-scoped one in a
-meaningful way.
-
-
-.. _`automatic per-resource grouping`:
-
-Automatic grouping of tests by fixture instances
-----------------------------------------------------------
-
-.. regendoc: wipe
-
-pytest minimizes the number of active fixtures during test runs.
-If you have a parametrized fixture, then all the tests using it will
-first execute with one instance and then finalizers are called
-before the next fixture instance is created.  Among other things,
-this eases testing of applications which create and use global state.
-
-The following example uses two parametrized fixtures, one of which is
-scoped on a per-module basis, and all the functions perform ``print`` calls
-to show the setup/teardown flow:
-
-.. code-block:: python
-
-    # content of test_module.py
-    import pytest
-
-
-    @pytest.fixture(scope="module", params=["mod1", "mod2"])
-    def modarg(request):
-        param = request.param
-        print("  SETUP modarg", param)
-        yield param
-        print("  TEARDOWN modarg", param)
-
-
-    @pytest.fixture(scope="function", params=[1, 2])
-    def otherarg(request):
-        param = request.param
-        print("  SETUP otherarg", param)
-        yield param
-        print("  TEARDOWN otherarg", param)
-
-
-    def test_0(otherarg):
-        print("  RUN test0 with otherarg", otherarg)
-
-
-    def test_1(modarg):
-        print("  RUN test1 with modarg", modarg)
-
-
-    def test_2(otherarg, modarg):
-        print("  RUN test2 with otherarg {} and modarg {}".format(otherarg, modarg))
-
-
-Let's run the tests in verbose mode and with looking at the print-output:
-
-.. code-block:: pytest
-
-    $ pytest -v -s test_module.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collecting ... collected 8 items
-
-    test_module.py::test_0[1]   SETUP otherarg 1
-      RUN test0 with otherarg 1
-    PASSED  TEARDOWN otherarg 1
-
-    test_module.py::test_0[2]   SETUP otherarg 2
-      RUN test0 with otherarg 2
-    PASSED  TEARDOWN otherarg 2
-
-    test_module.py::test_1[mod1]   SETUP modarg mod1
-      RUN test1 with modarg mod1
-    PASSED
-    test_module.py::test_2[mod1-1]   SETUP otherarg 1
-      RUN test2 with otherarg 1 and modarg mod1
-    PASSED  TEARDOWN otherarg 1
-
-    test_module.py::test_2[mod1-2]   SETUP otherarg 2
-      RUN test2 with otherarg 2 and modarg mod1
-    PASSED  TEARDOWN otherarg 2
-
-    test_module.py::test_1[mod2]   TEARDOWN modarg mod1
-      SETUP modarg mod2
-      RUN test1 with modarg mod2
-    PASSED
-    test_module.py::test_2[mod2-1]   SETUP otherarg 1
-      RUN test2 with otherarg 1 and modarg mod2
-    PASSED  TEARDOWN otherarg 1
-
-    test_module.py::test_2[mod2-2]   SETUP otherarg 2
-      RUN test2 with otherarg 2 and modarg mod2
-    PASSED  TEARDOWN otherarg 2
-      TEARDOWN modarg mod2
-
-
-    ============================ 8 passed in 0.12s =============================
-
-You can see that the parametrized module-scoped ``modarg`` resource caused an
-ordering of test execution that lead to the fewest possible "active" resources.
-The finalizer for the ``mod1`` parametrized resource was executed before the
-``mod2`` resource was setup.
-
-In particular notice that test_0 is completely independent and finishes first.
-Then test_1 is executed with ``mod1``, then test_2 with ``mod1``, then test_1
-with ``mod2`` and finally test_2 with ``mod2``.
-
-The ``otherarg`` parametrized resource (having function scope) was set up before
-and teared down after every test that used it.
-
-
-.. _`usefixtures`:
-
-Use fixtures in classes and modules with ``usefixtures``
---------------------------------------------------------
-
-.. regendoc:wipe
-
-Sometimes test functions do not directly need access to a fixture object.
-For example, tests may require to operate with an empty directory as the
-current working directory but otherwise do not care for the concrete
-directory.  Here is how you can use the standard `tempfile
-<http://docs.python.org/library/tempfile.html>`_ and pytest fixtures to
-achieve it.  We separate the creation of the fixture into a conftest.py
-file:
-
-.. code-block:: python
-
-    # content of conftest.py
-
-    import os
-    import shutil
-    import tempfile
-
-    import pytest
-
-
-    @pytest.fixture
-    def cleandir():
-        old_cwd = os.getcwd()
-        newpath = tempfile.mkdtemp()
-        os.chdir(newpath)
-        yield
-        os.chdir(old_cwd)
-        shutil.rmtree(newpath)
-
-and declare its use in a test module via a ``usefixtures`` marker:
-
-.. code-block:: python
-
-    # content of test_setenv.py
-    import os
-    import pytest
-
-
-    @pytest.mark.usefixtures("cleandir")
-    class TestDirectoryInit:
-        def test_cwd_starts_empty(self):
-            assert os.listdir(os.getcwd()) == []
-            with open("myfile", "w") as f:
-                f.write("hello")
-
-        def test_cwd_again_starts_empty(self):
-            assert os.listdir(os.getcwd()) == []
-
-Due to the ``usefixtures`` marker, the ``cleandir`` fixture
-will be required for the execution of each test method, just as if
-you specified a "cleandir" function argument to each of them.  Let's run it
-to verify our fixture is activated and the tests pass:
-
-.. code-block:: pytest
-
-    $ pytest -q
-    ..                                                                   [100%]
-    2 passed in 0.12s
-
-You can specify multiple fixtures like this:
-
-.. code-block:: python
-
-    @pytest.mark.usefixtures("cleandir", "anotherfixture")
-    def test():
-        ...
-
-and you may specify fixture usage at the test module level using :globalvar:`pytestmark`:
-
-.. code-block:: python
-
-    pytestmark = pytest.mark.usefixtures("cleandir")
-
-
-It is also possible to put fixtures required by all tests in your project
-into an ini-file:
-
-.. code-block:: ini
-
-    # content of pytest.ini
-    [pytest]
-    usefixtures = cleandir
-
-
-.. warning::
-
-    Note this mark has no effect in **fixture functions**. For example,
-    this **will not work as expected**:
-
-    .. code-block:: python
-
-        @pytest.mark.usefixtures("my_other_fixture")
-        @pytest.fixture
-        def my_fixture_that_sadly_wont_use_my_other_fixture():
-            ...
-
-    Currently this will not generate any error or warning, but this is intended
-    to be handled by `#3664 <https://github.com/pytest-dev/pytest/issues/3664>`_.
-
-.. _`override fixtures`:
-
-Overriding fixtures on various levels
--------------------------------------
-
-In relatively large test suite, you most likely need to ``override`` a ``global`` or ``root`` fixture with a ``locally``
-defined one, keeping the test code readable and maintainable.
-
-Override a fixture on a folder (conftest) level
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Given the tests file structure is:
-
-::
-
-    tests/
-        __init__.py
-
-        conftest.py
-            # content of tests/conftest.py
-            import pytest
-
-            @pytest.fixture
-            def username():
-                return 'username'
-
-        test_something.py
-            # content of tests/test_something.py
-            def test_username(username):
-                assert username == 'username'
-
-        subfolder/
-            __init__.py
-
-            conftest.py
-                # content of tests/subfolder/conftest.py
-                import pytest
-
-                @pytest.fixture
-                def username(username):
-                    return 'overridden-' + username
-
-            test_something.py
-                # content of tests/subfolder/test_something.py
-                def test_username(username):
-                    assert username == 'overridden-username'
-
-As you can see, a fixture with the same name can be overridden for certain test folder level.
-Note that the ``base`` or ``super`` fixture can be accessed from the ``overriding``
-fixture easily - used in the example above.
-
-Override a fixture on a test module level
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Given the tests file structure is:
-
-::
-
-    tests/
-        __init__.py
-
-        conftest.py
-            # content of tests/conftest.py
-            import pytest
-
-            @pytest.fixture
-            def username():
-                return 'username'
-
-        test_something.py
-            # content of tests/test_something.py
-            import pytest
-
-            @pytest.fixture
-            def username(username):
-                return 'overridden-' + username
-
-            def test_username(username):
-                assert username == 'overridden-username'
-
-        test_something_else.py
-            # content of tests/test_something_else.py
-            import pytest
-
-            @pytest.fixture
-            def username(username):
-                return 'overridden-else-' + username
-
-            def test_username(username):
-                assert username == 'overridden-else-username'
-
-In the example above, a fixture with the same name can be overridden for certain test module.
-
-
-Override a fixture with direct test parametrization
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Given the tests file structure is:
-
-::
-
-    tests/
-        __init__.py
-
-        conftest.py
-            # content of tests/conftest.py
-            import pytest
-
-            @pytest.fixture
-            def username():
-                return 'username'
-
-            @pytest.fixture
-            def other_username(username):
-                return 'other-' + username
-
-        test_something.py
-            # content of tests/test_something.py
-            import pytest
-
-            @pytest.mark.parametrize('username', ['directly-overridden-username'])
-            def test_username(username):
-                assert username == 'directly-overridden-username'
-
-            @pytest.mark.parametrize('username', ['directly-overridden-username-other'])
-            def test_username_other(other_username):
-                assert other_username == 'other-directly-overridden-username-other'
-
-In the example above, a fixture value is overridden by the test parameter value. Note that the value of the fixture
-can be overridden this way even if the test doesn't use it directly (doesn't mention it in the function prototype).
-
-
-Override a parametrized fixture with non-parametrized one and vice versa
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Given the tests file structure is:
-
-::
-
-    tests/
-        __init__.py
-
-        conftest.py
-            # content of tests/conftest.py
-            import pytest
-
-            @pytest.fixture(params=['one', 'two', 'three'])
-            def parametrized_username(request):
-                return request.param
-
-            @pytest.fixture
-            def non_parametrized_username(request):
-                return 'username'
-
-        test_something.py
-            # content of tests/test_something.py
-            import pytest
-
-            @pytest.fixture
-            def parametrized_username():
-                return 'overridden-username'
-
-            @pytest.fixture(params=['one', 'two', 'three'])
-            def non_parametrized_username(request):
-                return request.param
-
-            def test_username(parametrized_username):
-                assert parametrized_username == 'overridden-username'
-
-            def test_parametrized_username(non_parametrized_username):
-                assert non_parametrized_username in ['one', 'two', 'three']
-
-        test_something_else.py
-            # content of tests/test_something_else.py
-            def test_username(parametrized_username):
-                assert parametrized_username in ['one', 'two', 'three']
-
-            def test_username(non_parametrized_username):
-                assert non_parametrized_username == 'username'
-
-In the example above, a parametrized fixture is overridden with a non-parametrized version, and
-a non-parametrized fixture is overridden with a parametrized version for certain test module.
-The same applies for the test folder level obviously.
-
-
-Using fixtures from other projects
-----------------------------------
-
-Usually projects that provide pytest support will use :ref:`entry points <setuptools entry points>`,
-so just installing those projects into an environment will make those fixtures available for use.
-
-In case you want to use fixtures from a project that does not use entry points, you can
-define :globalvar:`pytest_plugins` in your top ``conftest.py`` file to register that module
-as a plugin.
-
-Suppose you have some fixtures in ``mylibrary.fixtures`` and you want to reuse them into your
-``app/tests`` directory.
-
-All you need to do is to define :globalvar:`pytest_plugins` in ``app/tests/conftest.py``
-pointing to that module.
-
-.. code-block:: python
-
-    pytest_plugins = "mylibrary.fixtures"
-
-This effectively registers ``mylibrary.fixtures`` as a plugin, making all its fixtures and
-hooks available to tests in ``app/tests``.
-
-.. note::
-
-    Sometimes users will *import* fixtures from other projects for use, however this is not
-    recommended: importing fixtures into a module will register them in pytest
-    as *defined* in that module.
-
-    This has minor consequences, such as appearing multiple times in ``pytest --help``,
-    but it is not **recommended** because this behavior might change/stop working
-    in future versions.
diff --git a/doc/en/flaky.rst b/doc/en/flaky.rst
deleted file mode 100644 (file)
index b6fc152..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-
-Flaky tests
------------
-
-A "flaky" test is one that exhibits intermittent or sporadic failure, that seems to have non-deterministic behaviour. Sometimes it passes, sometimes it fails, and it's not clear why. This page discusses pytest features that can help and other general strategies for identifying, fixing or mitigating them.
-
-Why flaky tests are a problem
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Flaky tests are particularly troublesome when a continuous integration (CI) server is being used, so that all tests must pass before a new code change can be merged. If the test result is not a reliable signal -- that a test failure means the code change broke the test -- developers can become mistrustful of the test results, which can lead to overlooking genuine failures. It is also a source of wasted time as developers must re-run test suites and investigate spurious failures.
-
-
-Potential root causes
-^^^^^^^^^^^^^^^^^^^^^
-
-System state
-~~~~~~~~~~~~
-
-Broadly speaking, a flaky test indicates that the test relies on some system state that is not being appropriately controlled - the test environment is not sufficiently isolated. Higher level tests are more likely to be flaky as they rely on more state.
-
-Flaky tests sometimes appear when a test suite is run in parallel (such as use of pytest-xdist). This can indicate a test is reliant on test ordering.
-
--  Perhaps a different test is failing to clean up after itself and leaving behind data which causes the flaky test to fail.
-- The flaky test is reliant on data from a previous test that doesn't clean up after itself, and in parallel runs that previous test is not always present
-- Tests that modify global state typically cannot be run in parallel.
-
-
-Overly strict assertion
-~~~~~~~~~~~~~~~~~~~~~~~
-
-Overly strict assertions can cause problems with floating point comparison as well as timing issues. `pytest.approx <https://docs.pytest.org/en/stable/reference.html#pytest-approx>`_ is useful here.
-
-
-Pytest features
-^^^^^^^^^^^^^^^
-
-Xfail strict
-~~~~~~~~~~~~
-
-:ref:`pytest.mark.xfail ref` with ``strict=False`` can be used to mark a test so that its failure does not cause the whole build to break. This could be considered like a manual quarantine, and is rather dangerous to use permanently.
-
-
-PYTEST_CURRENT_TEST
-~~~~~~~~~~~~~~~~~~~
-
-:envvar:`PYTEST_CURRENT_TEST` may be useful for figuring out "which test got stuck".
-See :ref:`pytest current test env` for more details.
-
-
-Plugins
-~~~~~~~
-
-Rerunning any failed tests can mitigate the negative effects of flaky tests by giving them additional chances to pass, so that the overall build does not fail. Several pytest plugins support this:
-
-* `flaky <https://github.com/box/flaky>`_
-* `pytest-flakefinder <https://github.com/dropbox/pytest-flakefinder>`_ - `blog post <https://blogs.dropbox.com/tech/2016/03/open-sourcing-pytest-tools/>`_
-* `pytest-rerunfailures <https://github.com/pytest-dev/pytest-rerunfailures>`_
-* `pytest-replay <https://github.com/ESSS/pytest-replay>`_: This plugin helps to reproduce locally crashes or flaky tests observed during CI runs.
-
-Plugins to deliberately randomize tests can help expose tests with state problems:
-
-* `pytest-random-order <https://github.com/jbasko/pytest-random-order>`_
-* `pytest-randomly <https://github.com/pytest-dev/pytest-randomly>`_
-
-
-Other general strategies
-^^^^^^^^^^^^^^^^^^^^^^^^
-
-Split up test suites
-~~~~~~~~~~~~~~~~~~~~
-
-It can be common to split a single test suite into two, such as unit vs integration, and only use the unit test suite as a CI gate. This also helps keep build times manageable as high level tests tend to be slower. However, it means it does become possible for code that breaks the build to be merged, so extra vigilance is needed for monitoring the integration test results.
-
-
-Video/screenshot on failure
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-For UI tests these are important for understanding what the state of the UI was when the test failed. pytest-splinter can be used with plugins like pytest-bdd and can `save a screenshot on test failure <https://pytest-splinter.readthedocs.io/en/latest/#automatic-screenshots-on-test-failure>`_, which can help to isolate the cause.
-
-
-Delete or rewrite the test
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-If the functionality is covered by other tests, perhaps the test can be removed. If not, perhaps it can be rewritten at a lower level which will remove the flakiness or make its source more apparent.
-
-
-Quarantine
-~~~~~~~~~~
-
-Mark Lapierre discusses the `Pros and Cons of Quarantined Tests <https://dev.to/mlapierre/pros-and-cons-of-quarantined-tests-2emj>`_ in a post from 2018.
-
-
-
-CI tools that rerun on failure
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Azure Pipelines (the Azure cloud CI/CD tool, formerly Visual Studio Team Services or VSTS) has a feature to `identify flaky tests <https://docs.microsoft.com/en-us/azure/devops/release-notes/2017/dec-11-vsts#identify-flaky-tests>`_ and rerun failed tests.
-
-
-
-Research
-^^^^^^^^
-
-This is a limited list, please submit an issue or pull request to expand it!
-
-* Gao, Zebao, Yalan Liang, Myra B. Cohen, Atif M. Memon, and Zhen Wang. "Making system user interactive tests repeatable: When and what should we control?." In *Software Engineering (ICSE), 2015 IEEE/ACM 37th IEEE International Conference on*, vol. 1, pp. 55-65. IEEE, 2015.  `PDF <http://www.cs.umd.edu/~atif/pubs/gao-icse15.pdf>`__
-* Palomba, Fabio, and Andy Zaidman. "Does refactoring of test smells induce fixing flaky tests?." In *Software Maintenance and Evolution (ICSME), 2017 IEEE International Conference on*, pp. 1-12. IEEE, 2017. `PDF in Google Drive <https://drive.google.com/file/d/10HdcCQiuQVgW3yYUJD-TSTq1NbYEprl0/view>`__
-*  Bell, Jonathan, Owolabi Legunsen, Michael Hilton, Lamyaa Eloussi, Tifany Yung, and Darko Marinov. "DeFlaker: Automatically detecting flaky tests." In *Proceedings of the 2018 International Conference on Software Engineering*. 2018. `PDF <https://www.jonbell.net/icse18-deflaker.pdf>`__
-
-
-Resources
-^^^^^^^^^
-
-* `Eradicating Non-Determinism in Tests <https://martinfowler.com/articles/nonDeterminism.html>`_ by Martin Fowler, 2011
-* `No more flaky tests on the Go team <https://www.thoughtworks.com/insights/blog/no-more-flaky-tests-go-team>`_ by Pavan Sudarshan, 2012
-* `The Build That Cried Broken: Building Trust in your Continuous Integration Tests <https://www.youtube.com/embed/VotJqV4n8ig>`_ talk (video) by `Angie Jones <http://angiejones.tech/>`_ at SeleniumConf Austin 2017
-* `Test and Code Podcast: Flaky Tests and How to Deal with Them <https://testandcode.com/50>`_ by Brian Okken and Anthony Shaw, 2018
-* Microsoft:
-
-  * `How we approach testing VSTS to enable continuous delivery <https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/>`_ by Brian Harry MS, 2017
-  * `Eliminating Flaky Tests <https://docs.microsoft.com/en-us/azure/devops/learn/devops-at-microsoft/eliminating-flaky-tests>`_ blog and talk (video) by Munil Shah, 2017
-
-* Google:
-
-  * `Flaky Tests at Google and How We Mitigate Them <https://testing.googleblog.com/2016/05/flaky-tests-at-google-and-how-we.html>`_ by John Micco, 2016
-  * `Where do Google's flaky tests come from? <https://testing.googleblog.com/2017/04/where-do-our-flaky-tests-come-from.html>`_  by Jeff Listfield, 2017
index 0c4913edff8704258a36319ef1be38bc79e27444..3bf4527cfb526729d1a9a3184e297f15f534912d 100644 (file)
@@ -7,7 +7,7 @@ pytest-2.3: reasoning for fixture/funcarg evolution
 
 **Target audience**: Reading this document requires basic knowledge of
 python testing, xUnit setup methods and the (previous) basic pytest
-funcarg mechanism, see https://docs.pytest.org/en/stable/historical-notes.html#funcargs-and-pytest-funcarg.
+funcarg mechanism, see :ref:`historical funcargs and pytest.funcargs`.
 If you are new to pytest, then you can simply ignore this
 section and read the other sections.
 
@@ -47,7 +47,7 @@ There are several limitations and difficulties with this approach:
 2. parametrizing the "db" resource is not straight forward:
    you need to apply a "parametrize" decorator or implement a
    :py:func:`~hookspec.pytest_generate_tests` hook
-   calling :py:func:`~python.Metafunc.parametrize` which
+   calling :py:func:`~pytest.Metafunc.parametrize` which
    performs parametrization at the places where the resource
    is used.  Moreover, you need to modify the factory to use an
    ``extrakey`` parameter containing ``request.param`` to the
@@ -113,7 +113,7 @@ This new way of parametrizing funcarg factories should in many cases
 allow to re-use already written factories because effectively
 ``request.param`` was already used when test functions/classes were
 parametrized via
-:py:func:`metafunc.parametrize(indirect=True) <_pytest.python.Metafunc.parametrize>` calls.
+:py:func:`metafunc.parametrize(indirect=True) <pytest.Metafunc.parametrize>` calls.
 
 Of course it's perfectly fine to combine parametrization and scoping:
 
@@ -168,7 +168,7 @@ pytest for a long time offered a pytest_configure and a pytest_sessionstart
 hook which are often used to setup global resources.  This suffers from
 several problems:
 
-1. in distributed testing the master process would setup test resources
+1. in distributed testing the managing process would setup test resources
    that are never needed because it only co-ordinates the test run
    activities of the worker processes.
 
index 1275dff902e621ff85bfc99dc545841a878bc4e1..ba6facd4cd980c28fd21d62f64b78eb62d1647e2 100644 (file)
@@ -1,15 +1,7 @@
-Installation and Getting Started
-===================================
-
-**Pythons**: Python 3.6, 3.7, 3.8, 3.9, PyPy3
-
-**Platforms**: Linux and Windows
-
-**PyPI package name**: `pytest <https://pypi.org/project/pytest/>`_
-
-**Documentation as PDF**: `download latest <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>`_
+.. _get-started:
 
-``pytest`` is a framework that makes building simple and scalable tests easy. Tests are expressive and readable—no boilerplate code required. Get started in minutes with a small unit test or complex functional test for your application or library.
+Get Started
+===================================
 
 .. _`getstarted`:
 .. _`installation`:
@@ -17,6 +9,8 @@ Installation and Getting Started
 Install ``pytest``
 ----------------------------------------
 
+``pytest`` requires: Python 3.7+ or PyPy3.
+
 1. Run the following command in your command line:
 
 .. code-block:: bash
@@ -28,14 +22,14 @@ Install ``pytest``
 .. code-block:: bash
 
     $ pytest --version
-    pytest 6.2.2
+    pytest 7.4.3
 
 .. _`simpletest`:
 
 Create your first test
 ----------------------------------------------------------
 
-Create a simple test function with just four lines of code:
+Create a new file called ``test_sample.py``, containing a function, and a test:
 
 .. code-block:: python
 
@@ -47,15 +41,14 @@ Create a simple test function with just four lines of code:
     def test_answer():
         assert func(3) == 5
 
-That’s it. You can now execute the test function:
+The test
 
 .. code-block:: pytest
 
     $ pytest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 1 item
 
     test_sample.py F                                                     [100%]
@@ -77,7 +70,7 @@ The ``[100%]`` refers to the overall progress of running all test cases. After i
 
 .. note::
 
-    You can use the ``assert`` statement to verify test expectations. pytest’s `Advanced assertion introspection <http://docs.python.org/reference/simple_stmts.html#the-assert-statement>`_ will intelligently report intermediate values of the assert expression so you can avoid the many names `of JUnit legacy methods <http://docs.python.org/library/unittest.html#test-cases>`_.
+    You can use the ``assert`` statement to verify test expectations. pytest’s :ref:`Advanced assertion introspection <python:assert>` will intelligently report intermediate values of the assert expression so you can avoid the many names :ref:`of JUnit legacy methods <testcase-objects>`.
 
 Run multiple tests
 ----------------------------------------------------------
@@ -144,7 +137,7 @@ Once you develop multiple tests, you may want to group them into a class. pytest
     ================================= FAILURES =================================
     ____________________________ TestClass.test_two ____________________________
 
-    self = <test_class.TestClass object at 0xdeadbeef>
+    self = <test_class.TestClass object at 0xdeadbeef0001>
 
         def test_two(self):
             x = "hello"
@@ -175,77 +168,73 @@ This is outlined below:
 
     # content of test_class_demo.py
     class TestClassDemoInstance:
+        value = 0
+
         def test_one(self):
-            assert 0
+            self.value = 1
+            assert self.value == 1
 
         def test_two(self):
-            assert 0
+            assert self.value == 1
 
 
 .. code-block:: pytest
 
     $ pytest -k TestClassDemoInstance -q
-    FF                                                                   [100%]
+    .F                                                                   [100%]
     ================================= FAILURES =================================
-    ______________________ TestClassDemoInstance.test_one ______________________
-
-    self = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef>
-
-        def test_one(self):
-    >       assert 0
-    E       assert 0
-
-    test_class_demo.py:3: AssertionError
     ______________________ TestClassDemoInstance.test_two ______________________
 
-    self = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef>
+    self = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef0002>
 
         def test_two(self):
-    >       assert 0
-    E       assert 0
+    >       assert self.value == 1
+    E       assert 0 == 1
+    E        +  where 0 = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef0002>.value
 
-    test_class_demo.py:6: AssertionError
+    test_class_demo.py:9: AssertionError
     ========================= short test summary info ==========================
-    FAILED test_class_demo.py::TestClassDemoInstance::test_one - assert 0
-    FAILED test_class_demo.py::TestClassDemoInstance::test_two - assert 0
-    2 failed in 0.12s
+    FAILED test_class_demo.py::TestClassDemoInstance::test_two - assert 0 == 1
+    1 failed, 1 passed in 0.12s
+
+Note that attributes added at class level are *class attributes*, so they will be shared between tests.
 
 Request a unique temporary directory for functional tests
 --------------------------------------------------------------
 
-``pytest`` provides `Builtin fixtures/function arguments <https://docs.pytest.org/en/stable/builtin.html>`_ to request arbitrary resources, like a unique temporary directory:
+``pytest`` provides :std:doc:`Builtin fixtures/function arguments <builtin>` to request arbitrary resources, like a unique temporary directory:
 
 .. code-block:: python
 
-    # content of test_tmpdir.py
-    def test_needsfiles(tmpdir):
-        print(tmpdir)
+    # content of test_tmp_path.py
+    def test_needsfiles(tmp_path):
+        print(tmp_path)
         assert 0
 
-List the name ``tmpdir`` in the test function signature and ``pytest`` will lookup and call a fixture factory to create the resource before performing the test function call. Before the test runs, ``pytest`` creates a unique-per-test-invocation temporary directory:
+List the name ``tmp_path`` in the test function signature and ``pytest`` will lookup and call a fixture factory to create the resource before performing the test function call. Before the test runs, ``pytest`` creates a unique-per-test-invocation temporary directory:
 
 .. code-block:: pytest
 
-    $ pytest -q test_tmpdir.py
+    $ pytest -q test_tmp_path.py
     F                                                                    [100%]
     ================================= FAILURES =================================
     _____________________________ test_needsfiles ______________________________
 
-    tmpdir = local('PYTEST_TMPDIR/test_needsfiles0')
+    tmp_path = PosixPath('PYTEST_TMPDIR/test_needsfiles0')
 
-        def test_needsfiles(tmpdir):
-            print(tmpdir)
+        def test_needsfiles(tmp_path):
+            print(tmp_path)
     >       assert 0
     E       assert 0
 
-    test_tmpdir.py:3: AssertionError
+    test_tmp_path.py:3: AssertionError
     --------------------------- Captured stdout call ---------------------------
     PYTEST_TMPDIR/test_needsfiles0
     ========================= short test summary info ==========================
-    FAILED test_tmpdir.py::test_needsfiles - assert 0
+    FAILED test_tmp_path.py::test_needsfiles - assert 0
     1 failed in 0.12s
 
-More info on tmpdir handling is available at :ref:`Temporary directories and files <tmpdir handling>`.
+More info on temporary directory handling is available at :ref:`Temporary directories and files <tmp_path handling>`.
 
 Find out what kind of builtin :ref:`pytest fixtures <fixtures>` exist with the command:
 
@@ -260,7 +249,7 @@ Continue reading
 
 Check out additional pytest resources to help you customize tests for your unique workflow:
 
-* ":ref:`cmdline`" for command line invocation examples
+* ":ref:`usage`" for command line invocation examples
 * ":ref:`existingtestsuite`" for working with pre-existing tests
 * ":ref:`mark`" for information on the ``pytest.mark`` mechanism
 * ":ref:`fixtures`" for providing a functional baseline to your tests
diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst
deleted file mode 100644 (file)
index 4b3c0af..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-.. highlight:: python
-.. _`goodpractices`:
-
-Good Integration Practices
-=================================================
-
-Install package with pip
--------------------------------------------------
-
-For development, we recommend you use venv_ for virtual environments and
-pip_ for installing your application and any dependencies,
-as well as the ``pytest`` package itself.
-This ensures your code and dependencies are isolated from your system Python installation.
-
-Next, place a ``setup.py`` file in the root of your package with the following minimum content:
-
-.. code-block:: python
-
-    from setuptools import setup, find_packages
-
-    setup(name="PACKAGENAME", packages=find_packages())
-
-Where ``PACKAGENAME`` is the name of your package. You can then install your package in "editable" mode by running from the same directory:
-
-.. code-block:: bash
-
-     pip install -e .
-
-which lets you change your source code (both tests and application) and rerun tests at will.
-This is similar to running ``python setup.py develop`` or ``conda develop`` in that it installs
-your package using a symlink to your development code.
-
-.. _`test discovery`:
-.. _`Python test discovery`:
-
-Conventions for Python test discovery
--------------------------------------------------
-
-``pytest`` implements the following standard test discovery:
-
-* If no arguments are specified then collection starts from :confval:`testpaths`
-  (if configured) or the current directory. Alternatively, command line arguments
-  can be used in any combination of directories, file names or node ids.
-* Recurse into directories, unless they match :confval:`norecursedirs`.
-* In those directories, search for ``test_*.py`` or ``*_test.py`` files, imported by their `test package name`_.
-* From those files, collect test items:
-
-  * ``test`` prefixed test functions or methods outside of class
-  * ``test`` prefixed test functions or methods inside ``Test`` prefixed test classes (without an ``__init__`` method)
-
-For examples of how to customize your test discovery :doc:`example/pythoncollection`.
-
-Within Python modules, ``pytest`` also discovers tests using the standard
-:ref:`unittest.TestCase <unittest.TestCase>` subclassing technique.
-
-
-Choosing a test layout / import rules
--------------------------------------
-
-``pytest`` supports two common test layouts:
-
-Tests outside application code
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Putting tests into an extra directory outside your actual application code
-might be useful if you have many functional tests or for other reasons want
-to keep tests separate from actual application code (often a good idea):
-
-.. code-block:: text
-
-    setup.py
-    mypkg/
-        __init__.py
-        app.py
-        view.py
-    tests/
-        test_app.py
-        test_view.py
-        ...
-
-This has the following benefits:
-
-* Your tests can run against an installed version after executing ``pip install .``.
-* Your tests can run against the local copy with an editable install after executing ``pip install --editable .``.
-* If you don't have a ``setup.py`` file and are relying on the fact that Python by default puts the current
-  directory in ``sys.path`` to import your package, you can execute ``python -m pytest`` to execute the tests against the
-  local copy directly, without using ``pip``.
-
-.. note::
-
-    See :ref:`pytest vs python -m pytest` for more information about the difference between calling ``pytest`` and
-    ``python -m pytest``.
-
-Note that this scheme has a drawback if you are using ``prepend`` :ref:`import mode <import-modes>`
-(which is the default): your test files must have **unique names**, because
-``pytest`` will import them as *top-level* modules since there are no packages
-to derive a full package name from. In other words, the test files in the example above will
-be imported as ``test_app`` and ``test_view`` top-level modules by adding ``tests/`` to
-``sys.path``.
-
-If you need to have test modules with the same name, you might add ``__init__.py`` files to your
-``tests`` folder and subfolders, changing them to packages:
-
-.. code-block:: text
-
-    setup.py
-    mypkg/
-        ...
-    tests/
-        __init__.py
-        foo/
-            __init__.py
-            test_view.py
-        bar/
-            __init__.py
-            test_view.py
-
-Now pytest will load the modules as ``tests.foo.test_view`` and ``tests.bar.test_view``, allowing
-you to have modules with the same name. But now this introduces a subtle problem: in order to load
-the test modules from the ``tests`` directory, pytest prepends the root of the repository to
-``sys.path``, which adds the side-effect that now ``mypkg`` is also importable.
-
-This is problematic if you are using a tool like `tox`_ to test your package in a virtual environment,
-because you want to test the *installed* version of your package, not the local code from the repository.
-
-.. _`src-layout`:
-
-In this situation, it is **strongly** suggested to use a ``src`` layout where application root package resides in a
-sub-directory of your root:
-
-.. code-block:: text
-
-    setup.py
-    src/
-        mypkg/
-            __init__.py
-            app.py
-            view.py
-    tests/
-        __init__.py
-        foo/
-            __init__.py
-            test_view.py
-        bar/
-            __init__.py
-            test_view.py
-
-
-This layout prevents a lot of common pitfalls and has many benefits, which are better explained in this excellent
-`blog post by Ionel Cristian Mărieș <https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure>`_.
-
-.. note::
-    The new ``--import-mode=importlib`` (see :ref:`import-modes`) doesn't have
-    any of the drawbacks above because ``sys.path`` and ``sys.modules`` are not changed when importing
-    test modules, so users that run
-    into this issue are strongly encouraged to try it and report if the new option works well for them.
-
-    The ``src`` directory layout is still strongly recommended however.
-
-
-Tests as part of application code
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Inlining test directories into your application package
-is useful if you have direct relation between tests and application modules and
-want to distribute them along with your application:
-
-.. code-block:: text
-
-    setup.py
-    mypkg/
-        __init__.py
-        app.py
-        view.py
-        test/
-            __init__.py
-            test_app.py
-            test_view.py
-            ...
-
-In this scheme, it is easy to run your tests using the ``--pyargs`` option:
-
-.. code-block:: bash
-
-    pytest --pyargs mypkg
-
-``pytest`` will discover where ``mypkg`` is installed and collect tests from there.
-
-Note that this layout also works in conjunction with the ``src`` layout mentioned in the previous section.
-
-
-.. note::
-
-    You can use Python3 namespace packages (PEP420) for your application
-    but pytest will still perform `test package name`_ discovery based on the
-    presence of ``__init__.py`` files.  If you use one of the
-    two recommended file system layouts above but leave away the ``__init__.py``
-    files from your directories it should just work on Python3.3 and above.  From
-    "inlined tests", however, you will need to use absolute imports for
-    getting at your application code.
-
-.. _`test package name`:
-
-.. note::
-
-    In ``prepend`` and ``append`` import-modes, if pytest finds a ``"a/b/test_module.py"``
-    test file while recursing into the filesystem it determines the import name
-    as follows:
-
-    * determine ``basedir``: this is the first "upward" (towards the root)
-      directory not containing an ``__init__.py``.  If e.g. both ``a``
-      and ``b`` contain an ``__init__.py`` file then the parent directory
-      of ``a`` will become the ``basedir``.
-
-    * perform ``sys.path.insert(0, basedir)`` to make the test module
-      importable under the fully qualified import name.
-
-    * ``import a.b.test_module`` where the path is determined
-      by converting path separators ``/`` into "." characters.  This means
-      you must follow the convention of having directory and file
-      names map directly to the import names.
-
-    The reason for this somewhat evolved importing technique is
-    that in larger projects multiple test modules might import
-    from each other and thus deriving a canonical import name helps
-    to avoid surprises such as a test module getting imported twice.
-
-    With ``--import-mode=importlib`` things are less convoluted because
-    pytest doesn't need to change ``sys.path`` or ``sys.modules``, making things
-    much less surprising.
-
-
-.. _`virtualenv`: https://pypi.org/project/virtualenv/
-.. _`buildout`: http://www.buildout.org/
-.. _pip: https://pypi.org/project/pip/
-
-.. _`use tox`:
-
-tox
-------
-
-Once you are done with your work and want to make sure that your actual
-package passes all tests you may want to look into `tox`_, the
-virtualenv test automation tool and its `pytest support
-<https://tox.readthedocs.io/en/latest/example/pytest.html>`_.
-tox helps you to setup virtualenv environments with pre-defined
-dependencies and then executing a pre-configured test command with
-options.  It will run tests against the installed package and not
-against your source code checkout, helping to detect packaging
-glitches.
-
-.. _`venv`: https://docs.python.org/3/library/venv.html
index 4f8722c1c16af8e212327a671dbba39e6cf88507..29ebbd5d1995162b0a57e7d6f5c52ef4b9d302dd 100644 (file)
@@ -76,38 +76,38 @@ order doesn't even matter. You probably want to think of your marks as a set her
 
 
 If you are unsure or have any questions, please consider opening
-`an issue <https://github.com/pytest-dev/pytest/issues>`_.
+:issue:`an issue <new>`.
 
 Related issues
 ~~~~~~~~~~~~~~
 
 Here is a non-exhaustive list of issues fixed by the new implementation:
 
-* Marks don't pick up nested classes (`#199 <https://github.com/pytest-dev/pytest/issues/199>`_).
+* Marks don't pick up nested classes (:issue:`199`).
 
-* Markers stain on all related classes (`#568 <https://github.com/pytest-dev/pytest/issues/568>`_).
+* Markers stain on all related classes (:issue:`568`).
 
-* Combining marks - args and kwargs calculation (`#2897 <https://github.com/pytest-dev/pytest/issues/2897>`_).
+* Combining marks - args and kwargs calculation (:issue:`2897`).
 
-* ``request.node.get_marker('name')`` returns ``None`` for markers applied in classes (`#902 <https://github.com/pytest-dev/pytest/issues/902>`_).
+* ``request.node.get_marker('name')`` returns ``None`` for markers applied in classes (:issue:`902`).
 
-* Marks applied in parametrize are stored as markdecorator (`#2400 <https://github.com/pytest-dev/pytest/issues/2400>`_).
+* Marks applied in parametrize are stored as markdecorator (:issue:`2400`).
 
-* Fix marker interaction in a backward incompatible way (`#1670 <https://github.com/pytest-dev/pytest/issues/1670>`_).
+* Fix marker interaction in a backward incompatible way (:issue:`1670`).
 
-* Refactor marks to get rid of the current "marks transfer" mechanism (`#2363 <https://github.com/pytest-dev/pytest/issues/2363>`_).
+* Refactor marks to get rid of the current "marks transfer" mechanism (:issue:`2363`).
 
-* Introduce FunctionDefinition node, use it in generate_tests (`#2522 <https://github.com/pytest-dev/pytest/issues/2522>`_).
+* Introduce FunctionDefinition node, use it in generate_tests (:issue:`2522`).
 
-* Remove named marker attributes and collect markers in items (`#891 <https://github.com/pytest-dev/pytest/issues/891>`_).
+* Remove named marker attributes and collect markers in items (:issue:`891`).
 
-* skipif mark from parametrize hides module level skipif mark (`#1540 <https://github.com/pytest-dev/pytest/issues/1540>`_).
+* skipif mark from parametrize hides module level skipif mark (:issue:`1540`).
 
-* skipif + parametrize not skipping tests (`#1296 <https://github.com/pytest-dev/pytest/issues/1296>`_).
+* skipif + parametrize not skipping tests (:issue:`1296`).
 
-* Marker transfer incompatible with inheritance (`#535 <https://github.com/pytest-dev/pytest/issues/535>`_).
+* Marker transfer incompatible with inheritance (:issue:`535`).
 
-More details can be found in the `original PR <https://github.com/pytest-dev/pytest/pull/3317>`_.
+More details can be found in the :pull:`original PR <3317>`.
 
 .. note::
 
@@ -125,6 +125,7 @@ as a third party plugin named ``pytest-cache``.  The core plugin
 is compatible regarding command line options and API usage except that you
 can only store/receive data between test runs that is json-serializable.
 
+.. _historical funcargs and pytest.funcargs:
 
 funcargs and ``pytest_funcarg__``
 ---------------------------------
diff --git a/doc/en/history.rst b/doc/en/history.rst
new file mode 100644 (file)
index 0000000..bb5aa49
--- /dev/null
@@ -0,0 +1,145 @@
+History
+=======
+
+pytest has a long and interesting history. The `first commit
+<https://github.com/pytest-dev/pytest/commit/5992a8ef21424d7571305a8d7e2a3431ee7e1e23>`__
+in this repository is from January 2007, and even that commit alone already
+tells a lot: The repository originally was from the :pypi:`py`
+library (later split off to pytest), and it
+originally was a SVN revision, migrated to Mercurial, and finally migrated to
+git.
+
+However, the commit says “create the new development trunk” and is
+already quite big: *435 files changed, 58640 insertions(+)*. This is because
+pytest originally was born as part of `PyPy <https://www.pypy.org/>`__, to make
+it easier to write tests for it. Here's how it evolved from there to its own
+project:
+
+
+-  Late 2002 / early 2003, `PyPy was
+   born <https://morepypy.blogspot.com/2018/09/the-first-15-years-of-pypy.html>`__.
+-  Like that blog post mentioned, from very early on, there was a big
+   focus on testing. There were various ``testsupport`` files on top of
+   unittest.py, and as early as June 2003, Holger Krekel (:user:`hpk42`)
+   `refactored <https://mail.python.org/pipermail/pypy-dev/2003-June/000787.html>`__
+   its test framework to clean things up (``pypy.tool.test``, but still
+   on top of ``unittest.py``, with nothing pytest-like yet).
+-  In December 2003, there was `another
+   iteration <https://foss.heptapod.net/pypy/pypy/-/commit/02752373e1b29d89c6bb0a97e5f940caa22bdd63>`__
+   at improving their testing situation, by Stefan Schwarzer, called
+   ``pypy.tool.newtest``.
+-  However, it didn’t seem to be around for long, as around June/July
+   2004, efforts started on a thing called ``utest``, offering plain
+   assertions. This seems like the start of something pytest-like, but
+   unfortunately, it's unclear where the test runner's code was at the time.
+   The closest thing still around is `this
+   file <https://foss.heptapod.net/pypy/pypy/-/commit/0735f9ed287ec20950a7dd0a16fc10810d4f6847>`__,
+   but that doesn’t seem like a complete test runner at all. What can be seen
+   is that there were `various
+   efforts <https://foss.heptapod.net/pypy/pypy/-/commits/branch/default?utf8=%E2%9C%93&search=utest>`__
+   by Laura Creighton and Samuele Pedroni (:user:`pedronis`) at automatically
+   converting existing tests to the new ``utest`` framework.
+-  Around the same time, for Europython 2004, @hpk42 `started a
+   project <http://web.archive.org/web/20041020215353/http://codespeak.net/svn/user/hpk/talks/std-talk.txt>`__
+   originally called “std”, intended to be a “complementary standard
+   library” - already laying out the principles behind what later became
+   pytest:
+
+       -  current “batteries included” are very useful, but
+
+          -  some of them are written in a pretty much java-like style,
+             especially the unittest-framework
+          -  […]
+          -  the best API is one that doesn’t exist
+
+       […]
+
+       -  a testing package should require as few boilerplate code as
+          possible and offer much flexibility
+       -  it should provide premium quality tracebacks and debugging aid
+
+       […]
+
+       -  first of all … forget about limited “assertXYZ APIs” and use the
+          real thing, e.g.::
+
+              assert x == y
+
+       -  this works with plain python but you get unhelpful “assertion
+          failed” errors with no information
+
+       -  std.utest (magic!) actually reinterprets the assertion expression
+          and offers detailed information about underlying values
+
+-  In September 2004, the ``py-dev`` mailinglist gets born, which `is
+   now <https://mail.python.org/pipermail/pytest-dev/>`__ ``pytest-dev``,
+   but thankfully with all the original archives still intact.
+
+-  Around September/October 2004, the ``std`` project `was renamed
+   <https://mail.python.org/pipermail/pypy-dev/2004-September/001565.html>`__ to
+   ``py`` and ``std.utest`` became ``py.test``. This is also the first time the
+   `entire source
+   code <https://foss.heptapod.net/pypy/pypy/-/commit/42cf50c412026028e20acd23d518bd92e623ac11>`__,
+   seems to be available, with much of the API still being around today:
+
+   -  ``py.path.local``, which is being phased out of pytest (in favour of
+      pathlib) some 16-17 years later
+   -  The idea of the collection tree, including ``Collector``,
+      ``FSCollector``, ``Directory``, ``PyCollector``, ``Module``,
+      ``Class``
+   -  Arguments like ``-x`` / ``--exitfirst``, ``-l`` /
+      ``--showlocals``, ``--fulltrace``, ``--pdb``, ``-S`` /
+      ``--nocapture`` (``-s`` / ``--capture=off`` today),
+      ``--collectonly`` (``--collect-only`` today)
+
+-  In the same month, the ``py`` library `gets split off
+   <https://foss.heptapod.net/pypy/pypy/-/commit/6bdafe9203ad92eb259270b267189141c53bce33>`__
+   from ``PyPy``
+
+-  It seemed to get rather quiet for a while, and little seemed to happen
+   between October 2004 (removing ``py`` from PyPy) and January
+   2007 (first commit in the now-pytest repository). However, there were
+   various discussions about features/ideas on the mailinglist, and
+   :pypi:`a couple of releases <py/0.8.0-alpha2/#history>` every
+   couple of months:
+
+   -  March 2006: py 0.8.0-alpha2
+   -  May 2007: py 0.9.0
+   -  March 2008: py 0.9.1 (first release to be found `in the pytest
+      changelog <https://github.com/pytest-dev/pytest/blob/main/doc/en/changelog.rst#091>`__!)
+   -  August 2008: py 0.9.2
+
+-  In August 2009, py 1.0.0 was released, `introducing a lot of
+   fundamental
+   features <https://holgerkrekel.net/2009/08/04/pylib-1-0-0-released-the-testing-with-python-innovations-continue/>`__:
+
+   -  funcargs/fixtures
+   -  A `plugin
+      architecture <http://web.archive.org/web/20090629032718/https://codespeak.net/py/dist/test/extend.html>`__
+      which still looks very much the same today!
+   -  Various `default
+      plugins <http://web.archive.org/web/20091005181132/https://codespeak.net/py/dist/test/plugin/index.html>`__,
+      including
+      `monkeypatch <http://web.archive.org/web/20091012022829/http://codespeak.net/py/dist/test/plugin/how-to/monkeypatch.html>`__
+
+-  Even back there, the
+   `FAQ <http://web.archive.org/web/20091005222413/http://codespeak.net/py/dist/faq.html>`__
+   said:
+
+       Clearly, [a second standard library] was ambitious and the naming has
+       maybe haunted the project rather than helping it. There may be a
+       project name change and possibly a split up into different projects
+       sometime.
+
+   and that finally happened in November 2010, when pytest 2.0.0 `was
+   released <https://mail.python.org/pipermail/pytest-dev/2010-November/001687.html>`__
+   as a package separate from ``py`` (but still called ``py.test``).
+
+-  In August 2016, pytest 3.0.0 :std:ref:`was released <release-3.0.0>`,
+   which adds ``pytest`` (rather than ``py.test``) as the recommended
+   command-line entry point
+
+Due to this history, it's difficult to answer the question when pytest was started.
+It depends what point should really be seen as the start of it all. One
+possible interpretation is to  pick Europython 2004, i.e. around June/July
+2004.
diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst
new file mode 100644 (file)
index 0000000..d99a1ce
--- /dev/null
@@ -0,0 +1,335 @@
+.. _`assert`:
+
+How to write and report assertions in tests
+==================================================
+
+.. _`assert with the assert statement`:
+
+Asserting with the ``assert`` statement
+---------------------------------------------------------
+
+``pytest`` allows you to use the standard Python ``assert`` for verifying
+expectations and values in Python tests.  For example, you can write the
+following:
+
+.. code-block:: python
+
+    # content of test_assert1.py
+    def f():
+        return 3
+
+
+    def test_function():
+        assert f() == 4
+
+to assert that your function returns a certain value. If this assertion fails
+you will see the return value of the function call:
+
+.. code-block:: pytest
+
+    $ pytest test_assert1.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_assert1.py F                                                    [100%]
+
+    ================================= FAILURES =================================
+    ______________________________ test_function _______________________________
+
+        def test_function():
+    >       assert f() == 4
+    E       assert 3 == 4
+    E        +  where 3 = f()
+
+    test_assert1.py:6: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_assert1.py::test_function - assert 3 == 4
+    ============================ 1 failed in 0.12s =============================
+
+``pytest`` has support for showing the values of the most common subexpressions
+including calls, attributes, comparisons, and binary and unary
+operators. (See :ref:`tbreportdemo`).  This allows you to use the
+idiomatic python constructs without boilerplate code while not losing
+introspection information.
+
+If a message is specified with the assertion like this:
+
+.. code-block:: python
+
+    assert a % 2 == 0, "value was odd, should be even"
+
+it is printed alongside the assertion introspection in the traceback.
+
+See :ref:`assert-details` for more information on assertion introspection.
+
+.. _`assertraises`:
+
+Assertions about expected exceptions
+------------------------------------------
+
+In order to write assertions about raised exceptions, you can use
+:func:`pytest.raises` as a context manager like this:
+
+.. code-block:: python
+
+    import pytest
+
+
+    def test_zero_division():
+        with pytest.raises(ZeroDivisionError):
+            1 / 0
+
+and if you need to have access to the actual exception info you may use:
+
+.. code-block:: python
+
+    def test_recursion_depth():
+        with pytest.raises(RuntimeError) as excinfo:
+
+            def f():
+                f()
+
+            f()
+        assert "maximum recursion" in str(excinfo.value)
+
+``excinfo`` is an :class:`~pytest.ExceptionInfo` instance, which is a wrapper around
+the actual exception raised.  The main attributes of interest are
+``.type``, ``.value`` and ``.traceback``.
+
+You can pass a ``match`` keyword parameter to the context-manager to test
+that a regular expression matches on the string representation of an exception
+(similar to the ``TestCase.assertRaisesRegex`` method from ``unittest``):
+
+.. code-block:: python
+
+    import pytest
+
+
+    def myfunc():
+        raise ValueError("Exception 123 raised")
+
+
+    def test_match():
+        with pytest.raises(ValueError, match=r".* 123 .*"):
+            myfunc()
+
+The regexp parameter of the ``match`` method is matched with the ``re.search``
+function, so in the above example ``match='123'`` would have worked as
+well.
+
+There's an alternate form of the :func:`pytest.raises` function where you pass
+a function that will be executed with the given ``*args`` and ``**kwargs`` and
+assert that the given exception is raised:
+
+.. code-block:: python
+
+    pytest.raises(ExpectedException, func, *args, **kwargs)
+
+The reporter will provide you with helpful output in case of failures such as *no
+exception* or *wrong exception*.
+
+Note that it is also possible to specify a "raises" argument to
+``pytest.mark.xfail``, which checks that the test is failing in a more
+specific way than just having any exception raised:
+
+.. code-block:: python
+
+    @pytest.mark.xfail(raises=IndexError)
+    def test_f():
+        f()
+
+Using :func:`pytest.raises` is likely to be better for cases where you are
+testing exceptions your own code is deliberately raising, whereas using
+``@pytest.mark.xfail`` with a check function is probably better for something
+like documenting unfixed bugs (where the test describes what "should" happen)
+or bugs in dependencies.
+
+
+.. _`assertwarns`:
+
+Assertions about expected warnings
+-----------------------------------------
+
+
+
+You can check that code raises a particular warning using
+:ref:`pytest.warns <warns>`.
+
+
+.. _newreport:
+
+Making use of context-sensitive comparisons
+-------------------------------------------------
+
+
+
+``pytest`` has rich support for providing context-sensitive information
+when it encounters comparisons.  For example:
+
+.. code-block:: python
+
+    # content of test_assert2.py
+    def test_set_comparison():
+        set1 = set("1308")
+        set2 = set("8035")
+        assert set1 == set2
+
+if you run this module:
+
+.. code-block:: pytest
+
+    $ pytest test_assert2.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_assert2.py F                                                    [100%]
+
+    ================================= FAILURES =================================
+    ___________________________ test_set_comparison ____________________________
+
+        def test_set_comparison():
+            set1 = set("1308")
+            set2 = set("8035")
+    >       assert set1 == set2
+    E       AssertionError: assert {'0', '1', '3', '8'} == {'0', '3', '5', '8'}
+    E         Extra items in the left set:
+    E         '1'
+    E         Extra items in the right set:
+    E         '5'
+    E         Use -v to get more diff
+
+    test_assert2.py:4: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_assert2.py::test_set_comparison - AssertionError: assert {'0'...
+    ============================ 1 failed in 0.12s =============================
+
+Special comparisons are done for a number of cases:
+
+* comparing long strings: a context diff is shown
+* comparing long sequences: first failing indices
+* comparing dicts: different entries
+
+See the :ref:`reporting demo <tbreportdemo>` for many more examples.
+
+Defining your own explanation for failed assertions
+---------------------------------------------------
+
+It is possible to add your own detailed explanations by implementing
+the ``pytest_assertrepr_compare`` hook.
+
+.. autofunction:: _pytest.hookspec.pytest_assertrepr_compare
+   :noindex:
+
+As an example consider adding the following hook in a :ref:`conftest.py <conftest.py>`
+file which provides an alternative explanation for ``Foo`` objects:
+
+.. code-block:: python
+
+   # content of conftest.py
+   from test_foocompare import Foo
+
+
+   def pytest_assertrepr_compare(op, left, right):
+       if isinstance(left, Foo) and isinstance(right, Foo) and op == "==":
+           return [
+               "Comparing Foo instances:",
+               f"   vals: {left.val} != {right.val}",
+           ]
+
+now, given this test module:
+
+.. code-block:: python
+
+   # content of test_foocompare.py
+   class Foo:
+       def __init__(self, val):
+           self.val = val
+
+       def __eq__(self, other):
+           return self.val == other.val
+
+
+   def test_compare():
+       f1 = Foo(1)
+       f2 = Foo(2)
+       assert f1 == f2
+
+you can run the test module and get the custom output defined in
+the conftest file:
+
+.. code-block:: pytest
+
+   $ pytest -q test_foocompare.py
+   F                                                                    [100%]
+   ================================= FAILURES =================================
+   _______________________________ test_compare _______________________________
+
+       def test_compare():
+           f1 = Foo(1)
+           f2 = Foo(2)
+   >       assert f1 == f2
+   E       assert Comparing Foo instances:
+   E            vals: 1 != 2
+
+   test_foocompare.py:12: AssertionError
+   ========================= short test summary info ==========================
+   FAILED test_foocompare.py::test_compare - assert Comparing Foo instances:
+   1 failed in 0.12s
+
+.. _assert-details:
+.. _`assert introspection`:
+
+Assertion introspection details
+-------------------------------
+
+
+Reporting details about a failing assertion is achieved by rewriting assert
+statements before they are run.  Rewritten assert statements put introspection
+information into the assertion failure message.  ``pytest`` only rewrites test
+modules directly discovered by its test collection process, so **asserts in
+supporting modules which are not themselves test modules will not be rewritten**.
+
+You can manually enable assertion rewriting for an imported module by calling
+:ref:`register_assert_rewrite <assertion-rewriting>`
+before you import it (a good place to do that is in your root ``conftest.py``).
+
+For further information, Benjamin Peterson wrote up `Behind the scenes of pytest's new assertion rewriting <http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests-new-assertion.html>`_.
+
+Assertion rewriting caches files on disk
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``pytest`` will write back the rewritten modules to disk for caching. You can disable
+this behavior (for example to avoid leaving stale ``.pyc`` files around in projects that
+move files around a lot) by adding this to the top of your ``conftest.py`` file:
+
+.. code-block:: python
+
+   import sys
+
+   sys.dont_write_bytecode = True
+
+Note that you still get the benefits of assertion introspection, the only change is that
+the ``.pyc`` files won't be cached on disk.
+
+Additionally, rewriting will silently skip caching if it cannot write new ``.pyc`` files,
+i.e. in a read-only filesystem or a zipfile.
+
+
+Disabling assert rewriting
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``pytest`` rewrites test modules on import by using an import
+hook to write new ``pyc`` files. Most of the time this works transparently.
+However, if you are working with the import machinery yourself, the import hook may
+interfere.
+
+If this is the case you have two options:
+
+* Disable rewriting for a specific module by adding the string
+  ``PYTEST_DONT_REWRITE`` to its docstring.
+
+* Disable rewriting for all modules by using ``--assert=plain``.
diff --git a/doc/en/how-to/bash-completion.rst b/doc/en/how-to/bash-completion.rst
new file mode 100644 (file)
index 0000000..117ff7e
--- /dev/null
@@ -0,0 +1,33 @@
+
+.. _bash_completion:
+
+How to set up bash completion
+=============================
+
+When using bash as your shell, ``pytest`` can use argcomplete
+(https://kislyuk.github.io/argcomplete/) for auto-completion.
+For this ``argcomplete`` needs to be installed **and** enabled.
+
+Install argcomplete using:
+
+.. code-block:: bash
+
+    sudo pip install 'argcomplete>=0.5.7'
+
+For global activation of all argcomplete enabled python applications run:
+
+.. code-block:: bash
+
+    sudo activate-global-python-argcomplete
+
+For permanent (but not global) ``pytest`` activation, use:
+
+.. code-block:: bash
+
+    register-python-argcomplete pytest >> ~/.bashrc
+
+For one-time activation of argcomplete for ``pytest`` only, use:
+
+.. code-block:: bash
+
+    eval "$(register-python-argcomplete pytest)"
diff --git a/doc/en/how-to/cache.rst b/doc/en/how-to/cache.rst
new file mode 100644 (file)
index 0000000..03ab0c7
--- /dev/null
@@ -0,0 +1,335 @@
+.. _`cache_provider`:
+.. _cache:
+
+
+How to re-run failed tests and maintain state between test runs
+===============================================================
+
+
+
+Usage
+---------
+
+The plugin provides two command line options to rerun failures from the
+last ``pytest`` invocation:
+
+* ``--lf``, ``--last-failed`` - to only re-run the failures.
+* ``--ff``, ``--failed-first`` - to run the failures first and then the rest of
+  the tests.
+
+For cleanup (usually not needed), a ``--cache-clear`` option allows to remove
+all cross-session cache contents ahead of a test run.
+
+Other plugins may access the `config.cache`_ object to set/get
+**json encodable** values between ``pytest`` invocations.
+
+.. note::
+
+    This plugin is enabled by default, but can be disabled if needed: see
+    :ref:`cmdunregister` (the internal name for this plugin is
+    ``cacheprovider``).
+
+
+Rerunning only failures or failures first
+-----------------------------------------------
+
+First, let's create 50 test invocation of which only 2 fail:
+
+.. code-block:: python
+
+    # content of test_50.py
+    import pytest
+
+
+    @pytest.mark.parametrize("i", range(50))
+    def test_num(i):
+        if i in (17, 25):
+            pytest.fail("bad luck")
+
+If you run this for the first time you will see two failures:
+
+.. code-block:: pytest
+
+    $ pytest -q
+    .................F.......F........................                   [100%]
+    ================================= FAILURES =================================
+    _______________________________ test_num[17] _______________________________
+
+    i = 17
+
+        @pytest.mark.parametrize("i", range(50))
+        def test_num(i):
+            if i in (17, 25):
+    >           pytest.fail("bad luck")
+    E           Failed: bad luck
+
+    test_50.py:7: Failed
+    _______________________________ test_num[25] _______________________________
+
+    i = 25
+
+        @pytest.mark.parametrize("i", range(50))
+        def test_num(i):
+            if i in (17, 25):
+    >           pytest.fail("bad luck")
+    E           Failed: bad luck
+
+    test_50.py:7: Failed
+    ========================= short test summary info ==========================
+    FAILED test_50.py::test_num[17] - Failed: bad luck
+    FAILED test_50.py::test_num[25] - Failed: bad luck
+    2 failed, 48 passed in 0.12s
+
+If you then run it with ``--lf``:
+
+.. code-block:: pytest
+
+    $ pytest --lf
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 2 items
+    run-last-failure: rerun previous 2 failures
+
+    test_50.py FF                                                        [100%]
+
+    ================================= FAILURES =================================
+    _______________________________ test_num[17] _______________________________
+
+    i = 17
+
+        @pytest.mark.parametrize("i", range(50))
+        def test_num(i):
+            if i in (17, 25):
+    >           pytest.fail("bad luck")
+    E           Failed: bad luck
+
+    test_50.py:7: Failed
+    _______________________________ test_num[25] _______________________________
+
+    i = 25
+
+        @pytest.mark.parametrize("i", range(50))
+        def test_num(i):
+            if i in (17, 25):
+    >           pytest.fail("bad luck")
+    E           Failed: bad luck
+
+    test_50.py:7: Failed
+    ========================= short test summary info ==========================
+    FAILED test_50.py::test_num[17] - Failed: bad luck
+    FAILED test_50.py::test_num[25] - Failed: bad luck
+    ============================ 2 failed in 0.12s =============================
+
+You have run only the two failing tests from the last run, while the 48 passing
+tests have not been run ("deselected").
+
+Now, if you run with the ``--ff`` option, all tests will be run but the first
+previous failures will be executed first (as can be seen from the series
+of ``FF`` and dots):
+
+.. code-block:: pytest
+
+    $ pytest --ff
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 50 items
+    run-last-failure: rerun previous 2 failures first
+
+    test_50.py FF................................................        [100%]
+
+    ================================= FAILURES =================================
+    _______________________________ test_num[17] _______________________________
+
+    i = 17
+
+        @pytest.mark.parametrize("i", range(50))
+        def test_num(i):
+            if i in (17, 25):
+    >           pytest.fail("bad luck")
+    E           Failed: bad luck
+
+    test_50.py:7: Failed
+    _______________________________ test_num[25] _______________________________
+
+    i = 25
+
+        @pytest.mark.parametrize("i", range(50))
+        def test_num(i):
+            if i in (17, 25):
+    >           pytest.fail("bad luck")
+    E           Failed: bad luck
+
+    test_50.py:7: Failed
+    ========================= short test summary info ==========================
+    FAILED test_50.py::test_num[17] - Failed: bad luck
+    FAILED test_50.py::test_num[25] - Failed: bad luck
+    ======================= 2 failed, 48 passed in 0.12s =======================
+
+.. _`config.cache`:
+
+New ``--nf``, ``--new-first`` options: run new tests first followed by the rest
+of the tests, in both cases tests are also sorted by the file modified time,
+with more recent files coming first.
+
+Behavior when no tests failed in the last run
+---------------------------------------------
+
+The ``--lfnf/--last-failed-no-failures`` option governs the behavior of ``--last-failed``.
+Determines whether to execute tests when there are no previously (known)
+failures or when no cached ``lastfailed`` data was found.
+
+There are two options:
+
+* ``all``:  when there are no known test failures, runs all tests (the full test suite). This is the default.
+* ``none``: when there are no known test failures, just emits a message stating this and exit successfully.
+
+Example:
+
+.. code-block:: bash
+
+    pytest --last-failed --last-failed-no-failures all    # runs the full test suite (default behavior)
+    pytest --last-failed --last-failed-no-failures none   # runs no tests and exits successfully
+
+The new config.cache object
+--------------------------------
+
+.. regendoc:wipe
+
+Plugins or conftest.py support code can get a cached value using the
+pytest ``config`` object.  Here is a basic example plugin which
+implements a :ref:`fixture <fixture>` which re-uses previously created state
+across pytest invocations:
+
+.. code-block:: python
+
+    # content of test_caching.py
+    import pytest
+
+
+    def expensive_computation():
+        print("running expensive computation...")
+
+
+    @pytest.fixture
+    def mydata(request):
+        val = request.config.cache.get("example/value", None)
+        if val is None:
+            expensive_computation()
+            val = 42
+            request.config.cache.set("example/value", val)
+        return val
+
+
+    def test_function(mydata):
+        assert mydata == 23
+
+If you run this command for the first time, you can see the print statement:
+
+.. code-block:: pytest
+
+    $ pytest -q
+    F                                                                    [100%]
+    ================================= FAILURES =================================
+    ______________________________ test_function _______________________________
+
+    mydata = 42
+
+        def test_function(mydata):
+    >       assert mydata == 23
+    E       assert 42 == 23
+
+    test_caching.py:19: AssertionError
+    -------------------------- Captured stdout setup ---------------------------
+    running expensive computation...
+    ========================= short test summary info ==========================
+    FAILED test_caching.py::test_function - assert 42 == 23
+    1 failed in 0.12s
+
+If you run it a second time, the value will be retrieved from
+the cache and nothing will be printed:
+
+.. code-block:: pytest
+
+    $ pytest -q
+    F                                                                    [100%]
+    ================================= FAILURES =================================
+    ______________________________ test_function _______________________________
+
+    mydata = 42
+
+        def test_function(mydata):
+    >       assert mydata == 23
+    E       assert 42 == 23
+
+    test_caching.py:19: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_caching.py::test_function - assert 42 == 23
+    1 failed in 0.12s
+
+See the :fixture:`config.cache fixture <cache>` for more details.
+
+
+Inspecting Cache content
+------------------------
+
+You can always peek at the content of the cache using the
+``--cache-show`` command line option:
+
+.. code-block:: pytest
+
+    $ pytest --cache-show
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    cachedir: /home/sweet/project/.pytest_cache
+    --------------------------- cache values for '*' ---------------------------
+    cache/lastfailed contains:
+      {'test_caching.py::test_function': True}
+    cache/nodeids contains:
+      ['test_caching.py::test_function']
+    cache/stepwise contains:
+      []
+    example/value contains:
+      42
+
+    ========================== no tests ran in 0.12s ===========================
+
+``--cache-show`` takes an optional argument to specify a glob pattern for
+filtering:
+
+.. code-block:: pytest
+
+    $ pytest --cache-show example/*
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    cachedir: /home/sweet/project/.pytest_cache
+    ----------------------- cache values for 'example/*' -----------------------
+    example/value contains:
+      42
+
+    ========================== no tests ran in 0.12s ===========================
+
+Clearing Cache content
+----------------------
+
+You can instruct pytest to clear all cache files and values
+by adding the ``--cache-clear`` option like this:
+
+.. code-block:: bash
+
+    pytest --cache-clear
+
+This is recommended for invocations from Continuous Integration
+servers where isolation and correctness is more important
+than speed.
+
+
+.. _cache stepwise:
+
+Stepwise
+--------
+
+As an alternative to ``--lf -x``, especially for cases where you expect a large part of the test suite will fail, ``--sw``, ``--stepwise`` allows you to fix them one at a time. The test suite will run until the first failure and then stop. At the next invocation, tests will continue from the last failing test and then run until the next failing test. You may use the ``--stepwise-skip`` option to ignore one failing test and stop the test execution on the second failing test instead. This is useful if you get stuck on a failing test and just want to ignore it until later.  Providing ``--stepwise-skip`` will also enable ``--stepwise`` implicitly.
diff --git a/doc/en/how-to/capture-stdout-stderr.rst b/doc/en/how-to/capture-stdout-stderr.rst
new file mode 100644 (file)
index 0000000..9ccea71
--- /dev/null
@@ -0,0 +1,170 @@
+
+.. _`captures`:
+
+How to capture stdout/stderr output
+=========================================================
+
+Default stdout/stderr/stdin capturing behaviour
+---------------------------------------------------------
+
+During test execution any output sent to ``stdout`` and ``stderr`` is
+captured.  If a test or a setup method fails its according captured
+output will usually be shown along with the failure traceback. (this
+behavior can be configured by the ``--show-capture`` command-line option).
+
+In addition, ``stdin`` is set to a "null" object which will
+fail on attempts to read from it because it is rarely desired
+to wait for interactive input when running automated tests.
+
+By default capturing is done by intercepting writes to low level
+file descriptors.  This allows to capture output from simple
+print statements as well as output from a subprocess started by
+a test.
+
+.. _capture-method:
+
+Setting capturing methods or disabling capturing
+-------------------------------------------------
+
+There are three ways in which ``pytest`` can perform capturing:
+
+* ``fd`` (file descriptor) level capturing (default): All writes going to the
+  operating system file descriptors 1 and 2 will be captured.
+
+* ``sys`` level capturing: Only writes to Python files ``sys.stdout``
+  and ``sys.stderr`` will be captured.  No capturing of writes to
+  filedescriptors is performed.
+
+* ``tee-sys`` capturing: Python writes to ``sys.stdout`` and ``sys.stderr``
+  will be captured, however the writes will also be passed-through to
+  the actual ``sys.stdout`` and ``sys.stderr``. This allows output to be
+  'live printed' and captured for plugin use, such as junitxml (new in pytest 5.4).
+
+.. _`disable capturing`:
+
+You can influence output capturing mechanisms from the command line:
+
+.. code-block:: bash
+
+    pytest -s                  # disable all capturing
+    pytest --capture=sys       # replace sys.stdout/stderr with in-mem files
+    pytest --capture=fd        # also point filedescriptors 1 and 2 to temp file
+    pytest --capture=tee-sys   # combines 'sys' and '-s', capturing sys.stdout/stderr
+                               # and passing it along to the actual sys.stdout/stderr
+
+.. _printdebugging:
+
+Using print statements for debugging
+---------------------------------------------------
+
+One primary benefit of the default capturing of stdout/stderr output
+is that you can use print statements for debugging:
+
+.. code-block:: python
+
+    # content of test_module.py
+
+
+    def setup_function(function):
+        print("setting up", function)
+
+
+    def test_func1():
+        assert True
+
+
+    def test_func2():
+        assert False
+
+and running this module will show you precisely the output
+of the failing function and hide the other one:
+
+.. code-block:: pytest
+
+    $ pytest
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 2 items
+
+    test_module.py .F                                                    [100%]
+
+    ================================= FAILURES =================================
+    ________________________________ test_func2 ________________________________
+
+        def test_func2():
+    >       assert False
+    E       assert False
+
+    test_module.py:12: AssertionError
+    -------------------------- Captured stdout setup ---------------------------
+    setting up <function test_func2 at 0xdeadbeef0001>
+    ========================= short test summary info ==========================
+    FAILED test_module.py::test_func2 - assert False
+    ======================= 1 failed, 1 passed in 0.12s ========================
+
+Accessing captured output from a test function
+---------------------------------------------------
+
+The ``capsys``, ``capsysbinary``, ``capfd``, and ``capfdbinary`` fixtures
+allow access to stdout/stderr output created during test execution.  Here is
+an example test function that performs some output related checks:
+
+.. code-block:: python
+
+    def test_myoutput(capsys):  # or use "capfd" for fd-level
+        print("hello")
+        sys.stderr.write("world\n")
+        captured = capsys.readouterr()
+        assert captured.out == "hello\n"
+        assert captured.err == "world\n"
+        print("next")
+        captured = capsys.readouterr()
+        assert captured.out == "next\n"
+
+The ``readouterr()`` call snapshots the output so far -
+and capturing will be continued.  After the test
+function finishes the original streams will
+be restored.  Using ``capsys`` this way frees your
+test from having to care about setting/resetting
+output streams and also interacts well with pytest's
+own per-test capturing.
+
+If you want to capture on filedescriptor level you can use
+the ``capfd`` fixture which offers the exact
+same interface but allows to also capture output from
+libraries or subprocesses that directly write to operating
+system level output streams (FD1 and FD2).
+
+
+
+The return value from ``readouterr`` changed to a ``namedtuple`` with two attributes, ``out`` and ``err``.
+
+
+
+If the code under test writes non-textual data, you can capture this using
+the ``capsysbinary`` fixture which instead returns ``bytes`` from
+the ``readouterr`` method.
+
+
+
+
+If the code under test writes non-textual data, you can capture this using
+the ``capfdbinary`` fixture which instead returns ``bytes`` from
+the ``readouterr`` method.  The ``capfdbinary`` fixture operates on the
+filedescriptor level.
+
+
+
+
+To temporarily disable capture within a test, both ``capsys``
+and ``capfd`` have a ``disabled()`` method that can be used
+as a context manager, disabling capture inside the ``with`` block:
+
+.. code-block:: python
+
+    def test_disabling_capturing(capsys):
+        print("this output is captured")
+        with capsys.disabled():
+            print("output not captured, going directly to sys.stdout")
+        print("this output is also captured")
diff --git a/doc/en/how-to/capture-warnings.rst b/doc/en/how-to/capture-warnings.rst
new file mode 100644 (file)
index 0000000..0390230
--- /dev/null
@@ -0,0 +1,505 @@
+.. _`warnings`:
+
+How to capture warnings
+=======================
+
+
+
+Starting from version ``3.1``, pytest now automatically catches warnings during test execution
+and displays them at the end of the session:
+
+.. code-block:: python
+
+    # content of test_show_warnings.py
+    import warnings
+
+
+    def api_v1():
+        warnings.warn(UserWarning("api v1, should use functions from v2"))
+        return 1
+
+
+    def test_one():
+        assert api_v1() == 1
+
+Running pytest now produces this output:
+
+.. code-block:: pytest
+
+    $ pytest test_show_warnings.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_show_warnings.py .                                              [100%]
+
+    ============================= warnings summary =============================
+    test_show_warnings.py::test_one
+      /home/sweet/project/test_show_warnings.py:5: UserWarning: api v1, should use functions from v2
+        warnings.warn(UserWarning("api v1, should use functions from v2"))
+
+    -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
+    ======================= 1 passed, 1 warning in 0.12s =======================
+
+.. _`controlling-warnings`:
+
+Controlling warnings
+--------------------
+
+Similar to Python's `warning filter`_ and :option:`-W option <python:-W>` flag, pytest provides
+its own ``-W`` flag to control which warnings are ignored, displayed, or turned into
+errors. See the `warning filter`_ documentation for more
+advanced use-cases.
+
+.. _`warning filter`: https://docs.python.org/3/library/warnings.html#warning-filter
+
+This code sample shows how to treat any ``UserWarning`` category class of warning
+as an error:
+
+.. code-block:: pytest
+
+    $ pytest -q test_show_warnings.py -W error::UserWarning
+    F                                                                    [100%]
+    ================================= FAILURES =================================
+    _________________________________ test_one _________________________________
+
+        def test_one():
+    >       assert api_v1() == 1
+
+    test_show_warnings.py:10:
+    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
+
+        def api_v1():
+    >       warnings.warn(UserWarning("api v1, should use functions from v2"))
+    E       UserWarning: api v1, should use functions from v2
+
+    test_show_warnings.py:5: UserWarning
+    ========================= short test summary info ==========================
+    FAILED test_show_warnings.py::test_one - UserWarning: api v1, should use ...
+    1 failed in 0.12s
+
+The same option can be set in the ``pytest.ini`` or ``pyproject.toml`` file using the
+``filterwarnings`` ini option. For example, the configuration below will ignore all
+user warnings and specific deprecation warnings matching a regex, but will transform
+all other warnings into errors.
+
+.. code-block:: ini
+
+    # pytest.ini
+    [pytest]
+    filterwarnings =
+        error
+        ignore::UserWarning
+        ignore:function ham\(\) is deprecated:DeprecationWarning
+
+.. code-block:: toml
+
+    # pyproject.toml
+    [tool.pytest.ini_options]
+    filterwarnings = [
+        "error",
+        "ignore::UserWarning",
+        # note the use of single quote below to denote "raw" strings in TOML
+        'ignore:function ham\(\) is deprecated:DeprecationWarning',
+    ]
+
+
+When a warning matches more than one option in the list, the action for the last matching option
+is performed.
+
+
+.. note::
+
+    The ``-W`` flag and the ``filterwarnings`` ini option use warning filters that are
+    similar in structure, but each configuration option interprets its filter
+    differently. For example, *message* in ``filterwarnings`` is a string containing a
+    regular expression that the start of the warning message must match,
+    case-insensitively, while *message* in ``-W`` is a literal string that the start of
+    the warning message must contain (case-insensitively), ignoring any whitespace at
+    the start or end of message. Consult the `warning filter`_ documentation for more
+    details.
+
+
+.. _`filterwarnings`:
+
+``@pytest.mark.filterwarnings``
+-------------------------------
+
+
+
+You can use the ``@pytest.mark.filterwarnings`` to add warning filters to specific test items,
+allowing you to have finer control of which warnings should be captured at test, class or
+even module level:
+
+.. code-block:: python
+
+    import warnings
+
+
+    def api_v1():
+        warnings.warn(UserWarning("api v1, should use functions from v2"))
+        return 1
+
+
+    @pytest.mark.filterwarnings("ignore:api v1")
+    def test_one():
+        assert api_v1() == 1
+
+
+Filters applied using a mark take precedence over filters passed on the command line or configured
+by the ``filterwarnings`` ini option.
+
+You may apply a filter to all tests of a class by using the ``filterwarnings`` mark as a class
+decorator or to all tests in a module by setting the :globalvar:`pytestmark` variable:
+
+.. code-block:: python
+
+    # turns all warnings into errors for this module
+    pytestmark = pytest.mark.filterwarnings("error")
+
+
+
+*Credits go to Florian Schulze for the reference implementation in the* `pytest-warnings`_
+*plugin.*
+
+.. _`pytest-warnings`: https://github.com/fschulze/pytest-warnings
+
+Disabling warnings summary
+--------------------------
+
+Although not recommended, you can use the ``--disable-warnings`` command-line option to suppress the
+warning summary entirely from the test run output.
+
+Disabling warning capture entirely
+----------------------------------
+
+This plugin is enabled by default but can be disabled entirely in your ``pytest.ini`` file with:
+
+    .. code-block:: ini
+
+        [pytest]
+        addopts = -p no:warnings
+
+Or passing ``-p no:warnings`` in the command-line. This might be useful if your test suites handles warnings
+using an external system.
+
+
+.. _`deprecation-warnings`:
+
+DeprecationWarning and PendingDeprecationWarning
+------------------------------------------------
+
+By default pytest will display ``DeprecationWarning`` and ``PendingDeprecationWarning`` warnings from
+user code and third-party libraries, as recommended by :pep:`565`.
+This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed.
+
+However, in the specific case where users capture any type of warnings in their test, either with
+:func:`pytest.warns`, :func:`pytest.deprecated_call` or using the :ref:`recwarn <recwarn>` fixture,
+no warning will be displayed at all.
+
+Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over
+(such as third-party libraries), in which case you might use the warning filters options (ini or marks) to ignore
+those warnings.
+
+For example:
+
+.. code-block:: ini
+
+    [pytest]
+    filterwarnings =
+        ignore:.*U.*mode is deprecated:DeprecationWarning
+
+
+This will ignore all warnings of type ``DeprecationWarning`` where the start of the message matches
+the regular expression ``".*U.*mode is deprecated"``.
+
+See :ref:`@pytest.mark.filterwarnings <filterwarnings>` and
+:ref:`Controlling warnings <controlling-warnings>` for more examples.
+
+.. note::
+
+    If warnings are configured at the interpreter level, using
+    the :envvar:`python:PYTHONWARNINGS` environment variable or the
+    ``-W`` command-line option, pytest will not configure any filters by default.
+
+    Also pytest doesn't follow :pep:`506` suggestion of resetting all warning filters because
+    it might break test suites that configure warning filters themselves
+    by calling :func:`warnings.simplefilter` (see :issue:`2430` for an example of that).
+
+
+.. _`ensuring a function triggers a deprecation warning`:
+
+.. _ensuring_function_triggers:
+
+Ensuring code triggers a deprecation warning
+--------------------------------------------
+
+You can also use :func:`pytest.deprecated_call` for checking
+that a certain function call triggers a ``DeprecationWarning`` or
+``PendingDeprecationWarning``:
+
+.. code-block:: python
+
+    import pytest
+
+
+    def test_myfunction_deprecated():
+        with pytest.deprecated_call():
+            myfunction(17)
+
+This test will fail if ``myfunction`` does not issue a deprecation warning
+when called with a ``17`` argument.
+
+
+
+
+.. _`asserting warnings`:
+
+.. _assertwarnings:
+
+.. _`asserting warnings with the warns function`:
+
+.. _warns:
+
+Asserting warnings with the warns function
+------------------------------------------
+
+You can check that code raises a particular warning using :func:`pytest.warns`,
+which works in a similar manner to :ref:`raises <assertraises>` (except that
+:ref:`raises <assertraises>` does not capture all exceptions, only the
+``expected_exception``):
+
+.. code-block:: python
+
+    import warnings
+
+    import pytest
+
+
+    def test_warning():
+        with pytest.warns(UserWarning):
+            warnings.warn("my warning", UserWarning)
+
+The test will fail if the warning in question is not raised. Use the keyword
+argument ``match`` to assert that the warning matches a text or regex.
+To match a literal string that may contain regular expression metacharacters like ``(`` or ``.``, the pattern can
+first be escaped with ``re.escape``.
+
+Some examples:
+
+.. code-block:: pycon
+
+
+    >>> with warns(UserWarning, match="must be 0 or None"):
+    ...     warnings.warn("value must be 0 or None", UserWarning)
+    ...
+
+    >>> with warns(UserWarning, match=r"must be \d+$"):
+    ...     warnings.warn("value must be 42", UserWarning)
+    ...
+
+    >>> with warns(UserWarning, match=r"must be \d+$"):
+    ...     warnings.warn("this is not here", UserWarning)
+    ...
+    Traceback (most recent call last):
+      ...
+    Failed: DID NOT WARN. No warnings of type ...UserWarning... were emitted...
+
+    >>> with warns(UserWarning, match=re.escape("issue with foo() func")):
+    ...     warnings.warn("issue with foo() func")
+    ...
+
+You can also call :func:`pytest.warns` on a function or code string:
+
+.. code-block:: python
+
+    pytest.warns(expected_warning, func, *args, **kwargs)
+    pytest.warns(expected_warning, "func(*args, **kwargs)")
+
+The function also returns a list of all raised warnings (as
+``warnings.WarningMessage`` objects), which you can query for
+additional information:
+
+.. code-block:: python
+
+    with pytest.warns(RuntimeWarning) as record:
+        warnings.warn("another warning", RuntimeWarning)
+
+    # check that only one warning was raised
+    assert len(record) == 1
+    # check that the message matches
+    assert record[0].message.args[0] == "another warning"
+
+Alternatively, you can examine raised warnings in detail using the
+:ref:`recwarn <recwarn>` fixture (see below).
+
+
+The :ref:`recwarn <recwarn>` fixture automatically ensures to reset the warnings
+filter at the end of the test, so no global state is leaked.
+
+.. _`recording warnings`:
+
+.. _recwarn:
+
+Recording warnings
+------------------
+
+You can record raised warnings either using :func:`pytest.warns` or with
+the ``recwarn`` fixture.
+
+To record with :func:`pytest.warns` without asserting anything about the warnings,
+pass no arguments as the expected warning type and it will default to a generic Warning:
+
+.. code-block:: python
+
+    with pytest.warns() as record:
+        warnings.warn("user", UserWarning)
+        warnings.warn("runtime", RuntimeWarning)
+
+    assert len(record) == 2
+    assert str(record[0].message) == "user"
+    assert str(record[1].message) == "runtime"
+
+The ``recwarn`` fixture will record warnings for the whole function:
+
+.. code-block:: python
+
+    import warnings
+
+
+    def test_hello(recwarn):
+        warnings.warn("hello", UserWarning)
+        assert len(recwarn) == 1
+        w = recwarn.pop(UserWarning)
+        assert issubclass(w.category, UserWarning)
+        assert str(w.message) == "hello"
+        assert w.filename
+        assert w.lineno
+
+Both ``recwarn`` and :func:`pytest.warns` return the same interface for recorded
+warnings: a WarningsRecorder instance. To view the recorded warnings, you can
+iterate over this instance, call ``len`` on it to get the number of recorded
+warnings, or index into it to get a particular recorded warning.
+
+.. currentmodule:: _pytest.warnings
+
+Full API: :class:`~_pytest.recwarn.WarningsRecorder`.
+
+.. _`warns use cases`:
+
+Additional use cases of warnings in tests
+-----------------------------------------
+
+Here are some use cases involving warnings that often come up in tests, and suggestions on how to deal with them:
+
+- To ensure that **at least one** of the indicated warnings is issued, use:
+
+.. code-block:: python
+
+    def test_warning():
+        with pytest.warns((RuntimeWarning, UserWarning)):
+            ...
+
+- To ensure that **only** certain warnings are issued, use:
+
+.. code-block:: python
+
+    def test_warning(recwarn):
+        ...
+        assert len(recwarn) == 1
+        user_warning = recwarn.pop(UserWarning)
+        assert issubclass(user_warning.category, UserWarning)
+
+-  To ensure that **no** warnings are emitted, use:
+
+.. code-block:: python
+
+    def test_warning():
+        with warnings.catch_warnings():
+            warnings.simplefilter("error")
+            ...
+
+- To suppress warnings, use:
+
+.. code-block:: python
+
+    with warnings.catch_warnings():
+        warnings.simplefilter("ignore")
+        ...
+
+
+.. _custom_failure_messages:
+
+Custom failure messages
+-----------------------
+
+Recording warnings provides an opportunity to produce custom test
+failure messages for when no warnings are issued or other conditions
+are met.
+
+.. code-block:: python
+
+    def test():
+        with pytest.warns(Warning) as record:
+            f()
+            if not record:
+                pytest.fail("Expected a warning!")
+
+If no warnings are issued when calling ``f``, then ``not record`` will
+evaluate to ``True``.  You can then call :func:`pytest.fail` with a
+custom error message.
+
+.. _internal-warnings:
+
+Internal pytest warnings
+------------------------
+
+pytest may generate its own warnings in some situations, such as improper usage or deprecated features.
+
+For example, pytest will emit a warning if it encounters a class that matches :confval:`python_classes` but also
+defines an ``__init__`` constructor, as this prevents the class from being instantiated:
+
+.. code-block:: python
+
+    # content of test_pytest_warnings.py
+    class Test:
+        def __init__(self):
+            pass
+
+        def test_foo(self):
+            assert 1 == 1
+
+.. code-block:: pytest
+
+    $ pytest test_pytest_warnings.py -q
+
+    ============================= warnings summary =============================
+    test_pytest_warnings.py:1
+      /home/sweet/project/test_pytest_warnings.py:1: PytestCollectionWarning: cannot collect test class 'Test' because it has a __init__ constructor (from: test_pytest_warnings.py)
+        class Test:
+
+    -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
+    1 warning in 0.12s
+
+These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings.
+
+Please read our :ref:`backwards-compatibility` to learn how we proceed about deprecating and eventually removing
+features.
+
+The full list of warnings is listed in :ref:`the reference documentation <warnings ref>`.
+
+
+.. _`resource-warnings`:
+
+Resource Warnings
+-----------------
+
+Additional information of the source of a :class:`ResourceWarning` can be obtained when captured by pytest if
+:mod:`tracemalloc` module is enabled.
+
+One convenient way to enable :mod:`tracemalloc` when running tests is to set the :envvar:`PYTHONTRACEMALLOC` to a large
+enough number of frames (say ``20``, but that number is application dependent).
+
+For more information, consult the `Python Development Mode <https://docs.python.org/3/library/devmode.html>`__
+section in the Python documentation.
diff --git a/doc/en/how-to/doctest.rst b/doc/en/how-to/doctest.rst
new file mode 100644 (file)
index 0000000..021ba27
--- /dev/null
@@ -0,0 +1,314 @@
+.. _doctest:
+
+How to run doctests
+=========================================================
+
+By default, all files matching the ``test*.txt`` pattern will
+be run through the python standard :mod:`doctest` module.  You
+can change the pattern by issuing:
+
+.. code-block:: bash
+
+    pytest --doctest-glob="*.rst"
+
+on the command line. ``--doctest-glob`` can be given multiple times in the command-line.
+
+If you then have a text file like this:
+
+.. code-block:: text
+
+    # content of test_example.txt
+
+    hello this is a doctest
+    >>> x = 3
+    >>> x
+    3
+
+then you can just invoke ``pytest`` directly:
+
+.. code-block:: pytest
+
+    $ pytest
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_example.txt .                                                   [100%]
+
+    ============================ 1 passed in 0.12s =============================
+
+By default, pytest will collect ``test*.txt`` files looking for doctest directives, but you
+can pass additional globs using the ``--doctest-glob`` option (multi-allowed).
+
+In addition to text files, you can also execute doctests directly from docstrings of your classes
+and functions, including from test modules:
+
+.. code-block:: python
+
+    # content of mymodule.py
+    def something():
+        """a doctest in a docstring
+        >>> something()
+        42
+        """
+        return 42
+
+.. code-block:: bash
+
+    $ pytest --doctest-modules
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 2 items
+
+    mymodule.py .                                                        [ 50%]
+    test_example.txt .                                                   [100%]
+
+    ============================ 2 passed in 0.12s =============================
+
+You can make these changes permanent in your project by
+putting them into a pytest.ini file like this:
+
+.. code-block:: ini
+
+    # content of pytest.ini
+    [pytest]
+    addopts = --doctest-modules
+
+
+Encoding
+--------
+
+The default encoding is **UTF-8**, but you can specify the encoding
+that will be used for those doctest files using the
+``doctest_encoding`` ini option:
+
+.. code-block:: ini
+
+    # content of pytest.ini
+    [pytest]
+    doctest_encoding = latin1
+
+.. _using doctest options:
+
+Using 'doctest' options
+-----------------------
+
+Python's standard :mod:`doctest` module provides some :ref:`options <python:option-flags-and-directives>`
+to configure the strictness of doctest tests. In pytest, you can enable those flags using the
+configuration file.
+
+For example, to make pytest ignore trailing whitespaces and ignore
+lengthy exception stack traces you can just write:
+
+.. code-block:: ini
+
+    [pytest]
+    doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
+
+Alternatively, options can be enabled by an inline comment in the doc test
+itself:
+
+.. code-block:: rst
+
+    >>> something_that_raises()  # doctest: +IGNORE_EXCEPTION_DETAIL
+    Traceback (most recent call last):
+    ValueError: ...
+
+pytest also introduces new options:
+
+* ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode
+  strings in expected doctest output. This allows doctests to run in Python 2
+  and Python 3 unchanged.
+
+* ``ALLOW_BYTES``: similarly, the ``b`` prefix is stripped from byte strings
+  in expected doctest output.
+
+* ``NUMBER``: when enabled, floating-point numbers only need to match as far as
+  the precision you have written in the expected doctest output. The numbers are
+  compared using :func:`pytest.approx` with relative tolerance equal to the
+  precision. For example, the following output would only need to match to 2
+  decimal places when comparing ``3.14`` to
+  ``pytest.approx(math.pi, rel=10**-2)``::
+
+      >>> math.pi
+      3.14
+
+  If you wrote ``3.1416`` then the actual output would need to match to
+  approximately 4 decimal places; and so on.
+
+  This avoids false positives caused by limited floating-point precision, like
+  this::
+
+      Expected:
+          0.233
+      Got:
+          0.23300000000000001
+
+  ``NUMBER`` also supports lists of floating-point numbers -- in fact, it
+  matches floating-point numbers appearing anywhere in the output, even inside
+  a string! This means that it may not be appropriate to enable globally in
+  ``doctest_optionflags`` in your configuration file.
+
+  .. versionadded:: 5.1
+
+
+Continue on failure
+-------------------
+
+By default, pytest would report only the first failure for a given doctest. If
+you want to continue the test even when you have failures, do:
+
+.. code-block:: bash
+
+    pytest --doctest-modules --doctest-continue-on-failure
+
+
+Output format
+-------------
+
+You can change the diff output format on failure for your doctests
+by using one of standard doctest modules format in options
+(see :data:`python:doctest.REPORT_UDIFF`, :data:`python:doctest.REPORT_CDIFF`,
+:data:`python:doctest.REPORT_NDIFF`, :data:`python:doctest.REPORT_ONLY_FIRST_FAILURE`):
+
+.. code-block:: bash
+
+    pytest --doctest-modules --doctest-report none
+    pytest --doctest-modules --doctest-report udiff
+    pytest --doctest-modules --doctest-report cdiff
+    pytest --doctest-modules --doctest-report ndiff
+    pytest --doctest-modules --doctest-report only_first_failure
+
+
+pytest-specific features
+------------------------
+
+Some features are provided to make writing doctests easier or with better integration with
+your existing test suite. Keep in mind however that by using those features you will make
+your doctests incompatible with the standard ``doctests`` module.
+
+Using fixtures
+^^^^^^^^^^^^^^
+
+It is possible to use fixtures using the ``getfixture`` helper:
+
+.. code-block:: text
+
+    # content of example.rst
+    >>> tmp = getfixture('tmp_path')
+    >>> ...
+    >>>
+
+Note that the fixture needs to be defined in a place visible by pytest, for example, a `conftest.py`
+file or plugin; normal python files containing docstrings are not normally scanned for fixtures
+unless explicitly configured by :confval:`python_files`.
+
+Also, the :ref:`usefixtures <usefixtures>` mark and fixtures marked as :ref:`autouse <autouse>` are supported
+when executing text doctest files.
+
+
+.. _`doctest_namespace`:
+
+'doctest_namespace' fixture
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``doctest_namespace`` fixture can be used to inject items into the
+namespace in which your doctests run. It is intended to be used within
+your own fixtures to provide the tests that use them with context.
+
+``doctest_namespace`` is a standard ``dict`` object into which you
+place the objects you want to appear in the doctest namespace:
+
+.. code-block:: python
+
+    # content of conftest.py
+    import numpy
+
+
+    @pytest.fixture(autouse=True)
+    def add_np(doctest_namespace):
+        doctest_namespace["np"] = numpy
+
+which can then be used in your doctests directly:
+
+.. code-block:: python
+
+    # content of numpy.py
+    def arange():
+        """
+        >>> a = np.arange(10)
+        >>> len(a)
+        10
+        """
+
+Note that like the normal ``conftest.py``, the fixtures are discovered in the directory tree conftest is in.
+Meaning that if you put your doctest with your source code, the relevant conftest.py needs to be in the same directory tree.
+Fixtures will not be discovered in a sibling directory tree!
+
+Skipping tests
+^^^^^^^^^^^^^^
+
+For the same reasons one might want to skip normal tests, it is also possible to skip
+tests inside doctests.
+
+To skip a single check inside a doctest you can use the standard
+:data:`doctest.SKIP` directive:
+
+.. code-block:: python
+
+    def test_random(y):
+        """
+        >>> random.random()  # doctest: +SKIP
+        0.156231223
+
+        >>> 1 + 1
+        2
+        """
+
+This will skip the first check, but not the second.
+
+pytest also allows using the standard pytest functions :func:`pytest.skip` and
+:func:`pytest.xfail` inside doctests, which might be useful because you can
+then skip/xfail tests based on external conditions:
+
+
+.. code-block:: text
+
+    >>> import sys, pytest
+    >>> if sys.platform.startswith('win'):
+    ...     pytest.skip('this doctest does not work on Windows')
+    ...
+    >>> import fcntl
+    >>> ...
+
+However using those functions is discouraged because it reduces the readability of the
+docstring.
+
+.. note::
+
+    :func:`pytest.skip` and :func:`pytest.xfail` behave differently depending
+    if the doctests are in a Python file (in docstrings) or a text file containing
+    doctests intermingled with text:
+
+    * Python modules (docstrings): the functions only act in that specific docstring,
+      letting the other docstrings in the same module execute as normal.
+
+    * Text files: the functions will skip/xfail the checks for the rest of the entire
+      file.
+
+
+Alternatives
+------------
+
+While the built-in pytest support provides a good set of functionalities for using
+doctests, if you use them extensively you might be interested in those external packages
+which add many more features, and include pytest integration:
+
+* `pytest-doctestplus <https://github.com/astropy/pytest-doctestplus>`__: provides
+  advanced doctest support and enables the testing of reStructuredText (".rst") files.
+
+* `Sybil <https://sybil.readthedocs.io>`__: provides a way to test examples in
+  your documentation by parsing them from the documentation source and evaluating
+  the parsed examples as part of your normal test run.
diff --git a/doc/en/how-to/existingtestsuite.rst b/doc/en/how-to/existingtestsuite.rst
new file mode 100644 (file)
index 0000000..9909e7d
--- /dev/null
@@ -0,0 +1,34 @@
+.. _existingtestsuite:
+
+How to use pytest with an existing test suite
+==============================================
+
+Pytest can be used with most existing test suites, but its
+behavior differs from other test runners such as :ref:`nose <noseintegration>` or
+Python's default unittest framework.
+
+Before using this section you will want to :ref:`install pytest <getstarted>`.
+
+Running an existing test suite with pytest
+---------------------------------------------
+
+Say you want to contribute to an existing repository somewhere.
+After pulling the code into your development space using some
+flavor of version control and (optionally) setting up a virtualenv
+you will want to run:
+
+.. code-block:: bash
+
+    cd <repository>
+    pip install -e .  # Environment dependent alternatives include
+                      # 'python setup.py develop' and 'conda develop'
+
+in your project root.  This will set up a symlink to your code in
+site-packages, allowing you to edit your code while your tests
+run against it as if it were installed.
+
+Setting up your project in development mode lets you avoid having to
+reinstall every time you want to run your tests, and is less brittle than
+mucking about with sys.path to point your tests at local code.
+
+Also consider using :ref:`tox <use tox>`.
diff --git a/doc/en/how-to/failures.rst b/doc/en/how-to/failures.rst
new file mode 100644 (file)
index 0000000..ef87550
--- /dev/null
@@ -0,0 +1,160 @@
+.. _how-to-handle-failures:
+
+How to handle test failures
+=============================
+
+.. _maxfail:
+
+Stopping after the first (or N) failures
+---------------------------------------------------
+
+To stop the testing process after the first (N) failures:
+
+.. code-block:: bash
+
+    pytest -x           # stop after first failure
+    pytest --maxfail=2  # stop after two failures
+
+
+.. _pdb-option:
+
+Using :doc:`python:library/pdb` with pytest
+-------------------------------------------
+
+Dropping to :doc:`pdb <python:library/pdb>` on failures
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Python comes with a builtin Python debugger called :doc:`pdb <python:library/pdb>`.  ``pytest``
+allows one to drop into the :doc:`pdb <python:library/pdb>` prompt via a command line option:
+
+.. code-block:: bash
+
+    pytest --pdb
+
+This will invoke the Python debugger on every failure (or KeyboardInterrupt).
+Often you might only want to do this for the first failing test to understand
+a certain failure situation:
+
+.. code-block:: bash
+
+    pytest -x --pdb   # drop to PDB on first failure, then end test session
+    pytest --pdb --maxfail=3  # drop to PDB for first three failures
+
+Note that on any failure the exception information is stored on
+``sys.last_value``, ``sys.last_type`` and ``sys.last_traceback``. In
+interactive use, this allows one to drop into postmortem debugging with
+any debug tool. One can also manually access the exception information,
+for example::
+
+    >>> import sys
+    >>> sys.last_traceback.tb_lineno
+    42
+    >>> sys.last_value
+    AssertionError('assert result == "ok"',)
+
+
+.. _trace-option:
+
+Dropping to :doc:`pdb <python:library/pdb>` at the start of a test
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``pytest`` allows one to drop into the :doc:`pdb <python:library/pdb>` prompt immediately at the start of each test via a command line option:
+
+.. code-block:: bash
+
+    pytest --trace
+
+This will invoke the Python debugger at the start of every test.
+
+.. _breakpoints:
+
+Setting breakpoints
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded: 2.4.0
+
+To set a breakpoint in your code use the native Python ``import pdb;pdb.set_trace()`` call
+in your code and pytest automatically disables its output capture for that test:
+
+* Output capture in other tests is not affected.
+* Any prior test output that has already been captured and will be processed as
+  such.
+* Output capture gets resumed when ending the debugger session (via the
+  ``continue`` command).
+
+
+.. _`breakpoint-builtin`:
+
+Using the builtin breakpoint function
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Python 3.7 introduces a builtin ``breakpoint()`` function.
+Pytest supports the use of ``breakpoint()`` with the following behaviours:
+
+ - When ``breakpoint()`` is called and ``PYTHONBREAKPOINT`` is set to the default value, pytest will use the custom internal PDB trace UI instead of the system default ``Pdb``.
+ - When tests are complete, the system will default back to the system ``Pdb`` trace UI.
+ - With ``--pdb`` passed to pytest, the custom internal Pdb trace UI is used with both ``breakpoint()`` and failed tests/unhandled exceptions.
+ - ``--pdbcls`` can be used to specify a custom debugger class.
+
+
+.. _faulthandler:
+
+Fault Handler
+-------------
+
+.. versionadded:: 5.0
+
+The :mod:`faulthandler` standard module
+can be used to dump Python tracebacks on a segfault or after a timeout.
+
+The module is automatically enabled for pytest runs, unless the ``-p no:faulthandler`` is given
+on the command-line.
+
+Also the :confval:`faulthandler_timeout=X<faulthandler_timeout>` configuration option can be used
+to dump the traceback of all threads if a test takes longer than ``X``
+seconds to finish (not available on Windows).
+
+.. note::
+
+    This functionality has been integrated from the external
+    `pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin, with two
+    small differences:
+
+    * To disable it, use ``-p no:faulthandler`` instead of ``--no-faulthandler``: the former
+      can be used with any plugin, so it saves one option.
+
+    * The ``--faulthandler-timeout`` command-line option has become the
+      :confval:`faulthandler_timeout` configuration option. It can still be configured from
+      the command-line using ``-o faulthandler_timeout=X``.
+
+
+.. _unraisable:
+
+Warning about unraisable exceptions and unhandled thread exceptions
+-------------------------------------------------------------------
+
+.. versionadded:: 6.2
+
+.. note::
+
+    These features only work on Python>=3.8.
+
+Unhandled exceptions are exceptions that are raised in a situation in which
+they cannot propagate to a caller. The most common case is an exception raised
+in a :meth:`__del__ <object.__del__>` implementation.
+
+Unhandled thread exceptions are exceptions raised in a :class:`~threading.Thread`
+but not handled, causing the thread to terminate uncleanly.
+
+Both types of exceptions are normally considered bugs, but may go unnoticed
+because they don't cause the program itself to crash. Pytest detects these
+conditions and issues a warning that is visible in the test run summary.
+
+The plugins are automatically enabled for pytest runs, unless the
+``-p no:unraisableexception`` (for unraisable exceptions) and
+``-p no:threadexception`` (for thread exceptions) options are given on the
+command-line.
+
+The warnings may be silenced selectively using the :ref:`pytest.mark.filterwarnings ref`
+mark. The warning categories are :class:`pytest.PytestUnraisableExceptionWarning` and
+:class:`pytest.PytestUnhandledThreadExceptionWarning`.
diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst
new file mode 100644 (file)
index 0000000..a6f4962
--- /dev/null
@@ -0,0 +1,1964 @@
+.. _how-to-fixtures:
+
+How to use fixtures
+====================
+
+.. seealso:: :ref:`about-fixtures`
+.. seealso:: :ref:`Fixtures reference <reference-fixtures>`
+
+
+"Requesting" fixtures
+---------------------
+
+At a basic level, test functions request fixtures they require by declaring
+them as arguments.
+
+When pytest goes to run a test, it looks at the parameters in that test
+function's signature, and then searches for fixtures that have the same names as
+those parameters. Once pytest finds them, it runs those fixtures, captures what
+they returned (if anything), and passes those objects into the test function as
+arguments.
+
+
+Quick example
+^^^^^^^^^^^^^
+
+.. code-block:: python
+
+    import pytest
+
+
+    class Fruit:
+        def __init__(self, name):
+            self.name = name
+            self.cubed = False
+
+        def cube(self):
+            self.cubed = True
+
+
+    class FruitSalad:
+        def __init__(self, *fruit_bowl):
+            self.fruit = fruit_bowl
+            self._cube_fruit()
+
+        def _cube_fruit(self):
+            for fruit in self.fruit:
+                fruit.cube()
+
+
+    # Arrange
+    @pytest.fixture
+    def fruit_bowl():
+        return [Fruit("apple"), Fruit("banana")]
+
+
+    def test_fruit_salad(fruit_bowl):
+        # Act
+        fruit_salad = FruitSalad(*fruit_bowl)
+
+        # Assert
+        assert all(fruit.cubed for fruit in fruit_salad.fruit)
+
+In this example, ``test_fruit_salad`` "**requests**" ``fruit_bowl`` (i.e.
+``def test_fruit_salad(fruit_bowl):``), and when pytest sees this, it will
+execute the ``fruit_bowl`` fixture function and pass the object it returns into
+``test_fruit_salad`` as the ``fruit_bowl`` argument.
+
+Here's roughly
+what's happening if we were to do it by hand:
+
+.. code-block:: python
+
+    def fruit_bowl():
+        return [Fruit("apple"), Fruit("banana")]
+
+
+    def test_fruit_salad(fruit_bowl):
+        # Act
+        fruit_salad = FruitSalad(*fruit_bowl)
+
+        # Assert
+        assert all(fruit.cubed for fruit in fruit_salad.fruit)
+
+
+    # Arrange
+    bowl = fruit_bowl()
+    test_fruit_salad(fruit_bowl=bowl)
+
+
+Fixtures can **request** other fixtures
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+One of pytest's greatest strengths is its extremely flexible fixture system. It
+allows us to boil down complex requirements for tests into more simple and
+organized functions, where we only need to have each one describe the things
+they are dependent on. We'll get more into this further down, but for now,
+here's a quick example to demonstrate how fixtures can use other fixtures:
+
+.. code-block:: python
+
+    # contents of test_append.py
+    import pytest
+
+
+    # Arrange
+    @pytest.fixture
+    def first_entry():
+        return "a"
+
+
+    # Arrange
+    @pytest.fixture
+    def order(first_entry):
+        return [first_entry]
+
+
+    def test_string(order):
+        # Act
+        order.append("b")
+
+        # Assert
+        assert order == ["a", "b"]
+
+
+Notice that this is the same example from above, but very little changed. The
+fixtures in pytest **request** fixtures just like tests. All the same
+**requesting** rules apply to fixtures that do for tests. Here's how this
+example would work if we did it by hand:
+
+.. code-block:: python
+
+    def first_entry():
+        return "a"
+
+
+    def order(first_entry):
+        return [first_entry]
+
+
+    def test_string(order):
+        # Act
+        order.append("b")
+
+        # Assert
+        assert order == ["a", "b"]
+
+
+    entry = first_entry()
+    the_list = order(first_entry=entry)
+    test_string(order=the_list)
+
+Fixtures are reusable
+^^^^^^^^^^^^^^^^^^^^^
+
+One of the things that makes pytest's fixture system so powerful, is that it
+gives us the ability to define a generic setup step that can be reused over and
+over, just like a normal function would be used. Two different tests can request
+the same fixture and have pytest give each test their own result from that
+fixture.
+
+This is extremely useful for making sure tests aren't affected by each other. We
+can use this system to make sure each test gets its own fresh batch of data and
+is starting from a clean state so it can provide consistent, repeatable results.
+
+Here's an example of how this can come in handy:
+
+.. code-block:: python
+
+    # contents of test_append.py
+    import pytest
+
+
+    # Arrange
+    @pytest.fixture
+    def first_entry():
+        return "a"
+
+
+    # Arrange
+    @pytest.fixture
+    def order(first_entry):
+        return [first_entry]
+
+
+    def test_string(order):
+        # Act
+        order.append("b")
+
+        # Assert
+        assert order == ["a", "b"]
+
+
+    def test_int(order):
+        # Act
+        order.append(2)
+
+        # Assert
+        assert order == ["a", 2]
+
+
+Each test here is being given its own copy of that ``list`` object,
+which means the ``order`` fixture is getting executed twice (the same
+is true for the ``first_entry`` fixture). If we were to do this by hand as
+well, it would look something like this:
+
+.. code-block:: python
+
+    def first_entry():
+        return "a"
+
+
+    def order(first_entry):
+        return [first_entry]
+
+
+    def test_string(order):
+        # Act
+        order.append("b")
+
+        # Assert
+        assert order == ["a", "b"]
+
+
+    def test_int(order):
+        # Act
+        order.append(2)
+
+        # Assert
+        assert order == ["a", 2]
+
+
+    entry = first_entry()
+    the_list = order(first_entry=entry)
+    test_string(order=the_list)
+
+    entry = first_entry()
+    the_list = order(first_entry=entry)
+    test_int(order=the_list)
+
+A test/fixture can **request** more than one fixture at a time
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Tests and fixtures aren't limited to **requesting** a single fixture at a time.
+They can request as many as they like. Here's another quick example to
+demonstrate:
+
+.. code-block:: python
+
+    # contents of test_append.py
+    import pytest
+
+
+    # Arrange
+    @pytest.fixture
+    def first_entry():
+        return "a"
+
+
+    # Arrange
+    @pytest.fixture
+    def second_entry():
+        return 2
+
+
+    # Arrange
+    @pytest.fixture
+    def order(first_entry, second_entry):
+        return [first_entry, second_entry]
+
+
+    # Arrange
+    @pytest.fixture
+    def expected_list():
+        return ["a", 2, 3.0]
+
+
+    def test_string(order, expected_list):
+        # Act
+        order.append(3.0)
+
+        # Assert
+        assert order == expected_list
+
+Fixtures can be **requested** more than once per test (return values are cached)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Fixtures can also be **requested** more than once during the same test, and
+pytest won't execute them again for that test. This means we can **request**
+fixtures in multiple fixtures that are dependent on them (and even again in the
+test itself) without those fixtures being executed more than once.
+
+.. code-block:: python
+
+    # contents of test_append.py
+    import pytest
+
+
+    # Arrange
+    @pytest.fixture
+    def first_entry():
+        return "a"
+
+
+    # Arrange
+    @pytest.fixture
+    def order():
+        return []
+
+
+    # Act
+    @pytest.fixture
+    def append_first(order, first_entry):
+        return order.append(first_entry)
+
+
+    def test_string_only(append_first, order, first_entry):
+        # Assert
+        assert order == [first_entry]
+
+If a **requested** fixture was executed once for every time it was **requested**
+during a test, then this test would fail because both ``append_first`` and
+``test_string_only`` would see ``order`` as an empty list (i.e. ``[]``), but
+since the return value of ``order`` was cached (along with any side effects
+executing it may have had) after the first time it was called, both the test and
+``append_first`` were referencing the same object, and the test saw the effect
+``append_first`` had on that object.
+
+.. _`autouse`:
+.. _`autouse fixtures`:
+
+Autouse fixtures (fixtures you don't have to request)
+-----------------------------------------------------
+
+Sometimes you may want to have a fixture (or even several) that you know all
+your tests will depend on. "Autouse" fixtures are a convenient way to make all
+tests automatically **request** them. This can cut out a
+lot of redundant **requests**, and can even provide more advanced fixture usage
+(more on that further down).
+
+We can make a fixture an autouse fixture by passing in ``autouse=True`` to the
+fixture's decorator. Here's a simple example for how they can be used:
+
+.. code-block:: python
+
+    # contents of test_append.py
+    import pytest
+
+
+    @pytest.fixture
+    def first_entry():
+        return "a"
+
+
+    @pytest.fixture
+    def order(first_entry):
+        return []
+
+
+    @pytest.fixture(autouse=True)
+    def append_first(order, first_entry):
+        return order.append(first_entry)
+
+
+    def test_string_only(order, first_entry):
+        assert order == [first_entry]
+
+
+    def test_string_and_int(order, first_entry):
+        order.append(2)
+        assert order == [first_entry, 2]
+
+In this example, the ``append_first`` fixture is an autouse fixture. Because it
+happens automatically, both tests are affected by it, even though neither test
+**requested** it. That doesn't mean they *can't* be **requested** though; just
+that it isn't *necessary*.
+
+.. _smtpshared:
+
+Scope: sharing fixtures across classes, modules, packages or session
+--------------------------------------------------------------------
+
+.. regendoc:wipe
+
+Fixtures requiring network access depend on connectivity and are
+usually time-expensive to create.  Extending the previous example, we
+can add a ``scope="module"`` parameter to the
+:py:func:`@pytest.fixture <pytest.fixture>` invocation
+to cause a ``smtp_connection`` fixture function, responsible to create a connection to a preexisting SMTP server, to only be invoked
+once per test *module* (the default is to invoke once per test *function*).
+Multiple test functions in a test module will thus
+each receive the same ``smtp_connection`` fixture instance, thus saving time.
+Possible values for ``scope`` are: ``function``, ``class``, ``module``, ``package`` or ``session``.
+
+The next example puts the fixture function into a separate ``conftest.py`` file
+so that tests from multiple test modules in the directory can
+access the fixture function:
+
+.. code-block:: python
+
+    # content of conftest.py
+    import smtplib
+
+    import pytest
+
+
+    @pytest.fixture(scope="module")
+    def smtp_connection():
+        return smtplib.SMTP("smtp.gmail.com", 587, timeout=5)
+
+
+.. code-block:: python
+
+    # content of test_module.py
+
+
+    def test_ehlo(smtp_connection):
+        response, msg = smtp_connection.ehlo()
+        assert response == 250
+        assert b"smtp.gmail.com" in msg
+        assert 0  # for demo purposes
+
+
+    def test_noop(smtp_connection):
+        response, msg = smtp_connection.noop()
+        assert response == 250
+        assert 0  # for demo purposes
+
+Here, the ``test_ehlo`` needs the ``smtp_connection`` fixture value.  pytest
+will discover and call the :py:func:`@pytest.fixture <pytest.fixture>`
+marked ``smtp_connection`` fixture function.  Running the test looks like this:
+
+.. code-block:: pytest
+
+    $ pytest test_module.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 2 items
+
+    test_module.py FF                                                    [100%]
+
+    ================================= FAILURES =================================
+    ________________________________ test_ehlo _________________________________
+
+    smtp_connection = <smtplib.SMTP object at 0xdeadbeef0001>
+
+        def test_ehlo(smtp_connection):
+            response, msg = smtp_connection.ehlo()
+            assert response == 250
+            assert b"smtp.gmail.com" in msg
+    >       assert 0  # for demo purposes
+    E       assert 0
+
+    test_module.py:7: AssertionError
+    ________________________________ test_noop _________________________________
+
+    smtp_connection = <smtplib.SMTP object at 0xdeadbeef0001>
+
+        def test_noop(smtp_connection):
+            response, msg = smtp_connection.noop()
+            assert response == 250
+    >       assert 0  # for demo purposes
+    E       assert 0
+
+    test_module.py:13: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_module.py::test_ehlo - assert 0
+    FAILED test_module.py::test_noop - assert 0
+    ============================ 2 failed in 0.12s =============================
+
+You see the two ``assert 0`` failing and more importantly you can also see
+that the **exactly same** ``smtp_connection`` object was passed into the
+two test functions because pytest shows the incoming argument values in the
+traceback.  As a result, the two test functions using ``smtp_connection`` run
+as quick as a single one because they reuse the same instance.
+
+If you decide that you rather want to have a session-scoped ``smtp_connection``
+instance, you can simply declare it:
+
+.. code-block:: python
+
+    @pytest.fixture(scope="session")
+    def smtp_connection():
+        # the returned fixture value will be shared for
+        # all tests requesting it
+        ...
+
+
+Fixture scopes
+^^^^^^^^^^^^^^
+
+Fixtures are created when first requested by a test, and are destroyed based on their ``scope``:
+
+* ``function``: the default scope, the fixture is destroyed at the end of the test.
+* ``class``: the fixture is destroyed during teardown of the last test in the class.
+* ``module``: the fixture is destroyed during teardown of the last test in the module.
+* ``package``: the fixture is destroyed during teardown of the last test in the package.
+* ``session``: the fixture is destroyed at the end of the test session.
+
+.. note::
+
+    Pytest only caches one instance of a fixture at a time, which
+    means that when using a parametrized fixture, pytest may invoke a fixture more than once in
+    the given scope.
+
+.. _dynamic scope:
+
+Dynamic scope
+^^^^^^^^^^^^^
+
+.. versionadded:: 5.2
+
+In some cases, you might want to change the scope of the fixture without changing the code.
+To do that, pass a callable to ``scope``. The callable must return a string with a valid scope
+and will be executed only once - during the fixture definition. It will be called with two
+keyword arguments - ``fixture_name`` as a string and ``config`` with a configuration object.
+
+This can be especially useful when dealing with fixtures that need time for setup, like spawning
+a docker container. You can use the command-line argument to control the scope of the spawned
+containers for different environments. See the example below.
+
+.. code-block:: python
+
+    def determine_scope(fixture_name, config):
+        if config.getoption("--keep-containers", None):
+            return "session"
+        return "function"
+
+
+    @pytest.fixture(scope=determine_scope)
+    def docker_container():
+        yield spawn_container()
+
+
+
+.. _`finalization`:
+
+Teardown/Cleanup (AKA Fixture finalization)
+-------------------------------------------
+
+When we run our tests, we'll want to make sure they clean up after themselves so
+they don't mess with any other tests (and also so that we don't leave behind a
+mountain of test data to bloat the system). Fixtures in pytest offer a very
+useful teardown system, which allows us to define the specific steps necessary
+for each fixture to clean up after itself.
+
+This system can be leveraged in two ways.
+
+.. _`yield fixtures`:
+
+1. ``yield`` fixtures (recommended)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. regendoc: wipe
+
+"Yield" fixtures ``yield`` instead of ``return``. With these
+fixtures, we can run some code and pass an object back to the requesting
+fixture/test, just like with the other fixtures. The only differences are:
+
+1. ``return`` is swapped out for ``yield``.
+2. Any teardown code for that fixture is placed *after* the ``yield``.
+
+Once pytest figures out a linear order for the fixtures, it will run each one up
+until it returns or yields, and then move on to the next fixture in the list to
+do the same thing.
+
+Once the test is finished, pytest will go back down the list of fixtures, but in
+the *reverse order*, taking each one that yielded, and running the code inside
+it that was *after* the ``yield`` statement.
+
+As a simple example, consider this basic email module:
+
+.. code-block:: python
+
+    # content of emaillib.py
+    class MailAdminClient:
+        def create_user(self):
+            return MailUser()
+
+        def delete_user(self, user):
+            # do some cleanup
+            pass
+
+
+    class MailUser:
+        def __init__(self):
+            self.inbox = []
+
+        def send_email(self, email, other):
+            other.inbox.append(email)
+
+        def clear_mailbox(self):
+            self.inbox.clear()
+
+
+    class Email:
+        def __init__(self, subject, body):
+            self.subject = subject
+            self.body = body
+
+Let's say we want to test sending email from one user to another. We'll have to
+first make each user, then send the email from one user to the other, and
+finally assert that the other user received that message in their inbox. If we
+want to clean up after the test runs, we'll likely have to make sure the other
+user's mailbox is emptied before deleting that user, otherwise the system may
+complain.
+
+Here's what that might look like:
+
+.. code-block:: python
+
+    # content of test_emaillib.py
+    from emaillib import Email, MailAdminClient
+
+    import pytest
+
+
+    @pytest.fixture
+    def mail_admin():
+        return MailAdminClient()
+
+
+    @pytest.fixture
+    def sending_user(mail_admin):
+        user = mail_admin.create_user()
+        yield user
+        mail_admin.delete_user(user)
+
+
+    @pytest.fixture
+    def receiving_user(mail_admin):
+        user = mail_admin.create_user()
+        yield user
+        user.clear_mailbox()
+        mail_admin.delete_user(user)
+
+
+    def test_email_received(sending_user, receiving_user):
+        email = Email(subject="Hey!", body="How's it going?")
+        sending_user.send_email(email, receiving_user)
+        assert email in receiving_user.inbox
+
+Because ``receiving_user`` is the last fixture to run during setup, it's the first to run
+during teardown.
+
+There is a risk that even having the order right on the teardown side of things
+doesn't guarantee a safe cleanup. That's covered in a bit more detail in
+:ref:`safe teardowns`.
+
+.. code-block:: pytest
+
+   $ pytest -q test_emaillib.py
+   .                                                                    [100%]
+   1 passed in 0.12s
+
+Handling errors for yield fixture
+"""""""""""""""""""""""""""""""""
+
+If a yield fixture raises an exception before yielding, pytest won't try to run
+the teardown code after that yield fixture's ``yield`` statement. But, for every
+fixture that has already run successfully for that test, pytest will still
+attempt to tear them down as it normally would.
+
+2. Adding finalizers directly
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+While yield fixtures are considered to be the cleaner and more straightforward
+option, there is another choice, and that is to add "finalizer" functions
+directly to the test's `request-context`_ object. It brings a similar result as
+yield fixtures, but requires a bit more verbosity.
+
+In order to use this approach, we have to request the `request-context`_ object
+(just like we would request another fixture) in the fixture we need to add
+teardown code for, and then pass a callable, containing that teardown code, to
+its ``addfinalizer`` method.
+
+We have to be careful though, because pytest will run that finalizer once it's
+been added, even if that fixture raises an exception after adding the finalizer.
+So to make sure we don't run the finalizer code when we wouldn't need to, we
+would only add the finalizer once the fixture would have done something that
+we'd need to teardown.
+
+Here's how the previous example would look using the ``addfinalizer`` method:
+
+.. code-block:: python
+
+    # content of test_emaillib.py
+    from emaillib import Email, MailAdminClient
+
+    import pytest
+
+
+    @pytest.fixture
+    def mail_admin():
+        return MailAdminClient()
+
+
+    @pytest.fixture
+    def sending_user(mail_admin):
+        user = mail_admin.create_user()
+        yield user
+        mail_admin.delete_user(user)
+
+
+    @pytest.fixture
+    def receiving_user(mail_admin, request):
+        user = mail_admin.create_user()
+
+        def delete_user():
+            mail_admin.delete_user(user)
+
+        request.addfinalizer(delete_user)
+        return user
+
+
+    @pytest.fixture
+    def email(sending_user, receiving_user, request):
+        _email = Email(subject="Hey!", body="How's it going?")
+        sending_user.send_email(_email, receiving_user)
+
+        def empty_mailbox():
+            receiving_user.clear_mailbox()
+
+        request.addfinalizer(empty_mailbox)
+        return _email
+
+
+    def test_email_received(receiving_user, email):
+        assert email in receiving_user.inbox
+
+
+It's a bit longer than yield fixtures and a bit more complex, but it
+does offer some nuances for when you're in a pinch.
+
+.. code-block:: pytest
+
+   $ pytest -q test_emaillib.py
+   .                                                                    [100%]
+   1 passed in 0.12s
+
+Note on finalizer order
+""""""""""""""""""""""""
+
+Finalizers are executed in a first-in-last-out order.
+For yield fixtures, the first teardown code to run is from the right-most fixture, i.e. the last test parameter.
+
+
+.. code-block:: python
+
+    # content of test_finalizers.py
+    import pytest
+
+
+    def test_bar(fix_w_yield1, fix_w_yield2):
+        print("test_bar")
+
+
+    @pytest.fixture
+    def fix_w_yield1():
+        yield
+        print("after_yield_1")
+
+
+    @pytest.fixture
+    def fix_w_yield2():
+        yield
+        print("after_yield_2")
+
+
+.. code-block:: pytest
+
+    $ pytest -s test_finalizers.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_finalizers.py test_bar
+    .after_yield_2
+    after_yield_1
+
+
+    ============================ 1 passed in 0.12s =============================
+
+For finalizers, the first fixture to run is last call to `request.addfinalizer`.
+
+.. code-block:: python
+
+    # content of test_finalizers.py
+    from functools import partial
+    import pytest
+
+
+    @pytest.fixture
+    def fix_w_finalizers(request):
+        request.addfinalizer(partial(print, "finalizer_2"))
+        request.addfinalizer(partial(print, "finalizer_1"))
+
+
+    def test_bar(fix_w_finalizers):
+        print("test_bar")
+
+
+.. code-block:: pytest
+
+    $ pytest -s test_finalizers.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_finalizers.py test_bar
+    .finalizer_1
+    finalizer_2
+
+
+    ============================ 1 passed in 0.12s =============================
+
+This is so because yield fixtures use `addfinalizer` behind the scenes: when the fixture executes, `addfinalizer` registers a function that resumes the generator, which in turn calls the teardown code.
+
+
+.. _`safe teardowns`:
+
+Safe teardowns
+--------------
+
+The fixture system of pytest is *very* powerful, but it's still being run by a
+computer, so it isn't able to figure out how to safely teardown everything we
+throw at it. If we aren't careful, an error in the wrong spot might leave stuff
+from our tests behind, and that can cause further issues pretty quickly.
+
+For example, consider the following tests (based off of the mail example from
+above):
+
+.. code-block:: python
+
+    # content of test_emaillib.py
+    from emaillib import Email, MailAdminClient
+
+    import pytest
+
+
+    @pytest.fixture
+    def setup():
+        mail_admin = MailAdminClient()
+        sending_user = mail_admin.create_user()
+        receiving_user = mail_admin.create_user()
+        email = Email(subject="Hey!", body="How's it going?")
+        sending_user.send_email(email, receiving_user)
+        yield receiving_user, email
+        receiving_user.clear_mailbox()
+        mail_admin.delete_user(sending_user)
+        mail_admin.delete_user(receiving_user)
+
+
+    def test_email_received(setup):
+        receiving_user, email = setup
+        assert email in receiving_user.inbox
+
+This version is a lot more compact, but it's also harder to read, doesn't have a
+very descriptive fixture name, and none of the fixtures can be reused easily.
+
+There's also a more serious issue, which is that if any of those steps in the
+setup raise an exception, none of the teardown code will run.
+
+One option might be to go with the ``addfinalizer`` method instead of yield
+fixtures, but that might get pretty complex and difficult to maintain (and it
+wouldn't be compact anymore).
+
+.. code-block:: pytest
+
+   $ pytest -q test_emaillib.py
+   .                                                                    [100%]
+   1 passed in 0.12s
+
+.. _`safe fixture structure`:
+
+Safe fixture structure
+^^^^^^^^^^^^^^^^^^^^^^
+
+The safest and simplest fixture structure requires limiting fixtures to only
+making one state-changing action each, and then bundling them together with
+their teardown code, as :ref:`the email examples above <yield fixtures>` showed.
+
+The chance that a state-changing operation can fail but still modify state is
+negligible, as most of these operations tend to be `transaction
+<https://en.wikipedia.org/wiki/Transaction_processing>`_-based (at least at the
+level of testing where state could be left behind). So if we make sure that any
+successful state-changing action gets torn down by moving it to a separate
+fixture function and separating it from other, potentially failing
+state-changing actions, then our tests will stand the best chance at leaving
+the test environment the way they found it.
+
+For an example, let's say we have a website with a login page, and we have
+access to an admin API where we can generate users. For our test, we want to:
+
+1. Create a user through that admin API
+2. Launch a browser using Selenium
+3. Go to the login page of our site
+4. Log in as the user we created
+5. Assert that their name is in the header of the landing page
+
+We wouldn't want to leave that user in the system, nor would we want to leave
+that browser session running, so we'll want to make sure the fixtures that
+create those things clean up after themselves.
+
+Here's what that might look like:
+
+.. note::
+
+    For this example, certain fixtures (i.e. ``base_url`` and
+    ``admin_credentials``) are implied to exist elsewhere. So for now, let's
+    assume they exist, and we're just not looking at them.
+
+.. code-block:: python
+
+    from uuid import uuid4
+    from urllib.parse import urljoin
+
+    from selenium.webdriver import Chrome
+    import pytest
+
+    from src.utils.pages import LoginPage, LandingPage
+    from src.utils import AdminApiClient
+    from src.utils.data_types import User
+
+
+    @pytest.fixture
+    def admin_client(base_url, admin_credentials):
+        return AdminApiClient(base_url, **admin_credentials)
+
+
+    @pytest.fixture
+    def user(admin_client):
+        _user = User(name="Susan", username=f"testuser-{uuid4()}", password="P4$$word")
+        admin_client.create_user(_user)
+        yield _user
+        admin_client.delete_user(_user)
+
+
+    @pytest.fixture
+    def driver():
+        _driver = Chrome()
+        yield _driver
+        _driver.quit()
+
+
+    @pytest.fixture
+    def login(driver, base_url, user):
+        driver.get(urljoin(base_url, "/login"))
+        page = LoginPage(driver)
+        page.login(user)
+
+
+    @pytest.fixture
+    def landing_page(driver, login):
+        return LandingPage(driver)
+
+
+    def test_name_on_landing_page_after_login(landing_page, user):
+        assert landing_page.header == f"Welcome, {user.name}!"
+
+The way the dependencies are laid out means it's unclear if the ``user``
+fixture would execute before the ``driver`` fixture. But that's ok, because
+those are atomic operations, and so it doesn't matter which one runs first
+because the sequence of events for the test is still `linearizable
+<https://en.wikipedia.org/wiki/Linearizability>`_. But what *does* matter is
+that, no matter which one runs first, if the one raises an exception while the
+other would not have, neither will have left anything behind. If ``driver``
+executes before ``user``, and ``user`` raises an exception, the driver will
+still quit, and the user was never made. And if ``driver`` was the one to raise
+the exception, then the driver would never have been started and the user would
+never have been made.
+
+.. note:
+
+    While the ``user`` fixture doesn't *actually* need to happen before the
+    ``driver`` fixture, if we made ``driver`` request ``user``, it might save
+    some time in the event that making the user raises an exception, since it
+    won't bother trying to start the driver, which is a fairly expensive
+    operation.
+
+
+Running multiple ``assert`` statements safely
+---------------------------------------------
+
+Sometimes you may want to run multiple asserts after doing all that setup, which
+makes sense as, in more complex systems, a single action can kick off multiple
+behaviors. pytest has a convenient way of handling this and it combines a bunch
+of what we've gone over so far.
+
+All that's needed is stepping up to a larger scope, then having the **act**
+step defined as an autouse fixture, and finally, making sure all the fixtures
+are targeting that higher level scope.
+
+Let's pull :ref:`an example from above <safe fixture structure>`, and tweak it a
+bit. Let's say that in addition to checking for a welcome message in the header,
+we also want to check for a sign out button, and a link to the user's profile.
+
+Let's take a look at how we can structure that so we can run multiple asserts
+without having to repeat all those steps again.
+
+.. note::
+
+    For this example, certain fixtures (i.e. ``base_url`` and
+    ``admin_credentials``) are implied to exist elsewhere. So for now, let's
+    assume they exist, and we're just not looking at them.
+
+.. code-block:: python
+
+    # contents of tests/end_to_end/test_login.py
+    from uuid import uuid4
+    from urllib.parse import urljoin
+
+    from selenium.webdriver import Chrome
+    import pytest
+
+    from src.utils.pages import LoginPage, LandingPage
+    from src.utils import AdminApiClient
+    from src.utils.data_types import User
+
+
+    @pytest.fixture(scope="class")
+    def admin_client(base_url, admin_credentials):
+        return AdminApiClient(base_url, **admin_credentials)
+
+
+    @pytest.fixture(scope="class")
+    def user(admin_client):
+        _user = User(name="Susan", username=f"testuser-{uuid4()}", password="P4$$word")
+        admin_client.create_user(_user)
+        yield _user
+        admin_client.delete_user(_user)
+
+
+    @pytest.fixture(scope="class")
+    def driver():
+        _driver = Chrome()
+        yield _driver
+        _driver.quit()
+
+
+    @pytest.fixture(scope="class")
+    def landing_page(driver, login):
+        return LandingPage(driver)
+
+
+    class TestLandingPageSuccess:
+        @pytest.fixture(scope="class", autouse=True)
+        def login(self, driver, base_url, user):
+            driver.get(urljoin(base_url, "/login"))
+            page = LoginPage(driver)
+            page.login(user)
+
+        def test_name_in_header(self, landing_page, user):
+            assert landing_page.header == f"Welcome, {user.name}!"
+
+        def test_sign_out_button(self, landing_page):
+            assert landing_page.sign_out_button.is_displayed()
+
+        def test_profile_link(self, landing_page, user):
+            profile_href = urljoin(base_url, f"/profile?id={user.profile_id}")
+            assert landing_page.profile_link.get_attribute("href") == profile_href
+
+Notice that the methods are only referencing ``self`` in the signature as a
+formality. No state is tied to the actual test class as it might be in the
+``unittest.TestCase`` framework. Everything is managed by the pytest fixture
+system.
+
+Each method only has to request the fixtures that it actually needs without
+worrying about order. This is because the **act** fixture is an autouse fixture,
+and it made sure all the other fixtures executed before it. There's no more
+changes of state that need to take place, so the tests are free to make as many
+non-state-changing queries as they want without risking stepping on the toes of
+the other tests.
+
+The ``login`` fixture is defined inside the class as well, because not every one
+of the other tests in the module will be expecting a successful login, and the **act** may need to
+be handled a little differently for another test class. For example, if we
+wanted to write another test scenario around submitting bad credentials, we
+could handle it by adding something like this to the test file:
+
+.. note:
+
+    It's assumed that the page object for this (i.e. ``LoginPage``) raises a
+    custom exception, ``BadCredentialsException``, when it recognizes text
+    signifying that on the login form after attempting to log in.
+
+.. code-block:: python
+
+    class TestLandingPageBadCredentials:
+        @pytest.fixture(scope="class")
+        def faux_user(self, user):
+            _user = deepcopy(user)
+            _user.password = "badpass"
+            return _user
+
+        def test_raises_bad_credentials_exception(self, login_page, faux_user):
+            with pytest.raises(BadCredentialsException):
+                login_page.login(faux_user)
+
+
+.. _`request-context`:
+
+Fixtures can introspect the requesting test context
+-------------------------------------------------------------
+
+Fixture functions can accept the :py:class:`request <_pytest.fixtures.FixtureRequest>` object
+to introspect the "requesting" test function, class or module context.
+Further extending the previous ``smtp_connection`` fixture example, let's
+read an optional server URL from the test module which uses our fixture:
+
+.. code-block:: python
+
+    # content of conftest.py
+    import smtplib
+
+    import pytest
+
+
+    @pytest.fixture(scope="module")
+    def smtp_connection(request):
+        server = getattr(request.module, "smtpserver", "smtp.gmail.com")
+        smtp_connection = smtplib.SMTP(server, 587, timeout=5)
+        yield smtp_connection
+        print(f"finalizing {smtp_connection} ({server})")
+        smtp_connection.close()
+
+We use the ``request.module`` attribute to optionally obtain an
+``smtpserver`` attribute from the test module.  If we just execute
+again, nothing much has changed:
+
+.. code-block:: pytest
+
+    $ pytest -s -q --tb=no test_module.py
+    FFfinalizing <smtplib.SMTP object at 0xdeadbeef0002> (smtp.gmail.com)
+
+    ========================= short test summary info ==========================
+    FAILED test_module.py::test_ehlo - assert 0
+    FAILED test_module.py::test_noop - assert 0
+    2 failed in 0.12s
+
+Let's quickly create another test module that actually sets the
+server URL in its module namespace:
+
+.. code-block:: python
+
+    # content of test_anothersmtp.py
+
+    smtpserver = "mail.python.org"  # will be read by smtp fixture
+
+
+    def test_showhelo(smtp_connection):
+        assert 0, smtp_connection.helo()
+
+Running it:
+
+.. code-block:: pytest
+
+    $ pytest -qq --tb=short test_anothersmtp.py
+    F                                                                    [100%]
+    ================================= FAILURES =================================
+    ______________________________ test_showhelo _______________________________
+    test_anothersmtp.py:6: in test_showhelo
+        assert 0, smtp_connection.helo()
+    E   AssertionError: (250, b'mail.python.org')
+    E   assert 0
+    ------------------------- Captured stdout teardown -------------------------
+    finalizing <smtplib.SMTP object at 0xdeadbeef0003> (mail.python.org)
+    ========================= short test summary info ==========================
+    FAILED test_anothersmtp.py::test_showhelo - AssertionError: (250, b'mail....
+
+voila! The ``smtp_connection`` fixture function picked up our mail server name
+from the module namespace.
+
+.. _`using-markers`:
+
+Using markers to pass data to fixtures
+-------------------------------------------------------------
+
+Using the :py:class:`request <_pytest.fixtures.FixtureRequest>` object, a fixture can also access
+markers which are applied to a test function. This can be useful to pass data
+into a fixture from a test:
+
+.. code-block:: python
+
+    import pytest
+
+
+    @pytest.fixture
+    def fixt(request):
+        marker = request.node.get_closest_marker("fixt_data")
+        if marker is None:
+            # Handle missing marker in some way...
+            data = None
+        else:
+            data = marker.args[0]
+
+        # Do something with the data
+        return data
+
+
+    @pytest.mark.fixt_data(42)
+    def test_fixt(fixt):
+        assert fixt == 42
+
+.. _`fixture-factory`:
+
+Factories as fixtures
+-------------------------------------------------------------
+
+The "factory as fixture" pattern can help in situations where the result
+of a fixture is needed multiple times in a single test. Instead of returning
+data directly, the fixture instead returns a function which generates the data.
+This function can then be called multiple times in the test.
+
+Factories can have parameters as needed:
+
+.. code-block:: python
+
+    @pytest.fixture
+    def make_customer_record():
+        def _make_customer_record(name):
+            return {"name": name, "orders": []}
+
+        return _make_customer_record
+
+
+    def test_customer_records(make_customer_record):
+        customer_1 = make_customer_record("Lisa")
+        customer_2 = make_customer_record("Mike")
+        customer_3 = make_customer_record("Meredith")
+
+If the data created by the factory requires managing, the fixture can take care of that:
+
+.. code-block:: python
+
+    @pytest.fixture
+    def make_customer_record():
+        created_records = []
+
+        def _make_customer_record(name):
+            record = models.Customer(name=name, orders=[])
+            created_records.append(record)
+            return record
+
+        yield _make_customer_record
+
+        for record in created_records:
+            record.destroy()
+
+
+    def test_customer_records(make_customer_record):
+        customer_1 = make_customer_record("Lisa")
+        customer_2 = make_customer_record("Mike")
+        customer_3 = make_customer_record("Meredith")
+
+
+.. _`fixture-parametrize`:
+
+Parametrizing fixtures
+-----------------------------------------------------------------
+
+Fixture functions can be parametrized in which case they will be called
+multiple times, each time executing the set of dependent tests, i.e. the
+tests that depend on this fixture.  Test functions usually do not need
+to be aware of their re-running.  Fixture parametrization helps to
+write exhaustive functional tests for components which themselves can be
+configured in multiple ways.
+
+Extending the previous example, we can flag the fixture to create two
+``smtp_connection`` fixture instances which will cause all tests using the fixture
+to run twice.  The fixture function gets access to each parameter
+through the special :py:class:`request <FixtureRequest>` object:
+
+.. code-block:: python
+
+    # content of conftest.py
+    import smtplib
+
+    import pytest
+
+
+    @pytest.fixture(scope="module", params=["smtp.gmail.com", "mail.python.org"])
+    def smtp_connection(request):
+        smtp_connection = smtplib.SMTP(request.param, 587, timeout=5)
+        yield smtp_connection
+        print(f"finalizing {smtp_connection}")
+        smtp_connection.close()
+
+The main change is the declaration of ``params`` with
+:py:func:`@pytest.fixture <pytest.fixture>`, a list of values
+for each of which the fixture function will execute and can access
+a value via ``request.param``.  No test function code needs to change.
+So let's just do another run:
+
+.. code-block:: pytest
+
+    $ pytest -q test_module.py
+    FFFF                                                                 [100%]
+    ================================= FAILURES =================================
+    ________________________ test_ehlo[smtp.gmail.com] _________________________
+
+    smtp_connection = <smtplib.SMTP object at 0xdeadbeef0004>
+
+        def test_ehlo(smtp_connection):
+            response, msg = smtp_connection.ehlo()
+            assert response == 250
+            assert b"smtp.gmail.com" in msg
+    >       assert 0  # for demo purposes
+    E       assert 0
+
+    test_module.py:7: AssertionError
+    ________________________ test_noop[smtp.gmail.com] _________________________
+
+    smtp_connection = <smtplib.SMTP object at 0xdeadbeef0004>
+
+        def test_noop(smtp_connection):
+            response, msg = smtp_connection.noop()
+            assert response == 250
+    >       assert 0  # for demo purposes
+    E       assert 0
+
+    test_module.py:13: AssertionError
+    ________________________ test_ehlo[mail.python.org] ________________________
+
+    smtp_connection = <smtplib.SMTP object at 0xdeadbeef0005>
+
+        def test_ehlo(smtp_connection):
+            response, msg = smtp_connection.ehlo()
+            assert response == 250
+    >       assert b"smtp.gmail.com" in msg
+    E       AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8\nCHUNKING'
+
+    test_module.py:6: AssertionError
+    -------------------------- Captured stdout setup ---------------------------
+    finalizing <smtplib.SMTP object at 0xdeadbeef0004>
+    ________________________ test_noop[mail.python.org] ________________________
+
+    smtp_connection = <smtplib.SMTP object at 0xdeadbeef0005>
+
+        def test_noop(smtp_connection):
+            response, msg = smtp_connection.noop()
+            assert response == 250
+    >       assert 0  # for demo purposes
+    E       assert 0
+
+    test_module.py:13: AssertionError
+    ------------------------- Captured stdout teardown -------------------------
+    finalizing <smtplib.SMTP object at 0xdeadbeef0005>
+    ========================= short test summary info ==========================
+    FAILED test_module.py::test_ehlo[smtp.gmail.com] - assert 0
+    FAILED test_module.py::test_noop[smtp.gmail.com] - assert 0
+    FAILED test_module.py::test_ehlo[mail.python.org] - AssertionError: asser...
+    FAILED test_module.py::test_noop[mail.python.org] - assert 0
+    4 failed in 0.12s
+
+We see that our two test functions each ran twice, against the different
+``smtp_connection`` instances.  Note also, that with the ``mail.python.org``
+connection the second test fails in ``test_ehlo`` because a
+different server string is expected than what arrived.
+
+pytest will build a string that is the test ID for each fixture value
+in a parametrized fixture, e.g. ``test_ehlo[smtp.gmail.com]`` and
+``test_ehlo[mail.python.org]`` in the above examples.  These IDs can
+be used with ``-k`` to select specific cases to run, and they will
+also identify the specific case when one is failing.  Running pytest
+with ``--collect-only`` will show the generated IDs.
+
+Numbers, strings, booleans and ``None`` will have their usual string
+representation used in the test ID. For other objects, pytest will
+make a string based on the argument name.  It is possible to customise
+the string used in a test ID for a certain fixture value by using the
+``ids`` keyword argument:
+
+.. code-block:: python
+
+   # content of test_ids.py
+   import pytest
+
+
+   @pytest.fixture(params=[0, 1], ids=["spam", "ham"])
+   def a(request):
+       return request.param
+
+
+   def test_a(a):
+       pass
+
+
+   def idfn(fixture_value):
+       if fixture_value == 0:
+           return "eggs"
+       else:
+           return None
+
+
+   @pytest.fixture(params=[0, 1], ids=idfn)
+   def b(request):
+       return request.param
+
+
+   def test_b(b):
+       pass
+
+The above shows how ``ids`` can be either a list of strings to use or
+a function which will be called with the fixture value and then
+has to return a string to use.  In the latter case if the function
+returns ``None`` then pytest's auto-generated ID will be used.
+
+Running the above tests results in the following test IDs being used:
+
+.. code-block:: pytest
+
+   $ pytest --collect-only
+   =========================== test session starts ============================
+   platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+   rootdir: /home/sweet/project
+   collected 12 items
+
+   <Module test_anothersmtp.py>
+     <Function test_showhelo[smtp.gmail.com]>
+     <Function test_showhelo[mail.python.org]>
+   <Module test_emaillib.py>
+     <Function test_email_received>
+   <Module test_finalizers.py>
+     <Function test_bar>
+   <Module test_ids.py>
+     <Function test_a[spam]>
+     <Function test_a[ham]>
+     <Function test_b[eggs]>
+     <Function test_b[1]>
+   <Module test_module.py>
+     <Function test_ehlo[smtp.gmail.com]>
+     <Function test_noop[smtp.gmail.com]>
+     <Function test_ehlo[mail.python.org]>
+     <Function test_noop[mail.python.org]>
+
+   ======================= 12 tests collected in 0.12s ========================
+
+.. _`fixture-parametrize-marks`:
+
+Using marks with parametrized fixtures
+--------------------------------------
+
+:func:`pytest.param` can be used to apply marks in values sets of parametrized fixtures in the same way
+that they can be used with :ref:`@pytest.mark.parametrize <@pytest.mark.parametrize>`.
+
+Example:
+
+.. code-block:: python
+
+    # content of test_fixture_marks.py
+    import pytest
+
+
+    @pytest.fixture(params=[0, 1, pytest.param(2, marks=pytest.mark.skip)])
+    def data_set(request):
+        return request.param
+
+
+    def test_data(data_set):
+        pass
+
+Running this test will *skip* the invocation of ``data_set`` with value ``2``:
+
+.. code-block:: pytest
+
+    $ pytest test_fixture_marks.py -v
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
+    collecting ... collected 3 items
+
+    test_fixture_marks.py::test_data[0] PASSED                           [ 33%]
+    test_fixture_marks.py::test_data[1] PASSED                           [ 66%]
+    test_fixture_marks.py::test_data[2] SKIPPED (unconditional skip)     [100%]
+
+    ======================= 2 passed, 1 skipped in 0.12s =======================
+
+.. _`interdependent fixtures`:
+
+Modularity: using fixtures from a fixture function
+----------------------------------------------------------
+
+In addition to using fixtures in test functions, fixture functions
+can use other fixtures themselves.  This contributes to a modular design
+of your fixtures and allows re-use of framework-specific fixtures across
+many projects.  As a simple example, we can extend the previous example
+and instantiate an object ``app`` where we stick the already defined
+``smtp_connection`` resource into it:
+
+.. code-block:: python
+
+    # content of test_appsetup.py
+
+    import pytest
+
+
+    class App:
+        def __init__(self, smtp_connection):
+            self.smtp_connection = smtp_connection
+
+
+    @pytest.fixture(scope="module")
+    def app(smtp_connection):
+        return App(smtp_connection)
+
+
+    def test_smtp_connection_exists(app):
+        assert app.smtp_connection
+
+Here we declare an ``app`` fixture which receives the previously defined
+``smtp_connection`` fixture and instantiates an ``App`` object with it.  Let's run it:
+
+.. code-block:: pytest
+
+    $ pytest -v test_appsetup.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
+    collecting ... collected 2 items
+
+    test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%]
+    test_appsetup.py::test_smtp_connection_exists[mail.python.org] PASSED [100%]
+
+    ============================ 2 passed in 0.12s =============================
+
+Due to the parametrization of ``smtp_connection``, the test will run twice with two
+different ``App`` instances and respective smtp servers.  There is no
+need for the ``app`` fixture to be aware of the ``smtp_connection``
+parametrization because pytest will fully analyse the fixture dependency graph.
+
+Note that the ``app`` fixture has a scope of ``module`` and uses a
+module-scoped ``smtp_connection`` fixture.  The example would still work if
+``smtp_connection`` was cached on a ``session`` scope: it is fine for fixtures to use
+"broader" scoped fixtures but not the other way round:
+A session-scoped fixture could not use a module-scoped one in a
+meaningful way.
+
+
+.. _`automatic per-resource grouping`:
+
+Automatic grouping of tests by fixture instances
+----------------------------------------------------------
+
+.. regendoc: wipe
+
+pytest minimizes the number of active fixtures during test runs.
+If you have a parametrized fixture, then all the tests using it will
+first execute with one instance and then finalizers are called
+before the next fixture instance is created.  Among other things,
+this eases testing of applications which create and use global state.
+
+The following example uses two parametrized fixtures, one of which is
+scoped on a per-module basis, and all the functions perform ``print`` calls
+to show the setup/teardown flow:
+
+.. code-block:: python
+
+    # content of test_module.py
+    import pytest
+
+
+    @pytest.fixture(scope="module", params=["mod1", "mod2"])
+    def modarg(request):
+        param = request.param
+        print("  SETUP modarg", param)
+        yield param
+        print("  TEARDOWN modarg", param)
+
+
+    @pytest.fixture(scope="function", params=[1, 2])
+    def otherarg(request):
+        param = request.param
+        print("  SETUP otherarg", param)
+        yield param
+        print("  TEARDOWN otherarg", param)
+
+
+    def test_0(otherarg):
+        print("  RUN test0 with otherarg", otherarg)
+
+
+    def test_1(modarg):
+        print("  RUN test1 with modarg", modarg)
+
+
+    def test_2(otherarg, modarg):
+        print(f"  RUN test2 with otherarg {otherarg} and modarg {modarg}")
+
+
+Let's run the tests in verbose mode and with looking at the print-output:
+
+.. code-block:: pytest
+
+    $ pytest -v -s test_module.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
+    cachedir: .pytest_cache
+    rootdir: /home/sweet/project
+    collecting ... collected 8 items
+
+    test_module.py::test_0[1]   SETUP otherarg 1
+      RUN test0 with otherarg 1
+    PASSED  TEARDOWN otherarg 1
+
+    test_module.py::test_0[2]   SETUP otherarg 2
+      RUN test0 with otherarg 2
+    PASSED  TEARDOWN otherarg 2
+
+    test_module.py::test_1[mod1]   SETUP modarg mod1
+      RUN test1 with modarg mod1
+    PASSED
+    test_module.py::test_2[mod1-1]   SETUP otherarg 1
+      RUN test2 with otherarg 1 and modarg mod1
+    PASSED  TEARDOWN otherarg 1
+
+    test_module.py::test_2[mod1-2]   SETUP otherarg 2
+      RUN test2 with otherarg 2 and modarg mod1
+    PASSED  TEARDOWN otherarg 2
+
+    test_module.py::test_1[mod2]   TEARDOWN modarg mod1
+      SETUP modarg mod2
+      RUN test1 with modarg mod2
+    PASSED
+    test_module.py::test_2[mod2-1]   SETUP otherarg 1
+      RUN test2 with otherarg 1 and modarg mod2
+    PASSED  TEARDOWN otherarg 1
+
+    test_module.py::test_2[mod2-2]   SETUP otherarg 2
+      RUN test2 with otherarg 2 and modarg mod2
+    PASSED  TEARDOWN otherarg 2
+      TEARDOWN modarg mod2
+
+
+    ============================ 8 passed in 0.12s =============================
+
+You can see that the parametrized module-scoped ``modarg`` resource caused an
+ordering of test execution that lead to the fewest possible "active" resources.
+The finalizer for the ``mod1`` parametrized resource was executed before the
+``mod2`` resource was setup.
+
+In particular notice that test_0 is completely independent and finishes first.
+Then test_1 is executed with ``mod1``, then test_2 with ``mod1``, then test_1
+with ``mod2`` and finally test_2 with ``mod2``.
+
+The ``otherarg`` parametrized resource (having function scope) was set up before
+and teared down after every test that used it.
+
+
+.. _`usefixtures`:
+
+Use fixtures in classes and modules with ``usefixtures``
+--------------------------------------------------------
+
+.. regendoc:wipe
+
+Sometimes test functions do not directly need access to a fixture object.
+For example, tests may require to operate with an empty directory as the
+current working directory but otherwise do not care for the concrete
+directory.  Here is how you can use the standard :mod:`tempfile`
+and pytest fixtures to
+achieve it.  We separate the creation of the fixture into a :file:`conftest.py`
+file:
+
+.. code-block:: python
+
+    # content of conftest.py
+
+    import os
+    import tempfile
+
+    import pytest
+
+
+    @pytest.fixture
+    def cleandir():
+        with tempfile.TemporaryDirectory() as newpath:
+            old_cwd = os.getcwd()
+            os.chdir(newpath)
+            yield
+            os.chdir(old_cwd)
+
+and declare its use in a test module via a ``usefixtures`` marker:
+
+.. code-block:: python
+
+    # content of test_setenv.py
+    import os
+
+    import pytest
+
+
+    @pytest.mark.usefixtures("cleandir")
+    class TestDirectoryInit:
+        def test_cwd_starts_empty(self):
+            assert os.listdir(os.getcwd()) == []
+            with open("myfile", "w", encoding="utf-8") as f:
+                f.write("hello")
+
+        def test_cwd_again_starts_empty(self):
+            assert os.listdir(os.getcwd()) == []
+
+Due to the ``usefixtures`` marker, the ``cleandir`` fixture
+will be required for the execution of each test method, just as if
+you specified a "cleandir" function argument to each of them.  Let's run it
+to verify our fixture is activated and the tests pass:
+
+.. code-block:: pytest
+
+    $ pytest -q
+    ..                                                                   [100%]
+    2 passed in 0.12s
+
+You can specify multiple fixtures like this:
+
+.. code-block:: python
+
+    @pytest.mark.usefixtures("cleandir", "anotherfixture")
+    def test():
+        ...
+
+and you may specify fixture usage at the test module level using :globalvar:`pytestmark`:
+
+.. code-block:: python
+
+    pytestmark = pytest.mark.usefixtures("cleandir")
+
+
+It is also possible to put fixtures required by all tests in your project
+into an ini-file:
+
+.. code-block:: ini
+
+    # content of pytest.ini
+    [pytest]
+    usefixtures = cleandir
+
+
+.. warning::
+
+    Note this mark has no effect in **fixture functions**. For example,
+    this **will not work as expected**:
+
+    .. code-block:: python
+
+        @pytest.mark.usefixtures("my_other_fixture")
+        @pytest.fixture
+        def my_fixture_that_sadly_wont_use_my_other_fixture():
+            ...
+
+    Currently this will not generate any error or warning, but this is intended
+    to be handled by :issue:`3664`.
+
+.. _`override fixtures`:
+
+Overriding fixtures on various levels
+-------------------------------------
+
+In relatively large test suite, you most likely need to ``override`` a ``global`` or ``root`` fixture with a ``locally``
+defined one, keeping the test code readable and maintainable.
+
+Override a fixture on a folder (conftest) level
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Given the tests file structure is:
+
+::
+
+    tests/
+        conftest.py
+            # content of tests/conftest.py
+            import pytest
+
+            @pytest.fixture
+            def username():
+                return 'username'
+
+        test_something.py
+            # content of tests/test_something.py
+            def test_username(username):
+                assert username == 'username'
+
+        subfolder/
+            conftest.py
+                # content of tests/subfolder/conftest.py
+                import pytest
+
+                @pytest.fixture
+                def username(username):
+                    return 'overridden-' + username
+
+            test_something_else.py
+                # content of tests/subfolder/test_something_else.py
+                def test_username(username):
+                    assert username == 'overridden-username'
+
+As you can see, a fixture with the same name can be overridden for certain test folder level.
+Note that the ``base`` or ``super`` fixture can be accessed from the ``overriding``
+fixture easily - used in the example above.
+
+Override a fixture on a test module level
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Given the tests file structure is:
+
+::
+
+    tests/
+        conftest.py
+            # content of tests/conftest.py
+            import pytest
+
+            @pytest.fixture
+            def username():
+                return 'username'
+
+        test_something.py
+            # content of tests/test_something.py
+            import pytest
+
+            @pytest.fixture
+            def username(username):
+                return 'overridden-' + username
+
+            def test_username(username):
+                assert username == 'overridden-username'
+
+        test_something_else.py
+            # content of tests/test_something_else.py
+            import pytest
+
+            @pytest.fixture
+            def username(username):
+                return 'overridden-else-' + username
+
+            def test_username(username):
+                assert username == 'overridden-else-username'
+
+In the example above, a fixture with the same name can be overridden for certain test module.
+
+
+Override a fixture with direct test parametrization
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Given the tests file structure is:
+
+::
+
+    tests/
+        conftest.py
+            # content of tests/conftest.py
+            import pytest
+
+            @pytest.fixture
+            def username():
+                return 'username'
+
+            @pytest.fixture
+            def other_username(username):
+                return 'other-' + username
+
+        test_something.py
+            # content of tests/test_something.py
+            import pytest
+
+            @pytest.mark.parametrize('username', ['directly-overridden-username'])
+            def test_username(username):
+                assert username == 'directly-overridden-username'
+
+            @pytest.mark.parametrize('username', ['directly-overridden-username-other'])
+            def test_username_other(other_username):
+                assert other_username == 'other-directly-overridden-username-other'
+
+In the example above, a fixture value is overridden by the test parameter value. Note that the value of the fixture
+can be overridden this way even if the test doesn't use it directly (doesn't mention it in the function prototype).
+
+
+Override a parametrized fixture with non-parametrized one and vice versa
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Given the tests file structure is:
+
+::
+
+    tests/
+        conftest.py
+            # content of tests/conftest.py
+            import pytest
+
+            @pytest.fixture(params=['one', 'two', 'three'])
+            def parametrized_username(request):
+                return request.param
+
+            @pytest.fixture
+            def non_parametrized_username(request):
+                return 'username'
+
+        test_something.py
+            # content of tests/test_something.py
+            import pytest
+
+            @pytest.fixture
+            def parametrized_username():
+                return 'overridden-username'
+
+            @pytest.fixture(params=['one', 'two', 'three'])
+            def non_parametrized_username(request):
+                return request.param
+
+            def test_username(parametrized_username):
+                assert parametrized_username == 'overridden-username'
+
+            def test_parametrized_username(non_parametrized_username):
+                assert non_parametrized_username in ['one', 'two', 'three']
+
+        test_something_else.py
+            # content of tests/test_something_else.py
+            def test_username(parametrized_username):
+                assert parametrized_username in ['one', 'two', 'three']
+
+            def test_username(non_parametrized_username):
+                assert non_parametrized_username == 'username'
+
+In the example above, a parametrized fixture is overridden with a non-parametrized version, and
+a non-parametrized fixture is overridden with a parametrized version for certain test module.
+The same applies for the test folder level obviously.
+
+
+Using fixtures from other projects
+----------------------------------
+
+Usually projects that provide pytest support will use :ref:`entry points <setuptools entry points>`,
+so just installing those projects into an environment will make those fixtures available for use.
+
+In case you want to use fixtures from a project that does not use entry points, you can
+define :globalvar:`pytest_plugins` in your top ``conftest.py`` file to register that module
+as a plugin.
+
+Suppose you have some fixtures in ``mylibrary.fixtures`` and you want to reuse them into your
+``app/tests`` directory.
+
+All you need to do is to define :globalvar:`pytest_plugins` in ``app/tests/conftest.py``
+pointing to that module.
+
+.. code-block:: python
+
+    pytest_plugins = "mylibrary.fixtures"
+
+This effectively registers ``mylibrary.fixtures`` as a plugin, making all its fixtures and
+hooks available to tests in ``app/tests``.
+
+.. note::
+
+    Sometimes users will *import* fixtures from other projects for use, however this is not
+    recommended: importing fixtures into a module will register them in pytest
+    as *defined* in that module.
+
+    This has minor consequences, such as appearing multiple times in ``pytest --help``,
+    but it is not **recommended** because this behavior might change/stop working
+    in future versions.
diff --git a/doc/en/how-to/index.rst b/doc/en/how-to/index.rst
new file mode 100644 (file)
index 0000000..6f52aae
--- /dev/null
@@ -0,0 +1,64 @@
+:orphan:
+
+.. _how-to:
+
+How-to guides
+================
+
+Core pytest functionality
+-------------------------
+
+.. toctree::
+   :maxdepth: 1
+
+   usage
+   assert
+   fixtures
+   mark
+   parametrize
+   tmp_path
+   monkeypatch
+   doctest
+   cache
+
+Test output and outcomes
+----------------------------
+
+.. toctree::
+   :maxdepth: 1
+
+   failures
+   output
+   logging
+   capture-stdout-stderr
+   capture-warnings
+   skipping
+
+Plugins
+----------------------------
+
+.. toctree::
+   :maxdepth: 1
+
+   plugins
+   writing_plugins
+   writing_hook_functions
+
+pytest and other test systems
+-----------------------------
+
+.. toctree::
+   :maxdepth: 1
+
+   existingtestsuite
+   unittest
+   nose
+   xunit_setup
+
+pytest development environment
+------------------------------
+
+.. toctree::
+   :maxdepth: 1
+
+   bash-completion
diff --git a/doc/en/how-to/logging.rst b/doc/en/how-to/logging.rst
new file mode 100644 (file)
index 0000000..9957a9b
--- /dev/null
@@ -0,0 +1,296 @@
+.. _logging:
+
+How to manage logging
+---------------------
+
+pytest captures log messages of level ``WARNING`` or above automatically and displays them in their own section
+for each failed test in the same manner as captured stdout and stderr.
+
+Running without options:
+
+.. code-block:: bash
+
+    pytest
+
+Shows failed tests like so:
+
+.. code-block:: pytest
+
+    ----------------------- Captured stdlog call ----------------------
+    test_reporting.py    26 WARNING  text going to logger
+    ----------------------- Captured stdout call ----------------------
+    text going to stdout
+    ----------------------- Captured stderr call ----------------------
+    text going to stderr
+    ==================== 2 failed in 0.02 seconds =====================
+
+By default each captured log message shows the module, line number, log level
+and message.
+
+If desired the log and date format can be specified to
+anything that the logging module supports by passing specific formatting options:
+
+.. code-block:: bash
+
+    pytest --log-format="%(asctime)s %(levelname)s %(message)s" \
+            --log-date-format="%Y-%m-%d %H:%M:%S"
+
+Shows failed tests like so:
+
+.. code-block:: pytest
+
+    ----------------------- Captured stdlog call ----------------------
+    2010-04-10 14:48:44 WARNING text going to logger
+    ----------------------- Captured stdout call ----------------------
+    text going to stdout
+    ----------------------- Captured stderr call ----------------------
+    text going to stderr
+    ==================== 2 failed in 0.02 seconds =====================
+
+These options can also be customized through ``pytest.ini`` file:
+
+.. code-block:: ini
+
+    [pytest]
+    log_format = %(asctime)s %(levelname)s %(message)s
+    log_date_format = %Y-%m-%d %H:%M:%S
+
+Specific loggers can be disabled via ``--log-disable={logger_name}``.
+This argument can be passed multiple times:
+
+.. code-block:: bash
+
+    pytest --log-disable=main --log-disable=testing
+
+Further it is possible to disable reporting of captured content (stdout,
+stderr and logs) on failed tests completely with:
+
+.. code-block:: bash
+
+    pytest --show-capture=no
+
+
+caplog fixture
+^^^^^^^^^^^^^^
+
+Inside tests it is possible to change the log level for the captured log
+messages.  This is supported by the ``caplog`` fixture:
+
+.. code-block:: python
+
+    def test_foo(caplog):
+        caplog.set_level(logging.INFO)
+
+By default the level is set on the root logger,
+however as a convenience it is also possible to set the log level of any
+logger:
+
+.. code-block:: python
+
+    def test_foo(caplog):
+        caplog.set_level(logging.CRITICAL, logger="root.baz")
+
+The log levels set are restored automatically at the end of the test.
+
+It is also possible to use a context manager to temporarily change the log
+level inside a ``with`` block:
+
+.. code-block:: python
+
+    def test_bar(caplog):
+        with caplog.at_level(logging.INFO):
+            pass
+
+Again, by default the level of the root logger is affected but the level of any
+logger can be changed instead with:
+
+.. code-block:: python
+
+    def test_bar(caplog):
+        with caplog.at_level(logging.CRITICAL, logger="root.baz"):
+            pass
+
+Lastly all the logs sent to the logger during the test run are made available on
+the fixture in the form of both the ``logging.LogRecord`` instances and the final log text.
+This is useful for when you want to assert on the contents of a message:
+
+.. code-block:: python
+
+    def test_baz(caplog):
+        func_under_test()
+        for record in caplog.records:
+            assert record.levelname != "CRITICAL"
+        assert "wally" not in caplog.text
+
+For all the available attributes of the log records see the
+``logging.LogRecord`` class.
+
+You can also resort to ``record_tuples`` if all you want to do is to ensure,
+that certain messages have been logged under a given logger name with a given
+severity and message:
+
+.. code-block:: python
+
+    def test_foo(caplog):
+        logging.getLogger().info("boo %s", "arg")
+
+        assert caplog.record_tuples == [("root", logging.INFO, "boo arg")]
+
+You can call ``caplog.clear()`` to reset the captured log records in a test:
+
+.. code-block:: python
+
+    def test_something_with_clearing_records(caplog):
+        some_method_that_creates_log_records()
+        caplog.clear()
+        your_test_method()
+        assert ["Foo"] == [rec.message for rec in caplog.records]
+
+
+The ``caplog.records`` attribute contains records from the current stage only, so
+inside the ``setup`` phase it contains only setup logs, same with the ``call`` and
+``teardown`` phases.
+
+To access logs from other stages, use the ``caplog.get_records(when)`` method. As an example,
+if you want to make sure that tests which use a certain fixture never log any warnings, you can inspect
+the records for the ``setup`` and ``call`` stages during teardown like so:
+
+.. code-block:: python
+
+    @pytest.fixture
+    def window(caplog):
+        window = create_window()
+        yield window
+        for when in ("setup", "call"):
+            messages = [
+                x.message for x in caplog.get_records(when) if x.levelno == logging.WARNING
+            ]
+            if messages:
+                pytest.fail(f"warning messages encountered during testing: {messages}")
+
+
+
+The full API is available at :class:`pytest.LogCaptureFixture`.
+
+
+.. _live_logs:
+
+Live Logs
+^^^^^^^^^
+
+By setting the :confval:`log_cli` configuration option to ``true``, pytest will output
+logging records as they are emitted directly into the console.
+
+You can specify the logging level for which log records with equal or higher
+level are printed to the console by passing ``--log-cli-level``. This setting
+accepts the logging level names or numeric values as seen in
+:ref:`logging's documentation <python:levels>`.
+
+Additionally, you can also specify ``--log-cli-format`` and
+``--log-cli-date-format`` which mirror and default to ``--log-format`` and
+``--log-date-format`` if not provided, but are applied only to the console
+logging handler.
+
+All of the CLI log options can also be set in the configuration INI file. The
+option names are:
+
+* ``log_cli_level``
+* ``log_cli_format``
+* ``log_cli_date_format``
+
+If you need to record the whole test suite logging calls to a file, you can pass
+``--log-file=/path/to/log/file``. This log file is opened in write mode which
+means that it will be overwritten at each run tests session.
+Note that relative paths for the log-file location, whether passed on the CLI or declared in a
+config file, are always resolved relative to the current working directory.
+
+You can also specify the logging level for the log file by passing
+``--log-file-level``. This setting accepts the logging level names or numeric
+values as seen in :ref:`logging's documentation <python:levels>`.
+
+Additionally, you can also specify ``--log-file-format`` and
+``--log-file-date-format`` which are equal to ``--log-format`` and
+``--log-date-format`` but are applied to the log file logging handler.
+
+All of the log file options can also be set in the configuration INI file. The
+option names are:
+
+* ``log_file``
+* ``log_file_level``
+* ``log_file_format``
+* ``log_file_date_format``
+
+You can call ``set_log_path()`` to customize the log_file path dynamically. This functionality
+is considered **experimental**.
+
+.. _log_colors:
+
+Customizing Colors
+^^^^^^^^^^^^^^^^^^
+
+Log levels are colored if colored terminal output is enabled. Changing
+from default colors or putting color on custom log levels is supported
+through ``add_color_level()``. Example:
+
+.. code-block:: python
+
+    @pytest.hookimpl
+    def pytest_configure(config):
+        logging_plugin = config.pluginmanager.get_plugin("logging-plugin")
+
+        # Change color on existing log level
+        logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, "cyan")
+
+        # Add color to a custom log level (a custom log level `SPAM` is already set up)
+        logging_plugin.log_cli_handler.formatter.add_color_level(logging.SPAM, "blue")
+.. warning::
+
+    This feature and its API are considered **experimental** and might change
+    between releases without a deprecation notice.
+.. _log_release_notes:
+
+Release notes
+^^^^^^^^^^^^^
+
+This feature was introduced as a drop-in replacement for the
+:pypi:`pytest-catchlog` plugin and they conflict
+with each other. The backward compatibility API with ``pytest-capturelog``
+has been dropped when this feature was introduced, so if for that reason you
+still need ``pytest-catchlog`` you can disable the internal feature by
+adding to your ``pytest.ini``:
+
+.. code-block:: ini
+
+   [pytest]
+       addopts=-p no:logging
+
+
+.. _log_changes_3_4:
+
+Incompatible changes in pytest 3.4
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+This feature was introduced in ``3.3`` and some **incompatible changes** have been
+made in ``3.4`` after community feedback:
+
+* Log levels are no longer changed unless explicitly requested by the :confval:`log_level` configuration
+  or ``--log-level`` command-line options. This allows users to configure logger objects themselves.
+  Setting :confval:`log_level` will set the level that is captured globally so if a specific test requires
+  a lower level than this, use the ``caplog.set_level()`` functionality otherwise that test will be prone to
+  failure.
+* :ref:`Live Logs <live_logs>` is now disabled by default and can be enabled setting the
+  :confval:`log_cli` configuration option to ``true``. When enabled, the verbosity is increased so logging for each
+  test is visible.
+* :ref:`Live Logs <live_logs>` are now sent to ``sys.stdout`` and no longer require the ``-s`` command-line option
+  to work.
+
+If you want to partially restore the logging behavior of version ``3.3``, you can add this options to your ``ini``
+file:
+
+.. code-block:: ini
+
+    [pytest]
+    log_cli=true
+    log_level=NOTSET
+
+More details about the discussion that lead to this changes can be read in :issue:`3013`.
diff --git a/doc/en/how-to/mark.rst b/doc/en/how-to/mark.rst
new file mode 100644 (file)
index 0000000..33f9d18
--- /dev/null
@@ -0,0 +1,93 @@
+.. _mark:
+
+How to mark test functions with attributes
+===========================================
+
+By using the ``pytest.mark`` helper you can easily set
+metadata on your test functions. You can find the full list of builtin markers
+in the :ref:`API Reference<marks ref>`. Or you can list all the markers, including
+builtin and custom, using the CLI - :code:`pytest --markers`.
+
+Here are some of the builtin markers:
+
+* :ref:`usefixtures <usefixtures>` - use fixtures on a test function or class
+* :ref:`filterwarnings <filterwarnings>` - filter certain warnings of a test function
+* :ref:`skip <skip>` - always skip a test function
+* :ref:`skipif <skipif>` - skip a test function if a certain condition is met
+* :ref:`xfail <xfail>` - produce an "expected failure" outcome if a certain
+  condition is met
+* :ref:`parametrize <parametrizemark>` - perform multiple calls
+  to the same test function.
+
+It's easy to create custom markers or to apply markers
+to whole test classes or modules. Those markers can be used by plugins, and also
+are commonly used to :ref:`select tests <mark run>` on the command-line with the ``-m`` option.
+
+See :ref:`mark examples` for examples which also serve as documentation.
+
+.. note::
+
+    Marks can only be applied to tests, having no effect on
+    :ref:`fixtures <fixtures>`.
+
+
+Registering marks
+-----------------
+
+You can register custom marks in your ``pytest.ini`` file like this:
+
+.. code-block:: ini
+
+    [pytest]
+    markers =
+        slow: marks tests as slow (deselect with '-m "not slow"')
+        serial
+
+or in your ``pyproject.toml`` file like this:
+
+.. code-block:: toml
+
+    [tool.pytest.ini_options]
+    markers = [
+        "slow: marks tests as slow (deselect with '-m \"not slow\"')",
+        "serial",
+    ]
+
+Note that everything past the ``:`` after the mark name is an optional description.
+
+Alternatively, you can register new markers programmatically in a
+:ref:`pytest_configure <initialization-hooks>` hook:
+
+.. code-block:: python
+
+    def pytest_configure(config):
+        config.addinivalue_line(
+            "markers", "env(name): mark test to run only on named environment"
+        )
+
+
+Registered marks appear in pytest's help text and do not emit warnings (see the next section). It
+is recommended that third-party plugins always :ref:`register their markers <registering-markers>`.
+
+.. _unknown-marks:
+
+Raising errors on unknown marks
+-------------------------------
+
+Unregistered marks applied with the ``@pytest.mark.name_of_the_mark`` decorator
+will always emit a warning in order to avoid silently doing something
+surprising due to mistyped names. As described in the previous section, you can disable
+the warning for custom marks by registering them in your ``pytest.ini`` file or
+using a custom ``pytest_configure`` hook.
+
+When the ``--strict-markers`` command-line flag is passed, any unknown marks applied
+with the ``@pytest.mark.name_of_the_mark`` decorator will trigger an error. You can
+enforce this validation in your project by adding ``--strict-markers`` to ``addopts``:
+
+.. code-block:: ini
+
+    [pytest]
+    addopts = --strict-markers
+    markers =
+        slow: marks tests as slow (deselect with '-m "not slow"')
+        serial
diff --git a/doc/en/how-to/monkeypatch.rst b/doc/en/how-to/monkeypatch.rst
new file mode 100644 (file)
index 0000000..a9504dc
--- /dev/null
@@ -0,0 +1,443 @@
+.. _monkeypatching:
+
+How to monkeypatch/mock modules and environments
+================================================================
+
+.. currentmodule:: pytest
+
+Sometimes tests need to invoke functionality which depends
+on global settings or which invokes code which cannot be easily
+tested such as network access.  The ``monkeypatch`` fixture
+helps you to safely set/delete an attribute, dictionary item or
+environment variable, or to modify ``sys.path`` for importing.
+
+The ``monkeypatch`` fixture provides these helper methods for safely patching and mocking
+functionality in tests:
+
+* :meth:`monkeypatch.setattr(obj, name, value, raising=True) <pytest.MonkeyPatch.setattr>`
+* :meth:`monkeypatch.delattr(obj, name, raising=True) <pytest.MonkeyPatch.delattr>`
+* :meth:`monkeypatch.setitem(mapping, name, value) <pytest.MonkeyPatch.setitem>`
+* :meth:`monkeypatch.delitem(obj, name, raising=True) <pytest.MonkeyPatch.delitem>`
+* :meth:`monkeypatch.setenv(name, value, prepend=None) <pytest.MonkeyPatch.setenv>`
+* :meth:`monkeypatch.delenv(name, raising=True) <pytest.MonkeyPatch.delenv>`
+* :meth:`monkeypatch.syspath_prepend(path) <pytest.MonkeyPatch.syspath_prepend>`
+* :meth:`monkeypatch.chdir(path) <pytest.MonkeyPatch.chdir>`
+* :meth:`monkeypatch.context() <pytest.MonkeyPatch.context>`
+
+
+All modifications will be undone after the requesting
+test function or fixture has finished. The ``raising``
+parameter determines if a ``KeyError`` or ``AttributeError``
+will be raised if the target of the set/deletion operation does not exist.
+
+Consider the following scenarios:
+
+1. Modifying the behavior of a function or the property of a class for a test e.g.
+there is an API call or database connection you will not make for a test but you know
+what the expected output should be. Use :py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` to patch the
+function or property with your desired testing behavior. This can include your own functions.
+Use :py:meth:`monkeypatch.delattr <MonkeyPatch.delattr>` to remove the function or property for the test.
+
+2. Modifying the values of dictionaries e.g. you have a global configuration that
+you want to modify for certain test cases. Use :py:meth:`monkeypatch.setitem <MonkeyPatch.setitem>` to patch the
+dictionary for the test. :py:meth:`monkeypatch.delitem <MonkeyPatch.delitem>` can be used to remove items.
+
+3. Modifying environment variables for a test e.g. to test program behavior if an
+environment variable is missing, or to set multiple values to a known variable.
+:py:meth:`monkeypatch.setenv <MonkeyPatch.setenv>` and :py:meth:`monkeypatch.delenv <MonkeyPatch.delenv>` can be used for
+these patches.
+
+4. Use ``monkeypatch.setenv("PATH", value, prepend=os.pathsep)`` to modify ``$PATH``, and
+:py:meth:`monkeypatch.chdir <MonkeyPatch.chdir>` to change the context of the current working directory
+during a test.
+
+5. Use :py:meth:`monkeypatch.syspath_prepend <MonkeyPatch.syspath_prepend>` to modify ``sys.path`` which will also
+call ``pkg_resources.fixup_namespace_packages`` and :py:func:`importlib.invalidate_caches`.
+
+6. Use :py:meth:`monkeypatch.context <MonkeyPatch.context>` to apply patches only in a specific scope, which can help
+control teardown of complex fixtures or patches to the stdlib.
+
+See the `monkeypatch blog post`_ for some introduction material
+and a discussion of its motivation.
+
+.. _`monkeypatch blog post`: https://tetamap.wordpress.com//2009/03/03/monkeypatching-in-unit-tests-done-right/
+
+Monkeypatching functions
+------------------------
+
+Consider a scenario where you are working with user directories. In the context of
+testing, you do not want your test to depend on the running user. ``monkeypatch``
+can be used to patch functions dependent on the user to always return a
+specific value.
+
+In this example, :py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` is used to patch ``Path.home``
+so that the known testing path ``Path("/abc")`` is always used when the test is run.
+This removes any dependency on the running user for testing purposes.
+:py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` must be called before the function which will use
+the patched function is called.
+After the test function finishes the ``Path.home`` modification will be undone.
+
+.. code-block:: python
+
+    # contents of test_module.py with source code and the test
+    from pathlib import Path
+
+
+    def getssh():
+        """Simple function to return expanded homedir ssh path."""
+        return Path.home() / ".ssh"
+
+
+    def test_getssh(monkeypatch):
+        # mocked return function to replace Path.home
+        # always return '/abc'
+        def mockreturn():
+            return Path("/abc")
+
+        # Application of the monkeypatch to replace Path.home
+        # with the behavior of mockreturn defined above.
+        monkeypatch.setattr(Path, "home", mockreturn)
+
+        # Calling getssh() will use mockreturn in place of Path.home
+        # for this test with the monkeypatch.
+        x = getssh()
+        assert x == Path("/abc/.ssh")
+
+Monkeypatching returned objects: building mock classes
+------------------------------------------------------
+
+:py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` can be used in conjunction with classes to mock returned
+objects from functions instead of values.
+Imagine a simple function to take an API url and return the json response.
+
+.. code-block:: python
+
+    # contents of app.py, a simple API retrieval example
+    import requests
+
+
+    def get_json(url):
+        """Takes a URL, and returns the JSON."""
+        r = requests.get(url)
+        return r.json()
+
+We need to mock ``r``, the returned response object for testing purposes.
+The mock of ``r`` needs a ``.json()`` method which returns a dictionary.
+This can be done in our test file by defining a class to represent ``r``.
+
+.. code-block:: python
+
+    # contents of test_app.py, a simple test for our API retrieval
+    # import requests for the purposes of monkeypatching
+    import requests
+
+    # our app.py that includes the get_json() function
+    # this is the previous code block example
+    import app
+
+
+    # custom class to be the mock return value
+    # will override the requests.Response returned from requests.get
+    class MockResponse:
+        # mock json() method always returns a specific testing dictionary
+        @staticmethod
+        def json():
+            return {"mock_key": "mock_response"}
+
+
+    def test_get_json(monkeypatch):
+        # Any arguments may be passed and mock_get() will always return our
+        # mocked object, which only has the .json() method.
+        def mock_get(*args, **kwargs):
+            return MockResponse()
+
+        # apply the monkeypatch for requests.get to mock_get
+        monkeypatch.setattr(requests, "get", mock_get)
+
+        # app.get_json, which contains requests.get, uses the monkeypatch
+        result = app.get_json("https://fakeurl")
+        assert result["mock_key"] == "mock_response"
+
+
+``monkeypatch`` applies the mock for ``requests.get`` with our ``mock_get`` function.
+The ``mock_get`` function returns an instance of the ``MockResponse`` class, which
+has a ``json()`` method defined to return a known testing dictionary and does not
+require any outside API connection.
+
+You can build the ``MockResponse`` class with the appropriate degree of complexity for
+the scenario you are testing. For instance, it could include an ``ok`` property that
+always returns ``True``, or return different values from the ``json()`` mocked method
+based on input strings.
+
+This mock can be shared across tests using a ``fixture``:
+
+.. code-block:: python
+
+    # contents of test_app.py, a simple test for our API retrieval
+    import pytest
+    import requests
+
+    # app.py that includes the get_json() function
+    import app
+
+
+    # custom class to be the mock return value of requests.get()
+    class MockResponse:
+        @staticmethod
+        def json():
+            return {"mock_key": "mock_response"}
+
+
+    # monkeypatched requests.get moved to a fixture
+    @pytest.fixture
+    def mock_response(monkeypatch):
+        """Requests.get() mocked to return {'mock_key':'mock_response'}."""
+
+        def mock_get(*args, **kwargs):
+            return MockResponse()
+
+        monkeypatch.setattr(requests, "get", mock_get)
+
+
+    # notice our test uses the custom fixture instead of monkeypatch directly
+    def test_get_json(mock_response):
+        result = app.get_json("https://fakeurl")
+        assert result["mock_key"] == "mock_response"
+
+
+Furthermore, if the mock was designed to be applied to all tests, the ``fixture`` could
+be moved to a ``conftest.py`` file and use the with ``autouse=True`` option.
+
+
+Global patch example: preventing "requests" from remote operations
+------------------------------------------------------------------
+
+If you want to prevent the "requests" library from performing http
+requests in all your tests, you can do:
+
+.. code-block:: python
+
+    # contents of conftest.py
+    import pytest
+
+
+    @pytest.fixture(autouse=True)
+    def no_requests(monkeypatch):
+        """Remove requests.sessions.Session.request for all tests."""
+        monkeypatch.delattr("requests.sessions.Session.request")
+
+This autouse fixture will be executed for each test function and it
+will delete the method ``request.session.Session.request``
+so that any attempts within tests to create http requests will fail.
+
+
+.. note::
+
+    Be advised that it is not recommended to patch builtin functions such as ``open``,
+    ``compile``, etc., because it might break pytest's internals. If that's
+    unavoidable, passing ``--tb=native``, ``--assert=plain`` and ``--capture=no`` might
+    help although there's no guarantee.
+
+.. note::
+
+    Mind that patching ``stdlib`` functions and some third-party libraries used by pytest
+    might break pytest itself, therefore in those cases it is recommended to use
+    :meth:`MonkeyPatch.context` to limit the patching to the block you want tested:
+
+    .. code-block:: python
+
+        import functools
+
+
+        def test_partial(monkeypatch):
+            with monkeypatch.context() as m:
+                m.setattr(functools, "partial", 3)
+                assert functools.partial == 3
+
+    See :issue:`3290` for details.
+
+
+Monkeypatching environment variables
+------------------------------------
+
+If you are working with environment variables you often need to safely change the values
+or delete them from the system for testing purposes. ``monkeypatch`` provides a mechanism
+to do this using the ``setenv`` and ``delenv`` method. Our example code to test:
+
+.. code-block:: python
+
+    # contents of our original code file e.g. code.py
+    import os
+
+
+    def get_os_user_lower():
+        """Simple retrieval function.
+        Returns lowercase USER or raises OSError."""
+        username = os.getenv("USER")
+
+        if username is None:
+            raise OSError("USER environment is not set.")
+
+        return username.lower()
+
+There are two potential paths. First, the ``USER`` environment variable is set to a
+value. Second, the ``USER`` environment variable does not exist. Using ``monkeypatch``
+both paths can be safely tested without impacting the running environment:
+
+.. code-block:: python
+
+    # contents of our test file e.g. test_code.py
+    import pytest
+
+
+    def test_upper_to_lower(monkeypatch):
+        """Set the USER env var to assert the behavior."""
+        monkeypatch.setenv("USER", "TestingUser")
+        assert get_os_user_lower() == "testinguser"
+
+
+    def test_raise_exception(monkeypatch):
+        """Remove the USER env var and assert OSError is raised."""
+        monkeypatch.delenv("USER", raising=False)
+
+        with pytest.raises(OSError):
+            _ = get_os_user_lower()
+
+This behavior can be moved into ``fixture`` structures and shared across tests:
+
+.. code-block:: python
+
+    # contents of our test file e.g. test_code.py
+    import pytest
+
+
+    @pytest.fixture
+    def mock_env_user(monkeypatch):
+        monkeypatch.setenv("USER", "TestingUser")
+
+
+    @pytest.fixture
+    def mock_env_missing(monkeypatch):
+        monkeypatch.delenv("USER", raising=False)
+
+
+    # notice the tests reference the fixtures for mocks
+    def test_upper_to_lower(mock_env_user):
+        assert get_os_user_lower() == "testinguser"
+
+
+    def test_raise_exception(mock_env_missing):
+        with pytest.raises(OSError):
+            _ = get_os_user_lower()
+
+
+Monkeypatching dictionaries
+---------------------------
+
+:py:meth:`monkeypatch.setitem <MonkeyPatch.setitem>` can be used to safely set the values of dictionaries
+to specific values during tests. Take this simplified connection string example:
+
+.. code-block:: python
+
+    # contents of app.py to generate a simple connection string
+    DEFAULT_CONFIG = {"user": "user1", "database": "db1"}
+
+
+    def create_connection_string(config=None):
+        """Creates a connection string from input or defaults."""
+        config = config or DEFAULT_CONFIG
+        return f"User Id={config['user']}; Location={config['database']};"
+
+For testing purposes we can patch the ``DEFAULT_CONFIG`` dictionary to specific values.
+
+.. code-block:: python
+
+    # contents of test_app.py
+    # app.py with the connection string function (prior code block)
+    import app
+
+
+    def test_connection(monkeypatch):
+        # Patch the values of DEFAULT_CONFIG to specific
+        # testing values only for this test.
+        monkeypatch.setitem(app.DEFAULT_CONFIG, "user", "test_user")
+        monkeypatch.setitem(app.DEFAULT_CONFIG, "database", "test_db")
+
+        # expected result based on the mocks
+        expected = "User Id=test_user; Location=test_db;"
+
+        # the test uses the monkeypatched dictionary settings
+        result = app.create_connection_string()
+        assert result == expected
+
+You can use the :py:meth:`monkeypatch.delitem <MonkeyPatch.delitem>` to remove values.
+
+.. code-block:: python
+
+    # contents of test_app.py
+    import pytest
+
+    # app.py with the connection string function
+    import app
+
+
+    def test_missing_user(monkeypatch):
+        # patch the DEFAULT_CONFIG t be missing the 'user' key
+        monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
+
+        # Key error expected because a config is not passed, and the
+        # default is now missing the 'user' entry.
+        with pytest.raises(KeyError):
+            _ = app.create_connection_string()
+
+
+The modularity of fixtures gives you the flexibility to define
+separate fixtures for each potential mock and reference them in the needed tests.
+
+.. code-block:: python
+
+    # contents of test_app.py
+    import pytest
+
+    # app.py with the connection string function
+    import app
+
+
+    # all of the mocks are moved into separated fixtures
+    @pytest.fixture
+    def mock_test_user(monkeypatch):
+        """Set the DEFAULT_CONFIG user to test_user."""
+        monkeypatch.setitem(app.DEFAULT_CONFIG, "user", "test_user")
+
+
+    @pytest.fixture
+    def mock_test_database(monkeypatch):
+        """Set the DEFAULT_CONFIG database to test_db."""
+        monkeypatch.setitem(app.DEFAULT_CONFIG, "database", "test_db")
+
+
+    @pytest.fixture
+    def mock_missing_default_user(monkeypatch):
+        """Remove the user key from DEFAULT_CONFIG"""
+        monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
+
+
+    # tests reference only the fixture mocks that are needed
+    def test_connection(mock_test_user, mock_test_database):
+        expected = "User Id=test_user; Location=test_db;"
+
+        result = app.create_connection_string()
+        assert result == expected
+
+
+    def test_missing_user(mock_missing_default_user):
+        with pytest.raises(KeyError):
+            _ = app.create_connection_string()
+
+
+.. currentmodule:: pytest
+
+API Reference
+-------------
+
+Consult the docs for the :class:`MonkeyPatch` class.
diff --git a/doc/en/how-to/nose.rst b/doc/en/how-to/nose.rst
new file mode 100644 (file)
index 0000000..a736dfa
--- /dev/null
@@ -0,0 +1,82 @@
+.. _`noseintegration`:
+
+How to run tests written for nose
+=======================================
+
+``pytest`` has basic support for running tests written for nose_.
+
+.. warning::
+    This functionality has been deprecated and is likely to be removed in ``pytest 8.x``.
+
+.. _nosestyle:
+
+Usage
+-------------
+
+After :ref:`installation` type:
+
+.. code-block:: bash
+
+    python setup.py develop  # make sure tests can import our package
+    pytest  # instead of 'nosetests'
+
+and you should be able to run your nose style tests and
+make use of pytest's capabilities.
+
+Supported nose Idioms
+----------------------
+
+* ``setup()`` and ``teardown()`` at module/class/method level: any function or method called ``setup`` will be called during the setup phase for each test, same for ``teardown``.
+* ``SkipTest`` exceptions and markers
+* setup/teardown decorators
+* ``__test__`` attribute on modules/classes/functions
+* general usage of nose utilities
+
+Unsupported idioms / known issues
+----------------------------------
+
+- unittest-style ``setUp, tearDown, setUpClass, tearDownClass``
+  are recognized only on ``unittest.TestCase`` classes but not
+  on plain classes.  ``nose`` supports these methods also on plain
+  classes but pytest deliberately does not.  As nose and pytest already
+  both support ``setup_class, teardown_class, setup_method, teardown_method``
+  it doesn't seem useful to duplicate the unittest-API like nose does.
+  If you however rather think pytest should support the unittest-spelling on
+  plain classes please post to :issue:`377`.
+
+- nose imports test modules with the same import path (e.g.
+  ``tests.test_mode``) but different file system paths
+  (e.g. ``tests/test_mode.py`` and ``other/tests/test_mode.py``)
+  by extending sys.path/import semantics.   pytest does not do that
+  but there is discussion in :issue:`268` for adding some support.  Note that
+  `nose2 choose to avoid this sys.path/import hackery <https://nose2.readthedocs.io/en/latest/differences.html#test-discovery-and-loading>`_.
+
+  If you place a conftest.py file in the root directory of your project
+  (as determined by pytest) pytest will run tests "nose style" against
+  the code below that directory by adding it to your ``sys.path`` instead of
+  running against your installed code.
+
+  You may find yourself wanting to do this if you ran ``python setup.py install``
+  to set up your project, as opposed to ``python setup.py develop`` or any of
+  the package manager equivalents.  Installing with develop in a
+  virtual environment like tox is recommended over this pattern.
+
+- nose-style doctests are not collected and executed correctly,
+  also doctest fixtures don't work.
+
+- no nose-configuration is recognized.
+
+- ``yield``-based methods are unsupported as of pytest 4.1.0.  They are
+  fundamentally incompatible with pytest because they don't support fixtures
+  properly since collection and test execution are separated.
+
+Migrating from nose to pytest
+------------------------------
+
+`nose2pytest <https://github.com/pytest-dev/nose2pytest>`_ is a Python script
+and pytest plugin to help convert Nose-based tests into pytest-based tests.
+Specifically, the script transforms nose.tools.assert_* function calls into
+raw assert statements, while preserving format of original arguments
+as much as possible.
+
+.. _nose: https://nose.readthedocs.io/en/latest/
diff --git a/doc/en/how-to/output.rst b/doc/en/how-to/output.rst
new file mode 100644 (file)
index 0000000..e8e9af0
--- /dev/null
@@ -0,0 +1,710 @@
+.. _how-to-manage-output:
+
+Managing pytest's output
+=========================
+
+.. _how-to-modifying-python-tb-printing:
+
+Modifying Python traceback printing
+--------------------------------------------------
+
+Examples for modifying traceback printing:
+
+.. code-block:: bash
+
+    pytest --showlocals     # show local variables in tracebacks
+    pytest -l               # show local variables (shortcut)
+    pytest --no-showlocals  # hide local variables (if addopts enables them)
+
+    pytest --tb=auto    # (default) 'long' tracebacks for the first and last
+                         # entry, but 'short' style for the other entries
+    pytest --tb=long    # exhaustive, informative traceback formatting
+    pytest --tb=short   # shorter traceback format
+    pytest --tb=line    # only one line per failure
+    pytest --tb=native  # Python standard library formatting
+    pytest --tb=no      # no traceback at all
+
+The ``--full-trace`` causes very long traces to be printed on error (longer
+than ``--tb=long``). It also ensures that a stack trace is printed on
+**KeyboardInterrupt** (Ctrl+C).
+This is very useful if the tests are taking too long and you interrupt them
+with Ctrl+C to find out where the tests are *hanging*. By default no output
+will be shown (because KeyboardInterrupt is caught by pytest). By using this
+option you make sure a trace is shown.
+
+
+Verbosity
+--------------------------------------------------
+
+The ``-v`` flag controls the verbosity of pytest output in various aspects: test session progress, assertion
+details when tests fail, fixtures details with ``--fixtures``, etc.
+
+.. regendoc:wipe
+
+Consider this simple file:
+
+.. code-block:: python
+
+    # content of test_verbosity_example.py
+    def test_ok():
+        pass
+
+
+    def test_words_fail():
+        fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
+        fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
+        assert fruits1 == fruits2
+
+
+    def test_numbers_fail():
+        number_to_text1 = {str(x): x for x in range(5)}
+        number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
+        assert number_to_text1 == number_to_text2
+
+
+    def test_long_text_fail():
+        long_text = "Lorem ipsum dolor sit amet " * 10
+        assert "hello world" in long_text
+
+Executing pytest normally gives us this output (we are skipping the header to focus on the rest):
+
+.. code-block:: pytest
+
+    $ pytest --no-header
+    =========================== test session starts ============================
+    collected 4 items
+
+    test_verbosity_example.py .FFF                                       [100%]
+
+    ================================= FAILURES =================================
+    _____________________________ test_words_fail ______________________________
+
+        def test_words_fail():
+            fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
+            fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
+    >       assert fruits1 == fruits2
+    E       AssertionError: assert ['banana', 'a...elon', 'kiwi'] == ['banana', 'a...elon', 'kiwi']
+    E         At index 2 diff: 'grapes' != 'orange'
+    E         Use -v to get more diff
+
+    test_verbosity_example.py:8: AssertionError
+    ____________________________ test_numbers_fail _____________________________
+
+        def test_numbers_fail():
+            number_to_text1 = {str(x): x for x in range(5)}
+            number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
+    >       assert number_to_text1 == number_to_text2
+    E       AssertionError: assert {'0': 0, '1':..., '3': 3, ...} == {'0': 0, '10'...'30': 30, ...}
+    E         Omitting 1 identical items, use -vv to show
+    E         Left contains 4 more items:
+    E         {'1': 1, '2': 2, '3': 3, '4': 4}
+    E         Right contains 4 more items:
+    E         {'10': 10, '20': 20, '30': 30, '40': 40}
+    E         Use -v to get more diff
+
+    test_verbosity_example.py:14: AssertionError
+    ___________________________ test_long_text_fail ____________________________
+
+        def test_long_text_fail():
+            long_text = "Lorem ipsum dolor sit amet " * 10
+    >       assert "hello world" in long_text
+    E       AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ips... sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
+
+    test_verbosity_example.py:19: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
+    FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
+    FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
+    ======================= 3 failed, 1 passed in 0.12s ========================
+
+Notice that:
+
+* Each test inside the file is shown by a single character in the output: ``.`` for passing, ``F`` for failure.
+* ``test_words_fail`` failed, and we are shown a short summary indicating the index 2 of the two lists differ.
+* ``test_numbers_fail`` failed, and we are shown a summary of left/right differences on dictionary items. Identical items are omitted.
+* ``test_long_text_fail`` failed, and the right hand side of the ``in`` statement is truncated using ``...```
+  because it is longer than an internal threshold (240 characters currently).
+
+Now we can increase pytest's verbosity:
+
+.. code-block:: pytest
+
+    $ pytest --no-header -v
+    =========================== test session starts ============================
+    collecting ... collected 4 items
+
+    test_verbosity_example.py::test_ok PASSED                            [ 25%]
+    test_verbosity_example.py::test_words_fail FAILED                    [ 50%]
+    test_verbosity_example.py::test_numbers_fail FAILED                  [ 75%]
+    test_verbosity_example.py::test_long_text_fail FAILED                [100%]
+
+    ================================= FAILURES =================================
+    _____________________________ test_words_fail ______________________________
+
+        def test_words_fail():
+            fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
+            fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
+    >       assert fruits1 == fruits2
+    E       AssertionError: assert ['banana', 'a...elon', 'kiwi'] == ['banana', 'a...elon', 'kiwi']
+    E         At index 2 diff: 'grapes' != 'orange'
+    E         Full diff:
+    E         - ['banana', 'apple', 'orange', 'melon', 'kiwi']
+    E         ?                      ^  ^^
+    E         + ['banana', 'apple', 'grapes', 'melon', 'kiwi']
+    E         ?                      ^  ^ +
+
+    test_verbosity_example.py:8: AssertionError
+    ____________________________ test_numbers_fail _____________________________
+
+        def test_numbers_fail():
+            number_to_text1 = {str(x): x for x in range(5)}
+            number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
+    >       assert number_to_text1 == number_to_text2
+    E       AssertionError: assert {'0': 0, '1':..., '3': 3, ...} == {'0': 0, '10'...'30': 30, ...}
+    E         Omitting 1 identical items, use -vv to show
+    E         Left contains 4 more items:
+    E         {'1': 1, '2': 2, '3': 3, '4': 4}
+    E         Right contains 4 more items:
+    E         {'10': 10, '20': 20, '30': 30, '40': 40}
+    E         Full diff:
+    E         - {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
+    E         ?            -    -    -    -    -    -    -    -
+    E         + {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
+
+    test_verbosity_example.py:14: AssertionError
+    ___________________________ test_long_text_fail ____________________________
+
+        def test_long_text_fail():
+            long_text = "Lorem ipsum dolor sit amet " * 10
+    >       assert "hello world" in long_text
+    E       AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
+
+    test_verbosity_example.py:19: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
+    FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
+    FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
+    ======================= 3 failed, 1 passed in 0.12s ========================
+
+Notice now that:
+
+* Each test inside the file gets its own line in the output.
+* ``test_words_fail`` now shows the two failing lists in full, in addition to which index differs.
+* ``test_numbers_fail`` now shows a text diff of the two dictionaries, truncated.
+* ``test_long_text_fail`` no longer truncates the right hand side of the ``in`` statement, because the internal
+  threshold for truncation is larger now (2400 characters currently).
+
+Now if we increase verbosity even more:
+
+.. code-block:: pytest
+
+    $ pytest --no-header -vv
+    =========================== test session starts ============================
+    collecting ... collected 4 items
+
+    test_verbosity_example.py::test_ok PASSED                            [ 25%]
+    test_verbosity_example.py::test_words_fail FAILED                    [ 50%]
+    test_verbosity_example.py::test_numbers_fail FAILED                  [ 75%]
+    test_verbosity_example.py::test_long_text_fail FAILED                [100%]
+
+    ================================= FAILURES =================================
+    _____________________________ test_words_fail ______________________________
+
+        def test_words_fail():
+            fruits1 = ["banana", "apple", "grapes", "melon", "kiwi"]
+            fruits2 = ["banana", "apple", "orange", "melon", "kiwi"]
+    >       assert fruits1 == fruits2
+    E       AssertionError: assert ['banana', 'apple', 'grapes', 'melon', 'kiwi'] == ['banana', 'apple', 'orange', 'melon', 'kiwi']
+    E         At index 2 diff: 'grapes' != 'orange'
+    E         Full diff:
+    E         - ['banana', 'apple', 'orange', 'melon', 'kiwi']
+    E         ?                      ^  ^^
+    E         + ['banana', 'apple', 'grapes', 'melon', 'kiwi']
+    E         ?                      ^  ^ +
+
+    test_verbosity_example.py:8: AssertionError
+    ____________________________ test_numbers_fail _____________________________
+
+        def test_numbers_fail():
+            number_to_text1 = {str(x): x for x in range(5)}
+            number_to_text2 = {str(x * 10): x * 10 for x in range(5)}
+    >       assert number_to_text1 == number_to_text2
+    E       AssertionError: assert {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4} == {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
+    E         Common items:
+    E         {'0': 0}
+    E         Left contains 4 more items:
+    E         {'1': 1, '2': 2, '3': 3, '4': 4}
+    E         Right contains 4 more items:
+    E         {'10': 10, '20': 20, '30': 30, '40': 40}
+    E         Full diff:
+    E         - {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
+    E         ?            -    -    -    -    -    -    -    -
+    E         + {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
+
+    test_verbosity_example.py:14: AssertionError
+    ___________________________ test_long_text_fail ____________________________
+
+        def test_long_text_fail():
+            long_text = "Lorem ipsum dolor sit amet " * 10
+    >       assert "hello world" in long_text
+    E       AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
+
+    test_verbosity_example.py:19: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
+    FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
+    FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
+    ======================= 3 failed, 1 passed in 0.12s ========================
+
+Notice now that:
+
+* Each test inside the file gets its own line in the output.
+* ``test_words_fail`` gives the same output as before in this case.
+* ``test_numbers_fail`` now shows a full text diff of the two dictionaries.
+* ``test_long_text_fail`` also doesn't truncate on the right hand side as before, but now pytest won't truncate any
+  text at all, regardless of its size.
+
+Those were examples of how verbosity affects normal test session output, but verbosity also is used in other
+situations, for example you are shown even fixtures that start with ``_`` if you use ``pytest --fixtures -v``.
+
+Using higher verbosity levels (``-vvv``, ``-vvvv``, ...) is supported, but has no effect in pytest itself at the moment,
+however some plugins might make use of higher verbosity.
+
+.. _`pytest.detailed_failed_tests_usage`:
+
+Producing a detailed summary report
+--------------------------------------------------
+
+The ``-r`` flag can be used to display a "short test summary info" at the end of the test session,
+making it easy in large test suites to get a clear picture of all failures, skips, xfails, etc.
+
+It defaults to ``fE`` to list failures and errors.
+
+.. regendoc:wipe
+
+Example:
+
+.. code-block:: python
+
+    # content of test_example.py
+    import pytest
+
+
+    @pytest.fixture
+    def error_fixture():
+        assert 0
+
+
+    def test_ok():
+        print("ok")
+
+
+    def test_fail():
+        assert 0
+
+
+    def test_error(error_fixture):
+        pass
+
+
+    def test_skip():
+        pytest.skip("skipping this test")
+
+
+    def test_xfail():
+        pytest.xfail("xfailing this test")
+
+
+    @pytest.mark.xfail(reason="always xfail")
+    def test_xpass():
+        pass
+
+
+.. code-block:: pytest
+
+    $ pytest -ra
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 6 items
+
+    test_example.py .FEsxX                                               [100%]
+
+    ================================== ERRORS ==================================
+    _______________________ ERROR at setup of test_error _______________________
+
+        @pytest.fixture
+        def error_fixture():
+    >       assert 0
+    E       assert 0
+
+    test_example.py:6: AssertionError
+    ================================= FAILURES =================================
+    ________________________________ test_fail _________________________________
+
+        def test_fail():
+    >       assert 0
+    E       assert 0
+
+    test_example.py:14: AssertionError
+    ========================= short test summary info ==========================
+    SKIPPED [1] test_example.py:22: skipping this test
+    XFAIL test_example.py::test_xfail - reason: xfailing this test
+    XPASS test_example.py::test_xpass always xfail
+    ERROR test_example.py::test_error - assert 0
+    FAILED test_example.py::test_fail - assert 0
+    == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
+
+The ``-r`` options accepts a number of characters after it, with ``a`` used
+above meaning "all except passes".
+
+Here is the full list of available characters that can be used:
+
+ - ``f`` - failed
+ - ``E`` - error
+ - ``s`` - skipped
+ - ``x`` - xfailed
+ - ``X`` - xpassed
+ - ``p`` - passed
+ - ``P`` - passed with output
+
+Special characters for (de)selection of groups:
+
+ - ``a`` - all except ``pP``
+ - ``A`` - all
+ - ``N`` - none, this can be used to display nothing (since ``fE`` is the default)
+
+More than one character can be used, so for example to only see failed and skipped tests, you can execute:
+
+.. code-block:: pytest
+
+    $ pytest -rfs
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 6 items
+
+    test_example.py .FEsxX                                               [100%]
+
+    ================================== ERRORS ==================================
+    _______________________ ERROR at setup of test_error _______________________
+
+        @pytest.fixture
+        def error_fixture():
+    >       assert 0
+    E       assert 0
+
+    test_example.py:6: AssertionError
+    ================================= FAILURES =================================
+    ________________________________ test_fail _________________________________
+
+        def test_fail():
+    >       assert 0
+    E       assert 0
+
+    test_example.py:14: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_example.py::test_fail - assert 0
+    SKIPPED [1] test_example.py:22: skipping this test
+    == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
+
+Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had
+captured output:
+
+.. code-block:: pytest
+
+    $ pytest -rpP
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 6 items
+
+    test_example.py .FEsxX                                               [100%]
+
+    ================================== ERRORS ==================================
+    _______________________ ERROR at setup of test_error _______________________
+
+        @pytest.fixture
+        def error_fixture():
+    >       assert 0
+    E       assert 0
+
+    test_example.py:6: AssertionError
+    ================================= FAILURES =================================
+    ________________________________ test_fail _________________________________
+
+        def test_fail():
+    >       assert 0
+    E       assert 0
+
+    test_example.py:14: AssertionError
+    ================================== PASSES ==================================
+    _________________________________ test_ok __________________________________
+    --------------------------- Captured stdout call ---------------------------
+    ok
+    ========================= short test summary info ==========================
+    PASSED test_example.py::test_ok
+    == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
+
+Creating resultlog format files
+--------------------------------------------------
+
+To create plain-text machine-readable result files you can issue:
+
+.. code-block:: bash
+
+    pytest --resultlog=path
+
+and look at the content at the ``path`` location.  Such files are used e.g.
+by the `PyPy-test`_ web page to show test results over several revisions.
+
+.. warning::
+
+    This option is rarely used and is scheduled for removal in pytest 6.0.
+
+    If you use this option, consider using the new `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin instead.
+
+    See :ref:`the deprecation docs <resultlog deprecated>` for more information.
+
+
+.. _`PyPy-test`: http://buildbot.pypy.org/summary
+
+
+Creating JUnitXML format files
+----------------------------------------------------
+
+To create result files which can be read by Jenkins_ or other Continuous
+integration servers, use this invocation:
+
+.. code-block:: bash
+
+    pytest --junitxml=path
+
+to create an XML file at ``path``.
+
+
+
+To set the name of the root test suite xml item, you can configure the ``junit_suite_name`` option in your config file:
+
+.. code-block:: ini
+
+    [pytest]
+    junit_suite_name = my_suite
+
+.. versionadded:: 4.0
+
+JUnit XML specification seems to indicate that ``"time"`` attribute
+should report total test execution times, including setup and teardown
+(`1 <http://windyroad.com.au/dl/Open%20Source/JUnit.xsd>`_, `2
+<https://www.ibm.com/support/knowledgecenter/en/SSQ2R2_14.1.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html>`_).
+It is the default pytest behavior. To report just call durations
+instead, configure the ``junit_duration_report`` option like this:
+
+.. code-block:: ini
+
+    [pytest]
+    junit_duration_report = call
+
+.. _record_property example:
+
+record_property
+~~~~~~~~~~~~~~~~~
+
+If you want to log additional information for a test, you can use the
+``record_property`` fixture:
+
+.. code-block:: python
+
+    def test_function(record_property):
+        record_property("example_key", 1)
+        assert True
+
+This will add an extra property ``example_key="1"`` to the generated
+``testcase`` tag:
+
+.. code-block:: xml
+
+    <testcase classname="test_function" file="test_function.py" line="0" name="test_function" time="0.0009">
+      <properties>
+        <property name="example_key" value="1" />
+      </properties>
+    </testcase>
+
+Alternatively, you can integrate this functionality with custom markers:
+
+.. code-block:: python
+
+    # content of conftest.py
+
+
+    def pytest_collection_modifyitems(session, config, items):
+        for item in items:
+            for marker in item.iter_markers(name="test_id"):
+                test_id = marker.args[0]
+                item.user_properties.append(("test_id", test_id))
+
+And in your tests:
+
+.. code-block:: python
+
+    # content of test_function.py
+    import pytest
+
+
+    @pytest.mark.test_id(1501)
+    def test_function():
+        assert True
+
+Will result in:
+
+.. code-block:: xml
+
+    <testcase classname="test_function" file="test_function.py" line="0" name="test_function" time="0.0009">
+      <properties>
+        <property name="test_id" value="1501" />
+      </properties>
+    </testcase>
+
+.. warning::
+
+    Please note that using this feature will break schema verifications for the latest JUnitXML schema.
+    This might be a problem when used with some CI servers.
+
+
+record_xml_attribute
+~~~~~~~~~~~~~~~~~~~~~~~
+
+To add an additional xml attribute to a testcase element, you can use
+``record_xml_attribute`` fixture. This can also be used to override existing values:
+
+.. code-block:: python
+
+    def test_function(record_xml_attribute):
+        record_xml_attribute("assertions", "REQ-1234")
+        record_xml_attribute("classname", "custom_classname")
+        print("hello world")
+        assert True
+
+Unlike ``record_property``, this will not add a new child element.
+Instead, this will add an attribute ``assertions="REQ-1234"`` inside the generated
+``testcase`` tag and override the default ``classname`` with ``"classname=custom_classname"``:
+
+.. code-block:: xml
+
+    <testcase classname="custom_classname" file="test_function.py" line="0" name="test_function" time="0.003" assertions="REQ-1234">
+        <system-out>
+            hello world
+        </system-out>
+    </testcase>
+
+.. warning::
+
+    ``record_xml_attribute`` is an experimental feature, and its interface might be replaced
+    by something more powerful and general in future versions. The
+    functionality per-se will be kept, however.
+
+    Using this over ``record_xml_property`` can help when using ci tools to parse the xml report.
+    However, some parsers are quite strict about the elements and attributes that are allowed.
+    Many tools use an xsd schema (like the example below) to validate incoming xml.
+    Make sure you are using attribute names that are allowed by your parser.
+
+    Below is the Scheme used by Jenkins to validate the XML report:
+
+    .. code-block:: xml
+
+        <xs:element name="testcase">
+            <xs:complexType>
+                <xs:sequence>
+                    <xs:element ref="skipped" minOccurs="0" maxOccurs="1"/>
+                    <xs:element ref="error" minOccurs="0" maxOccurs="unbounded"/>
+                    <xs:element ref="failure" minOccurs="0" maxOccurs="unbounded"/>
+                    <xs:element ref="system-out" minOccurs="0" maxOccurs="unbounded"/>
+                    <xs:element ref="system-err" minOccurs="0" maxOccurs="unbounded"/>
+                </xs:sequence>
+                <xs:attribute name="name" type="xs:string" use="required"/>
+                <xs:attribute name="assertions" type="xs:string" use="optional"/>
+                <xs:attribute name="time" type="xs:string" use="optional"/>
+                <xs:attribute name="classname" type="xs:string" use="optional"/>
+                <xs:attribute name="status" type="xs:string" use="optional"/>
+            </xs:complexType>
+        </xs:element>
+
+.. warning::
+
+    Please note that using this feature will break schema verifications for the latest JUnitXML schema.
+    This might be a problem when used with some CI servers.
+
+.. _record_testsuite_property example:
+
+record_testsuite_property
+^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. versionadded:: 4.5
+
+If you want to add a properties node at the test-suite level, which may contains properties
+that are relevant to all tests, you can use the ``record_testsuite_property`` session-scoped fixture:
+
+The ``record_testsuite_property`` session-scoped fixture can be used to add properties relevant
+to all tests.
+
+.. code-block:: python
+
+    import pytest
+
+
+    @pytest.fixture(scope="session", autouse=True)
+    def log_global_env_facts(record_testsuite_property):
+        record_testsuite_property("ARCH", "PPC")
+        record_testsuite_property("STORAGE_TYPE", "CEPH")
+
+
+    class TestMe:
+        def test_foo(self):
+            assert True
+
+The fixture is a callable which receives ``name`` and ``value`` of a ``<property>`` tag
+added at the test-suite level of the generated xml:
+
+.. code-block:: xml
+
+    <testsuite errors="0" failures="0" name="pytest" skipped="0" tests="1" time="0.006">
+      <properties>
+        <property name="ARCH" value="PPC"/>
+        <property name="STORAGE_TYPE" value="CEPH"/>
+      </properties>
+      <testcase classname="test_me.TestMe" file="test_me.py" line="16" name="test_foo" time="0.000243663787842"/>
+    </testsuite>
+
+``name`` must be a string, ``value`` will be converted to a string and properly xml-escaped.
+
+The generated XML is compatible with the latest ``xunit`` standard, contrary to `record_property`_
+and `record_xml_attribute`_.
+
+
+Sending test report to an online pastebin service
+--------------------------------------------------
+
+**Creating a URL for each test failure**:
+
+.. code-block:: bash
+
+    pytest --pastebin=failed
+
+This will submit test run information to a remote Paste service and
+provide a URL for each failure.  You may select tests as usual or add
+for example ``-x`` if you only want to send one particular failure.
+
+**Creating a URL for a whole test session log**:
+
+.. code-block:: bash
+
+    pytest --pastebin=all
+
+Currently only pasting to the https://bpaste.net/ service is implemented.
+
+.. versionchanged:: 5.2
+
+If creating the URL fails for any reason, a warning is generated instead of failing the
+entire test suite.
+
+.. _jenkins: https://jenkins-ci.org
diff --git a/doc/en/how-to/parametrize.rst b/doc/en/how-to/parametrize.rst
new file mode 100644 (file)
index 0000000..a0c9968
--- /dev/null
@@ -0,0 +1,298 @@
+
+.. _`test generators`:
+.. _`parametrizing-tests`:
+.. _`parametrized test functions`:
+.. _`parametrize`:
+
+.. _`parametrize-basics`:
+
+How to parametrize fixtures and test functions
+==========================================================================
+
+pytest enables test parametrization at several levels:
+
+- :py:func:`pytest.fixture` allows one to :ref:`parametrize fixture
+  functions <fixture-parametrize>`.
+
+* `@pytest.mark.parametrize`_ allows one to define multiple sets of
+  arguments and fixtures at the test function or class.
+
+* `pytest_generate_tests`_ allows one to define custom parametrization
+  schemes or extensions.
+
+.. _parametrizemark:
+.. _`@pytest.mark.parametrize`:
+
+
+``@pytest.mark.parametrize``: parametrizing test functions
+---------------------------------------------------------------------
+
+.. regendoc: wipe
+
+
+
+    Several improvements.
+
+The builtin :ref:`pytest.mark.parametrize ref` decorator enables
+parametrization of arguments for a test function.  Here is a typical example
+of a test function that implements checking that a certain input leads
+to an expected output:
+
+.. code-block:: python
+
+    # content of test_expectation.py
+    import pytest
+
+
+    @pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)])
+    def test_eval(test_input, expected):
+        assert eval(test_input) == expected
+
+Here, the ``@parametrize`` decorator defines three different ``(test_input,expected)``
+tuples so that the ``test_eval`` function will run three times using
+them in turn:
+
+.. code-block:: pytest
+
+    $ pytest
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 3 items
+
+    test_expectation.py ..F                                              [100%]
+
+    ================================= FAILURES =================================
+    ____________________________ test_eval[6*9-42] _____________________________
+
+    test_input = '6*9', expected = 42
+
+        @pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)])
+        def test_eval(test_input, expected):
+    >       assert eval(test_input) == expected
+    E       AssertionError: assert 54 == 42
+    E        +  where 54 = eval('6*9')
+
+    test_expectation.py:6: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_expectation.py::test_eval[6*9-42] - AssertionError: assert 54...
+    ======================= 1 failed, 2 passed in 0.12s ========================
+
+.. note::
+
+    Parameter values are passed as-is to tests (no copy whatsoever).
+
+    For example, if you pass a list or a dict as a parameter value, and
+    the test case code mutates it, the mutations will be reflected in subsequent
+    test case calls.
+
+.. note::
+
+    pytest by default escapes any non-ascii characters used in unicode strings
+    for the parametrization because it has several downsides.
+    If however you would like to use unicode strings in parametrization
+    and see them in the terminal as is (non-escaped), use this option
+    in your ``pytest.ini``:
+
+    .. code-block:: ini
+
+        [pytest]
+        disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
+
+    Keep in mind however that this might cause unwanted side effects and
+    even bugs depending on the OS used and plugins currently installed,
+    so use it at your own risk.
+
+
+As designed in this example, only one pair of input/output values fails
+the simple test function.  And as usual with test function arguments,
+you can see the ``input`` and ``output`` values in the traceback.
+
+Note that you could also use the parametrize marker on a class or a module
+(see :ref:`mark`) which would invoke several functions with the argument sets,
+for instance:
+
+
+.. code-block:: python
+
+    import pytest
+
+
+    @pytest.mark.parametrize("n,expected", [(1, 2), (3, 4)])
+    class TestClass:
+        def test_simple_case(self, n, expected):
+            assert n + 1 == expected
+
+        def test_weird_simple_case(self, n, expected):
+            assert (n * 1) + 1 == expected
+
+
+To parametrize all tests in a module, you can assign to the :globalvar:`pytestmark` global variable:
+
+
+.. code-block:: python
+
+    import pytest
+
+    pytestmark = pytest.mark.parametrize("n,expected", [(1, 2), (3, 4)])
+
+
+    class TestClass:
+        def test_simple_case(self, n, expected):
+            assert n + 1 == expected
+
+        def test_weird_simple_case(self, n, expected):
+            assert (n * 1) + 1 == expected
+
+
+It is also possible to mark individual test instances within parametrize,
+for example with the builtin ``mark.xfail``:
+
+.. code-block:: python
+
+    # content of test_expectation.py
+    import pytest
+
+
+    @pytest.mark.parametrize(
+        "test_input,expected",
+        [("3+5", 8), ("2+4", 6), pytest.param("6*9", 42, marks=pytest.mark.xfail)],
+    )
+    def test_eval(test_input, expected):
+        assert eval(test_input) == expected
+
+Let's run this:
+
+.. code-block:: pytest
+
+    $ pytest
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 3 items
+
+    test_expectation.py ..x                                              [100%]
+
+    ======================= 2 passed, 1 xfailed in 0.12s =======================
+
+The one parameter set which caused a failure previously now
+shows up as an "xfailed" (expected to fail) test.
+
+In case the values provided to ``parametrize`` result in an empty list - for
+example, if they're dynamically generated by some function - the behaviour of
+pytest is defined by the :confval:`empty_parameter_set_mark` option.
+
+To get all combinations of multiple parametrized arguments you can stack
+``parametrize`` decorators:
+
+.. code-block:: python
+
+    import pytest
+
+
+    @pytest.mark.parametrize("x", [0, 1])
+    @pytest.mark.parametrize("y", [2, 3])
+    def test_foo(x, y):
+        pass
+
+This will run the test with the arguments set to ``x=0/y=2``, ``x=1/y=2``,
+``x=0/y=3``, and ``x=1/y=3`` exhausting parameters in the order of the decorators.
+
+.. _`pytest_generate_tests`:
+
+Basic ``pytest_generate_tests`` example
+---------------------------------------------
+
+Sometimes you may want to implement your own parametrization scheme
+or implement some dynamism for determining the parameters or scope
+of a fixture.   For this, you can use the ``pytest_generate_tests`` hook
+which is called when collecting a test function.  Through the passed in
+``metafunc`` object you can inspect the requesting test context and, most
+importantly, you can call ``metafunc.parametrize()`` to cause
+parametrization.
+
+For example, let's say we want to run a test taking string inputs which
+we want to set via a new ``pytest`` command line option.  Let's first write
+a simple test accepting a ``stringinput`` fixture function argument:
+
+.. code-block:: python
+
+    # content of test_strings.py
+
+
+    def test_valid_string(stringinput):
+        assert stringinput.isalpha()
+
+Now we add a ``conftest.py`` file containing the addition of a
+command line option and the parametrization of our test function:
+
+.. code-block:: python
+
+    # content of conftest.py
+
+
+    def pytest_addoption(parser):
+        parser.addoption(
+            "--stringinput",
+            action="append",
+            default=[],
+            help="list of stringinputs to pass to test functions",
+        )
+
+
+    def pytest_generate_tests(metafunc):
+        if "stringinput" in metafunc.fixturenames:
+            metafunc.parametrize("stringinput", metafunc.config.getoption("stringinput"))
+
+If we now pass two stringinput values, our test will run twice:
+
+.. code-block:: pytest
+
+    $ pytest -q --stringinput="hello" --stringinput="world" test_strings.py
+    ..                                                                   [100%]
+    2 passed in 0.12s
+
+Let's also run with a stringinput that will lead to a failing test:
+
+.. code-block:: pytest
+
+    $ pytest -q --stringinput="!" test_strings.py
+    F                                                                    [100%]
+    ================================= FAILURES =================================
+    ___________________________ test_valid_string[!] ___________________________
+
+    stringinput = '!'
+
+        def test_valid_string(stringinput):
+    >       assert stringinput.isalpha()
+    E       AssertionError: assert False
+    E        +  where False = <built-in method isalpha of str object at 0xdeadbeef0001>()
+    E        +    where <built-in method isalpha of str object at 0xdeadbeef0001> = '!'.isalpha
+
+    test_strings.py:4: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_strings.py::test_valid_string[!] - AssertionError: assert False
+    1 failed in 0.12s
+
+As expected our test function fails.
+
+If you don't specify a stringinput it will be skipped because
+``metafunc.parametrize()`` will be called with an empty parameter
+list:
+
+.. code-block:: pytest
+
+    $ pytest -q -rs test_strings.py
+    s                                                                    [100%]
+    ========================= short test summary info ==========================
+    SKIPPED [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at /home/sweet/project/test_strings.py:2
+    1 skipped in 0.12s
+
+Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across
+those sets cannot be duplicated, otherwise an error will be raised.
+
+More examples
+-------------
+
+For further examples, you might want to look at :ref:`more
+parametrization examples <paramexamples>`.
diff --git a/doc/en/how-to/plugins.rst b/doc/en/how-to/plugins.rst
new file mode 100644 (file)
index 0000000..7d5bcd8
--- /dev/null
@@ -0,0 +1,136 @@
+.. _`external plugins`:
+.. _`extplugins`:
+.. _`using plugins`:
+
+How to install and use plugins
+===============================
+
+This section talks about installing and using third party plugins.
+For writing your own plugins, please refer to :ref:`writing-plugins`.
+
+Installing a third party plugin can be easily done with ``pip``:
+
+.. code-block:: bash
+
+    pip install pytest-NAME
+    pip uninstall pytest-NAME
+
+If a plugin is installed, ``pytest`` automatically finds and integrates it,
+there is no need to activate it.
+
+Here is a little annotated list for some popular plugins:
+
+* :pypi:`pytest-django`: write tests
+  for `django <https://docs.djangoproject.com/>`_ apps, using pytest integration.
+
+* :pypi:`pytest-twisted`: write tests
+  for `twisted <https://twistedmatrix.com/>`_ apps, starting a reactor and
+  processing deferreds from test functions.
+
+* :pypi:`pytest-cov`:
+  coverage reporting, compatible with distributed testing
+
+* :pypi:`pytest-xdist`:
+  to distribute tests to CPUs and remote hosts, to run in boxed
+  mode which allows to survive segmentation faults, to run in
+  looponfailing mode, automatically re-running failing tests
+  on file changes.
+
+* :pypi:`pytest-instafail`:
+  to report failures while the test run is happening.
+
+* :pypi:`pytest-bdd`:
+  to write tests using behaviour-driven testing.
+
+* :pypi:`pytest-timeout`:
+  to timeout tests based on function marks or global definitions.
+
+* :pypi:`pytest-pep8`:
+  a ``--pep8`` option to enable PEP8 compliance checking.
+
+* :pypi:`pytest-flakes`:
+  check source code with pyflakes.
+
+* :pypi:`allure-pytest`:
+  report test results via `allure-framework <https://github.com/allure-framework/>`_.
+
+To see a complete list of all plugins with their latest testing
+status against different pytest and Python versions, please visit
+:ref:`plugin-list`.
+
+You may also discover more plugins through a `pytest- pypi.org search`_.
+
+.. _`pytest- pypi.org search`: https://pypi.org/search/?q=pytest-
+
+
+.. _`available installable plugins`:
+
+Requiring/Loading plugins in a test module or conftest file
+-----------------------------------------------------------
+
+You can require plugins in a test module or a conftest file using :globalvar:`pytest_plugins`:
+
+.. code-block:: python
+
+    pytest_plugins = ("myapp.testsupport.myplugin",)
+
+When the test module or conftest plugin is loaded the specified plugins
+will be loaded as well.
+
+.. note::
+
+    Requiring plugins using a ``pytest_plugins`` variable in non-root
+    ``conftest.py`` files is deprecated. See
+    :ref:`full explanation <requiring plugins in non-root conftests>`
+    in the Writing plugins section.
+
+.. note::
+   The name ``pytest_plugins`` is reserved and should not be used as a
+   name for a custom plugin module.
+
+
+.. _`findpluginname`:
+
+Finding out which plugins are active
+------------------------------------
+
+If you want to find out which plugins are active in your
+environment you can type:
+
+.. code-block:: bash
+
+    pytest --trace-config
+
+and will get an extended test header which shows activated plugins
+and their names. It will also print local plugins aka
+:ref:`conftest.py <conftest.py plugins>` files when they are loaded.
+
+.. _`cmdunregister`:
+
+Deactivating / unregistering a plugin by name
+---------------------------------------------
+
+You can prevent plugins from loading or unregister them:
+
+.. code-block:: bash
+
+    pytest -p no:NAME
+
+This means that any subsequent try to activate/load the named
+plugin will not work.
+
+If you want to unconditionally disable a plugin for a project, you can add
+this option to your ``pytest.ini`` file:
+
+.. code-block:: ini
+
+      [pytest]
+      addopts = -p no:NAME
+
+Alternatively to disable it only in certain environments (for example in a
+CI server), you can set ``PYTEST_ADDOPTS`` environment variable to
+``-p no:name``.
+
+See :ref:`findpluginname` for how to obtain the name of a plugin.
+
+.. _`builtin plugins`:
diff --git a/doc/en/how-to/skipping.rst b/doc/en/how-to/skipping.rst
new file mode 100644 (file)
index 0000000..1fc6f5e
--- /dev/null
@@ -0,0 +1,432 @@
+.. _`skip and xfail`:
+
+.. _skipping:
+
+How to use skip and xfail to deal with tests that cannot succeed
+=================================================================
+
+You can mark test functions that cannot be run on certain platforms
+or that you expect to fail so pytest can deal with them accordingly and
+present a summary of the test session, while keeping the test suite *green*.
+
+A **skip** means that you expect your test to pass only if some conditions are met,
+otherwise pytest should skip running the test altogether. Common examples are skipping
+windows-only tests on non-windows platforms, or skipping tests that depend on an external
+resource which is not available at the moment (for example a database).
+
+An **xfail** means that you expect a test to fail for some reason.
+A common example is a test for a feature not yet implemented, or a bug not yet fixed.
+When a test passes despite being expected to fail (marked with ``pytest.mark.xfail``),
+it's an **xpass** and will be reported in the test summary.
+
+``pytest`` counts and lists *skip* and *xfail* tests separately. Detailed
+information about skipped/xfailed tests is not shown by default to avoid
+cluttering the output.  You can use the ``-r`` option to see details
+corresponding to the "short" letters shown in the test progress:
+
+.. code-block:: bash
+
+    pytest -rxXs  # show extra info on xfailed, xpassed, and skipped tests
+
+More details on the ``-r`` option can be found by running ``pytest -h``.
+
+(See :ref:`how to change command line options defaults`)
+
+.. _skipif:
+.. _skip:
+.. _`condition booleans`:
+
+Skipping test functions
+-----------------------
+
+
+
+The simplest way to skip a test function is to mark it with the ``skip`` decorator
+which may be passed an optional ``reason``:
+
+.. code-block:: python
+
+    @pytest.mark.skip(reason="no way of currently testing this")
+    def test_the_unknown():
+        ...
+
+
+Alternatively, it is also possible to skip imperatively during test execution or setup
+by calling the ``pytest.skip(reason)`` function:
+
+.. code-block:: python
+
+    def test_function():
+        if not valid_config():
+            pytest.skip("unsupported configuration")
+
+The imperative method is useful when it is not possible to evaluate the skip condition
+during import time.
+
+It is also possible to skip the whole module using
+``pytest.skip(reason, allow_module_level=True)`` at the module level:
+
+.. code-block:: python
+
+    import sys
+
+    import pytest
+
+    if not sys.platform.startswith("win"):
+        pytest.skip("skipping windows-only tests", allow_module_level=True)
+
+
+**Reference**: :ref:`pytest.mark.skip ref`
+
+``skipif``
+~~~~~~~~~~
+
+
+
+If you wish to skip something conditionally then you can use ``skipif`` instead.
+Here is an example of marking a test function to be skipped
+when run on an interpreter earlier than Python3.10:
+
+.. code-block:: python
+
+    import sys
+
+
+    @pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
+    def test_function():
+        ...
+
+If the condition evaluates to ``True`` during collection, the test function will be skipped,
+with the specified reason appearing in the summary when using ``-rs``.
+
+You can share ``skipif`` markers between modules.  Consider this test module:
+
+.. code-block:: python
+
+    # content of test_mymodule.py
+    import mymodule
+
+    minversion = pytest.mark.skipif(
+        mymodule.__versioninfo__ < (1, 1), reason="at least mymodule-1.1 required"
+    )
+
+
+    @minversion
+    def test_function():
+        ...
+
+You can import the marker and reuse it in another test module:
+
+.. code-block:: python
+
+    # test_myothermodule.py
+    from test_mymodule import minversion
+
+
+    @minversion
+    def test_anotherfunction():
+        ...
+
+For larger test suites it's usually a good idea to have one file
+where you define the markers which you then consistently apply
+throughout your test suite.
+
+Alternatively, you can use :ref:`condition strings
+<string conditions>` instead of booleans, but they can't be shared between modules easily
+so they are supported mainly for backward compatibility reasons.
+
+**Reference**: :ref:`pytest.mark.skipif ref`
+
+
+Skip all test functions of a class or module
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can use the ``skipif`` marker (as any other marker) on classes:
+
+.. code-block:: python
+
+    @pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
+    class TestPosixCalls:
+        def test_function(self):
+            "will not be setup or run under 'win32' platform"
+
+If the condition is ``True``, this marker will produce a skip result for
+each of the test methods of that class.
+
+If you want to skip all test functions of a module, you may use the
+:globalvar:`pytestmark` global:
+
+.. code-block:: python
+
+    # test_module.py
+    pytestmark = pytest.mark.skipif(...)
+
+If multiple ``skipif`` decorators are applied to a test function, it
+will be skipped if any of the skip conditions is true.
+
+.. _`whole class- or module level`: mark.html#scoped-marking
+
+
+Skipping files or directories
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sometimes you may need to skip an entire file or directory, for example if the
+tests rely on Python version-specific features or contain code that you do not
+wish pytest to run. In this case, you must exclude the files and directories
+from collection. Refer to :ref:`customizing-test-collection` for more
+information.
+
+
+Skipping on a missing import dependency
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can skip tests on a missing import by using :ref:`pytest.importorskip ref`
+at module level, within a test, or test setup function.
+
+.. code-block:: python
+
+    docutils = pytest.importorskip("docutils")
+
+If ``docutils`` cannot be imported here, this will lead to a skip outcome of
+the test. You can also skip based on the version number of a library:
+
+.. code-block:: python
+
+    docutils = pytest.importorskip("docutils", minversion="0.3")
+
+The version will be read from the specified
+module's ``__version__`` attribute.
+
+Summary
+~~~~~~~
+
+Here's a quick guide on how to skip tests in a module in different situations:
+
+1. Skip all tests in a module unconditionally:
+
+  .. code-block:: python
+
+        pytestmark = pytest.mark.skip("all tests still WIP")
+
+2. Skip all tests in a module based on some condition:
+
+  .. code-block:: python
+
+        pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="tests for linux only")
+
+3. Skip all tests in a module if some import is missing:
+
+  .. code-block:: python
+
+        pexpect = pytest.importorskip("pexpect")
+
+
+.. _xfail:
+
+XFail: mark test functions as expected to fail
+----------------------------------------------
+
+You can use the ``xfail`` marker to indicate that you
+expect a test to fail:
+
+.. code-block:: python
+
+    @pytest.mark.xfail
+    def test_function():
+        ...
+
+This test will run but no traceback will be reported when it fails. Instead, terminal
+reporting will list it in the "expected to fail" (``XFAIL``) or "unexpectedly
+passing" (``XPASS``) sections.
+
+Alternatively, you can also mark a test as ``XFAIL`` from within the test or its setup function
+imperatively:
+
+.. code-block:: python
+
+    def test_function():
+        if not valid_config():
+            pytest.xfail("failing configuration (but should work)")
+
+.. code-block:: python
+
+    def test_function2():
+        import slow_module
+
+        if slow_module.slow_function():
+            pytest.xfail("slow_module taking too long")
+
+These two examples illustrate situations where you don't want to check for a condition
+at the module level, which is when a condition would otherwise be evaluated for marks.
+
+This will make ``test_function`` ``XFAIL``. Note that no other code is executed after
+the :func:`pytest.xfail` call, differently from the marker. That's because it is implemented
+internally by raising a known exception.
+
+**Reference**: :ref:`pytest.mark.xfail ref`
+
+
+``condition`` parameter
+~~~~~~~~~~~~~~~~~~~~~~~
+
+If a test is only expected to fail under a certain condition, you can pass
+that condition as the first parameter:
+
+.. code-block:: python
+
+    @pytest.mark.xfail(sys.platform == "win32", reason="bug in a 3rd party library")
+    def test_function():
+        ...
+
+Note that you have to pass a reason as well (see the parameter description at
+:ref:`pytest.mark.xfail ref`).
+
+``reason`` parameter
+~~~~~~~~~~~~~~~~~~~~
+
+You can specify the motive of an expected failure with the ``reason`` parameter:
+
+.. code-block:: python
+
+    @pytest.mark.xfail(reason="known parser issue")
+    def test_function():
+        ...
+
+
+``raises`` parameter
+~~~~~~~~~~~~~~~~~~~~
+
+If you want to be more specific as to why the test is failing, you can specify
+a single exception, or a tuple of exceptions, in the ``raises`` argument.
+
+.. code-block:: python
+
+    @pytest.mark.xfail(raises=RuntimeError)
+    def test_function():
+        ...
+
+Then the test will be reported as a regular failure if it fails with an
+exception not mentioned in ``raises``.
+
+``run`` parameter
+~~~~~~~~~~~~~~~~~
+
+If a test should be marked as xfail and reported as such but should not be
+even executed, use the ``run`` parameter as ``False``:
+
+.. code-block:: python
+
+    @pytest.mark.xfail(run=False)
+    def test_function():
+        ...
+
+This is specially useful for xfailing tests that are crashing the interpreter and should be
+investigated later.
+
+.. _`xfail strict tutorial`:
+
+``strict`` parameter
+~~~~~~~~~~~~~~~~~~~~
+
+Both ``XFAIL`` and ``XPASS`` don't fail the test suite by default.
+You can change this by setting the ``strict`` keyword-only parameter to ``True``:
+
+.. code-block:: python
+
+    @pytest.mark.xfail(strict=True)
+    def test_function():
+        ...
+
+
+This will make ``XPASS`` ("unexpectedly passing") results from this test to fail the test suite.
+
+You can change the default value of the ``strict`` parameter using the
+``xfail_strict`` ini option:
+
+.. code-block:: ini
+
+    [pytest]
+    xfail_strict=true
+
+
+Ignoring xfail
+~~~~~~~~~~~~~~
+
+By specifying on the commandline:
+
+.. code-block:: bash
+
+    pytest --runxfail
+
+you can force the running and reporting of an ``xfail`` marked test
+as if it weren't marked at all. This also causes :func:`pytest.xfail` to produce no effect.
+
+Examples
+~~~~~~~~
+
+Here is a simple test file with the several usages:
+
+.. literalinclude:: /example/xfail_demo.py
+
+Running it with the report-on-xfail option gives this output:
+
+.. FIXME: Use $ instead of ! again to re-enable regendoc once it's fixed:
+   https://github.com/pytest-dev/pytest/issues/8807
+
+.. code-block:: pytest
+
+    ! pytest -rx xfail_demo.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
+    cachedir: $PYTHON_PREFIX/.pytest_cache
+    rootdir: $REGENDOC_TMPDIR/example
+    collected 7 items
+
+    xfail_demo.py xxxxxxx                                                [100%]
+
+    ========================= short test summary info ==========================
+    XFAIL xfail_demo.py::test_hello
+    XFAIL xfail_demo.py::test_hello2
+      reason: [NOTRUN]
+    XFAIL xfail_demo.py::test_hello3
+      condition: hasattr(os, 'sep')
+    XFAIL xfail_demo.py::test_hello4
+      bug 110
+    XFAIL xfail_demo.py::test_hello5
+      condition: pytest.__version__[0] != "17"
+    XFAIL xfail_demo.py::test_hello6
+      reason: reason
+    XFAIL xfail_demo.py::test_hello7
+    ============================ 7 xfailed in 0.12s ============================
+
+.. _`skip/xfail with parametrize`:
+
+Skip/xfail with parametrize
+---------------------------
+
+It is possible to apply markers like skip and xfail to individual
+test instances when using parametrize:
+
+.. code-block:: python
+
+    import sys
+
+    import pytest
+
+
+    @pytest.mark.parametrize(
+        ("n", "expected"),
+        [
+            (1, 2),
+            pytest.param(1, 0, marks=pytest.mark.xfail),
+            pytest.param(1, 3, marks=pytest.mark.xfail(reason="some bug")),
+            (2, 3),
+            (3, 4),
+            (4, 5),
+            pytest.param(
+                10, 11, marks=pytest.mark.skipif(sys.version_info >= (3, 0), reason="py2k")
+            ),
+        ],
+    )
+    def test_increment(n, expected):
+        assert n + 1 == expected
diff --git a/doc/en/how-to/tmp_path.rst b/doc/en/how-to/tmp_path.rst
new file mode 100644 (file)
index 0000000..3b49d63
--- /dev/null
@@ -0,0 +1,158 @@
+
+.. _`tmp_path handling`:
+.. _tmp_path:
+
+How to use temporary directories and files in tests
+===================================================
+
+The ``tmp_path`` fixture
+------------------------
+
+You can use the ``tmp_path`` fixture which will
+provide a temporary directory unique to the test invocation,
+created in the `base temporary directory`_.
+
+``tmp_path`` is a :class:`pathlib.Path` object. Here is an example test usage:
+
+.. code-block:: python
+
+    # content of test_tmp_path.py
+    CONTENT = "content"
+
+
+    def test_create_file(tmp_path):
+        d = tmp_path / "sub"
+        d.mkdir()
+        p = d / "hello.txt"
+        p.write_text(CONTENT, encoding="utf-8")
+        assert p.read_text(encoding="utf-8") == CONTENT
+        assert len(list(tmp_path.iterdir())) == 1
+        assert 0
+
+Running this would result in a passed test except for the last
+``assert 0`` line which we use to look at values:
+
+.. code-block:: pytest
+
+    $ pytest test_tmp_path.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 1 item
+
+    test_tmp_path.py F                                                   [100%]
+
+    ================================= FAILURES =================================
+    _____________________________ test_create_file _____________________________
+
+    tmp_path = PosixPath('PYTEST_TMPDIR/test_create_file0')
+
+        def test_create_file(tmp_path):
+            d = tmp_path / "sub"
+            d.mkdir()
+            p = d / "hello.txt"
+            p.write_text(CONTENT, encoding="utf-8")
+            assert p.read_text(encoding="utf-8") == CONTENT
+            assert len(list(tmp_path.iterdir())) == 1
+    >       assert 0
+    E       assert 0
+
+    test_tmp_path.py:11: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_tmp_path.py::test_create_file - assert 0
+    ============================ 1 failed in 0.12s =============================
+
+.. _`tmp_path_factory example`:
+
+The ``tmp_path_factory`` fixture
+--------------------------------
+
+The ``tmp_path_factory`` is a session-scoped fixture which can be used
+to create arbitrary temporary directories from any other fixture or test.
+
+For example, suppose your test suite needs a large image on disk, which is
+generated procedurally. Instead of computing the same image for each test
+that uses it into its own ``tmp_path``, you can generate it once per-session
+to save time:
+
+.. code-block:: python
+
+    # contents of conftest.py
+    import pytest
+
+
+    @pytest.fixture(scope="session")
+    def image_file(tmp_path_factory):
+        img = compute_expensive_image()
+        fn = tmp_path_factory.mktemp("data") / "img.png"
+        img.save(fn)
+        return fn
+
+
+    # contents of test_image.py
+    def test_histogram(image_file):
+        img = load_image(image_file)
+        # compute and test histogram
+
+See :ref:`tmp_path_factory API <tmp_path_factory factory api>` for details.
+
+.. _`tmpdir and tmpdir_factory`:
+.. _tmpdir:
+
+The ``tmpdir`` and ``tmpdir_factory`` fixtures
+---------------------------------------------------
+
+The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
+and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
+rather than standard :class:`pathlib.Path` objects.
+
+.. note::
+    These days, it is preferred to use ``tmp_path`` and ``tmp_path_factory``.
+
+    In order to help modernize old code bases, one can run pytest with the legacypath
+    plugin disabled:
+
+    .. code-block:: bash
+
+        pytest -p no:legacypath
+
+    This will trigger errors on tests using the legacy paths.
+    It can also be permanently set as part of the :confval:`addopts` parameter in the
+    config file.
+
+See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
+API for details.
+
+
+.. _`base temporary directory`:
+
+The default base temporary directory
+-----------------------------------------------
+
+Temporary directories are by default created as sub-directories of
+the system temporary directory.  The base name will be ``pytest-NUM`` where
+``NUM`` will be incremented with each test run.
+By default, entries older than 3 temporary directories will be removed.
+This behavior can be configured with :confval:`tmp_path_retention_count` and
+:confval:`tmp_path_retention_policy`.
+
+Using the ``--basetemp``
+option will remove the directory before every run, effectively meaning the temporary directories
+of only the most recent run will be kept.
+
+You can override the default temporary directory setting like this:
+
+.. code-block:: bash
+
+    pytest --basetemp=mydir
+
+.. warning::
+
+    The contents of ``mydir`` will be completely removed, so make sure to use a directory
+    for that purpose only.
+
+When distributing tests on the local machine using ``pytest-xdist``, care is taken to
+automatically configure a basetemp directory for the sub processes such that all temporary
+data lands below a single per-test run basetemp directory.
+
+.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
diff --git a/doc/en/how-to/unittest.rst b/doc/en/how-to/unittest.rst
new file mode 100644 (file)
index 0000000..7856c1a
--- /dev/null
@@ -0,0 +1,255 @@
+
+.. _`unittest.TestCase`:
+.. _`unittest`:
+
+How to use ``unittest``-based tests with pytest
+===============================================
+
+``pytest`` supports running Python ``unittest``-based tests out of the box.
+It's meant for leveraging existing ``unittest``-based test suites
+to use pytest as a test runner and also allow to incrementally adapt
+the test suite to take full advantage of pytest's features.
+
+To run an existing ``unittest``-style test suite using ``pytest``, type:
+
+.. code-block:: bash
+
+    pytest tests
+
+
+pytest will automatically collect ``unittest.TestCase`` subclasses and
+their ``test`` methods in ``test_*.py`` or ``*_test.py`` files.
+
+Almost all ``unittest`` features are supported:
+
+* ``@unittest.skip`` style decorators;
+* ``setUp/tearDown``;
+* ``setUpClass/tearDownClass``;
+* ``setUpModule/tearDownModule``;
+
+.. _`pytest-subtests`: https://github.com/pytest-dev/pytest-subtests
+.. _`load_tests protocol`: https://docs.python.org/3/library/unittest.html#load-tests-protocol
+
+Additionally, :ref:`subtests <python:subtests>` are supported by the
+`pytest-subtests`_ plugin.
+
+Up to this point pytest does not have support for the following features:
+
+* `load_tests protocol`_;
+
+Benefits out of the box
+-----------------------
+
+By running your test suite with pytest you can make use of several features,
+in most cases without having to modify existing code:
+
+* Obtain :ref:`more informative tracebacks <tbreportdemo>`;
+* :ref:`stdout and stderr <captures>` capturing;
+* :ref:`Test selection options <select-tests>` using ``-k`` and ``-m`` flags;
+* :ref:`maxfail`;
+* :ref:`--pdb <pdb-option>` command-line option for debugging on test failures
+  (see :ref:`note <pdb-unittest-note>` below);
+* Distribute tests to multiple CPUs using the :pypi:`pytest-xdist` plugin;
+* Use :ref:`plain assert-statements <assert>` instead of ``self.assert*`` functions
+  (:pypi:`unittest2pytest` is immensely helpful in this);
+
+
+pytest features in ``unittest.TestCase`` subclasses
+---------------------------------------------------
+
+The following pytest features work in ``unittest.TestCase`` subclasses:
+
+* :ref:`Marks <mark>`: :ref:`skip <skip>`, :ref:`skipif <skipif>`, :ref:`xfail <xfail>`;
+* :ref:`Auto-use fixtures <mixing-fixtures>`;
+
+The following pytest features **do not** work, and probably
+never will due to different design philosophies:
+
+* :ref:`Fixtures <fixture>` (except for ``autouse`` fixtures, see :ref:`below <mixing-fixtures>`);
+* :ref:`Parametrization <parametrize>`;
+* :ref:`Custom hooks <writing-plugins>`;
+
+
+Third party plugins may or may not work well, depending on the plugin and the test suite.
+
+.. _mixing-fixtures:
+
+Mixing pytest fixtures into ``unittest.TestCase`` subclasses using marks
+------------------------------------------------------------------------
+
+Running your unittest with ``pytest`` allows you to use its
+:ref:`fixture mechanism <fixture>` with ``unittest.TestCase`` style
+tests.  Assuming you have at least skimmed the pytest fixture features,
+let's jump-start into an example that integrates a pytest ``db_class``
+fixture, setting up a class-cached database object, and then reference
+it from a unittest-style test:
+
+.. code-block:: python
+
+    # content of conftest.py
+
+    # we define a fixture function below and it will be "used" by
+    # referencing its name from tests
+
+    import pytest
+
+
+    @pytest.fixture(scope="class")
+    def db_class(request):
+        class DummyDB:
+            pass
+
+        # set a class attribute on the invoking test context
+        request.cls.db = DummyDB()
+
+This defines a fixture function ``db_class`` which - if used - is
+called once for each test class and which sets the class-level
+``db`` attribute to a ``DummyDB`` instance.  The fixture function
+achieves this by receiving a special ``request`` object which gives
+access to :ref:`the requesting test context <request-context>` such
+as the ``cls`` attribute, denoting the class from which the fixture
+is used.  This architecture de-couples fixture writing from actual test
+code and allows re-use of the fixture by a minimal reference, the fixture
+name.  So let's write an actual ``unittest.TestCase`` class using our
+fixture definition:
+
+.. code-block:: python
+
+    # content of test_unittest_db.py
+
+    import unittest
+
+    import pytest
+
+
+    @pytest.mark.usefixtures("db_class")
+    class MyTest(unittest.TestCase):
+        def test_method1(self):
+            assert hasattr(self, "db")
+            assert 0, self.db  # fail for demo purposes
+
+        def test_method2(self):
+            assert 0, self.db  # fail for demo purposes
+
+The ``@pytest.mark.usefixtures("db_class")`` class-decorator makes sure that
+the pytest fixture function ``db_class`` is called once per class.
+Due to the deliberately failing assert statements, we can take a look at
+the ``self.db`` values in the traceback:
+
+.. code-block:: pytest
+
+    $ pytest test_unittest_db.py
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    collected 2 items
+
+    test_unittest_db.py FF                                               [100%]
+
+    ================================= FAILURES =================================
+    ___________________________ MyTest.test_method1 ____________________________
+
+    self = <test_unittest_db.MyTest testMethod=test_method1>
+
+        def test_method1(self):
+            assert hasattr(self, "db")
+    >       assert 0, self.db  # fail for demo purposes
+    E       AssertionError: <conftest.db_class.<locals>.DummyDB object at 0xdeadbeef0001>
+    E       assert 0
+
+    test_unittest_db.py:11: AssertionError
+    ___________________________ MyTest.test_method2 ____________________________
+
+    self = <test_unittest_db.MyTest testMethod=test_method2>
+
+        def test_method2(self):
+    >       assert 0, self.db  # fail for demo purposes
+    E       AssertionError: <conftest.db_class.<locals>.DummyDB object at 0xdeadbeef0001>
+    E       assert 0
+
+    test_unittest_db.py:14: AssertionError
+    ========================= short test summary info ==========================
+    FAILED test_unittest_db.py::MyTest::test_method1 - AssertionError: <conft...
+    FAILED test_unittest_db.py::MyTest::test_method2 - AssertionError: <conft...
+    ============================ 2 failed in 0.12s =============================
+
+This default pytest traceback shows that the two test methods
+share the same ``self.db`` instance which was our intention
+when writing the class-scoped fixture function above.
+
+
+Using autouse fixtures and accessing other fixtures
+---------------------------------------------------
+
+Although it's usually better to explicitly declare use of fixtures you need
+for a given test, you may sometimes want to have fixtures that are
+automatically used in a given context.  After all, the traditional
+style of unittest-setup mandates the use of this implicit fixture writing
+and chances are, you are used to it or like it.
+
+You can flag fixture functions with ``@pytest.fixture(autouse=True)``
+and define the fixture function in the context where you want it used.
+Let's look at an ``initdir`` fixture which makes all test methods of a
+``TestCase`` class execute in a temporary directory with a
+pre-initialized ``samplefile.ini``.  Our ``initdir`` fixture itself uses
+the pytest builtin :fixture:`tmp_path` fixture to delegate the
+creation of a per-test temporary directory:
+
+.. code-block:: python
+
+    # content of test_unittest_cleandir.py
+    import unittest
+
+    import pytest
+
+
+    class MyTest(unittest.TestCase):
+        @pytest.fixture(autouse=True)
+        def initdir(self, tmp_path, monkeypatch):
+            monkeypatch.chdir(tmp_path)  # change to pytest-provided temporary directory
+            tmp_path.joinpath("samplefile.ini").write_text("# testdata", encoding="utf-8")
+
+        def test_method(self):
+            with open("samplefile.ini", encoding="utf-8") as f:
+                s = f.read()
+            assert "testdata" in s
+
+Due to the ``autouse`` flag the ``initdir`` fixture function will be
+used for all methods of the class where it is defined.  This is a
+shortcut for using a ``@pytest.mark.usefixtures("initdir")`` marker
+on the class like in the previous example.
+
+Running this test module ...:
+
+.. code-block:: pytest
+
+    $ pytest -q test_unittest_cleandir.py
+    .                                                                    [100%]
+    1 passed in 0.12s
+
+... gives us one passed test because the ``initdir`` fixture function
+was executed ahead of the ``test_method``.
+
+.. note::
+
+   ``unittest.TestCase`` methods cannot directly receive fixture
+   arguments as implementing that is likely to inflict
+   on the ability to run general unittest.TestCase test suites.
+
+   The above ``usefixtures`` and ``autouse`` examples should help to mix in
+   pytest fixtures into unittest suites.
+
+   You can also gradually move away from subclassing from ``unittest.TestCase`` to *plain asserts*
+   and then start to benefit from the full pytest feature set step by step.
+
+.. _pdb-unittest-note:
+
+.. note::
+
+    Due to architectural differences between the two frameworks, setup and
+    teardown for ``unittest``-based tests is performed during the ``call`` phase
+    of testing instead of in ``pytest``'s standard ``setup`` and ``teardown``
+    stages. This can be important to understand in some situations, particularly
+    when reasoning about errors. For example, if a ``unittest``-based suite
+    exhibits errors during setup, ``pytest`` will report no errors during its
+    ``setup`` phase and will instead raise the error during ``call``.
diff --git a/doc/en/how-to/usage.rst b/doc/en/how-to/usage.rst
new file mode 100644 (file)
index 0000000..4ec4459
--- /dev/null
@@ -0,0 +1,217 @@
+
+.. _usage:
+
+How to invoke pytest
+==========================================
+
+..  seealso:: :ref:`Complete pytest command-line flag reference <command-line-flags>`
+
+In general, pytest is invoked with the command ``pytest`` (see below for :ref:`other ways to invoke pytest
+<invoke-other>`). This will execute all tests in all files whose names follow the form ``test_*.py`` or ``\*_test.py``
+in the current directory and its subdirectories. More generally, pytest follows :ref:`standard test discovery rules
+<test discovery>`.
+
+
+.. _select-tests:
+
+Specifying which tests to run
+------------------------------
+
+Pytest supports several ways to run and select tests from the command-line.
+
+**Run tests in a module**
+
+.. code-block:: bash
+
+    pytest test_mod.py
+
+**Run tests in a directory**
+
+.. code-block:: bash
+
+    pytest testing/
+
+**Run tests by keyword expressions**
+
+.. code-block:: bash
+
+    pytest -k 'MyClass and not method'
+
+This will run tests which contain names that match the given *string expression* (case-insensitive),
+which can include Python operators that use filenames, class names and function names as variables.
+The example above will run ``TestMyClass.test_something``  but not ``TestMyClass.test_method_simple``.
+Use ``""`` instead of ``''`` in expression when running this on Windows
+
+.. _nodeids:
+
+**Run tests by node ids**
+
+Each collected test is assigned a unique ``nodeid`` which consist of the module filename followed
+by specifiers like class names, function names and parameters from parametrization, separated by ``::`` characters.
+
+To run a specific test within a module:
+
+.. code-block:: bash
+
+    pytest test_mod.py::test_func
+
+
+Another example specifying a test method in the command line:
+
+.. code-block:: bash
+
+    pytest test_mod.py::TestClass::test_method
+
+**Run tests by marker expressions**
+
+.. code-block:: bash
+
+    pytest -m slow
+
+Will run all tests which are decorated with the ``@pytest.mark.slow`` decorator.
+
+For more information see :ref:`marks <mark>`.
+
+**Run tests from packages**
+
+.. code-block:: bash
+
+    pytest --pyargs pkg.testing
+
+This will import ``pkg.testing`` and use its filesystem location to find and run tests from.
+
+
+Getting help on version, option names, environment variables
+--------------------------------------------------------------
+
+.. code-block:: bash
+
+    pytest --version   # shows where pytest was imported from
+    pytest --fixtures  # show available builtin function arguments
+    pytest -h | --help # show help on command line and config file options
+
+
+.. _durations:
+
+Profiling test execution duration
+-------------------------------------
+
+.. versionchanged:: 6.0
+
+To get a list of the slowest 10 test durations over 1.0s long:
+
+.. code-block:: bash
+
+    pytest --durations=10 --durations-min=1.0
+
+By default, pytest will not show test durations that are too small (<0.005s) unless ``-vv`` is passed on the command-line.
+
+
+Managing loading of plugins
+-------------------------------
+
+Early loading plugins
+~~~~~~~~~~~~~~~~~~~~~~~
+
+You can early-load plugins (internal and external) explicitly in the command-line with the ``-p`` option::
+
+    pytest -p mypluginmodule
+
+The option receives a ``name`` parameter, which can be:
+
+* A full module dotted name, for example ``myproject.plugins``. This dotted name must be importable.
+* The entry-point name of a plugin. This is the name passed to ``setuptools`` when the plugin is
+  registered. For example to early-load the :pypi:`pytest-cov` plugin you can use::
+
+    pytest -p pytest_cov
+
+
+Disabling plugins
+~~~~~~~~~~~~~~~~~~
+
+To disable loading specific plugins at invocation time, use the ``-p`` option
+together with the prefix ``no:``.
+
+Example: to disable loading the plugin ``doctest``, which is responsible for
+executing doctest tests from text files, invoke pytest like this:
+
+.. code-block:: bash
+
+    pytest -p no:doctest
+
+
+.. _invoke-other:
+
+Other ways of calling pytest
+-----------------------------------------------------
+
+.. _invoke-python:
+
+Calling pytest through ``python -m pytest``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can invoke testing through the Python interpreter from the command line:
+
+.. code-block:: text
+
+    python -m pytest [...]
+
+This is almost equivalent to invoking the command line script ``pytest [...]``
+directly, except that calling via ``python`` will also add the current directory to ``sys.path``.
+
+
+.. _`pytest.main-usage`:
+
+Calling pytest from Python code
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+You can invoke ``pytest`` from Python code directly:
+
+.. code-block:: python
+
+    retcode = pytest.main()
+
+this acts as if you would call "pytest" from the command line.
+It will not raise :class:`SystemExit` but return the :ref:`exit code <exit-codes>` instead.
+If you don't pass it any arguments, ``main`` reads the arguments from the command line arguments of the process (:data:`sys.argv`), which may be undesirable.
+You can pass in options and arguments explicitly:
+
+.. code-block:: python
+
+    retcode = pytest.main(["-x", "mytestdir"])
+
+You can specify additional plugins to ``pytest.main``:
+
+.. code-block:: python
+
+    # content of myinvoke.py
+    import sys
+
+    import pytest
+
+
+    class MyPlugin:
+        def pytest_sessionfinish(self):
+            print("*** test run reporting finishing")
+
+
+    if __name__ == "__main__":
+        sys.exit(pytest.main(["-qq"], plugins=[MyPlugin()]))
+
+Running it will show that ``MyPlugin`` was added and its
+hook was invoked:
+
+.. code-block:: pytest
+
+    $ python myinvoke.py
+    *** test run reporting finishing
+
+
+.. note::
+
+    Calling ``pytest.main()`` will result in importing your tests and any modules
+    that they import. Due to the caching mechanism of python's import system,
+    making subsequent calls to ``pytest.main()`` from the same process will not
+    reflect changes to those files between the calls. For this reason, making
+    multiple calls to ``pytest.main()`` from the same process (in order to re-run
+    tests, for example) is not recommended.
diff --git a/doc/en/how-to/writing_hook_functions.rst b/doc/en/how-to/writing_hook_functions.rst
new file mode 100644 (file)
index 0000000..7137901
--- /dev/null
@@ -0,0 +1,353 @@
+.. _`writinghooks`:
+
+Writing hook functions
+======================
+
+
+.. _validation:
+
+hook function validation and execution
+--------------------------------------
+
+pytest calls hook functions from registered plugins for any
+given hook specification.  Let's look at a typical hook function
+for the ``pytest_collection_modifyitems(session, config,
+items)`` hook which pytest calls after collection of all test items is
+completed.
+
+When we implement a ``pytest_collection_modifyitems`` function in our plugin
+pytest will during registration verify that you use argument
+names which match the specification and bail out if not.
+
+Let's look at a possible implementation:
+
+.. code-block:: python
+
+    def pytest_collection_modifyitems(config, items):
+        # called after collection is completed
+        # you can modify the ``items`` list
+        ...
+
+Here, ``pytest`` will pass in ``config`` (the pytest config object)
+and ``items`` (the list of collected test items) but will not pass
+in the ``session`` argument because we didn't list it in the function
+signature.  This dynamic "pruning" of arguments allows ``pytest`` to
+be "future-compatible": we can introduce new hook named parameters without
+breaking the signatures of existing hook implementations.  It is one of
+the reasons for the general long-lived compatibility of pytest plugins.
+
+Note that hook functions other than ``pytest_runtest_*`` are not
+allowed to raise exceptions.  Doing so will break the pytest run.
+
+
+
+.. _firstresult:
+
+firstresult: stop at first non-None result
+-------------------------------------------
+
+Most calls to ``pytest`` hooks result in a **list of results** which contains
+all non-None results of the called hook functions.
+
+Some hook specifications use the ``firstresult=True`` option so that the hook
+call only executes until the first of N registered functions returns a
+non-None result which is then taken as result of the overall hook call.
+The remaining hook functions will not be called in this case.
+
+.. _`hookwrapper`:
+
+hookwrapper: executing around other hooks
+-------------------------------------------------
+
+.. currentmodule:: _pytest.core
+
+
+
+pytest plugins can implement hook wrappers which wrap the execution
+of other hook implementations.  A hook wrapper is a generator function
+which yields exactly once. When pytest invokes hooks it first executes
+hook wrappers and passes the same arguments as to the regular hooks.
+
+At the yield point of the hook wrapper pytest will execute the next hook
+implementations and return their result to the yield point in the form of
+a :py:class:`Result <pluggy._Result>` instance which encapsulates a result or
+exception info.  The yield point itself will thus typically not raise
+exceptions (unless there are bugs).
+
+Here is an example definition of a hook wrapper:
+
+.. code-block:: python
+
+    import pytest
+
+
+    @pytest.hookimpl(hookwrapper=True)
+    def pytest_pyfunc_call(pyfuncitem):
+        do_something_before_next_hook_executes()
+
+        outcome = yield
+        # outcome.excinfo may be None or a (cls, val, tb) tuple
+
+        res = outcome.get_result()  # will raise if outcome was exception
+
+        post_process_result(res)
+
+        outcome.force_result(new_res)  # to override the return value to the plugin system
+
+Note that hook wrappers don't return results themselves, they merely
+perform tracing or other side effects around the actual hook implementations.
+If the result of the underlying hook is a mutable object, they may modify
+that result but it's probably better to avoid it.
+
+For more information, consult the
+:ref:`pluggy documentation about hookwrappers <pluggy:hookwrappers>`.
+
+.. _plugin-hookorder:
+
+Hook function ordering / call example
+-------------------------------------
+
+For any given hook specification there may be more than one
+implementation and we thus generally view ``hook`` execution as a
+``1:N`` function call where ``N`` is the number of registered functions.
+There are ways to influence if a hook implementation comes before or
+after others, i.e.  the position in the ``N``-sized list of functions:
+
+.. code-block:: python
+
+    # Plugin 1
+    @pytest.hookimpl(tryfirst=True)
+    def pytest_collection_modifyitems(items):
+        # will execute as early as possible
+        ...
+
+
+    # Plugin 2
+    @pytest.hookimpl(trylast=True)
+    def pytest_collection_modifyitems(items):
+        # will execute as late as possible
+        ...
+
+
+    # Plugin 3
+    @pytest.hookimpl(hookwrapper=True)
+    def pytest_collection_modifyitems(items):
+        # will execute even before the tryfirst one above!
+        outcome = yield
+        # will execute after all non-hookwrappers executed
+
+Here is the order of execution:
+
+1. Plugin3's pytest_collection_modifyitems called until the yield point
+   because it is a hook wrapper.
+
+2. Plugin1's pytest_collection_modifyitems is called because it is marked
+   with ``tryfirst=True``.
+
+3. Plugin2's pytest_collection_modifyitems is called because it is marked
+   with ``trylast=True`` (but even without this mark it would come after
+   Plugin1).
+
+4. Plugin3's pytest_collection_modifyitems then executing the code after the yield
+   point.  The yield receives a :py:class:`Result <pluggy._Result>` instance which encapsulates
+   the result from calling the non-wrappers.  Wrappers shall not modify the result.
+
+It's possible to use ``tryfirst`` and ``trylast`` also in conjunction with
+``hookwrapper=True`` in which case it will influence the ordering of hookwrappers
+among each other.
+
+
+Declaring new hooks
+------------------------
+
+.. note::
+
+    This is a quick overview on how to add new hooks and how they work in general, but a more complete
+    overview can be found in `the pluggy documentation <https://pluggy.readthedocs.io/en/latest/>`__.
+
+.. currentmodule:: _pytest.hookspec
+
+Plugins and ``conftest.py`` files may declare new hooks that can then be
+implemented by other plugins in order to alter behaviour or interact with
+the new plugin:
+
+.. autofunction:: pytest_addhooks
+    :noindex:
+
+Hooks are usually declared as do-nothing functions that contain only
+documentation describing when the hook will be called and what return values
+are expected. The names of the functions must start with `pytest_` otherwise pytest won't recognize them.
+
+Here's an example. Let's assume this code is in the ``sample_hook.py`` module.
+
+.. code-block:: python
+
+    def pytest_my_hook(config):
+        """
+        Receives the pytest config and does things with it
+        """
+
+To register the hooks with pytest they need to be structured in their own module or class. This
+class or module can then be passed to the ``pluginmanager`` using the ``pytest_addhooks`` function
+(which itself is a hook exposed by pytest).
+
+.. code-block:: python
+
+    def pytest_addhooks(pluginmanager):
+        """This example assumes the hooks are grouped in the 'sample_hook' module."""
+        from my_app.tests import sample_hook
+
+        pluginmanager.add_hookspecs(sample_hook)
+
+For a real world example, see `newhooks.py`_ from `xdist <https://github.com/pytest-dev/pytest-xdist>`_.
+
+.. _`newhooks.py`: https://github.com/pytest-dev/pytest-xdist/blob/974bd566c599dc6a9ea291838c6f226197208b46/xdist/newhooks.py
+
+Hooks may be called both from fixtures or from other hooks. In both cases, hooks are called
+through the ``hook`` object, available in the ``config`` object. Most hooks receive a
+``config`` object directly, while fixtures may use the ``pytestconfig`` fixture which provides the same object.
+
+.. code-block:: python
+
+    @pytest.fixture()
+    def my_fixture(pytestconfig):
+        # call the hook called "pytest_my_hook"
+        # 'result' will be a list of return values from all registered functions.
+        result = pytestconfig.hook.pytest_my_hook(config=pytestconfig)
+
+.. note::
+    Hooks receive parameters using only keyword arguments.
+
+Now your hook is ready to be used. To register a function at the hook, other plugins or users must
+now simply define the function ``pytest_my_hook`` with the correct signature in their ``conftest.py``.
+
+Example:
+
+.. code-block:: python
+
+    def pytest_my_hook(config):
+        """
+        Print all active hooks to the screen.
+        """
+        print(config.hook)
+
+
+.. _`addoptionhooks`:
+
+
+Using hooks in pytest_addoption
+-------------------------------
+
+Occasionally, it is necessary to change the way in which command line options
+are defined by one plugin based on hooks in another plugin. For example,
+a plugin may expose a command line option for which another plugin needs
+to define the default value. The pluginmanager can be used to install and
+use hooks to accomplish this. The plugin would define and add the hooks
+and use pytest_addoption as follows:
+
+.. code-block:: python
+
+   # contents of hooks.py
+
+
+   # Use firstresult=True because we only want one plugin to define this
+   # default value
+   @hookspec(firstresult=True)
+   def pytest_config_file_default_value():
+       """Return the default value for the config file command line option."""
+
+
+   # contents of myplugin.py
+
+
+   def pytest_addhooks(pluginmanager):
+       """This example assumes the hooks are grouped in the 'hooks' module."""
+       from . import hooks
+
+       pluginmanager.add_hookspecs(hooks)
+
+
+   def pytest_addoption(parser, pluginmanager):
+       default_value = pluginmanager.hook.pytest_config_file_default_value()
+       parser.addoption(
+           "--config-file",
+           help="Config file to use, defaults to %(default)s",
+           default=default_value,
+       )
+
+The conftest.py that is using myplugin would simply define the hook as follows:
+
+.. code-block:: python
+
+    def pytest_config_file_default_value():
+        return "config.yaml"
+
+
+Optionally using hooks from 3rd party plugins
+---------------------------------------------
+
+Using new hooks from plugins as explained above might be a little tricky
+because of the standard :ref:`validation mechanism <validation>`:
+if you depend on a plugin that is not installed, validation will fail and
+the error message will not make much sense to your users.
+
+One approach is to defer the hook implementation to a new plugin instead of
+declaring the hook functions directly in your plugin module, for example:
+
+.. code-block:: python
+
+    # contents of myplugin.py
+
+
+    class DeferPlugin:
+        """Simple plugin to defer pytest-xdist hook functions."""
+
+        def pytest_testnodedown(self, node, error):
+            """standard xdist hook function."""
+
+
+    def pytest_configure(config):
+        if config.pluginmanager.hasplugin("xdist"):
+            config.pluginmanager.register(DeferPlugin())
+
+This has the added benefit of allowing you to conditionally install hooks
+depending on which plugins are installed.
+
+.. _plugin-stash:
+
+Storing data on items across hook functions
+-------------------------------------------
+
+Plugins often need to store data on :class:`~pytest.Item`\s in one hook
+implementation, and access it in another. One common solution is to just
+assign some private attribute directly on the item, but type-checkers like
+mypy frown upon this, and it may also cause conflicts with other plugins.
+So pytest offers a better way to do this, :attr:`item.stash <_pytest.nodes.Node.stash>`.
+
+To use the "stash" in your plugins, first create "stash keys" somewhere at the
+top level of your plugin:
+
+.. code-block:: python
+
+    been_there_key = pytest.StashKey[bool]()
+    done_that_key = pytest.StashKey[str]()
+
+then use the keys to stash your data at some point:
+
+.. code-block:: python
+
+    def pytest_runtest_setup(item: pytest.Item) -> None:
+        item.stash[been_there_key] = True
+        item.stash[done_that_key] = "no"
+
+and retrieve them at another point:
+
+.. code-block:: python
+
+    def pytest_runtest_teardown(item: pytest.Item) -> None:
+        if not item.stash[been_there_key]:
+            print("Oh?")
+        item.stash[done_that_key] = "yes!"
+
+Stashes are available on all node types (like :class:`~pytest.Class`,
+:class:`~pytest.Session`) and also on :class:`~pytest.Config`, if needed.
diff --git a/doc/en/how-to/writing_plugins.rst b/doc/en/how-to/writing_plugins.rst
new file mode 100644 (file)
index 0000000..6f32111
--- /dev/null
@@ -0,0 +1,462 @@
+.. _plugins:
+.. _`writing-plugins`:
+
+Writing plugins
+===============
+
+It is easy to implement `local conftest plugins`_ for your own project
+or `pip-installable plugins`_ that can be used throughout many projects,
+including third party projects.  Please refer to :ref:`using plugins` if you
+only want to use but not write plugins.
+
+A plugin contains one or multiple hook functions. :ref:`Writing hooks <writinghooks>`
+explains the basics and details of how you can write a hook function yourself.
+``pytest`` implements all aspects of configuration, collection, running and
+reporting by calling :ref:`well specified hooks <hook-reference>` of the following plugins:
+
+* builtin plugins: loaded from pytest's internal ``_pytest`` directory.
+
+* :ref:`external plugins <extplugins>`: modules discovered through
+  `setuptools entry points`_
+
+* `conftest.py plugins`_: modules auto-discovered in test directories
+
+In principle, each hook call is a ``1:N`` Python function call where ``N`` is the
+number of registered implementation functions for a given specification.
+All specifications and implementations follow the ``pytest_`` prefix
+naming convention, making them easy to distinguish and find.
+
+.. _`pluginorder`:
+
+Plugin discovery order at tool startup
+--------------------------------------
+
+``pytest`` loads plugin modules at tool startup in the following way:
+
+1. by scanning the command line for the ``-p no:name`` option
+   and *blocking* that plugin from being loaded (even builtin plugins can
+   be blocked this way). This happens before normal command-line parsing.
+
+2. by loading all builtin plugins.
+
+3. by scanning the command line for the ``-p name`` option
+   and loading the specified plugin. This happens before normal command-line parsing.
+
+4. by loading all plugins registered through `setuptools entry points`_.
+
+5. by loading all plugins specified through the :envvar:`PYTEST_PLUGINS` environment variable.
+
+6. by loading all :file:`conftest.py` files as inferred by the command line
+   invocation:
+
+   - if no test paths are specified, use the current dir as a test path
+   - if exists, load ``conftest.py`` and ``test*/conftest.py`` relative
+     to the directory part of the first test path. After the ``conftest.py``
+     file is loaded, load all plugins specified in its
+     :globalvar:`pytest_plugins` variable if present.
+
+   Note that pytest does not find ``conftest.py`` files in deeper nested
+   sub directories at tool startup.  It is usually a good idea to keep
+   your ``conftest.py`` file in the top level test or project root directory.
+
+7. by recursively loading all plugins specified by the
+   :globalvar:`pytest_plugins` variable in ``conftest.py`` files.
+
+
+.. _`pytest/plugin`: http://bitbucket.org/pytest-dev/pytest/src/tip/pytest/plugin/
+.. _`conftest.py plugins`:
+.. _`localplugin`:
+.. _`local conftest plugins`:
+
+conftest.py: local per-directory plugins
+----------------------------------------
+
+Local ``conftest.py`` plugins contain directory-specific hook
+implementations.  Hook Session and test running activities will
+invoke all hooks defined in ``conftest.py`` files closer to the
+root of the filesystem.  Example of implementing the
+``pytest_runtest_setup`` hook so that is called for tests in the ``a``
+sub directory but not for other directories::
+
+    a/conftest.py:
+        def pytest_runtest_setup(item):
+            # called for running each test in 'a' directory
+            print("setting up", item)
+
+    a/test_sub.py:
+        def test_sub():
+            pass
+
+    test_flat.py:
+        def test_flat():
+            pass
+
+Here is how you might run it::
+
+     pytest test_flat.py --capture=no  # will not show "setting up"
+     pytest a/test_sub.py --capture=no  # will show "setting up"
+
+.. note::
+    If you have ``conftest.py`` files which do not reside in a
+    python package directory (i.e. one containing an ``__init__.py``) then
+    "import conftest" can be ambiguous because there might be other
+    ``conftest.py`` files as well on your ``PYTHONPATH`` or ``sys.path``.
+    It is thus good practice for projects to either put ``conftest.py``
+    under a package scope or to never import anything from a
+    ``conftest.py`` file.
+
+    See also: :ref:`pythonpath`.
+
+.. note::
+    Some hooks should be implemented only in plugins or conftest.py files situated at the
+    tests root directory due to how pytest discovers plugins during startup,
+    see the documentation of each hook for details.
+
+Writing your own plugin
+-----------------------
+
+If you want to write a plugin, there are many real-life examples
+you can copy from:
+
+* a custom collection example plugin: :ref:`yaml plugin`
+* builtin plugins which provide pytest's own functionality
+* many :ref:`external plugins <plugin-list>` providing additional features
+
+All of these plugins implement :ref:`hooks <hook-reference>` and/or :ref:`fixtures <fixture>`
+to extend and add functionality.
+
+.. note::
+    Make sure to check out the excellent
+    `cookiecutter-pytest-plugin <https://github.com/pytest-dev/cookiecutter-pytest-plugin>`_
+    project, which is a `cookiecutter template <https://github.com/audreyr/cookiecutter>`_
+    for authoring plugins.
+
+    The template provides an excellent starting point with a working plugin,
+    tests running with tox, a comprehensive README file as well as a
+    pre-configured entry-point.
+
+Also consider :ref:`contributing your plugin to pytest-dev<submitplugin>`
+once it has some happy users other than yourself.
+
+
+.. _`setuptools entry points`:
+.. _`pip-installable plugins`:
+
+Making your plugin installable by others
+----------------------------------------
+
+If you want to make your plugin externally available, you
+may define a so-called entry point for your distribution so
+that ``pytest`` finds your plugin module. Entry points are
+a feature that is provided by :std:doc:`setuptools <setuptools:index>`.
+
+pytest looks up the ``pytest11`` entrypoint to discover its
+plugins, thus you can make your plugin available by defining
+it in your ``pyproject.toml`` file.
+
+.. sourcecode:: toml
+
+    # sample ./pyproject.toml file
+    [build-system]
+    requires = ["hatchling"]
+    build-backend = "hatchling.build"
+
+    [project]
+    name = "myproject"
+    classifiers = [
+        "Framework :: Pytest",
+    ]
+
+    [project.entry-points.pytest11]
+    myproject = "myproject.pluginmodule"
+
+If a package is installed this way, ``pytest`` will load
+``myproject.pluginmodule`` as a plugin which can define
+:ref:`hooks <hook-reference>`. Confirm registration with ``pytest --trace-config``
+
+.. note::
+
+    Make sure to include ``Framework :: Pytest`` in your list of
+    `PyPI classifiers <https://pypi.org/classifiers/>`_
+    to make it easy for users to find your plugin.
+
+
+.. _assertion-rewriting:
+
+Assertion Rewriting
+-------------------
+
+One of the main features of ``pytest`` is the use of plain assert
+statements and the detailed introspection of expressions upon
+assertion failures.  This is provided by "assertion rewriting" which
+modifies the parsed AST before it gets compiled to bytecode.  This is
+done via a :pep:`302` import hook which gets installed early on when
+``pytest`` starts up and will perform this rewriting when modules get
+imported.  However, since we do not want to test different bytecode
+from what you will run in production, this hook only rewrites test modules
+themselves (as defined by the :confval:`python_files` configuration option),
+and any modules which are part of plugins.
+Any other imported module will not be rewritten and normal assertion behaviour
+will happen.
+
+If you have assertion helpers in other modules where you would need
+assertion rewriting to be enabled you need to ask ``pytest``
+explicitly to rewrite this module before it gets imported.
+
+.. autofunction:: pytest.register_assert_rewrite
+    :noindex:
+
+This is especially important when you write a pytest plugin which is
+created using a package.  The import hook only treats ``conftest.py``
+files and any modules which are listed in the ``pytest11`` entrypoint
+as plugins.  As an example consider the following package::
+
+   pytest_foo/__init__.py
+   pytest_foo/plugin.py
+   pytest_foo/helper.py
+
+With the following typical ``setup.py`` extract:
+
+.. code-block:: python
+
+   setup(..., entry_points={"pytest11": ["foo = pytest_foo.plugin"]}, ...)
+
+In this case only ``pytest_foo/plugin.py`` will be rewritten.  If the
+helper module also contains assert statements which need to be
+rewritten it needs to be marked as such, before it gets imported.
+This is easiest by marking it for rewriting inside the
+``__init__.py`` module, which will always be imported first when a
+module inside a package is imported.  This way ``plugin.py`` can still
+import ``helper.py`` normally.  The contents of
+``pytest_foo/__init__.py`` will then need to look like this:
+
+.. code-block:: python
+
+   import pytest
+
+   pytest.register_assert_rewrite("pytest_foo.helper")
+
+
+Requiring/Loading plugins in a test module or conftest file
+-----------------------------------------------------------
+
+You can require plugins in a test module or a ``conftest.py`` file using :globalvar:`pytest_plugins`:
+
+.. code-block:: python
+
+    pytest_plugins = ["name1", "name2"]
+
+When the test module or conftest plugin is loaded the specified plugins
+will be loaded as well. Any module can be blessed as a plugin, including internal
+application modules:
+
+.. code-block:: python
+
+    pytest_plugins = "myapp.testsupport.myplugin"
+
+:globalvar:`pytest_plugins` are processed recursively, so note that in the example above
+if ``myapp.testsupport.myplugin`` also declares :globalvar:`pytest_plugins`, the contents
+of the variable will also be loaded as plugins, and so on.
+
+.. _`requiring plugins in non-root conftests`:
+
+.. note::
+    Requiring plugins using :globalvar:`pytest_plugins` variable in non-root
+    ``conftest.py`` files is deprecated.
+
+    This is important because ``conftest.py`` files implement per-directory
+    hook implementations, but once a plugin is imported, it will affect the
+    entire directory tree. In order to avoid confusion, defining
+    :globalvar:`pytest_plugins` in any ``conftest.py`` file which is not located in the
+    tests root directory is deprecated, and will raise a warning.
+
+This mechanism makes it easy to share fixtures within applications or even
+external applications without the need to create external plugins using
+the ``setuptools``'s entry point technique.
+
+Plugins imported by :globalvar:`pytest_plugins` will also automatically be marked
+for assertion rewriting (see :func:`pytest.register_assert_rewrite`).
+However for this to have any effect the module must not be
+imported already; if it was already imported at the time the
+:globalvar:`pytest_plugins` statement is processed, a warning will result and
+assertions inside the plugin will not be rewritten.  To fix this you
+can either call :func:`pytest.register_assert_rewrite` yourself before
+the module is imported, or you can arrange the code to delay the
+importing until after the plugin is registered.
+
+
+Accessing another plugin by name
+--------------------------------
+
+If a plugin wants to collaborate with code from
+another plugin it can obtain a reference through
+the plugin manager like this:
+
+.. sourcecode:: python
+
+    plugin = config.pluginmanager.get_plugin("name_of_plugin")
+
+If you want to look at the names of existing plugins, use
+the ``--trace-config`` option.
+
+
+.. _registering-markers:
+
+Registering custom markers
+--------------------------
+
+If your plugin uses any markers, you should register them so that they appear in
+pytest's help text and do not :ref:`cause spurious warnings <unknown-marks>`.
+For example, the following plugin would register ``cool_marker`` and
+``mark_with`` for all users:
+
+.. code-block:: python
+
+    def pytest_configure(config):
+        config.addinivalue_line("markers", "cool_marker: this one is for cool tests.")
+        config.addinivalue_line(
+            "markers", "mark_with(arg, arg2): this marker takes arguments."
+        )
+
+
+Testing plugins
+---------------
+
+pytest comes with a plugin named ``pytester`` that helps you write tests for
+your plugin code. The plugin is disabled by default, so you will have to enable
+it before you can use it.
+
+You can do so by adding the following line to a ``conftest.py`` file in your
+testing directory:
+
+.. code-block:: python
+
+    # content of conftest.py
+
+    pytest_plugins = ["pytester"]
+
+Alternatively you can invoke pytest with the ``-p pytester`` command line
+option.
+
+This will allow you to use the :py:class:`pytester <pytest.Pytester>`
+fixture for testing your plugin code.
+
+Let's demonstrate what you can do with the plugin with an example. Imagine we
+developed a plugin that provides a fixture ``hello`` which yields a function
+and we can invoke this function with one optional parameter. It will return a
+string value of ``Hello World!`` if we do not supply a value or ``Hello
+{value}!`` if we do supply a string value.
+
+.. code-block:: python
+
+    import pytest
+
+
+    def pytest_addoption(parser):
+        group = parser.getgroup("helloworld")
+        group.addoption(
+            "--name",
+            action="store",
+            dest="name",
+            default="World",
+            help='Default "name" for hello().',
+        )
+
+
+    @pytest.fixture
+    def hello(request):
+        name = request.config.getoption("name")
+
+        def _hello(name=None):
+            if not name:
+                name = request.config.getoption("name")
+            return f"Hello {name}!"
+
+        return _hello
+
+
+Now the ``pytester`` fixture provides a convenient API for creating temporary
+``conftest.py`` files and test files. It also allows us to run the tests and
+return a result object, with which we can assert the tests' outcomes.
+
+.. code-block:: python
+
+    def test_hello(pytester):
+        """Make sure that our plugin works."""
+
+        # create a temporary conftest.py file
+        pytester.makeconftest(
+            """
+            import pytest
+
+            @pytest.fixture(params=[
+                "Brianna",
+                "Andreas",
+                "Floris",
+            ])
+            def name(request):
+                return request.param
+        """
+        )
+
+        # create a temporary pytest test file
+        pytester.makepyfile(
+            """
+            def test_hello_default(hello):
+                assert hello() == "Hello World!"
+
+            def test_hello_name(hello, name):
+                assert hello(name) == "Hello {0}!".format(name)
+        """
+        )
+
+        # run all tests with pytest
+        result = pytester.runpytest()
+
+        # check that all 4 tests passed
+        result.assert_outcomes(passed=4)
+
+
+Additionally it is possible to copy examples to the ``pytester``'s isolated environment
+before running pytest on it. This way we can abstract the tested logic to separate files,
+which is especially useful for longer tests and/or longer ``conftest.py`` files.
+
+Note that for ``pytester.copy_example`` to work we need to set `pytester_example_dir`
+in our ``pytest.ini`` to tell pytest where to look for example files.
+
+.. code-block:: ini
+
+  # content of pytest.ini
+  [pytest]
+  pytester_example_dir = .
+
+
+.. code-block:: python
+
+    # content of test_example.py
+
+
+    def test_plugin(pytester):
+        pytester.copy_example("test_example.py")
+        pytester.runpytest("-k", "test_example")
+
+
+    def test_example():
+        pass
+
+.. code-block:: pytest
+
+    $ pytest
+    =========================== test session starts ============================
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
+    configfile: pytest.ini
+    collected 2 items
+
+    test_example.py ..                                                   [100%]
+
+    ============================ 2 passed in 0.12s =============================
+
+For more information about the result object that ``runpytest()`` returns, and
+the methods that it provides please check out the :py:class:`RunResult
+<_pytest.pytester.RunResult>` documentation.
diff --git a/doc/en/how-to/xunit_setup.rst b/doc/en/how-to/xunit_setup.rst
new file mode 100644 (file)
index 0000000..3de6681
--- /dev/null
@@ -0,0 +1,119 @@
+
+.. _`classic xunit`:
+.. _xunitsetup:
+
+How to implement xunit-style set-up
+========================================
+
+This section describes a classic and popular way how you can implement
+fixtures (setup and teardown test state) on a per-module/class/function basis.
+
+
+.. note::
+
+    While these setup/teardown methods are simple and familiar to those
+    coming from a ``unittest`` or ``nose`` background, you may also consider
+    using pytest's more powerful :ref:`fixture mechanism
+    <fixture>` which leverages the concept of dependency injection, allowing
+    for a more modular and more scalable approach for managing test state,
+    especially for larger projects and for functional testing.  You can
+    mix both fixture mechanisms in the same file but
+    test methods of ``unittest.TestCase`` subclasses
+    cannot receive fixture arguments.
+
+
+Module level setup/teardown
+--------------------------------------
+
+If you have multiple test functions and test classes in a single
+module you can optionally implement the following fixture methods
+which will usually be called once for all the functions:
+
+.. code-block:: python
+
+    def setup_module(module):
+        """setup any state specific to the execution of the given module."""
+
+
+    def teardown_module(module):
+        """teardown any state that was previously setup with a setup_module
+        method.
+        """
+
+As of pytest-3.0, the ``module`` parameter is optional.
+
+Class level setup/teardown
+----------------------------------
+
+Similarly, the following methods are called at class level before
+and after all test methods of the class are called:
+
+.. code-block:: python
+
+    @classmethod
+    def setup_class(cls):
+        """setup any state specific to the execution of the given class (which
+        usually contains tests).
+        """
+
+
+    @classmethod
+    def teardown_class(cls):
+        """teardown any state that was previously setup with a call to
+        setup_class.
+        """
+
+.. _xunit-method-setup:
+
+Method and function level setup/teardown
+-----------------------------------------------
+
+Similarly, the following methods are called around each method invocation:
+
+.. code-block:: python
+
+    def setup_method(self, method):
+        """setup any state tied to the execution of the given method in a
+        class.  setup_method is invoked for every test method of a class.
+        """
+
+
+    def teardown_method(self, method):
+        """teardown any state that was previously setup with a setup_method
+        call.
+        """
+
+As of pytest-3.0, the ``method`` parameter is optional.
+
+If you would rather define test functions directly at module level
+you can also use the following functions to implement fixtures:
+
+.. code-block:: python
+
+    def setup_function(function):
+        """setup any state tied to the execution of the given function.
+        Invoked for every test function in the module.
+        """
+
+
+    def teardown_function(function):
+        """teardown any state that was previously setup with a setup_function
+        call.
+        """
+
+As of pytest-3.0, the ``function`` parameter is optional.
+
+Remarks:
+
+* It is possible for setup/teardown pairs to be invoked multiple times
+  per testing process.
+
+* teardown functions are not called if the corresponding setup function existed
+  and failed/was skipped.
+
+* Prior to pytest-4.2, xunit-style functions did not obey the scope rules of fixtures, so
+  it was possible, for example, for a ``setup_method`` to be called before a
+  session-scoped autouse fixture.
+
+  Now the xunit-style functions are integrated with the fixture mechanism and obey the proper
+  scope rules of fixtures involved in the call.
index e8064a694ca8eff0f2167d29ad13609f9a99a46e..498e70485d214c242ab75ce24f93225223fc5f8c 100644 (file)
Binary files a/doc/en/img/pytest1.png and b/doc/en/img/pytest1.png differ
diff --git a/doc/en/img/pytest_logo_curves.svg b/doc/en/img/pytest_logo_curves.svg
new file mode 100644 (file)
index 0000000..e05ceb1
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="1500" height="1500" viewBox="0, 0, 1500, 1500">
+  <g id="pytest_logo">
+    <g id="graphics">
+      <path d="M521.576,213.75 L952.616,213.75 C964.283,213.75 973.741,223.208 973.741,234.875 L973.741,234.875 C973.741,246.542 964.283,256 952.616,256 L521.576,256 C509.909,256 500.451,246.542 500.451,234.875 L500.451,234.875 C500.451,223.208 509.909,213.75 521.576,213.75 z" fill="#696969" id="horizontal_bar"/>
+      <g id="top_bars">
+        <path d="M525.333,171 L612,171 L612,191 L525.333,191 L525.333,171 z" fill="#009FE3"/>
+        <path d="M638.667,171 L725.333,171 L725.333,191 L638.667,191 L638.667,171 z" fill="#C7D302"/>
+        <path d="M750.5,171 L837.167,171 L837.167,191 L750.5,191 L750.5,171 z" fill="#F07E16"/>
+        <path d="M861.861,171 L948.528,171 L948.528,191 L861.861,191 L861.861,171 z" fill="#DF2815"/>
+      </g>
+      <g id="bottom_bars">
+        <path d="M861.861,278 L948.528,278 L948.528,424.5 L861.861,424.5 L861.861,278 z" fill="#DF2815"/>
+        <path d="M750.5,278 L837.328,278 L837.328,516 L750.5,516 L750.5,278 z" fill="#F07E16"/>
+        <path d="M638.667,278 L725.328,278 L725.328,634.5 L638.667,634.5 L638.667,278 z" fill="#C7D302"/>
+        <path d="M525.333,278 L612,278 L612,712.5 L525.333,712.5 L525.333,278 z" fill="#009FE3"/>
+      </g>
+    </g>
+    <g id="pytest">
+      <path d="M252.959,1173.846 Q240.139,1173.846 229.71,1171.021 Q219.28,1168.196 210.914,1163.525 Q202.549,1158.853 196.139,1152.552 Q189.729,1146.25 184.732,1139.297 L182.124,1139.297 Q182.776,1146.685 183.428,1153.421 Q183.862,1159.07 184.297,1165.046 Q184.732,1171.021 184.732,1174.498 L184.732,1276.404 L145.186,1276.404 L145.186,930.921 L177.344,930.921 L182.993,963.079 L184.732,963.079 Q189.729,955.474 196.03,948.847 Q202.332,942.22 210.697,937.331 Q219.063,932.442 229.492,929.509 Q239.922,926.575 252.959,926.575 Q273.384,926.575 290.115,934.397 Q306.846,942.22 318.688,957.756 Q330.53,973.292 337.048,996.324 Q343.567,1019.356 343.567,1049.776 Q343.567,1080.413 337.048,1103.554 Q330.53,1126.695 318.688,1142.339 Q306.846,1157.984 290.115,1165.915 Q273.384,1173.846 252.959,1173.846 z M245.354,959.385 Q228.84,959.385 217.433,964.383 Q206.025,969.38 198.964,979.593 Q191.902,989.805 188.534,1005.015 Q185.166,1020.225 184.732,1040.867 L184.732,1049.776 Q184.732,1071.722 187.665,1088.779 Q190.598,1105.835 197.66,1117.46 Q204.722,1129.085 216.455,1135.06 Q228.189,1141.036 245.789,1141.036 Q275.122,1141.036 288.92,1117.352 Q302.717,1093.667 302.717,1049.341 Q302.717,1004.146 288.92,981.766 Q275.122,959.385 245.354,959.385 z" fill="#696969"/>
+      <path d="M370.293,930.921 L411.36,930.921 L458.076,1064.117 Q461.118,1072.808 464.269,1082.369 Q467.42,1091.929 470.136,1101.49 Q472.852,1111.05 474.807,1119.959 Q476.763,1128.868 477.632,1136.473 L478.936,1136.473 Q480.022,1131.041 482.412,1121.697 Q484.802,1112.354 487.736,1101.816 Q490.669,1091.277 493.82,1081.065 Q496.97,1070.853 499.36,1063.682 L542.6,930.921 L583.45,930.921 L489.148,1200.572 Q483.064,1218.172 476.002,1232.187 Q468.941,1246.202 459.597,1255.979 Q450.254,1265.757 437.651,1271.081 Q425.049,1276.404 407.666,1276.404 Q396.367,1276.404 388.11,1275.209 Q379.854,1274.014 373.987,1272.71 L373.987,1241.204 Q378.55,1242.291 385.503,1243.051 Q392.456,1243.812 400.061,1243.812 Q410.491,1243.812 418.096,1241.313 Q425.701,1238.814 431.35,1234.034 Q437,1229.253 441.019,1222.3 Q445.039,1215.347 448.298,1206.438 L460.684,1171.673 z" fill="#696969"/>
+      <path d="M695.568,1141.47 Q699.479,1141.47 704.368,1141.036 Q709.257,1140.601 713.82,1139.949 Q718.383,1139.297 722.186,1138.428 Q725.988,1137.559 727.944,1136.907 L727.944,1166.893 Q725.119,1168.196 720.773,1169.5 Q716.428,1170.804 711.213,1171.781 Q705.998,1172.759 700.349,1173.302 Q694.699,1173.846 689.267,1173.846 Q675.795,1173.846 664.279,1170.369 Q652.763,1166.893 644.398,1158.418 Q636.032,1149.944 631.252,1135.495 Q626.472,1121.045 626.472,1099.1 L626.472,960.689 L592.792,960.689 L592.792,943.089 L626.472,926.141 L643.42,876.165 L666.235,876.165 L666.235,930.921 L726.206,930.921 L726.206,960.689 L666.235,960.689 L666.235,1099.1 Q666.235,1120.176 673.079,1130.823 Q679.924,1141.47 695.568,1141.47 z" fill="#009FE3"/>
+      <path d="M868.527,1173.846 Q844.626,1173.846 824.853,1165.806 Q805.08,1157.767 790.848,1142.339 Q776.616,1126.912 768.793,1104.097 Q760.971,1081.282 760.971,1051.949 Q760.971,1022.398 768.142,999.148 Q775.312,975.899 788.349,959.711 Q801.386,943.523 819.529,935.049 Q837.673,926.575 859.619,926.575 Q881.13,926.575 898.295,934.289 Q915.461,942.002 927.412,956.017 Q939.362,970.032 945.772,989.697 Q952.182,1009.361 952.182,1033.262 L952.182,1057.815 L801.821,1057.815 Q802.907,1099.751 819.529,1119.524 Q836.152,1139.297 868.962,1139.297 Q880.043,1139.297 889.495,1138.211 Q898.947,1137.125 907.747,1135.06 Q916.547,1132.996 924.804,1129.845 Q933.061,1126.695 941.535,1122.784 L941.535,1157.984 Q932.844,1162.112 924.478,1165.154 Q916.113,1168.196 907.313,1170.152 Q898.513,1172.107 889.061,1172.977 Q879.609,1173.846 868.527,1173.846 z M858.749,959.385 Q833.979,959.385 819.529,976.333 Q805.08,993.282 802.69,1025.657 L909.594,1025.657 Q909.594,1010.882 906.661,998.605 Q903.727,986.329 897.535,977.637 Q891.342,968.946 881.782,964.166 Q872.221,959.385 858.749,959.385 z" fill="#009FE3"/>
+      <path d="M1155.126,1104.097 Q1155.126,1121.48 1148.825,1134.517 Q1142.524,1147.554 1130.682,1156.354 Q1118.84,1165.154 1102.109,1169.5 Q1085.378,1173.846 1064.518,1173.846 Q1040.834,1173.846 1023.886,1170.043 Q1006.938,1166.241 994.118,1158.853 L994.118,1122.784 Q1000.854,1126.26 1009.111,1129.628 Q1017.368,1132.996 1026.494,1135.604 Q1035.62,1138.211 1045.289,1139.841 Q1054.958,1141.47 1064.518,1141.47 Q1078.642,1141.47 1088.528,1139.08 Q1098.415,1136.69 1104.608,1132.236 Q1110.8,1127.781 1113.625,1121.371 Q1116.45,1114.961 1116.45,1107.139 Q1116.45,1100.403 1114.277,1094.971 Q1112.104,1089.539 1106.346,1084.216 Q1100.588,1078.892 1090.593,1073.46 Q1080.598,1068.028 1064.953,1061.292 Q1049.308,1054.556 1036.815,1048.038 Q1024.321,1041.519 1015.629,1033.479 Q1006.938,1025.44 1002.266,1014.902 Q997.595,1004.363 997.595,989.805 Q997.595,974.595 1003.57,962.753 Q1009.545,950.911 1020.41,942.872 Q1031.274,934.832 1046.484,930.704 Q1061.694,926.575 1080.38,926.575 Q1101.457,926.575 1118.948,931.138 Q1136.44,935.701 1152.084,943.089 L1138.395,975.03 Q1124.272,968.729 1109.388,964.057 Q1094.504,959.385 1079.077,959.385 Q1056.913,959.385 1046.266,966.664 Q1035.62,973.943 1035.62,987.415 Q1035.62,995.02 1038.118,1000.669 Q1040.617,1006.319 1046.701,1011.316 Q1052.785,1016.314 1062.997,1021.42 Q1073.21,1026.526 1088.42,1032.828 Q1104.064,1039.346 1116.341,1045.865 Q1128.618,1052.383 1137.309,1060.531 Q1146,1068.68 1150.563,1079.109 Q1155.126,1089.539 1155.126,1104.097 z" fill="#009FE3"/>
+      <path d="M1285.28,1141.47 Q1289.191,1141.47 1294.08,1141.036 Q1298.969,1140.601 1303.532,1139.949 Q1308.095,1139.297 1311.898,1138.428 Q1315.7,1137.559 1317.656,1136.907 L1317.656,1166.893 Q1314.831,1168.196 1310.485,1169.5 Q1306.14,1170.804 1300.925,1171.781 Q1295.71,1172.759 1290.06,1173.302 Q1284.411,1173.846 1278.979,1173.846 Q1265.507,1173.846 1253.991,1170.369 Q1242.475,1166.893 1234.109,1158.418 Q1225.744,1149.944 1220.964,1135.495 Q1216.183,1121.045 1216.183,1099.1 L1216.183,960.689 L1182.504,960.689 L1182.504,943.089 L1216.183,926.141 L1233.132,876.165 L1255.947,876.165 L1255.947,930.921 L1315.917,930.921 L1315.917,960.689 L1255.947,960.689 L1255.947,1099.1 Q1255.947,1120.176 1262.791,1130.823 Q1269.636,1141.47 1285.28,1141.47 z" fill="#009FE3"/>
+    </g>
+  </g>
+</svg>
index 58f6c1d86c7a11f4029715a9f5014f8abe79d833..bdee8b5dbd948bbdd53e1144dec1b2b61c6a2292 100644 (file)
@@ -2,20 +2,28 @@
 
 .. sidebar:: Next Open Trainings
 
-   - `Professional testing with Python <https://www.python-academy.com/courses/specialtopics/python_course_testing.html>`_, via Python Academy, February 1-3 2021, remote and Leipzig (Germany). **Early-bird discount available until January 15th**.
+   - `Professional Testing with Python <https://python-academy.com/courses/python_course_testing.html>`_, via `Python Academy <https://www.python-academy.com/>`_, **March 5th to 7th 2024** (3 day in-depth training), **Leipzig, Germany / Remote**
 
-   Also see `previous talks and blogposts <talks.html>`_.
+   Also see :doc:`previous talks and blogposts <talks>`.
 
 .. _features:
 
 pytest: helps you write better programs
 =======================================
 
+.. module:: pytest
 
-The ``pytest`` framework makes it easy to write small tests, yet
-scales to support complex functional testing for applications and libraries.
+The ``pytest`` framework makes it easy to write small, readable tests, and can
+scale to support complex functional testing for applications and libraries.
 
-An example of a simple test:
+
+``pytest`` requires: Python 3.7+ or PyPy3.
+
+**PyPI package name**: :pypi:`pytest`
+
+
+A quick example
+---------------
 
 .. code-block:: python
 
@@ -34,9 +42,8 @@ To execute it:
 
     $ pytest
     =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
+    platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
+    rootdir: /home/sweet/project
     collected 1 item
 
     test_sample.py F                                                     [100%]
@@ -55,7 +62,7 @@ To execute it:
     ============================ 1 failed in 0.12s =============================
 
 Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used.
-See :ref:`Getting Started <getstarted>` for more examples.
+See :ref:`Get started <getstarted>` for a basic introduction to using pytest.
 
 
 Features
@@ -69,15 +76,18 @@ Features
 
 - Can run :ref:`unittest <unittest>` (including trial) and :ref:`nose <noseintegration>` test suites out of the box
 
-- Python 3.6+ and PyPy 3
+- Python 3.7+ or PyPy 3
 
-- Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community
+- Rich plugin architecture, with over 800+ :ref:`external plugins <plugin-list>` and thriving community
 
 
 Documentation
 -------------
 
-Please see :ref:`Contents <toc>` for full documentation, including installation, tutorials and PDF documents.
+* :ref:`Get started <get-started>` - install pytest and grasp its basics just twenty minutes
+* :ref:`How-to guides <how-to>` - step-by-step guides, covering a vast range of use-cases and needs
+* :ref:`Reference guides <reference>` - includes the complete pytest API reference, lists of plugins and more
+* :ref:`Explanation <explanation>` - background, discussion of key topics, answers to higher-level questions
 
 
 Bugs/Requests
@@ -86,16 +96,11 @@ Bugs/Requests
 Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features.
 
 
-Changelog
----------
-
-Consult the :ref:`Changelog <changelog>` page for fixes and enhancements of each version.
-
 Support pytest
 --------------
 
 `Open Collective`_ is an online funding platform for open and transparent communities.
-It provide tools to raise money and share your finances in full transparency.
+It provides tools to raise money and share your finances in full transparency.
 
 It is the platform of choice for individuals and companies that want to make one-time or
 monthly donations directly to the project.
@@ -118,18 +123,8 @@ Save time, reduce risk, and improve code health, while paying the maintainers of
 `Learn more. <https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`_
 
 Security
-^^^^^^^^
+~~~~~~~~
 
 pytest has never been associated with a security vulnerability, but in any case, to report a
 security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
 Tidelift will coordinate the fix and disclosure.
-
-
-License
--------
-
-Copyright Holger Krekel and others, 2004-2020.
-
-Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
-
-.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE
index c6c10bbf358c4b1b16241b113c67a6dbff0e18f3..acbfb8bdb110e96798813a1b96fc4f871d74f826 100644 (file)
@@ -9,7 +9,7 @@ Distributed under the terms of the `MIT`_ license, pytest is free and open sourc
 
     The MIT License (MIT)
 
-    Copyright (c) 2004-2020 Holger Krekel and others
+    Copyright (c) 2004 Holger Krekel and others
 
     Permission is hereby granted, free of charge, to any person obtaining a copy of
     this software and associated documentation files (the "Software"), to deal in
@@ -29,4 +29,4 @@ Distributed under the terms of the `MIT`_ license, pytest is free and open sourc
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     SOFTWARE.
 
-.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE
+.. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE
diff --git a/doc/en/logging.rst b/doc/en/logging.rst
deleted file mode 100644 (file)
index 5271385..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-.. _logging:
-
-Logging
--------
-
-
-
-
-pytest captures log messages of level ``WARNING`` or above automatically and displays them in their own section
-for each failed test in the same manner as captured stdout and stderr.
-
-Running without options:
-
-.. code-block:: bash
-
-    pytest
-
-Shows failed tests like so:
-
-.. code-block:: pytest
-
-    ----------------------- Captured stdlog call ----------------------
-    test_reporting.py    26 WARNING  text going to logger
-    ----------------------- Captured stdout call ----------------------
-    text going to stdout
-    ----------------------- Captured stderr call ----------------------
-    text going to stderr
-    ==================== 2 failed in 0.02 seconds =====================
-
-By default each captured log message shows the module, line number, log level
-and message.
-
-If desired the log and date format can be specified to
-anything that the logging module supports by passing specific formatting options:
-
-.. code-block:: bash
-
-    pytest --log-format="%(asctime)s %(levelname)s %(message)s" \
-            --log-date-format="%Y-%m-%d %H:%M:%S"
-
-Shows failed tests like so:
-
-.. code-block:: pytest
-
-    ----------------------- Captured stdlog call ----------------------
-    2010-04-10 14:48:44 WARNING text going to logger
-    ----------------------- Captured stdout call ----------------------
-    text going to stdout
-    ----------------------- Captured stderr call ----------------------
-    text going to stderr
-    ==================== 2 failed in 0.02 seconds =====================
-
-These options can also be customized through ``pytest.ini`` file:
-
-.. code-block:: ini
-
-    [pytest]
-    log_format = %(asctime)s %(levelname)s %(message)s
-    log_date_format = %Y-%m-%d %H:%M:%S
-
-Further it is possible to disable reporting of captured content (stdout,
-stderr and logs) on failed tests completely with:
-
-.. code-block:: bash
-
-    pytest --show-capture=no
-
-
-caplog fixture
-^^^^^^^^^^^^^^
-
-Inside tests it is possible to change the log level for the captured log
-messages.  This is supported by the ``caplog`` fixture:
-
-.. code-block:: python
-
-    def test_foo(caplog):
-        caplog.set_level(logging.INFO)
-        pass
-
-By default the level is set on the root logger,
-however as a convenience it is also possible to set the log level of any
-logger:
-
-.. code-block:: python
-
-    def test_foo(caplog):
-        caplog.set_level(logging.CRITICAL, logger="root.baz")
-        pass
-
-The log levels set are restored automatically at the end of the test.
-
-It is also possible to use a context manager to temporarily change the log
-level inside a ``with`` block:
-
-.. code-block:: python
-
-    def test_bar(caplog):
-        with caplog.at_level(logging.INFO):
-            pass
-
-Again, by default the level of the root logger is affected but the level of any
-logger can be changed instead with:
-
-.. code-block:: python
-
-    def test_bar(caplog):
-        with caplog.at_level(logging.CRITICAL, logger="root.baz"):
-            pass
-
-Lastly all the logs sent to the logger during the test run are made available on
-the fixture in the form of both the ``logging.LogRecord`` instances and the final log text.
-This is useful for when you want to assert on the contents of a message:
-
-.. code-block:: python
-
-    def test_baz(caplog):
-        func_under_test()
-        for record in caplog.records:
-            assert record.levelname != "CRITICAL"
-        assert "wally" not in caplog.text
-
-For all the available attributes of the log records see the
-``logging.LogRecord`` class.
-
-You can also resort to ``record_tuples`` if all you want to do is to ensure,
-that certain messages have been logged under a given logger name with a given
-severity and message:
-
-.. code-block:: python
-
-    def test_foo(caplog):
-        logging.getLogger().info("boo %s", "arg")
-
-        assert caplog.record_tuples == [("root", logging.INFO, "boo arg")]
-
-You can call ``caplog.clear()`` to reset the captured log records in a test:
-
-.. code-block:: python
-
-    def test_something_with_clearing_records(caplog):
-        some_method_that_creates_log_records()
-        caplog.clear()
-        your_test_method()
-        assert ["Foo"] == [rec.message for rec in caplog.records]
-
-
-The ``caplog.records`` attribute contains records from the current stage only, so
-inside the ``setup`` phase it contains only setup logs, same with the ``call`` and
-``teardown`` phases.
-
-To access logs from other stages, use the ``caplog.get_records(when)`` method. As an example,
-if you want to make sure that tests which use a certain fixture never log any warnings, you can inspect
-the records for the ``setup`` and ``call`` stages during teardown like so:
-
-.. code-block:: python
-
-    @pytest.fixture
-    def window(caplog):
-        window = create_window()
-        yield window
-        for when in ("setup", "call"):
-            messages = [
-                x.message for x in caplog.get_records(when) if x.levelno == logging.WARNING
-            ]
-            if messages:
-                pytest.fail(
-                    "warning messages encountered during testing: {}".format(messages)
-                )
-
-
-
-The full API is available at :class:`_pytest.logging.LogCaptureFixture`.
-
-
-.. _live_logs:
-
-Live Logs
-^^^^^^^^^
-
-By setting the :confval:`log_cli` configuration option to ``true``, pytest will output
-logging records as they are emitted directly into the console.
-
-You can specify the logging level for which log records with equal or higher
-level are printed to the console by passing ``--log-cli-level``. This setting
-accepts the logging level names as seen in python's documentation or an integer
-as the logging level num.
-
-Additionally, you can also specify ``--log-cli-format`` and
-``--log-cli-date-format`` which mirror and default to ``--log-format`` and
-``--log-date-format`` if not provided, but are applied only to the console
-logging handler.
-
-All of the CLI log options can also be set in the configuration INI file. The
-option names are:
-
-* ``log_cli_level``
-* ``log_cli_format``
-* ``log_cli_date_format``
-
-If you need to record the whole test suite logging calls to a file, you can pass
-``--log-file=/path/to/log/file``. This log file is opened in write mode which
-means that it will be overwritten at each run tests session.
-
-You can also specify the logging level for the log file by passing
-``--log-file-level``. This setting accepts the logging level names as seen in
-python's documentation(ie, uppercased level names) or an integer as the logging
-level num.
-
-Additionally, you can also specify ``--log-file-format`` and
-``--log-file-date-format`` which are equal to ``--log-format`` and
-``--log-date-format`` but are applied to the log file logging handler.
-
-All of the log file options can also be set in the configuration INI file. The
-option names are:
-
-* ``log_file``
-* ``log_file_level``
-* ``log_file_format``
-* ``log_file_date_format``
-
-You can call ``set_log_path()`` to customize the log_file path dynamically. This functionality
-is considered **experimental**.
-
-.. _log_release_notes:
-
-Release notes
-^^^^^^^^^^^^^
-
-This feature was introduced as a drop-in replacement for the `pytest-catchlog
-<https://pypi.org/project/pytest-catchlog/>`_ plugin and they conflict
-with each other. The backward compatibility API with ``pytest-capturelog``
-has been dropped when this feature was introduced, so if for that reason you
-still need ``pytest-catchlog`` you can disable the internal feature by
-adding to your ``pytest.ini``:
-
-.. code-block:: ini
-
-   [pytest]
-       addopts=-p no:logging
-
-
-.. _log_changes_3_4:
-
-Incompatible changes in pytest 3.4
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-This feature was introduced in ``3.3`` and some **incompatible changes** have been
-made in ``3.4`` after community feedback:
-
-* Log levels are no longer changed unless explicitly requested by the :confval:`log_level` configuration
-  or ``--log-level`` command-line options. This allows users to configure logger objects themselves.
-  Setting :confval:`log_level` will set the level that is captured globally so if a specific test requires
-  a lower level than this, use the ``caplog.set_level()`` functionality otherwise that test will be prone to
-  failure.
-* :ref:`Live Logs <live_logs>` is now disabled by default and can be enabled setting the
-  :confval:`log_cli` configuration option to ``true``. When enabled, the verbosity is increased so logging for each
-  test is visible.
-* :ref:`Live Logs <live_logs>` are now sent to ``sys.stdout`` and no longer require the ``-s`` command-line option
-  to work.
-
-If you want to partially restore the logging behavior of version ``3.3``, you can add this options to your ``ini``
-file:
-
-.. code-block:: ini
-
-    [pytest]
-    log_cli=true
-    log_level=NOTSET
-
-More details about the discussion that lead to this changes can be read in
-issue `#3013 <https://github.com/pytest-dev/pytest/issues/3013>`_.
diff --git a/doc/en/mark.rst b/doc/en/mark.rst
deleted file mode 100644 (file)
index 7370342..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-.. _mark:
-
-Marking test functions with attributes
-======================================
-
-By using the ``pytest.mark`` helper you can easily set
-metadata on your test functions. You can find the full list of builtin markers
-in the :ref:`API Reference<marks ref>`. Or you can list all the markers, including
-builtin and custom, using the CLI - :code:`pytest --markers`.
-
-Here are some of the builtin markers:
-
-* :ref:`usefixtures <usefixtures>` - use fixtures on a test function or class
-* :ref:`filterwarnings <filterwarnings>` - filter certain warnings of a test function
-* :ref:`skip <skip>` - always skip a test function
-* :ref:`skipif <skipif>` - skip a test function if a certain condition is met
-* :ref:`xfail <xfail>` - produce an "expected failure" outcome if a certain
-  condition is met
-* :ref:`parametrize <parametrizemark>` - perform multiple calls
-  to the same test function.
-
-It's easy to create custom markers or to apply markers
-to whole test classes or modules. Those markers can be used by plugins, and also
-are commonly used to :ref:`select tests <mark run>` on the command-line with the ``-m`` option.
-
-See :ref:`mark examples` for examples which also serve as documentation.
-
-.. note::
-
-    Marks can only be applied to tests, having no effect on
-    :ref:`fixtures <fixtures>`.
-
-
-Registering marks
------------------
-
-You can register custom marks in your ``pytest.ini`` file like this:
-
-.. code-block:: ini
-
-    [pytest]
-    markers =
-        slow: marks tests as slow (deselect with '-m "not slow"')
-        serial
-
-or in your ``pyproject.toml`` file like this:
-
-.. code-block:: toml
-
-    [tool.pytest.ini_options]
-    markers = [
-        "slow: marks tests as slow (deselect with '-m \"not slow\"')",
-        "serial",
-    ]
-
-Note that everything past the ``:`` after the mark name is an optional description.
-
-Alternatively, you can register new markers programmatically in a
-:ref:`pytest_configure <initialization-hooks>` hook:
-
-.. code-block:: python
-
-    def pytest_configure(config):
-        config.addinivalue_line(
-            "markers", "env(name): mark test to run only on named environment"
-        )
-
-
-Registered marks appear in pytest's help text and do not emit warnings (see the next section). It
-is recommended that third-party plugins always :ref:`register their markers <registering-markers>`.
-
-.. _unknown-marks:
-
-Raising errors on unknown marks
--------------------------------
-
-Unregistered marks applied with the ``@pytest.mark.name_of_the_mark`` decorator
-will always emit a warning in order to avoid silently doing something
-surprising due to mistyped names. As described in the previous section, you can disable
-the warning for custom marks by registering them in your ``pytest.ini`` file or
-using a custom ``pytest_configure`` hook.
-
-When the ``--strict-markers`` command-line flag is passed, any unknown marks applied
-with the ``@pytest.mark.name_of_the_mark`` decorator will trigger an error. You can
-enforce this validation in your project by adding ``--strict-markers`` to ``addopts``:
-
-.. code-block:: ini
-
-    [pytest]
-    addopts = --strict-markers
-    markers =
-        slow: marks tests as slow (deselect with '-m "not slow"')
-        serial
diff --git a/doc/en/monkeypatch.rst b/doc/en/monkeypatch.rst
deleted file mode 100644 (file)
index 9480f00..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-
-Monkeypatching/mocking modules and environments
-================================================================
-
-.. currentmodule:: _pytest.monkeypatch
-
-Sometimes tests need to invoke functionality which depends
-on global settings or which invokes code which cannot be easily
-tested such as network access.  The ``monkeypatch`` fixture
-helps you to safely set/delete an attribute, dictionary item or
-environment variable, or to modify ``sys.path`` for importing.
-
-The ``monkeypatch`` fixture provides these helper methods for safely patching and mocking
-functionality in tests:
-
-.. code-block:: python
-
-    monkeypatch.setattr(obj, name, value, raising=True)
-    monkeypatch.delattr(obj, name, raising=True)
-    monkeypatch.setitem(mapping, name, value)
-    monkeypatch.delitem(obj, name, raising=True)
-    monkeypatch.setenv(name, value, prepend=False)
-    monkeypatch.delenv(name, raising=True)
-    monkeypatch.syspath_prepend(path)
-    monkeypatch.chdir(path)
-
-All modifications will be undone after the requesting
-test function or fixture has finished. The ``raising``
-parameter determines if a ``KeyError`` or ``AttributeError``
-will be raised if the target of the set/deletion operation does not exist.
-
-Consider the following scenarios:
-
-1. Modifying the behavior of a function or the property of a class for a test e.g.
-there is an API call or database connection you will not make for a test but you know
-what the expected output should be. Use :py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` to patch the
-function or property with your desired testing behavior. This can include your own functions.
-Use :py:meth:`monkeypatch.delattr <MonkeyPatch.delattr>` to remove the function or property for the test.
-
-2. Modifying the values of dictionaries e.g. you have a global configuration that
-you want to modify for certain test cases. Use :py:meth:`monkeypatch.setitem <MonkeyPatch.setitem>` to patch the
-dictionary for the test. :py:meth:`monkeypatch.delitem <MonkeyPatch.delitem>` can be used to remove items.
-
-3. Modifying environment variables for a test e.g. to test program behavior if an
-environment variable is missing, or to set multiple values to a known variable.
-:py:meth:`monkeypatch.setenv <MonkeyPatch.setenv>` and :py:meth:`monkeypatch.delenv <MonkeyPatch.delenv>` can be used for
-these patches.
-
-4. Use ``monkeypatch.setenv("PATH", value, prepend=os.pathsep)`` to modify ``$PATH``, and
-:py:meth:`monkeypatch.chdir <MonkeyPatch.chdir>` to change the context of the current working directory
-during a test.
-
-5. Use :py:meth:`monkeypatch.syspath_prepend <MonkeyPatch.syspath_prepend>` to modify ``sys.path`` which will also
-call ``pkg_resources.fixup_namespace_packages`` and :py:func:`importlib.invalidate_caches`.
-
-See the `monkeypatch blog post`_ for some introduction material
-and a discussion of its motivation.
-
-.. _`monkeypatch blog post`: http://tetamap.wordpress.com/2009/03/03/monkeypatching-in-unit-tests-done-right/
-
-Simple example: monkeypatching functions
-----------------------------------------
-
-Consider a scenario where you are working with user directories. In the context of
-testing, you do not want your test to depend on the running user. ``monkeypatch``
-can be used to patch functions dependent on the user to always return a
-specific value.
-
-In this example, :py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` is used to patch ``Path.home``
-so that the known testing path ``Path("/abc")`` is always used when the test is run.
-This removes any dependency on the running user for testing purposes.
-:py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` must be called before the function which will use
-the patched function is called.
-After the test function finishes the ``Path.home`` modification will be undone.
-
-.. code-block:: python
-
-    # contents of test_module.py with source code and the test
-    from pathlib import Path
-
-
-    def getssh():
-        """Simple function to return expanded homedir ssh path."""
-        return Path.home() / ".ssh"
-
-
-    def test_getssh(monkeypatch):
-        # mocked return function to replace Path.home
-        # always return '/abc'
-        def mockreturn():
-            return Path("/abc")
-
-        # Application of the monkeypatch to replace Path.home
-        # with the behavior of mockreturn defined above.
-        monkeypatch.setattr(Path, "home", mockreturn)
-
-        # Calling getssh() will use mockreturn in place of Path.home
-        # for this test with the monkeypatch.
-        x = getssh()
-        assert x == Path("/abc/.ssh")
-
-Monkeypatching returned objects: building mock classes
-------------------------------------------------------
-
-:py:meth:`monkeypatch.setattr <MonkeyPatch.setattr>` can be used in conjunction with classes to mock returned
-objects from functions instead of values.
-Imagine a simple function to take an API url and return the json response.
-
-.. code-block:: python
-
-    # contents of app.py, a simple API retrieval example
-    import requests
-
-
-    def get_json(url):
-        """Takes a URL, and returns the JSON."""
-        r = requests.get(url)
-        return r.json()
-
-We need to mock ``r``, the returned response object for testing purposes.
-The mock of ``r`` needs a ``.json()`` method which returns a dictionary.
-This can be done in our test file by defining a class to represent ``r``.
-
-.. code-block:: python
-
-    # contents of test_app.py, a simple test for our API retrieval
-    # import requests for the purposes of monkeypatching
-    import requests
-
-    # our app.py that includes the get_json() function
-    # this is the previous code block example
-    import app
-
-    # custom class to be the mock return value
-    # will override the requests.Response returned from requests.get
-    class MockResponse:
-
-        # mock json() method always returns a specific testing dictionary
-        @staticmethod
-        def json():
-            return {"mock_key": "mock_response"}
-
-
-    def test_get_json(monkeypatch):
-
-        # Any arguments may be passed and mock_get() will always return our
-        # mocked object, which only has the .json() method.
-        def mock_get(*args, **kwargs):
-            return MockResponse()
-
-        # apply the monkeypatch for requests.get to mock_get
-        monkeypatch.setattr(requests, "get", mock_get)
-
-        # app.get_json, which contains requests.get, uses the monkeypatch
-        result = app.get_json("https://fakeurl")
-        assert result["mock_key"] == "mock_response"
-
-
-``monkeypatch`` applies the mock for ``requests.get`` with our ``mock_get`` function.
-The ``mock_get`` function returns an instance of the ``MockResponse`` class, which
-has a ``json()`` method defined to return a known testing dictionary and does not
-require any outside API connection.
-
-You can build the ``MockResponse`` class with the appropriate degree of complexity for
-the scenario you are testing. For instance, it could include an ``ok`` property that
-always returns ``True``, or return different values from the ``json()`` mocked method
-based on input strings.
-
-This mock can be shared across tests using a ``fixture``:
-
-.. code-block:: python
-
-    # contents of test_app.py, a simple test for our API retrieval
-    import pytest
-    import requests
-
-    # app.py that includes the get_json() function
-    import app
-
-    # custom class to be the mock return value of requests.get()
-    class MockResponse:
-        @staticmethod
-        def json():
-            return {"mock_key": "mock_response"}
-
-
-    # monkeypatched requests.get moved to a fixture
-    @pytest.fixture
-    def mock_response(monkeypatch):
-        """Requests.get() mocked to return {'mock_key':'mock_response'}."""
-
-        def mock_get(*args, **kwargs):
-            return MockResponse()
-
-        monkeypatch.setattr(requests, "get", mock_get)
-
-
-    # notice our test uses the custom fixture instead of monkeypatch directly
-    def test_get_json(mock_response):
-        result = app.get_json("https://fakeurl")
-        assert result["mock_key"] == "mock_response"
-
-
-Furthermore, if the mock was designed to be applied to all tests, the ``fixture`` could
-be moved to a ``conftest.py`` file and use the with ``autouse=True`` option.
-
-
-Global patch example: preventing "requests" from remote operations
-------------------------------------------------------------------
-
-If you want to prevent the "requests" library from performing http
-requests in all your tests, you can do:
-
-.. code-block:: python
-
-    # contents of conftest.py
-    import pytest
-
-
-    @pytest.fixture(autouse=True)
-    def no_requests(monkeypatch):
-        """Remove requests.sessions.Session.request for all tests."""
-        monkeypatch.delattr("requests.sessions.Session.request")
-
-This autouse fixture will be executed for each test function and it
-will delete the method ``request.session.Session.request``
-so that any attempts within tests to create http requests will fail.
-
-
-.. note::
-
-    Be advised that it is not recommended to patch builtin functions such as ``open``,
-    ``compile``, etc., because it might break pytest's internals. If that's
-    unavoidable, passing ``--tb=native``, ``--assert=plain`` and ``--capture=no`` might
-    help although there's no guarantee.
-
-.. note::
-
-    Mind that patching ``stdlib`` functions and some third-party libraries used by pytest
-    might break pytest itself, therefore in those cases it is recommended to use
-    :meth:`MonkeyPatch.context` to limit the patching to the block you want tested:
-
-    .. code-block:: python
-
-        import functools
-
-
-        def test_partial(monkeypatch):
-            with monkeypatch.context() as m:
-                m.setattr(functools, "partial", 3)
-                assert functools.partial == 3
-
-    See issue `#3290 <https://github.com/pytest-dev/pytest/issues/3290>`_ for details.
-
-
-Monkeypatching environment variables
-------------------------------------
-
-If you are working with environment variables you often need to safely change the values
-or delete them from the system for testing purposes. ``monkeypatch`` provides a mechanism
-to do this using the ``setenv`` and ``delenv`` method. Our example code to test:
-
-.. code-block:: python
-
-    # contents of our original code file e.g. code.py
-    import os
-
-
-    def get_os_user_lower():
-        """Simple retrieval function.
-        Returns lowercase USER or raises OSError."""
-        username = os.getenv("USER")
-
-        if username is None:
-            raise OSError("USER environment is not set.")
-
-        return username.lower()
-
-There are two potential paths. First, the ``USER`` environment variable is set to a
-value. Second, the ``USER`` environment variable does not exist. Using ``monkeypatch``
-both paths can be safely tested without impacting the running environment:
-
-.. code-block:: python
-
-    # contents of our test file e.g. test_code.py
-    import pytest
-
-
-    def test_upper_to_lower(monkeypatch):
-        """Set the USER env var to assert the behavior."""
-        monkeypatch.setenv("USER", "TestingUser")
-        assert get_os_user_lower() == "testinguser"
-
-
-    def test_raise_exception(monkeypatch):
-        """Remove the USER env var and assert OSError is raised."""
-        monkeypatch.delenv("USER", raising=False)
-
-        with pytest.raises(OSError):
-            _ = get_os_user_lower()
-
-This behavior can be moved into ``fixture`` structures and shared across tests:
-
-.. code-block:: python
-
-    # contents of our test file e.g. test_code.py
-    import pytest
-
-
-    @pytest.fixture
-    def mock_env_user(monkeypatch):
-        monkeypatch.setenv("USER", "TestingUser")
-
-
-    @pytest.fixture
-    def mock_env_missing(monkeypatch):
-        monkeypatch.delenv("USER", raising=False)
-
-
-    # notice the tests reference the fixtures for mocks
-    def test_upper_to_lower(mock_env_user):
-        assert get_os_user_lower() == "testinguser"
-
-
-    def test_raise_exception(mock_env_missing):
-        with pytest.raises(OSError):
-            _ = get_os_user_lower()
-
-
-Monkeypatching dictionaries
----------------------------
-
-:py:meth:`monkeypatch.setitem <MonkeyPatch.setitem>` can be used to safely set the values of dictionaries
-to specific values during tests. Take this simplified connection string example:
-
-.. code-block:: python
-
-    # contents of app.py to generate a simple connection string
-    DEFAULT_CONFIG = {"user": "user1", "database": "db1"}
-
-
-    def create_connection_string(config=None):
-        """Creates a connection string from input or defaults."""
-        config = config or DEFAULT_CONFIG
-        return f"User Id={config['user']}; Location={config['database']};"
-
-For testing purposes we can patch the ``DEFAULT_CONFIG`` dictionary to specific values.
-
-.. code-block:: python
-
-    # contents of test_app.py
-    # app.py with the connection string function (prior code block)
-    import app
-
-
-    def test_connection(monkeypatch):
-
-        # Patch the values of DEFAULT_CONFIG to specific
-        # testing values only for this test.
-        monkeypatch.setitem(app.DEFAULT_CONFIG, "user", "test_user")
-        monkeypatch.setitem(app.DEFAULT_CONFIG, "database", "test_db")
-
-        # expected result based on the mocks
-        expected = "User Id=test_user; Location=test_db;"
-
-        # the test uses the monkeypatched dictionary settings
-        result = app.create_connection_string()
-        assert result == expected
-
-You can use the :py:meth:`monkeypatch.delitem <MonkeyPatch.delitem>` to remove values.
-
-.. code-block:: python
-
-    # contents of test_app.py
-    import pytest
-
-    # app.py with the connection string function
-    import app
-
-
-    def test_missing_user(monkeypatch):
-
-        # patch the DEFAULT_CONFIG t be missing the 'user' key
-        monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
-
-        # Key error expected because a config is not passed, and the
-        # default is now missing the 'user' entry.
-        with pytest.raises(KeyError):
-            _ = app.create_connection_string()
-
-
-The modularity of fixtures gives you the flexibility to define
-separate fixtures for each potential mock and reference them in the needed tests.
-
-.. code-block:: python
-
-    # contents of test_app.py
-    import pytest
-
-    # app.py with the connection string function
-    import app
-
-    # all of the mocks are moved into separated fixtures
-    @pytest.fixture
-    def mock_test_user(monkeypatch):
-        """Set the DEFAULT_CONFIG user to test_user."""
-        monkeypatch.setitem(app.DEFAULT_CONFIG, "user", "test_user")
-
-
-    @pytest.fixture
-    def mock_test_database(monkeypatch):
-        """Set the DEFAULT_CONFIG database to test_db."""
-        monkeypatch.setitem(app.DEFAULT_CONFIG, "database", "test_db")
-
-
-    @pytest.fixture
-    def mock_missing_default_user(monkeypatch):
-        """Remove the user key from DEFAULT_CONFIG"""
-        monkeypatch.delitem(app.DEFAULT_CONFIG, "user", raising=False)
-
-
-    # tests reference only the fixture mocks that are needed
-    def test_connection(mock_test_user, mock_test_database):
-
-        expected = "User Id=test_user; Location=test_db;"
-
-        result = app.create_connection_string()
-        assert result == expected
-
-
-    def test_missing_user(mock_missing_default_user):
-
-        with pytest.raises(KeyError):
-            _ = app.create_connection_string()
-
-
-.. currentmodule:: _pytest.monkeypatch
-
-API Reference
--------------
-
-Consult the docs for the :class:`MonkeyPatch` class.
diff --git a/doc/en/nose.rst b/doc/en/nose.rst
deleted file mode 100644 (file)
index e16d764..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-.. _`noseintegration`:
-
-Running tests written for nose
-=======================================
-
-``pytest`` has basic support for running tests written for nose_.
-
-.. _nosestyle:
-
-Usage
--------------
-
-After :ref:`installation` type:
-
-.. code-block:: bash
-
-    python setup.py develop  # make sure tests can import our package
-    pytest  # instead of 'nosetests'
-
-and you should be able to run your nose style tests and
-make use of pytest's capabilities.
-
-Supported nose Idioms
-----------------------
-
-* setup and teardown at module/class/method level
-* SkipTest exceptions and markers
-* setup/teardown decorators
-* ``__test__`` attribute on modules/classes/functions
-* general usage of nose utilities
-
-Unsupported idioms / known issues
-----------------------------------
-
-- unittest-style ``setUp, tearDown, setUpClass, tearDownClass``
-  are recognized only on ``unittest.TestCase`` classes but not
-  on plain classes.  ``nose`` supports these methods also on plain
-  classes but pytest deliberately does not.  As nose and pytest already
-  both support ``setup_class, teardown_class, setup_method, teardown_method``
-  it doesn't seem useful to duplicate the unittest-API like nose does.
-  If you however rather think pytest should support the unittest-spelling on
-  plain classes please post `to this issue
-  <https://github.com/pytest-dev/pytest/issues/377/>`_.
-
-- nose imports test modules with the same import path (e.g.
-  ``tests.test_mode``) but different file system paths
-  (e.g. ``tests/test_mode.py`` and ``other/tests/test_mode.py``)
-  by extending sys.path/import semantics.   pytest does not do that
-  but there is discussion in `#268 <https://github.com/pytest-dev/pytest/issues/268>`_ for adding some support.  Note that
-  `nose2 choose to avoid this sys.path/import hackery <https://nose2.readthedocs.io/en/latest/differences.html#test-discovery-and-loading>`_.
-
-  If you place a conftest.py file in the root directory of your project
-  (as determined by pytest) pytest will run tests "nose style" against
-  the code below that directory by adding it to your ``sys.path`` instead of
-  running against your installed code.
-
-  You may find yourself wanting to do this if you ran ``python setup.py install``
-  to set up your project, as opposed to ``python setup.py develop`` or any of
-  the package manager equivalents.  Installing with develop in a
-  virtual environment like tox is recommended over this pattern.
-
-- nose-style doctests are not collected and executed correctly,
-  also doctest fixtures don't work.
-
-- no nose-configuration is recognized.
-
-- ``yield``-based methods are unsupported as of pytest 4.1.0.  They are
-  fundamentally incompatible with pytest because they don't support fixtures
-  properly since collection and test execution are separated.
-
-Migrating from nose to pytest
-------------------------------
-
-`nose2pytest <https://github.com/pytest-dev/nose2pytest>`_ is a Python script
-and pytest plugin to help convert Nose-based tests into pytest-based tests.
-Specifically, the script transforms nose.tools.assert_* function calls into
-raw assert statements, while preserving format of original arguments
-as much as possible.
-
-.. _nose: https://nose.readthedocs.io/en/latest/
diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst
deleted file mode 100644 (file)
index 9e531dd..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-
-.. _`test generators`:
-.. _`parametrizing-tests`:
-.. _`parametrized test functions`:
-.. _`parametrize`:
-
-.. _`parametrize-basics`:
-
-Parametrizing fixtures and test functions
-==========================================================================
-
-pytest enables test parametrization at several levels:
-
-- :py:func:`pytest.fixture` allows one to :ref:`parametrize fixture
-  functions <fixture-parametrize>`.
-
-* `@pytest.mark.parametrize`_ allows one to define multiple sets of
-  arguments and fixtures at the test function or class.
-
-* `pytest_generate_tests`_ allows one to define custom parametrization
-  schemes or extensions.
-
-.. _parametrizemark:
-.. _`@pytest.mark.parametrize`:
-
-
-``@pytest.mark.parametrize``: parametrizing test functions
----------------------------------------------------------------------
-
-.. regendoc: wipe
-
-
-
-    Several improvements.
-
-The builtin :ref:`pytest.mark.parametrize ref` decorator enables
-parametrization of arguments for a test function.  Here is a typical example
-of a test function that implements checking that a certain input leads
-to an expected output:
-
-.. code-block:: python
-
-    # content of test_expectation.py
-    import pytest
-
-
-    @pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)])
-    def test_eval(test_input, expected):
-        assert eval(test_input) == expected
-
-Here, the ``@parametrize`` decorator defines three different ``(test_input,expected)``
-tuples so that the ``test_eval`` function will run three times using
-them in turn:
-
-.. code-block:: pytest
-
-    $ pytest
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 3 items
-
-    test_expectation.py ..F                                              [100%]
-
-    ================================= FAILURES =================================
-    ____________________________ test_eval[6*9-42] _____________________________
-
-    test_input = '6*9', expected = 42
-
-        @pytest.mark.parametrize("test_input,expected", [("3+5", 8), ("2+4", 6), ("6*9", 42)])
-        def test_eval(test_input, expected):
-    >       assert eval(test_input) == expected
-    E       AssertionError: assert 54 == 42
-    E        +  where 54 = eval('6*9')
-
-    test_expectation.py:6: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_expectation.py::test_eval[6*9-42] - AssertionError: assert 54...
-    ======================= 1 failed, 2 passed in 0.12s ========================
-
-.. note::
-
-    Parameter values are passed as-is to tests (no copy whatsoever).
-
-    For example, if you pass a list or a dict as a parameter value, and
-    the test case code mutates it, the mutations will be reflected in subsequent
-    test case calls.
-
-.. note::
-
-    pytest by default escapes any non-ascii characters used in unicode strings
-    for the parametrization because it has several downsides.
-    If however you would like to use unicode strings in parametrization
-    and see them in the terminal as is (non-escaped), use this option
-    in your ``pytest.ini``:
-
-    .. code-block:: ini
-
-        [pytest]
-        disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
-
-    Keep in mind however that this might cause unwanted side effects and
-    even bugs depending on the OS used and plugins currently installed,
-    so use it at your own risk.
-
-
-As designed in this example, only one pair of input/output values fails
-the simple test function.  And as usual with test function arguments,
-you can see the ``input`` and ``output`` values in the traceback.
-
-Note that you could also use the parametrize marker on a class or a module
-(see :ref:`mark`) which would invoke several functions with the argument sets.
-
-It is also possible to mark individual test instances within parametrize,
-for example with the builtin ``mark.xfail``:
-
-.. code-block:: python
-
-    # content of test_expectation.py
-    import pytest
-
-
-    @pytest.mark.parametrize(
-        "test_input,expected",
-        [("3+5", 8), ("2+4", 6), pytest.param("6*9", 42, marks=pytest.mark.xfail)],
-    )
-    def test_eval(test_input, expected):
-        assert eval(test_input) == expected
-
-Let's run this:
-
-.. code-block:: pytest
-
-    $ pytest
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 3 items
-
-    test_expectation.py ..x                                              [100%]
-
-    ======================= 2 passed, 1 xfailed in 0.12s =======================
-
-The one parameter set which caused a failure previously now
-shows up as an "xfailed" (expected to fail) test.
-
-In case the values provided to ``parametrize`` result in an empty list - for
-example, if they're dynamically generated by some function - the behaviour of
-pytest is defined by the :confval:`empty_parameter_set_mark` option.
-
-To get all combinations of multiple parametrized arguments you can stack
-``parametrize`` decorators:
-
-.. code-block:: python
-
-    import pytest
-
-
-    @pytest.mark.parametrize("x", [0, 1])
-    @pytest.mark.parametrize("y", [2, 3])
-    def test_foo(x, y):
-        pass
-
-This will run the test with the arguments set to ``x=0/y=2``, ``x=1/y=2``,
-``x=0/y=3``, and ``x=1/y=3`` exhausting parameters in the order of the decorators.
-
-.. _`pytest_generate_tests`:
-
-Basic ``pytest_generate_tests`` example
----------------------------------------------
-
-Sometimes you may want to implement your own parametrization scheme
-or implement some dynamism for determining the parameters or scope
-of a fixture.   For this, you can use the ``pytest_generate_tests`` hook
-which is called when collecting a test function.  Through the passed in
-``metafunc`` object you can inspect the requesting test context and, most
-importantly, you can call ``metafunc.parametrize()`` to cause
-parametrization.
-
-For example, let's say we want to run a test taking string inputs which
-we want to set via a new ``pytest`` command line option.  Let's first write
-a simple test accepting a ``stringinput`` fixture function argument:
-
-.. code-block:: python
-
-    # content of test_strings.py
-
-
-    def test_valid_string(stringinput):
-        assert stringinput.isalpha()
-
-Now we add a ``conftest.py`` file containing the addition of a
-command line option and the parametrization of our test function:
-
-.. code-block:: python
-
-    # content of conftest.py
-
-
-    def pytest_addoption(parser):
-        parser.addoption(
-            "--stringinput",
-            action="append",
-            default=[],
-            help="list of stringinputs to pass to test functions",
-        )
-
-
-    def pytest_generate_tests(metafunc):
-        if "stringinput" in metafunc.fixturenames:
-            metafunc.parametrize("stringinput", metafunc.config.getoption("stringinput"))
-
-If we now pass two stringinput values, our test will run twice:
-
-.. code-block:: pytest
-
-    $ pytest -q --stringinput="hello" --stringinput="world" test_strings.py
-    ..                                                                   [100%]
-    2 passed in 0.12s
-
-Let's also run with a stringinput that will lead to a failing test:
-
-.. code-block:: pytest
-
-    $ pytest -q --stringinput="!" test_strings.py
-    F                                                                    [100%]
-    ================================= FAILURES =================================
-    ___________________________ test_valid_string[!] ___________________________
-
-    stringinput = '!'
-
-        def test_valid_string(stringinput):
-    >       assert stringinput.isalpha()
-    E       AssertionError: assert False
-    E        +  where False = <built-in method isalpha of str object at 0xdeadbeef>()
-    E        +    where <built-in method isalpha of str object at 0xdeadbeef> = '!'.isalpha
-
-    test_strings.py:4: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_strings.py::test_valid_string[!] - AssertionError: assert False
-    1 failed in 0.12s
-
-As expected our test function fails.
-
-If you don't specify a stringinput it will be skipped because
-``metafunc.parametrize()`` will be called with an empty parameter
-list:
-
-.. code-block:: pytest
-
-    $ pytest -q -rs test_strings.py
-    s                                                                    [100%]
-    ========================= short test summary info ==========================
-    SKIPPED [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:2
-    1 skipped in 0.12s
-
-Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across
-those sets cannot be duplicated, otherwise an error will be raised.
-
-More examples
--------------
-
-For further examples, you might want to look at :ref:`more
-parametrization examples <paramexamples>`.
diff --git a/doc/en/plugins.rst b/doc/en/plugins.rst
deleted file mode 100644 (file)
index 855b597..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-.. _`external plugins`:
-.. _`extplugins`:
-.. _`using plugins`:
-
-Installing and Using plugins
-============================
-
-This section talks about installing and using third party plugins.
-For writing your own plugins, please refer to :ref:`writing-plugins`.
-
-Installing a third party plugin can be easily done with ``pip``:
-
-.. code-block:: bash
-
-    pip install pytest-NAME
-    pip uninstall pytest-NAME
-
-If a plugin is installed, ``pytest`` automatically finds and integrates it,
-there is no need to activate it.
-
-Here is a little annotated list for some popular plugins:
-
-.. _`django`: https://www.djangoproject.com/
-
-* `pytest-django <https://pypi.org/project/pytest-django/>`_: write tests
-  for `django`_ apps, using pytest integration.
-
-* `pytest-twisted <https://pypi.org/project/pytest-twisted/>`_: write tests
-  for `twisted <http://twistedmatrix.com>`_ apps, starting a reactor and
-  processing deferreds from test functions.
-
-* `pytest-cov <https://pypi.org/project/pytest-cov/>`__:
-  coverage reporting, compatible with distributed testing
-
-* `pytest-xdist <https://pypi.org/project/pytest-xdist/>`_:
-  to distribute tests to CPUs and remote hosts, to run in boxed
-  mode which allows to survive segmentation faults, to run in
-  looponfailing mode, automatically re-running failing tests
-  on file changes.
-
-* `pytest-instafail <https://pypi.org/project/pytest-instafail/>`_:
-  to report failures while the test run is happening.
-
-* `pytest-bdd <https://pypi.org/project/pytest-bdd/>`_:
-  to write tests using behaviour-driven testing.
-
-* `pytest-timeout <https://pypi.org/project/pytest-timeout/>`_:
-  to timeout tests based on function marks or global definitions.
-
-* `pytest-pep8 <https://pypi.org/project/pytest-pep8/>`_:
-  a ``--pep8`` option to enable PEP8 compliance checking.
-
-* `pytest-flakes <https://pypi.org/project/pytest-flakes/>`_:
-  check source code with pyflakes.
-
-* `oejskit <https://pypi.org/project/oejskit/>`_:
-  a plugin to run javascript unittests in live browsers.
-
-To see a complete list of all plugins with their latest testing
-status against different pytest and Python versions, please visit
-`plugincompat <http://plugincompat.herokuapp.com/>`_.
-
-You may also discover more plugins through a `pytest- pypi.org search`_.
-
-.. _`pytest- pypi.org search`: https://pypi.org/search/?q=pytest-
-
-
-.. _`available installable plugins`:
-
-Requiring/Loading plugins in a test module or conftest file
------------------------------------------------------------
-
-You can require plugins in a test module or a conftest file using :globalvar:`pytest_plugins`:
-
-.. code-block:: python
-
-    pytest_plugins = ("myapp.testsupport.myplugin",)
-
-When the test module or conftest plugin is loaded the specified plugins
-will be loaded as well.
-
-.. note::
-
-    Requiring plugins using a ``pytest_plugins`` variable in non-root
-    ``conftest.py`` files is deprecated. See
-    :ref:`full explanation <requiring plugins in non-root conftests>`
-    in the Writing plugins section.
-
-.. note::
-   The name ``pytest_plugins`` is reserved and should not be used as a
-   name for a custom plugin module.
-
-
-.. _`findpluginname`:
-
-Finding out which plugins are active
-------------------------------------
-
-If you want to find out which plugins are active in your
-environment you can type:
-
-.. code-block:: bash
-
-    pytest --trace-config
-
-and will get an extended test header which shows activated plugins
-and their names. It will also print local plugins aka
-:ref:`conftest.py <conftest.py plugins>` files when they are loaded.
-
-.. _`cmdunregister`:
-
-Deactivating / unregistering a plugin by name
----------------------------------------------
-
-You can prevent plugins from loading or unregister them:
-
-.. code-block:: bash
-
-    pytest -p no:NAME
-
-This means that any subsequent try to activate/load the named
-plugin will not work.
-
-If you want to unconditionally disable a plugin for a project, you can add
-this option to your ``pytest.ini`` file:
-
-.. code-block:: ini
-
-      [pytest]
-      addopts = -p no:NAME
-
-Alternatively to disable it only in certain environments (for example in a
-CI server), you can set ``PYTEST_ADDOPTS`` environment variable to
-``-p no:name``.
-
-See :ref:`findpluginname` for how to obtain the name of a plugin.
-
-.. _`builtin plugins`:
diff --git a/doc/en/projects.rst b/doc/en/projects.rst
deleted file mode 100644 (file)
index 0720bc9..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-.. _projects:
-
-.. image:: img/gaynor3.png
-   :width: 400px
-   :align: right
-
-.. image:: img/theuni.png
-   :width: 400px
-   :align: right
-
-.. image:: img/cramer2.png
-   :width: 400px
-   :align: right
-
-.. image:: img/keleshev.png
-   :width: 400px
-   :align: right
-
-
-Project examples
-==========================
-
-Here are some examples of projects using ``pytest`` (please send notes via :ref:`contact`):
-
-* `PyPy <http://pypy.org>`_, Python with a JIT compiler, running over
-  `21000 tests <http://buildbot.pypy.org/summary?branch=%3Ctrunk%3E>`_
-* the `MoinMoin <http://moinmo.in>`_ Wiki Engine
-* `sentry <https://getsentry.com/welcome/>`_, realtime app-maintenance and exception tracking
-* `Astropy <http://www.astropy.org/>`_ and `affiliated packages <http://www.astropy.org/affiliated/index.html>`_
-* `tox <http://testrun.org/tox>`_, virtualenv/Hudson integration tool
-* `PyPM <http://code.activestate.com/pypm/>`_ ActiveState's package manager
-* `Fom <http://packages.python.org/Fom/>`_ a fluid object mapper for FluidDB
-* `applib <https://github.com/ActiveState/applib>`_ cross-platform utilities
-* `six <https://pypi.org/project/six/>`_ Python 2 and 3 compatibility utilities
-* `pediapress <http://code.pediapress.com/wiki/wiki>`_ MediaWiki articles
-* `mwlib <https://pypi.org/project/mwlib/>`_ mediawiki parser and utility library
-* `The Translate Toolkit <http://translate.sourceforge.net/wiki/toolkit/index>`_ for localization and conversion
-* `execnet <http://codespeak.net/execnet>`_ rapid multi-Python deployment
-* `pylib <https://pylib.readthedocs.io/en/stable/>`_ cross-platform path, IO, dynamic code library
-* `bbfreeze <https://pypi.org/project/bbfreeze/>`_ create standalone executables from Python scripts
-* `pdb++ <https://github.com/pdbpp/pdbpp>`_ a fancier version of PDB
-* `pudb <https://github.com/inducer/pudb>`_ full-screen console debugger for python
-* `py-s3fuse <http://code.google.com/p/py-s3fuse/>`_ Amazon S3 FUSE based filesystem
-* `waskr <http://code.google.com/p/waskr/>`_ WSGI Stats Middleware
-* `guachi <http://code.google.com/p/guachi/>`_ global persistent configs for Python modules
-* `Circuits <https://pypi.org/project/circuits/>`_ lightweight Event Driven Framework
-* `pygtk-helpers <http://bitbucket.org/aafshar/pygtkhelpers-main/>`_ easy interaction with PyGTK
-* `QuantumCore <http://quantumcore.org/>`_ statusmessage and repoze openid plugin
-* `pydataportability <http://pydataportability.net/>`_ libraries for managing the open web
-* `XIST <http://www.livinglogic.de/Python/xist/>`_ extensible HTML/XML generator
-* `tiddlyweb <https://pypi.org/project/tiddlyweb/>`_ optionally headless, extensible RESTful datastore
-* `fancycompleter <http://bitbucket.org/antocuni/fancycompleter/src>`_ for colorful tab-completion
-* `Paludis <http://paludis.exherbo.org/>`_ tools for Gentoo Paludis package manager
-* `Gerald <http://halfcooked.com/code/gerald/>`_ schema comparison tool
-* `abjad <http://code.google.com/p/abjad/>`_ Python API for Formalized Score control
-* `bu <http://packages.python.org/bu/>`_ a microscopic build system
-* `katcp <https://bitbucket.org/hodgestar/katcp>`_ Telescope communication protocol over Twisted
-* `kss plugin timer <https://pypi.org/project/kss.plugin.timer/>`_
-* `pyudev <https://pyudev.readthedocs.io/en/latest/tests/plugins.html>`_ a pure Python binding to the Linux library libudev
-* `pytest-localserver <https://bitbucket.org/pytest-dev/pytest-localserver/>`_ a plugin for pytest that provides an httpserver and smtpserver
-* `pytest-monkeyplus <https://pypi.org/project/pytest-monkeyplus/>`_ a plugin that extends monkeypatch
-
-These projects help integrate ``pytest`` into other Python frameworks:
-
-* `pytest-django <https://pypi.org/project/pytest-django/>`_ for Django
-* `zope.pytest <http://packages.python.org/zope.pytest/>`_ for Zope and Grok
-* `pytest_gae <https://pypi.org/project/pytest_gae/0.2.1/>`_ for Google App Engine
-* There is `some work <https://github.com/Kotti/Kotti/blob/master/kotti/testing.py>`_ underway for Kotti, a CMS built in Pyramid/Pylons
-
-
-Some organisations using pytest
------------------------------------
-
-* `Square Kilometre Array, Cape Town <http://ska.ac.za/>`_
-* `Some Mozilla QA people <https://www.theautomatedtester.co.uk/blog/2011/pytest_and_xdist_plugin/>`_ use pytest to distribute their Selenium tests
-* `Shootq <http://web.shootq.com/>`_
-* `Stups department of Heinrich Heine University Duesseldorf <http://www.stups.uni-duesseldorf.de/projects.php>`_
-* cellzome
-* `Open End, Gothenborg <http://www.openend.se>`_
-* `Laboratory of Bioinformatics, Warsaw <http://genesilico.pl/>`_
-* `merlinux, Germany <http://merlinux.eu>`_
-* `ESSS, Brazil <http://www.esss.com.br>`_
-* many more ... (please be so kind to send a note via :ref:`contact`)
index b7295f27ab218be44be5a5705791dbf1579fd7c4..f6814ec78dbcb247d9fe0de48078626661c24722 100644 (file)
@@ -120,7 +120,7 @@ all parameters marked as a fixture.
 
 .. note::
 
-    The `pytest-lazy-fixture <https://pypi.org/project/pytest-lazy-fixture/>`_ plugin implements a very
+    The :pypi:`pytest-lazy-fixture` plugin implements a very
     similar solution to the proposal below, make sure to check it out.
 
 .. code-block:: python
diff --git a/doc/en/py27-py34-deprecation.rst b/doc/en/py27-py34-deprecation.rst
deleted file mode 100644 (file)
index f23f206..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-Python 2.7 and 3.4 support
-==========================
-
-It is demanding on the maintainers of an open source project to support many Python versions, as
-there's extra cost of keeping code compatible between all versions, while holding back on
-features only made possible on newer Python versions.
-
-In case of Python 2 and 3, the difference between the languages makes it even more prominent,
-because many new Python 3 features cannot be used in a Python 2/3 compatible code base.
-
-Python 2.7 EOL has been reached `in 2020 <https://legacy.python.org/dev/peps/pep-0373/#id4>`__, with
-the last release made in April, 2020.
-
-Python 3.4 EOL has been reached `in 2019 <https://www.python.org/dev/peps/pep-0429/#release-schedule>`__, with the last release made in March, 2019.
-
-For those reasons, in Jun 2019 it was decided that **pytest 4.6** series will be the last to support Python 2.7 and 3.4.
-
-What this means for general users
----------------------------------
-
-Thanks to the `python_requires`_ setuptools option,
-Python 2.7 and Python 3.4 users using a modern pip version
-will install the last pytest 4.6.X version automatically even if 5.0 or later versions
-are available on PyPI.
-
-Users should ensure they are using the latest pip and setuptools versions for this to work.
-
-Maintenance of 4.6.X versions
------------------------------
-
-Until January 2020, the pytest core team ported many bug-fixes from the main release into the
-``4.6.x`` branch, with several 4.6.X releases being made along the year.
-
-From now on, the core team will **no longer actively backport patches**, but the ``4.6.x``
-branch will continue to exist so the community itself can contribute patches.
-
-The core team will be happy to accept those patches, and make new 4.6.X releases **until mid-2020**
-(but consider that date as a ballpark, after that date the team might still decide to make new releases
-for critical bugs).
-
-.. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
-
-Technical aspects
-~~~~~~~~~~~~~~~~~
-
-(This section is a transcript from `#5275 <https://github.com/pytest-dev/pytest/issues/5275>`__).
-
-In this section we describe the technical aspects of the Python 2.7 and 3.4 support plan.
-
-What goes into 4.6.X releases
-+++++++++++++++++++++++++++++
-
-New 4.6.X releases will contain bug fixes only.
-
-When will 4.6.X releases happen
-+++++++++++++++++++++++++++++++
-
-New 4.6.X releases will happen after we have a few bugs in place to release, or if a few weeks have
-passed (say a single bug has been fixed a month after the latest 4.6.X release).
-
-No hard rules here, just ballpark.
-
-Who will handle applying bug fixes
-++++++++++++++++++++++++++++++++++
-
-We core maintainers expect that people still using Python 2.7/3.4 and being affected by
-bugs to step up and provide patches and/or port bug fixes from the active branches.
-
-We will be happy to guide users interested in doing so, so please don't hesitate to ask.
-
-**Backporting changes into 4.6**
-
-Please follow these instructions:
-
-#. ``git fetch --all --prune``
-
-#. ``git checkout origin/4.6.x -b backport-XXXX`` # use the PR number here
-
-#. Locate the merge commit on the PR, in the *merged* message, for example:
-
-    nicoddemus merged commit 0f8b462 into pytest-dev:features
-
-#. ``git cherry-pick -m1 REVISION`` # use the revision you found above (``0f8b462``).
-
-#. Open a PR targeting ``4.6.x``:
-
-   * Prefix the message with ``[4.6]`` so it is an obvious backport
-   * Delete the PR body, it usually contains a duplicate commit message.
-
-**Providing new PRs to 4.6**
-
-Fresh pull requests to ``4.6.x`` will be accepted provided that
-the equivalent code in the active branches does not contain that bug (for example, a bug is specific
-to Python 2 only).
-
-Bug fixes that also happen in the mainstream version should be first fixed
-there, and then backported as per instructions above.
diff --git a/doc/en/pythonpath.rst b/doc/en/pythonpath.rst
deleted file mode 100644 (file)
index b8f4de9..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-.. _pythonpath:
-
-pytest import mechanisms and ``sys.path``/``PYTHONPATH``
-========================================================
-
-.. _`import-modes`:
-
-Import modes
-------------
-
-pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution.
-
-Importing files in Python (at least until recently) is a non-trivial processes, often requiring
-changing `sys.path <https://docs.python.org/3/library/sys.html#sys.path>`__. Some aspects of the
-import process can be controlled through the ``--import-mode`` command-line flag, which can assume
-these values:
-
-* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
-  of ``sys.path`` if not already there, and then imported with the `__import__ <https://docs.python.org/3/library/functions.html#__import__>`__ builtin.
-
-  This requires test module names to be unique when the test directory tree is not arranged in
-  packages, because the modules will put in ``sys.modules`` after importing.
-
-  This is the classic mechanism, dating back from the time Python 2 was still supported.
-
-* ``append``: the directory containing each module is appended to the end of ``sys.path`` if not already
-  there, and imported with ``__import__``.
-
-  This better allows to run test modules against installed versions of a package even if the
-  package under test has the same import root. For example:
-
-  ::
-
-        testing/__init__.py
-        testing/test_pkg_under_test.py
-        pkg_under_test/
-
-  the tests will run against the installed version
-  of ``pkg_under_test`` when ``--import-mode=append`` is used whereas
-  with ``prepend`` they would pick up the local version. This kind of confusion is why
-  we advocate for using :ref:`src <src-layout>` layouts.
-
-  Same as ``prepend``, requires test module names to be unique when the test directory tree is
-  not arranged in packages, because the modules will put in ``sys.modules`` after importing.
-
-* ``importlib``: new in pytest-6.0, this mode uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules. This gives full control over the import process, and doesn't require
-  changing ``sys.path`` or ``sys.modules`` at all.
-
-  For this reason this doesn't require test module names to be unique at all, but also makes test
-  modules non-importable by each other. This was made possible in previous modes, for tests not residing
-  in Python packages, because of the side-effects of changing ``sys.path`` and ``sys.modules``
-  mentioned above. Users which require this should turn their tests into proper packages instead.
-
-  We intend to make ``importlib`` the default in future releases.
-
-``prepend`` and ``append`` import modes scenarios
--------------------------------------------------
-
-Here's a list of scenarios when using ``prepend`` or ``append`` import modes where pytest needs to
-change ``sys.path`` in order to import test modules or ``conftest.py`` files, and the issues users
-might encounter because of that.
-
-Test modules / ``conftest.py`` files inside packages
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Consider this file and directory layout::
-
-    root/
-    |- foo/
-       |- __init__.py
-       |- conftest.py
-       |- bar/
-          |- __init__.py
-          |- tests/
-             |- __init__.py
-             |- test_foo.py
-
-
-When executing:
-
-.. code-block:: bash
-
-    pytest root/
-
-pytest will find ``foo/bar/tests/test_foo.py`` and realize it is part of a package given that
-there's an ``__init__.py`` file in the same folder. It will then search upwards until it can find the
-last folder which still contains an ``__init__.py`` file in order to find the package *root* (in
-this case ``foo/``). To load the module, it will insert ``root/``  to the front of
-``sys.path`` (if not there already) in order to load
-``test_foo.py`` as the *module* ``foo.bar.tests.test_foo``.
-
-The same logic applies to the ``conftest.py`` file: it will be imported as ``foo.conftest`` module.
-
-Preserving the full package name is important when tests live in a package to avoid problems
-and allow test modules to have duplicated names. This is also discussed in details in
-:ref:`test discovery`.
-
-Standalone test modules / ``conftest.py`` files
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Consider this file and directory layout::
-
-    root/
-    |- foo/
-       |- conftest.py
-       |- bar/
-          |- tests/
-             |- test_foo.py
-
-
-When executing:
-
-.. code-block:: bash
-
-    pytest root/
-
-pytest will find ``foo/bar/tests/test_foo.py`` and realize it is NOT part of a package given that
-there's no ``__init__.py`` file in the same folder. It will then add ``root/foo/bar/tests`` to
-``sys.path`` in order to import ``test_foo.py`` as the *module* ``test_foo``. The same is done
-with the ``conftest.py`` file by adding ``root/foo`` to ``sys.path`` to import it as ``conftest``.
-
-For this reason this layout cannot have test modules with the same name, as they all will be
-imported in the global import namespace.
-
-This is also discussed in details in :ref:`test discovery`.
-
-.. _`pytest vs python -m pytest`:
-
-Invoking ``pytest`` versus ``python -m pytest``
------------------------------------------------
-
-Running pytest with ``pytest [...]`` instead of ``python -m pytest [...]`` yields nearly
-equivalent behaviour, except that the latter will add the current directory to ``sys.path``, which
-is standard ``python`` behavior.
-
-See also :ref:`cmdline`.
diff --git a/doc/en/reference.rst b/doc/en/reference.rst
deleted file mode 100644 (file)
index 658516a..0000000
+++ /dev/null
@@ -1,1981 +0,0 @@
-.. _`reference`:
-
-API Reference
-=============
-
-.. module:: pytest
-
-This page contains the full reference to pytest's API.
-
-.. contents::
-    :depth: 3
-    :local:
-
-Functions
----------
-
-pytest.approx
-~~~~~~~~~~~~~
-
-.. autofunction:: pytest.approx
-
-pytest.fail
-~~~~~~~~~~~
-
-**Tutorial**: :ref:`skipping`
-
-.. autofunction:: pytest.fail
-
-pytest.skip
-~~~~~~~~~~~
-
-.. autofunction:: pytest.skip(msg, [allow_module_level=False])
-
-.. _`pytest.importorskip ref`:
-
-pytest.importorskip
-~~~~~~~~~~~~~~~~~~~
-
-.. autofunction:: pytest.importorskip
-
-pytest.xfail
-~~~~~~~~~~~~
-
-.. autofunction:: pytest.xfail
-
-pytest.exit
-~~~~~~~~~~~
-
-.. autofunction:: pytest.exit
-
-pytest.main
-~~~~~~~~~~~
-
-.. autofunction:: pytest.main
-
-pytest.param
-~~~~~~~~~~~~
-
-.. autofunction:: pytest.param(*values, [id], [marks])
-
-pytest.raises
-~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`assertraises`.
-
-.. autofunction:: pytest.raises(expected_exception: Exception [, *, match])
-    :with: excinfo
-
-pytest.deprecated_call
-~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`ensuring_function_triggers`.
-
-.. autofunction:: pytest.deprecated_call()
-    :with:
-
-pytest.register_assert_rewrite
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`assertion-rewriting`.
-
-.. autofunction:: pytest.register_assert_rewrite
-
-pytest.warns
-~~~~~~~~~~~~
-
-**Tutorial**: :ref:`assertwarnings`
-
-.. autofunction:: pytest.warns(expected_warning: Exception, [match])
-    :with:
-
-pytest.freeze_includes
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`freezing-pytest`.
-
-.. autofunction:: pytest.freeze_includes
-
-.. _`marks ref`:
-
-Marks
------
-
-Marks can be used apply meta data to *test functions* (but not fixtures), which can then be accessed by
-fixtures or plugins.
-
-
-
-
-.. _`pytest.mark.filterwarnings ref`:
-
-pytest.mark.filterwarnings
-~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`filterwarnings`.
-
-Add warning filters to marked test items.
-
-.. py:function:: pytest.mark.filterwarnings(filter)
-
-    :keyword str filter:
-        A *warning specification string*, which is composed of contents of the tuple ``(action, message, category, module, lineno)``
-        as specified in `The Warnings filter <https://docs.python.org/3/library/warnings.html#warning-filter>`_ section of
-        the Python documentation, separated by ``":"``. Optional fields can be omitted.
-        Module names passed for filtering are not regex-escaped.
-
-        For example:
-
-        .. code-block:: python
-
-            @pytest.mark.filterwarnings("ignore:.*usage will be deprecated.*:DeprecationWarning")
-            def test_foo():
-                ...
-
-
-.. _`pytest.mark.parametrize ref`:
-
-pytest.mark.parametrize
-~~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :doc:`parametrize`.
-
-This mark has the same signature as :py:meth:`_pytest.python.Metafunc.parametrize`; see there.
-
-
-.. _`pytest.mark.skip ref`:
-
-pytest.mark.skip
-~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`skip`.
-
-Unconditionally skip a test function.
-
-.. py:function:: pytest.mark.skip(*, reason=None)
-
-    :keyword str reason: Reason why the test function is being skipped.
-
-
-.. _`pytest.mark.skipif ref`:
-
-pytest.mark.skipif
-~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`skipif`.
-
-Skip a test function if a condition is ``True``.
-
-.. py:function:: pytest.mark.skipif(condition, *, reason=None)
-
-    :type condition: bool or str
-    :param condition: ``True/False`` if the condition should be skipped or a :ref:`condition string <string conditions>`.
-    :keyword str reason: Reason why the test function is being skipped.
-
-
-.. _`pytest.mark.usefixtures ref`:
-
-pytest.mark.usefixtures
-~~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`usefixtures`.
-
-Mark a test function as using the given fixture names.
-
-.. py:function:: pytest.mark.usefixtures(*names)
-
-    :param args: The names of the fixture to use, as strings.
-
-.. note::
-
-    When using `usefixtures` in hooks, it can only load fixtures when applied to a test function before test setup
-    (for example in the `pytest_collection_modifyitems` hook).
-
-    Also note that this mark has no effect when applied to **fixtures**.
-
-
-
-.. _`pytest.mark.xfail ref`:
-
-pytest.mark.xfail
-~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`xfail`.
-
-Marks a test function as *expected to fail*.
-
-.. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=False)
-
-    :type condition: bool or str
-    :param condition:
-        Condition for marking the test function as xfail (``True/False`` or a
-        :ref:`condition string <string conditions>`). If a bool, you also have
-        to specify ``reason`` (see :ref:`condition string <string conditions>`).
-    :keyword str reason:
-        Reason why the test function is marked as xfail.
-    :keyword Type[Exception] raises:
-        Exception subclass expected to be raised by the test function; other exceptions will fail the test.
-    :keyword bool run:
-        If the test function should actually be executed. If ``False``, the function will always xfail and will
-        not be executed (useful if a function is segfaulting).
-    :keyword bool strict:
-        * If ``False`` (the default) the function will be shown in the terminal output as ``xfailed`` if it fails
-          and as ``xpass`` if it passes. In both cases this will not cause the test suite to fail as a whole. This
-          is particularly useful to mark *flaky* tests (tests that fail at random) to be tackled later.
-        * If ``True``, the function will be shown in the terminal output as ``xfailed`` if it fails, but if it
-          unexpectedly passes then it will **fail** the test suite. This is particularly useful to mark functions
-          that are always failing and there should be a clear indication if they unexpectedly start to pass (for example
-          a new release of a library fixes a known bug).
-
-
-Custom marks
-~~~~~~~~~~~~
-
-Marks are created dynamically using the factory object ``pytest.mark`` and applied as a decorator.
-
-For example:
-
-.. code-block:: python
-
-    @pytest.mark.timeout(10, "slow", method="thread")
-    def test_function():
-        ...
-
-Will create and attach a :class:`Mark <_pytest.mark.structures.Mark>` object to the collected
-:class:`Item <pytest.Item>`, which can then be accessed by fixtures or hooks with
-:meth:`Node.iter_markers <_pytest.nodes.Node.iter_markers>`. The ``mark`` object will have the following attributes:
-
-.. code-block:: python
-
-    mark.args == (10, "slow")
-    mark.kwargs == {"method": "thread"}
-
-Example for using multiple custom markers:
-
-.. code-block:: python
-
-    @pytest.mark.timeout(10, "slow", method="thread")
-    @pytest.mark.slow
-    def test_function():
-        ...
-
-When :meth:`Node.iter_markers <_pytest.nodes.Node.iter_markers>` or :meth:`Node.iter_markers <_pytest.nodes.Node.iter_markers_with_node>` is used with multiple markers, the marker closest to the function will be iterated over first. The above example will result in ``@pytest.mark.slow`` followed by ``@pytest.mark.timeout(...)``.
-
-.. _`fixtures-api`:
-
-Fixtures
---------
-
-**Tutorial**: :ref:`fixture`.
-
-Fixtures are requested by test functions or other fixtures by declaring them as argument names.
-
-
-Example of a test requiring a fixture:
-
-.. code-block:: python
-
-    def test_output(capsys):
-        print("hello")
-        out, err = capsys.readouterr()
-        assert out == "hello\n"
-
-
-Example of a fixture requiring another fixture:
-
-.. code-block:: python
-
-    @pytest.fixture
-    def db_session(tmpdir):
-        fn = tmpdir / "db.file"
-        return connect(str(fn))
-
-For more details, consult the full :ref:`fixtures docs <fixture>`.
-
-
-.. _`pytest.fixture-api`:
-
-@pytest.fixture
-~~~~~~~~~~~~~~~
-
-.. autofunction:: pytest.fixture
-    :decorator:
-
-
-.. fixture:: cache
-
-config.cache
-~~~~~~~~~~~~
-
-**Tutorial**: :ref:`cache`.
-
-The ``config.cache`` object allows other plugins and fixtures
-to store and retrieve values across test runs. To access it from fixtures
-request ``pytestconfig`` into your fixture and get it with ``pytestconfig.cache``.
-
-Under the hood, the cache plugin uses the simple
-``dumps``/``loads`` API of the :py:mod:`json` stdlib module.
-
-``config.cache`` is an instance of :class:`pytest.Cache`:
-
-.. autoclass:: pytest.Cache()
-   :members:
-
-
-.. fixture:: capsys
-
-capsys
-~~~~~~
-
-**Tutorial**: :doc:`capture`.
-
-.. autofunction:: _pytest.capture.capsys()
-    :no-auto-options:
-
-    Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
-
-    Example:
-
-    .. code-block:: python
-
-        def test_output(capsys):
-            print("hello")
-            captured = capsys.readouterr()
-            assert captured.out == "hello\n"
-
-.. autoclass:: pytest.CaptureFixture()
-    :members:
-
-
-.. fixture:: capsysbinary
-
-capsysbinary
-~~~~~~~~~~~~
-
-**Tutorial**: :doc:`capture`.
-
-.. autofunction:: _pytest.capture.capsysbinary()
-    :no-auto-options:
-
-    Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
-
-    Example:
-
-    .. code-block:: python
-
-        def test_output(capsysbinary):
-            print("hello")
-            captured = capsysbinary.readouterr()
-            assert captured.out == b"hello\n"
-
-
-.. fixture:: capfd
-
-capfd
-~~~~~~
-
-**Tutorial**: :doc:`capture`.
-
-.. autofunction:: _pytest.capture.capfd()
-    :no-auto-options:
-
-    Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
-
-    Example:
-
-    .. code-block:: python
-
-        def test_system_echo(capfd):
-            os.system('echo "hello"')
-            captured = capfd.readouterr()
-            assert captured.out == "hello\n"
-
-
-.. fixture:: capfdbinary
-
-capfdbinary
-~~~~~~~~~~~~
-
-**Tutorial**: :doc:`capture`.
-
-.. autofunction:: _pytest.capture.capfdbinary()
-    :no-auto-options:
-
-    Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
-
-    Example:
-
-    .. code-block:: python
-
-        def test_system_echo(capfdbinary):
-            os.system('echo "hello"')
-            captured = capfdbinary.readouterr()
-            assert captured.out == b"hello\n"
-
-
-.. fixture:: doctest_namespace
-
-doctest_namespace
-~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :doc:`doctest`.
-
-.. autofunction:: _pytest.doctest.doctest_namespace()
-
-    Usually this fixture is used in conjunction with another ``autouse`` fixture:
-
-    .. code-block:: python
-
-        @pytest.fixture(autouse=True)
-        def add_np(doctest_namespace):
-            doctest_namespace["np"] = numpy
-
-    For more details: :ref:`doctest_namespace`.
-
-
-.. fixture:: request
-
-request
-~~~~~~~
-
-**Tutorial**: :ref:`request example`.
-
-The ``request`` fixture is a special fixture providing information of the requesting test function.
-
-.. autoclass:: pytest.FixtureRequest()
-    :members:
-
-
-.. fixture:: pytestconfig
-
-pytestconfig
-~~~~~~~~~~~~
-
-.. autofunction:: _pytest.fixtures.pytestconfig()
-
-
-.. fixture:: record_property
-
-record_property
-~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`record_property example`.
-
-.. autofunction:: _pytest.junitxml.record_property()
-
-
-.. fixture:: record_testsuite_property
-
-record_testsuite_property
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`record_testsuite_property example`.
-
-.. autofunction:: _pytest.junitxml.record_testsuite_property()
-
-
-.. fixture:: caplog
-
-caplog
-~~~~~~
-
-**Tutorial**: :doc:`logging`.
-
-.. autofunction:: _pytest.logging.caplog()
-    :no-auto-options:
-
-    Returns a :class:`pytest.LogCaptureFixture` instance.
-
-.. autoclass:: pytest.LogCaptureFixture()
-    :members:
-
-
-.. fixture:: monkeypatch
-
-monkeypatch
-~~~~~~~~~~~
-
-**Tutorial**: :doc:`monkeypatch`.
-
-.. autofunction:: _pytest.monkeypatch.monkeypatch()
-    :no-auto-options:
-
-    Returns a :class:`~pytest.MonkeyPatch` instance.
-
-.. autoclass:: pytest.MonkeyPatch
-    :members:
-
-
-.. fixture:: pytester
-
-pytester
-~~~~~~~~
-
-.. versionadded:: 6.2
-
-Provides a :class:`~pytest.Pytester` instance that can be used to run and test pytest itself.
-
-It provides an empty directory where pytest can be executed in isolation, and contains facilities
-to write tests, configuration files, and match against expected output.
-
-To use it, include in your topmost ``conftest.py`` file:
-
-.. code-block:: python
-
-    pytest_plugins = "pytester"
-
-
-
-.. autoclass:: pytest.Pytester()
-    :members:
-
-.. autoclass:: _pytest.pytester.RunResult()
-    :members:
-
-.. autoclass:: _pytest.pytester.LineMatcher()
-    :members:
-    :special-members: __str__
-
-.. autoclass:: _pytest.pytester.HookRecorder()
-    :members:
-
-.. fixture:: testdir
-
-testdir
-~~~~~~~
-
-Identical to :fixture:`pytester`, but provides an instance whose methods return
-legacy ``py.path.local`` objects instead when applicable.
-
-New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
-
-.. autoclass:: pytest.Testdir()
-    :members:
-
-
-.. fixture:: recwarn
-
-recwarn
-~~~~~~~
-
-**Tutorial**: :ref:`assertwarnings`
-
-.. autofunction:: _pytest.recwarn.recwarn()
-    :no-auto-options:
-
-.. autoclass:: pytest.WarningsRecorder()
-    :members:
-
-Each recorded warning is an instance of :class:`warnings.WarningMessage`.
-
-.. note::
-    ``DeprecationWarning`` and ``PendingDeprecationWarning`` are treated
-    differently; see :ref:`ensuring_function_triggers`.
-
-
-.. fixture:: tmp_path
-
-tmp_path
-~~~~~~~~
-
-**Tutorial**: :doc:`tmpdir`
-
-.. autofunction:: _pytest.tmpdir.tmp_path()
-    :no-auto-options:
-
-
-.. fixture:: _pytest.tmpdir.tmp_path_factory
-
-tmp_path_factory
-~~~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`tmp_path_factory example`
-
-.. _`tmp_path_factory factory api`:
-
-``tmp_path_factory`` is an instance of :class:`~pytest.TempPathFactory`:
-
-.. autoclass:: pytest.TempPathFactory()
-
-
-.. fixture:: tmpdir
-
-tmpdir
-~~~~~~
-
-**Tutorial**: :doc:`tmpdir`
-
-.. autofunction:: _pytest.tmpdir.tmpdir()
-    :no-auto-options:
-
-
-.. fixture:: tmpdir_factory
-
-tmpdir_factory
-~~~~~~~~~~~~~~
-
-**Tutorial**: :ref:`tmpdir factory example`
-
-.. _`tmpdir factory api`:
-
-``tmp_path_factory`` is an instance of :class:`~pytest.TempdirFactory`:
-
-.. autoclass:: pytest.TempdirFactory()
-
-
-.. _`hook-reference`:
-
-Hooks
------
-
-**Tutorial**: :doc:`writing_plugins`.
-
-.. currentmodule:: _pytest.hookspec
-
-Reference to all hooks which can be implemented by :ref:`conftest.py files <localplugin>` and :ref:`plugins <plugins>`.
-
-Bootstrapping hooks
-~~~~~~~~~~~~~~~~~~~
-
-Bootstrapping hooks called for plugins registered early enough (internal and setuptools plugins).
-
-.. autofunction:: pytest_load_initial_conftests
-.. autofunction:: pytest_cmdline_preparse
-.. autofunction:: pytest_cmdline_parse
-.. autofunction:: pytest_cmdline_main
-
-.. _`initialization-hooks`:
-
-Initialization hooks
-~~~~~~~~~~~~~~~~~~~~
-
-Initialization hooks called for plugins and ``conftest.py`` files.
-
-.. autofunction:: pytest_addoption
-.. autofunction:: pytest_addhooks
-.. autofunction:: pytest_configure
-.. autofunction:: pytest_unconfigure
-.. autofunction:: pytest_sessionstart
-.. autofunction:: pytest_sessionfinish
-
-.. autofunction:: pytest_plugin_registered
-
-Collection hooks
-~~~~~~~~~~~~~~~~
-
-``pytest`` calls the following hooks for collecting files and directories:
-
-.. autofunction:: pytest_collection
-.. autofunction:: pytest_ignore_collect
-.. autofunction:: pytest_collect_file
-.. autofunction:: pytest_pycollect_makemodule
-
-For influencing the collection of objects in Python modules
-you can use the following hook:
-
-.. autofunction:: pytest_pycollect_makeitem
-.. autofunction:: pytest_generate_tests
-.. autofunction:: pytest_make_parametrize_id
-
-After collection is complete, you can modify the order of
-items, delete or otherwise amend the test items:
-
-.. autofunction:: pytest_collection_modifyitems
-
-.. note::
-    If this hook is implemented in ``conftest.py`` files, it always receives all collected items, not only those
-    under the ``conftest.py`` where it is implemented.
-
-.. autofunction:: pytest_collection_finish
-
-Test running (runtest) hooks
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-All runtest related hooks receive a :py:class:`pytest.Item <pytest.Item>` object.
-
-.. autofunction:: pytest_runtestloop
-.. autofunction:: pytest_runtest_protocol
-.. autofunction:: pytest_runtest_logstart
-.. autofunction:: pytest_runtest_logfinish
-.. autofunction:: pytest_runtest_setup
-.. autofunction:: pytest_runtest_call
-.. autofunction:: pytest_runtest_teardown
-.. autofunction:: pytest_runtest_makereport
-
-For deeper understanding you may look at the default implementation of
-these hooks in ``_pytest.runner`` and maybe also
-in ``_pytest.pdb`` which interacts with ``_pytest.capture``
-and its input/output capturing in order to immediately drop
-into interactive debugging when a test failure occurs.
-
-.. autofunction:: pytest_pyfunc_call
-
-Reporting hooks
-~~~~~~~~~~~~~~~
-
-Session related reporting hooks:
-
-.. autofunction:: pytest_collectstart
-.. autofunction:: pytest_make_collect_report
-.. autofunction:: pytest_itemcollected
-.. autofunction:: pytest_collectreport
-.. autofunction:: pytest_deselected
-.. autofunction:: pytest_report_header
-.. autofunction:: pytest_report_collectionfinish
-.. autofunction:: pytest_report_teststatus
-.. autofunction:: pytest_terminal_summary
-.. autofunction:: pytest_fixture_setup
-.. autofunction:: pytest_fixture_post_finalizer
-.. autofunction:: pytest_warning_captured
-.. autofunction:: pytest_warning_recorded
-
-Central hook for reporting about test execution:
-
-.. autofunction:: pytest_runtest_logreport
-
-Assertion related hooks:
-
-.. autofunction:: pytest_assertrepr_compare
-.. autofunction:: pytest_assertion_pass
-
-
-Debugging/Interaction hooks
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-There are few hooks which can be used for special
-reporting or interaction with exceptions:
-
-.. autofunction:: pytest_internalerror
-.. autofunction:: pytest_keyboard_interrupt
-.. autofunction:: pytest_exception_interact
-.. autofunction:: pytest_enter_pdb
-
-
-Objects
--------
-
-Full reference to objects accessible from :ref:`fixtures <fixture>` or :ref:`hooks <hook-reference>`.
-
-
-CallInfo
-~~~~~~~~
-
-.. autoclass:: _pytest.runner.CallInfo()
-    :members:
-
-
-Class
-~~~~~
-
-.. autoclass:: pytest.Class()
-    :members:
-    :show-inheritance:
-
-Collector
-~~~~~~~~~
-
-.. autoclass:: pytest.Collector()
-    :members:
-    :show-inheritance:
-
-CollectReport
-~~~~~~~~~~~~~
-
-.. autoclass:: _pytest.reports.CollectReport()
-    :members:
-    :show-inheritance:
-    :inherited-members:
-
-Config
-~~~~~~
-
-.. autoclass:: _pytest.config.Config()
-    :members:
-
-ExceptionInfo
-~~~~~~~~~~~~~
-
-.. autoclass:: _pytest._code.ExceptionInfo
-    :members:
-
-
-ExitCode
-~~~~~~~~
-
-.. autoclass:: pytest.ExitCode
-    :members:
-
-File
-~~~~
-
-.. autoclass:: pytest.File()
-    :members:
-    :show-inheritance:
-
-
-FixtureDef
-~~~~~~~~~~
-
-.. autoclass:: _pytest.fixtures.FixtureDef()
-    :members:
-    :show-inheritance:
-
-FSCollector
-~~~~~~~~~~~
-
-.. autoclass:: _pytest.nodes.FSCollector()
-    :members:
-    :show-inheritance:
-
-Function
-~~~~~~~~
-
-.. autoclass:: pytest.Function()
-    :members:
-    :show-inheritance:
-
-FunctionDefinition
-~~~~~~~~~~~~~~~~~~
-
-.. autoclass:: _pytest.python.FunctionDefinition()
-    :members:
-    :show-inheritance:
-
-Item
-~~~~
-
-.. autoclass:: pytest.Item()
-    :members:
-    :show-inheritance:
-
-MarkDecorator
-~~~~~~~~~~~~~
-
-.. autoclass:: _pytest.mark.MarkDecorator
-    :members:
-
-
-MarkGenerator
-~~~~~~~~~~~~~
-
-.. autoclass:: _pytest.mark.MarkGenerator
-    :members:
-
-
-Mark
-~~~~
-
-.. autoclass:: _pytest.mark.structures.Mark
-    :members:
-
-
-Metafunc
-~~~~~~~~
-
-.. autoclass:: _pytest.python.Metafunc
-    :members:
-
-Module
-~~~~~~
-
-.. autoclass:: pytest.Module()
-    :members:
-    :show-inheritance:
-
-Node
-~~~~
-
-.. autoclass:: _pytest.nodes.Node()
-    :members:
-
-Parser
-~~~~~~
-
-.. autoclass:: _pytest.config.argparsing.Parser()
-    :members:
-
-
-PytestPluginManager
-~~~~~~~~~~~~~~~~~~~
-
-.. autoclass:: _pytest.config.PytestPluginManager()
-    :members:
-    :undoc-members:
-    :inherited-members:
-    :show-inheritance:
-
-Session
-~~~~~~~
-
-.. autoclass:: pytest.Session()
-    :members:
-    :show-inheritance:
-
-TestReport
-~~~~~~~~~~
-
-.. autoclass:: _pytest.reports.TestReport()
-    :members:
-    :show-inheritance:
-    :inherited-members:
-
-_Result
-~~~~~~~
-
-Result used within :ref:`hook wrappers <hookwrapper>`.
-
-.. autoclass:: pluggy.callers._Result
-.. automethod:: pluggy.callers._Result.get_result
-.. automethod:: pluggy.callers._Result.force_result
-
-Global Variables
-----------------
-
-pytest treats some global variables in a special manner when defined in a test module or
-``conftest.py`` files.
-
-
-.. globalvar:: collect_ignore
-
-**Tutorial**: :ref:`customizing-test-collection`
-
-Can be declared in *conftest.py files* to exclude test directories or modules.
-Needs to be ``list[str]``.
-
-.. code-block:: python
-
-  collect_ignore = ["setup.py"]
-
-
-.. globalvar:: collect_ignore_glob
-
-**Tutorial**: :ref:`customizing-test-collection`
-
-Can be declared in *conftest.py files* to exclude test directories or modules
-with Unix shell-style wildcards. Needs to be ``list[str]`` where ``str`` can
-contain glob patterns.
-
-.. code-block:: python
-
-  collect_ignore_glob = ["*_ignore.py"]
-
-
-.. globalvar:: pytest_plugins
-
-**Tutorial**: :ref:`available installable plugins`
-
-Can be declared at the **global** level in *test modules* and *conftest.py files* to register additional plugins.
-Can be either a ``str`` or ``Sequence[str]``.
-
-.. code-block:: python
-
-    pytest_plugins = "myapp.testsupport.myplugin"
-
-.. code-block:: python
-
-    pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression")
-
-
-.. globalvar:: pytestmark
-
-**Tutorial**: :ref:`scoped-marking`
-
-Can be declared at the **global** level in *test modules* to apply one or more :ref:`marks <marks ref>` to all
-test functions and methods. Can be either a single mark or a list of marks (applied in left-to-right order).
-
-.. code-block:: python
-
-    import pytest
-
-    pytestmark = pytest.mark.webtest
-
-
-.. code-block:: python
-
-    import pytest
-
-    pytestmark = [pytest.mark.integration, pytest.mark.slow]
-
-
-Environment Variables
----------------------
-
-Environment variables that can be used to change pytest's behavior.
-
-.. envvar:: PYTEST_ADDOPTS
-
-This contains a command-line (parsed by the py:mod:`shlex` module) that will be **prepended** to the command line given
-by the user, see :ref:`adding default options` for more information.
-
-.. envvar:: PYTEST_CURRENT_TEST
-
-This is not meant to be set by users, but is set by pytest internally with the name of the current test so other
-processes can inspect it, see :ref:`pytest current test env` for more information.
-
-.. envvar:: PYTEST_DEBUG
-
-When set, pytest will print tracing and debug information.
-
-.. envvar:: PYTEST_DISABLE_PLUGIN_AUTOLOAD
-
-When set, disables plugin auto-loading through setuptools entrypoints. Only explicitly specified plugins will be
-loaded.
-
-.. envvar:: PYTEST_PLUGINS
-
-Contains comma-separated list of modules that should be loaded as plugins:
-
-.. code-block:: bash
-
-    export PYTEST_PLUGINS=mymodule.plugin,xdist
-
-.. envvar:: PY_COLORS
-
-When set to ``1``, pytest will use color in terminal output.
-When set to ``0``, pytest will not use color.
-``PY_COLORS`` takes precedence over ``NO_COLOR`` and ``FORCE_COLOR``.
-
-.. envvar:: NO_COLOR
-
-When set (regardless of value), pytest will not use color in terminal output.
-``PY_COLORS`` takes precedence over ``NO_COLOR``, which takes precedence over ``FORCE_COLOR``.
-See `no-color.org <https://no-color.org/>`__ for other libraries supporting this community standard.
-
-.. envvar:: FORCE_COLOR
-
-When set (regardless of value), pytest will use color in terminal output.
-``PY_COLORS`` and ``NO_COLOR`` take precedence over ``FORCE_COLOR``.
-
-Exceptions
-----------
-
-.. autoclass:: pytest.UsageError()
-    :show-inheritance:
-
-.. _`warnings ref`:
-
-Warnings
---------
-
-Custom warnings generated in some situations such as improper usage or deprecated features.
-
-.. autoclass:: pytest.PytestWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestAssertRewriteWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestCacheWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestCollectionWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestConfigWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestDeprecationWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestExperimentalApiWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestUnhandledCoroutineWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestUnknownMarkWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestUnraisableExceptionWarning
-   :show-inheritance:
-
-.. autoclass:: pytest.PytestUnhandledThreadExceptionWarning
-   :show-inheritance:
-
-
-Consult the :ref:`internal-warnings` section in the documentation for more information.
-
-
-.. _`ini options ref`:
-
-Configuration Options
----------------------
-
-Here is a list of builtin configuration options that may be written in a ``pytest.ini``, ``pyproject.toml``, ``tox.ini`` or ``setup.cfg``
-file, usually located at the root of your repository. To see each file format in details, see
-:ref:`config file formats`.
-
-.. warning::
-    Usage of ``setup.cfg`` is not recommended except for very simple use cases. ``.cfg``
-    files use a different parser than ``pytest.ini`` and ``tox.ini`` which might cause hard to track
-    down problems.
-    When possible, it is recommended to use the latter files, or ``pyproject.toml``, to hold your pytest configuration.
-
-Configuration options may be overwritten in the command-line by using ``-o/--override-ini``, which can also be
-passed multiple times. The expected format is ``name=value``. For example::
-
-   pytest -o console_output_style=classic -o cache_dir=/tmp/mycache
-
-
-.. confval:: addopts
-
-   Add the specified ``OPTS`` to the set of command line arguments as if they
-   had been specified by the user. Example: if you have this ini file content:
-
-   .. code-block:: ini
-
-        # content of pytest.ini
-        [pytest]
-        addopts = --maxfail=2 -rf  # exit after 2 failures, report fail info
-
-   issuing ``pytest test_hello.py`` actually means:
-
-   .. code-block:: bash
-
-        pytest --maxfail=2 -rf test_hello.py
-
-   Default is to add no options.
-
-
-.. confval:: cache_dir
-
-   Sets a directory where stores content of cache plugin. Default directory is
-   ``.pytest_cache`` which is created in :ref:`rootdir <rootdir>`. Directory may be
-   relative or absolute path. If setting relative path, then directory is created
-   relative to :ref:`rootdir <rootdir>`. Additionally path may contain environment
-   variables, that will be expanded. For more information about cache plugin
-   please refer to :ref:`cache_provider`.
-
-
-.. confval:: confcutdir
-
-   Sets a directory where search upwards for ``conftest.py`` files stops.
-   By default, pytest will stop searching for ``conftest.py`` files upwards
-   from ``pytest.ini``/``tox.ini``/``setup.cfg`` of the project if any,
-   or up to the file-system root.
-
-
-.. confval:: console_output_style
-
-
-
-   Sets the console output style while running tests:
-
-   * ``classic``: classic pytest output.
-   * ``progress``: like classic pytest output, but with a progress indicator.
-   * ``count``: like progress, but shows progress as the number of tests completed instead of a percent.
-
-   The default is ``progress``, but you can fallback to ``classic`` if you prefer or
-   the new mode is causing unexpected problems:
-
-   .. code-block:: ini
-
-        # content of pytest.ini
-        [pytest]
-        console_output_style = classic
-
-
-.. confval:: doctest_encoding
-
-
-
-   Default encoding to use to decode text files with docstrings.
-   :doc:`See how pytest handles doctests <doctest>`.
-
-
-.. confval:: doctest_optionflags
-
-   One or more doctest flag names from the standard ``doctest`` module.
-   :doc:`See how pytest handles doctests <doctest>`.
-
-
-.. confval:: empty_parameter_set_mark
-
-
-
-    Allows to pick the action for empty parametersets in parameterization
-
-    * ``skip`` skips tests with an empty parameterset (default)
-    * ``xfail`` marks tests with an empty parameterset as xfail(run=False)
-    * ``fail_at_collect`` raises an exception if parametrize collects an empty parameter set
-
-    .. code-block:: ini
-
-      # content of pytest.ini
-      [pytest]
-      empty_parameter_set_mark = xfail
-
-    .. note::
-
-      The default value of this option is planned to change to ``xfail`` in future releases
-      as this is considered less error prone, see `#3155 <https://github.com/pytest-dev/pytest/issues/3155>`_
-      for more details.
-
-
-.. confval:: faulthandler_timeout
-
-   Dumps the tracebacks of all threads if a test takes longer than ``X`` seconds to run (including
-   fixture setup and teardown). Implemented using the `faulthandler.dump_traceback_later`_ function,
-   so all caveats there apply.
-
-   .. code-block:: ini
-
-        # content of pytest.ini
-        [pytest]
-        faulthandler_timeout=5
-
-   For more information please refer to :ref:`faulthandler`.
-
-.. _`faulthandler.dump_traceback_later`: https://docs.python.org/3/library/faulthandler.html#faulthandler.dump_traceback_later
-
-
-.. confval:: filterwarnings
-
-
-
-   Sets a list of filters and actions that should be taken for matched
-   warnings. By default all warnings emitted during the test session
-   will be displayed in a summary at the end of the test session.
-
-   .. code-block:: ini
-
-        # content of pytest.ini
-        [pytest]
-        filterwarnings =
-            error
-            ignore::DeprecationWarning
-
-   This tells pytest to ignore deprecation warnings and turn all other warnings
-   into errors. For more information please refer to :ref:`warnings`.
-
-
-.. confval:: junit_duration_report
-
-    .. versionadded:: 4.1
-
-    Configures how durations are recorded into the JUnit XML report:
-
-    * ``total`` (the default): duration times reported include setup, call, and teardown times.
-    * ``call``: duration times reported include only call times, excluding setup and teardown.
-
-    .. code-block:: ini
-
-        [pytest]
-        junit_duration_report = call
-
-
-.. confval:: junit_family
-
-    .. versionadded:: 4.2
-    .. versionchanged:: 6.1
-        Default changed to ``xunit2``.
-
-    Configures the format of the generated JUnit XML file. The possible options are:
-
-    * ``xunit1`` (or ``legacy``): produces old style output, compatible with the xunit 1.0 format.
-    * ``xunit2``: produces `xunit 2.0 style output <https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__, which should be more compatible with latest Jenkins versions.  **This is the default**.
-
-    .. code-block:: ini
-
-        [pytest]
-        junit_family = xunit2
-
-
-.. confval:: junit_logging
-
-    .. versionadded:: 3.5
-    .. versionchanged:: 5.4
-        ``log``, ``all``, ``out-err`` options added.
-
-    Configures if captured output should be written to the JUnit XML file. Valid values are:
-
-    * ``log``: write only ``logging`` captured output.
-    * ``system-out``: write captured ``stdout`` contents.
-    * ``system-err``: write captured ``stderr`` contents.
-    * ``out-err``: write both captured ``stdout`` and ``stderr`` contents.
-    * ``all``: write captured ``logging``, ``stdout`` and ``stderr`` contents.
-    * ``no`` (the default): no captured output is written.
-
-    .. code-block:: ini
-
-        [pytest]
-        junit_logging = system-out
-
-
-.. confval:: junit_log_passing_tests
-
-    .. versionadded:: 4.6
-
-    If ``junit_logging != "no"``, configures if the captured output should be written
-    to the JUnit XML file for **passing** tests. Default is ``True``.
-
-    .. code-block:: ini
-
-        [pytest]
-        junit_log_passing_tests = False
-
-
-.. confval:: junit_suite_name
-
-    To set the name of the root test suite xml item, you can configure the ``junit_suite_name`` option in your config file:
-
-    .. code-block:: ini
-
-        [pytest]
-        junit_suite_name = my_suite
-
-.. confval:: log_auto_indent
-
-    Allow selective auto-indentation of multiline log messages.
-
-    Supports command line option ``--log-auto-indent [value]``
-    and config option ``log_auto_indent = [value]`` to set the
-    auto-indentation behavior for all logging.
-
-    ``[value]`` can be:
-        * True or "On" - Dynamically auto-indent multiline log messages
-        * False or "Off" or 0 - Do not auto-indent multiline log messages (the default behavior)
-        * [positive integer] - auto-indent multiline log messages by [value] spaces
-
-    .. code-block:: ini
-
-        [pytest]
-        log_auto_indent = False
-
-    Supports passing kwarg ``extra={"auto_indent": [value]}`` to
-    calls to ``logging.log()`` to specify auto-indentation behavior for
-    a specific entry in the log. ``extra`` kwarg overrides the value specified
-    on the command line or in the config.
-
-.. confval:: log_cli
-
-    Enable log display during test run (also known as :ref:`"live logging" <live_logs>`).
-    The default is ``False``.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_cli = True
-
-.. confval:: log_cli_date_format
-
-
-
-    Sets a :py:func:`time.strftime`-compatible string that will be used when formatting dates for live logging.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_cli_date_format = %Y-%m-%d %H:%M:%S
-
-    For more information, see :ref:`live_logs`.
-
-.. confval:: log_cli_format
-
-
-
-    Sets a :py:mod:`logging`-compatible string used to format live logging messages.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_cli_format = %(asctime)s %(levelname)s %(message)s
-
-    For more information, see :ref:`live_logs`.
-
-
-.. confval:: log_cli_level
-
-
-
-    Sets the minimum log message level that should be captured for live logging. The integer value or
-    the names of the levels can be used.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_cli_level = INFO
-
-    For more information, see :ref:`live_logs`.
-
-
-.. confval:: log_date_format
-
-
-
-    Sets a :py:func:`time.strftime`-compatible string that will be used when formatting dates for logging capture.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_date_format = %Y-%m-%d %H:%M:%S
-
-    For more information, see :ref:`logging`.
-
-
-.. confval:: log_file
-
-
-
-    Sets a file name relative to the ``pytest.ini`` file where log messages should be written to, in addition
-    to the other logging facilities that are active.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_file = logs/pytest-logs.txt
-
-    For more information, see :ref:`logging`.
-
-
-.. confval:: log_file_date_format
-
-
-
-    Sets a :py:func:`time.strftime`-compatible string that will be used when formatting dates for the logging file.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_file_date_format = %Y-%m-%d %H:%M:%S
-
-    For more information, see :ref:`logging`.
-
-.. confval:: log_file_format
-
-
-
-    Sets a :py:mod:`logging`-compatible string used to format logging messages redirected to the logging file.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_file_format = %(asctime)s %(levelname)s %(message)s
-
-    For more information, see :ref:`logging`.
-
-.. confval:: log_file_level
-
-
-
-    Sets the minimum log message level that should be captured for the logging file. The integer value or
-    the names of the levels can be used.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_file_level = INFO
-
-    For more information, see :ref:`logging`.
-
-
-.. confval:: log_format
-
-
-
-    Sets a :py:mod:`logging`-compatible string used to format captured logging messages.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_format = %(asctime)s %(levelname)s %(message)s
-
-    For more information, see :ref:`logging`.
-
-
-.. confval:: log_level
-
-
-
-    Sets the minimum log message level that should be captured for logging capture. The integer value or
-    the names of the levels can be used.
-
-    .. code-block:: ini
-
-        [pytest]
-        log_level = INFO
-
-    For more information, see :ref:`logging`.
-
-
-.. confval:: markers
-
-    When the ``--strict-markers`` or ``--strict`` command-line arguments are used,
-    only known markers - defined in code by core pytest or some plugin - are allowed.
-
-    You can list additional markers in this setting to add them to the whitelist,
-    in which case you probably want to add ``--strict-markers`` to ``addopts``
-    to avoid future regressions:
-
-    .. code-block:: ini
-
-        [pytest]
-        addopts = --strict-markers
-        markers =
-            slow
-            serial
-
-    .. note::
-        The use of ``--strict-markers`` is highly preferred. ``--strict`` was kept for
-        backward compatibility only and may be confusing for others as it only applies to
-        markers and not to other options.
-
-.. confval:: minversion
-
-   Specifies a minimal pytest version required for running tests.
-
-   .. code-block:: ini
-
-        # content of pytest.ini
-        [pytest]
-        minversion = 3.0  # will fail if we run with pytest-2.8
-
-
-.. confval:: norecursedirs
-
-   Set the directory basename patterns to avoid when recursing
-   for test discovery.  The individual (fnmatch-style) patterns are
-   applied to the basename of a directory to decide if to recurse into it.
-   Pattern matching characters::
-
-        *       matches everything
-        ?       matches any single character
-        [seq]   matches any character in seq
-        [!seq]  matches any char not in seq
-
-   Default patterns are ``'*.egg'``, ``'.*'``, ``'_darcs'``, ``'build'``,
-   ``'CVS'``, ``'dist'``, ``'node_modules'``, ``'venv'``, ``'{arch}'``.
-   Setting a ``norecursedirs`` replaces the default.  Here is an example of
-   how to avoid certain directories:
-
-   .. code-block:: ini
-
-        [pytest]
-        norecursedirs = .svn _build tmp*
-
-   This would tell ``pytest`` to not look into typical subversion or
-   sphinx-build directories or into any ``tmp`` prefixed directory.
-
-   Additionally, ``pytest`` will attempt to intelligently identify and ignore a
-   virtualenv by the presence of an activation script.  Any directory deemed to
-   be the root of a virtual environment will not be considered during test
-   collection unless ``‑‑collect‑in‑virtualenv`` is given.  Note also that
-   ``norecursedirs`` takes precedence over ``‑‑collect‑in‑virtualenv``; e.g. if
-   you intend to run tests in a virtualenv with a base directory that matches
-   ``'.*'`` you *must* override ``norecursedirs`` in addition to using the
-   ``‑‑collect‑in‑virtualenv`` flag.
-
-
-.. confval:: python_classes
-
-   One or more name prefixes or glob-style patterns determining which classes
-   are considered for test collection. Search for multiple glob patterns by
-   adding a space between patterns. By default, pytest will consider any
-   class prefixed with ``Test`` as a test collection.  Here is an example of how
-   to collect tests from classes that end in ``Suite``:
-
-   .. code-block:: ini
-
-        [pytest]
-        python_classes = *Suite
-
-   Note that ``unittest.TestCase`` derived classes are always collected
-   regardless of this option, as ``unittest``'s own collection framework is used
-   to collect those tests.
-
-
-.. confval:: python_files
-
-   One or more Glob-style file patterns determining which python files
-   are considered as test modules. Search for multiple glob patterns by
-   adding a space between patterns:
-
-   .. code-block:: ini
-
-        [pytest]
-        python_files = test_*.py check_*.py example_*.py
-
-   Or one per line:
-
-   .. code-block:: ini
-
-        [pytest]
-        python_files =
-            test_*.py
-            check_*.py
-            example_*.py
-
-   By default, files matching ``test_*.py`` and ``*_test.py`` will be considered
-   test modules.
-
-
-.. confval:: python_functions
-
-   One or more name prefixes or glob-patterns determining which test functions
-   and methods are considered tests. Search for multiple glob patterns by
-   adding a space between patterns. By default, pytest will consider any
-   function prefixed with ``test`` as a test.  Here is an example of how
-   to collect test functions and methods that end in ``_test``:
-
-   .. code-block:: ini
-
-        [pytest]
-        python_functions = *_test
-
-   Note that this has no effect on methods that live on a ``unittest
-   .TestCase`` derived class, as ``unittest``'s own collection framework is used
-   to collect those tests.
-
-   See :ref:`change naming conventions` for more detailed examples.
-
-
-.. confval:: required_plugins
-
-   A space separated list of plugins that must be present for pytest to run.
-   Plugins can be listed with or without version specifiers directly following
-   their name. Whitespace between different version specifiers is not allowed.
-   If any one of the plugins is not found, emit an error.
-
-   .. code-block:: ini
-
-       [pytest]
-       required_plugins = pytest-django>=3.0.0,<4.0.0 pytest-html pytest-xdist>=1.0.0
-
-
-.. confval:: testpaths
-
-
-
-   Sets list of directories that should be searched for tests when
-   no specific directories, files or test ids are given in the command line when
-   executing pytest from the :ref:`rootdir <rootdir>` directory.
-   Useful when all project tests are in a known location to speed up
-   test collection and to avoid picking up undesired tests by accident.
-
-   .. code-block:: ini
-
-        [pytest]
-        testpaths = testing doc
-
-   This tells pytest to only look for tests in ``testing`` and ``doc``
-   directories when executing from the root directory.
-
-
-.. confval:: usefixtures
-
-    List of fixtures that will be applied to all test functions; this is semantically the same to apply
-    the ``@pytest.mark.usefixtures`` marker to all test functions.
-
-
-    .. code-block:: ini
-
-        [pytest]
-        usefixtures =
-            clean_db
-
-
-.. confval:: xfail_strict
-
-    If set to ``True``, tests marked with ``@pytest.mark.xfail`` that actually succeed will by default fail the
-    test suite.
-    For more information, see :ref:`xfail strict tutorial`.
-
-
-    .. code-block:: ini
-
-        [pytest]
-        xfail_strict = True
-
-
-.. _`command-line-flags`:
-
-Command-line Flags
-------------------
-
-All the command-line flags can be obtained by running ``pytest --help``::
-
-    $ pytest --help
-    usage: pytest [options] [file_or_dir] [file_or_dir] [...]
-
-    positional arguments:
-      file_or_dir
-
-    general:
-      -k EXPRESSION         only run tests which match the given substring
-                            expression. An expression is a python evaluatable
-                            expression where all names are substring-matched
-                            against test names and their parent classes.
-                            Example: -k 'test_method or test_other' matches all
-                            test functions and classes whose name contains
-                            'test_method' or 'test_other', while -k 'not
-                            test_method' matches those that don't contain
-                            'test_method' in their names. -k 'not test_method
-                            and not test_other' will eliminate the matches.
-                            Additionally keywords are matched to classes and
-                            functions containing extra names in their
-                            'extra_keyword_matches' set, as well as functions
-                            which have names assigned directly to them. The
-                            matching is case-insensitive.
-      -m MARKEXPR           only run tests matching given mark expression.
-                            For example: -m 'mark1 and not mark2'.
-      --markers             show markers (builtin, plugin and per-project ones).
-      -x, --exitfirst       exit instantly on first error or failed test.
-      --fixtures, --funcargs
-                            show available fixtures, sorted by plugin appearance
-                            (fixtures with leading '_' are only shown with '-v')
-      --fixtures-per-test   show fixtures per test
-      --pdb                 start the interactive Python debugger on errors or
-                            KeyboardInterrupt.
-      --pdbcls=modulename:classname
-                            start a custom interactive Python debugger on
-                            errors. For example:
-                            --pdbcls=IPython.terminal.debugger:TerminalPdb
-      --trace               Immediately break when running each test.
-      --capture=method      per-test capturing method: one of fd|sys|no|tee-sys.
-      -s                    shortcut for --capture=no.
-      --runxfail            report the results of xfail tests as if they were
-                            not marked
-      --lf, --last-failed   rerun only the tests that failed at the last run (or
-                            all if none failed)
-      --ff, --failed-first  run all tests, but run the last failures first.
-                            This may re-order tests and thus lead to repeated
-                            fixture setup/teardown.
-      --nf, --new-first     run tests from new files first, then the rest of the
-                            tests sorted by file mtime
-      --cache-show=[CACHESHOW]
-                            show cache contents, don't perform collection or
-                            tests. Optional argument: glob (default: '*').
-      --cache-clear         remove all cache contents at start of test run.
-      --lfnf={all,none}, --last-failed-no-failures={all,none}
-                            which tests to run with no previously (known)
-                            failures.
-      --sw, --stepwise      exit on test failure and continue from last failing
-                            test next time
-      --sw-skip, --stepwise-skip
-                            ignore the first failing test but stop on the next
-                            failing test
-
-    reporting:
-      --durations=N         show N slowest setup/test durations (N=0 for all).
-      --durations-min=N     Minimal duration in seconds for inclusion in slowest
-                            list. Default 0.005
-      -v, --verbose         increase verbosity.
-      --no-header           disable header
-      --no-summary          disable summary
-      -q, --quiet           decrease verbosity.
-      --verbosity=VERBOSE   set verbosity. Default is 0.
-      -r chars              show extra test summary info as specified by chars:
-                            (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed,
-                            (p)assed, (P)assed with output, (a)ll except passed
-                            (p/P), or (A)ll. (w)arnings are enabled by default
-                            (see --disable-warnings), 'N' can be used to reset
-                            the list. (default: 'fE').
-      --disable-warnings, --disable-pytest-warnings
-                            disable warnings summary
-      -l, --showlocals      show locals in tracebacks (disabled by default).
-      --tb=style            traceback print mode
-                            (auto/long/short/line/native/no).
-      --show-capture={no,stdout,stderr,log,all}
-                            Controls how captured stdout/stderr/log is shown on
-                            failed tests. Default is 'all'.
-      --full-trace          don't cut any tracebacks (default is to cut).
-      --color=color         color terminal output (yes/no/auto).
-      --code-highlight={yes,no}
-                            Whether code should be highlighted (only if --color
-                            is also enabled)
-      --pastebin=mode       send failed|all info to bpaste.net pastebin service.
-      --junit-xml=path      create junit-xml style report file at given path.
-      --junit-prefix=str    prepend prefix to classnames in junit-xml output
-
-    pytest-warnings:
-      -W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS
-                            set which warnings to report, see -W option of
-                            python itself.
-      --maxfail=num         exit after first num failures or errors.
-      --strict-config       any warnings encountered while parsing the `pytest`
-                            section of the configuration file raise errors.
-      --strict-markers      markers not registered in the `markers` section of
-                            the configuration file raise errors.
-      --strict              (deprecated) alias to --strict-markers.
-      -c file               load configuration from `file` instead of trying to
-                            locate one of the implicit configuration files.
-      --continue-on-collection-errors
-                            Force test execution even if collection errors
-                            occur.
-      --rootdir=ROOTDIR     Define root directory for tests. Can be relative
-                            path: 'root_dir', './root_dir',
-                            'root_dir/another_dir/'; absolute path:
-                            '/home/user/root_dir'; path with variables:
-                            '$HOME/root_dir'.
-
-    collection:
-      --collect-only, --co  only collect tests, don't execute them.
-      --pyargs              try to interpret all arguments as python packages.
-      --ignore=path         ignore path during collection (multi-allowed).
-      --ignore-glob=path    ignore path pattern during collection (multi-
-                            allowed).
-      --deselect=nodeid_prefix
-                            deselect item (via node id prefix) during collection
-                            (multi-allowed).
-      --confcutdir=dir      only load conftest.py's relative to specified dir.
-      --noconftest          Don't load any conftest.py files.
-      --keep-duplicates     Keep duplicate tests.
-      --collect-in-virtualenv
-                            Don't ignore tests in a local virtualenv directory
-      --import-mode={prepend,append,importlib}
-                            prepend/append to sys.path when importing test
-                            modules and conftest files, default is to prepend.
-      --doctest-modules     run doctests in all .py modules
-      --doctest-report={none,cdiff,ndiff,udiff,only_first_failure}
-                            choose another output format for diffs on doctest
-                            failure
-      --doctest-glob=pat    doctests file matching pattern, default: test*.txt
-      --doctest-ignore-import-errors
-                            ignore doctest ImportErrors
-      --doctest-continue-on-failure
-                            for a given doctest, continue to run after the first
-                            failure
-
-    test session debugging and configuration:
-      --basetemp=dir        base temporary directory for this test run.(warning:
-                            this directory is removed if it exists)
-      -V, --version         display pytest version and information about
-                            plugins.When given twice, also display information
-                            about plugins.
-      -h, --help            show help message and configuration info
-      -p name               early-load given plugin module name or entry point
-                            (multi-allowed).
-                            To avoid loading of plugins, use the `no:` prefix,
-                            e.g. `no:doctest`.
-      --trace-config        trace considerations of conftest.py files.
-      --debug               store internal tracing debug information in
-                            'pytestdebug.log'.
-      -o OVERRIDE_INI, --override-ini=OVERRIDE_INI
-                            override ini option with "option=value" style, e.g.
-                            `-o xfail_strict=True -o cache_dir=cache`.
-      --assert=MODE         Control assertion debugging tools.
-                            'plain' performs no assertion debugging.
-                            'rewrite' (the default) rewrites assert statements
-                            in test modules on import to provide assert
-                            expression information.
-      --setup-only          only setup fixtures, do not execute tests.
-      --setup-show          show setup of fixtures while executing tests.
-      --setup-plan          show what fixtures and tests would be executed but
-                            don't execute anything.
-
-    logging:
-      --log-level=LEVEL     level of messages to catch/display.
-                            Not set by default, so it depends on the root/parent
-                            log handler's effective level, where it is "WARNING"
-                            by default.
-      --log-format=LOG_FORMAT
-                            log format as used by the logging module.
-      --log-date-format=LOG_DATE_FORMAT
-                            log date format as used by the logging module.
-      --log-cli-level=LOG_CLI_LEVEL
-                            cli logging level.
-      --log-cli-format=LOG_CLI_FORMAT
-                            log format as used by the logging module.
-      --log-cli-date-format=LOG_CLI_DATE_FORMAT
-                            log date format as used by the logging module.
-      --log-file=LOG_FILE   path to a file when logging will be written to.
-      --log-file-level=LOG_FILE_LEVEL
-                            log file logging level.
-      --log-file-format=LOG_FILE_FORMAT
-                            log format as used by the logging module.
-      --log-file-date-format=LOG_FILE_DATE_FORMAT
-                            log date format as used by the logging module.
-      --log-auto-indent=LOG_AUTO_INDENT
-                            Auto-indent multiline messages passed to the logging
-                            module. Accepts true|on, false|off or an integer.
-
-    [pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:
-
-      markers (linelist):   markers for test functions
-      empty_parameter_set_mark (string):
-                            default marker for empty parametersets
-      norecursedirs (args): directory patterns to avoid for recursion
-      testpaths (args):     directories to search for tests when no files or
-                            directories are given in the command line.
-      filterwarnings (linelist):
-                            Each line specifies a pattern for
-                            warnings.filterwarnings. Processed after
-                            -W/--pythonwarnings.
-      usefixtures (args):   list of default fixtures to be used with this
-                            project
-      python_files (args):  glob-style file patterns for Python test module
-                            discovery
-      python_classes (args):
-                            prefixes or glob names for Python test class
-                            discovery
-      python_functions (args):
-                            prefixes or glob names for Python test function and
-                            method discovery
-      disable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool):
-                            disable string escape non-ascii characters, might
-                            cause unwanted side effects(use at your own risk)
-      console_output_style (string):
-                            console output: "classic", or with additional
-                            progress information ("progress" (percentage) |
-                            "count").
-      xfail_strict (bool):  default for the strict parameter of xfail markers
-                            when not given explicitly (default: False)
-      enable_assertion_pass_hook (bool):
-                            Enables the pytest_assertion_pass hook.Make sure to
-                            delete any previously generated pyc cache files.
-      junit_suite_name (string):
-                            Test suite name for JUnit report
-      junit_logging (string):
-                            Write captured log messages to JUnit report: one of
-                            no|log|system-out|system-err|out-err|all
-      junit_log_passing_tests (bool):
-                            Capture log information for passing tests to JUnit
-                            report:
-      junit_duration_report (string):
-                            Duration time to report: one of total|call
-      junit_family (string):
-                            Emit XML for schema: one of legacy|xunit1|xunit2
-      doctest_optionflags (args):
-                            option flags for doctests
-      doctest_encoding (string):
-                            encoding used for doctest files
-      cache_dir (string):   cache directory path.
-      log_level (string):   default value for --log-level
-      log_format (string):  default value for --log-format
-      log_date_format (string):
-                            default value for --log-date-format
-      log_cli (bool):       enable log display during test run (also known as
-                            "live logging").
-      log_cli_level (string):
-                            default value for --log-cli-level
-      log_cli_format (string):
-                            default value for --log-cli-format
-      log_cli_date_format (string):
-                            default value for --log-cli-date-format
-      log_file (string):    default value for --log-file
-      log_file_level (string):
-                            default value for --log-file-level
-      log_file_format (string):
-                            default value for --log-file-format
-      log_file_date_format (string):
-                            default value for --log-file-date-format
-      log_auto_indent (string):
-                            default value for --log-auto-indent
-      faulthandler_timeout (string):
-                            Dump the traceback of all threads if a test takes
-                            more than TIMEOUT seconds to finish.
-      addopts (args):       extra command line options
-      minversion (string):  minimally required pytest version
-      required_plugins (args):
-                            plugins that must be present for pytest to run
-
-    environment variables:
-      PYTEST_ADDOPTS           extra command line options
-      PYTEST_PLUGINS           comma-separated plugins to load during startup
-      PYTEST_DISABLE_PLUGIN_AUTOLOAD set to disable plugin auto-loading
-      PYTEST_DEBUG             set to enable debug tracing of pytest's internals
-
-
-    to see available markers type: pytest --markers
-    to see available fixtures type: pytest --fixtures
-    (shown according to specified file_or_dir or current dir if not specified; fixtures with leading '_' are only shown with the '-v' option
diff --git a/doc/en/reference/customize.rst b/doc/en/reference/customize.rst
new file mode 100644 (file)
index 0000000..24c0ed2
--- /dev/null
@@ -0,0 +1,250 @@
+Configuration
+=============
+
+Command line options and configuration file settings
+-----------------------------------------------------------------
+
+You can get help on command line options and values in INI-style
+configurations files by using the general help option:
+
+.. code-block:: bash
+
+    pytest -h   # prints options _and_ config file settings
+
+This will display command line and configuration file settings
+which were registered by installed plugins.
+
+.. _`config file formats`:
+
+Configuration file formats
+--------------------------
+
+Many :ref:`pytest settings <ini options ref>` can be set in a *configuration file*, which
+by convention resides in the root directory of your repository.
+
+A quick example of the configuration files supported by pytest:
+
+pytest.ini
+~~~~~~~~~~
+
+``pytest.ini`` files take precedence over other files, even when empty.
+
+Alternatively, the hidden version ``.pytest.ini`` can be used.
+
+.. code-block:: ini
+
+    # pytest.ini or .pytest.ini
+    [pytest]
+    minversion = 6.0
+    addopts = -ra -q
+    testpaths =
+        tests
+        integration
+
+
+pyproject.toml
+~~~~~~~~~~~~~~
+
+.. versionadded:: 6.0
+
+``pyproject.toml`` are considered for configuration when they contain a ``tool.pytest.ini_options`` table.
+
+.. code-block:: toml
+
+    # pyproject.toml
+    [tool.pytest.ini_options]
+    minversion = "6.0"
+    addopts = "-ra -q"
+    testpaths = [
+        "tests",
+        "integration",
+    ]
+
+.. note::
+
+    One might wonder why ``[tool.pytest.ini_options]`` instead of ``[tool.pytest]`` as is the
+    case with other tools.
+
+    The reason is that the pytest team intends to fully utilize the rich TOML data format
+    for configuration in the future, reserving the ``[tool.pytest]`` table for that.
+    The ``ini_options`` table is being used, for now, as a bridge between the existing
+    ``.ini`` configuration system and the future configuration format.
+
+tox.ini
+~~~~~~~
+
+``tox.ini`` files are the configuration files of the `tox <https://tox.readthedocs.io>`__ project,
+and can also be used to hold pytest configuration if they have a ``[pytest]`` section.
+
+.. code-block:: ini
+
+    # tox.ini
+    [pytest]
+    minversion = 6.0
+    addopts = -ra -q
+    testpaths =
+        tests
+        integration
+
+
+setup.cfg
+~~~~~~~~~
+
+``setup.cfg`` files are general purpose configuration files, used originally by ``distutils`` (now deprecated) and `setuptools <https://setuptools.pypa.io/en/latest/userguide/declarative_config.html>`__, and can also be used to hold pytest configuration
+if they have a ``[tool:pytest]`` section.
+
+.. code-block:: ini
+
+    # setup.cfg
+    [tool:pytest]
+    minversion = 6.0
+    addopts = -ra -q
+    testpaths =
+        tests
+        integration
+
+.. warning::
+
+    Usage of ``setup.cfg`` is not recommended unless for very simple use cases. ``.cfg``
+    files use a different parser than ``pytest.ini`` and ``tox.ini`` which might cause hard to track
+    down problems.
+    When possible, it is recommended to use the latter files, or ``pyproject.toml``, to hold your
+    pytest configuration.
+
+
+.. _rootdir:
+.. _configfiles:
+
+Initialization: determining rootdir and configfile
+--------------------------------------------------
+
+pytest determines a ``rootdir`` for each test run which depends on
+the command line arguments (specified test files, paths) and on
+the existence of configuration files.  The determined ``rootdir`` and ``configfile`` are
+printed as part of the pytest header during startup.
+
+Here's a summary what ``pytest`` uses ``rootdir`` for:
+
+* Construct *nodeids* during collection; each test is assigned
+  a unique *nodeid* which is rooted at the ``rootdir`` and takes into account
+  the full path, class name, function name and parametrization (if any).
+
+* Is used by plugins as a stable location to store project/test run specific information;
+  for example, the internal :ref:`cache <cache>` plugin creates a ``.pytest_cache`` subdirectory
+  in ``rootdir`` to store its cross-test run state.
+
+``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
+influence how modules are imported. See :ref:`pythonpath` for more details.
+
+The ``--rootdir=path`` command-line option can be used to force a specific directory.
+Note that contrary to other command-line options, ``--rootdir`` cannot be used with
+:confval:`addopts` inside ``pytest.ini`` because the ``rootdir`` is used to *find* ``pytest.ini``
+already.
+
+Finding the ``rootdir``
+~~~~~~~~~~~~~~~~~~~~~~~
+
+Here is the algorithm which finds the rootdir from ``args``:
+
+- If ``-c`` is passed in the command-line, use that as configuration file, and its directory as ``rootdir``.
+
+- Determine the common ancestor directory for the specified ``args`` that are
+  recognised as paths that exist in the file system. If no such paths are
+  found, the common ancestor directory is set to the current working directory.
+
+- Look for ``pytest.ini``, ``pyproject.toml``, ``tox.ini``, and ``setup.cfg`` files in the ancestor
+  directory and upwards.  If one is matched, it becomes the ``configfile`` and its
+  directory becomes the ``rootdir``.
+
+- If no configuration file was found, look for ``setup.py`` upwards from the common
+  ancestor directory to determine the ``rootdir``.
+
+- If no ``setup.py`` was found, look for ``pytest.ini``, ``pyproject.toml``, ``tox.ini``, and
+  ``setup.cfg`` in each of the specified ``args`` and upwards. If one is
+  matched, it becomes the ``configfile`` and its directory becomes the ``rootdir``.
+
+- If no ``configfile`` was found and no configuration argument is passed, use the already determined common ancestor as root
+  directory. This allows the use of pytest in structures that are not part of
+  a package and don't have any particular configuration file.
+
+If no ``args`` are given, pytest collects test below the current working
+directory and also starts determining the ``rootdir`` from there.
+
+Files will only be matched for configuration if:
+
+* ``pytest.ini``: will always match and take precedence, even if empty.
+* ``pyproject.toml``: contains a ``[tool.pytest.ini_options]`` table.
+* ``tox.ini``: contains a ``[pytest]`` section.
+* ``setup.cfg``: contains a ``[tool:pytest]`` section.
+
+The files are considered in the order above. Options from multiple ``configfiles`` candidates
+are never merged - the first match wins.
+
+The :class:`Config <pytest.Config>` object (accessible via hooks or through the :fixture:`pytestconfig` fixture)
+will subsequently carry these attributes:
+
+- :attr:`config.rootpath <pytest.Config.rootpath>`: the determined root directory, guaranteed to exist.
+
+- :attr:`config.inipath <pytest.Config.inipath>`: the determined ``configfile``, may be ``None``
+  (it is named ``inipath`` for historical reasons).
+
+.. versionadded:: 6.1
+    The ``config.rootpath`` and ``config.inipath`` properties. They are :class:`pathlib.Path`
+    versions of the older ``config.rootdir`` and ``config.inifile``, which have type
+    ``py.path.local``, and still exist for backward compatibility.
+
+The ``rootdir`` is used as a reference directory for constructing test
+addresses ("nodeids") and can be used also by plugins for storing
+per-testrun information.
+
+Example:
+
+.. code-block:: bash
+
+    pytest path/to/testdir path/other/
+
+will determine the common ancestor as ``path`` and then
+check for configuration files as follows:
+
+.. code-block:: text
+
+    # first look for pytest.ini files
+    path/pytest.ini
+    path/pyproject.toml  # must contain a [tool.pytest.ini_options] table to match
+    path/tox.ini         # must contain [pytest] section to match
+    path/setup.cfg       # must contain [tool:pytest] section to match
+    pytest.ini
+    ... # all the way up to the root
+
+    # now look for setup.py
+    path/setup.py
+    setup.py
+    ... # all the way up to the root
+
+
+.. warning::
+
+    Custom pytest plugin commandline arguments may include a path, as in
+    ``pytest --log-output ../../test.log args``. Then ``args`` is mandatory,
+    otherwise pytest uses the folder of test.log for rootdir determination
+    (see also :issue:`1435`).
+    A dot ``.`` for referencing to the current working directory is also
+    possible.
+
+
+.. _`how to change command line options defaults`:
+.. _`adding default options`:
+
+
+Builtin configuration file options
+----------------------------------------------
+
+For the full list of options consult the :ref:`reference documentation <ini options ref>`.
+
+Syntax highlighting theme customization
+---------------------------------------
+
+The syntax highlighting themes used by pytest can be customized using two environment variables:
+
+- :envvar:`PYTEST_THEME` sets a `pygment style <https://pygments.org/docs/styles/>`_ to use.
+- :envvar:`PYTEST_THEME_MODE` sets this style to *light* or *dark*.
diff --git a/doc/en/reference/exit-codes.rst b/doc/en/reference/exit-codes.rst
new file mode 100644 (file)
index 0000000..b695ca3
--- /dev/null
@@ -0,0 +1,26 @@
+.. _exit-codes:
+
+Exit codes
+========================================================
+
+Running ``pytest`` can result in six different exit codes:
+
+:Exit code 0: All tests were collected and passed successfully
+:Exit code 1: Tests were collected and run but some of the tests failed
+:Exit code 2: Test execution was interrupted by the user
+:Exit code 3: Internal error happened while executing tests
+:Exit code 4: pytest command line usage error
+:Exit code 5: No tests were collected
+
+They are represented by the :class:`pytest.ExitCode` enum. The exit codes being a part of the public API can be imported and accessed directly using:
+
+.. code-block:: python
+
+    from pytest import ExitCode
+
+.. note::
+
+    If you would like to customize the exit code in some scenarios, specially when
+    no tests are collected, consider using the
+    `pytest-custom_exit_code <https://github.com/yashtodi94/pytest-custom_exit_code>`__
+    plugin.
diff --git a/doc/en/reference/fixtures.rst b/doc/en/reference/fixtures.rst
new file mode 100644 (file)
index 0000000..01f8252
--- /dev/null
@@ -0,0 +1,455 @@
+.. _reference-fixtures:
+.. _fixture:
+.. _fixtures:
+.. _`@pytest.fixture`:
+.. _`pytest.fixture`:
+
+
+Fixtures reference
+========================================================
+
+.. seealso:: :ref:`about-fixtures`
+.. seealso:: :ref:`how-to-fixtures`
+
+
+.. currentmodule:: _pytest.python
+
+.. _`Dependency injection`: https://en.wikipedia.org/wiki/Dependency_injection
+
+
+Built-in fixtures
+-----------------
+
+:ref:`Fixtures <fixtures-api>` are defined using the :ref:`@pytest.fixture
+<pytest.fixture-api>` decorator. Pytest has several useful built-in fixtures:
+
+   :fixture:`capfd`
+        Capture, as text, output to file descriptors ``1`` and ``2``.
+
+   :fixture:`capfdbinary`
+        Capture, as bytes, output to file descriptors ``1`` and ``2``.
+
+   :fixture:`caplog`
+        Control logging and access log entries.
+
+   :fixture:`capsys`
+        Capture, as text, output to ``sys.stdout`` and ``sys.stderr``.
+
+   :fixture:`capsysbinary`
+        Capture, as bytes, output to ``sys.stdout`` and ``sys.stderr``.
+
+   :fixture:`cache`
+        Store and retrieve values across pytest runs.
+
+   :fixture:`doctest_namespace`
+        Provide a dict injected into the docstests namespace.
+
+   :fixture:`monkeypatch`
+       Temporarily modify classes, functions, dictionaries,
+       ``os.environ``, and other objects.
+
+   :fixture:`pytestconfig`
+        Access to configuration values, pluginmanager and plugin hooks.
+
+   :fixture:`record_property`
+       Add extra properties to the test.
+
+   :fixture:`record_testsuite_property`
+       Add extra properties to the test suite.
+
+   :fixture:`recwarn`
+        Record warnings emitted by test functions.
+
+   :fixture:`request`
+       Provide information on the executing test function.
+
+   :fixture:`testdir`
+        Provide a temporary test directory to aid in running, and
+        testing, pytest plugins.
+
+   :fixture:`tmp_path`
+       Provide a :class:`pathlib.Path` object to a temporary directory
+       which is unique to each test function.
+
+   :fixture:`tmp_path_factory`
+        Make session-scoped temporary directories and return
+        :class:`pathlib.Path` objects.
+
+   :fixture:`tmpdir`
+        Provide a :class:`py.path.local` object to a temporary
+        directory which is unique to each test function;
+        replaced by :fixture:`tmp_path`.
+
+        .. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
+
+   :fixture:`tmpdir_factory`
+        Make session-scoped temporary directories and return
+        :class:`py.path.local` objects;
+        replaced by :fixture:`tmp_path_factory`.
+
+
+.. _`conftest.py`:
+.. _`conftest`:
+
+Fixture availability
+---------------------
+
+Fixture availability is determined from the perspective of the test. A fixture
+is only available for tests to request if they are in the scope that fixture is
+defined in. If a fixture is defined inside a class, it can only be requested by
+tests inside that class. But if a fixture is defined inside the global scope of
+the module, than every test in that module, even if it's defined inside a class,
+can request it.
+
+Similarly, a test can also only be affected by an autouse fixture if that test
+is in the same scope that autouse fixture is defined in (see
+:ref:`autouse order`).
+
+A fixture can also request any other fixture, no matter where it's defined, so
+long as the test requesting them can see all fixtures involved.
+
+For example, here's a test file with a fixture (``outer``) that requests a
+fixture (``inner``) from a scope it wasn't defined in:
+
+.. literalinclude:: /example/fixtures/test_fixtures_request_different_scope.py
+
+From the tests' perspectives, they have no problem seeing each of the fixtures
+they're dependent on:
+
+.. image:: /example/fixtures/test_fixtures_request_different_scope.*
+    :align: center
+
+So when they run, ``outer`` will have no problem finding ``inner``, because
+pytest searched from the tests' perspectives.
+
+.. note::
+    The scope a fixture is defined in has no bearing on the order it will be
+    instantiated in: the order is mandated by the logic described
+    :ref:`here <fixture order>`.
+
+``conftest.py``: sharing fixtures across multiple files
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The ``conftest.py`` file serves as a means of providing fixtures for an entire
+directory. Fixtures defined in a ``conftest.py`` can be used by any test
+in that package without needing to import them (pytest will automatically
+discover them).
+
+You can have multiple nested directories/packages containing your tests, and
+each directory can have its own ``conftest.py`` with its own fixtures, adding on
+to the ones provided by the ``conftest.py`` files in parent directories.
+
+For example, given a test file structure like this:
+
+::
+
+    tests/
+        __init__.py
+
+        conftest.py
+            # content of tests/conftest.py
+            import pytest
+
+            @pytest.fixture
+            def order():
+                return []
+
+            @pytest.fixture
+            def top(order, innermost):
+                order.append("top")
+
+        test_top.py
+            # content of tests/test_top.py
+            import pytest
+
+            @pytest.fixture
+            def innermost(order):
+                order.append("innermost top")
+
+            def test_order(order, top):
+                assert order == ["innermost top", "top"]
+
+        subpackage/
+            __init__.py
+
+            conftest.py
+                # content of tests/subpackage/conftest.py
+                import pytest
+
+                @pytest.fixture
+                def mid(order):
+                    order.append("mid subpackage")
+
+            test_subpackage.py
+                # content of tests/subpackage/test_subpackage.py
+                import pytest
+
+                @pytest.fixture
+                def innermost(order, mid):
+                    order.append("innermost subpackage")
+
+                def test_order(order, top):
+                    assert order == ["mid subpackage", "innermost subpackage", "top"]
+
+The boundaries of the scopes can be visualized like this:
+
+.. image:: /example/fixtures/fixture_availability.*
+    :align: center
+
+The directories become their own sort of scope where fixtures that are defined
+in a ``conftest.py`` file in that directory become available for that whole
+scope.
+
+Tests are allowed to search upward (stepping outside a circle) for fixtures, but
+can never go down (stepping inside a circle) to continue their search. So
+``tests/subpackage/test_subpackage.py::test_order`` would be able to find the
+``innermost`` fixture defined in ``tests/subpackage/test_subpackage.py``, but
+the one defined in ``tests/test_top.py`` would be unavailable to it because it
+would have to step down a level (step inside a circle) to find it.
+
+The first fixture the test finds is the one that will be used, so
+:ref:`fixtures can be overridden <override fixtures>` if you need to change or
+extend what one does for a particular scope.
+
+You can also use the ``conftest.py`` file to implement
+:ref:`local per-directory plugins <conftest.py plugins>`.
+
+Fixtures from third-party plugins
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Fixtures don't have to be defined in this structure to be available for tests,
+though. They can also be provided by third-party plugins that are installed, and
+this is how many pytest plugins operate. As long as those plugins are installed,
+the fixtures they provide can be requested from anywhere in your test suite.
+
+Because they're provided from outside the structure of your test suite,
+third-party plugins don't really provide a scope like `conftest.py` files and
+the directories in your test suite do. As a result, pytest will search for
+fixtures stepping out through scopes as explained previously, only reaching
+fixtures defined in plugins *last*.
+
+For example, given the following file structure:
+
+::
+
+    tests/
+        __init__.py
+
+        conftest.py
+            # content of tests/conftest.py
+            import pytest
+
+            @pytest.fixture
+            def order():
+                return []
+
+        subpackage/
+            __init__.py
+
+            conftest.py
+                # content of tests/subpackage/conftest.py
+                import pytest
+
+                @pytest.fixture(autouse=True)
+                def mid(order, b_fix):
+                    order.append("mid subpackage")
+
+            test_subpackage.py
+                # content of tests/subpackage/test_subpackage.py
+                import pytest
+
+                @pytest.fixture
+                def inner(order, mid, a_fix):
+                    order.append("inner subpackage")
+
+                def test_order(order, inner):
+                    assert order == ["b_fix", "mid subpackage", "a_fix", "inner subpackage"]
+
+If ``plugin_a`` is installed and provides the fixture ``a_fix``, and
+``plugin_b`` is installed and provides the fixture ``b_fix``, then this is what
+the test's search for fixtures would look like:
+
+.. image:: /example/fixtures/fixture_availability_plugins.svg
+    :align: center
+
+pytest will only search for ``a_fix`` and ``b_fix`` in the plugins after
+searching for them first in the scopes inside ``tests/``.
+
+.. note:
+
+    pytest can tell you what fixtures are available for a given test if you call
+    ``pytests`` along with the test's name (or the scope it's in), and provide
+    the ``--fixtures`` flag, e.g. ``pytest --fixtures test_something.py``
+    (fixtures with names that start with ``_`` will only be shown if you also
+    provide the ``-v`` flag).
+
+
+.. _`fixture order`:
+
+Fixture instantiation order
+---------------------------
+
+When pytest wants to execute a test, once it knows what fixtures will be
+executed, it has to figure out the order they'll be executed in. To do this, it
+considers 3 factors:
+
+1. scope
+2. dependencies
+3. autouse
+
+Names of fixtures or tests, where they're defined, the order they're defined in,
+and the order fixtures are requested in have no bearing on execution order
+beyond coincidence. While pytest will try to make sure coincidences like these
+stay consistent from run to run, it's not something that should be depended on.
+If you want to control the order, it's safest to rely on these 3 things and make
+sure dependencies are clearly established.
+
+Higher-scoped fixtures are executed first
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Within a function request for fixtures, those of higher-scopes (such as
+``session``) are executed before lower-scoped fixtures (such as ``function`` or
+``class``).
+
+Here's an example:
+
+.. literalinclude:: /example/fixtures/test_fixtures_order_scope.py
+
+The test will pass because the larger scoped fixtures are executing first.
+
+The order breaks down to this:
+
+.. image:: /example/fixtures/test_fixtures_order_scope.*
+    :align: center
+
+Fixtures of the same order execute based on dependencies
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+When a fixture requests another fixture, the other fixture is executed first.
+So if fixture ``a`` requests fixture ``b``, fixture ``b`` will execute first,
+because ``a`` depends on ``b`` and can't operate without it. Even if ``a``
+doesn't need the result of ``b``, it can still request ``b`` if it needs to make
+sure it is executed after ``b``.
+
+For example:
+
+.. literalinclude:: /example/fixtures/test_fixtures_order_dependencies.py
+
+If we map out what depends on what, we get something that looks like this:
+
+.. image:: /example/fixtures/test_fixtures_order_dependencies.*
+    :align: center
+
+The rules provided by each fixture (as to what fixture(s) each one has to come
+after) are comprehensive enough that it can be flattened to this:
+
+.. image:: /example/fixtures/test_fixtures_order_dependencies_flat.*
+    :align: center
+
+Enough information has to be provided through these requests in order for pytest
+to be able to figure out a clear, linear chain of dependencies, and as a result,
+an order of operations for a given test. If there's any ambiguity, and the order
+of operations can be interpreted more than one way, you should assume pytest
+could go with any one of those interpretations at any point.
+
+For example, if ``d`` didn't request ``c``, i.e.the graph would look like this:
+
+.. image:: /example/fixtures/test_fixtures_order_dependencies_unclear.*
+    :align: center
+
+Because nothing requested ``c`` other than ``g``, and ``g`` also requests ``f``,
+it's now unclear if ``c`` should go before/after ``f``, ``e``, or ``d``. The
+only rules that were set for ``c`` is that it must execute after ``b`` and
+before ``g``.
+
+pytest doesn't know where ``c`` should go in the case, so it should be assumed
+that it could go anywhere between ``g`` and ``b``.
+
+This isn't necessarily bad, but it's something to keep in mind. If the order
+they execute in could affect the behavior a test is targeting, or could
+otherwise influence the result of a test, then the order should be defined
+explicitly in a way that allows pytest to linearize/"flatten" that order.
+
+.. _`autouse order`:
+
+Autouse fixtures are executed first within their scope
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Autouse fixtures are assumed to apply to every test that could reference them,
+so they are executed before other fixtures in that scope. Fixtures that are
+requested by autouse fixtures effectively become autouse fixtures themselves for
+the tests that the real autouse fixture applies to.
+
+So if fixture ``a`` is autouse and fixture ``b`` is not, but fixture ``a``
+requests fixture ``b``, then fixture ``b`` will effectively be an autouse
+fixture as well, but only for the tests that ``a`` applies to.
+
+In the last example, the graph became unclear if ``d`` didn't request ``c``. But
+if ``c`` was autouse, then ``b`` and ``a`` would effectively also be autouse
+because ``c`` depends on them. As a result, they would all be shifted above
+non-autouse fixtures within that scope.
+
+So if the test file looked like this:
+
+.. literalinclude:: /example/fixtures/test_fixtures_order_autouse.py
+
+the graph would look like this:
+
+.. image:: /example/fixtures/test_fixtures_order_autouse.*
+    :align: center
+
+Because ``c`` can now be put above ``d`` in the graph, pytest can once again
+linearize the graph to this:
+
+.. image:: /example/fixtures/test_fixtures_order_autouse_flat.*
+    :align: center
+
+In this example, ``c`` makes ``b`` and ``a`` effectively autouse fixtures as
+well.
+
+Be careful with autouse, though, as an autouse fixture will automatically
+execute for every test that can reach it, even if they don't request it. For
+example, consider this file:
+
+.. literalinclude:: /example/fixtures/test_fixtures_order_autouse_multiple_scopes.py
+
+Even though nothing in ``TestClassWithoutC1Request`` is requesting ``c1``, it still
+is executed for the tests inside it anyway:
+
+.. image:: /example/fixtures/test_fixtures_order_autouse_multiple_scopes.*
+    :align: center
+
+But just because one autouse fixture requested a non-autouse fixture, that
+doesn't mean the non-autouse fixture becomes an autouse fixture for all contexts
+that it can apply to. It only effectively becomes an autouse fixture for the
+contexts the real autouse fixture (the one that requested the non-autouse
+fixture) can apply to.
+
+For example, take a look at this test file:
+
+.. literalinclude:: /example/fixtures/test_fixtures_order_autouse_temp_effects.py
+
+It would break down to something like this:
+
+.. image:: /example/fixtures/test_fixtures_order_autouse_temp_effects.*
+    :align: center
+
+For ``test_req`` and ``test_no_req`` inside ``TestClassWithAutouse``, ``c3``
+effectively makes ``c2`` an autouse fixture, which is why ``c2`` and ``c3`` are
+executed for both tests, despite not being requested, and why ``c2`` and ``c3``
+are executed before ``c1`` for ``test_req``.
+
+If this made ``c2`` an *actual* autouse fixture, then ``c2`` would also execute
+for the tests inside ``TestClassWithoutAutouse``, since they can reference
+``c2`` if they wanted to. But it doesn't, because from the perspective of the
+``TestClassWithoutAutouse`` tests, ``c2`` isn't an autouse fixture, since they
+can't see ``c3``.
+
+
+.. note:
+
+    pytest can tell you what order the fixtures will execute in for a given test
+    if you call ``pytests`` along with the test's name (or the scope it's in),
+    and provide the ``--setup-plan`` flag, e.g.
+    ``pytest --setup-plan test_something.py`` (fixtures with names that start
+    with ``_`` will only be shown if you also provide the ``-v`` flag).
diff --git a/doc/en/reference/index.rst b/doc/en/reference/index.rst
new file mode 100644 (file)
index 0000000..ee1b2e6
--- /dev/null
@@ -0,0 +1,15 @@
+:orphan:
+
+.. _reference:
+
+Reference guides
+================
+
+.. toctree::
+   :maxdepth: 1
+
+   reference
+   fixtures
+   customize
+   exit-codes
+   plugin_list
diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst
new file mode 100644 (file)
index 0000000..42b6a9a
--- /dev/null
@@ -0,0 +1,10174 @@
+
+.. _plugin-list:
+
+Pytest Plugin List
+==================
+
+Below is an automated compilation of ``pytest``` plugins available on `PyPI <https://pypi.org>`_.
+It includes PyPI projects whose names begin with "pytest-" and a handful of manually selected projects.
+Packages classified as inactive are excluded.
+
+For detailed insights into how this list is generated,
+please refer to `the update script <https://github.com/pytest-dev/pytest/blob/main/scripts/update-plugin-list.py>`_.
+
+.. warning::
+
+   Please be aware that this list is not a curated collection of projects
+   and does not undergo a systematic review process.
+   It serves purely as an informational resource to aid in the discovery of ``pytest`` plugins.
+
+   Do not presume any endorsement from the ``pytest`` project or its developers,
+   and always conduct your own quality assessment before incorporating any of these plugins into your own projects.
+
+
+.. The following conditional uses a different format for this list when
+   creating a PDF, because otherwise the table gets far too wide for the
+   page.
+
+This list contains 1267 plugins.
+
+.. only:: not latex
+
+   ===============================================  ========================================================================================================================================================================================================  ==============  =====================  ================================================
+   name                                             summary                                                                                                                                                                                                   last release    status                 requires
+   ===============================================  ========================================================================================================================================================================================================  ==============  =====================  ================================================
+   :pypi:`logassert`                                Simple but powerful assertion and verification of logged lines.                                                                                                                                           May 20, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-abq`                               Pytest integration for the ABQ universal test runner.                                                                                                                                                     Apr 07, 2023    N/A                    N/A
+   :pypi:`pytest-abstracts`                         A contextmanager pytest fixture for handling multiple mock abstracts                                                                                                                                      May 25, 2022    N/A                    N/A
+   :pypi:`pytest-accept`                            A pytest-plugin for updating doctest outputs                                                                                                                                                              Dec 21, 2022    N/A                    pytest (>=6,<8)
+   :pypi:`pytest-adaptavist`                        pytest plugin for generating test execution results within Jira Test Management (tm4j)                                                                                                                    Oct 13, 2022    N/A                    pytest (>=5.4.0)
+   :pypi:`pytest-addons-test`                       用于测试pytest的插件                                                                                                                                                                                      Aug 02, 2021    N/A                    pytest (>=6.2.4,<7.0.0)
+   :pypi:`pytest-adf`                               Pytest plugin for writing Azure Data Factory integration tests                                                                                                                                            May 10, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-adf-azure-identity`                Pytest plugin for writing Azure Data Factory integration tests                                                                                                                                            Mar 06, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-ads-testplan`                      Azure DevOps Test Case reporting for pytest tests                                                                                                                                                         Sep 15, 2022    N/A                    N/A
+   :pypi:`pytest-agent`                             Service that exposes a REST API that can be used to interract remotely with Pytest. It is shipped with a dashboard that enables running tests in a more convenient way.                                   Nov 25, 2021    N/A                    N/A
+   :pypi:`pytest-aggreport`                         pytest plugin for pytest-repeat that generate aggregate report of the same test cases with additional statistics details.                                                                                 Mar 07, 2021    4 - Beta               pytest (>=6.2.2)
+   :pypi:`pytest-aio`                               Pytest plugin for testing async python code                                                                                                                                                               Feb 03, 2023    4 - Beta               pytest
+   :pypi:`pytest-aiofiles`                          pytest fixtures for writing aiofiles tests with pyfakefs                                                                                                                                                  May 14, 2017    5 - Production/Stable  N/A
+   :pypi:`pytest-aiogram`                                                                                                                                                                                                                                     May 06, 2023    N/A                    N/A
+   :pypi:`pytest-aiohttp`                           Pytest plugin for aiohttp support                                                                                                                                                                         Feb 12, 2022    4 - Beta               pytest (>=6.1.0)
+   :pypi:`pytest-aiohttp-client`                    Pytest \`client\` fixture for the Aiohttp                                                                                                                                                                 Jan 10, 2023    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-aiomoto`                           pytest-aiomoto                                                                                                                                                                                            Nov 09, 2022    N/A                    pytest (>=7.0,<8.0)
+   :pypi:`pytest-aioresponses`                      py.test integration for aioresponses                                                                                                                                                                      Jul 29, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-aioworkers`                        A plugin to test aioworkers project with pytest                                                                                                                                                           May 01, 2023    5 - Production/Stable  pytest>=6.1.0
+   :pypi:`pytest-airflow`                           pytest support for airflow.                                                                                                                                                                               Apr 03, 2019    3 - Alpha              pytest (>=4.4.0)
+   :pypi:`pytest-airflow-utils`                                                                                                                                                                                                                               Nov 15, 2021    N/A                    N/A
+   :pypi:`pytest-alembic`                           A pytest plugin for verifying alembic migrations.                                                                                                                                                         May 23, 2023    N/A                    pytest (>=6.0)
+   :pypi:`pytest-allclose`                          Pytest fixture extending Numpy's allclose function                                                                                                                                                        Jul 30, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-allure-adaptor`                    Plugin for py.test to generate allure xml reports                                                                                                                                                         Jan 10, 2018    N/A                    pytest (>=2.7.3)
+   :pypi:`pytest-allure-adaptor2`                   Plugin for py.test to generate allure xml reports                                                                                                                                                         Oct 14, 2020    N/A                    pytest (>=2.7.3)
+   :pypi:`pytest-allure-collection`                 pytest plugin to collect allure markers without running any tests                                                                                                                                         Apr 13, 2023    N/A                    pytest
+   :pypi:`pytest-allure-dsl`                        pytest plugin to test case doc string dls instructions                                                                                                                                                    Oct 25, 2020    4 - Beta               pytest
+   :pypi:`pytest-allure-intersection`                                                                                                                                                                                                                         Oct 27, 2022    N/A                    pytest (<5)
+   :pypi:`pytest-allure-spec-coverage`              The pytest plugin aimed to display test coverage of the specs(requirements) in Allure                                                                                                                     Oct 26, 2021    N/A                    pytest
+   :pypi:`pytest-alphamoon`                         Static code checks used at Alphamoon                                                                                                                                                                      Dec 30, 2021    5 - Production/Stable  pytest (>=3.5.0)
+   :pypi:`pytest-android`                           This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2.                                                                                                            Feb 21, 2019    3 - Alpha              pytest
+   :pypi:`pytest-anki`                              A pytest plugin for testing Anki add-ons                                                                                                                                                                  Jul 31, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-annotate`                          pytest-annotate: Generate PyAnnotate annotations from your pytest tests.                                                                                                                                  Jun 07, 2022    3 - Alpha              pytest (<8.0.0,>=3.2.0)
+   :pypi:`pytest-ansible`                           Plugin for pytest to simplify calling ansible modules from tests or fixtures                                                                                                                              May 15, 2023    5 - Production/Stable  pytest (<8.0.0,>=6)
+   :pypi:`pytest-ansible-playbook`                  Pytest fixture which runs given ansible playbook file.                                                                                                                                                    Mar 08, 2019    4 - Beta               N/A
+   :pypi:`pytest-ansible-playbook-runner`           Pytest fixture which runs given ansible playbook file.                                                                                                                                                    Dec 02, 2020    4 - Beta               pytest (>=3.1.0)
+   :pypi:`pytest-ansible-units`                     A pytest plugin for running unit tests within an ansible collection                                                                                                                                       Apr 14, 2022    N/A                    N/A
+   :pypi:`pytest-antilru`                           Bust functools.lru_cache when running pytest to avoid test pollution                                                                                                                                      Jul 05, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-anyio`                             The pytest anyio plugin is built into anyio. You don't need this package.                                                                                                                                 Jun 29, 2021    N/A                    pytest
+   :pypi:`pytest-anything`                          Pytest fixtures to assert anything and something                                                                                                                                                          Oct 13, 2022    N/A                    pytest
+   :pypi:`pytest-aoc`                               Downloads puzzle inputs for Advent of Code and synthesizes PyTest fixtures                                                                                                                                Dec 08, 2022    N/A                    pytest ; extra == 'test'
+   :pypi:`pytest-aoreporter`                        pytest report                                                                                                                                                                                             Jun 27, 2022    N/A                    N/A
+   :pypi:`pytest-api`                               An ASGI middleware to populate OpenAPI Specification examples from pytest functions                                                                                                                       May 12, 2022    N/A                    pytest (>=7.1.1,<8.0.0)
+   :pypi:`pytest-api-soup`                          Validate multiple endpoints with unit testing using a single source of truth.                                                                                                                             Aug 27, 2022    N/A                    N/A
+   :pypi:`pytest-apistellar`                        apistellar plugin for pytest.                                                                                                                                                                             Jun 18, 2019    N/A                    N/A
+   :pypi:`pytest-appengine`                         AppEngine integration that works well with pytest-django                                                                                                                                                  Feb 27, 2017    N/A                    N/A
+   :pypi:`pytest-appium`                            Pytest plugin for appium                                                                                                                                                                                  Dec 05, 2019    N/A                    N/A
+   :pypi:`pytest-approvaltests`                     A plugin to use approvaltests with pytest                                                                                                                                                                 May 08, 2022    4 - Beta               pytest (>=7.0.1)
+   :pypi:`pytest-approvaltests-geo`                 Extension for ApprovalTests.Python specific to geo data verification                                                                                                                                      Mar 04, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-archon`                            Rule your architecture like a real developer                                                                                                                                                              Jan 31, 2023    5 - Production/Stable  pytest (>=7.2)
+   :pypi:`pytest-argus`                             pyest results colection plugin                                                                                                                                                                            Jun 24, 2021    5 - Production/Stable  pytest (>=6.2.4)
+   :pypi:`pytest-arraydiff`                         pytest plugin to help with comparing array output from tests                                                                                                                                              Jan 13, 2022    4 - Beta               pytest (>=4.6)
+   :pypi:`pytest-asgi-server`                       Convenient ASGI client/server fixtures for Pytest                                                                                                                                                         Dec 12, 2020    N/A                    pytest (>=5.4.1)
+   :pypi:`pytest-asptest`                           test Answer Set Programming programs                                                                                                                                                                      Apr 28, 2018    4 - Beta               N/A
+   :pypi:`pytest-assertcount`                       Plugin to count actual number of asserts in pytest                                                                                                                                                        Oct 23, 2022    N/A                    pytest (>=5.0.0)
+   :pypi:`pytest-assertions`                        Pytest Assertions                                                                                                                                                                                         Apr 27, 2022    N/A                    N/A
+   :pypi:`pytest-assertutil`                        pytest-assertutil                                                                                                                                                                                         May 10, 2019    N/A                    N/A
+   :pypi:`pytest-assert-utils`                      Useful assertion utilities for use with pytest                                                                                                                                                            Apr 14, 2022    3 - Alpha              N/A
+   :pypi:`pytest-assume`                            A pytest plugin that allows multiple failures per test                                                                                                                                                    Jun 24, 2021    N/A                    pytest (>=2.7)
+   :pypi:`pytest-assurka`                           A pytest plugin for Assurka Studio                                                                                                                                                                        Aug 04, 2022    N/A                    N/A
+   :pypi:`pytest-ast-back-to-python`                A plugin for pytest devs to view how assertion rewriting recodes the AST                                                                                                                                  Sep 29, 2019    4 - Beta               N/A
+   :pypi:`pytest-asteroid`                          PyTest plugin for docker-based testing on database images                                                                                                                                                 Aug 15, 2022    N/A                    pytest (>=6.2.5,<8.0.0)
+   :pypi:`pytest-astropy`                           Meta-package containing dependencies for testing                                                                                                                                                          Apr 12, 2022    5 - Production/Stable  pytest (>=4.6)
+   :pypi:`pytest-astropy-header`                    pytest plugin to add diagnostic information to the header of the test output                                                                                                                              Sep 06, 2022    3 - Alpha              pytest (>=4.6)
+   :pypi:`pytest-ast-transformer`                                                                                                                                                                                                                             May 04, 2019    3 - Alpha              pytest
+   :pypi:`pytest-asyncio`                           Pytest support for asyncio                                                                                                                                                                                Mar 19, 2023    4 - Beta               pytest (>=7.0.0)
+   :pypi:`pytest-asyncio-cooperative`               Run all your asynchronous tests cooperatively.                                                                                                                                                            May 31, 2023    N/A                    N/A
+   :pypi:`pytest-asyncio-network-simulator`         pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests                                                                                                                    Jul 31, 2018    3 - Alpha              pytest (<3.7.0,>=3.3.2)
+   :pypi:`pytest-async-mongodb`                     pytest plugin for async MongoDB                                                                                                                                                                           Oct 18, 2017    5 - Production/Stable  pytest (>=2.5.2)
+   :pypi:`pytest-async-sqlalchemy`                  Database testing fixtures using the SQLAlchemy asyncio API                                                                                                                                                Oct 07, 2021    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-atomic`                            Skip rest of tests if previous test failed.                                                                                                                                                               Nov 24, 2018    4 - Beta               N/A
+   :pypi:`pytest-attrib`                            pytest plugin to select tests based on attributes similar to the nose-attrib plugin                                                                                                                       May 24, 2016    4 - Beta               N/A
+   :pypi:`pytest-austin`                            Austin plugin for pytest                                                                                                                                                                                  Oct 11, 2020    4 - Beta               N/A
+   :pypi:`pytest-autocap`                           automatically capture test & fixture stdout/stderr to files                                                                                                                                               May 15, 2022    N/A                    pytest (<7.2,>=7.1.2)
+   :pypi:`pytest-autochecklog`                      automatically check condition and log all the checks                                                                                                                                                      Apr 25, 2015    4 - Beta               N/A
+   :pypi:`pytest-automation`                        pytest plugin for building a test suite, using YAML files to extend pytest parameterize functionality.                                                                                                    May 20, 2022    N/A                    pytest (>=7.0.0)
+   :pypi:`pytest-automock`                          Pytest plugin for automatical mocks creation                                                                                                                                                              May 16, 2023    N/A                    pytest ; extra == 'dev'
+   :pypi:`pytest-auto-parametrize`                  pytest plugin: avoid repeating arguments in parametrize                                                                                                                                                   Oct 02, 2016    3 - Alpha              N/A
+   :pypi:`pytest-autotest`                          This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2.                                                                                                            Aug 25, 2021    N/A                    pytest
+   :pypi:`pytest-aviator`                           Aviator's Flakybot pytest plugin that automatically reruns flaky tests.                                                                                                                                   Nov 04, 2022    4 - Beta               pytest
+   :pypi:`pytest-avoidance`                         Makes pytest skip tests that don not need rerunning                                                                                                                                                       May 23, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-aws`                               pytest plugin for testing AWS resource configurations                                                                                                                                                     Oct 04, 2017    4 - Beta               N/A
+   :pypi:`pytest-aws-config`                        Protect your AWS credentials in unit tests                                                                                                                                                                May 28, 2021    N/A                    N/A
+   :pypi:`pytest-axe`                               pytest plugin for axe-selenium-python                                                                                                                                                                     Nov 12, 2018    N/A                    pytest (>=3.0.0)
+   :pypi:`pytest-azure`                             Pytest utilities and mocks for Azure                                                                                                                                                                      Jan 18, 2023    3 - Alpha              pytest
+   :pypi:`pytest-azure-devops`                      Simplifies using azure devops parallel strategy (https://docs.microsoft.com/en-us/azure/devops/pipelines/test/parallel-testing-any-test-runner) with pytest.                                              Jun 20, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-azurepipelines`                    Formatting PyTest output for Azure Pipelines UI                                                                                                                                                           Oct 20, 2022    5 - Production/Stable  pytest (>=5.0.0)
+   :pypi:`pytest-bandit`                            A bandit plugin for pytest                                                                                                                                                                                Feb 23, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-bandit-xayon`                      A bandit plugin for pytest                                                                                                                                                                                Oct 17, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-base-url`                          pytest plugin for URL based testing                                                                                                                                                                       Mar 27, 2022    5 - Production/Stable  pytest (>=3.0.0,<8.0.0)
+   :pypi:`pytest-bdd`                               BDD for pytest                                                                                                                                                                                            Nov 08, 2022    6 - Mature             pytest (>=6.2.0)
+   :pypi:`pytest-bdd-html`                          pytest plugin to display BDD info in HTML test report                                                                                                                                                     Nov 22, 2022    3 - Alpha              pytest (!=6.0.0,>=5.0)
+   :pypi:`pytest-bdd-ng`                            BDD for pytest                                                                                                                                                                                            Oct 06, 2022    4 - Beta               pytest (>=5.0)
+   :pypi:`pytest-bdd-splinter`                      Common steps for pytest bdd and splinter integration                                                                                                                                                      Aug 12, 2019    5 - Production/Stable  pytest (>=4.0.0)
+   :pypi:`pytest-bdd-web`                           A simple plugin to use with pytest                                                                                                                                                                        Jan 02, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-bdd-wrappers`                                                                                                                                                                                                                                Feb 11, 2020    2 - Pre-Alpha          N/A
+   :pypi:`pytest-beakerlib`                         A pytest plugin that reports test results to the BeakerLib framework                                                                                                                                      Mar 17, 2017    5 - Production/Stable  pytest
+   :pypi:`pytest-beds`                              Fixtures for testing Google Appengine (GAE) apps                                                                                                                                                          Jun 07, 2016    4 - Beta               N/A
+   :pypi:`pytest-beeprint`                          use icdiff for better error messages in pytest assertions                                                                                                                                                 Jun 09, 2023    4 - Beta               N/A
+   :pypi:`pytest-bench`                             Benchmark utility that plugs into pytest.                                                                                                                                                                 Jul 21, 2014    3 - Alpha              N/A
+   :pypi:`pytest-benchmark`                         A \`\`pytest\`\` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer.                                                                              Oct 25, 2022    5 - Production/Stable  pytest (>=3.8)
+   :pypi:`pytest-better-datadir`                    A small example package                                                                                                                                                                                   Mar 13, 2023    N/A                    N/A
+   :pypi:`pytest-bg-process`                        Pytest plugin to initialize background process                                                                                                                                                            Jan 24, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-bigchaindb`                        A BigchainDB plugin for pytest.                                                                                                                                                                           Jan 24, 2022    4 - Beta               N/A
+   :pypi:`pytest-bigquery-mock`                     Provides a mock fixture for python bigquery client                                                                                                                                                        Dec 28, 2022    N/A                    pytest (>=5.0)
+   :pypi:`pytest-black`                             A pytest plugin to enable format checking with black                                                                                                                                                      Oct 05, 2020    4 - Beta               N/A
+   :pypi:`pytest-black-multipy`                     Allow '--black' on older Pythons                                                                                                                                                                          Jan 14, 2021    5 - Production/Stable  pytest (!=3.7.3,>=3.5) ; extra == 'testing'
+   :pypi:`pytest-black-ng`                          A pytest plugin to enable format checking with black                                                                                                                                                      Oct 20, 2022    4 - Beta               pytest (>=7.0.0)
+   :pypi:`pytest-blame`                             A pytest plugin helps developers to debug by providing useful commits history.                                                                                                                            May 04, 2019    N/A                    pytest (>=4.4.0)
+   :pypi:`pytest-blender`                           Blender Pytest plugin.                                                                                                                                                                                    Jan 04, 2023    N/A                    pytest ; extra == 'dev'
+   :pypi:`pytest-blink1`                            Pytest plugin to emit notifications via the Blink(1) RGB LED                                                                                                                                              Jan 07, 2018    4 - Beta               N/A
+   :pypi:`pytest-blockage`                          Disable network requests during a test run.                                                                                                                                                               Dec 21, 2021    N/A                    pytest
+   :pypi:`pytest-blocker`                           pytest plugin to mark a test as blocker and skip all other tests                                                                                                                                          Sep 07, 2015    4 - Beta               N/A
+   :pypi:`pytest-blue`                              A pytest plugin that adds a \`blue\` fixture for printing stuff in blue.                                                                                                                                  Sep 05, 2022    N/A                    N/A
+   :pypi:`pytest-board`                             Local continuous test runner with pytest and watchdog.                                                                                                                                                    Jan 20, 2019    N/A                    N/A
+   :pypi:`pytest-boost-xml`                         Plugin for pytest to generate boost xml reports                                                                                                                                                           Nov 30, 2022    4 - Beta               N/A
+   :pypi:`pytest-bootstrap`                                                                                                                                                                                                                                   Mar 04, 2022    N/A                    N/A
+   :pypi:`pytest-bpdb`                              A py.test plug-in to enable drop to bpdb debugger on test failure.                                                                                                                                        Jan 19, 2015    2 - Pre-Alpha          N/A
+   :pypi:`pytest-bravado`                           Pytest-bravado automatically generates from OpenAPI specification client fixtures.                                                                                                                        Feb 15, 2022    N/A                    N/A
+   :pypi:`pytest-breakword`                         Use breakword with pytest                                                                                                                                                                                 Aug 04, 2021    N/A                    pytest (>=6.2.4,<7.0.0)
+   :pypi:`pytest-breed-adapter`                     A simple plugin to connect with breed-server                                                                                                                                                              Nov 07, 2018    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-briefcase`                         A pytest plugin for running tests on a Briefcase project.                                                                                                                                                 Jun 14, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-browser`                           A pytest plugin for console based browser test selection just after the collection phase                                                                                                                  Dec 10, 2016    3 - Alpha              N/A
+   :pypi:`pytest-browsermob-proxy`                  BrowserMob proxy plugin for py.test.                                                                                                                                                                      Jun 11, 2013    4 - Beta               N/A
+   :pypi:`pytest-browserstack-local`                \`\`py.test\`\` plugin to run \`\`BrowserStackLocal\`\` in background.                                                                                                                                    Feb 09, 2018    N/A                    N/A
+   :pypi:`pytest-budosystems`                       Budo Systems is a martial arts school management system. This module is the Budo Systems Pytest Plugin.                                                                                                   May 07, 2023    3 - Alpha              pytest
+   :pypi:`pytest-bug`                               Pytest plugin for marking tests as a bug                                                                                                                                                                  Jan 29, 2023    5 - Production/Stable  pytest (>=6.2.0)
+   :pypi:`pytest-bugtong-tag`                       pytest-bugtong-tag is a plugin for pytest                                                                                                                                                                 Jan 16, 2022    N/A                    N/A
+   :pypi:`pytest-bugzilla`                          py.test bugzilla integration plugin                                                                                                                                                                       May 05, 2010    4 - Beta               N/A
+   :pypi:`pytest-bugzilla-notifier`                 A plugin that allows you to execute create, update, and read information from BugZilla bugs                                                                                                               Jun 15, 2018    4 - Beta               pytest (>=2.9.2)
+   :pypi:`pytest-buildkite`                         Plugin for pytest that automatically publishes coverage and pytest report annotations to Buildkite.                                                                                                       Jul 13, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-builtin-types`                                                                                                                                                                                                                               Nov 17, 2021    N/A                    pytest
+   :pypi:`pytest-bwrap`                             Run your tests in Bubblewrap sandboxes                                                                                                                                                                    Oct 26, 2018    3 - Alpha              N/A
+   :pypi:`pytest-cache`                             pytest plugin with mechanisms for caching across test runs                                                                                                                                                Jun 04, 2013    3 - Alpha              N/A
+   :pypi:`pytest-cache-assert`                      Cache assertion data to simplify regression testing of complex serializable data                                                                                                                          Feb 26, 2023    5 - Production/Stable  pytest (>=5.0.0)
+   :pypi:`pytest-cagoule`                           Pytest plugin to only run tests affected by changes                                                                                                                                                       Jan 01, 2020    3 - Alpha              N/A
+   :pypi:`pytest-cairo`                             Pytest support for cairo-lang and starknet                                                                                                                                                                Apr 17, 2022    N/A                    pytest
+   :pypi:`pytest-call-checker`                      Small pytest utility to easily create test doubles                                                                                                                                                        Oct 16, 2022    4 - Beta               pytest (>=7.1.3,<8.0.0)
+   :pypi:`pytest-camel-collect`                     Enable CamelCase-aware pytest class collection                                                                                                                                                            Aug 02, 2020    N/A                    pytest (>=2.9)
+   :pypi:`pytest-canonical-data`                    A plugin which allows to compare results with canonical results, based on previous runs                                                                                                                   May 08, 2020    2 - Pre-Alpha          pytest (>=3.5.0)
+   :pypi:`pytest-caprng`                            A plugin that replays pRNG state on failure.                                                                                                                                                              May 02, 2018    4 - Beta               N/A
+   :pypi:`pytest-capture-deprecatedwarnings`        pytest plugin to capture all deprecatedwarnings and put them in one file                                                                                                                                  Apr 30, 2019    N/A                    N/A
+   :pypi:`pytest-capture-warnings`                  pytest plugin to capture all warnings and put them in one file of your choice                                                                                                                             May 03, 2022    N/A                    pytest
+   :pypi:`pytest-cases`                             Separate test code from test cases in pytest.                                                                                                                                                             Feb 23, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-cassandra`                         Cassandra CCM Test Fixtures for pytest                                                                                                                                                                    Nov 04, 2017    1 - Planning           N/A
+   :pypi:`pytest-catchlog`                          py.test plugin to catch log messages. This is a fork of pytest-capturelog.                                                                                                                                Jan 24, 2016    4 - Beta               pytest (>=2.6)
+   :pypi:`pytest-catch-server`                      Pytest plugin with server for catching HTTP requests.                                                                                                                                                     Dec 12, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-celery`                            pytest-celery a shim pytest plugin to enable celery.contrib.pytest                                                                                                                                        May 06, 2021    N/A                    N/A
+   :pypi:`pytest-chainmaker`                        pytest plugin for chainmaker                                                                                                                                                                              Oct 15, 2021    N/A                    N/A
+   :pypi:`pytest-chalice`                           A set of py.test fixtures for AWS Chalice                                                                                                                                                                 Jul 01, 2020    4 - Beta               N/A
+   :pypi:`pytest-change-assert`                     修改报错中文为英文                                                                                                                                                                                        Oct 19, 2022    N/A                    N/A
+   :pypi:`pytest-change-demo`                       turn . into √,turn F into x                                                                                                                                                                              Mar 02, 2022    N/A                    pytest
+   :pypi:`pytest-change-report`                     turn . into √,turn F into x                                                                                                                                                                              Sep 14, 2020    N/A                    pytest
+   :pypi:`pytest-change-xds`                        turn . into √,turn F into x                                                                                                                                                                              Apr 16, 2022    N/A                    pytest
+   :pypi:`pytest-chdir`                             A pytest fixture for changing current working directory                                                                                                                                                   Jan 28, 2020    N/A                    pytest (>=5.0.0,<6.0.0)
+   :pypi:`pytest-check`                             A pytest plugin that allows multiple failures per test.                                                                                                                                                   Jun 06, 2023    N/A                    pytest
+   :pypi:`pytest-checkdocs`                         check the README when running tests                                                                                                                                                                       Oct 09, 2022    5 - Production/Stable  pytest (>=6) ; extra == 'testing'
+   :pypi:`pytest-checkipdb`                         plugin to check if there are ipdb debugs left                                                                                                                                                             Jul 22, 2020    5 - Production/Stable  pytest (>=2.9.2)
+   :pypi:`pytest-check-library`                     check your missing library                                                                                                                                                                                Jul 17, 2022    N/A                    N/A
+   :pypi:`pytest-check-libs`                        check your missing library                                                                                                                                                                                Jul 17, 2022    N/A                    N/A
+   :pypi:`pytest-check-links`                       Check links in files                                                                                                                                                                                      Jul 29, 2020    N/A                    pytest>=7.0
+   :pypi:`pytest-check-mk`                          pytest plugin to test Check_MK checks                                                                                                                                                                     Nov 19, 2015    4 - Beta               pytest
+   :pypi:`pytest-check-requirements`                A package to prevent Dependency Confusion attacks against Yandex.                                                                                                                                         Feb 10, 2023    N/A                    N/A
+   :pypi:`pytest-chic-report`                       A pytest plugin to send a report and printing summary of tests.                                                                                                                                           Jan 31, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-chunks`                            Run only a chunk of your test suite                                                                                                                                                                       Jul 05, 2022    N/A                    pytest (>=6.0.0)
+   :pypi:`pytest-circleci`                          py.test plugin for CircleCI                                                                                                                                                                               May 03, 2019    N/A                    N/A
+   :pypi:`pytest-circleci-parallelized`             Parallelize pytest across CircleCI workers.                                                                                                                                                               Oct 20, 2022    N/A                    N/A
+   :pypi:`pytest-circleci-parallelized-rjp`         Parallelize pytest across CircleCI workers.                                                                                                                                                               Jun 21, 2022    N/A                    pytest
+   :pypi:`pytest-ckan`                              Backport of CKAN 2.9 pytest plugin and fixtures to CAKN 2.8                                                                                                                                               Apr 28, 2020    4 - Beta               pytest
+   :pypi:`pytest-clarity`                           A plugin providing an alternative, colourful diff output for failing assertions.                                                                                                                          Jun 11, 2021    N/A                    N/A
+   :pypi:`pytest-cldf`                              Easy quality control for CLDF datasets using pytest                                                                                                                                                       Nov 07, 2022    N/A                    pytest (>=3.6)
+   :pypi:`pytest-click`                             Pytest plugin for Click                                                                                                                                                                                   Feb 11, 2022    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-cli-fixtures`                      Automatically register fixtures for custom CLI arguments                                                                                                                                                  Jul 28, 2022    N/A                    pytest (~=7.0)
+   :pypi:`pytest-clld`                                                                                                                                                                                                                                        Jul 06, 2022    N/A                    pytest (>=3.6)
+   :pypi:`pytest-cloud`                             Distributed tests planner plugin for pytest testing framework.                                                                                                                                            Oct 05, 2020    6 - Mature             N/A
+   :pypi:`pytest-cloudflare-worker`                 pytest plugin for testing cloudflare workers                                                                                                                                                              Mar 30, 2021    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-cloudist`                          Distribute tests to cloud machines without fuss                                                                                                                                                           Sep 02, 2022    4 - Beta               pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-cmake`                             Provide CMake module for Pytest                                                                                                                                                                           Jan 21, 2023    N/A                    pytest<8,>=4
+   :pypi:`pytest-cmake-presets`                     Execute CMake Presets via pytest                                                                                                                                                                          Dec 26, 2022    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-cobra`                             PyTest plugin for testing Smart Contracts for Ethereum blockchain.                                                                                                                                        Jun 29, 2019    3 - Alpha              pytest (<4.0.0,>=3.7.1)
+   :pypi:`pytest-codecarbon`                        Pytest plugin for measuring carbon emissions                                                                                                                                                              Jun 15, 2022    N/A                    pytest
+   :pypi:`pytest-codecheckers`                      pytest plugin to add source code sanity checks (pep8 and friends)                                                                                                                                         Feb 13, 2010    N/A                    N/A
+   :pypi:`pytest-codecov`                           Pytest plugin for uploading pytest-cov results to codecov.io                                                                                                                                              Nov 29, 2022    4 - Beta               pytest (>=4.6.0)
+   :pypi:`pytest-codegen`                           Automatically create pytest test signatures                                                                                                                                                               Aug 23, 2020    2 - Pre-Alpha          N/A
+   :pypi:`pytest-codeowners`                        Pytest plugin for selecting tests by GitHub CODEOWNERS.                                                                                                                                                   Mar 30, 2022    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-codestyle`                         pytest plugin to run pycodestyle                                                                                                                                                                          Mar 23, 2020    3 - Alpha              N/A
+   :pypi:`pytest-codspeed`                          Pytest plugin to create CodSpeed benchmarks                                                                                                                                                               Dec 02, 2022    5 - Production/Stable  pytest>=3.8
+   :pypi:`pytest-collect-formatter`                 Formatter for pytest collect output                                                                                                                                                                       Mar 29, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-collect-formatter2`                Formatter for pytest collect output                                                                                                                                                                       May 31, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-collector`                         Python package for collecting pytest.                                                                                                                                                                     Aug 02, 2022    N/A                    pytest (>=7.0,<8.0)
+   :pypi:`pytest-colordots`                         Colorizes the progress indicators                                                                                                                                                                         Oct 06, 2017    5 - Production/Stable  N/A
+   :pypi:`pytest-commander`                         An interactive GUI test runner for PyTest                                                                                                                                                                 Aug 17, 2021    N/A                    pytest (<7.0.0,>=6.2.4)
+   :pypi:`pytest-common-subject`                    pytest framework for testing different aspects of a common method                                                                                                                                         May 15, 2022    N/A                    pytest (>=3.6,<8)
+   :pypi:`pytest-compare`                           pytest plugin for comparing call arguments.                                                                                                                                                               Mar 30, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-concurrent`                        Concurrently execute test cases with multithread, multiprocess and gevent                                                                                                                                 Jan 12, 2019    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-config`                            Base configurations and utilities for developing    your Python project test suite with pytest.                                                                                                           Nov 07, 2014    5 - Production/Stable  N/A
+   :pypi:`pytest-confluence-report`                 Package stands for pytest plugin to upload results into Confluence page.                                                                                                                                  Apr 17, 2022    N/A                    N/A
+   :pypi:`pytest-console-scripts`                   Pytest plugin for testing console scripts                                                                                                                                                                 May 31, 2023    4 - Beta               pytest (>=4.0.0)
+   :pypi:`pytest-consul`                            pytest plugin with fixtures for testing consul aware apps                                                                                                                                                 Nov 24, 2018    3 - Alpha              pytest
+   :pypi:`pytest-container`                         Pytest fixtures for writing container based tests                                                                                                                                                         Mar 21, 2023    4 - Beta               pytest (>=3.10)
+   :pypi:`pytest-contextfixture`                    Define pytest fixtures as context managers.                                                                                                                                                               Mar 12, 2013    4 - Beta               N/A
+   :pypi:`pytest-contexts`                          A plugin to run tests written with the Contexts framework using pytest                                                                                                                                    May 19, 2021    4 - Beta               N/A
+   :pypi:`pytest-cookies`                           The pytest plugin for your Cookiecutter templates. 🍪                                                                                                                                                     Mar 22, 2023    5 - Production/Stable  pytest (>=3.9.0)
+   :pypi:`pytest-couchdbkit`                        py.test extension for per-test couchdb databases using couchdbkit                                                                                                                                         Apr 17, 2012    N/A                    N/A
+   :pypi:`pytest-count`                             count erros and send email                                                                                                                                                                                Jan 12, 2018    4 - Beta               N/A
+   :pypi:`pytest-cov`                               Pytest plugin for measuring coverage.                                                                                                                                                                     May 24, 2023    5 - Production/Stable  pytest (>=4.6)
+   :pypi:`pytest-cover`                             Pytest plugin for measuring coverage. Forked from \`pytest-cov\`.                                                                                                                                         Aug 01, 2015    5 - Production/Stable  N/A
+   :pypi:`pytest-coverage`                                                                                                                                                                                                                                    Jun 17, 2015    N/A                    N/A
+   :pypi:`pytest-coverage-context`                  Coverage dynamic context support for PyTest, including sub-processes                                                                                                                                      Jan 04, 2021    4 - Beta               pytest (>=6.1.0)
+   :pypi:`pytest-coveragemarkers`                   Using pytest markers to track functional coverage and filtering of tests                                                                                                                                  Nov 29, 2022    N/A                    pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-cov-exclude`                       Pytest plugin for excluding tests based on coverage data                                                                                                                                                  Apr 29, 2016    4 - Beta               pytest (>=2.8.0,<2.9.0); extra == 'dev'
+   :pypi:`pytest-cpp`                               Use pytest's runner to discover and execute C++ tests                                                                                                                                                     Jan 30, 2023    5 - Production/Stable  pytest (>=7.0)
+   :pypi:`pytest-cppython`                          A pytest plugin that imports CPPython testing types                                                                                                                                                       Jun 14, 2023    N/A                    N/A
+   :pypi:`pytest-cqase`                             Custom qase pytest plugin                                                                                                                                                                                 Aug 22, 2022    N/A                    pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-cram`                              Run cram tests with pytest.                                                                                                                                                                               Aug 08, 2020    N/A                    N/A
+   :pypi:`pytest-crate`                             Manages CrateDB instances during your integration tests                                                                                                                                                   May 28, 2019    3 - Alpha              pytest (>=4.0)
+   :pypi:`pytest-crayons`                           A pytest plugin for colorful print statements                                                                                                                                                             Mar 19, 2023    N/A                    pytest
+   :pypi:`pytest-create`                            pytest-create                                                                                                                                                                                             Feb 15, 2023    1 - Planning           N/A
+   :pypi:`pytest-cricri`                            A Cricri plugin for pytest.                                                                                                                                                                               Jan 27, 2018    N/A                    pytest
+   :pypi:`pytest-crontab`                           add crontab task in crontab                                                                                                                                                                               Dec 09, 2019    N/A                    N/A
+   :pypi:`pytest-csv`                               CSV output for pytest.                                                                                                                                                                                    Apr 22, 2021    N/A                    pytest (>=6.0)
+   :pypi:`pytest-csv-params`                        Pytest plugin for Test Case Parametrization with CSV files                                                                                                                                                Aug 28, 2022    5 - Production/Stable  pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-curio`                             Pytest support for curio.                                                                                                                                                                                 Oct 07, 2020    N/A                    N/A
+   :pypi:`pytest-curl-report`                       pytest plugin to generate curl command line report                                                                                                                                                        Dec 11, 2016    4 - Beta               N/A
+   :pypi:`pytest-custom-concurrency`                Custom grouping concurrence for pytest                                                                                                                                                                    Feb 08, 2021    N/A                    N/A
+   :pypi:`pytest-custom-exit-code`                  Exit pytest test session with custom exit code in different scenarios                                                                                                                                     Aug 07, 2019    4 - Beta               pytest (>=4.0.2)
+   :pypi:`pytest-custom-nodeid`                     Custom grouping for pytest-xdist, rename test cases name and test cases nodeid, support allure report                                                                                                     Mar 07, 2021    N/A                    N/A
+   :pypi:`pytest-custom-report`                     Configure the symbols displayed for test outcomes                                                                                                                                                         Jan 30, 2019    N/A                    pytest
+   :pypi:`pytest-custom-scheduling`                 Custom grouping for pytest-xdist, rename test cases name and test cases nodeid, support allure report                                                                                                     Mar 01, 2021    N/A                    N/A
+   :pypi:`pytest-cython`                            A plugin for testing Cython extension modules                                                                                                                                                             Feb 16, 2023    5 - Production/Stable  pytest (>=4.6.0)
+   :pypi:`pytest-cython-collect`                                                                                                                                                                                                                              Jun 17, 2022    N/A                    pytest
+   :pypi:`pytest-darker`                            A pytest plugin for checking of modified code using Darker                                                                                                                                                Aug 16, 2020    N/A                    pytest (>=6.0.1) ; extra == 'test'
+   :pypi:`pytest-dash`                              pytest fixtures to run dash applications.                                                                                                                                                                 Mar 18, 2019    N/A                    N/A
+   :pypi:`pytest-data`                              Useful functions for managing data for pytest fixtures                                                                                                                                                    Nov 01, 2016    5 - Production/Stable  N/A
+   :pypi:`pytest-databricks`                        Pytest plugin for remote Databricks notebooks testing                                                                                                                                                     Jul 29, 2020    N/A                    pytest
+   :pypi:`pytest-datadir`                           pytest plugin for test data directories and files                                                                                                                                                         Oct 25, 2022    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-datadir-mgr`                       Manager for test data: downloads, artifact caching, and a tmpdir context.                                                                                                                                 Apr 06, 2023    5 - Production/Stable  pytest (>=7.1)
+   :pypi:`pytest-datadir-ng`                        Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem.                                                                                          Dec 25, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-datadir-nng`                       Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem.                                                                                          Nov 09, 2022    5 - Production/Stable  pytest (>=7.0.0,<8.0.0)
+   :pypi:`pytest-data-extractor`                    A pytest plugin to extract relevant metadata about tests into an external file (currently only json support)                                                                                              Jul 19, 2022    N/A                    pytest (>=7.0.1)
+   :pypi:`pytest-data-file`                         Fixture "data" and "case_data" for test from yaml file                                                                                                                                                    Dec 04, 2019    N/A                    N/A
+   :pypi:`pytest-datafiles`                         py.test plugin to create a 'tmp_path' containing predefined files/directories.                                                                                                                            Feb 24, 2023    5 - Production/Stable  pytest (>=3.6)
+   :pypi:`pytest-datafixtures`                      Data fixtures for pytest made simple                                                                                                                                                                      Dec 05, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-data-from-files`                   pytest plugin to provide data from files loaded automatically                                                                                                                                             Oct 13, 2021    4 - Beta               pytest
+   :pypi:`pytest-dataplugin`                        A pytest plugin for managing an archive of test data.                                                                                                                                                     Sep 16, 2017    1 - Planning           N/A
+   :pypi:`pytest-datarecorder`                      A py.test plugin recording and comparing test output.                                                                                                                                                     Jan 08, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-dataset`                           Plugin for loading different datasets for pytest by prefix from json or yaml files                                                                                                                        May 01, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-data-suites`                       Class-based pytest parametrization                                                                                                                                                                        Jul 24, 2022    N/A                    pytest (>=6.0,<8.0)
+   :pypi:`pytest-datatest`                          A pytest plugin for test driven data-wrangling (this is the development version of datatest's pytest integration).                                                                                        Oct 15, 2020    4 - Beta               pytest (>=3.3)
+   :pypi:`pytest-db`                                Session scope fixture "db" for mysql query or change                                                                                                                                                      Dec 04, 2019    N/A                    N/A
+   :pypi:`pytest-dbfixtures`                        Databases fixtures plugin for py.test.                                                                                                                                                                    Dec 07, 2016    4 - Beta               N/A
+   :pypi:`pytest-db-plugin`                                                                                                                                                                                                                                   Nov 27, 2021    N/A                    pytest (>=5.0)
+   :pypi:`pytest-dbt`                               Unit test dbt models with standard python tooling                                                                                                                                                         Jun 08, 2023    2 - Pre-Alpha          pytest (>=7.0.0,<8.0.0)
+   :pypi:`pytest-dbt-adapter`                       A pytest plugin for testing dbt adapter plugins                                                                                                                                                           Nov 24, 2021    N/A                    pytest (<7,>=6)
+   :pypi:`pytest-dbt-conventions`                   A pytest plugin for linting a dbt project's conventions                                                                                                                                                   Mar 02, 2022    N/A                    pytest (>=6.2.5,<7.0.0)
+   :pypi:`pytest-dbt-core`                          Pytest extension for dbt.                                                                                                                                                                                 May 03, 2023    N/A                    pytest (>=6.2.5) ; extra == 'test'
+   :pypi:`pytest-dbus-notification`                 D-BUS notifications for pytest results.                                                                                                                                                                   Mar 05, 2014    5 - Production/Stable  N/A
+   :pypi:`pytest-dbx`                               Pytest plugin to run unit tests for dbx (Databricks CLI extensions) related code                                                                                                                          Nov 29, 2022    N/A                    pytest (>=7.1.3,<8.0.0)
+   :pypi:`pytest-deadfixtures`                      A simple plugin to list unused fixtures in pytest                                                                                                                                                         Jul 23, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-deepcov`                           deepcov                                                                                                                                                                                                   Mar 30, 2021    N/A                    N/A
+   :pypi:`pytest-defer`                                                                                                                                                                                                                                       Aug 24, 2021    N/A                    N/A
+   :pypi:`pytest-demo-plugin`                       pytest示例插件                                                                                                                                                                                            May 15, 2021    N/A                    N/A
+   :pypi:`pytest-dependency`                        Manage dependencies of tests                                                                                                                                                                              Feb 14, 2020    4 - Beta               N/A
+   :pypi:`pytest-depends`                           Tests that depend on other tests                                                                                                                                                                          Apr 05, 2020    5 - Production/Stable  pytest (>=3)
+   :pypi:`pytest-deprecate`                         Mark tests as testing a deprecated feature with a warning note.                                                                                                                                           Jul 01, 2019    N/A                    N/A
+   :pypi:`pytest-describe`                          Describe-style plugin for pytest                                                                                                                                                                          Apr 09, 2023    5 - Production/Stable  pytest (<8,>=4.6)
+   :pypi:`pytest-describe-it`                       plugin for rich text descriptions                                                                                                                                                                         Jul 19, 2019    4 - Beta               pytest
+   :pypi:`pytest-devpi-server`                      DevPI server fixture for py.test                                                                                                                                                                          May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-dhos`                              Common fixtures for pytest in DHOS services and libraries                                                                                                                                                 Sep 07, 2022    N/A                    N/A
+   :pypi:`pytest-diamond`                           pytest plugin for diamond                                                                                                                                                                                 Aug 31, 2015    4 - Beta               N/A
+   :pypi:`pytest-dicom`                             pytest plugin to provide DICOM fixtures                                                                                                                                                                   Dec 19, 2018    3 - Alpha              pytest
+   :pypi:`pytest-dictsdiff`                                                                                                                                                                                                                                   Jul 26, 2019    N/A                    N/A
+   :pypi:`pytest-diff`                              A simple plugin to use with pytest                                                                                                                                                                        Mar 30, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-diffeo`                            A package to prevent Dependency Confusion attacks against Yandex.                                                                                                                                         Feb 10, 2023    N/A                    N/A
+   :pypi:`pytest-diff-selector`                     Get tests affected by code changes (using git)                                                                                                                                                            Feb 24, 2022    4 - Beta               pytest (>=6.2.2) ; extra == 'all'
+   :pypi:`pytest-difido`                            PyTest plugin for generating Difido reports                                                                                                                                                               Oct 23, 2022    4 - Beta               pytest (>=4.0.0)
+   :pypi:`pytest-disable`                           pytest plugin to disable a test and skip it from testrun                                                                                                                                                  Sep 10, 2015    4 - Beta               N/A
+   :pypi:`pytest-disable-plugin`                    Disable plugins per test                                                                                                                                                                                  Feb 28, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-discord`                           A pytest plugin to notify test results to a Discord channel.                                                                                                                                              Feb 05, 2023    4 - Beta               pytest (!=6.0.0,<8,>=3.3.2)
+   :pypi:`pytest-django`                            A Django plugin for pytest.                                                                                                                                                                               Dec 07, 2021    5 - Production/Stable  pytest (>=5.4.0)
+   :pypi:`pytest-django-ahead`                      A Django plugin for pytest.                                                                                                                                                                               Oct 27, 2016    5 - Production/Stable  pytest (>=2.9)
+   :pypi:`pytest-djangoapp`                         Nice pytest plugin to help you with Django pluggable application testing.                                                                                                                                 May 19, 2023    4 - Beta               pytest
+   :pypi:`pytest-django-cache-xdist`                A djangocachexdist plugin for pytest                                                                                                                                                                      May 12, 2020    4 - Beta               N/A
+   :pypi:`pytest-django-casperjs`                   Integrate CasperJS with your django tests as a pytest fixture.                                                                                                                                            Mar 15, 2015    2 - Pre-Alpha          N/A
+   :pypi:`pytest-django-dotenv`                     Pytest plugin used to setup environment variables with django-dotenv                                                                                                                                      Nov 26, 2019    4 - Beta               pytest (>=2.6.0)
+   :pypi:`pytest-django-factories`                  Factories for your Django models that can be used as Pytest fixtures.                                                                                                                                     Nov 12, 2020    4 - Beta               N/A
+   :pypi:`pytest-django-filefield`                  Replaces FileField.storage with something you can patch globally.                                                                                                                                         May 09, 2022    5 - Production/Stable  pytest >= 5.2
+   :pypi:`pytest-django-gcir`                       A Django plugin for pytest.                                                                                                                                                                               Mar 06, 2018    5 - Production/Stable  N/A
+   :pypi:`pytest-django-haystack`                   Cleanup your Haystack indexes between tests                                                                                                                                                               Sep 03, 2017    5 - Production/Stable  pytest (>=2.3.4)
+   :pypi:`pytest-django-ifactory`                   A model instance factory for pytest-django                                                                                                                                                                Jun 06, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-django-lite`                       The bare minimum to integrate py.test with Django.                                                                                                                                                        Jan 30, 2014    N/A                    N/A
+   :pypi:`pytest-django-liveserver-ssl`                                                                                                                                                                                                                       Jan 20, 2022    3 - Alpha              N/A
+   :pypi:`pytest-django-model`                      A Simple Way to Test your Django Models                                                                                                                                                                   Feb 14, 2019    4 - Beta               N/A
+   :pypi:`pytest-django-ordering`                   A pytest plugin for preserving the order in which Django runs tests.                                                                                                                                      Jul 25, 2019    5 - Production/Stable  pytest (>=2.3.0)
+   :pypi:`pytest-django-queries`                    Generate performance reports from your django database performance tests.                                                                                                                                 Mar 01, 2021    N/A                    N/A
+   :pypi:`pytest-djangorestframework`               A djangorestframework plugin for pytest                                                                                                                                                                   Aug 11, 2019    4 - Beta               N/A
+   :pypi:`pytest-django-rq`                         A pytest plugin to help writing unit test for django-rq                                                                                                                                                   Apr 13, 2020    4 - Beta               N/A
+   :pypi:`pytest-django-sqlcounts`                  py.test plugin for reporting the number of SQLs executed per django testcase.                                                                                                                             Jun 16, 2015    4 - Beta               N/A
+   :pypi:`pytest-django-testing-postgresql`         Use a temporary PostgreSQL database with pytest-django                                                                                                                                                    Jan 31, 2022    4 - Beta               N/A
+   :pypi:`pytest-doc`                               A documentation plugin for py.test.                                                                                                                                                                       Jun 28, 2015    5 - Production/Stable  N/A
+   :pypi:`pytest-docfiles`                          pytest plugin to test codeblocks in your documentation.                                                                                                                                                   Dec 22, 2021    4 - Beta               pytest (>=3.7.0)
+   :pypi:`pytest-docgen`                            An RST Documentation Generator for pytest-based test suites                                                                                                                                               Apr 17, 2020    N/A                    N/A
+   :pypi:`pytest-docker`                            Simple pytest fixtures for Docker and docker-compose based tests                                                                                                                                          Sep 14, 2022    N/A                    pytest (<8.0,>=4.0)
+   :pypi:`pytest-docker-apache-fixtures`            Pytest fixtures for testing with apache2 (httpd).                                                                                                                                                         Feb 16, 2022    4 - Beta               pytest
+   :pypi:`pytest-docker-butla`                                                                                                                                                                                                                                Jun 16, 2019    3 - Alpha              N/A
+   :pypi:`pytest-dockerc`                           Run, manage and stop Docker Compose project from Docker API                                                                                                                                               Oct 09, 2020    5 - Production/Stable  pytest (>=3.0)
+   :pypi:`pytest-docker-compose`                    Manages Docker containers during your integration tests                                                                                                                                                   Jan 26, 2021    5 - Production/Stable  pytest (>=3.3)
+   :pypi:`pytest-docker-db`                         A plugin to use docker databases for pytests                                                                                                                                                              Mar 20, 2021    5 - Production/Stable  pytest (>=3.1.1)
+   :pypi:`pytest-docker-fixtures`                   pytest docker fixtures                                                                                                                                                                                    May 02, 2023    3 - Alpha              pytest
+   :pypi:`pytest-docker-git-fixtures`               Pytest fixtures for testing with git scm.                                                                                                                                                                 Feb 09, 2022    4 - Beta               pytest
+   :pypi:`pytest-docker-haproxy-fixtures`           Pytest fixtures for testing with haproxy.                                                                                                                                                                 Feb 09, 2022    4 - Beta               pytest
+   :pypi:`pytest-docker-pexpect`                    pytest plugin for writing functional tests with pexpect and docker                                                                                                                                        Jan 14, 2019    N/A                    pytest
+   :pypi:`pytest-docker-postgresql`                 A simple plugin to use with pytest                                                                                                                                                                        Sep 24, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-docker-py`                         Easy to use, simple to extend, pytest plugin that minimally leverages docker-py.                                                                                                                          Nov 27, 2018    N/A                    pytest (==4.0.0)
+   :pypi:`pytest-docker-registry-fixtures`          Pytest fixtures for testing with docker registries.                                                                                                                                                       Apr 08, 2022    4 - Beta               pytest
+   :pypi:`pytest-docker-service`                    pytest plugin to start docker container                                                                                                                                                                   Feb 22, 2023    3 - Alpha              pytest (>=7.1.3)
+   :pypi:`pytest-docker-squid-fixtures`             Pytest fixtures for testing with squid.                                                                                                                                                                   Feb 09, 2022    4 - Beta               pytest
+   :pypi:`pytest-docker-tools`                      Docker integration tests for pytest                                                                                                                                                                       Feb 17, 2022    4 - Beta               pytest (>=6.0.1)
+   :pypi:`pytest-docs`                              Documentation tool for pytest                                                                                                                                                                             Nov 11, 2018    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-docstyle`                          pytest plugin to run pydocstyle                                                                                                                                                                           Mar 23, 2020    3 - Alpha              N/A
+   :pypi:`pytest-doctest-custom`                    A py.test plugin for customizing string representations of doctest results.                                                                                                                               Jul 25, 2016    4 - Beta               N/A
+   :pypi:`pytest-doctest-ellipsis-markers`          Setup additional values for ELLIPSIS_MARKER for doctests                                                                                                                                                  Jan 12, 2018    4 - Beta               N/A
+   :pypi:`pytest-doctest-import`                    A simple pytest plugin to import names and add them to the doctest namespace.                                                                                                                             Nov 13, 2018    4 - Beta               pytest (>=3.3.0)
+   :pypi:`pytest-doctestplus`                       Pytest plugin with advanced doctest features.                                                                                                                                                             Jun 08, 2023    3 - Alpha              pytest (>=4.6)
+   :pypi:`pytest-dolphin`                           Some extra stuff that we use ininternally                                                                                                                                                                 Nov 30, 2016    4 - Beta               pytest (==3.0.4)
+   :pypi:`pytest-doorstop`                          A pytest plugin for adding test results into doorstop items.                                                                                                                                              Jun 09, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-dotenv`                            A py.test plugin that parses environment files before running tests                                                                                                                                       Jun 16, 2020    4 - Beta               pytest (>=5.0.0)
+   :pypi:`pytest-draw`                              Pytest plugin for randomly selecting a specific number of tests                                                                                                                                           Mar 21, 2023    3 - Alpha              pytest
+   :pypi:`pytest-drf`                               A Django REST framework plugin for pytest.                                                                                                                                                                Jul 12, 2022    5 - Production/Stable  pytest (>=3.7)
+   :pypi:`pytest-drivings`                          Tool to allow webdriver automation to be ran locally or remotely                                                                                                                                          Jan 13, 2021    N/A                    N/A
+   :pypi:`pytest-drop-dup-tests`                    A Pytest plugin to drop duplicated tests during collection                                                                                                                                                May 23, 2020    4 - Beta               pytest (>=2.7)
+   :pypi:`pytest-dummynet`                          A py.test plugin providing access to a dummynet.                                                                                                                                                          Dec 15, 2021    5 - Production/Stable  pytest
+   :pypi:`pytest-dump2json`                         A pytest plugin for dumping test results to json.                                                                                                                                                         Jun 29, 2015    N/A                    N/A
+   :pypi:`pytest-duration-insights`                                                                                                                                                                                                                           Jun 25, 2021    N/A                    N/A
+   :pypi:`pytest-durations`                         Pytest plugin reporting fixtures and test functions execution time.                                                                                                                                       Apr 22, 2022    5 - Production/Stable  pytest (>=4.6)
+   :pypi:`pytest-dynamicrerun`                      A pytest plugin to rerun tests dynamically based off of test outcome and output.                                                                                                                          Aug 15, 2020    4 - Beta               N/A
+   :pypi:`pytest-dynamodb`                          DynamoDB fixtures for pytest                                                                                                                                                                              Jun 12, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-easy-addoption`                    pytest-easy-addoption: Easy way to work with pytest addoption                                                                                                                                             Jan 22, 2020    N/A                    N/A
+   :pypi:`pytest-easy-api`                          Simple API testing with pytest                                                                                                                                                                            Mar 26, 2018    N/A                    N/A
+   :pypi:`pytest-easyMPI`                           Package that supports mpi tests in pytest                                                                                                                                                                 Oct 21, 2020    N/A                    N/A
+   :pypi:`pytest-easyread`                          pytest plugin that makes terminal printouts of the reports easier to read                                                                                                                                 Nov 17, 2017    N/A                    N/A
+   :pypi:`pytest-easy-server`                       Pytest plugin for easy testing against servers                                                                                                                                                            May 01, 2021    4 - Beta               pytest (<5.0.0,>=4.3.1) ; python_version < "3.5"
+   :pypi:`pytest-ebics-sandbox`                     A pytest plugin for testing against an EBICS sandbox server. Requires docker.                                                                                                                             Aug 15, 2022    N/A                    N/A
+   :pypi:`pytest-ec2`                               Pytest execution on EC2 instance                                                                                                                                                                          Oct 22, 2019    3 - Alpha              N/A
+   :pypi:`pytest-echo`                              pytest plugin with mechanisms for echoing environment variables, package version and generic attributes                                                                                                   Jan 08, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-ekstazi`                           Pytest plugin to select test using Ekstazi algorithm                                                                                                                                                      Sep 10, 2022    N/A                    pytest
+   :pypi:`pytest-elasticsearch`                     Elasticsearch fixtures and fixture factories for Pytest.                                                                                                                                                  Mar 01, 2022    5 - Production/Stable  pytest (>=6.2.0)
+   :pypi:`pytest-elements`                          Tool to help automate user interfaces                                                                                                                                                                     Jan 13, 2021    N/A                    pytest (>=5.4,<6.0)
+   :pypi:`pytest-eliot`                             An eliot plugin for pytest.                                                                                                                                                                               Aug 31, 2022    1 - Planning           pytest (>=5.4.0)
+   :pypi:`pytest-elk-reporter`                      A simple plugin to use with pytest                                                                                                                                                                        Jan 24, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-email`                             Send execution result email                                                                                                                                                                               Jul 08, 2020    N/A                    pytest
+   :pypi:`pytest-embedded`                          A pytest plugin that designed for embedded testing.                                                                                                                                                       Jun 14, 2023    5 - Production/Stable  pytest>=7.0
+   :pypi:`pytest-embedded-arduino`                  Make pytest-embedded plugin work with Arduino.                                                                                                                                                            Jun 14, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-embedded-idf`                      Make pytest-embedded plugin work with ESP-IDF.                                                                                                                                                            Jun 14, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-embedded-jtag`                     Make pytest-embedded plugin work with JTAG.                                                                                                                                                               Jun 14, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-embedded-qemu`                     Make pytest-embedded plugin work with QEMU.                                                                                                                                                               Jun 14, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-embedded-serial`                   Make pytest-embedded plugin work with Serial.                                                                                                                                                             Jun 14, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-embedded-serial-esp`               Make pytest-embedded plugin work with Espressif target boards.                                                                                                                                            Jun 14, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-embrace`                           💝  Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate.                                                                                                            Mar 25, 2023    N/A                    pytest (>=7.0,<8.0)
+   :pypi:`pytest-emoji`                             A pytest plugin that adds emojis to your test result report                                                                                                                                               Feb 19, 2019    4 - Beta               pytest (>=4.2.1)
+   :pypi:`pytest-emoji-output`                      Pytest plugin to represent test output with emoji support                                                                                                                                                 Apr 09, 2023    4 - Beta               pytest (==7.0.1)
+   :pypi:`pytest-enabler`                           Enable installed pytest plugins                                                                                                                                                                           May 12, 2023    5 - Production/Stable  pytest (>=6) ; extra == 'testing'
+   :pypi:`pytest-encode`                            set your encoding and logger                                                                                                                                                                              Nov 06, 2021    N/A                    N/A
+   :pypi:`pytest-encode-kane`                       set your encoding and logger                                                                                                                                                                              Nov 16, 2021    N/A                    pytest
+   :pypi:`pytest-enhanced-reports`                  Enhanced test reports for pytest                                                                                                                                                                          Dec 15, 2022    N/A                    N/A
+   :pypi:`pytest-enhancements`                      Improvements for pytest (rejected upstream)                                                                                                                                                               Oct 30, 2019    4 - Beta               N/A
+   :pypi:`pytest-env`                               py.test plugin that allows you to add environment variables.                                                                                                                                              Jun 15, 2023    5 - Production/Stable  pytest>=7.3.1
+   :pypi:`pytest-envfiles`                          A py.test plugin that parses environment files before running tests                                                                                                                                       Oct 08, 2015    3 - Alpha              N/A
+   :pypi:`pytest-env-info`                          Push information about the running pytest into envvars                                                                                                                                                    Nov 25, 2017    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-envraw`                            py.test plugin that allows you to add environment variables.                                                                                                                                              Aug 27, 2020    4 - Beta               pytest (>=2.6.0)
+   :pypi:`pytest-envvars`                           Pytest plugin to validate use of envvars on your tests                                                                                                                                                    Jun 13, 2020    5 - Production/Stable  pytest (>=3.0.0)
+   :pypi:`pytest-env-yaml`                                                                                                                                                                                                                                    Apr 02, 2019    N/A                    N/A
+   :pypi:`pytest-eradicate`                         pytest plugin to check for commented out code                                                                                                                                                             Sep 08, 2020    N/A                    pytest (>=2.4.2)
+   :pypi:`pytest-error-for-skips`                   Pytest plugin to treat skipped tests a test failure                                                                                                                                                       Dec 19, 2019    4 - Beta               pytest (>=4.6)
+   :pypi:`pytest-eth`                               PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM).                                                                                                                             Aug 14, 2020    1 - Planning           N/A
+   :pypi:`pytest-ethereum`                          pytest-ethereum: Pytest library for ethereum projects.                                                                                                                                                    Jun 24, 2019    3 - Alpha              pytest (==3.3.2); extra == 'dev'
+   :pypi:`pytest-eucalyptus`                        Pytest Plugin for BDD                                                                                                                                                                                     Jun 28, 2022    N/A                    pytest (>=4.2.0)
+   :pypi:`pytest-eventlet`                          Applies eventlet monkey-patch as a pytest plugin.                                                                                                                                                         Oct 04, 2021    N/A                    pytest ; extra == 'dev'
+   :pypi:`pytest-examples`                          Pytest plugin for testing examples in docstrings and markdown files.                                                                                                                                      May 05, 2023    4 - Beta               pytest>=7
+   :pypi:`pytest-excel`                             pytest plugin for generating excel reports                                                                                                                                                                Jan 31, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-exceptional`                       Better exceptions                                                                                                                                                                                         Mar 16, 2017    4 - Beta               N/A
+   :pypi:`pytest-exception-script`                  Walk your code through exception script to check it's resiliency to failures.                                                                                                                             Aug 04, 2020    3 - Alpha              pytest
+   :pypi:`pytest-executable`                        pytest plugin for testing executables                                                                                                                                                                     Mar 25, 2023    N/A                    pytest (<8,>=4.3)
+   :pypi:`pytest-execution-timer`                   A timer for the phases of Pytest's execution.                                                                                                                                                             Dec 24, 2021    4 - Beta               N/A
+   :pypi:`pytest-expect`                            py.test plugin to store test expectations and mark tests based on them                                                                                                                                    Apr 21, 2016    4 - Beta               N/A
+   :pypi:`pytest-expectdir`                         A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one                                                                            Mar 19, 2023    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-expecter`                          Better testing with expecter and pytest.                                                                                                                                                                  Sep 18, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-expectr`                           This plugin is used to expect multiple assert using pytest framework.                                                                                                                                     Oct 05, 2018    N/A                    pytest (>=2.4.2)
+   :pypi:`pytest-expect-test`                       A fixture to support expect tests in pytest                                                                                                                                                               Apr 10, 2023    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-experiments`                       A pytest plugin to help developers of research-oriented software projects keep track of the results of their numerical experiments.                                                                       Dec 13, 2021    4 - Beta               pytest (>=6.2.5,<7.0.0)
+   :pypi:`pytest-explicit`                          A Pytest plugin to ignore certain marked tests by default                                                                                                                                                 Jun 15, 2021    5 - Production/Stable  pytest
+   :pypi:`pytest-exploratory`                       Interactive console for pytest.                                                                                                                                                                           Feb 21, 2022    N/A                    pytest (>=6.2)
+   :pypi:`pytest-extensions`                        A collection of helpers for pytest to ease testing                                                                                                                                                        Aug 17, 2022    4 - Beta               pytest ; extra == 'testing'
+   :pypi:`pytest-external-blockers`                 a special outcome for tests that are blocked for external reasons                                                                                                                                         Oct 05, 2021    N/A                    pytest
+   :pypi:`pytest-extra-durations`                   A pytest plugin to get durations on a per-function basis and per module basis.                                                                                                                            Apr 21, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-extra-markers`                     Additional pytest markers to dynamically enable/disable tests viia CLI flags                                                                                                                              Mar 05, 2023    4 - Beta               pytest
+   :pypi:`pytest-fabric`                            Provides test utilities to run fabric task tests by using docker containers                                                                                                                               Sep 12, 2018    5 - Production/Stable  N/A
+   :pypi:`pytest-factor`                            A package to prevent Dependency Confusion attacks against Yandex.                                                                                                                                         Feb 10, 2023    N/A                    N/A
+   :pypi:`pytest-factory`                           Use factories for test setup with py.test                                                                                                                                                                 Sep 06, 2020    3 - Alpha              pytest (>4.3)
+   :pypi:`pytest-factoryboy`                        Factory Boy support for pytest.                                                                                                                                                                           Dec 01, 2022    6 - Mature             pytest (>=5.0.0)
+   :pypi:`pytest-factoryboy-fixtures`               Generates pytest fixtures that allow the use of type hinting                                                                                                                                              Jun 25, 2020    N/A                    N/A
+   :pypi:`pytest-factoryboy-state`                  Simple factoryboy random state management                                                                                                                                                                 Mar 22, 2022    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-failed-screen-record`              Create a video of the screen when pytest fails                                                                                                                                                            Jan 05, 2023    4 - Beta               pytest (>=7.1.2d,<8.0.0)
+   :pypi:`pytest-failed-screenshot`                 Test case fails,take a screenshot,save it,attach it to the allure                                                                                                                                         Apr 21, 2021    N/A                    N/A
+   :pypi:`pytest-failed-to-verify`                  A pytest plugin that helps better distinguishing real test failures from setup flakiness.                                                                                                                 Aug 08, 2019    5 - Production/Stable  pytest (>=4.1.0)
+   :pypi:`pytest-fail-slow`                         Fail tests that take too long to run                                                                                                                                                                      Aug 13, 2022    4 - Beta               pytest (>=6.0)
+   :pypi:`pytest-faker`                             Faker integration with the pytest framework.                                                                                                                                                              Dec 19, 2016    6 - Mature             N/A
+   :pypi:`pytest-falcon`                            Pytest helpers for Falcon.                                                                                                                                                                                Sep 07, 2016    4 - Beta               N/A
+   :pypi:`pytest-falcon-client`                     Pytest \`client\` fixture for the Falcon Framework                                                                                                                                                        Mar 19, 2019    N/A                    N/A
+   :pypi:`pytest-fantasy`                           Pytest plugin for Flask Fantasy Framework                                                                                                                                                                 Mar 14, 2019    N/A                    N/A
+   :pypi:`pytest-fastapi`                                                                                                                                                                                                                                     Dec 27, 2020    N/A                    N/A
+   :pypi:`pytest-fastapi-deps`                      A fixture which allows easy replacement of fastapi dependencies for testing                                                                                                                               Jul 20, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-fastest`                           Use SCM and coverage to run only needed tests                                                                                                                                                             Jun 15, 2023    4 - Beta               pytest (>=4.4)
+   :pypi:`pytest-fast-first`                        Pytest plugin that runs fast tests first                                                                                                                                                                  Jan 19, 2023    3 - Alpha              pytest
+   :pypi:`pytest-faulthandler`                      py.test plugin that activates the fault handler module for tests (dummy package)                                                                                                                          Jul 04, 2019    6 - Mature             pytest (>=5.0)
+   :pypi:`pytest-fauxfactory`                       Integration of fauxfactory into pytest.                                                                                                                                                                   Dec 06, 2017    5 - Production/Stable  pytest (>=3.2)
+   :pypi:`pytest-figleaf`                           py.test figleaf coverage plugin                                                                                                                                                                           Jan 18, 2010    5 - Production/Stable  N/A
+   :pypi:`pytest-filecov`                           A pytest plugin to detect unused files                                                                                                                                                                    Jun 27, 2021    4 - Beta               pytest
+   :pypi:`pytest-filedata`                          easily load data from files                                                                                                                                                                               Jan 17, 2019    4 - Beta               N/A
+   :pypi:`pytest-filemarker`                        A pytest plugin that runs marked tests when files change.                                                                                                                                                 Dec 01, 2020    N/A                    pytest
+   :pypi:`pytest-file-watcher`                      Pytest-File-Watcher is a CLI tool that watches for changes in your code and runs pytest on the changed files.                                                                                             Mar 23, 2023    N/A                    pytest
+   :pypi:`pytest-filter-case`                       run test cases filter by mark                                                                                                                                                                             Nov 05, 2020    N/A                    N/A
+   :pypi:`pytest-filter-subpackage`                 Pytest plugin for filtering based on sub-packages                                                                                                                                                         Dec 12, 2022    3 - Alpha              pytest (>=3.0)
+   :pypi:`pytest-find-dependencies`                 A pytest plugin to find dependencies between tests                                                                                                                                                        Apr 09, 2022    4 - Beta               pytest (>=4.3.0)
+   :pypi:`pytest-finer-verdicts`                    A pytest plugin to treat non-assertion failures as test errors.                                                                                                                                           Jun 18, 2020    N/A                    pytest (>=5.4.3)
+   :pypi:`pytest-firefox`                           pytest plugin to manipulate firefox                                                                                                                                                                       Aug 08, 2017    3 - Alpha              pytest (>=3.0.2)
+   :pypi:`pytest-fixture-classes`                   Fixtures as classes that work well with dependency injection, autocompletetion, type checkers, and language servers                                                                                       Jan 20, 2023    4 - Beta               pytest
+   :pypi:`pytest-fixture-config`                    Fixture configuration utils for py.test                                                                                                                                                                   May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-fixture-maker`                     Pytest plugin to load fixtures from YAML files                                                                                                                                                            Sep 21, 2021    N/A                    N/A
+   :pypi:`pytest-fixture-marker`                    A pytest plugin to add markers based on fixtures used.                                                                                                                                                    Oct 11, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-fixture-order`                     pytest plugin to control fixture evaluation order                                                                                                                                                         May 16, 2022    5 - Production/Stable  pytest (>=3.0)
+   :pypi:`pytest-fixture-ref`                       Lets users reference fixtures without name matching magic.                                                                                                                                                Nov 17, 2022    4 - Beta               N/A
+   :pypi:`pytest-fixture-rtttg`                     Warn or fail on fixture name clash                                                                                                                                                                        Feb 23, 2022    N/A                    pytest (>=7.0.1,<8.0.0)
+   :pypi:`pytest-fixtures`                          Common fixtures for pytest                                                                                                                                                                                May 01, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-fixture-tools`                     Plugin for pytest which provides tools for fixtures                                                                                                                                                       Aug 18, 2020    6 - Mature             pytest
+   :pypi:`pytest-fixture-typecheck`                 A pytest plugin to assert type annotations at runtime.                                                                                                                                                    Aug 24, 2021    N/A                    pytest
+   :pypi:`pytest-flake8`                            pytest plugin to check FLAKE8 requirements                                                                                                                                                                Mar 18, 2022    4 - Beta               pytest (>=7.0)
+   :pypi:`pytest-flake8-path`                       A pytest fixture for testing flake8 plugins.                                                                                                                                                              Jun 16, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-flake8-v2`                         pytest plugin to check FLAKE8 requirements                                                                                                                                                                Mar 01, 2022    5 - Production/Stable  pytest (>=7.0)
+   :pypi:`pytest-flakefinder`                       Runs tests multiple times to expose flakiness.                                                                                                                                                            Oct 26, 2022    4 - Beta               pytest (>=2.7.1)
+   :pypi:`pytest-flakes`                            pytest plugin to check source code with pyflakes                                                                                                                                                          Dec 02, 2021    5 - Production/Stable  pytest (>=5)
+   :pypi:`pytest-flaptastic`                        Flaptastic py.test plugin                                                                                                                                                                                 Mar 17, 2019    N/A                    N/A
+   :pypi:`pytest-flask`                             A set of py.test fixtures to test Flask applications.                                                                                                                                                     Feb 27, 2021    5 - Production/Stable  pytest (>=5.2)
+   :pypi:`pytest-flask-ligand`                      Pytest fixtures and helper functions to use for testing flask-ligand microservices.                                                                                                                       Apr 25, 2023    4 - Beta               pytest (~=7.3)
+   :pypi:`pytest-flask-sqlalchemy`                  A pytest plugin for preserving test isolation in Flask-SQlAlchemy using database transactions.                                                                                                            Apr 30, 2022    4 - Beta               pytest (>=3.2.1)
+   :pypi:`pytest-flask-sqlalchemy-transactions`     Run tests in transactions using pytest, Flask, and SQLalchemy.                                                                                                                                            Aug 02, 2018    4 - Beta               pytest (>=3.2.1)
+   :pypi:`pytest-flexreport`                                                                                                                                                                                                                                  Apr 15, 2023    4 - Beta               pytest
+   :pypi:`pytest-fluent`                            A pytest plugin in order to provide logs via fluentd                                                                                                                                                      Jul 12, 2022    4 - Beta               pytest
+   :pypi:`pytest-flyte`                             Pytest fixtures for simplifying Flyte integration testing                                                                                                                                                 May 03, 2021    N/A                    pytest
+   :pypi:`pytest-focus`                             A pytest plugin that alerts user of failed test cases with screen notifications                                                                                                                           May 04, 2019    4 - Beta               pytest
+   :pypi:`pytest-forbid`                                                                                                                                                                                                                                      Mar 07, 2023    N/A                    pytest (>=7.2.2,<8.0.0)
+   :pypi:`pytest-forcefail`                         py.test plugin to make the test failing regardless of pytest.mark.xfail                                                                                                                                   May 15, 2018    4 - Beta               N/A
+   :pypi:`pytest-forward-compatability`             A name to avoid typosquating pytest-foward-compatibility                                                                                                                                                  Sep 06, 2020    N/A                    N/A
+   :pypi:`pytest-forward-compatibility`             A pytest plugin to shim pytest commandline options for fowards compatibility                                                                                                                              Sep 29, 2020    N/A                    N/A
+   :pypi:`pytest-frappe`                            Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications                                                                                                                               May 03, 2023    4 - Beta               pytest>=7.0.0
+   :pypi:`pytest-freezegun`                         Wrap tests with fixtures in freeze_time                                                                                                                                                                   Jul 19, 2020    4 - Beta               pytest (>=3.0.0)
+   :pypi:`pytest-freezer`                           Pytest plugin providing a fixture interface for spulec/freezegun                                                                                                                                          Jun 17, 2023    N/A                    pytest>=3.6
+   :pypi:`pytest-freeze-reqs`                       Check if requirement files are frozen                                                                                                                                                                     Apr 29, 2021    N/A                    N/A
+   :pypi:`pytest-frozen-uuids`                      Deterministically frozen UUID's for your tests                                                                                                                                                            Apr 17, 2022    N/A                    pytest (>=3.0)
+   :pypi:`pytest-func-cov`                          Pytest plugin for measuring function coverage                                                                                                                                                             Apr 15, 2021    3 - Alpha              pytest (>=5)
+   :pypi:`pytest-funparam`                          An alternative way to parametrize test cases.                                                                                                                                                             Dec 02, 2021    4 - Beta               pytest >=4.6.0
+   :pypi:`pytest-fxa`                               pytest plugin for Firefox Accounts                                                                                                                                                                        Aug 28, 2018    5 - Production/Stable  N/A
+   :pypi:`pytest-fxtest`                                                                                                                                                                                                                                      Oct 27, 2020    N/A                    N/A
+   :pypi:`pytest-fzf`                               fzf-based test selector for pytest                                                                                                                                                                        Aug 17, 2022    1 - Planning           pytest (>=7.1.2)
+   :pypi:`pytest-gather-fixtures`                   set up asynchronous pytest fixtures concurrently                                                                                                                                                          Apr 12, 2022    N/A                    pytest (>=6.0.0)
+   :pypi:`pytest-gc`                                The garbage collector plugin for py.test                                                                                                                                                                  Feb 01, 2018    N/A                    N/A
+   :pypi:`pytest-gcov`                              Uses gcov to measure test coverage of a C library                                                                                                                                                         Feb 01, 2018    3 - Alpha              N/A
+   :pypi:`pytest-gevent`                            Ensure that gevent is properly patched when invoking pytest                                                                                                                                               Feb 25, 2020    N/A                    pytest
+   :pypi:`pytest-gherkin`                           A flexible framework for executing BDD gherkin tests                                                                                                                                                      Jul 27, 2019    3 - Alpha              pytest (>=5.0.0)
+   :pypi:`pytest-gh-log-group`                      pytest plugin for gh actions                                                                                                                                                                              Jan 11, 2022    3 - Alpha              pytest
+   :pypi:`pytest-ghostinspector`                    For finding/executing Ghost Inspector tests                                                                                                                                                               May 17, 2016    3 - Alpha              N/A
+   :pypi:`pytest-girder`                            A set of pytest fixtures for testing Girder applications.                                                                                                                                                 Jun 14, 2023    N/A                    N/A
+   :pypi:`pytest-git`                               Git repository fixture for py.test                                                                                                                                                                        May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-gitcov`                            Pytest plugin for reporting on coverage of the last git commit.                                                                                                                                           Jan 11, 2020    2 - Pre-Alpha          N/A
+   :pypi:`pytest-git-fixtures`                      Pytest fixtures for testing with git.                                                                                                                                                                     Mar 11, 2021    4 - Beta               pytest
+   :pypi:`pytest-github`                            Plugin for py.test that associates tests with github issues using a marker.                                                                                                                               Mar 07, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-github-actions-annotate-failures`  pytest plugin to annotate failed tests with a workflow command for GitHub Actions                                                                                                                         May 04, 2023    5 - Production/Stable  pytest (>=4.0.0)
+   :pypi:`pytest-github-report`                     Generate a GitHub report using pytest in GitHub Workflows                                                                                                                                                 Jun 03, 2022    4 - Beta               N/A
+   :pypi:`pytest-gitignore`                         py.test plugin to ignore the same files as git                                                                                                                                                            Jul 17, 2015    4 - Beta               N/A
+   :pypi:`pytest-gitlabci-parallelized`             Parallelize pytest across GitLab CI workers.                                                                                                                                                              Mar 08, 2023    N/A                    N/A
+   :pypi:`pytest-git-selector`                      Utility to select tests that have had its dependencies modified (as identified by git diff)                                                                                                               Nov 17, 2022    N/A                    N/A
+   :pypi:`pytest-glamor-allure`                     Extends allure-pytest functionality                                                                                                                                                                       Jul 22, 2022    4 - Beta               pytest
+   :pypi:`pytest-gnupg-fixtures`                    Pytest fixtures for testing with gnupg.                                                                                                                                                                   Mar 04, 2021    4 - Beta               pytest
+   :pypi:`pytest-golden`                            Plugin for pytest that offloads expected outputs to data files                                                                                                                                            Jul 18, 2022    N/A                    pytest (>=6.1.2)
+   :pypi:`pytest-goldie`                            A plugin to support golden tests with pytest.                                                                                                                                                             May 23, 2023    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-google-chat`                       Notify google chat channel for test results                                                                                                                                                               Mar 27, 2022    4 - Beta               pytest
+   :pypi:`pytest-graphql-schema`                    Get graphql schema as fixture for pytest                                                                                                                                                                  Oct 18, 2019    N/A                    N/A
+   :pypi:`pytest-greendots`                         Green progress dots                                                                                                                                                                                       Feb 08, 2014    3 - Alpha              N/A
+   :pypi:`pytest-growl`                             Growl notifications for pytest results.                                                                                                                                                                   Jan 13, 2014    5 - Production/Stable  N/A
+   :pypi:`pytest-grpc`                              pytest plugin for grpc                                                                                                                                                                                    May 01, 2020    N/A                    pytest (>=3.6.0)
+   :pypi:`pytest-grunnur`                           Py.Test plugin for Grunnur-based packages.                                                                                                                                                                Feb 05, 2023    N/A                    N/A
+   :pypi:`pytest-hammertime`                        Display "🔨 " instead of "." for passed pytest tests.                                                                                                                                                     Jul 28, 2018    N/A                    pytest
+   :pypi:`pytest-harmony`                           Chain tests and data with pytest                                                                                                                                                                          Jan 17, 2023    N/A                    pytest (>=7.2.1,<8.0.0)
+   :pypi:`pytest-harvest`                           Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.                                                             Jun 10, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-helm-chart`                        A plugin to provide different types and configs of Kubernetes clusters that can be used for testing.                                                                                                      Jun 15, 2020    4 - Beta               pytest (>=5.4.2,<6.0.0)
+   :pypi:`pytest-helm-charts`                       A plugin to provide different types and configs of Kubernetes clusters that can be used for testing.                                                                                                      Mar 08, 2023    4 - Beta               pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-helper`                            Functions to help in using the pytest testing framework                                                                                                                                                   May 31, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-helpers`                           pytest helpers                                                                                                                                                                                            May 17, 2020    N/A                    pytest
+   :pypi:`pytest-helpers-namespace`                 Pytest Helpers Namespace Plugin                                                                                                                                                                           Dec 29, 2021    5 - Production/Stable  pytest (>=6.0.0)
+   :pypi:`pytest-hidecaptured`                      Hide captured output                                                                                                                                                                                      May 04, 2018    4 - Beta               pytest (>=2.8.5)
+   :pypi:`pytest-historic`                          Custom report to display pytest historical execution records                                                                                                                                              Apr 08, 2020    N/A                    pytest
+   :pypi:`pytest-historic-hook`                     Custom listener to store execution results into MYSQL DB, which is used for pytest-historic report                                                                                                        Apr 08, 2020    N/A                    pytest
+   :pypi:`pytest-homeassistant`                     A pytest plugin for use with homeassistant custom components.                                                                                                                                             Aug 12, 2020    4 - Beta               N/A
+   :pypi:`pytest-homeassistant-custom-component`    Experimental package to automatically extract test plugins for Home Assistant custom components                                                                                                           Jun 16, 2023    3 - Alpha              pytest (==7.3.1)
+   :pypi:`pytest-honey`                             A simple plugin to use with pytest                                                                                                                                                                        Jan 07, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-honors`                            Report on tests that honor constraints, and guard against regressions                                                                                                                                     Mar 06, 2020    4 - Beta               N/A
+   :pypi:`pytest-hot-reloading`                                                                                                                                                                                                                               Jun 16, 2023    N/A                    N/A
+   :pypi:`pytest-hot-test`                          A plugin that tracks test changes                                                                                                                                                                         Dec 10, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-hoverfly`                          Simplify working with Hoverfly from pytest                                                                                                                                                                Jan 30, 2023    N/A                    pytest (>=5.0)
+   :pypi:`pytest-hoverfly-wrapper`                  Integrates the Hoverfly HTTP proxy into Pytest                                                                                                                                                            Feb 27, 2023    5 - Production/Stable  pytest (>=3.7.0)
+   :pypi:`pytest-hpfeeds`                           Helpers for testing hpfeeds in your python project                                                                                                                                                        Feb 28, 2023    4 - Beta               pytest (>=6.2.4,<7.0.0)
+   :pypi:`pytest-html`                              pytest plugin for generating HTML reports                                                                                                                                                                 Apr 08, 2023    5 - Production/Stable  pytest (!=6.0.0,>=5.0)
+   :pypi:`pytest-html-lee`                          optimized pytest plugin for generating HTML reports                                                                                                                                                       Jun 30, 2020    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-html-merger`                       Pytest HTML reports merging utility                                                                                                                                                                       Apr 03, 2022    N/A                    N/A
+   :pypi:`pytest-html-object-storage`               Pytest report plugin for send HTML report on object-storage                                                                                                                                               Mar 04, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-html-profiling`                    Pytest plugin for generating HTML reports with per-test profiling and optionally call graph visualizations. Based on pytest-html by Dave Hunt.                                                            Feb 11, 2020    5 - Production/Stable  pytest (>=3.0)
+   :pypi:`pytest-html-reporter`                     Generates a static html report based on pytest framework                                                                                                                                                  Feb 13, 2022    N/A                    N/A
+   :pypi:`pytest-html-report-merger`                                                                                                                                                                                                                          Aug 31, 2022    N/A                    N/A
+   :pypi:`pytest-html-thread`                       pytest plugin for generating HTML reports                                                                                                                                                                 Dec 29, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-http`                              Fixture "http" for http requests                                                                                                                                                                          Dec 05, 2019    N/A                    N/A
+   :pypi:`pytest-httpbin`                           Easily test your HTTP library against a local copy of httpbin                                                                                                                                             May 08, 2023    5 - Production/Stable  pytest ; extra == 'test'
+   :pypi:`pytest-httpdbg`                           A pytest plugin to record HTTP(S) requests with stack trace                                                                                                                                               May 09, 2023    3 - Alpha              pytest (>=7.0.0)
+   :pypi:`pytest-http-mocker`                       Pytest plugin for http mocking (via https://github.com/vilus/mocker)                                                                                                                                      Oct 20, 2019    N/A                    N/A
+   :pypi:`pytest-httpretty`                         A thin wrapper of HTTPretty for pytest                                                                                                                                                                    Feb 16, 2014    3 - Alpha              N/A
+   :pypi:`pytest-httpserver`                        pytest-httpserver is a httpserver for pytest                                                                                                                                                              May 22, 2023    3 - Alpha              N/A
+   :pypi:`pytest-httptesting`                       http_testing framework on top of pytest                                                                                                                                                                   Jun 03, 2023    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-httpx`                             Send responses to httpx.                                                                                                                                                                                  Apr 12, 2023    5 - Production/Stable  pytest (<8.0,>=6.0)
+   :pypi:`pytest-httpx-blockage`                    Disable httpx requests during a test run                                                                                                                                                                  Feb 16, 2023    N/A                    pytest (>=7.2.1)
+   :pypi:`pytest-hue`                               Visualise PyTest status via your Phillips Hue lights                                                                                                                                                      May 09, 2019    N/A                    N/A
+   :pypi:`pytest-hylang`                            Pytest plugin to allow running tests written in hylang                                                                                                                                                    Mar 28, 2021    N/A                    pytest
+   :pypi:`pytest-hypo-25`                           help hypo module for pytest                                                                                                                                                                               Jan 12, 2020    3 - Alpha              N/A
+   :pypi:`pytest-ibutsu`                            A plugin to sent pytest results to an Ibutsu server                                                                                                                                                       Aug 05, 2022    4 - Beta               pytest>=7.1
+   :pypi:`pytest-icdiff`                            use icdiff for better error messages in pytest assertions                                                                                                                                                 Aug 09, 2022    4 - Beta               N/A
+   :pypi:`pytest-idapro`                            A pytest plugin for idapython. Allows a pytest setup to run tests outside and inside IDA in an automated manner by runnig pytest inside IDA and by mocking idapython api                                  Nov 03, 2018    N/A                    N/A
+   :pypi:`pytest-idem`                              A pytest plugin to help with testing idem projects                                                                                                                                                        Sep 07, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-idempotent`                        Pytest plugin for testing function idempotence.                                                                                                                                                           Jul 25, 2022    N/A                    N/A
+   :pypi:`pytest-ignore-flaky`                      ignore failures from flaky tests (pytest plugin)                                                                                                                                                          Apr 23, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-image-diff`                                                                                                                                                                                                                                  Mar 09, 2023    3 - Alpha              pytest
+   :pypi:`pytest-incremental`                       an incremental test runner (pytest plugin)                                                                                                                                                                Apr 24, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-influxdb`                          Plugin for influxdb and pytest integration.                                                                                                                                                               Apr 20, 2021    N/A                    N/A
+   :pypi:`pytest-info-collector`                    pytest plugin to collect information from tests                                                                                                                                                           May 26, 2019    3 - Alpha              N/A
+   :pypi:`pytest-informative-node`                  display more node ininformation.                                                                                                                                                                          Apr 25, 2019    4 - Beta               N/A
+   :pypi:`pytest-infrastructure`                    pytest stack validation prior to testing executing                                                                                                                                                        Apr 12, 2020    4 - Beta               N/A
+   :pypi:`pytest-ini`                               Reuse pytest.ini to store env variables                                                                                                                                                                   Apr 26, 2022    N/A                    N/A
+   :pypi:`pytest-inline`                            A pytest plugin for writing inline tests.                                                                                                                                                                 Feb 08, 2023    4 - Beta               pytest (>=7.0.0)
+   :pypi:`pytest-inmanta`                           A py.test plugin providing fixtures to simplify inmanta modules testing.                                                                                                                                  Feb 23, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-inmanta-extensions`                Inmanta tests package                                                                                                                                                                                     Apr 12, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-inmanta-lsm`                       Common fixtures for inmanta LSM related modules                                                                                                                                                           May 17, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-inmanta-yang`                      Common fixtures used in inmanta yang related modules                                                                                                                                                      Jun 16, 2022    4 - Beta               N/A
+   :pypi:`pytest-Inomaly`                           A simple image diff plugin for pytest                                                                                                                                                                     Feb 13, 2018    4 - Beta               N/A
+   :pypi:`pytest-insta`                             A practical snapshot testing plugin for pytest                                                                                                                                                            Nov 02, 2022    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-instafail`                         pytest plugin to show failures instantly                                                                                                                                                                  Mar 31, 2023    4 - Beta               pytest (>=5)
+   :pypi:`pytest-instrument`                        pytest plugin to instrument tests                                                                                                                                                                         Apr 05, 2020    5 - Production/Stable  pytest (>=5.1.0)
+   :pypi:`pytest-integration`                       Organizing pytests by integration or not                                                                                                                                                                  Nov 17, 2022    N/A                    N/A
+   :pypi:`pytest-integration-mark`                  Automatic integration test marking and excluding plugin for pytest                                                                                                                                        May 22, 2023    N/A                    pytest (>=5.2)
+   :pypi:`pytest-interactive`                       A pytest plugin for console based interactive test selection just after the collection phase                                                                                                              Nov 30, 2017    3 - Alpha              N/A
+   :pypi:`pytest-intercept-remote`                  Pytest plugin for intercepting outgoing connection requests during pytest run.                                                                                                                            May 24, 2021    4 - Beta               pytest (>=4.6)
+   :pypi:`pytest-interface-tester`                  Pytest plugin for checking charm relation interface protocol compliance.                                                                                                                                  May 09, 2023    4 - Beta               pytest
+   :pypi:`pytest-invenio`                           Pytest fixtures for Invenio.                                                                                                                                                                              Jun 02, 2023    5 - Production/Stable  pytest (<7.2.0,>=6)
+   :pypi:`pytest-involve`                           Run tests covering a specific file or changeset                                                                                                                                                           Feb 02, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-ipdb`                              A py.test plug-in to enable drop to ipdb debugger on test failure.                                                                                                                                        Mar 20, 2013    2 - Pre-Alpha          N/A
+   :pypi:`pytest-ipynb`                             THIS PROJECT IS ABANDONED                                                                                                                                                                                 Jan 29, 2019    3 - Alpha              N/A
+   :pypi:`pytest-isolate`                                                                                                                                                                                                                                     Feb 20, 2023    4 - Beta               pytest
+   :pypi:`pytest-isort`                             py.test plugin to check import ordering using isort                                                                                                                                                       Oct 31, 2022    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-is-running`                        pytest plugin providing a function to check if pytest is running.                                                                                                                                         Jun 16, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-it`                                Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it.                                                                                      Jan 22, 2020    4 - Beta               N/A
+   :pypi:`pytest-iterassert`                        Nicer list and iterable assertion messages for pytest                                                                                                                                                     May 11, 2020    3 - Alpha              N/A
+   :pypi:`pytest-iters`                             A contextmanager pytest fixture for handling multiple mock iters                                                                                                                                          May 24, 2022    N/A                    N/A
+   :pypi:`pytest-jasmine`                           Run jasmine tests from your pytest test suite                                                                                                                                                             Nov 04, 2017    1 - Planning           N/A
+   :pypi:`pytest-jelastic`                          Pytest plugin defining the necessary command-line options to pass to pytests testing a Jelastic environment.                                                                                              Nov 16, 2022    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-jest`                              A custom jest-pytest oriented Pytest reporter                                                                                                                                                             May 22, 2018    4 - Beta               pytest (>=3.3.2)
+   :pypi:`pytest-jinja`                             A plugin to generate customizable jinja-based HTML reports in pytest                                                                                                                                      Oct 04, 2022    3 - Alpha              pytest (>=6.2.5,<7.0.0)
+   :pypi:`pytest-jira`                              py.test JIRA integration plugin, using markers                                                                                                                                                            Jun 12, 2023    3 - Alpha              N/A
+   :pypi:`pytest-jira-xfail`                        Plugin skips (xfail) tests if unresolved Jira issue(s) linked                                                                                                                                             Jun 14, 2023    N/A                    pytest (>=7.2.0)
+   :pypi:`pytest-jira-xray`                         pytest plugin to integrate tests with JIRA XRAY                                                                                                                                                           Jun 06, 2023    4 - Beta               pytest
+   :pypi:`pytest-job-selection`                     A pytest plugin for load balancing test suites                                                                                                                                                            Jan 30, 2023    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-jobserver`                         Limit parallel tests with posix jobserver.                                                                                                                                                                May 15, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-joke`                              Test failures are better served with humor.                                                                                                                                                               Oct 08, 2019    4 - Beta               pytest (>=4.2.1)
+   :pypi:`pytest-json`                              Generate JSON test reports                                                                                                                                                                                Jan 18, 2016    4 - Beta               N/A
+   :pypi:`pytest-json-fixtures`                     JSON output for the --fixtures flag                                                                                                                                                                       Mar 14, 2023    4 - Beta               N/A
+   :pypi:`pytest-jsonlint`                          UNKNOWN                                                                                                                                                                                                   Aug 04, 2016    N/A                    N/A
+   :pypi:`pytest-json-report`                       A pytest plugin to report test results as JSON files                                                                                                                                                      Mar 15, 2022    4 - Beta               pytest (>=3.8.0)
+   :pypi:`pytest-jtr`                               pytest plugin supporting json test report output                                                                                                                                                          Nov 29, 2022    N/A                    pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-jupyter`                           A pytest plugin for testing Jupyter libraries and extensions.                                                                                                                                             Mar 30, 2023    4 - Beta               pytest
+   :pypi:`pytest-jupyterhub`                        A reusable JupyterHub pytest plugin                                                                                                                                                                       Apr 25, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-kafka`                             Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest                                                                                                                                           Jun 14, 2023    N/A                    pytest
+   :pypi:`pytest-kafkavents`                        A plugin to send pytest events to Kafka                                                                                                                                                                   Sep 08, 2021    4 - Beta               pytest
+   :pypi:`pytest-kasima`                            Display horizontal lines above and below the captured standard output for easy viewing.                                                                                                                   Jan 26, 2023    5 - Production/Stable  pytest (>=7.2.1,<8.0.0)
+   :pypi:`pytest-keep-together`                     Pytest plugin to customize test ordering by running all 'related' tests together                                                                                                                          Dec 07, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-kexi`                                                                                                                                                                                                                                        Apr 29, 2022    N/A                    pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-kind`                              Kubernetes test support with KIND for pytest                                                                                                                                                              Nov 30, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-kivy`                              Kivy GUI tests fixtures using pytest                                                                                                                                                                      Jul 06, 2021    4 - Beta               pytest (>=3.6)
+   :pypi:`pytest-knows`                             A pytest plugin that can automaticly skip test case based on dependence info calculated by trace                                                                                                          Aug 22, 2014    N/A                    N/A
+   :pypi:`pytest-konira`                            Run Konira DSL tests with py.test                                                                                                                                                                         Oct 09, 2011    N/A                    N/A
+   :pypi:`pytest-koopmans`                          A plugin for testing the koopmans package                                                                                                                                                                 Nov 21, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-krtech-common`                     pytest krtech common library                                                                                                                                                                              Nov 28, 2016    4 - Beta               N/A
+   :pypi:`pytest-kubernetes`                                                                                                                                                                                                                                  May 17, 2023    N/A                    pytest (>=7.2.1,<8.0.0)
+   :pypi:`pytest-kwparametrize`                     Alternate syntax for @pytest.mark.parametrize with test cases as dictionaries and default value fallbacks                                                                                                 Jan 22, 2021    N/A                    pytest (>=6)
+   :pypi:`pytest-lambda`                            Define pytest fixtures with lambda functions.                                                                                                                                                             Aug 20, 2022    3 - Alpha              pytest (>=3.6,<8)
+   :pypi:`pytest-lamp`                                                                                                                                                                                                                                        Jan 06, 2017    3 - Alpha              N/A
+   :pypi:`pytest-langchain`                         Pytest-style test runner for langchain agents                                                                                                                                                             Feb 26, 2023    N/A                    pytest
+   :pypi:`pytest-lark`                              A package for enhancing pytest                                                                                                                                                                            Nov 20, 2022    N/A                    N/A
+   :pypi:`pytest-launchable`                        Launchable Pytest Plugin                                                                                                                                                                                  Apr 05, 2023    N/A                    pytest (>=4.2.0)
+   :pypi:`pytest-layab`                             Pytest fixtures for layab.                                                                                                                                                                                Oct 05, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-lazy-fixture`                      It helps to use fixtures in pytest.mark.parametrize                                                                                                                                                       Feb 01, 2020    4 - Beta               pytest (>=3.2.5)
+   :pypi:`pytest-lazy-fixtures`                     Allows you to use fixtures in @pytest.mark.parametrize.                                                                                                                                                   May 28, 2023    N/A                    pytest (>=7.2.1,<8.0.0)
+   :pypi:`pytest-ldap`                              python-ldap fixtures for pytest                                                                                                                                                                           Aug 18, 2020    N/A                    pytest
+   :pypi:`pytest-leak-finder`                       Find the test that's leaking before the one that fails                                                                                                                                                    Feb 15, 2023    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-leaks`                             A pytest plugin to trace resource leaks.                                                                                                                                                                  Nov 27, 2019    1 - Planning           N/A
+   :pypi:`pytest-level`                             Select tests of a given level or lower                                                                                                                                                                    Oct 21, 2019    N/A                    pytest
+   :pypi:`pytest-libfaketime`                       A python-libfaketime plugin for pytest.                                                                                                                                                                   Dec 22, 2018    4 - Beta               pytest (>=3.0.0)
+   :pypi:`pytest-libiio`                            A pytest plugin to manage interfacing with libiio contexts                                                                                                                                                Jul 11, 2022    4 - Beta               N/A
+   :pypi:`pytest-libnotify`                         Pytest plugin that shows notifications about the test run                                                                                                                                                 Apr 02, 2021    3 - Alpha              pytest
+   :pypi:`pytest-ligo`                                                                                                                                                                                                                                        Jan 16, 2020    4 - Beta               N/A
+   :pypi:`pytest-lineno`                            A pytest plugin to show the line numbers of test functions                                                                                                                                                Dec 04, 2020    N/A                    pytest
+   :pypi:`pytest-line-profiler`                     Profile code executed by pytest                                                                                                                                                                           May 03, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-line-profiler-apn`                 Profile code executed by pytest                                                                                                                                                                           Dec 05, 2022    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-lisa`                              Pytest plugin for organizing tests.                                                                                                                                                                       Jan 21, 2021    3 - Alpha              pytest (>=6.1.2,<7.0.0)
+   :pypi:`pytest-listener`                          A simple network listener                                                                                                                                                                                 May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-litf`                              A pytest plugin that stream output in LITF format                                                                                                                                                         Jan 18, 2021    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-live`                              Live results for pytest                                                                                                                                                                                   Mar 08, 2020    N/A                    pytest
+   :pypi:`pytest-local-badge`                       Generate local badges (shields) reporting your test suite status.                                                                                                                                         Jan 15, 2023    N/A                    pytest (>=6.1.0)
+   :pypi:`pytest-localftpserver`                    A PyTest plugin which provides an FTP fixture for your tests                                                                                                                                              Oct 04, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-localserver`                       pytest plugin to test server connections locally.                                                                                                                                                         Jan 30, 2023    4 - Beta               N/A
+   :pypi:`pytest-localstack`                        Pytest plugin for AWS integration tests                                                                                                                                                                   Jun 07, 2023    4 - Beta               pytest (>=6.0.0,<7.0.0)
+   :pypi:`pytest-lockable`                          lockable resource plugin for pytest                                                                                                                                                                       Jul 20, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-locker`                            Used to lock object during testing. Essentially changing assertions from being hard coded to asserting that nothing changed                                                                               Oct 29, 2021    N/A                    pytest (>=5.4)
+   :pypi:`pytest-log`                               print log                                                                                                                                                                                                 Aug 15, 2021    N/A                    pytest (>=3.8)
+   :pypi:`pytest-logbook`                           py.test plugin to capture logbook log messages                                                                                                                                                            Nov 23, 2015    5 - Production/Stable  pytest (>=2.8)
+   :pypi:`pytest-logdog`                            Pytest plugin to test logging                                                                                                                                                                             Jun 15, 2021    1 - Planning           pytest (>=6.2.0)
+   :pypi:`pytest-logfest`                           Pytest plugin providing three logger fixtures with basic or full writing to log files                                                                                                                     Jul 21, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-logger`                            Plugin configuring handlers for loggers from Python logging module.                                                                                                                                       Jul 25, 2019    4 - Beta               pytest (>=3.2)
+   :pypi:`pytest-logging`                           Configures logging and allows tweaking the log level with a py.test flag                                                                                                                                  Nov 04, 2015    4 - Beta               N/A
+   :pypi:`pytest-logging-end-to-end-test-tool`                                                                                                                                                                                                                Sep 23, 2022    N/A                    pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-logikal`                           Common testing environment                                                                                                                                                                                Jun 04, 2023    5 - Production/Stable  pytest (==7.3.1)
+   :pypi:`pytest-log-report`                        Package for creating a pytest test run reprot                                                                                                                                                             Dec 26, 2019    N/A                    N/A
+   :pypi:`pytest-loguru`                            Pytest Loguru                                                                                                                                                                                             Apr 12, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-loop`                              pytest plugin for looping tests                                                                                                                                                                           Jul 22, 2022    5 - Production/Stable  pytest (>=6)
+   :pypi:`pytest-lsp`                               pytest plugin for end-to-end testing of language servers                                                                                                                                                  May 19, 2023    3 - Alpha              pytest
+   :pypi:`pytest-manual-marker`                     pytest marker for marking manual tests                                                                                                                                                                    Aug 04, 2022    3 - Alpha              pytest>=7
+   :pypi:`pytest-markdoctest`                       A pytest plugin to doctest your markdown files                                                                                                                                                            Jul 22, 2022    4 - Beta               pytest (>=6)
+   :pypi:`pytest-markdown`                          Test your markdown docs with pytest                                                                                                                                                                       Jan 15, 2021    4 - Beta               pytest (>=6.0.1,<7.0.0)
+   :pypi:`pytest-markdown-docs`                     Run markdown code fences through pytest                                                                                                                                                                   Mar 09, 2023    N/A                    N/A
+   :pypi:`pytest-marker-bugzilla`                   py.test bugzilla integration plugin, using markers                                                                                                                                                        Jan 09, 2020    N/A                    N/A
+   :pypi:`pytest-markers-presence`                  A simple plugin to detect missed pytest tags and markers"                                                                                                                                                 Feb 04, 2021    4 - Beta               pytest (>=6.0)
+   :pypi:`pytest-markfiltration`                    UNKNOWN                                                                                                                                                                                                   Nov 08, 2011    3 - Alpha              N/A
+   :pypi:`pytest-mark-no-py3`                       pytest plugin and bowler codemod to help migrate tests to Python 3                                                                                                                                        May 17, 2019    N/A                    pytest
+   :pypi:`pytest-marks`                             UNKNOWN                                                                                                                                                                                                   Nov 23, 2012    3 - Alpha              N/A
+   :pypi:`pytest-matcher`                           Match test output against patterns stored in files                                                                                                                                                        Dec 10, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-match-skip`                        Skip matching marks. Matches partial marks using wildcards.                                                                                                                                               May 15, 2019    4 - Beta               pytest (>=4.4.1)
+   :pypi:`pytest-mat-report`                        this is report                                                                                                                                                                                            Jan 20, 2021    N/A                    N/A
+   :pypi:`pytest-matrix`                            Provide tools for generating tests from combinations of fixtures.                                                                                                                                         Jun 24, 2020    5 - Production/Stable  pytest (>=5.4.3,<6.0.0)
+   :pypi:`pytest-maybe-context`                     Simplify tests with warning and exception cases.                                                                                                                                                          Apr 16, 2023    N/A                    pytest (>=7,<8)
+   :pypi:`pytest-maybe-raises`                      Pytest fixture for optional exception testing.                                                                                                                                                            May 27, 2022    N/A                    pytest ; extra == 'dev'
+   :pypi:`pytest-mccabe`                            pytest plugin to run the mccabe code complexity checker.                                                                                                                                                  Jul 22, 2020    3 - Alpha              pytest (>=5.4.0)
+   :pypi:`pytest-md`                                Plugin for generating Markdown reports for pytest results                                                                                                                                                 Jul 11, 2019    3 - Alpha              pytest (>=4.2.1)
+   :pypi:`pytest-md-report`                         A pytest plugin to make a test results report with Markdown table format.                                                                                                                                 May 28, 2023    4 - Beta               pytest (!=6.0.0,<8,>=3.3.2)
+   :pypi:`pytest-memlog`                            Log memory usage during tests                                                                                                                                                                             May 03, 2023    N/A                    pytest (>=7.3.0,<8.0.0)
+   :pypi:`pytest-memprof`                           Estimates memory consumption of test functions                                                                                                                                                            Mar 29, 2019    4 - Beta               N/A
+   :pypi:`pytest-memray`                            A simple plugin to use with pytest                                                                                                                                                                        Jun 06, 2023    N/A                    pytest>=7.2
+   :pypi:`pytest-menu`                              A pytest plugin for console based interactive test selection just after the collection phase                                                                                                              Oct 04, 2017    3 - Alpha              pytest (>=2.4.2)
+   :pypi:`pytest-mercurial`                         pytest plugin to write integration tests for projects using Mercurial Python internals                                                                                                                    Nov 21, 2020    1 - Planning           N/A
+   :pypi:`pytest-mesh`                              pytest_mesh插件                                                                                                                                                                                           Aug 05, 2022    N/A                    pytest (==7.1.2)
+   :pypi:`pytest-message`                           Pytest plugin for sending report message of marked tests execution                                                                                                                                        Aug 04, 2022    N/A                    pytest (>=6.2.5)
+   :pypi:`pytest-messenger`                         Pytest to Slack reporting plugin                                                                                                                                                                          Nov 24, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-metadata`                          pytest plugin for test session metadata                                                                                                                                                                   May 27, 2023    5 - Production/Stable  pytest>=7.0.0
+   :pypi:`pytest-metrics`                           Custom metrics report for pytest                                                                                                                                                                          Apr 04, 2020    N/A                    pytest
+   :pypi:`pytest-mh`                                Pytest multihost plugin                                                                                                                                                                                   Jun 08, 2023    N/A                    pytest
+   :pypi:`pytest-mimesis`                           Mimesis integration with the pytest test runner                                                                                                                                                           Mar 21, 2020    5 - Production/Stable  pytest (>=4.2)
+   :pypi:`pytest-minecraft`                         A pytest plugin for running tests against Minecraft releases                                                                                                                                              Apr 06, 2022    N/A                    pytest (>=6.0.1)
+   :pypi:`pytest-mini`                              A plugin to test mp                                                                                                                                                                                       Feb 06, 2023    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-missing-fixtures`                  Pytest plugin that creates missing fixtures                                                                                                                                                               Oct 14, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-ml`                                Test your machine learning!                                                                                                                                                                               May 04, 2019    4 - Beta               N/A
+   :pypi:`pytest-mocha`                             pytest plugin to display test execution output like a mochajs                                                                                                                                             Apr 02, 2020    4 - Beta               pytest (>=5.4.0)
+   :pypi:`pytest-mock`                              Thin-wrapper around the mock package for easier use with pytest                                                                                                                                           Jun 15, 2023    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-mock-api`                          A mock API server with configurable routes and responses available as a fixture.                                                                                                                          Feb 13, 2019    1 - Planning           pytest (>=4.0.0)
+   :pypi:`pytest-mock-generator`                    A pytest fixture wrapper for https://pypi.org/project/mock-generator                                                                                                                                      May 16, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-mock-helper`                       Help you mock HTTP call and generate mock code                                                                                                                                                            Jan 24, 2018    N/A                    pytest
+   :pypi:`pytest-mockito`                           Base fixtures for mockito                                                                                                                                                                                 Jul 11, 2018    4 - Beta               N/A
+   :pypi:`pytest-mockredis`                         An in-memory mock of a Redis server that runs in a separate thread. This is to be used for unit-tests that require a Redis database.                                                                      Jan 02, 2018    2 - Pre-Alpha          N/A
+   :pypi:`pytest-mock-resources`                    A pytest plugin for easily instantiating reproducible mock resources.                                                                                                                                     Jun 09, 2023    N/A                    pytest (>=1.0)
+   :pypi:`pytest-mock-server`                       Mock server plugin for pytest                                                                                                                                                                             Jan 09, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-mockservers`                       A set of fixtures to test your requests to HTTP/UDP servers                                                                                                                                               Mar 31, 2020    N/A                    pytest (>=4.3.0)
+   :pypi:`pytest-mocktcp`                           A pytest plugin for testing TCP clients                                                                                                                                                                   Oct 11, 2022    N/A                    pytest
+   :pypi:`pytest-modified-env`                      Pytest plugin to fail a test if it leaves modified \`os.environ\` afterwards.                                                                                                                             Jan 29, 2022    4 - Beta               N/A
+   :pypi:`pytest-modifyjunit`                       Utility for adding additional properties to junit xml for IDM QE                                                                                                                                          Jan 10, 2019    N/A                    N/A
+   :pypi:`pytest-modifyscope`                       pytest plugin to modify fixture scope                                                                                                                                                                     Apr 12, 2020    N/A                    pytest
+   :pypi:`pytest-molecule`                          PyTest Molecule Plugin :: discover and run molecule tests                                                                                                                                                 Mar 29, 2022    5 - Production/Stable  pytest (>=7.0.0)
+   :pypi:`pytest-mongo`                             MongoDB process and client fixtures plugin for Pytest.                                                                                                                                                    Jun 07, 2021    5 - Production/Stable  pytest
+   :pypi:`pytest-mongodb`                           pytest plugin for MongoDB fixtures                                                                                                                                                                        May 16, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-monitor`                           Pytest plugin for analyzing resource usage.                                                                                                                                                               Oct 22, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-monkeyplus`                        pytest's monkeypatch subclass with extra functionalities                                                                                                                                                  Sep 18, 2012    5 - Production/Stable  N/A
+   :pypi:`pytest-monkeytype`                        pytest-monkeytype: Generate Monkeytype annotations from your pytest tests.                                                                                                                                Jul 29, 2020    4 - Beta               N/A
+   :pypi:`pytest-moto`                              Fixtures for integration tests of AWS services,uses moto mocking library.                                                                                                                                 Aug 28, 2015    1 - Planning           N/A
+   :pypi:`pytest-motor`                             A pytest plugin for motor, the non-blocking MongoDB driver.                                                                                                                                               Jul 21, 2021    3 - Alpha              pytest
+   :pypi:`pytest-mp`                                A test batcher for multiprocessed Pytest runs                                                                                                                                                             May 23, 2018    4 - Beta               pytest
+   :pypi:`pytest-mpi`                               pytest plugin to collect information from tests                                                                                                                                                           Jan 08, 2022    3 - Alpha              pytest
+   :pypi:`pytest-mpiexec`                           pytest plugin for running individual tests with mpiexec                                                                                                                                                   Apr 13, 2023    3 - Alpha              pytest
+   :pypi:`pytest-mpl`                               pytest plugin to help with testing figures output from Matplotlib                                                                                                                                         Jul 23, 2022    4 - Beta               pytest
+   :pypi:`pytest-mproc`                             low-startup-overhead, scalable, distributed-testing pytest plugin                                                                                                                                         Nov 15, 2022    4 - Beta               pytest (>=6)
+   :pypi:`pytest-mqtt`                              pytest-mqtt supports testing systems based on MQTT                                                                                                                                                        Mar 15, 2023    4 - Beta               pytest (<8) ; extra == 'test'
+   :pypi:`pytest-multihost`                         Utility for writing multi-host tests for pytest                                                                                                                                                           Apr 07, 2020    4 - Beta               N/A
+   :pypi:`pytest-multilog`                          Multi-process logs handling and other helpers for pytest                                                                                                                                                  Jan 17, 2023    N/A                    pytest
+   :pypi:`pytest-multithreading`                    a pytest plugin for th and concurrent testing                                                                                                                                                             Dec 07, 2022    N/A                    N/A
+   :pypi:`pytest-multithreading-allure`             pytest_multithreading_allure                                                                                                                                                                              Nov 25, 2022    N/A                    N/A
+   :pypi:`pytest-mutagen`                           Add the mutation testing feature to pytest                                                                                                                                                                Jul 24, 2020    N/A                    pytest (>=5.4)
+   :pypi:`pytest-mypy`                              Mypy static type checker plugin for Pytest                                                                                                                                                                Dec 18, 2022    4 - Beta               pytest (>=6.2) ; python_version >= "3.10"
+   :pypi:`pytest-mypyd`                             Mypy static type checker plugin for Pytest                                                                                                                                                                Aug 20, 2019    4 - Beta               pytest (<4.7,>=2.8) ; python_version < "3.5"
+   :pypi:`pytest-mypy-plugins`                      pytest plugin for writing tests for mypy plugins                                                                                                                                                          May 05, 2023    4 - Beta               pytest (>=6.2.0)
+   :pypi:`pytest-mypy-plugins-shim`                 Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy.                                                                                                           Apr 12, 2021    N/A                    pytest>=6.0.0
+   :pypi:`pytest-mypy-testing`                      Pytest plugin to check mypy output.                                                                                                                                                                       Feb 25, 2023    N/A                    pytest>=7,<8
+   :pypi:`pytest-mysql`                             MySQL process and client fixtures for pytest                                                                                                                                                              Mar 27, 2023    5 - Production/Stable  pytest (>=6.2)
+   :pypi:`pytest-needle`                            pytest plugin for visual testing websites using selenium                                                                                                                                                  Dec 10, 2018    4 - Beta               pytest (<5.0.0,>=3.0.0)
+   :pypi:`pytest-neo`                               pytest-neo is a plugin for pytest that shows tests like screen of Matrix.                                                                                                                                 Jan 08, 2022    3 - Alpha              pytest (>=6.2.0)
+   :pypi:`pytest-netdut`                            "Automated software testing for switches using pytest"                                                                                                                                                    Jun 05, 2023    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-network`                           A simple plugin to disable network on socket level.                                                                                                                                                       May 07, 2020    N/A                    N/A
+   :pypi:`pytest-network-endpoints`                 Network endpoints plugin for pytest                                                                                                                                                                       Mar 06, 2022    N/A                    pytest
+   :pypi:`pytest-never-sleep`                       pytest plugin helps to avoid adding tests without mock \`time.sleep\`                                                                                                                                     May 05, 2021    3 - Alpha              pytest (>=3.5.1)
+   :pypi:`pytest-nginx`                             nginx fixture for pytest                                                                                                                                                                                  Aug 12, 2017    5 - Production/Stable  N/A
+   :pypi:`pytest-nginx-iplweb`                      nginx fixture for pytest - iplweb temporary fork                                                                                                                                                          Mar 01, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-ngrok`                                                                                                                                                                                                                                       Jan 20, 2022    3 - Alpha              pytest
+   :pypi:`pytest-ngsfixtures`                       pytest ngs fixtures                                                                                                                                                                                       Sep 06, 2019    2 - Pre-Alpha          pytest (>=5.0.0)
+   :pypi:`pytest-nhsd-apim`                         Pytest plugin accessing NHSDigital's APIM proxies                                                                                                                                                         Jun 07, 2023    N/A                    pytest (==6.2.5)
+   :pypi:`pytest-nice`                              A pytest plugin that alerts user of failed test cases with screen notifications                                                                                                                           May 04, 2019    4 - Beta               pytest
+   :pypi:`pytest-nice-parametrize`                  A small snippet for nicer PyTest's Parametrize                                                                                                                                                            Apr 17, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-nlcov`                             Pytest plugin to get the coverage of the new lines (based on git diff) only                                                                                                                               Jul 07, 2021    N/A                    N/A
+   :pypi:`pytest-nocustom`                          Run all tests without custom markers                                                                                                                                                                      Jul 07, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-nodev`                             Test-driven source code search for Python.                                                                                                                                                                Jul 21, 2016    4 - Beta               pytest (>=2.8.1)
+   :pypi:`pytest-nogarbage`                         Ensure a test produces no garbage                                                                                                                                                                         Aug 29, 2021    5 - Production/Stable  pytest (>=4.6.0)
+   :pypi:`pytest-notice`                            Send pytest execution result email                                                                                                                                                                        Nov 05, 2020    N/A                    N/A
+   :pypi:`pytest-notification`                      A pytest plugin for sending a desktop notification and playing a sound upon completion of tests                                                                                                           Jun 19, 2020    N/A                    pytest (>=4)
+   :pypi:`pytest-notifier`                          A pytest plugin to notify test result                                                                                                                                                                     Jun 12, 2020    3 - Alpha              pytest
+   :pypi:`pytest-notimplemented`                    Pytest markers for not implemented features and tests.                                                                                                                                                    Aug 27, 2019    N/A                    pytest (>=5.1,<6.0)
+   :pypi:`pytest-notion`                            A PyTest Reporter to send test runs to Notion.so                                                                                                                                                          Aug 07, 2019    N/A                    N/A
+   :pypi:`pytest-nunit`                             A pytest plugin for generating NUnit3 test result XML output                                                                                                                                              Oct 20, 2022    5 - Production/Stable  pytest (>=4.6.0)
+   :pypi:`pytest-oar`                               PyTest plugin for the OAR testing framework                                                                                                                                                               May 02, 2023    N/A                    pytest>=6.0.1
+   :pypi:`pytest-object-getter`                     Import any object from a 3rd party module while mocking its namespace on demand.                                                                                                                          Jul 31, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-ochrus`                            pytest results data-base and HTML reporter                                                                                                                                                                Feb 21, 2018    4 - Beta               N/A
+   :pypi:`pytest-odoo`                              py.test plugin to run Odoo tests                                                                                                                                                                          Nov 17, 2022    4 - Beta               pytest (>=7.2.0)
+   :pypi:`pytest-odoo-fixtures`                     Project description                                                                                                                                                                                       Jun 25, 2019    N/A                    N/A
+   :pypi:`pytest-oerp`                              pytest plugin to test OpenERP modules                                                                                                                                                                     Feb 28, 2012    3 - Alpha              N/A
+   :pypi:`pytest-offline`                                                                                                                                                                                                                                     Mar 09, 2023    1 - Planning           pytest (>=7.0.0,<8.0.0)
+   :pypi:`pytest-ogsm-plugin`                       针对特定项目定制化插件,优化了pytest报告展示方式,并添加了项目所需特定参数                                                                                                                                 May 16, 2023    N/A                    N/A
+   :pypi:`pytest-ok`                                The ultimate pytest output plugin                                                                                                                                                                         Apr 01, 2019    4 - Beta               N/A
+   :pypi:`pytest-only`                              Use @pytest.mark.only to run a single test                                                                                                                                                                Jun 14, 2022    5 - Production/Stable  pytest (<7.1); python_version <= "3.6"
+   :pypi:`pytest-oot`                               Run object-oriented tests in a simple format                                                                                                                                                              Sep 18, 2016    4 - Beta               N/A
+   :pypi:`pytest-openfiles`                         Pytest plugin for detecting inadvertent open file handles                                                                                                                                                 Apr 16, 2020    3 - Alpha              pytest (>=4.6)
+   :pypi:`pytest-opentelemetry`                     A pytest plugin for instrumenting test runs via OpenTelemetry                                                                                                                                             Mar 15, 2023    N/A                    pytest
+   :pypi:`pytest-opentmi`                           pytest plugin for publish results to opentmi                                                                                                                                                              Jun 02, 2022    5 - Production/Stable  pytest (>=5.0)
+   :pypi:`pytest-operator`                          Fixtures for Operators                                                                                                                                                                                    Sep 28, 2022    N/A                    pytest
+   :pypi:`pytest-optional`                          include/exclude values of fixtures in pytest                                                                                                                                                              Oct 07, 2015    N/A                    N/A
+   :pypi:`pytest-optional-tests`                    Easy declaration of optional tests (i.e., that are not run by default)                                                                                                                                    Jul 09, 2019    4 - Beta               pytest (>=4.5.0)
+   :pypi:`pytest-orchestration`                     A pytest plugin for orchestrating tests                                                                                                                                                                   Jul 18, 2019    N/A                    N/A
+   :pypi:`pytest-order`                             pytest plugin to run your tests in a specific order                                                                                                                                                       Mar 10, 2023    4 - Beta               pytest (>=5.0) ; python_version < "3.10"
+   :pypi:`pytest-ordering`                          pytest plugin to run your tests in a specific order                                                                                                                                                       Nov 14, 2018    4 - Beta               pytest
+   :pypi:`pytest-order-modify`                      新增run_marker 来自定义用例的执行顺序                                                                                                                                                                     Nov 04, 2022    N/A                    N/A
+   :pypi:`pytest-osxnotify`                         OS X notifications for py.test results.                                                                                                                                                                   May 15, 2015    N/A                    N/A
+   :pypi:`pytest-otel`                              pytest-otel report OpenTelemetry traces about test executed                                                                                                                                               Jan 18, 2023    N/A                    N/A
+   :pypi:`pytest-override-env-var`                  Pytest mark to override a value of an environment variable.                                                                                                                                               Feb 25, 2023    N/A                    N/A
+   :pypi:`pytest-owner`                             Add owner mark for tests                                                                                                                                                                                  Apr 25, 2022    N/A                    N/A
+   :pypi:`pytest-pact`                              A simple plugin to use with pytest                                                                                                                                                                        Jan 07, 2019    4 - Beta               N/A
+   :pypi:`pytest-pahrametahrize`                    Parametrize your tests with a Boston accent.                                                                                                                                                              Nov 24, 2021    4 - Beta               pytest (>=6.0,<7.0)
+   :pypi:`pytest-parallel`                          a pytest plugin for parallel and concurrent testing                                                                                                                                                       Oct 10, 2021    3 - Alpha              pytest (>=3.0.0)
+   :pypi:`pytest-parallel-39`                       a pytest plugin for parallel and concurrent testing                                                                                                                                                       Jul 12, 2021    3 - Alpha              pytest (>=3.0.0)
+   :pypi:`pytest-parallelize-tests`                 pytest plugin that parallelizes test execution across multiple hosts                                                                                                                                      Jan 27, 2023    4 - Beta               N/A
+   :pypi:`pytest-param`                             pytest plugin to test all, first, last or random params                                                                                                                                                   Sep 11, 2016    4 - Beta               pytest (>=2.6.0)
+   :pypi:`pytest-paramark`                          Configure pytest fixtures using a combination of"parametrize" and markers                                                                                                                                 Jan 10, 2020    4 - Beta               pytest (>=4.5.0)
+   :pypi:`pytest-parametrization`                   Simpler PyTest parametrization                                                                                                                                                                            May 22, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-parametrize-cases`                 A more user-friendly way to write parametrized tests.                                                                                                                                                     Mar 13, 2022    N/A                    pytest (>=6.1.2)
+   :pypi:`pytest-parametrized`                      Pytest decorator for parametrizing tests with default iterables.                                                                                                                                          Sep 13, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-parametrize-suite`                 A simple pytest extension for creating a named test suite.                                                                                                                                                Jan 19, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-parawtf`                           Finally spell paramete?ri[sz]e correctly                                                                                                                                                                  Dec 03, 2018    4 - Beta               pytest (>=3.6.0)
+   :pypi:`pytest-pass`                              Check out https://github.com/elilutsky/pytest-pass                                                                                                                                                        Dec 04, 2019    N/A                    N/A
+   :pypi:`pytest-passrunner`                        Pytest plugin providing the 'run_on_pass' marker                                                                                                                                                          Feb 10, 2021    5 - Production/Stable  pytest (>=4.6.0)
+   :pypi:`pytest-paste-config`                      Allow setting the path to a paste config file                                                                                                                                                             Sep 18, 2013    3 - Alpha              N/A
+   :pypi:`pytest-patch`                             An automagic \`patch\` fixture that can patch objects directly or by name.                                                                                                                                Apr 29, 2023    3 - Alpha              pytest (>=7.0.0)
+   :pypi:`pytest-patches`                           A contextmanager pytest fixture for handling multiple mock patches                                                                                                                                        Aug 30, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-pdb`                               pytest plugin which adds pdb helper commands related to pytest.                                                                                                                                           Jul 31, 2018    N/A                    N/A
+   :pypi:`pytest-peach`                             pytest plugin for fuzzing with Peach API Security                                                                                                                                                         Apr 12, 2019    4 - Beta               pytest (>=2.8.7)
+   :pypi:`pytest-pep257`                            py.test plugin for pep257                                                                                                                                                                                 Jul 09, 2016    N/A                    N/A
+   :pypi:`pytest-pep8`                              pytest plugin to check PEP8 requirements                                                                                                                                                                  Apr 27, 2014    N/A                    N/A
+   :pypi:`pytest-percent`                           Change the exit code of pytest test sessions when a required percent of tests pass.                                                                                                                       May 21, 2020    N/A                    pytest (>=5.2.0)
+   :pypi:`pytest-perf`                              Run performance tests against the mainline code.                                                                                                                                                          Jun 02, 2023    5 - Production/Stable  pytest (>=6) ; extra == 'testing'
+   :pypi:`pytest-performance`                       A simple plugin to ensure the execution of critical sections of code has not been impacted                                                                                                                Sep 11, 2020    5 - Production/Stable  pytest (>=3.7.0)
+   :pypi:`pytest-persistence`                       Pytest tool for persistent objects                                                                                                                                                                        Jun 14, 2023    N/A                    N/A
+   :pypi:`pytest-pg`                                A tiny plugin for pytest which runs PostgreSQL in Docker                                                                                                                                                  May 04, 2023    5 - Production/Stable  pytest (>=6.0.0)
+   :pypi:`pytest-pgsql`                             Pytest plugins and helpers for tests using a Postgres database.                                                                                                                                           May 13, 2020    5 - Production/Stable  pytest (>=3.0.0)
+   :pypi:`pytest-phmdoctest`                        pytest plugin to test Python examples in Markdown using phmdoctest.                                                                                                                                       Apr 15, 2022    4 - Beta               pytest (>=5.4.3)
+   :pypi:`pytest-picked`                            Run the tests related to the changed files                                                                                                                                                                Dec 23, 2020    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-pigeonhole`                                                                                                                                                                                                                                  Jun 25, 2018    5 - Production/Stable  pytest (>=3.4)
+   :pypi:`pytest-pikachu`                           Show surprise when tests are passing                                                                                                                                                                      Aug 05, 2021    5 - Production/Stable  pytest
+   :pypi:`pytest-pilot`                             Slice in your test base thanks to powerful markers.                                                                                                                                                       Oct 09, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-pingguo-pytest-plugin`             pingguo test                                                                                                                                                                                              Oct 26, 2022    4 - Beta               N/A
+   :pypi:`pytest-pings`                             🦊 The pytest plugin for Firefox Telemetry 📊                                                                                                                                                             Jun 29, 2019    3 - Alpha              pytest (>=5.0.0)
+   :pypi:`pytest-pinned`                            A simple pytest plugin for pinning tests                                                                                                                                                                  Sep 17, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-pinpoint`                          A pytest plugin which runs SBFL algorithms to detect faults.                                                                                                                                              Sep 25, 2020    N/A                    pytest (>=4.4.0)
+   :pypi:`pytest-pipeline`                          Pytest plugin for functional testing of data analysispipelines                                                                                                                                            Jan 24, 2017    3 - Alpha              N/A
+   :pypi:`pytest-platform-markers`                  Markers for pytest to skip tests on specific platforms                                                                                                                                                    Sep 09, 2019    4 - Beta               pytest (>=3.6.0)
+   :pypi:`pytest-play`                              pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files                                                                                         Jun 12, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-playbook`                          Pytest plugin for reading playbooks.                                                                                                                                                                      Jan 21, 2021    3 - Alpha              pytest (>=6.1.2,<7.0.0)
+   :pypi:`pytest-playwright`                        A pytest wrapper with fixtures for Playwright to automate web browsers                                                                                                                                    Apr 24, 2023    N/A                    pytest (<8.0.0,>=6.2.4)
+   :pypi:`pytest-playwrights`                       A pytest wrapper with fixtures for Playwright to automate web browsers                                                                                                                                    Dec 02, 2021    N/A                    N/A
+   :pypi:`pytest-playwright-snapshot`               A pytest wrapper for snapshot testing with playwright                                                                                                                                                     Aug 19, 2021    N/A                    N/A
+   :pypi:`pytest-playwright-visual`                 A pytest fixture for visual testing with Playwright                                                                                                                                                       Apr 28, 2022    N/A                    N/A
+   :pypi:`pytest-plone`                             Pytest plugin to test Plone addons                                                                                                                                                                        Jan 05, 2023    3 - Alpha              pytest
+   :pypi:`pytest-plt`                               Fixtures for quickly making Matplotlib plots in tests                                                                                                                                                     Aug 17, 2020    5 - Production/Stable  pytest
+   :pypi:`pytest-plugin-helpers`                    A plugin to help developing and testing other plugins                                                                                                                                                     Nov 23, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-plus`                              PyTest Plus Plugin :: extends pytest functionality                                                                                                                                                        Dec 24, 2022    5 - Production/Stable  pytest (>=6.0.1)
+   :pypi:`pytest-pmisc`                                                                                                                                                                                                                                       Mar 21, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-pointers`                          Pytest plugin to define functions you test with special marks for better navigation and reports                                                                                                           Dec 26, 2022    N/A                    N/A
+   :pypi:`pytest-pokie`                             Pokie plugin for pytest                                                                                                                                                                                   May 22, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-polarion-cfme`                     pytest plugin for collecting test cases and recording test results                                                                                                                                        Nov 13, 2017    3 - Alpha              N/A
+   :pypi:`pytest-polarion-collect`                  pytest plugin for collecting polarion test cases data                                                                                                                                                     Jun 18, 2020    3 - Alpha              pytest
+   :pypi:`pytest-polecat`                           Provides Polecat pytest fixtures                                                                                                                                                                          Aug 12, 2019    4 - Beta               N/A
+   :pypi:`pytest-ponyorm`                           PonyORM in Pytest                                                                                                                                                                                         Oct 31, 2018    N/A                    pytest (>=3.1.1)
+   :pypi:`pytest-poo`                               Visualize your crappy tests                                                                                                                                                                               Mar 25, 2021    5 - Production/Stable  pytest (>=2.3.4)
+   :pypi:`pytest-poo-fail`                          Visualize your failed tests with poo                                                                                                                                                                      Feb 12, 2015    5 - Production/Stable  N/A
+   :pypi:`pytest-pop`                               A pytest plugin to help with testing pop projects                                                                                                                                                         May 09, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-portion`                           Select a portion of the collected tests                                                                                                                                                                   Jan 28, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-postgres`                          Run PostgreSQL in Docker container in Pytest.                                                                                                                                                             Mar 22, 2020    N/A                    pytest
+   :pypi:`pytest-postgresql`                        Postgresql fixtures and fixture factories for Pytest.                                                                                                                                                     May 20, 2023    5 - Production/Stable  pytest (>=6.2)
+   :pypi:`pytest-pot`                               A package for enhancing pytest                                                                                                                                                                            Nov 20, 2022    N/A                    N/A
+   :pypi:`pytest-power`                             pytest plugin with powerful fixtures                                                                                                                                                                      Dec 31, 2020    N/A                    pytest (>=5.4)
+   :pypi:`pytest-prefer-nested-dup-tests`           A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages.                                                                                                      Apr 27, 2022    4 - Beta               pytest (>=7.1.1,<8.0.0)
+   :pypi:`pytest-pretty`                            pytest plugin for printing summary data as I want it                                                                                                                                                      Apr 05, 2023    5 - Production/Stable  pytest>=7
+   :pypi:`pytest-pretty-terminal`                   pytest plugin for generating prettier terminal output                                                                                                                                                     Jan 31, 2022    N/A                    pytest (>=3.4.1)
+   :pypi:`pytest-pride`                             Minitest-style test colors                                                                                                                                                                                Apr 02, 2016    3 - Alpha              N/A
+   :pypi:`pytest-print`                             pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout)                                                                               Jun 16, 2023    5 - Production/Stable  pytest>=7.3.2
+   :pypi:`pytest-profiles`                          pytest plugin for configuration profiles                                                                                                                                                                  Dec 09, 2021    4 - Beta               pytest (>=3.7.0)
+   :pypi:`pytest-profiling`                         Profiling plugin for py.test                                                                                                                                                                              May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-progress`                          pytest plugin for instant test progress status                                                                                                                                                            Jan 31, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-prometheus`                        Report test pass / failures to a Prometheus PushGateway                                                                                                                                                   Oct 03, 2017    N/A                    N/A
+   :pypi:`pytest-prometheus-pushgateway`            Pytest report plugin for Zulip                                                                                                                                                                            Sep 27, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-prosper`                           Test helpers for Prosper projects                                                                                                                                                                         Sep 24, 2018    N/A                    N/A
+   :pypi:`pytest-pspec`                             A rspec format reporter for Python ptest                                                                                                                                                                  Jun 02, 2020    4 - Beta               pytest (>=3.0.0)
+   :pypi:`pytest-psqlgraph`                         pytest plugin for testing applications that use psqlgraph                                                                                                                                                 Oct 19, 2021    4 - Beta               pytest (>=6.0)
+   :pypi:`pytest-ptera`                             Use ptera probes in tests                                                                                                                                                                                 Mar 01, 2022    N/A                    pytest (>=6.2.4,<7.0.0)
+   :pypi:`pytest-pudb`                              Pytest PuDB debugger integration                                                                                                                                                                          Oct 25, 2018    3 - Alpha              pytest (>=2.0)
+   :pypi:`pytest-pumpkin-spice`                     A pytest plugin that makes your test reporting pumpkin-spiced                                                                                                                                             Sep 18, 2022    4 - Beta               N/A
+   :pypi:`pytest-purkinje`                          py.test plugin for purkinje test runner                                                                                                                                                                   Oct 28, 2017    2 - Pre-Alpha          N/A
+   :pypi:`pytest-pusher`                            pytest plugin for push report to minio                                                                                                                                                                    Jan 06, 2023    5 - Production/Stable  pytest (>=3.6)
+   :pypi:`pytest-py125`                                                                                                                                                                                                                                       Dec 03, 2022    N/A                    N/A
+   :pypi:`pytest-pycharm`                           Plugin for py.test to enter PyCharm debugger on uncaught exceptions                                                                                                                                       Aug 13, 2020    5 - Production/Stable  pytest (>=2.3)
+   :pypi:`pytest-pycodestyle`                       pytest plugin to run pycodestyle                                                                                                                                                                          Oct 28, 2022    3 - Alpha              N/A
+   :pypi:`pytest-pydev`                             py.test plugin to connect to a remote debug server with PyDev or PyCharm.                                                                                                                                 Nov 15, 2017    3 - Alpha              N/A
+   :pypi:`pytest-pydocstyle`                        pytest plugin to run pydocstyle                                                                                                                                                                           Jan 05, 2023    3 - Alpha              N/A
+   :pypi:`pytest-pylint`                            pytest plugin to check source code with pylint                                                                                                                                                            Sep 10, 2022    5 - Production/Stable  pytest (>=5.4)
+   :pypi:`pytest-pymysql-autorecord`                Record PyMySQL queries and mock with the stored data.                                                                                                                                                     Sep 02, 2022    N/A                    N/A
+   :pypi:`pytest-pyodide`                           "Pytest plugin for testing applications that use Pyodide"                                                                                                                                                 Jun 11, 2023    N/A                    pytest
+   :pypi:`pytest-pypi`                              Easily test your HTTP library against a local copy of pypi                                                                                                                                                Mar 04, 2018    3 - Alpha              N/A
+   :pypi:`pytest-pypom-navigation`                  Core engine for cookiecutter-qa and pytest-play packages                                                                                                                                                  Feb 18, 2019    4 - Beta               pytest (>=3.0.7)
+   :pypi:`pytest-pyppeteer`                         A plugin to run pyppeteer in pytest                                                                                                                                                                       Apr 28, 2022    N/A                    pytest (>=6.2.5,<7.0.0)
+   :pypi:`pytest-pyq`                               Pytest fixture "q" for pyq                                                                                                                                                                                Mar 10, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-pyramid`                           pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite                                                                                                                Dec 13, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-pyramid-server`                    Pyramid server fixture for py.test                                                                                                                                                                        May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-pyreport`                          PyReport is a lightweight reporting plugin for Pytest that provides concise HTML report                                                                                                                   May 08, 2023    N/A                    pytest (>=7.3.1)
+   :pypi:`pytest-pyright`                           Pytest plugin for type checking code with Pyright                                                                                                                                                         Nov 20, 2022    4 - Beta               pytest (>=7.0.0)
+   :pypi:`pytest-pyspec`                            A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it".  Mar 12, 2023    5 - Production/Stable  pytest (>=7.2.1,<8.0.0)
+   :pypi:`pytest-pystack`                           Plugin to run pystack after a timeout for a test suite.                                                                                                                                                   May 07, 2023    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-pytestrail`                        Pytest plugin for interaction with TestRail                                                                                                                                                               Aug 27, 2020    4 - Beta               pytest (>=3.8.0)
+   :pypi:`pytest-pythonpath`                        pytest plugin for adding to the PYTHONPATH from command line or configs.                                                                                                                                  Feb 10, 2022    5 - Production/Stable  pytest (<7,>=2.5.2)
+   :pypi:`pytest-pytorch`                           pytest plugin for a better developer experience when working with the PyTorch test suite                                                                                                                  May 25, 2021    4 - Beta               pytest
+   :pypi:`pytest-pyvista`                           Pytest-pyvista package                                                                                                                                                                                    Mar 19, 2023    4 - Beta               pytest>=3.5.0
+   :pypi:`pytest-qaseio`                            Pytest plugin for Qase.io integration                                                                                                                                                                     May 11, 2023    4 - Beta               pytest (>=7.2.2,<8.0.0)
+   :pypi:`pytest-qasync`                            Pytest support for qasync.                                                                                                                                                                                Jul 12, 2021    4 - Beta               pytest (>=5.4.0)
+   :pypi:`pytest-qatouch`                           Pytest plugin for uploading test results to your QA Touch Testrun.                                                                                                                                        Feb 14, 2023    4 - Beta               pytest (>=6.2.0)
+   :pypi:`pytest-qgis`                              A pytest plugin for testing QGIS python plugins                                                                                                                                                           Jun 09, 2023    5 - Production/Stable  pytest (>=6.2.5)
+   :pypi:`pytest-qml`                               Run QML Tests with pytest                                                                                                                                                                                 Dec 02, 2020    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-qr`                                pytest plugin to generate test result QR codes                                                                                                                                                            Nov 25, 2021    4 - Beta               N/A
+   :pypi:`pytest-qt`                                pytest support for PyQt and PySide applications                                                                                                                                                           Oct 25, 2022    5 - Production/Stable  pytest (>=3.0.0)
+   :pypi:`pytest-qt-app`                            QT app fixture for py.test                                                                                                                                                                                Dec 23, 2015    5 - Production/Stable  N/A
+   :pypi:`pytest-quarantine`                        A plugin for pytest to manage expected test failures                                                                                                                                                      Nov 24, 2019    5 - Production/Stable  pytest (>=4.6)
+   :pypi:`pytest-quickcheck`                        pytest plugin to generate random data inspired by QuickCheck                                                                                                                                              Nov 05, 2022    4 - Beta               pytest (>=4.0)
+   :pypi:`pytest-rabbitmq`                          RabbitMQ process and client fixtures for pytest                                                                                                                                                           Jun 16, 2023    5 - Production/Stable  pytest (>=6.2)
+   :pypi:`pytest-race`                              Race conditions tester for pytest                                                                                                                                                                         Jun 07, 2022    4 - Beta               N/A
+   :pypi:`pytest-rage`                              pytest plugin to implement PEP712                                                                                                                                                                         Oct 21, 2011    3 - Alpha              N/A
+   :pypi:`pytest-rail`                              pytest plugin for creating TestRail runs and adding results                                                                                                                                               May 02, 2022    N/A                    pytest (>=3.6)
+   :pypi:`pytest-railflow-testrail-reporter`        Generate json reports along with specified metadata defined in test markers.                                                                                                                              Jun 29, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-raises`                            An implementation of pytest.raises as a pytest.mark fixture                                                                                                                                               Apr 23, 2020    N/A                    pytest (>=3.2.2)
+   :pypi:`pytest-raisesregexp`                      Simple pytest plugin to look for regex in Exceptions                                                                                                                                                      Dec 18, 2015    N/A                    N/A
+   :pypi:`pytest-raisin`                            Plugin enabling the use of exception instances with pytest.raises                                                                                                                                         Feb 06, 2022    N/A                    pytest
+   :pypi:`pytest-random`                            py.test plugin to randomize tests                                                                                                                                                                         Apr 28, 2013    3 - Alpha              N/A
+   :pypi:`pytest-randomly`                          Pytest plugin to randomly order tests and control random.seed.                                                                                                                                            May 11, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-randomness`                        Pytest plugin about random seed management                                                                                                                                                                May 30, 2019    3 - Alpha              N/A
+   :pypi:`pytest-random-num`                        Randomise the order in which pytest tests are run with some control over the randomness                                                                                                                   Oct 19, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-random-order`                      Randomise the order in which pytest tests are run with some control over the randomness                                                                                                                   Dec 03, 2022    5 - Production/Stable  pytest (>=3.0.0)
+   :pypi:`pytest-readme`                            Test your README.md file                                                                                                                                                                                  Sep 02, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-reana`                             Pytest fixtures for REANA.                                                                                                                                                                                Dec 13, 2022    3 - Alpha              N/A
+   :pypi:`pytest-recorder`                          Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs.                                                                                                                      Mar 30, 2023    N/A                    N/A
+   :pypi:`pytest-recording`                         A pytest plugin that allows you recording of network interactions via VCR.py                                                                                                                              Feb 16, 2023    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-recordings`                        Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal                                                                                                     Aug 13, 2020    N/A                    N/A
+   :pypi:`pytest-redis`                             Redis fixtures and fixture factories for Pytest.                                                                                                                                                          Apr 19, 2023    5 - Production/Stable  pytest (>=6.2)
+   :pypi:`pytest-redislite`                         Pytest plugin for testing code using Redis                                                                                                                                                                Apr 05, 2022    4 - Beta               pytest
+   :pypi:`pytest-redmine`                           Pytest plugin for redmine                                                                                                                                                                                 Mar 19, 2018    1 - Planning           N/A
+   :pypi:`pytest-ref`                               A plugin to store reference files to ease regression testing                                                                                                                                              Nov 23, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-reference-formatter`               Conveniently run pytest with a dot-formatted test reference.                                                                                                                                              Oct 01, 2019    4 - Beta               N/A
+   :pypi:`pytest-regex`                             Select pytest tests with regular expressions                                                                                                                                                              May 29, 2023    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-regex-dependency`                  Management of Pytest dependencies via regex patterns                                                                                                                                                      Jun 12, 2022    N/A                    pytest
+   :pypi:`pytest-regressions`                       Easy to use fixtures to write regression tests.                                                                                                                                                           Jan 13, 2023    5 - Production/Stable  pytest (>=6.2.0)
+   :pypi:`pytest-regtest`                           pytest plugin for regression tests                                                                                                                                                                        Jul 08, 2022    N/A                    N/A
+   :pypi:`pytest-relative-order`                    a pytest plugin that sorts tests using "before" and "after" markers                                                                                                                                       May 17, 2021    4 - Beta               N/A
+   :pypi:`pytest-relaxed`                           Relaxed test discovery/organization for pytest                                                                                                                                                            May 23, 2023    5 - Production/Stable  pytest (>=7)
+   :pypi:`pytest-remfiles`                          Pytest plugin to create a temporary directory with remote files                                                                                                                                           Jul 01, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-remotedata`                        Pytest plugin for controlling remote data access.                                                                                                                                                         Dec 12, 2022    3 - Alpha              pytest (>=4.6)
+   :pypi:`pytest-remote-response`                   Pytest plugin for capturing and mocking connection requests.                                                                                                                                              Apr 26, 2023    5 - Production/Stable  pytest (>=4.6)
+   :pypi:`pytest-remove-stale-bytecode`             py.test plugin to remove stale byte code files.                                                                                                                                                           Mar 04, 2020    4 - Beta               pytest
+   :pypi:`pytest-reorder`                           Reorder tests depending on their paths and names.                                                                                                                                                         May 31, 2018    4 - Beta               pytest
+   :pypi:`pytest-repeat`                            pytest plugin for repeating tests                                                                                                                                                                         Oct 31, 2020    5 - Production/Stable  pytest (>=3.6)
+   :pypi:`pytest-replay`                            Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests                                                                                                    Jun 09, 2021    4 - Beta               pytest (>=3.0.0)
+   :pypi:`pytest-repo-health`                       A pytest plugin to report on repository standards conformance                                                                                                                                             Apr 17, 2023    3 - Alpha              pytest
+   :pypi:`pytest-report`                            Creates json report that is compatible with atom.io's linter message format                                                                                                                               May 11, 2016    4 - Beta               N/A
+   :pypi:`pytest-reporter`                          Generate Pytest reports with templates                                                                                                                                                                    Jul 22, 2021    4 - Beta               pytest
+   :pypi:`pytest-reporter-html1`                    A basic HTML report template for Pytest                                                                                                                                                                   Jun 05, 2023    4 - Beta               N/A
+   :pypi:`pytest-reporter-html-dots`                A basic HTML report for pytest using Jinja2 template engine.                                                                                                                                              Jan 22, 2023    N/A                    N/A
+   :pypi:`pytest-reportinfra`                       Pytest plugin for reportinfra                                                                                                                                                                             Aug 11, 2019    3 - Alpha              N/A
+   :pypi:`pytest-reporting`                         A plugin to report summarized results in a table format                                                                                                                                                   Oct 25, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-reportlog`                         Replacement for the --resultlog option, focused in simplicity and extensibility                                                                                                                           May 22, 2023    3 - Alpha              pytest
+   :pypi:`pytest-report-me`                         A pytest plugin to generate report.                                                                                                                                                                       Dec 31, 2020    N/A                    pytest
+   :pypi:`pytest-report-parameters`                 pytest plugin for adding tests' parameters to junit report                                                                                                                                                Jun 18, 2020    3 - Alpha              pytest (>=2.4.2)
+   :pypi:`pytest-reportportal`                      Agent for Reporting results of tests to the Report Portal                                                                                                                                                 Jun 08, 2023    N/A                    pytest (>=3.8.0)
+   :pypi:`pytest-reports`                           An interesting python package                                                                                                                                                                             Jun 07, 2023    N/A                    N/A
+   :pypi:`pytest-reqs`                              pytest plugin to check pinned requirements                                                                                                                                                                May 12, 2019    N/A                    pytest (>=2.4.2)
+   :pypi:`pytest-requests`                          A simple plugin to use with pytest                                                                                                                                                                        Jun 24, 2019    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-requestselapsed`                   collect and show http requests elapsed time                                                                                                                                                               Aug 14, 2022    N/A                    N/A
+   :pypi:`pytest-requests-futures`                  Pytest Plugin to Mock Requests Futures                                                                                                                                                                    Jul 06, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-requires`                          A pytest plugin to elegantly skip tests with optional requirements                                                                                                                                        Dec 21, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-reraise`                           Make multi-threaded pytest test cases fail when they should                                                                                                                                               Sep 20, 2022    5 - Production/Stable  pytest (>=4.6)
+   :pypi:`pytest-rerun`                             Re-run only changed files in specified branch                                                                                                                                                             Jul 08, 2019    N/A                    pytest (>=3.6)
+   :pypi:`pytest-rerunfailures`                     pytest plugin to re-run tests to eliminate flaky failures                                                                                                                                                 Mar 09, 2023    5 - Production/Stable  pytest (>=5.3)
+   :pypi:`pytest-rerunfailures-all-logs`            pytest plugin to re-run tests to eliminate flaky failures                                                                                                                                                 Mar 07, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-reserial`                          Pytest fixture for recording and replaying serial port traffic.                                                                                                                                           Apr 26, 2023    4 - Beta               pytest
+   :pypi:`pytest-resilient-circuits`                Resilient Circuits fixtures for PyTest                                                                                                                                                                    Jun 01, 2023    N/A                    pytest (~=4.6) ; python_version == "2.7"
+   :pypi:`pytest-resource`                          Load resource fixture plugin to use with pytest                                                                                                                                                           Nov 14, 2018    4 - Beta               N/A
+   :pypi:`pytest-resource-path`                     Provides path for uniform access to test resources in isolated directory                                                                                                                                  May 01, 2021    5 - Production/Stable  pytest (>=3.5.0)
+   :pypi:`pytest-resource-usage`                    Pytest plugin for reporting running time and peak memory usage                                                                                                                                            Nov 06, 2022    5 - Production/Stable  pytest>=7.0.0
+   :pypi:`pytest-responsemock`                      Simplified requests calls mocking for pytest                                                                                                                                                              Mar 10, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-responses`                         py.test integration for responses                                                                                                                                                                         Oct 11, 2022    N/A                    pytest (>=2.5)
+   :pypi:`pytest-rest-api`                                                                                                                                                                                                                                    Aug 08, 2022    N/A                    pytest (>=7.1.2,<8.0.0)
+   :pypi:`pytest-restrict`                          Pytest plugin to restrict the test types allowed                                                                                                                                                          Jun 16, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-result-log`                        Write the execution result of the case to the log                                                                                                                                                         Apr 17, 2023    N/A                    pytest>=7.2.0
+   :pypi:`pytest-result-sender`                                                                                                                                                                                                                               Apr 20, 2023    N/A                    pytest>=7.3.1
+   :pypi:`pytest-resume`                            A Pytest plugin to resuming from the last run test                                                                                                                                                        Apr 22, 2023    4 - Beta               pytest (>=7.0)
+   :pypi:`pytest-rethinkdb`                         A RethinkDB plugin for pytest.                                                                                                                                                                            Jul 24, 2016    4 - Beta               N/A
+   :pypi:`pytest-retry`                             Adds the ability to retry flaky tests in CI environments                                                                                                                                                  Aug 16, 2022    N/A                    pytest (>=7.0.0)
+   :pypi:`pytest-retry-class`                       A pytest plugin to rerun entire class on failure                                                                                                                                                          Mar 25, 2023    N/A                    pytest (>=5.3)
+   :pypi:`pytest-reusable-testcases`                                                                                                                                                                                                                          Apr 28, 2023    N/A                    N/A
+   :pypi:`pytest-reverse`                           Pytest plugin to reverse test order.                                                                                                                                                                      Jun 16, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-rich`                              Leverage rich for richer test session output                                                                                                                                                              Mar 03, 2022    4 - Beta               pytest (>=7.0)
+   :pypi:`pytest-rich-reporter`                     A pytest plugin using Rich for beautiful test result formatting.                                                                                                                                          Feb 17, 2022    1 - Planning           pytest (>=5.0.0)
+   :pypi:`pytest-richtrace`                                                                                                                                                                                                                                   Nov 05, 2022    N/A                    pytest (>=7.2.0,<8.0.0)
+   :pypi:`pytest-ringo`                             pytest plugin to test webapplications using the Ringo webframework                                                                                                                                        Sep 27, 2017    3 - Alpha              N/A
+   :pypi:`pytest-rmsis`                             Sycronise pytest results to Jira RMsis                                                                                                                                                                    Aug 10, 2022    N/A                    pytest (>=5.3.5)
+   :pypi:`pytest-rng`                               Fixtures for seeding tests and making randomness reproducible                                                                                                                                             Aug 08, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-roast`                             pytest plugin for ROAST configuration override and fixtures                                                                                                                                               Nov 09, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-rocketchat`                        Pytest to Rocket.Chat reporting plugin                                                                                                                                                                    Apr 18, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-rotest`                            Pytest integration with rotest                                                                                                                                                                            Sep 08, 2019    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-rpc`                               Extend py.test for RPC OpenStack testing.                                                                                                                                                                 Feb 22, 2019    4 - Beta               pytest (~=3.6)
+   :pypi:`pytest-rst`                               Test code from RST documents with pytest                                                                                                                                                                  Jan 26, 2023    N/A                    N/A
+   :pypi:`pytest-rt`                                pytest data collector plugin for Testgr                                                                                                                                                                   May 05, 2022    N/A                    N/A
+   :pypi:`pytest-rts`                               Coverage-based regression test selection (RTS) plugin for pytest                                                                                                                                          May 17, 2021    N/A                    pytest
+   :pypi:`pytest-ruff`                              pytest plugin to check ruff requirements.                                                                                                                                                                 Jun 08, 2023    4 - Beta               N/A
+   :pypi:`pytest-run-changed`                       Pytest plugin that runs changed tests only                                                                                                                                                                Apr 02, 2021    3 - Alpha              pytest
+   :pypi:`pytest-runfailed`                         implement a --failed option for pytest                                                                                                                                                                    Mar 24, 2016    N/A                    N/A
+   :pypi:`pytest-runner`                            Invoke py.test as distutils command with dependency resolution                                                                                                                                            Feb 25, 2022    5 - Production/Stable  pytest (>=6) ; extra == 'testing'
+   :pypi:`pytest-run-subprocess`                    Pytest Plugin for running and testing subprocesses.                                                                                                                                                       Nov 12, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-runtime-types`                     Checks type annotations on runtime while running tests.                                                                                                                                                   Feb 09, 2023    N/A                    pytest
+   :pypi:`pytest-runtime-xfail`                     Call runtime_xfail() to mark running test as xfail.                                                                                                                                                       Aug 26, 2021    N/A                    pytest>=5.0.0
+   :pypi:`pytest-runtime-yoyo`                      run case mark timeout                                                                                                                                                                                     Jun 12, 2023    N/A                    pytest (>=7.2.0)
+   :pypi:`pytest-ry-demo1`                          测试                                                                                                                                                                                                      Mar 26, 2023    N/A                    N/A
+   :pypi:`pytest-saccharin`                         pytest-saccharin is a updated fork of pytest-sugar, a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly).                              Oct 31, 2022    3 - Alpha              N/A
+   :pypi:`pytest-salt`                              Pytest Salt Plugin                                                                                                                                                                                        Jan 27, 2020    4 - Beta               N/A
+   :pypi:`pytest-salt-containers`                   A Pytest plugin that builds and creates docker containers                                                                                                                                                 Nov 09, 2016    4 - Beta               N/A
+   :pypi:`pytest-salt-factories`                    Pytest Salt Plugin                                                                                                                                                                                        Dec 15, 2022    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-salt-from-filenames`               Simple PyTest Plugin For Salt's Test Suite Specifically                                                                                                                                                   Jan 29, 2019    4 - Beta               pytest (>=4.1)
+   :pypi:`pytest-salt-runtests-bridge`              Simple PyTest Plugin For Salt's Test Suite Specifically                                                                                                                                                   Dec 05, 2019    4 - Beta               pytest (>=4.1)
+   :pypi:`pytest-sanic`                             a pytest plugin for Sanic                                                                                                                                                                                 Oct 25, 2021    N/A                    pytest (>=5.2)
+   :pypi:`pytest-sanity`                                                                                                                                                                                                                                      Dec 07, 2020    N/A                    N/A
+   :pypi:`pytest-sa-pg`                                                                                                                                                                                                                                       May 14, 2019    N/A                    N/A
+   :pypi:`pytest-sbase`                             A complete web automation framework for end-to-end testing.                                                                                                                                               Jun 13, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-scenario`                          pytest plugin for test scenarios                                                                                                                                                                          Feb 06, 2017    3 - Alpha              N/A
+   :pypi:`pytest-schedule`                          The job of test scheduling for humans.                                                                                                                                                                    Jan 07, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-schema`                            👍 Validate return values against a schema-like object in testing                                                                                                                                         Mar 14, 2022    5 - Production/Stable  pytest (>=3.5.0)
+   :pypi:`pytest-securestore`                       An encrypted password store for use within pytest cases                                                                                                                                                   Nov 08, 2021    4 - Beta               N/A
+   :pypi:`pytest-select`                            A pytest plugin which allows to (de-)select tests from a file.                                                                                                                                            Jan 18, 2019    3 - Alpha              pytest (>=3.0)
+   :pypi:`pytest-selenium`                          pytest plugin for Selenium                                                                                                                                                                                May 28, 2023    5 - Production/Stable  pytest>=6.0.0
+   :pypi:`pytest-seleniumbase`                      A complete web automation framework for end-to-end testing.                                                                                                                                               Jun 13, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-selenium-enhancer`                 pytest plugin for Selenium                                                                                                                                                                                Apr 29, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-selenium-pdiff`                    A pytest package implementing perceptualdiff for Selenium tests.                                                                                                                                          Apr 06, 2017    2 - Pre-Alpha          N/A
+   :pypi:`pytest-send-email`                        Send pytest execution result email                                                                                                                                                                        Dec 04, 2019    N/A                    N/A
+   :pypi:`pytest-sentry`                            A pytest plugin to send testrun information to Sentry.io                                                                                                                                                  Jan 05, 2023    N/A                    N/A
+   :pypi:`pytest-sequence-markers`                  Pytest plugin for sequencing markers for execution of tests                                                                                                                                               May 23, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-server-fixtures`                   Extensible server fixures for py.test                                                                                                                                                                     May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-serverless`                        Automatically mocks resources from serverless.yml in pytest using moto.                                                                                                                                   May 09, 2022    4 - Beta               N/A
+   :pypi:`pytest-servers`                           pytest servers                                                                                                                                                                                            Apr 15, 2023    3 - Alpha              pytest (>=6.2)
+   :pypi:`pytest-services`                          Services plugin for pytest testing framework                                                                                                                                                              Oct 30, 2020    6 - Mature             N/A
+   :pypi:`pytest-session2file`                      pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test.                                                         Jan 26, 2021    3 - Alpha              pytest
+   :pypi:`pytest-session-fixture-globalize`         py.test plugin to make session fixtures behave as if written in conftest, even if it is written in some modules                                                                                           May 15, 2018    4 - Beta               N/A
+   :pypi:`pytest-session_to_file`                   pytest-session_to_file is a py.test plugin for capturing and saving to file the stdout of py.test.                                                                                                        Oct 01, 2015    3 - Alpha              N/A
+   :pypi:`pytest-setupinfo`                         Displaying setup info during pytest command run                                                                                                                                                           Jan 23, 2023    N/A                    N/A
+   :pypi:`pytest-sftpserver`                        py.test plugin to locally test sftp server connections.                                                                                                                                                   Sep 16, 2019    4 - Beta               N/A
+   :pypi:`pytest-shard`                                                                                                                                                                                                                                       Dec 11, 2020    4 - Beta               pytest
+   :pypi:`pytest-share-hdf`                         Plugin to save test data in HDF files and retrieve them for comparison                                                                                                                                    Sep 21, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-sharkreport`                       this is pytest report plugin.                                                                                                                                                                             Jul 11, 2022    N/A                    pytest (>=3.5)
+   :pypi:`pytest-shell`                             A pytest plugin to help with testing shell scripts / black box commands                                                                                                                                   Mar 27, 2022    N/A                    N/A
+   :pypi:`pytest-shell-utilities`                   Pytest plugin to simplify running shell commands against the system                                                                                                                                       Sep 23, 2022    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-sheraf`                            Versatile ZODB abstraction layer - pytest fixtures                                                                                                                                                        Feb 11, 2020    N/A                    pytest
+   :pypi:`pytest-sherlock`                          pytest plugin help to find coupled tests                                                                                                                                                                  Jan 16, 2023    5 - Production/Stable  pytest (>=3.5.1)
+   :pypi:`pytest-shortcuts`                         Expand command-line shortcuts listed in pytest configuration                                                                                                                                              Oct 29, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-shutil`                            A goodie-bag of unix shell and environment tools for py.test                                                                                                                                              May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-simplehttpserver`                  Simple pytest fixture to spin up an HTTP server                                                                                                                                                           Jun 24, 2021    4 - Beta               N/A
+   :pypi:`pytest-simple-plugin`                     Simple pytest plugin                                                                                                                                                                                      Nov 27, 2019    N/A                    N/A
+   :pypi:`pytest-simple-settings`                   simple-settings plugin for pytest                                                                                                                                                                         Nov 17, 2020    4 - Beta               pytest
+   :pypi:`pytest-single-file-logging`               Allow for multiple processes to log to a single file                                                                                                                                                      May 05, 2016    4 - Beta               pytest (>=2.8.1)
+   :pypi:`pytest-skip-markers`                      Pytest Salt Plugin                                                                                                                                                                                        Dec 20, 2022    5 - Production/Stable  pytest (>=7.1.0)
+   :pypi:`pytest-skipper`                           A plugin that selects only tests with changes in execution path                                                                                                                                           Mar 26, 2017    3 - Alpha              pytest (>=3.0.6)
+   :pypi:`pytest-skippy`                            Automatically skip tests that don't need to run!                                                                                                                                                          Jan 27, 2018    3 - Alpha              pytest (>=2.3.4)
+   :pypi:`pytest-skip-slow`                         A pytest plugin to skip \`@pytest.mark.slow\` tests by default.                                                                                                                                           Feb 09, 2023    N/A                    pytest>=6.2.0
+   :pypi:`pytest-slack`                             Pytest to Slack reporting plugin                                                                                                                                                                          Dec 15, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-slow`                              A pytest plugin to skip \`@pytest.mark.slow\` tests by default.                                                                                                                                           Sep 28, 2021    N/A                    N/A
+   :pypi:`pytest-slowest-first`                     Sort tests by their last duration, slowest first                                                                                                                                                          Dec 11, 2022    4 - Beta               N/A
+   :pypi:`pytest-slow-last`                         Run tests in order of execution time (faster tests first)                                                                                                                                                 Dec 10, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-smartcollect`                      A plugin for collecting tests that touch changed code                                                                                                                                                     Oct 04, 2018    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-smartcov`                          Smart coverage plugin for pytest.                                                                                                                                                                         Sep 30, 2017    3 - Alpha              N/A
+   :pypi:`pytest-smell`                             Automated bad smell detection tool for Pytest                                                                                                                                                             Jun 26, 2022    N/A                    N/A
+   :pypi:`pytest-smtp`                              Send email with pytest execution result                                                                                                                                                                   Feb 20, 2021    N/A                    pytest
+   :pypi:`pytest-smtpd`                             An SMTP server for testing built on aiosmtpd                                                                                                                                                              May 15, 2023    N/A                    pytest
+   :pypi:`pytest-snail`                             Plugin for adding a marker to slow running tests. 🐌                                                                                                                                                      Nov 04, 2019    3 - Alpha              pytest (>=5.0.1)
+   :pypi:`pytest-snapci`                            py.test plugin for Snap-CI                                                                                                                                                                                Nov 12, 2015    N/A                    N/A
+   :pypi:`pytest-snapshot`                          A plugin for snapshot testing with pytest.                                                                                                                                                                Apr 23, 2022    4 - Beta               pytest (>=3.0.0)
+   :pypi:`pytest-snmpserver`                                                                                                                                                                                                                                  May 12, 2021    N/A                    N/A
+   :pypi:`pytest-snowflake-bdd`                     Setup test data and run tests on snowflake in BDD style!                                                                                                                                                  Jan 05, 2022    4 - Beta               pytest (>=6.2.0)
+   :pypi:`pytest-socket`                            Pytest Plugin to disable socket calls during tests                                                                                                                                                        Feb 03, 2023    4 - Beta               pytest (>=3.6.3)
+   :pypi:`pytest-sofaepione`                        Test the installation of SOFA and the SofaEpione plugin.                                                                                                                                                  Aug 17, 2022    N/A                    N/A
+   :pypi:`pytest-soft-assertions`                                                                                                                                                                                                                             May 05, 2020    3 - Alpha              pytest
+   :pypi:`pytest-solidity`                          A PyTest library plugin for Solidity language.                                                                                                                                                            Jan 15, 2022    1 - Planning           pytest (<7,>=6.0.1) ; extra == 'tests'
+   :pypi:`pytest-solr`                              Solr process and client fixtures for py.test.                                                                                                                                                             May 11, 2020    3 - Alpha              pytest (>=3.0.0)
+   :pypi:`pytest-sorter`                            A simple plugin to first execute tests that historically failed more                                                                                                                                      Apr 20, 2021    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-sosu`                              Unofficial PyTest plugin for Sauce Labs                                                                                                                                                                   Feb 14, 2023    2 - Pre-Alpha          pytest
+   :pypi:`pytest-sourceorder`                       Test-ordering plugin for pytest                                                                                                                                                                           Sep 01, 2021    4 - Beta               pytest
+   :pypi:`pytest-spark`                             pytest plugin to run the tests with support of pyspark.                                                                                                                                                   Feb 23, 2020    4 - Beta               pytest
+   :pypi:`pytest-spawner`                           py.test plugin to spawn process and communicate with them.                                                                                                                                                Jul 31, 2015    4 - Beta               N/A
+   :pypi:`pytest-spec`                              Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.                                                                                                             May 04, 2021    N/A                    N/A
+   :pypi:`pytest-spec2md`                           Library pytest-spec2md is a pytest plugin to create a markdown specification while running pytest.                                                                                                        Jun 26, 2022    N/A                    pytest (>7.0)
+   :pypi:`pytest-speed`                             Modern benchmarking library for python with pytest integration.                                                                                                                                           Jan 22, 2023    3 - Alpha              pytest>=7
+   :pypi:`pytest-sphinx`                            Doctest plugin for pytest with support for Sphinx-specific doctest-directives                                                                                                                             Sep 06, 2022    4 - Beta               pytest (>=7.0.0)
+   :pypi:`pytest-spiratest`                         Exports unit tests as test runs in SpiraTest/Team/Plan                                                                                                                                                    Feb 08, 2022    N/A                    N/A
+   :pypi:`pytest-splinter`                          Splinter plugin for pytest testing framework                                                                                                                                                              Sep 09, 2022    6 - Mature             pytest (>=3.0.0)
+   :pypi:`pytest-splinter4`                         Pytest plugin for the splinter automation library                                                                                                                                                         Jun 11, 2022    6 - Mature             pytest (<8.0,>=7.1.2)
+   :pypi:`pytest-split`                             Pytest plugin which splits the test suite to equally sized sub suites based on test execution time.                                                                                                       Apr 12, 2023    4 - Beta               pytest (>=5,<8)
+   :pypi:`pytest-splitio`                           Split.io SDK integration for e2e tests                                                                                                                                                                    Sep 22, 2020    N/A                    pytest (<7,>=5.0)
+   :pypi:`pytest-split-tests`                       A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups.                                             Jul 30, 2021    5 - Production/Stable  pytest (>=2.5)
+   :pypi:`pytest-split-tests-tresorit`                                                                                                                                                                                                                        Feb 22, 2021    1 - Planning           N/A
+   :pypi:`pytest-splunk-addon`                      A Dynamic test tool for Splunk Apps and Add-ons                                                                                                                                                           Feb 22, 2023    N/A                    pytest (>5.4.0,<7.3)
+   :pypi:`pytest-splunk-addon-ui-smartx`            Library to support testing Splunk Add-on UX                                                                                                                                                               Mar 07, 2023    N/A                    N/A
+   :pypi:`pytest-splunk-env`                        pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud                                                                                                                                   Oct 22, 2020    N/A                    pytest (>=6.1.1,<7.0.0)
+   :pypi:`pytest-sqitch`                            sqitch for pytest                                                                                                                                                                                         Apr 06, 2020    4 - Beta               N/A
+   :pypi:`pytest-sqlalchemy`                        pytest plugin with sqlalchemy related fixtures                                                                                                                                                            Mar 13, 2018    3 - Alpha              N/A
+   :pypi:`pytest-sqlalchemy-mock`                   pytest sqlalchemy plugin for mock                                                                                                                                                                         Mar 15, 2023    3 - Alpha              pytest (>=2.0)
+   :pypi:`pytest-sqlalchemy-session`                A pytest plugin for preserving test isolation that use SQLAlchemy.                                                                                                                                        May 19, 2023    4 - Beta               pytest (>=7.0)
+   :pypi:`pytest-sql-bigquery`                      Yet another SQL-testing framework for BigQuery provided by pytest plugin                                                                                                                                  Dec 19, 2019    N/A                    pytest
+   :pypi:`pytest-sqlfluff`                          A pytest plugin to use sqlfluff to enable format checking of sql files.                                                                                                                                   Dec 21, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-squadcast`                         Pytest report plugin for Squadcast                                                                                                                                                                        Feb 22, 2022    5 - Production/Stable  pytest
+   :pypi:`pytest-srcpaths`                          Add paths to sys.path                                                                                                                                                                                     Oct 15, 2021    N/A                    pytest>=6.2.0
+   :pypi:`pytest-ssh`                               pytest plugin for ssh command run                                                                                                                                                                         May 27, 2019    N/A                    pytest
+   :pypi:`pytest-start-from`                        Start pytest run from a given point                                                                                                                                                                       Apr 11, 2016    N/A                    N/A
+   :pypi:`pytest-star-track-issue`                  A package to prevent Dependency Confusion attacks against Yandex.                                                                                                                                         Feb 10, 2023    N/A                    N/A
+   :pypi:`pytest-static`                            pytest-static                                                                                                                                                                                             May 07, 2023    1 - Planning           N/A
+   :pypi:`pytest-statsd`                            pytest plugin for reporting to graphite                                                                                                                                                                   Nov 30, 2018    5 - Production/Stable  pytest (>=3.0.0)
+   :pypi:`pytest-stepfunctions`                     A small description                                                                                                                                                                                       May 08, 2021    4 - Beta               pytest
+   :pypi:`pytest-steps`                             Create step-wise / incremental tests in pytest.                                                                                                                                                           Sep 23, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-stepwise`                          Run a test suite one failing test at a time.                                                                                                                                                              Dec 01, 2015    4 - Beta               N/A
+   :pypi:`pytest-stf`                               pytest plugin for openSTF                                                                                                                                                                                 Dec 04, 2022    N/A                    pytest (>=5.0)
+   :pypi:`pytest-stoq`                              A plugin to pytest stoq                                                                                                                                                                                   Feb 09, 2021    4 - Beta               N/A
+   :pypi:`pytest-stress`                            A Pytest plugin that allows you to loop tests for a user defined amount of time.                                                                                                                          Dec 07, 2019    4 - Beta               pytest (>=3.6.0)
+   :pypi:`pytest-structlog`                         Structured logging assertions                                                                                                                                                                             Dec 18, 2022    N/A                    pytest
+   :pypi:`pytest-structmpd`                         provide structured temporary directory                                                                                                                                                                    Oct 17, 2018    N/A                    N/A
+   :pypi:`pytest-stub`                              Stub packages, modules and attributes.                                                                                                                                                                    Apr 28, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-stubprocess`                       Provide stub implementations for subprocesses in Python tests                                                                                                                                             Sep 17, 2018    3 - Alpha              pytest (>=3.5.0)
+   :pypi:`pytest-study`                             A pytest plugin to organize long run tests (named studies) without interfering the regular tests                                                                                                          Sep 26, 2017    3 - Alpha              pytest (>=2.0)
+   :pypi:`pytest-subprocess`                        A plugin to fake subprocess for pytest                                                                                                                                                                    Jan 28, 2023    5 - Production/Stable  pytest (>=4.0.0)
+   :pypi:`pytest-subtesthack`                       A hack to explicitly set up and tear down fixtures.                                                                                                                                                       Jul 16, 2022    N/A                    N/A
+   :pypi:`pytest-subtests`                          unittest subTest() support and subtests fixture                                                                                                                                                           May 15, 2023    4 - Beta               pytest (>=7.0)
+   :pypi:`pytest-subunit`                           pytest-subunit is a plugin for py.test which outputs testsresult in subunit format.                                                                                                                       Aug 29, 2017    N/A                    N/A
+   :pypi:`pytest-sugar`                             pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly).                                                                  Apr 10, 2023    4 - Beta               pytest (>=6.2.0)
+   :pypi:`pytest-suitemanager`                      A simple plugin to use with pytest                                                                                                                                                                        Apr 28, 2023    4 - Beta               N/A
+   :pypi:`pytest-svn`                               SVN repository fixture for py.test                                                                                                                                                                        May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-symbols`                           pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests.                                                                                               Nov 20, 2017    3 - Alpha              N/A
+   :pypi:`pytest-system-statistics`                 Pytest plugin to track and report system usage statistics                                                                                                                                                 Feb 16, 2022    5 - Production/Stable  pytest (>=6.0.0)
+   :pypi:`pytest-system-test-plugin`                Pyst - Pytest System-Test Plugin                                                                                                                                                                          Feb 03, 2022    N/A                    N/A
+   :pypi:`pytest-tagging`                           a pytest plugin to tag tests                                                                                                                                                                              Apr 01, 2023    N/A                    pytest (>=7.1.3,<8.0.0)
+   :pypi:`pytest-takeltest`                         Fixtures for ansible, testinfra and molecule                                                                                                                                                              Feb 15, 2023    N/A                    N/A
+   :pypi:`pytest-talisker`                                                                                                                                                                                                                                    Nov 28, 2021    N/A                    N/A
+   :pypi:`pytest-tally`                             A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard.                                                                                             May 22, 2023    4 - Beta               pytest (>=6.2.5)
+   :pypi:`pytest-tap`                               Test Anything Protocol (TAP) reporting plugin for pytest                                                                                                                                                  Oct 27, 2021    5 - Production/Stable  pytest (>=3.0)
+   :pypi:`pytest-tape`                              easy assertion with expected results saved to yaml files                                                                                                                                                  Mar 17, 2021    4 - Beta               N/A
+   :pypi:`pytest-target`                            Pytest plugin for remote target orchestration.                                                                                                                                                            Jan 21, 2021    3 - Alpha              pytest (>=6.1.2,<7.0.0)
+   :pypi:`pytest-tblineinfo`                        tblineinfo is a py.test plugin that insert the node id in the final py.test report when --tb=line option is used                                                                                          Dec 01, 2015    3 - Alpha              pytest (>=2.0)
+   :pypi:`pytest-tcpclient`                         A pytest plugin for testing TCP clients                                                                                                                                                                   Nov 16, 2022    N/A                    pytest (<8,>=7.1.3)
+   :pypi:`pytest-teamcity-logblock`                 py.test plugin to introduce block structure in teamcity build log, if output is not captured                                                                                                              May 15, 2018    4 - Beta               N/A
+   :pypi:`pytest-telegram`                          Pytest to Telegram reporting plugin                                                                                                                                                                       Dec 10, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-telegram-notifier`                 Telegram notification plugin for Pytest                                                                                                                                                                   Mar 17, 2023    5 - Production/Stable  N/A
+   :pypi:`pytest-tempdir`                           Predictable and repeatable tempdir support.                                                                                                                                                               Oct 11, 2019    4 - Beta               pytest (>=2.8.1)
+   :pypi:`pytest-terra-fixt`                        Terraform and Terragrunt fixtures for pytest                                                                                                                                                              Sep 15, 2022    N/A                    pytest (==6.2.5)
+   :pypi:`pytest-terraform`                         A pytest plugin for using terraform fixtures                                                                                                                                                              Sep 01, 2022    N/A                    pytest (>=6.0)
+   :pypi:`pytest-terraform-fixture`                 generate terraform resources to use with pytest                                                                                                                                                           Nov 14, 2018    4 - Beta               N/A
+   :pypi:`pytest-testbook`                          A plugin to run tests written in Jupyter notebook                                                                                                                                                         Dec 11, 2016    3 - Alpha              N/A
+   :pypi:`pytest-testconfig`                        Test configuration plugin for pytest.                                                                                                                                                                     Jan 11, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-testdirectory`                     A py.test plugin providing temporary directories in unit tests.                                                                                                                                           May 02, 2023    5 - Production/Stable  pytest
+   :pypi:`pytest-testdox`                           A testdox format reporter for pytest                                                                                                                                                                      Apr 19, 2022    5 - Production/Stable  pytest (>=4.6.0)
+   :pypi:`pytest-test-grouping`                     A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups.                                                                                                          Feb 01, 2023    5 - Production/Stable  pytest (>=2.5)
+   :pypi:`pytest-test-groups`                       A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups.                                                                                                          Oct 25, 2016    5 - Production/Stable  N/A
+   :pypi:`pytest-testinfra`                         Test infrastructures                                                                                                                                                                                      May 21, 2023    5 - Production/Stable  pytest (!=3.0.2)
+   :pypi:`pytest-testlink-adaptor`                  pytest reporting plugin for testlink                                                                                                                                                                      Dec 20, 2018    4 - Beta               pytest (>=2.6)
+   :pypi:`pytest-testmon`                           selects tests affected by changed files and methods                                                                                                                                                       Jun 16, 2023    4 - Beta               N/A
+   :pypi:`pytest-testmon-dev`                       selects tests affected by changed files and methods                                                                                                                                                       Mar 30, 2023    4 - Beta               pytest (<8,>=5)
+   :pypi:`pytest-testmon-oc`                        nOly selects tests affected by changed files and methods                                                                                                                                                  Jun 01, 2022    4 - Beta               pytest (<8,>=5)
+   :pypi:`pytest-testmon-skip-libraries`            selects tests affected by changed files and methods                                                                                                                                                       Mar 03, 2023    4 - Beta               pytest (<8,>=5)
+   :pypi:`pytest-testobject`                        Plugin to use TestObject Suites with Pytest                                                                                                                                                               Sep 24, 2019    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-testpluggy`                        set your encoding                                                                                                                                                                                         Jan 07, 2022    N/A                    pytest
+   :pypi:`pytest-testrail`                          pytest plugin for creating TestRail runs and adding results                                                                                                                                               Aug 27, 2020    N/A                    pytest (>=3.6)
+   :pypi:`pytest-testrail2`                         A pytest plugin to upload results to TestRail.                                                                                                                                                            Feb 10, 2023    N/A                    pytest (<8.0,>=7.2.0)
+   :pypi:`pytest-testrail-api-client`               TestRail Api Python Client                                                                                                                                                                                Dec 14, 2021    N/A                    pytest
+   :pypi:`pytest-testrail-appetize`                 pytest plugin for creating TestRail runs and adding results                                                                                                                                               Sep 29, 2021    N/A                    N/A
+   :pypi:`pytest-testrail-client`                   pytest plugin for Testrail                                                                                                                                                                                Sep 29, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-testrail-e2e`                      pytest plugin for creating TestRail runs and adding results                                                                                                                                               Oct 11, 2021    N/A                    pytest (>=3.6)
+   :pypi:`pytest-testrail-integrator`               Pytest plugin for sending report to testrail system.                                                                                                                                                      Aug 01, 2022    N/A                    pytest (>=6.2.5)
+   :pypi:`pytest-testrail-ns`                       pytest plugin for creating TestRail runs and adding results                                                                                                                                               Aug 12, 2022    N/A                    N/A
+   :pypi:`pytest-testrail-plugin`                   PyTest plugin for TestRail                                                                                                                                                                                Apr 21, 2020    3 - Alpha              pytest
+   :pypi:`pytest-testrail-reporter`                                                                                                                                                                                                                           Sep 10, 2018    N/A                    N/A
+   :pypi:`pytest-testreport`                                                                                                                                                                                                                                  Dec 01, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-testreport-new`                                                                                                                                                                                                                              Aug 15, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-testslide`                         TestSlide fixture for pytest                                                                                                                                                                              Jan 07, 2021    5 - Production/Stable  pytest (~=6.2)
+   :pypi:`pytest-test-this`                         Plugin for py.test to run relevant tests, based on naively checking if a test contains a reference to the symbol you supply                                                                               Sep 15, 2019    2 - Pre-Alpha          pytest (>=2.3)
+   :pypi:`pytest-test-utils`                                                                                                                                                                                                                                  Jul 14, 2022    N/A                    pytest (>=5)
+   :pypi:`pytest-tesults`                           Tesults plugin for pytest                                                                                                                                                                                 Dec 23, 2022    5 - Production/Stable  pytest (>=3.5.0)
+   :pypi:`pytest-tezos`                             pytest-ligo                                                                                                                                                                                               Jan 16, 2020    4 - Beta               N/A
+   :pypi:`pytest-th2-bdd`                           pytest_th2_bdd                                                                                                                                                                                            May 13, 2022    N/A                    N/A
+   :pypi:`pytest-thawgun`                           Pytest plugin for time travel                                                                                                                                                                             May 26, 2020    3 - Alpha              N/A
+   :pypi:`pytest-threadleak`                        Detects thread leaks                                                                                                                                                                                      Jul 03, 2022    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-tick`                              Ticking on tests                                                                                                                                                                                          Aug 31, 2021    5 - Production/Stable  pytest (>=6.2.5,<7.0.0)
+   :pypi:`pytest-time`                                                                                                                                                                                                                                        Jun 16, 2023    3 - Alpha              pytest
+   :pypi:`pytest-timeit`                            A pytest plugin to time test function runs                                                                                                                                                                Oct 13, 2016    4 - Beta               N/A
+   :pypi:`pytest-timeout`                           pytest plugin to abort hanging tests                                                                                                                                                                      Jan 18, 2022    5 - Production/Stable  pytest (>=5.0.0)
+   :pypi:`pytest-timeouts`                          Linux-only Pytest plugin to control durations of various test case execution phases                                                                                                                       Sep 21, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-timer`                             A timer plugin for pytest                                                                                                                                                                                 Jun 02, 2021    N/A                    N/A
+   :pypi:`pytest-timestamper`                       Pytest plugin to add a timestamp prefix to the pytest output                                                                                                                                              Jun 06, 2021    N/A                    N/A
+   :pypi:`pytest-timestamps`                        A simple plugin to view timestamps for each test                                                                                                                                                          Apr 01, 2023    N/A                    pytest (>=5.2)
+   :pypi:`pytest-tipsi-django`                                                                                                                                                                                                                                Nov 17, 2021    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-tipsi-testing`                     Better fixtures management. Various helpers                                                                                                                                                               Nov 04, 2020    4 - Beta               pytest (>=3.3.0)
+   :pypi:`pytest-tldr`                              A pytest plugin that limits the output to just the things you need.                                                                                                                                       Oct 26, 2022    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-tm4j-reporter`                     Cloud Jira Test Management (TM4J) PyTest reporter plugin                                                                                                                                                  Sep 01, 2020    N/A                    pytest
+   :pypi:`pytest-tmnet`                             A small example package                                                                                                                                                                                   Mar 01, 2022    N/A                    N/A
+   :pypi:`pytest-tmp-files`                         Utilities to create temporary file hierarchies in pytest.                                                                                                                                                 Apr 03, 2022    N/A                    pytest
+   :pypi:`pytest-tmpfs`                             A pytest plugin that helps you on using a temporary filesystem for testing.                                                                                                                               Aug 29, 2022    N/A                    pytest
+   :pypi:`pytest-tmreport`                          this is a vue-element ui report for pytest                                                                                                                                                                Aug 12, 2022    N/A                    N/A
+   :pypi:`pytest-tmux`                              A pytest plugin that enables tmux driven tests                                                                                                                                                            Apr 22, 2023    4 - Beta               N/A
+   :pypi:`pytest-todo`                              A small plugin for the pytest testing framework, marking TODO comments as failure                                                                                                                         May 23, 2019    4 - Beta               pytest
+   :pypi:`pytest-tomato`                                                                                                                                                                                                                                      Mar 01, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-toolbelt`                          This is just a collection of utilities for pytest, but don't really belong in pytest proper.                                                                                                              Aug 12, 2019    3 - Alpha              N/A
+   :pypi:`pytest-toolbox`                           Numerous useful plugins for pytest.                                                                                                                                                                       Apr 07, 2018    N/A                    pytest (>=3.5.0)
+   :pypi:`pytest-tools`                             Pytest tools                                                                                                                                                                                              Oct 21, 2022    4 - Beta               N/A
+   :pypi:`pytest-tornado`                           A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.                                                                                                 Jun 17, 2020    5 - Production/Stable  pytest (>=3.6)
+   :pypi:`pytest-tornado5`                          A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.                                                                                                 Nov 16, 2018    5 - Production/Stable  pytest (>=3.6)
+   :pypi:`pytest-tornado-yen3`                      A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.                                                                                                 Oct 15, 2018    5 - Production/Stable  N/A
+   :pypi:`pytest-tornasync`                         py.test plugin for testing Python 3.5+ Tornado code                                                                                                                                                       Jul 15, 2019    3 - Alpha              pytest (>=3.0)
+   :pypi:`pytest-trace`                             Save OpenTelemetry spans generated during testing                                                                                                                                                         Jun 19, 2022    N/A                    pytest (>=4.6)
+   :pypi:`pytest-track`                                                                                                                                                                                                                                       Feb 26, 2021    3 - Alpha              pytest (>=3.0)
+   :pypi:`pytest-translations`                      Test your translation files.                                                                                                                                                                              Nov 05, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-travis-fold`                       Folds captured output sections in Travis CI build log                                                                                                                                                     Nov 29, 2017    4 - Beta               pytest (>=2.6.0)
+   :pypi:`pytest-trello`                            Plugin for py.test that integrates trello using markers                                                                                                                                                   Nov 20, 2015    5 - Production/Stable  N/A
+   :pypi:`pytest-trepan`                            Pytest plugin for trepan debugger.                                                                                                                                                                        Jul 28, 2018    5 - Production/Stable  N/A
+   :pypi:`pytest-trialtemp`                         py.test plugin for using the same _trial_temp working directory as trial                                                                                                                                  Jun 08, 2015    N/A                    N/A
+   :pypi:`pytest-trio`                              Pytest plugin for trio                                                                                                                                                                                    Nov 01, 2022    N/A                    pytest (>=7.2.0)
+   :pypi:`pytest-trytond`                           Pytest plugin for the Tryton server framework                                                                                                                                                             Nov 04, 2022    4 - Beta               pytest (>=5)
+   :pypi:`pytest-tspwplib`                          A simple plugin to use with tspwplib                                                                                                                                                                      Jan 08, 2021    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-tst`                               Customize pytest options, output and exit code to make it compatible with tst                                                                                                                             Apr 27, 2022    N/A                    pytest (>=5.0.0)
+   :pypi:`pytest-tstcls`                            Test Class Base                                                                                                                                                                                           Mar 23, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-tui`                               Text User Interface (TUI) and HTML report for Pytest test runs                                                                                                                                            Jun 12, 2023    4 - Beta               N/A
+   :pypi:`pytest-tutorials`                                                                                                                                                                                                                                   Mar 11, 2023    N/A                    N/A
+   :pypi:`pytest-twilio-conversations-client-mock`                                                                                                                                                                                                            Aug 02, 2022    N/A                    N/A
+   :pypi:`pytest-twisted`                           A twisted plugin for pytest.                                                                                                                                                                              Oct 16, 2022    5 - Production/Stable  pytest (>=2.3)
+   :pypi:`pytest-typechecker`                       Run type checkers on specified test files                                                                                                                                                                 Feb 04, 2022    N/A                    pytest (>=6.2.5,<7.0.0)
+   :pypi:`pytest-typhoon-config`                    A Typhoon HIL plugin that facilitates test parameter configuration at runtime                                                                                                                             Apr 07, 2022    5 - Production/Stable  N/A
+   :pypi:`pytest-typhoon-xray`                      Typhoon HIL plugin for pytest                                                                                                                                                                             Jun 10, 2023    4 - Beta               N/A
+   :pypi:`pytest-tytest`                            Typhoon HIL plugin for pytest                                                                                                                                                                             May 25, 2020    4 - Beta               pytest (>=5.4.2)
+   :pypi:`pytest-ubersmith`                         Easily mock calls to ubersmith at the \`requests\` level.                                                                                                                                                 Apr 13, 2015    N/A                    N/A
+   :pypi:`pytest-ui`                                Text User Interface for running python tests                                                                                                                                                              Jul 05, 2021    4 - Beta               pytest
+   :pypi:`pytest-ui-failed-screenshot`              UI自动测试失败时自动截图,并将截图加入到测试报告中                                                                                                                                                        Dec 06, 2022    N/A                    N/A
+   :pypi:`pytest-ui-failed-screenshot-allure`       UI自动测试失败时自动截图,并将截图加入到Allure测试报告中                                                                                                                                                  Dec 06, 2022    N/A                    N/A
+   :pypi:`pytest-unflakable`                        Unflakable plugin for PyTest                                                                                                                                                                              Mar 24, 2023    4 - Beta               pytest (>=6.2.0)
+   :pypi:`pytest-unhandled-exception-exit-code`     Plugin for py.test set a different exit code on uncaught exceptions                                                                                                                                       Jun 22, 2020    5 - Production/Stable  pytest (>=2.3)
+   :pypi:`pytest-unittest-filter`                   A pytest plugin for filtering unittest-based test classes                                                                                                                                                 Jan 12, 2019    4 - Beta               pytest (>=3.1.0)
+   :pypi:`pytest-unmarked`                          Run only unmarked tests                                                                                                                                                                                   Aug 27, 2019    5 - Production/Stable  N/A
+   :pypi:`pytest-unordered`                         Test equality of unordered collections in pytest                                                                                                                                                          Nov 28, 2022    4 - Beta               pytest (>=6.0.0)
+   :pypi:`pytest-unstable`                          Set a test as unstable to return 0 even if it failed                                                                                                                                                      Sep 27, 2022    4 - Beta               N/A
+   :pypi:`pytest-unused-fixtures`                   A pytest plugin to list unused fixtures after a test run.                                                                                                                                                 Jun 15, 2023    4 - Beta               pytest (>=7.3.2,<8.0.0)
+   :pypi:`pytest-upload-report`                     pytest-upload-report is a plugin for pytest that upload your test report for test results.                                                                                                                Jun 18, 2021    5 - Production/Stable  N/A
+   :pypi:`pytest-utils`                             Some helpers for pytest.                                                                                                                                                                                  Feb 02, 2023    4 - Beta               pytest (>=7.0.0,<8.0.0)
+   :pypi:`pytest-vagrant`                           A py.test plugin providing access to vagrant.                                                                                                                                                             Sep 07, 2021    5 - Production/Stable  pytest
+   :pypi:`pytest-valgrind`                                                                                                                                                                                                                                    May 19, 2021    N/A                    N/A
+   :pypi:`pytest-variables`                         pytest plugin for providing variables to tests/fixtures                                                                                                                                                   May 27, 2023    5 - Production/Stable  pytest>=7.0.0
+   :pypi:`pytest-variant`                           Variant support for Pytest                                                                                                                                                                                Jun 06, 2022    N/A                    N/A
+   :pypi:`pytest-vcr`                               Plugin for managing VCR.py cassettes                                                                                                                                                                      Apr 26, 2019    5 - Production/Stable  pytest (>=3.6.0)
+   :pypi:`pytest-vcr-delete-on-fail`                A pytest plugin that automates vcrpy cassettes deletion on test failure.                                                                                                                                  Jun 20, 2022    5 - Production/Stable  pytest (>=6.2.2)
+   :pypi:`pytest-vcrpandas`                         Test from HTTP interactions to dataframe processed.                                                                                                                                                       Jan 12, 2019    4 - Beta               pytest
+   :pypi:`pytest-vcs`                                                                                                                                                                                                                                         Sep 22, 2022    4 - Beta               N/A
+   :pypi:`pytest-venv`                              py.test fixture for creating a virtual environment                                                                                                                                                        Aug 04, 2020    4 - Beta               pytest
+   :pypi:`pytest-ver`                               Pytest module with Verification Protocol, Verification Report and Trace Matrix                                                                                                                            Mar 22, 2023    4 - Beta               N/A
+   :pypi:`pytest-verbose-parametrize`               More descriptive output for parametrized py.test tests                                                                                                                                                    May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-vimqf`                             A simple pytest plugin that will shrink pytest output when specified, to fit vim quickfix window.                                                                                                         Feb 08, 2021    4 - Beta               pytest (>=6.2.2,<7.0.0)
+   :pypi:`pytest-virtualenv`                        Virtualenv fixture for py.test                                                                                                                                                                            May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-vnc`                               VNC client for Pytest                                                                                                                                                                                     Feb 25, 2023    N/A                    pytest
+   :pypi:`pytest-voluptuous`                        Pytest plugin for asserting data against voluptuous schema.                                                                                                                                               Jun 09, 2020    N/A                    pytest
+   :pypi:`pytest-vscodedebug`                       A pytest plugin to easily enable debugging tests within Visual Studio Code                                                                                                                                Dec 04, 2020    4 - Beta               N/A
+   :pypi:`pytest-vscode-pycharm-cls`                A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used.                                                                                                Feb 01, 2023    N/A                    pytest
+   :pypi:`pytest-vts`                               pytest plugin for automatic recording of http stubbed tests                                                                                                                                               Jun 05, 2019    N/A                    pytest (>=2.3)
+   :pypi:`pytest-vulture`                           A pytest plugin to checks dead code with vulture                                                                                                                                                          Jun 01, 2023    N/A                    pytest (>=7.0.0)
+   :pypi:`pytest-vw`                                pytest-vw makes your failing test cases succeed under CI tools scrutiny                                                                                                                                   Oct 07, 2015    4 - Beta               N/A
+   :pypi:`pytest-vyper`                             Plugin for the vyper smart contract language.                                                                                                                                                             May 28, 2020    2 - Pre-Alpha          N/A
+   :pypi:`pytest-wa-e2e-plugin`                     Pytest plugin for testing whatsapp bots with end to end tests                                                                                                                                             Feb 18, 2020    4 - Beta               pytest (>=3.5.0)
+   :pypi:`pytest-wake`                                                                                                                                                                                                                                        May 11, 2023    N/A                    pytest
+   :pypi:`pytest-watch`                             Local continuous test runner with pytest and watchdog.                                                                                                                                                    May 20, 2018    N/A                    N/A
+   :pypi:`pytest-watcher`                           Automatically rerun your tests on file modifications                                                                                                                                                      Jun 11, 2023    4 - Beta               N/A
+   :pypi:`pytest-wdl`                               Pytest plugin for testing WDL workflows.                                                                                                                                                                  Nov 17, 2020    5 - Production/Stable  N/A
+   :pypi:`pytest-web3-data`                                                                                                                                                                                                                                   Sep 15, 2022    4 - Beta               pytest
+   :pypi:`pytest-webdriver`                         Selenium webdriver fixture for py.test                                                                                                                                                                    May 28, 2019    5 - Production/Stable  pytest
+   :pypi:`pytest-wetest`                            Welian API Automation test framework pytest plugin                                                                                                                                                        Nov 10, 2018    4 - Beta               N/A
+   :pypi:`pytest-when`                              Utility which makes mocking more readable and controllable                                                                                                                                                Jun 05, 2023    N/A                    pytest>=7.3.1
+   :pypi:`pytest-whirlwind`                         Testing Tornado.                                                                                                                                                                                          Jun 12, 2020    N/A                    N/A
+   :pypi:`pytest-wholenodeid`                       pytest addon for displaying the whole node id for failures                                                                                                                                                Aug 26, 2015    4 - Beta               pytest (>=2.0)
+   :pypi:`pytest-win32consoletitle`                 Pytest progress in console title (Win32 only)                                                                                                                                                             Aug 08, 2021    N/A                    N/A
+   :pypi:`pytest-winnotify`                         Windows tray notifications for py.test results.                                                                                                                                                           Apr 22, 2016    N/A                    N/A
+   :pypi:`pytest-wiremock`                          A pytest plugin for programmatically using wiremock in integration tests                                                                                                                                  Mar 27, 2022    N/A                    pytest (>=7.1.1,<8.0.0)
+   :pypi:`pytest-with-docker`                       pytest with docker helpers.                                                                                                                                                                               Nov 09, 2021    N/A                    pytest
+   :pypi:`pytest-workflow`                          A pytest plugin for configuring workflow/pipeline tests using YAML files                                                                                                                                  Jan 13, 2023    5 - Production/Stable  pytest (>=7.0.0)
+   :pypi:`pytest-xdist`                             pytest xdist plugin for distributed testing, most importantly across multiple CPUs                                                                                                                        May 19, 2023    5 - Production/Stable  pytest (>=6.2.0)
+   :pypi:`pytest-xdist-debug-for-graingert`         pytest xdist plugin for distributed testing and loop-on-failing modes                                                                                                                                     Jul 24, 2019    5 - Production/Stable  pytest (>=4.4.0)
+   :pypi:`pytest-xdist-forked`                      forked from pytest-xdist                                                                                                                                                                                  Feb 10, 2020    5 - Production/Stable  pytest (>=4.4.0)
+   :pypi:`pytest-xdist-tracker`                     pytest plugin helps to reproduce failures for particular xdist node                                                                                                                                       Nov 18, 2021    3 - Alpha              pytest (>=3.5.1)
+   :pypi:`pytest-xdist-worker-stats`                A pytest plugin to list worker statistics after a xdist run.                                                                                                                                              Jun 15, 2023    4 - Beta               pytest (>=7.3.2,<8.0.0)
+   :pypi:`pytest-xfaillist`                         Maintain a xfaillist in an additional file to avoid merge-conflicts.                                                                                                                                      Sep 17, 2021    N/A                    pytest (>=6.2.2,<7.0.0)
+   :pypi:`pytest-xfiles`                            Pytest fixtures providing data read from function, module or package related (x)files.                                                                                                                    Feb 27, 2018    N/A                    N/A
+   :pypi:`pytest-xlog`                              Extended logging for test and decorators                                                                                                                                                                  May 31, 2020    4 - Beta               N/A
+   :pypi:`pytest-xlsx`                              pytest plugin for generating test cases by xlsx(excel)                                                                                                                                                    Mar 01, 2023    N/A                    pytest>=7.2.0
+   :pypi:`pytest-xpara`                             An extended parametrizing plugin of pytest.                                                                                                                                                               Oct 30, 2017    3 - Alpha              pytest
+   :pypi:`pytest-xprocess`                          A pytest plugin for managing processes across test runs.                                                                                                                                                  Jan 05, 2023    4 - Beta               pytest (>=2.8)
+   :pypi:`pytest-xray`                                                                                                                                                                                                                                        May 30, 2019    3 - Alpha              N/A
+   :pypi:`pytest-xrayjira`                                                                                                                                                                                                                                    Mar 17, 2020    3 - Alpha              pytest (==4.3.1)
+   :pypi:`pytest-xray-server`                                                                                                                                                                                                                                 May 03, 2022    3 - Alpha              pytest (>=5.3.1)
+   :pypi:`pytest-xskynet`                           A package to prevent Dependency Confusion attacks against Yandex.                                                                                                                                         Feb 10, 2023    N/A                    N/A
+   :pypi:`pytest-xvfb`                              A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests.                                                                                                                                                   May 29, 2023    4 - Beta               pytest (>=2.8.1)
+   :pypi:`pytest-yaml`                              This plugin is used to load yaml output to your test using pytest framework.                                                                                                                              Oct 05, 2018    N/A                    pytest
+   :pypi:`pytest-yaml-sanmu`                        pytest plugin for generating test cases by yaml                                                                                                                                                           May 28, 2023    N/A                    pytest>=7.2.0
+   :pypi:`pytest-yamltree`                          Create or check file/directory trees described by YAML                                                                                                                                                    Mar 02, 2020    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-yamlwsgi`                          Run tests against wsgi apps defined in yaml                                                                                                                                                               May 11, 2010    N/A                    N/A
+   :pypi:`pytest-yaml-yoyo`                         http/https API run by yaml                                                                                                                                                                                Jun 08, 2023    N/A                    pytest (>=7.2.0)
+   :pypi:`pytest-yapf`                              Run yapf                                                                                                                                                                                                  Jul 06, 2017    4 - Beta               pytest (>=3.1.1)
+   :pypi:`pytest-yapf3`                             Validate your Python file format with yapf                                                                                                                                                                Mar 29, 2023    5 - Production/Stable  pytest (>=7)
+   :pypi:`pytest-yield`                             PyTest plugin to run tests concurrently, each \`yield\` switch context to other one                                                                                                                       Jan 23, 2019    N/A                    N/A
+   :pypi:`pytest-yls`                               Pytest plugin to test the YLS as a whole.                                                                                                                                                                 Mar 29, 2023    N/A                    pytest (>=7.2.2,<8.0.0)
+   :pypi:`pytest-yuk`                               Display tests you are uneasy with, using 🤢/🤮 for pass/fail of tests marked with yuk.                                                                                                                    Mar 26, 2021    N/A                    pytest>=5.0.0
+   :pypi:`pytest-zafira`                            A Zafira plugin for pytest                                                                                                                                                                                Sep 18, 2019    5 - Production/Stable  pytest (==4.1.1)
+   :pypi:`pytest-zap`                               OWASP ZAP plugin for py.test.                                                                                                                                                                             May 12, 2014    4 - Beta               N/A
+   :pypi:`pytest-zebrunner`                         Pytest connector for Zebrunner reporting                                                                                                                                                                  Dec 12, 2022    5 - Production/Stable  pytest (>=4.5.0)
+   :pypi:`pytest-zest`                              Zesty additions to pytest.                                                                                                                                                                                Nov 17, 2022    N/A                    N/A
+   :pypi:`pytest-zigzag`                            Extend py.test for RPC OpenStack testing.                                                                                                                                                                 Feb 27, 2019    4 - Beta               pytest (~=3.6)
+   :pypi:`pytest-zulip`                             Pytest report plugin for Zulip                                                                                                                                                                            May 07, 2022    5 - Production/Stable  pytest
+   ===============================================  ========================================================================================================================================================================================================  ==============  =====================  ================================================
+
+.. only:: latex
+
+
+  :pypi:`logassert`
+     *last release*: May 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Simple but powerful assertion and verification of logged lines.
+
+  :pypi:`pytest-abq`
+     *last release*: Apr 07, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest integration for the ABQ universal test runner.
+
+  :pypi:`pytest-abstracts`
+     *last release*: May 25, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A contextmanager pytest fixture for handling multiple mock abstracts
+
+  :pypi:`pytest-accept`
+     *last release*: Dec 21, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6,<8)
+
+     A pytest-plugin for updating doctest outputs
+
+  :pypi:`pytest-adaptavist`
+     *last release*: Oct 13, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5.4.0)
+
+     pytest plugin for generating test execution results within Jira Test Management (tm4j)
+
+  :pypi:`pytest-addons-test`
+     *last release*: Aug 02, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.4,<7.0.0)
+
+     用于测试pytest的插件
+
+  :pypi:`pytest-adf`
+     *last release*: May 10, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest plugin for writing Azure Data Factory integration tests
+
+  :pypi:`pytest-adf-azure-identity`
+     *last release*: Mar 06, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest plugin for writing Azure Data Factory integration tests
+
+  :pypi:`pytest-ads-testplan`
+     *last release*: Sep 15, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Azure DevOps Test Case reporting for pytest tests
+
+  :pypi:`pytest-agent`
+     *last release*: Nov 25, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Service that exposes a REST API that can be used to interract remotely with Pytest. It is shipped with a dashboard that enables running tests in a more convenient way.
+
+  :pypi:`pytest-aggreport`
+     *last release*: Mar 07, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.2)
+
+     pytest plugin for pytest-repeat that generate aggregate report of the same test cases with additional statistics details.
+
+  :pypi:`pytest-aio`
+     *last release*: Feb 03, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest plugin for testing async python code
+
+  :pypi:`pytest-aiofiles`
+     *last release*: May 14, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest fixtures for writing aiofiles tests with pyfakefs
+
+  :pypi:`pytest-aiogram`
+     *last release*: May 06, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-aiohttp`
+     *last release*: Feb 12, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.1.0)
+
+     Pytest plugin for aiohttp support
+
+  :pypi:`pytest-aiohttp-client`
+     *last release*: Jan 10, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+     Pytest \`client\` fixture for the Aiohttp
+
+  :pypi:`pytest-aiomoto`
+     *last release*: Nov 09, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.0,<8.0)
+
+     pytest-aiomoto
+
+  :pypi:`pytest-aioresponses`
+     *last release*: Jul 29, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     py.test integration for aioresponses
+
+  :pypi:`pytest-aioworkers`
+     *last release*: May 01, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=6.1.0
+
+     A plugin to test aioworkers project with pytest
+
+  :pypi:`pytest-airflow`
+     *last release*: Apr 03, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.4.0)
+
+     pytest support for airflow.
+
+  :pypi:`pytest-airflow-utils`
+     *last release*: Nov 15, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-alembic`
+     *last release*: May 23, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=6.0)
+
+     A pytest plugin for verifying alembic migrations.
+
+  :pypi:`pytest-allclose`
+     *last release*: Jul 30, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest fixture extending Numpy's allclose function
+
+  :pypi:`pytest-allure-adaptor`
+     *last release*: Jan 10, 2018,
+     *status*: N/A,
+     *requires*: pytest (>=2.7.3)
+
+     Plugin for py.test to generate allure xml reports
+
+  :pypi:`pytest-allure-adaptor2`
+     *last release*: Oct 14, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=2.7.3)
+
+     Plugin for py.test to generate allure xml reports
+
+  :pypi:`pytest-allure-collection`
+     *last release*: Apr 13, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest plugin to collect allure markers without running any tests
+
+  :pypi:`pytest-allure-dsl`
+     *last release*: Oct 25, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to test case doc string dls instructions
+
+  :pypi:`pytest-allure-intersection`
+     *last release*: Oct 27, 2022,
+     *status*: N/A,
+     *requires*: pytest (<5)
+
+
+
+  :pypi:`pytest-allure-spec-coverage`
+     *last release*: Oct 26, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     The pytest plugin aimed to display test coverage of the specs(requirements) in Allure
+
+  :pypi:`pytest-alphamoon`
+     *last release*: Dec 30, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.5.0)
+
+     Static code checks used at Alphamoon
+
+  :pypi:`pytest-android`
+     *last release*: Feb 21, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2.
+
+  :pypi:`pytest-anki`
+     *last release*: Jul 31, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin for testing Anki add-ons
+
+  :pypi:`pytest-annotate`
+     *last release*: Jun 07, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (<8.0.0,>=3.2.0)
+
+     pytest-annotate: Generate PyAnnotate annotations from your pytest tests.
+
+  :pypi:`pytest-ansible`
+     *last release*: May 15, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (<8.0.0,>=6)
+
+     Plugin for pytest to simplify calling ansible modules from tests or fixtures
+
+  :pypi:`pytest-ansible-playbook`
+     *last release*: Mar 08, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest fixture which runs given ansible playbook file.
+
+  :pypi:`pytest-ansible-playbook-runner`
+     *last release*: Dec 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.0)
+
+     Pytest fixture which runs given ansible playbook file.
+
+  :pypi:`pytest-ansible-units`
+     *last release*: Apr 14, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin for running unit tests within an ansible collection
+
+  :pypi:`pytest-antilru`
+     *last release*: Jul 05, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Bust functools.lru_cache when running pytest to avoid test pollution
+
+  :pypi:`pytest-anyio`
+     *last release*: Jun 29, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     The pytest anyio plugin is built into anyio. You don't need this package.
+
+  :pypi:`pytest-anything`
+     *last release*: Oct 13, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest fixtures to assert anything and something
+
+  :pypi:`pytest-aoc`
+     *last release*: Dec 08, 2022,
+     *status*: N/A,
+     *requires*: pytest ; extra == 'test'
+
+     Downloads puzzle inputs for Advent of Code and synthesizes PyTest fixtures
+
+  :pypi:`pytest-aoreporter`
+     *last release*: Jun 27, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest report
+
+  :pypi:`pytest-api`
+     *last release*: May 12, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.1,<8.0.0)
+
+     An ASGI middleware to populate OpenAPI Specification examples from pytest functions
+
+  :pypi:`pytest-api-soup`
+     *last release*: Aug 27, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Validate multiple endpoints with unit testing using a single source of truth.
+
+  :pypi:`pytest-apistellar`
+     *last release*: Jun 18, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     apistellar plugin for pytest.
+
+  :pypi:`pytest-appengine`
+     *last release*: Feb 27, 2017,
+     *status*: N/A,
+     *requires*: N/A
+
+     AppEngine integration that works well with pytest-django
+
+  :pypi:`pytest-appium`
+     *last release*: Dec 05, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin for appium
+
+  :pypi:`pytest-approvaltests`
+     *last release*: May 08, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.1)
+
+     A plugin to use approvaltests with pytest
+
+  :pypi:`pytest-approvaltests-geo`
+     *last release*: Mar 04, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Extension for ApprovalTests.Python specific to geo data verification
+
+  :pypi:`pytest-archon`
+     *last release*: Jan 31, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.2)
+
+     Rule your architecture like a real developer
+
+  :pypi:`pytest-argus`
+     *last release*: Jun 24, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.4)
+
+     pyest results colection plugin
+
+  :pypi:`pytest-arraydiff`
+     *last release*: Jan 13, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.6)
+
+     pytest plugin to help with comparing array output from tests
+
+  :pypi:`pytest-asgi-server`
+     *last release*: Dec 12, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=5.4.1)
+
+     Convenient ASGI client/server fixtures for Pytest
+
+  :pypi:`pytest-asptest`
+     *last release*: Apr 28, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     test Answer Set Programming programs
+
+  :pypi:`pytest-assertcount`
+     *last release*: Oct 23, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5.0.0)
+
+     Plugin to count actual number of asserts in pytest
+
+  :pypi:`pytest-assertions`
+     *last release*: Apr 27, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest Assertions
+
+  :pypi:`pytest-assertutil`
+     *last release*: May 10, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest-assertutil
+
+  :pypi:`pytest-assert-utils`
+     *last release*: Apr 14, 2022,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Useful assertion utilities for use with pytest
+
+  :pypi:`pytest-assume`
+     *last release*: Jun 24, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=2.7)
+
+     A pytest plugin that allows multiple failures per test
+
+  :pypi:`pytest-assurka`
+     *last release*: Aug 04, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin for Assurka Studio
+
+  :pypi:`pytest-ast-back-to-python`
+     *last release*: Sep 29, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A plugin for pytest devs to view how assertion rewriting recodes the AST
+
+  :pypi:`pytest-asteroid`
+     *last release*: Aug 15, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5,<8.0.0)
+
+     PyTest plugin for docker-based testing on database images
+
+  :pypi:`pytest-astropy`
+     *last release*: Apr 12, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6)
+
+     Meta-package containing dependencies for testing
+
+  :pypi:`pytest-astropy-header`
+     *last release*: Sep 06, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.6)
+
+     pytest plugin to add diagnostic information to the header of the test output
+
+  :pypi:`pytest-ast-transformer`
+     *last release*: May 04, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-asyncio`
+     *last release*: Mar 19, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.0)
+
+     Pytest support for asyncio
+
+  :pypi:`pytest-asyncio-cooperative`
+     *last release*: May 31, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Run all your asynchronous tests cooperatively.
+
+  :pypi:`pytest-asyncio-network-simulator`
+     *last release*: Jul 31, 2018,
+     *status*: 3 - Alpha,
+     *requires*: pytest (<3.7.0,>=3.3.2)
+
+     pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests
+
+  :pypi:`pytest-async-mongodb`
+     *last release*: Oct 18, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.5.2)
+
+     pytest plugin for async MongoDB
+
+  :pypi:`pytest-async-sqlalchemy`
+     *last release*: Oct 07, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     Database testing fixtures using the SQLAlchemy asyncio API
+
+  :pypi:`pytest-atomic`
+     *last release*: Nov 24, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Skip rest of tests if previous test failed.
+
+  :pypi:`pytest-attrib`
+     *last release*: May 24, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to select tests based on attributes similar to the nose-attrib plugin
+
+  :pypi:`pytest-austin`
+     *last release*: Oct 11, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Austin plugin for pytest
+
+  :pypi:`pytest-autocap`
+     *last release*: May 15, 2022,
+     *status*: N/A,
+     *requires*: pytest (<7.2,>=7.1.2)
+
+     automatically capture test & fixture stdout/stderr to files
+
+  :pypi:`pytest-autochecklog`
+     *last release*: Apr 25, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     automatically check condition and log all the checks
+
+  :pypi:`pytest-automation`
+     *last release*: May 20, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.0.0)
+
+     pytest plugin for building a test suite, using YAML files to extend pytest parameterize functionality.
+
+  :pypi:`pytest-automock`
+     *last release*: May 16, 2023,
+     *status*: N/A,
+     *requires*: pytest ; extra == 'dev'
+
+     Pytest plugin for automatical mocks creation
+
+  :pypi:`pytest-auto-parametrize`
+     *last release*: Oct 02, 2016,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin: avoid repeating arguments in parametrize
+
+  :pypi:`pytest-autotest`
+     *last release*: Aug 25, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2.
+
+  :pypi:`pytest-aviator`
+     *last release*: Nov 04, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Aviator's Flakybot pytest plugin that automatically reruns flaky tests.
+
+  :pypi:`pytest-avoidance`
+     *last release*: May 23, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Makes pytest skip tests that don not need rerunning
+
+  :pypi:`pytest-aws`
+     *last release*: Oct 04, 2017,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin for testing AWS resource configurations
+
+  :pypi:`pytest-aws-config`
+     *last release*: May 28, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Protect your AWS credentials in unit tests
+
+  :pypi:`pytest-axe`
+     *last release*: Nov 12, 2018,
+     *status*: N/A,
+     *requires*: pytest (>=3.0.0)
+
+     pytest plugin for axe-selenium-python
+
+  :pypi:`pytest-azure`
+     *last release*: Jan 18, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Pytest utilities and mocks for Azure
+
+  :pypi:`pytest-azure-devops`
+     *last release*: Jun 20, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Simplifies using azure devops parallel strategy (https://docs.microsoft.com/en-us/azure/devops/pipelines/test/parallel-testing-any-test-runner) with pytest.
+
+  :pypi:`pytest-azurepipelines`
+     *last release*: Oct 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0.0)
+
+     Formatting PyTest output for Azure Pipelines UI
+
+  :pypi:`pytest-bandit`
+     *last release*: Feb 23, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A bandit plugin for pytest
+
+  :pypi:`pytest-bandit-xayon`
+     *last release*: Oct 17, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A bandit plugin for pytest
+
+  :pypi:`pytest-base-url`
+     *last release*: Mar 27, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0.0,<8.0.0)
+
+     pytest plugin for URL based testing
+
+  :pypi:`pytest-bdd`
+     *last release*: Nov 08, 2022,
+     *status*: 6 - Mature,
+     *requires*: pytest (>=6.2.0)
+
+     BDD for pytest
+
+  :pypi:`pytest-bdd-html`
+     *last release*: Nov 22, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (!=6.0.0,>=5.0)
+
+     pytest plugin to display BDD info in HTML test report
+
+  :pypi:`pytest-bdd-ng`
+     *last release*: Oct 06, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.0)
+
+     BDD for pytest
+
+  :pypi:`pytest-bdd-splinter`
+     *last release*: Aug 12, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.0.0)
+
+     Common steps for pytest bdd and splinter integration
+
+  :pypi:`pytest-bdd-web`
+     *last release*: Jan 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-bdd-wrappers`
+     *last release*: Feb 11, 2020,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-beakerlib`
+     *last release*: Mar 17, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A pytest plugin that reports test results to the BeakerLib framework
+
+  :pypi:`pytest-beds`
+     *last release*: Jun 07, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Fixtures for testing Google Appengine (GAE) apps
+
+  :pypi:`pytest-beeprint`
+     *last release*: Jun 09, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     use icdiff for better error messages in pytest assertions
+
+  :pypi:`pytest-bench`
+     *last release*: Jul 21, 2014,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Benchmark utility that plugs into pytest.
+
+  :pypi:`pytest-benchmark`
+     *last release*: Oct 25, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.8)
+
+     A \`\`pytest\`\` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer.
+
+  :pypi:`pytest-better-datadir`
+     *last release*: Mar 13, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A small example package
+
+  :pypi:`pytest-bg-process`
+     *last release*: Jan 24, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest plugin to initialize background process
+
+  :pypi:`pytest-bigchaindb`
+     *last release*: Jan 24, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A BigchainDB plugin for pytest.
+
+  :pypi:`pytest-bigquery-mock`
+     *last release*: Dec 28, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5.0)
+
+     Provides a mock fixture for python bigquery client
+
+  :pypi:`pytest-black`
+     *last release*: Oct 05, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin to enable format checking with black
+
+  :pypi:`pytest-black-multipy`
+     *last release*: Jan 14, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (!=3.7.3,>=3.5) ; extra == 'testing'
+
+     Allow '--black' on older Pythons
+
+  :pypi:`pytest-black-ng`
+     *last release*: Oct 20, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.0)
+
+     A pytest plugin to enable format checking with black
+
+  :pypi:`pytest-blame`
+     *last release*: May 04, 2019,
+     *status*: N/A,
+     *requires*: pytest (>=4.4.0)
+
+     A pytest plugin helps developers to debug by providing useful commits history.
+
+  :pypi:`pytest-blender`
+     *last release*: Jan 04, 2023,
+     *status*: N/A,
+     *requires*: pytest ; extra == 'dev'
+
+     Blender Pytest plugin.
+
+  :pypi:`pytest-blink1`
+     *last release*: Jan 07, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest plugin to emit notifications via the Blink(1) RGB LED
+
+  :pypi:`pytest-blockage`
+     *last release*: Dec 21, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     Disable network requests during a test run.
+
+  :pypi:`pytest-blocker`
+     *last release*: Sep 07, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to mark a test as blocker and skip all other tests
+
+  :pypi:`pytest-blue`
+     *last release*: Sep 05, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin that adds a \`blue\` fixture for printing stuff in blue.
+
+  :pypi:`pytest-board`
+     *last release*: Jan 20, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Local continuous test runner with pytest and watchdog.
+
+  :pypi:`pytest-boost-xml`
+     *last release*: Nov 30, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Plugin for pytest to generate boost xml reports
+
+  :pypi:`pytest-bootstrap`
+     *last release*: Mar 04, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-bpdb`
+     *last release*: Jan 19, 2015,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     A py.test plug-in to enable drop to bpdb debugger on test failure.
+
+  :pypi:`pytest-bravado`
+     *last release*: Feb 15, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest-bravado automatically generates from OpenAPI specification client fixtures.
+
+  :pypi:`pytest-breakword`
+     *last release*: Aug 04, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.4,<7.0.0)
+
+     Use breakword with pytest
+
+  :pypi:`pytest-breed-adapter`
+     *last release*: Nov 07, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to connect with breed-server
+
+  :pypi:`pytest-briefcase`
+     *last release*: Jun 14, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin for running tests on a Briefcase project.
+
+  :pypi:`pytest-browser`
+     *last release*: Dec 10, 2016,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     A pytest plugin for console based browser test selection just after the collection phase
+
+  :pypi:`pytest-browsermob-proxy`
+     *last release*: Jun 11, 2013,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     BrowserMob proxy plugin for py.test.
+
+  :pypi:`pytest-browserstack-local`
+     *last release*: Feb 09, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     \`\`py.test\`\` plugin to run \`\`BrowserStackLocal\`\` in background.
+
+  :pypi:`pytest-budosystems`
+     *last release*: May 07, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Budo Systems is a martial arts school management system. This module is the Budo Systems Pytest Plugin.
+
+  :pypi:`pytest-bug`
+     *last release*: Jan 29, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.0)
+
+     Pytest plugin for marking tests as a bug
+
+  :pypi:`pytest-bugtong-tag`
+     *last release*: Jan 16, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest-bugtong-tag is a plugin for pytest
+
+  :pypi:`pytest-bugzilla`
+     *last release*: May 05, 2010,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test bugzilla integration plugin
+
+  :pypi:`pytest-bugzilla-notifier`
+     *last release*: Jun 15, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.9.2)
+
+     A plugin that allows you to execute create, update, and read information from BugZilla bugs
+
+  :pypi:`pytest-buildkite`
+     *last release*: Jul 13, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Plugin for pytest that automatically publishes coverage and pytest report annotations to Buildkite.
+
+  :pypi:`pytest-builtin-types`
+     *last release*: Nov 17, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-bwrap`
+     *last release*: Oct 26, 2018,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Run your tests in Bubblewrap sandboxes
+
+  :pypi:`pytest-cache`
+     *last release*: Jun 04, 2013,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin with mechanisms for caching across test runs
+
+  :pypi:`pytest-cache-assert`
+     *last release*: Feb 26, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0.0)
+
+     Cache assertion data to simplify regression testing of complex serializable data
+
+  :pypi:`pytest-cagoule`
+     *last release*: Jan 01, 2020,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest plugin to only run tests affected by changes
+
+  :pypi:`pytest-cairo`
+     *last release*: Apr 17, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest support for cairo-lang and starknet
+
+  :pypi:`pytest-call-checker`
+     *last release*: Oct 16, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.1.3,<8.0.0)
+
+     Small pytest utility to easily create test doubles
+
+  :pypi:`pytest-camel-collect`
+     *last release*: Aug 02, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=2.9)
+
+     Enable CamelCase-aware pytest class collection
+
+  :pypi:`pytest-canonical-data`
+     *last release*: May 08, 2020,
+     *status*: 2 - Pre-Alpha,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin which allows to compare results with canonical results, based on previous runs
+
+  :pypi:`pytest-caprng`
+     *last release*: May 02, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A plugin that replays pRNG state on failure.
+
+  :pypi:`pytest-capture-deprecatedwarnings`
+     *last release*: Apr 30, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin to capture all deprecatedwarnings and put them in one file
+
+  :pypi:`pytest-capture-warnings`
+     *last release*: May 03, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest plugin to capture all warnings and put them in one file of your choice
+
+  :pypi:`pytest-cases`
+     *last release*: Feb 23, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Separate test code from test cases in pytest.
+
+  :pypi:`pytest-cassandra`
+     *last release*: Nov 04, 2017,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     Cassandra CCM Test Fixtures for pytest
+
+  :pypi:`pytest-catchlog`
+     *last release*: Jan 24, 2016,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.6)
+
+     py.test plugin to catch log messages. This is a fork of pytest-capturelog.
+
+  :pypi:`pytest-catch-server`
+     *last release*: Dec 12, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest plugin with server for catching HTTP requests.
+
+  :pypi:`pytest-celery`
+     *last release*: May 06, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest-celery a shim pytest plugin to enable celery.contrib.pytest
+
+  :pypi:`pytest-chainmaker`
+     *last release*: Oct 15, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin for chainmaker
+
+  :pypi:`pytest-chalice`
+     *last release*: Jul 01, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A set of py.test fixtures for AWS Chalice
+
+  :pypi:`pytest-change-assert`
+     *last release*: Oct 19, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     修改报错中文为英文
+
+  :pypi:`pytest-change-demo`
+     *last release*: Mar 02, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     turn . into √,turn F into x
+
+  :pypi:`pytest-change-report`
+     *last release*: Sep 14, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     turn . into √,turn F into x
+
+  :pypi:`pytest-change-xds`
+     *last release*: Apr 16, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     turn . into √,turn F into x
+
+  :pypi:`pytest-chdir`
+     *last release*: Jan 28, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=5.0.0,<6.0.0)
+
+     A pytest fixture for changing current working directory
+
+  :pypi:`pytest-check`
+     *last release*: Jun 06, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin that allows multiple failures per test.
+
+  :pypi:`pytest-checkdocs`
+     *last release*: Oct 09, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6) ; extra == 'testing'
+
+     check the README when running tests
+
+  :pypi:`pytest-checkipdb`
+     *last release*: Jul 22, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.9.2)
+
+     plugin to check if there are ipdb debugs left
+
+  :pypi:`pytest-check-library`
+     *last release*: Jul 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     check your missing library
+
+  :pypi:`pytest-check-libs`
+     *last release*: Jul 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     check your missing library
+
+  :pypi:`pytest-check-links`
+     *last release*: Jul 29, 2020,
+     *status*: N/A,
+     *requires*: pytest>=7.0
+
+     Check links in files
+
+  :pypi:`pytest-check-mk`
+     *last release*: Nov 19, 2015,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to test Check_MK checks
+
+  :pypi:`pytest-check-requirements`
+     *last release*: Feb 10, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package to prevent Dependency Confusion attacks against Yandex.
+
+  :pypi:`pytest-chic-report`
+     *last release*: Jan 31, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A pytest plugin to send a report and printing summary of tests.
+
+  :pypi:`pytest-chunks`
+     *last release*: Jul 05, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.0.0)
+
+     Run only a chunk of your test suite
+
+  :pypi:`pytest-circleci`
+     *last release*: May 03, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     py.test plugin for CircleCI
+
+  :pypi:`pytest-circleci-parallelized`
+     *last release*: Oct 20, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Parallelize pytest across CircleCI workers.
+
+  :pypi:`pytest-circleci-parallelized-rjp`
+     *last release*: Jun 21, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Parallelize pytest across CircleCI workers.
+
+  :pypi:`pytest-ckan`
+     *last release*: Apr 28, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Backport of CKAN 2.9 pytest plugin and fixtures to CAKN 2.8
+
+  :pypi:`pytest-clarity`
+     *last release*: Jun 11, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     A plugin providing an alternative, colourful diff output for failing assertions.
+
+  :pypi:`pytest-cldf`
+     *last release*: Nov 07, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.6)
+
+     Easy quality control for CLDF datasets using pytest
+
+  :pypi:`pytest-click`
+     *last release*: Feb 11, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     Pytest plugin for Click
+
+  :pypi:`pytest-cli-fixtures`
+     *last release*: Jul 28, 2022,
+     *status*: N/A,
+     *requires*: pytest (~=7.0)
+
+     Automatically register fixtures for custom CLI arguments
+
+  :pypi:`pytest-clld`
+     *last release*: Jul 06, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.6)
+
+
+
+  :pypi:`pytest-cloud`
+     *last release*: Oct 05, 2020,
+     *status*: 6 - Mature,
+     *requires*: N/A
+
+     Distributed tests planner plugin for pytest testing framework.
+
+  :pypi:`pytest-cloudflare-worker`
+     *last release*: Mar 30, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     pytest plugin for testing cloudflare workers
+
+  :pypi:`pytest-cloudist`
+     *last release*: Sep 02, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+     Distribute tests to cloud machines without fuss
+
+  :pypi:`pytest-cmake`
+     *last release*: Jan 21, 2023,
+     *status*: N/A,
+     *requires*: pytest<8,>=4
+
+     Provide CMake module for Pytest
+
+  :pypi:`pytest-cmake-presets`
+     *last release*: Dec 26, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+     Execute CMake Presets via pytest
+
+  :pypi:`pytest-cobra`
+     *last release*: Jun 29, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (<4.0.0,>=3.7.1)
+
+     PyTest plugin for testing Smart Contracts for Ethereum blockchain.
+
+  :pypi:`pytest-codecarbon`
+     *last release*: Jun 15, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest plugin for measuring carbon emissions
+
+  :pypi:`pytest-codecheckers`
+     *last release*: Feb 13, 2010,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin to add source code sanity checks (pep8 and friends)
+
+  :pypi:`pytest-codecov`
+     *last release*: Nov 29, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.6.0)
+
+     Pytest plugin for uploading pytest-cov results to codecov.io
+
+  :pypi:`pytest-codegen`
+     *last release*: Aug 23, 2020,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     Automatically create pytest test signatures
+
+  :pypi:`pytest-codeowners`
+     *last release*: Mar 30, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     Pytest plugin for selecting tests by GitHub CODEOWNERS.
+
+  :pypi:`pytest-codestyle`
+     *last release*: Mar 23, 2020,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to run pycodestyle
+
+  :pypi:`pytest-codspeed`
+     *last release*: Dec 02, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=3.8
+
+     Pytest plugin to create CodSpeed benchmarks
+
+  :pypi:`pytest-collect-formatter`
+     *last release*: Mar 29, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Formatter for pytest collect output
+
+  :pypi:`pytest-collect-formatter2`
+     *last release*: May 31, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Formatter for pytest collect output
+
+  :pypi:`pytest-collector`
+     *last release*: Aug 02, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.0,<8.0)
+
+     Python package for collecting pytest.
+
+  :pypi:`pytest-colordots`
+     *last release*: Oct 06, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Colorizes the progress indicators
+
+  :pypi:`pytest-commander`
+     *last release*: Aug 17, 2021,
+     *status*: N/A,
+     *requires*: pytest (<7.0.0,>=6.2.4)
+
+     An interactive GUI test runner for PyTest
+
+  :pypi:`pytest-common-subject`
+     *last release*: May 15, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.6,<8)
+
+     pytest framework for testing different aspects of a common method
+
+  :pypi:`pytest-compare`
+     *last release*: Mar 30, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for comparing call arguments.
+
+  :pypi:`pytest-concurrent`
+     *last release*: Jan 12, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     Concurrently execute test cases with multithread, multiprocess and gevent
+
+  :pypi:`pytest-config`
+     *last release*: Nov 07, 2014,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Base configurations and utilities for developing    your Python project test suite with pytest.
+
+  :pypi:`pytest-confluence-report`
+     *last release*: Apr 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Package stands for pytest plugin to upload results into Confluence page.
+
+  :pypi:`pytest-console-scripts`
+     *last release*: May 31, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.0.0)
+
+     Pytest plugin for testing console scripts
+
+  :pypi:`pytest-consul`
+     *last release*: Nov 24, 2018,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin with fixtures for testing consul aware apps
+
+  :pypi:`pytest-container`
+     *last release*: Mar 21, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.10)
+
+     Pytest fixtures for writing container based tests
+
+  :pypi:`pytest-contextfixture`
+     *last release*: Mar 12, 2013,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Define pytest fixtures as context managers.
+
+  :pypi:`pytest-contexts`
+     *last release*: May 19, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A plugin to run tests written with the Contexts framework using pytest
+
+  :pypi:`pytest-cookies`
+     *last release*: Mar 22, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.9.0)
+
+     The pytest plugin for your Cookiecutter templates. 🍪
+
+  :pypi:`pytest-couchdbkit`
+     *last release*: Apr 17, 2012,
+     *status*: N/A,
+     *requires*: N/A
+
+     py.test extension for per-test couchdb databases using couchdbkit
+
+  :pypi:`pytest-count`
+     *last release*: Jan 12, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     count erros and send email
+
+  :pypi:`pytest-cov`
+     *last release*: May 24, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin for measuring coverage.
+
+  :pypi:`pytest-cover`
+     *last release*: Aug 01, 2015,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest plugin for measuring coverage. Forked from \`pytest-cov\`.
+
+  :pypi:`pytest-coverage`
+     *last release*: Jun 17, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-coverage-context`
+     *last release*: Jan 04, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.1.0)
+
+     Coverage dynamic context support for PyTest, including sub-processes
+
+  :pypi:`pytest-coveragemarkers`
+     *last release*: Nov 29, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+     Using pytest markers to track functional coverage and filtering of tests
+
+  :pypi:`pytest-cov-exclude`
+     *last release*: Apr 29, 2016,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.0,<2.9.0); extra == 'dev'
+
+     Pytest plugin for excluding tests based on coverage data
+
+  :pypi:`pytest-cpp`
+     *last release*: Jan 30, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.0)
+
+     Use pytest's runner to discover and execute C++ tests
+
+  :pypi:`pytest-cppython`
+     *last release*: Jun 14, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin that imports CPPython testing types
+
+  :pypi:`pytest-cqase`
+     *last release*: Aug 22, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+     Custom qase pytest plugin
+
+  :pypi:`pytest-cram`
+     *last release*: Aug 08, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Run cram tests with pytest.
+
+  :pypi:`pytest-crate`
+     *last release*: May 28, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.0)
+
+     Manages CrateDB instances during your integration tests
+
+  :pypi:`pytest-crayons`
+     *last release*: Mar 19, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin for colorful print statements
+
+  :pypi:`pytest-create`
+     *last release*: Feb 15, 2023,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     pytest-create
+
+  :pypi:`pytest-cricri`
+     *last release*: Jan 27, 2018,
+     *status*: N/A,
+     *requires*: pytest
+
+     A Cricri plugin for pytest.
+
+  :pypi:`pytest-crontab`
+     *last release*: Dec 09, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     add crontab task in crontab
+
+  :pypi:`pytest-csv`
+     *last release*: Apr 22, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=6.0)
+
+     CSV output for pytest.
+
+  :pypi:`pytest-csv-params`
+     *last release*: Aug 28, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+     Pytest plugin for Test Case Parametrization with CSV files
+
+  :pypi:`pytest-curio`
+     *last release*: Oct 07, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest support for curio.
+
+  :pypi:`pytest-curl-report`
+     *last release*: Dec 11, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to generate curl command line report
+
+  :pypi:`pytest-custom-concurrency`
+     *last release*: Feb 08, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Custom grouping concurrence for pytest
+
+  :pypi:`pytest-custom-exit-code`
+     *last release*: Aug 07, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.0.2)
+
+     Exit pytest test session with custom exit code in different scenarios
+
+  :pypi:`pytest-custom-nodeid`
+     *last release*: Mar 07, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Custom grouping for pytest-xdist, rename test cases name and test cases nodeid, support allure report
+
+  :pypi:`pytest-custom-report`
+     *last release*: Jan 30, 2019,
+     *status*: N/A,
+     *requires*: pytest
+
+     Configure the symbols displayed for test outcomes
+
+  :pypi:`pytest-custom-scheduling`
+     *last release*: Mar 01, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Custom grouping for pytest-xdist, rename test cases name and test cases nodeid, support allure report
+
+  :pypi:`pytest-cython`
+     *last release*: Feb 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6.0)
+
+     A plugin for testing Cython extension modules
+
+  :pypi:`pytest-cython-collect`
+     *last release*: Jun 17, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-darker`
+     *last release*: Aug 16, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=6.0.1) ; extra == 'test'
+
+     A pytest plugin for checking of modified code using Darker
+
+  :pypi:`pytest-dash`
+     *last release*: Mar 18, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest fixtures to run dash applications.
+
+  :pypi:`pytest-data`
+     *last release*: Nov 01, 2016,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Useful functions for managing data for pytest fixtures
+
+  :pypi:`pytest-databricks`
+     *last release*: Jul 29, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest plugin for remote Databricks notebooks testing
+
+  :pypi:`pytest-datadir`
+     *last release*: Oct 25, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     pytest plugin for test data directories and files
+
+  :pypi:`pytest-datadir-mgr`
+     *last release*: Apr 06, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.1)
+
+     Manager for test data: downloads, artifact caching, and a tmpdir context.
+
+  :pypi:`pytest-datadir-ng`
+     *last release*: Dec 25, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem.
+
+  :pypi:`pytest-datadir-nng`
+     *last release*: Nov 09, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.0.0,<8.0.0)
+
+     Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem.
+
+  :pypi:`pytest-data-extractor`
+     *last release*: Jul 19, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.0.1)
+
+     A pytest plugin to extract relevant metadata about tests into an external file (currently only json support)
+
+  :pypi:`pytest-data-file`
+     *last release*: Dec 04, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Fixture "data" and "case_data" for test from yaml file
+
+  :pypi:`pytest-datafiles`
+     *last release*: Feb 24, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.6)
+
+     py.test plugin to create a 'tmp_path' containing predefined files/directories.
+
+  :pypi:`pytest-datafixtures`
+     *last release*: Dec 05, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Data fixtures for pytest made simple
+
+  :pypi:`pytest-data-from-files`
+     *last release*: Oct 13, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to provide data from files loaded automatically
+
+  :pypi:`pytest-dataplugin`
+     *last release*: Sep 16, 2017,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     A pytest plugin for managing an archive of test data.
+
+  :pypi:`pytest-datarecorder`
+     *last release*: Jan 08, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A py.test plugin recording and comparing test output.
+
+  :pypi:`pytest-dataset`
+     *last release*: May 01, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Plugin for loading different datasets for pytest by prefix from json or yaml files
+
+  :pypi:`pytest-data-suites`
+     *last release*: Jul 24, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.0,<8.0)
+
+     Class-based pytest parametrization
+
+  :pypi:`pytest-datatest`
+     *last release*: Oct 15, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.3)
+
+     A pytest plugin for test driven data-wrangling (this is the development version of datatest's pytest integration).
+
+  :pypi:`pytest-db`
+     *last release*: Dec 04, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Session scope fixture "db" for mysql query or change
+
+  :pypi:`pytest-dbfixtures`
+     *last release*: Dec 07, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Databases fixtures plugin for py.test.
+
+  :pypi:`pytest-db-plugin`
+     *last release*: Nov 27, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=5.0)
+
+
+
+  :pypi:`pytest-dbt`
+     *last release*: Jun 08, 2023,
+     *status*: 2 - Pre-Alpha,
+     *requires*: pytest (>=7.0.0,<8.0.0)
+
+     Unit test dbt models with standard python tooling
+
+  :pypi:`pytest-dbt-adapter`
+     *last release*: Nov 24, 2021,
+     *status*: N/A,
+     *requires*: pytest (<7,>=6)
+
+     A pytest plugin for testing dbt adapter plugins
+
+  :pypi:`pytest-dbt-conventions`
+     *last release*: Mar 02, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5,<7.0.0)
+
+     A pytest plugin for linting a dbt project's conventions
+
+  :pypi:`pytest-dbt-core`
+     *last release*: May 03, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5) ; extra == 'test'
+
+     Pytest extension for dbt.
+
+  :pypi:`pytest-dbus-notification`
+     *last release*: Mar 05, 2014,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     D-BUS notifications for pytest results.
+
+  :pypi:`pytest-dbx`
+     *last release*: Nov 29, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.3,<8.0.0)
+
+     Pytest plugin to run unit tests for dbx (Databricks CLI extensions) related code
+
+  :pypi:`pytest-deadfixtures`
+     *last release*: Jul 23, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A simple plugin to list unused fixtures in pytest
+
+  :pypi:`pytest-deepcov`
+     *last release*: Mar 30, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     deepcov
+
+  :pypi:`pytest-defer`
+     *last release*: Aug 24, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-demo-plugin`
+     *last release*: May 15, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest示例插件
+
+  :pypi:`pytest-dependency`
+     *last release*: Feb 14, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Manage dependencies of tests
+
+  :pypi:`pytest-depends`
+     *last release*: Apr 05, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3)
+
+     Tests that depend on other tests
+
+  :pypi:`pytest-deprecate`
+     *last release*: Jul 01, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Mark tests as testing a deprecated feature with a warning note.
+
+  :pypi:`pytest-describe`
+     *last release*: Apr 09, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (<8,>=4.6)
+
+     Describe-style plugin for pytest
+
+  :pypi:`pytest-describe-it`
+     *last release*: Jul 19, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     plugin for rich text descriptions
+
+  :pypi:`pytest-devpi-server`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     DevPI server fixture for py.test
+
+  :pypi:`pytest-dhos`
+     *last release*: Sep 07, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Common fixtures for pytest in DHOS services and libraries
+
+  :pypi:`pytest-diamond`
+     *last release*: Aug 31, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin for diamond
+
+  :pypi:`pytest-dicom`
+     *last release*: Dec 19, 2018,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin to provide DICOM fixtures
+
+  :pypi:`pytest-dictsdiff`
+     *last release*: Jul 26, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-diff`
+     *last release*: Mar 30, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-diffeo`
+     *last release*: Feb 10, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package to prevent Dependency Confusion attacks against Yandex.
+
+  :pypi:`pytest-diff-selector`
+     *last release*: Feb 24, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.2) ; extra == 'all'
+
+     Get tests affected by code changes (using git)
+
+  :pypi:`pytest-difido`
+     *last release*: Oct 23, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.0.0)
+
+     PyTest plugin for generating Difido reports
+
+  :pypi:`pytest-disable`
+     *last release*: Sep 10, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to disable a test and skip it from testrun
+
+  :pypi:`pytest-disable-plugin`
+     *last release*: Feb 28, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Disable plugins per test
+
+  :pypi:`pytest-discord`
+     *last release*: Feb 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (!=6.0.0,<8,>=3.3.2)
+
+     A pytest plugin to notify test results to a Discord channel.
+
+  :pypi:`pytest-django`
+     *last release*: Dec 07, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.4.0)
+
+     A Django plugin for pytest.
+
+  :pypi:`pytest-django-ahead`
+     *last release*: Oct 27, 2016,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.9)
+
+     A Django plugin for pytest.
+
+  :pypi:`pytest-djangoapp`
+     *last release*: May 19, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Nice pytest plugin to help you with Django pluggable application testing.
+
+  :pypi:`pytest-django-cache-xdist`
+     *last release*: May 12, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A djangocachexdist plugin for pytest
+
+  :pypi:`pytest-django-casperjs`
+     *last release*: Mar 15, 2015,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     Integrate CasperJS with your django tests as a pytest fixture.
+
+  :pypi:`pytest-django-dotenv`
+     *last release*: Nov 26, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.6.0)
+
+     Pytest plugin used to setup environment variables with django-dotenv
+
+  :pypi:`pytest-django-factories`
+     *last release*: Nov 12, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Factories for your Django models that can be used as Pytest fixtures.
+
+  :pypi:`pytest-django-filefield`
+     *last release*: May 09, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest >= 5.2
+
+     Replaces FileField.storage with something you can patch globally.
+
+  :pypi:`pytest-django-gcir`
+     *last release*: Mar 06, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A Django plugin for pytest.
+
+  :pypi:`pytest-django-haystack`
+     *last release*: Sep 03, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.3.4)
+
+     Cleanup your Haystack indexes between tests
+
+  :pypi:`pytest-django-ifactory`
+     *last release*: Jun 06, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A model instance factory for pytest-django
+
+  :pypi:`pytest-django-lite`
+     *last release*: Jan 30, 2014,
+     *status*: N/A,
+     *requires*: N/A
+
+     The bare minimum to integrate py.test with Django.
+
+  :pypi:`pytest-django-liveserver-ssl`
+     *last release*: Jan 20, 2022,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-django-model`
+     *last release*: Feb 14, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A Simple Way to Test your Django Models
+
+  :pypi:`pytest-django-ordering`
+     *last release*: Jul 25, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.3.0)
+
+     A pytest plugin for preserving the order in which Django runs tests.
+
+  :pypi:`pytest-django-queries`
+     *last release*: Mar 01, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Generate performance reports from your django database performance tests.
+
+  :pypi:`pytest-djangorestframework`
+     *last release*: Aug 11, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A djangorestframework plugin for pytest
+
+  :pypi:`pytest-django-rq`
+     *last release*: Apr 13, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin to help writing unit test for django-rq
+
+  :pypi:`pytest-django-sqlcounts`
+     *last release*: Jun 16, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin for reporting the number of SQLs executed per django testcase.
+
+  :pypi:`pytest-django-testing-postgresql`
+     *last release*: Jan 31, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Use a temporary PostgreSQL database with pytest-django
+
+  :pypi:`pytest-doc`
+     *last release*: Jun 28, 2015,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A documentation plugin for py.test.
+
+  :pypi:`pytest-docfiles`
+     *last release*: Dec 22, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.7.0)
+
+     pytest plugin to test codeblocks in your documentation.
+
+  :pypi:`pytest-docgen`
+     *last release*: Apr 17, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     An RST Documentation Generator for pytest-based test suites
+
+  :pypi:`pytest-docker`
+     *last release*: Sep 14, 2022,
+     *status*: N/A,
+     *requires*: pytest (<8.0,>=4.0)
+
+     Simple pytest fixtures for Docker and docker-compose based tests
+
+  :pypi:`pytest-docker-apache-fixtures`
+     *last release*: Feb 16, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with apache2 (httpd).
+
+  :pypi:`pytest-docker-butla`
+     *last release*: Jun 16, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-dockerc`
+     *last release*: Oct 09, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0)
+
+     Run, manage and stop Docker Compose project from Docker API
+
+  :pypi:`pytest-docker-compose`
+     *last release*: Jan 26, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.3)
+
+     Manages Docker containers during your integration tests
+
+  :pypi:`pytest-docker-db`
+     *last release*: Mar 20, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.1.1)
+
+     A plugin to use docker databases for pytests
+
+  :pypi:`pytest-docker-fixtures`
+     *last release*: May 02, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest docker fixtures
+
+  :pypi:`pytest-docker-git-fixtures`
+     *last release*: Feb 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with git scm.
+
+  :pypi:`pytest-docker-haproxy-fixtures`
+     *last release*: Feb 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with haproxy.
+
+  :pypi:`pytest-docker-pexpect`
+     *last release*: Jan 14, 2019,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest plugin for writing functional tests with pexpect and docker
+
+  :pypi:`pytest-docker-postgresql`
+     *last release*: Sep 24, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-docker-py`
+     *last release*: Nov 27, 2018,
+     *status*: N/A,
+     *requires*: pytest (==4.0.0)
+
+     Easy to use, simple to extend, pytest plugin that minimally leverages docker-py.
+
+  :pypi:`pytest-docker-registry-fixtures`
+     *last release*: Apr 08, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with docker registries.
+
+  :pypi:`pytest-docker-service`
+     *last release*: Feb 22, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=7.1.3)
+
+     pytest plugin to start docker container
+
+  :pypi:`pytest-docker-squid-fixtures`
+     *last release*: Feb 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with squid.
+
+  :pypi:`pytest-docker-tools`
+     *last release*: Feb 17, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.1)
+
+     Docker integration tests for pytest
+
+  :pypi:`pytest-docs`
+     *last release*: Nov 11, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Documentation tool for pytest
+
+  :pypi:`pytest-docstyle`
+     *last release*: Mar 23, 2020,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to run pydocstyle
+
+  :pypi:`pytest-doctest-custom`
+     *last release*: Jul 25, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A py.test plugin for customizing string representations of doctest results.
+
+  :pypi:`pytest-doctest-ellipsis-markers`
+     *last release*: Jan 12, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Setup additional values for ELLIPSIS_MARKER for doctests
+
+  :pypi:`pytest-doctest-import`
+     *last release*: Nov 13, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.3.0)
+
+     A simple pytest plugin to import names and add them to the doctest namespace.
+
+  :pypi:`pytest-doctestplus`
+     *last release*: Jun 08, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin with advanced doctest features.
+
+  :pypi:`pytest-dolphin`
+     *last release*: Nov 30, 2016,
+     *status*: 4 - Beta,
+     *requires*: pytest (==3.0.4)
+
+     Some extra stuff that we use ininternally
+
+  :pypi:`pytest-doorstop`
+     *last release*: Jun 09, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin for adding test results into doorstop items.
+
+  :pypi:`pytest-dotenv`
+     *last release*: Jun 16, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.0.0)
+
+     A py.test plugin that parses environment files before running tests
+
+  :pypi:`pytest-draw`
+     *last release*: Mar 21, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Pytest plugin for randomly selecting a specific number of tests
+
+  :pypi:`pytest-drf`
+     *last release*: Jul 12, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.7)
+
+     A Django REST framework plugin for pytest.
+
+  :pypi:`pytest-drivings`
+     *last release*: Jan 13, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Tool to allow webdriver automation to be ran locally or remotely
+
+  :pypi:`pytest-drop-dup-tests`
+     *last release*: May 23, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.7)
+
+     A Pytest plugin to drop duplicated tests during collection
+
+  :pypi:`pytest-dummynet`
+     *last release*: Dec 15, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A py.test plugin providing access to a dummynet.
+
+  :pypi:`pytest-dump2json`
+     *last release*: Jun 29, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin for dumping test results to json.
+
+  :pypi:`pytest-duration-insights`
+     *last release*: Jun 25, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-durations`
+     *last release*: Apr 22, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin reporting fixtures and test functions execution time.
+
+  :pypi:`pytest-dynamicrerun`
+     *last release*: Aug 15, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin to rerun tests dynamically based off of test outcome and output.
+
+  :pypi:`pytest-dynamodb`
+     *last release*: Jun 12, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     DynamoDB fixtures for pytest
+
+  :pypi:`pytest-easy-addoption`
+     *last release*: Jan 22, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest-easy-addoption: Easy way to work with pytest addoption
+
+  :pypi:`pytest-easy-api`
+     *last release*: Mar 26, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     Simple API testing with pytest
+
+  :pypi:`pytest-easyMPI`
+     *last release*: Oct 21, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Package that supports mpi tests in pytest
+
+  :pypi:`pytest-easyread`
+     *last release*: Nov 17, 2017,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin that makes terminal printouts of the reports easier to read
+
+  :pypi:`pytest-easy-server`
+     *last release*: May 01, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (<5.0.0,>=4.3.1) ; python_version < "3.5"
+
+     Pytest plugin for easy testing against servers
+
+  :pypi:`pytest-ebics-sandbox`
+     *last release*: Aug 15, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin for testing against an EBICS sandbox server. Requires docker.
+
+  :pypi:`pytest-ec2`
+     *last release*: Oct 22, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest execution on EC2 instance
+
+  :pypi:`pytest-echo`
+     *last release*: Jan 08, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin with mechanisms for echoing environment variables, package version and generic attributes
+
+  :pypi:`pytest-ekstazi`
+     *last release*: Sep 10, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest plugin to select test using Ekstazi algorithm
+
+  :pypi:`pytest-elasticsearch`
+     *last release*: Mar 01, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.0)
+
+     Elasticsearch fixtures and fixture factories for Pytest.
+
+  :pypi:`pytest-elements`
+     *last release*: Jan 13, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=5.4,<6.0)
+
+     Tool to help automate user interfaces
+
+  :pypi:`pytest-eliot`
+     *last release*: Aug 31, 2022,
+     *status*: 1 - Planning,
+     *requires*: pytest (>=5.4.0)
+
+     An eliot plugin for pytest.
+
+  :pypi:`pytest-elk-reporter`
+     *last release*: Jan 24, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-email`
+     *last release*: Jul 08, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Send execution result email
+
+  :pypi:`pytest-embedded`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7.0
+
+     A pytest plugin that designed for embedded testing.
+
+  :pypi:`pytest-embedded-arduino`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Make pytest-embedded plugin work with Arduino.
+
+  :pypi:`pytest-embedded-idf`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Make pytest-embedded plugin work with ESP-IDF.
+
+  :pypi:`pytest-embedded-jtag`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Make pytest-embedded plugin work with JTAG.
+
+  :pypi:`pytest-embedded-qemu`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Make pytest-embedded plugin work with QEMU.
+
+  :pypi:`pytest-embedded-serial`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Make pytest-embedded plugin work with Serial.
+
+  :pypi:`pytest-embedded-serial-esp`
+     *last release*: Jun 14, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Make pytest-embedded plugin work with Espressif target boards.
+
+  :pypi:`pytest-embrace`
+     *last release*: Mar 25, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.0,<8.0)
+
+     💝  Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate.
+
+  :pypi:`pytest-emoji`
+     *last release*: Feb 19, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.2.1)
+
+     A pytest plugin that adds emojis to your test result report
+
+  :pypi:`pytest-emoji-output`
+     *last release*: Apr 09, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (==7.0.1)
+
+     Pytest plugin to represent test output with emoji support
+
+  :pypi:`pytest-enabler`
+     *last release*: May 12, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6) ; extra == 'testing'
+
+     Enable installed pytest plugins
+
+  :pypi:`pytest-encode`
+     *last release*: Nov 06, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     set your encoding and logger
+
+  :pypi:`pytest-encode-kane`
+     *last release*: Nov 16, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     set your encoding and logger
+
+  :pypi:`pytest-enhanced-reports`
+     *last release*: Dec 15, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Enhanced test reports for pytest
+
+  :pypi:`pytest-enhancements`
+     *last release*: Oct 30, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Improvements for pytest (rejected upstream)
+
+  :pypi:`pytest-env`
+     *last release*: Jun 15, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7.3.1
+
+     py.test plugin that allows you to add environment variables.
+
+  :pypi:`pytest-envfiles`
+     *last release*: Oct 08, 2015,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     A py.test plugin that parses environment files before running tests
+
+  :pypi:`pytest-env-info`
+     *last release*: Nov 25, 2017,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     Push information about the running pytest into envvars
+
+  :pypi:`pytest-envraw`
+     *last release*: Aug 27, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.6.0)
+
+     py.test plugin that allows you to add environment variables.
+
+  :pypi:`pytest-envvars`
+     *last release*: Jun 13, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0.0)
+
+     Pytest plugin to validate use of envvars on your tests
+
+  :pypi:`pytest-env-yaml`
+     *last release*: Apr 02, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-eradicate`
+     *last release*: Sep 08, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=2.4.2)
+
+     pytest plugin to check for commented out code
+
+  :pypi:`pytest-error-for-skips`
+     *last release*: Dec 19, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin to treat skipped tests a test failure
+
+  :pypi:`pytest-eth`
+     *last release*: Aug 14, 2020,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM).
+
+  :pypi:`pytest-ethereum`
+     *last release*: Jun 24, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (==3.3.2); extra == 'dev'
+
+     pytest-ethereum: Pytest library for ethereum projects.
+
+  :pypi:`pytest-eucalyptus`
+     *last release*: Jun 28, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=4.2.0)
+
+     Pytest Plugin for BDD
+
+  :pypi:`pytest-eventlet`
+     *last release*: Oct 04, 2021,
+     *status*: N/A,
+     *requires*: pytest ; extra == 'dev'
+
+     Applies eventlet monkey-patch as a pytest plugin.
+
+  :pypi:`pytest-examples`
+     *last release*: May 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest>=7
+
+     Pytest plugin for testing examples in docstrings and markdown files.
+
+  :pypi:`pytest-excel`
+     *last release*: Jan 31, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for generating excel reports
+
+  :pypi:`pytest-exceptional`
+     *last release*: Mar 16, 2017,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Better exceptions
+
+  :pypi:`pytest-exception-script`
+     *last release*: Aug 04, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Walk your code through exception script to check it's resiliency to failures.
+
+  :pypi:`pytest-executable`
+     *last release*: Mar 25, 2023,
+     *status*: N/A,
+     *requires*: pytest (<8,>=4.3)
+
+     pytest plugin for testing executables
+
+  :pypi:`pytest-execution-timer`
+     *last release*: Dec 24, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A timer for the phases of Pytest's execution.
+
+  :pypi:`pytest-expect`
+     *last release*: Apr 21, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to store test expectations and mark tests based on them
+
+  :pypi:`pytest-expectdir`
+     *last release*: Mar 19, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one
+
+  :pypi:`pytest-expecter`
+     *last release*: Sep 18, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Better testing with expecter and pytest.
+
+  :pypi:`pytest-expectr`
+     *last release*: Oct 05, 2018,
+     *status*: N/A,
+     *requires*: pytest (>=2.4.2)
+
+     This plugin is used to expect multiple assert using pytest framework.
+
+  :pypi:`pytest-expect-test`
+     *last release*: Apr 10, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A fixture to support expect tests in pytest
+
+  :pypi:`pytest-experiments`
+     *last release*: Dec 13, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.5,<7.0.0)
+
+     A pytest plugin to help developers of research-oriented software projects keep track of the results of their numerical experiments.
+
+  :pypi:`pytest-explicit`
+     *last release*: Jun 15, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A Pytest plugin to ignore certain marked tests by default
+
+  :pypi:`pytest-exploratory`
+     *last release*: Feb 21, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2)
+
+     Interactive console for pytest.
+
+  :pypi:`pytest-extensions`
+     *last release*: Aug 17, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest ; extra == 'testing'
+
+     A collection of helpers for pytest to ease testing
+
+  :pypi:`pytest-external-blockers`
+     *last release*: Oct 05, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     a special outcome for tests that are blocked for external reasons
+
+  :pypi:`pytest-extra-durations`
+     *last release*: Apr 21, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin to get durations on a per-function basis and per module basis.
+
+  :pypi:`pytest-extra-markers`
+     *last release*: Mar 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Additional pytest markers to dynamically enable/disable tests viia CLI flags
+
+  :pypi:`pytest-fabric`
+     *last release*: Sep 12, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Provides test utilities to run fabric task tests by using docker containers
+
+  :pypi:`pytest-factor`
+     *last release*: Feb 10, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package to prevent Dependency Confusion attacks against Yandex.
+
+  :pypi:`pytest-factory`
+     *last release*: Sep 06, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>4.3)
+
+     Use factories for test setup with py.test
+
+  :pypi:`pytest-factoryboy`
+     *last release*: Dec 01, 2022,
+     *status*: 6 - Mature,
+     *requires*: pytest (>=5.0.0)
+
+     Factory Boy support for pytest.
+
+  :pypi:`pytest-factoryboy-fixtures`
+     *last release*: Jun 25, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Generates pytest fixtures that allow the use of type hinting
+
+  :pypi:`pytest-factoryboy-state`
+     *last release*: Mar 22, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     Simple factoryboy random state management
+
+  :pypi:`pytest-failed-screen-record`
+     *last release*: Jan 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.1.2d,<8.0.0)
+
+     Create a video of the screen when pytest fails
+
+  :pypi:`pytest-failed-screenshot`
+     *last release*: Apr 21, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Test case fails,take a screenshot,save it,attach it to the allure
+
+  :pypi:`pytest-failed-to-verify`
+     *last release*: Aug 08, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.1.0)
+
+     A pytest plugin that helps better distinguishing real test failures from setup flakiness.
+
+  :pypi:`pytest-fail-slow`
+     *last release*: Aug 13, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0)
+
+     Fail tests that take too long to run
+
+  :pypi:`pytest-faker`
+     *last release*: Dec 19, 2016,
+     *status*: 6 - Mature,
+     *requires*: N/A
+
+     Faker integration with the pytest framework.
+
+  :pypi:`pytest-falcon`
+     *last release*: Sep 07, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest helpers for Falcon.
+
+  :pypi:`pytest-falcon-client`
+     *last release*: Mar 19, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest \`client\` fixture for the Falcon Framework
+
+  :pypi:`pytest-fantasy`
+     *last release*: Mar 14, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin for Flask Fantasy Framework
+
+  :pypi:`pytest-fastapi`
+     *last release*: Dec 27, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-fastapi-deps`
+     *last release*: Jul 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A fixture which allows easy replacement of fastapi dependencies for testing
+
+  :pypi:`pytest-fastest`
+     *last release*: Jun 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.4)
+
+     Use SCM and coverage to run only needed tests
+
+  :pypi:`pytest-fast-first`
+     *last release*: Jan 19, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Pytest plugin that runs fast tests first
+
+  :pypi:`pytest-faulthandler`
+     *last release*: Jul 04, 2019,
+     *status*: 6 - Mature,
+     *requires*: pytest (>=5.0)
+
+     py.test plugin that activates the fault handler module for tests (dummy package)
+
+  :pypi:`pytest-fauxfactory`
+     *last release*: Dec 06, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.2)
+
+     Integration of fauxfactory into pytest.
+
+  :pypi:`pytest-figleaf`
+     *last release*: Jan 18, 2010,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     py.test figleaf coverage plugin
+
+  :pypi:`pytest-filecov`
+     *last release*: Jun 27, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A pytest plugin to detect unused files
+
+  :pypi:`pytest-filedata`
+     *last release*: Jan 17, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     easily load data from files
+
+  :pypi:`pytest-filemarker`
+     *last release*: Dec 01, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin that runs marked tests when files change.
+
+  :pypi:`pytest-file-watcher`
+     *last release*: Mar 23, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest-File-Watcher is a CLI tool that watches for changes in your code and runs pytest on the changed files.
+
+  :pypi:`pytest-filter-case`
+     *last release*: Nov 05, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     run test cases filter by mark
+
+  :pypi:`pytest-filter-subpackage`
+     *last release*: Dec 12, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0)
+
+     Pytest plugin for filtering based on sub-packages
+
+  :pypi:`pytest-find-dependencies`
+     *last release*: Apr 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.3.0)
+
+     A pytest plugin to find dependencies between tests
+
+  :pypi:`pytest-finer-verdicts`
+     *last release*: Jun 18, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=5.4.3)
+
+     A pytest plugin to treat non-assertion failures as test errors.
+
+  :pypi:`pytest-firefox`
+     *last release*: Aug 08, 2017,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0.2)
+
+     pytest plugin to manipulate firefox
+
+  :pypi:`pytest-fixture-classes`
+     *last release*: Jan 20, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Fixtures as classes that work well with dependency injection, autocompletetion, type checkers, and language servers
+
+  :pypi:`pytest-fixture-config`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Fixture configuration utils for py.test
+
+  :pypi:`pytest-fixture-maker`
+     *last release*: Sep 21, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin to load fixtures from YAML files
+
+  :pypi:`pytest-fixture-marker`
+     *last release*: Oct 11, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A pytest plugin to add markers based on fixtures used.
+
+  :pypi:`pytest-fixture-order`
+     *last release*: May 16, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0)
+
+     pytest plugin to control fixture evaluation order
+
+  :pypi:`pytest-fixture-ref`
+     *last release*: Nov 17, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Lets users reference fixtures without name matching magic.
+
+  :pypi:`pytest-fixture-rtttg`
+     *last release*: Feb 23, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.0.1,<8.0.0)
+
+     Warn or fail on fixture name clash
+
+  :pypi:`pytest-fixtures`
+     *last release*: May 01, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Common fixtures for pytest
+
+  :pypi:`pytest-fixture-tools`
+     *last release*: Aug 18, 2020,
+     *status*: 6 - Mature,
+     *requires*: pytest
+
+     Plugin for pytest which provides tools for fixtures
+
+  :pypi:`pytest-fixture-typecheck`
+     *last release*: Aug 24, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin to assert type annotations at runtime.
+
+  :pypi:`pytest-flake8`
+     *last release*: Mar 18, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0)
+
+     pytest plugin to check FLAKE8 requirements
+
+  :pypi:`pytest-flake8-path`
+     *last release*: Jun 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A pytest fixture for testing flake8 plugins.
+
+  :pypi:`pytest-flake8-v2`
+     *last release*: Mar 01, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.0)
+
+     pytest plugin to check FLAKE8 requirements
+
+  :pypi:`pytest-flakefinder`
+     *last release*: Oct 26, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.7.1)
+
+     Runs tests multiple times to expose flakiness.
+
+  :pypi:`pytest-flakes`
+     *last release*: Dec 02, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5)
+
+     pytest plugin to check source code with pyflakes
+
+  :pypi:`pytest-flaptastic`
+     *last release*: Mar 17, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Flaptastic py.test plugin
+
+  :pypi:`pytest-flask`
+     *last release*: Feb 27, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.2)
+
+     A set of py.test fixtures to test Flask applications.
+
+  :pypi:`pytest-flask-ligand`
+     *last release*: Apr 25, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (~=7.3)
+
+     Pytest fixtures and helper functions to use for testing flask-ligand microservices.
+
+  :pypi:`pytest-flask-sqlalchemy`
+     *last release*: Apr 30, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.2.1)
+
+     A pytest plugin for preserving test isolation in Flask-SQlAlchemy using database transactions.
+
+  :pypi:`pytest-flask-sqlalchemy-transactions`
+     *last release*: Aug 02, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.2.1)
+
+     Run tests in transactions using pytest, Flask, and SQLalchemy.
+
+  :pypi:`pytest-flexreport`
+     *last release*: Apr 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-fluent`
+     *last release*: Jul 12, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A pytest plugin in order to provide logs via fluentd
+
+  :pypi:`pytest-flyte`
+     *last release*: May 03, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest fixtures for simplifying Flyte integration testing
+
+  :pypi:`pytest-focus`
+     *last release*: May 04, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A pytest plugin that alerts user of failed test cases with screen notifications
+
+  :pypi:`pytest-forbid`
+     *last release*: Mar 07, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.2,<8.0.0)
+
+
+
+  :pypi:`pytest-forcefail`
+     *last release*: May 15, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to make the test failing regardless of pytest.mark.xfail
+
+  :pypi:`pytest-forward-compatability`
+     *last release*: Sep 06, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     A name to avoid typosquating pytest-foward-compatibility
+
+  :pypi:`pytest-forward-compatibility`
+     *last release*: Sep 29, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin to shim pytest commandline options for fowards compatibility
+
+  :pypi:`pytest-frappe`
+     *last release*: May 03, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest>=7.0.0
+
+     Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications
+
+  :pypi:`pytest-freezegun`
+     *last release*: Jul 19, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.0.0)
+
+     Wrap tests with fixtures in freeze_time
+
+  :pypi:`pytest-freezer`
+     *last release*: Jun 17, 2023,
+     *status*: N/A,
+     *requires*: pytest>=3.6
+
+     Pytest plugin providing a fixture interface for spulec/freezegun
+
+  :pypi:`pytest-freeze-reqs`
+     *last release*: Apr 29, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Check if requirement files are frozen
+
+  :pypi:`pytest-frozen-uuids`
+     *last release*: Apr 17, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.0)
+
+     Deterministically frozen UUID's for your tests
+
+  :pypi:`pytest-func-cov`
+     *last release*: Apr 15, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=5)
+
+     Pytest plugin for measuring function coverage
+
+  :pypi:`pytest-funparam`
+     *last release*: Dec 02, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest >=4.6.0
+
+     An alternative way to parametrize test cases.
+
+  :pypi:`pytest-fxa`
+     *last release*: Aug 28, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for Firefox Accounts
+
+  :pypi:`pytest-fxtest`
+     *last release*: Oct 27, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-fzf`
+     *last release*: Aug 17, 2022,
+     *status*: 1 - Planning,
+     *requires*: pytest (>=7.1.2)
+
+     fzf-based test selector for pytest
+
+  :pypi:`pytest-gather-fixtures`
+     *last release*: Apr 12, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.0.0)
+
+     set up asynchronous pytest fixtures concurrently
+
+  :pypi:`pytest-gc`
+     *last release*: Feb 01, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     The garbage collector plugin for py.test
+
+  :pypi:`pytest-gcov`
+     *last release*: Feb 01, 2018,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Uses gcov to measure test coverage of a C library
+
+  :pypi:`pytest-gevent`
+     *last release*: Feb 25, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Ensure that gevent is properly patched when invoking pytest
+
+  :pypi:`pytest-gherkin`
+     *last release*: Jul 27, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=5.0.0)
+
+     A flexible framework for executing BDD gherkin tests
+
+  :pypi:`pytest-gh-log-group`
+     *last release*: Jan 11, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin for gh actions
+
+  :pypi:`pytest-ghostinspector`
+     *last release*: May 17, 2016,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     For finding/executing Ghost Inspector tests
+
+  :pypi:`pytest-girder`
+     *last release*: Jun 14, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A set of pytest fixtures for testing Girder applications.
+
+  :pypi:`pytest-git`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Git repository fixture for py.test
+
+  :pypi:`pytest-gitcov`
+     *last release*: Jan 11, 2020,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     Pytest plugin for reporting on coverage of the last git commit.
+
+  :pypi:`pytest-git-fixtures`
+     *last release*: Mar 11, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with git.
+
+  :pypi:`pytest-github`
+     *last release*: Mar 07, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Plugin for py.test that associates tests with github issues using a marker.
+
+  :pypi:`pytest-github-actions-annotate-failures`
+     *last release*: May 04, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.0.0)
+
+     pytest plugin to annotate failed tests with a workflow command for GitHub Actions
+
+  :pypi:`pytest-github-report`
+     *last release*: Jun 03, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Generate a GitHub report using pytest in GitHub Workflows
+
+  :pypi:`pytest-gitignore`
+     *last release*: Jul 17, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to ignore the same files as git
+
+  :pypi:`pytest-gitlabci-parallelized`
+     *last release*: Mar 08, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Parallelize pytest across GitLab CI workers.
+
+  :pypi:`pytest-git-selector`
+     *last release*: Nov 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Utility to select tests that have had its dependencies modified (as identified by git diff)
+
+  :pypi:`pytest-glamor-allure`
+     *last release*: Jul 22, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Extends allure-pytest functionality
+
+  :pypi:`pytest-gnupg-fixtures`
+     *last release*: Mar 04, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixtures for testing with gnupg.
+
+  :pypi:`pytest-golden`
+     *last release*: Jul 18, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.1.2)
+
+     Plugin for pytest that offloads expected outputs to data files
+
+  :pypi:`pytest-goldie`
+     *last release*: May 23, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin to support golden tests with pytest.
+
+  :pypi:`pytest-google-chat`
+     *last release*: Mar 27, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Notify google chat channel for test results
+
+  :pypi:`pytest-graphql-schema`
+     *last release*: Oct 18, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Get graphql schema as fixture for pytest
+
+  :pypi:`pytest-greendots`
+     *last release*: Feb 08, 2014,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Green progress dots
+
+  :pypi:`pytest-growl`
+     *last release*: Jan 13, 2014,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Growl notifications for pytest results.
+
+  :pypi:`pytest-grpc`
+     *last release*: May 01, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=3.6.0)
+
+     pytest plugin for grpc
+
+  :pypi:`pytest-grunnur`
+     *last release*: Feb 05, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Py.Test plugin for Grunnur-based packages.
+
+  :pypi:`pytest-hammertime`
+     *last release*: Jul 28, 2018,
+     *status*: N/A,
+     *requires*: pytest
+
+     Display "🔨 " instead of "." for passed pytest tests.
+
+  :pypi:`pytest-harmony`
+     *last release*: Jan 17, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.1,<8.0.0)
+
+     Chain tests and data with pytest
+
+  :pypi:`pytest-harvest`
+     *last release*: Jun 10, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes.
+
+  :pypi:`pytest-helm-chart`
+     *last release*: Jun 15, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.4.2,<6.0.0)
+
+     A plugin to provide different types and configs of Kubernetes clusters that can be used for testing.
+
+  :pypi:`pytest-helm-charts`
+     *last release*: Mar 08, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+     A plugin to provide different types and configs of Kubernetes clusters that can be used for testing.
+
+  :pypi:`pytest-helper`
+     *last release*: May 31, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Functions to help in using the pytest testing framework
+
+  :pypi:`pytest-helpers`
+     *last release*: May 17, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest helpers
+
+  :pypi:`pytest-helpers-namespace`
+     *last release*: Dec 29, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.0.0)
+
+     Pytest Helpers Namespace Plugin
+
+  :pypi:`pytest-hidecaptured`
+     *last release*: May 04, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.5)
+
+     Hide captured output
+
+  :pypi:`pytest-historic`
+     *last release*: Apr 08, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Custom report to display pytest historical execution records
+
+  :pypi:`pytest-historic-hook`
+     *last release*: Apr 08, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Custom listener to store execution results into MYSQL DB, which is used for pytest-historic report
+
+  :pypi:`pytest-homeassistant`
+     *last release*: Aug 12, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin for use with homeassistant custom components.
+
+  :pypi:`pytest-homeassistant-custom-component`
+     *last release*: Jun 16, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (==7.3.1)
+
+     Experimental package to automatically extract test plugins for Home Assistant custom components
+
+  :pypi:`pytest-honey`
+     *last release*: Jan 07, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-honors`
+     *last release*: Mar 06, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Report on tests that honor constraints, and guard against regressions
+
+  :pypi:`pytest-hot-reloading`
+     *last release*: Jun 16, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-hot-test`
+     *last release*: Dec 10, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin that tracks test changes
+
+  :pypi:`pytest-hoverfly`
+     *last release*: Jan 30, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=5.0)
+
+     Simplify working with Hoverfly from pytest
+
+  :pypi:`pytest-hoverfly-wrapper`
+     *last release*: Feb 27, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.7.0)
+
+     Integrates the Hoverfly HTTP proxy into Pytest
+
+  :pypi:`pytest-hpfeeds`
+     *last release*: Feb 28, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.4,<7.0.0)
+
+     Helpers for testing hpfeeds in your python project
+
+  :pypi:`pytest-html`
+     *last release*: Apr 08, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (!=6.0.0,>=5.0)
+
+     pytest plugin for generating HTML reports
+
+  :pypi:`pytest-html-lee`
+     *last release*: Jun 30, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     optimized pytest plugin for generating HTML reports
+
+  :pypi:`pytest-html-merger`
+     *last release*: Apr 03, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest HTML reports merging utility
+
+  :pypi:`pytest-html-object-storage`
+     *last release*: Mar 04, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest report plugin for send HTML report on object-storage
+
+  :pypi:`pytest-html-profiling`
+     *last release*: Feb 11, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0)
+
+     Pytest plugin for generating HTML reports with per-test profiling and optionally call graph visualizations. Based on pytest-html by Dave Hunt.
+
+  :pypi:`pytest-html-reporter`
+     *last release*: Feb 13, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Generates a static html report based on pytest framework
+
+  :pypi:`pytest-html-report-merger`
+     *last release*: Aug 31, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-html-thread`
+     *last release*: Dec 29, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for generating HTML reports
+
+  :pypi:`pytest-http`
+     *last release*: Dec 05, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Fixture "http" for http requests
+
+  :pypi:`pytest-httpbin`
+     *last release*: May 08, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest ; extra == 'test'
+
+     Easily test your HTTP library against a local copy of httpbin
+
+  :pypi:`pytest-httpdbg`
+     *last release*: May 09, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=7.0.0)
+
+     A pytest plugin to record HTTP(S) requests with stack trace
+
+  :pypi:`pytest-http-mocker`
+     *last release*: Oct 20, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin for http mocking (via https://github.com/vilus/mocker)
+
+  :pypi:`pytest-httpretty`
+     *last release*: Feb 16, 2014,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     A thin wrapper of HTTPretty for pytest
+
+  :pypi:`pytest-httpserver`
+     *last release*: May 22, 2023,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest-httpserver is a httpserver for pytest
+
+  :pypi:`pytest-httptesting`
+     *last release*: Jun 03, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+     http_testing framework on top of pytest
+
+  :pypi:`pytest-httpx`
+     *last release*: Apr 12, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (<8.0,>=6.0)
+
+     Send responses to httpx.
+
+  :pypi:`pytest-httpx-blockage`
+     *last release*: Feb 16, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.1)
+
+     Disable httpx requests during a test run
+
+  :pypi:`pytest-hue`
+     *last release*: May 09, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Visualise PyTest status via your Phillips Hue lights
+
+  :pypi:`pytest-hylang`
+     *last release*: Mar 28, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest plugin to allow running tests written in hylang
+
+  :pypi:`pytest-hypo-25`
+     *last release*: Jan 12, 2020,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     help hypo module for pytest
+
+  :pypi:`pytest-ibutsu`
+     *last release*: Aug 05, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest>=7.1
+
+     A plugin to sent pytest results to an Ibutsu server
+
+  :pypi:`pytest-icdiff`
+     *last release*: Aug 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     use icdiff for better error messages in pytest assertions
+
+  :pypi:`pytest-idapro`
+     *last release*: Nov 03, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin for idapython. Allows a pytest setup to run tests outside and inside IDA in an automated manner by runnig pytest inside IDA and by mocking idapython api
+
+  :pypi:`pytest-idem`
+     *last release*: Sep 07, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A pytest plugin to help with testing idem projects
+
+  :pypi:`pytest-idempotent`
+     *last release*: Jul 25, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin for testing function idempotence.
+
+  :pypi:`pytest-ignore-flaky`
+     *last release*: Apr 23, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     ignore failures from flaky tests (pytest plugin)
+
+  :pypi:`pytest-image-diff`
+     *last release*: Mar 09, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-incremental`
+     *last release*: Apr 24, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     an incremental test runner (pytest plugin)
+
+  :pypi:`pytest-influxdb`
+     *last release*: Apr 20, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Plugin for influxdb and pytest integration.
+
+  :pypi:`pytest-info-collector`
+     *last release*: May 26, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to collect information from tests
+
+  :pypi:`pytest-informative-node`
+     *last release*: Apr 25, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     display more node ininformation.
+
+  :pypi:`pytest-infrastructure`
+     *last release*: Apr 12, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest stack validation prior to testing executing
+
+  :pypi:`pytest-ini`
+     *last release*: Apr 26, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Reuse pytest.ini to store env variables
+
+  :pypi:`pytest-inline`
+     *last release*: Feb 08, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.0)
+
+     A pytest plugin for writing inline tests.
+
+  :pypi:`pytest-inmanta`
+     *last release*: Feb 23, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A py.test plugin providing fixtures to simplify inmanta modules testing.
+
+  :pypi:`pytest-inmanta-extensions`
+     *last release*: Apr 12, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Inmanta tests package
+
+  :pypi:`pytest-inmanta-lsm`
+     *last release*: May 17, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Common fixtures for inmanta LSM related modules
+
+  :pypi:`pytest-inmanta-yang`
+     *last release*: Jun 16, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Common fixtures used in inmanta yang related modules
+
+  :pypi:`pytest-Inomaly`
+     *last release*: Feb 13, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A simple image diff plugin for pytest
+
+  :pypi:`pytest-insta`
+     *last release*: Nov 02, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+     A practical snapshot testing plugin for pytest
+
+  :pypi:`pytest-instafail`
+     *last release*: Mar 31, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5)
+
+     pytest plugin to show failures instantly
+
+  :pypi:`pytest-instrument`
+     *last release*: Apr 05, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.1.0)
+
+     pytest plugin to instrument tests
+
+  :pypi:`pytest-integration`
+     *last release*: Nov 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Organizing pytests by integration or not
+
+  :pypi:`pytest-integration-mark`
+     *last release*: May 22, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=5.2)
+
+     Automatic integration test marking and excluding plugin for pytest
+
+  :pypi:`pytest-interactive`
+     *last release*: Nov 30, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     A pytest plugin for console based interactive test selection just after the collection phase
+
+  :pypi:`pytest-intercept-remote`
+     *last release*: May 24, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin for intercepting outgoing connection requests during pytest run.
+
+  :pypi:`pytest-interface-tester`
+     *last release*: May 09, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest plugin for checking charm relation interface protocol compliance.
+
+  :pypi:`pytest-invenio`
+     *last release*: Jun 02, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (<7.2.0,>=6)
+
+     Pytest fixtures for Invenio.
+
+  :pypi:`pytest-involve`
+     *last release*: Feb 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Run tests covering a specific file or changeset
+
+  :pypi:`pytest-ipdb`
+     *last release*: Mar 20, 2013,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     A py.test plug-in to enable drop to ipdb debugger on test failure.
+
+  :pypi:`pytest-ipynb`
+     *last release*: Jan 29, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     THIS PROJECT IS ABANDONED
+
+  :pypi:`pytest-isolate`
+     *last release*: Feb 20, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-isort`
+     *last release*: Oct 31, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     py.test plugin to check import ordering using isort
+
+  :pypi:`pytest-is-running`
+     *last release*: Jun 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin providing a function to check if pytest is running.
+
+  :pypi:`pytest-it`
+     *last release*: Jan 22, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it.
+
+  :pypi:`pytest-iterassert`
+     *last release*: May 11, 2020,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Nicer list and iterable assertion messages for pytest
+
+  :pypi:`pytest-iters`
+     *last release*: May 24, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A contextmanager pytest fixture for handling multiple mock iters
+
+  :pypi:`pytest-jasmine`
+     *last release*: Nov 04, 2017,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     Run jasmine tests from your pytest test suite
+
+  :pypi:`pytest-jelastic`
+     *last release*: Nov 16, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+     Pytest plugin defining the necessary command-line options to pass to pytests testing a Jelastic environment.
+
+  :pypi:`pytest-jest`
+     *last release*: May 22, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.3.2)
+
+     A custom jest-pytest oriented Pytest reporter
+
+  :pypi:`pytest-jinja`
+     *last release*: Oct 04, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=6.2.5,<7.0.0)
+
+     A plugin to generate customizable jinja-based HTML reports in pytest
+
+  :pypi:`pytest-jira`
+     *last release*: Jun 12, 2023,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     py.test JIRA integration plugin, using markers
+
+  :pypi:`pytest-jira-xfail`
+     *last release*: Jun 14, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0)
+
+     Plugin skips (xfail) tests if unresolved Jira issue(s) linked
+
+  :pypi:`pytest-jira-xray`
+     *last release*: Jun 06, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to integrate tests with JIRA XRAY
+
+  :pypi:`pytest-job-selection`
+     *last release*: Jan 30, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin for load balancing test suites
+
+  :pypi:`pytest-jobserver`
+     *last release*: May 15, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Limit parallel tests with posix jobserver.
+
+  :pypi:`pytest-joke`
+     *last release*: Oct 08, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.2.1)
+
+     Test failures are better served with humor.
+
+  :pypi:`pytest-json`
+     *last release*: Jan 18, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Generate JSON test reports
+
+  :pypi:`pytest-json-fixtures`
+     *last release*: Mar 14, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     JSON output for the --fixtures flag
+
+  :pypi:`pytest-jsonlint`
+     *last release*: Aug 04, 2016,
+     *status*: N/A,
+     *requires*: N/A
+
+     UNKNOWN
+
+  :pypi:`pytest-json-report`
+     *last release*: Mar 15, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.8.0)
+
+     A pytest plugin to report test results as JSON files
+
+  :pypi:`pytest-jtr`
+     *last release*: Nov 29, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+     pytest plugin supporting json test report output
+
+  :pypi:`pytest-jupyter`
+     *last release*: Mar 30, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A pytest plugin for testing Jupyter libraries and extensions.
+
+  :pypi:`pytest-jupyterhub`
+     *last release*: Apr 25, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A reusable JupyterHub pytest plugin
+
+  :pypi:`pytest-kafka`
+     *last release*: Jun 14, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest
+
+  :pypi:`pytest-kafkavents`
+     *last release*: Sep 08, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A plugin to send pytest events to Kafka
+
+  :pypi:`pytest-kasima`
+     *last release*: Jan 26, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.2.1,<8.0.0)
+
+     Display horizontal lines above and below the captured standard output for easy viewing.
+
+  :pypi:`pytest-keep-together`
+     *last release*: Dec 07, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest plugin to customize test ordering by running all 'related' tests together
+
+  :pypi:`pytest-kexi`
+     *last release*: Apr 29, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+
+
+  :pypi:`pytest-kind`
+     *last release*: Nov 30, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Kubernetes test support with KIND for pytest
+
+  :pypi:`pytest-kivy`
+     *last release*: Jul 06, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.6)
+
+     Kivy GUI tests fixtures using pytest
+
+  :pypi:`pytest-knows`
+     *last release*: Aug 22, 2014,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin that can automaticly skip test case based on dependence info calculated by trace
+
+  :pypi:`pytest-konira`
+     *last release*: Oct 09, 2011,
+     *status*: N/A,
+     *requires*: N/A
+
+     Run Konira DSL tests with py.test
+
+  :pypi:`pytest-koopmans`
+     *last release*: Nov 21, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin for testing the koopmans package
+
+  :pypi:`pytest-krtech-common`
+     *last release*: Nov 28, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest krtech common library
+
+  :pypi:`pytest-kubernetes`
+     *last release*: May 17, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.1,<8.0.0)
+
+
+
+  :pypi:`pytest-kwparametrize`
+     *last release*: Jan 22, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=6)
+
+     Alternate syntax for @pytest.mark.parametrize with test cases as dictionaries and default value fallbacks
+
+  :pypi:`pytest-lambda`
+     *last release*: Aug 20, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.6,<8)
+
+     Define pytest fixtures with lambda functions.
+
+  :pypi:`pytest-lamp`
+     *last release*: Jan 06, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-langchain`
+     *last release*: Feb 26, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest-style test runner for langchain agents
+
+  :pypi:`pytest-lark`
+     *last release*: Nov 20, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package for enhancing pytest
+
+  :pypi:`pytest-launchable`
+     *last release*: Apr 05, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=4.2.0)
+
+     Launchable Pytest Plugin
+
+  :pypi:`pytest-layab`
+     *last release*: Oct 05, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest fixtures for layab.
+
+  :pypi:`pytest-lazy-fixture`
+     *last release*: Feb 01, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.2.5)
+
+     It helps to use fixtures in pytest.mark.parametrize
+
+  :pypi:`pytest-lazy-fixtures`
+     *last release*: May 28, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.1,<8.0.0)
+
+     Allows you to use fixtures in @pytest.mark.parametrize.
+
+  :pypi:`pytest-ldap`
+     *last release*: Aug 18, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     python-ldap fixtures for pytest
+
+  :pypi:`pytest-leak-finder`
+     *last release*: Feb 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Find the test that's leaking before the one that fails
+
+  :pypi:`pytest-leaks`
+     *last release*: Nov 27, 2019,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     A pytest plugin to trace resource leaks.
+
+  :pypi:`pytest-level`
+     *last release*: Oct 21, 2019,
+     *status*: N/A,
+     *requires*: pytest
+
+     Select tests of a given level or lower
+
+  :pypi:`pytest-libfaketime`
+     *last release*: Dec 22, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.0.0)
+
+     A python-libfaketime plugin for pytest.
+
+  :pypi:`pytest-libiio`
+     *last release*: Jul 11, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin to manage interfacing with libiio contexts
+
+  :pypi:`pytest-libnotify`
+     *last release*: Apr 02, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Pytest plugin that shows notifications about the test run
+
+  :pypi:`pytest-ligo`
+     *last release*: Jan 16, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-lineno`
+     *last release*: Dec 04, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin to show the line numbers of test functions
+
+  :pypi:`pytest-line-profiler`
+     *last release*: May 03, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Profile code executed by pytest
+
+  :pypi:`pytest-line-profiler-apn`
+     *last release*: Dec 05, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     Profile code executed by pytest
+
+  :pypi:`pytest-lisa`
+     *last release*: Jan 21, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=6.1.2,<7.0.0)
+
+     Pytest plugin for organizing tests.
+
+  :pypi:`pytest-listener`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A simple network listener
+
+  :pypi:`pytest-litf`
+     *last release*: Jan 18, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     A pytest plugin that stream output in LITF format
+
+  :pypi:`pytest-live`
+     *last release*: Mar 08, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Live results for pytest
+
+  :pypi:`pytest-local-badge`
+     *last release*: Jan 15, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=6.1.0)
+
+     Generate local badges (shields) reporting your test suite status.
+
+  :pypi:`pytest-localftpserver`
+     *last release*: Oct 04, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A PyTest plugin which provides an FTP fixture for your tests
+
+  :pypi:`pytest-localserver`
+     *last release*: Jan 30, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to test server connections locally.
+
+  :pypi:`pytest-localstack`
+     *last release*: Jun 07, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0,<7.0.0)
+
+     Pytest plugin for AWS integration tests
+
+  :pypi:`pytest-lockable`
+     *last release*: Jul 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     lockable resource plugin for pytest
+
+  :pypi:`pytest-locker`
+     *last release*: Oct 29, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=5.4)
+
+     Used to lock object during testing. Essentially changing assertions from being hard coded to asserting that nothing changed
+
+  :pypi:`pytest-log`
+     *last release*: Aug 15, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=3.8)
+
+     print log
+
+  :pypi:`pytest-logbook`
+     *last release*: Nov 23, 2015,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.8)
+
+     py.test plugin to capture logbook log messages
+
+  :pypi:`pytest-logdog`
+     *last release*: Jun 15, 2021,
+     *status*: 1 - Planning,
+     *requires*: pytest (>=6.2.0)
+
+     Pytest plugin to test logging
+
+  :pypi:`pytest-logfest`
+     *last release*: Jul 21, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest plugin providing three logger fixtures with basic or full writing to log files
+
+  :pypi:`pytest-logger`
+     *last release*: Jul 25, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.2)
+
+     Plugin configuring handlers for loggers from Python logging module.
+
+  :pypi:`pytest-logging`
+     *last release*: Nov 04, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Configures logging and allows tweaking the log level with a py.test flag
+
+  :pypi:`pytest-logging-end-to-end-test-tool`
+     *last release*: Sep 23, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+
+
+  :pypi:`pytest-logikal`
+     *last release*: Jun 04, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (==7.3.1)
+
+     Common testing environment
+
+  :pypi:`pytest-log-report`
+     *last release*: Dec 26, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Package for creating a pytest test run reprot
+
+  :pypi:`pytest-loguru`
+     *last release*: Apr 12, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest Loguru
+
+  :pypi:`pytest-loop`
+     *last release*: Jul 22, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6)
+
+     pytest plugin for looping tests
+
+  :pypi:`pytest-lsp`
+     *last release*: May 19, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin for end-to-end testing of language servers
+
+  :pypi:`pytest-manual-marker`
+     *last release*: Aug 04, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest>=7
+
+     pytest marker for marking manual tests
+
+  :pypi:`pytest-markdoctest`
+     *last release*: Jul 22, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6)
+
+     A pytest plugin to doctest your markdown files
+
+  :pypi:`pytest-markdown`
+     *last release*: Jan 15, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.1,<7.0.0)
+
+     Test your markdown docs with pytest
+
+  :pypi:`pytest-markdown-docs`
+     *last release*: Mar 09, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Run markdown code fences through pytest
+
+  :pypi:`pytest-marker-bugzilla`
+     *last release*: Jan 09, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     py.test bugzilla integration plugin, using markers
+
+  :pypi:`pytest-markers-presence`
+     *last release*: Feb 04, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0)
+
+     A simple plugin to detect missed pytest tags and markers"
+
+  :pypi:`pytest-markfiltration`
+     *last release*: Nov 08, 2011,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     UNKNOWN
+
+  :pypi:`pytest-mark-no-py3`
+     *last release*: May 17, 2019,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest plugin and bowler codemod to help migrate tests to Python 3
+
+  :pypi:`pytest-marks`
+     *last release*: Nov 23, 2012,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     UNKNOWN
+
+  :pypi:`pytest-matcher`
+     *last release*: Dec 10, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Match test output against patterns stored in files
+
+  :pypi:`pytest-match-skip`
+     *last release*: May 15, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.4.1)
+
+     Skip matching marks. Matches partial marks using wildcards.
+
+  :pypi:`pytest-mat-report`
+     *last release*: Jan 20, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     this is report
+
+  :pypi:`pytest-matrix`
+     *last release*: Jun 24, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.4.3,<6.0.0)
+
+     Provide tools for generating tests from combinations of fixtures.
+
+  :pypi:`pytest-maybe-context`
+     *last release*: Apr 16, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7,<8)
+
+     Simplify tests with warning and exception cases.
+
+  :pypi:`pytest-maybe-raises`
+     *last release*: May 27, 2022,
+     *status*: N/A,
+     *requires*: pytest ; extra == 'dev'
+
+     Pytest fixture for optional exception testing.
+
+  :pypi:`pytest-mccabe`
+     *last release*: Jul 22, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=5.4.0)
+
+     pytest plugin to run the mccabe code complexity checker.
+
+  :pypi:`pytest-md`
+     *last release*: Jul 11, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.2.1)
+
+     Plugin for generating Markdown reports for pytest results
+
+  :pypi:`pytest-md-report`
+     *last release*: May 28, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (!=6.0.0,<8,>=3.3.2)
+
+     A pytest plugin to make a test results report with Markdown table format.
+
+  :pypi:`pytest-memlog`
+     *last release*: May 03, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.3.0,<8.0.0)
+
+     Log memory usage during tests
+
+  :pypi:`pytest-memprof`
+     *last release*: Mar 29, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Estimates memory consumption of test functions
+
+  :pypi:`pytest-memray`
+     *last release*: Jun 06, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7.2
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-menu`
+     *last release*: Oct 04, 2017,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.4.2)
+
+     A pytest plugin for console based interactive test selection just after the collection phase
+
+  :pypi:`pytest-mercurial`
+     *last release*: Nov 21, 2020,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     pytest plugin to write integration tests for projects using Mercurial Python internals
+
+  :pypi:`pytest-mesh`
+     *last release*: Aug 05, 2022,
+     *status*: N/A,
+     *requires*: pytest (==7.1.2)
+
+     pytest_mesh插件
+
+  :pypi:`pytest-message`
+     *last release*: Aug 04, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5)
+
+     Pytest plugin for sending report message of marked tests execution
+
+  :pypi:`pytest-messenger`
+     *last release*: Nov 24, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest to Slack reporting plugin
+
+  :pypi:`pytest-metadata`
+     *last release*: May 27, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7.0.0
+
+     pytest plugin for test session metadata
+
+  :pypi:`pytest-metrics`
+     *last release*: Apr 04, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Custom metrics report for pytest
+
+  :pypi:`pytest-mh`
+     *last release*: Jun 08, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest multihost plugin
+
+  :pypi:`pytest-mimesis`
+     *last release*: Mar 21, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.2)
+
+     Mimesis integration with the pytest test runner
+
+  :pypi:`pytest-minecraft`
+     *last release*: Apr 06, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.0.1)
+
+     A pytest plugin for running tests against Minecraft releases
+
+  :pypi:`pytest-mini`
+     *last release*: Feb 06, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+     A plugin to test mp
+
+  :pypi:`pytest-missing-fixtures`
+     *last release*: Oct 14, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest plugin that creates missing fixtures
+
+  :pypi:`pytest-ml`
+     *last release*: May 04, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Test your machine learning!
+
+  :pypi:`pytest-mocha`
+     *last release*: Apr 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.4.0)
+
+     pytest plugin to display test execution output like a mochajs
+
+  :pypi:`pytest-mock`
+     *last release*: Jun 15, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     Thin-wrapper around the mock package for easier use with pytest
+
+  :pypi:`pytest-mock-api`
+     *last release*: Feb 13, 2019,
+     *status*: 1 - Planning,
+     *requires*: pytest (>=4.0.0)
+
+     A mock API server with configurable routes and responses available as a fixture.
+
+  :pypi:`pytest-mock-generator`
+     *last release*: May 16, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A pytest fixture wrapper for https://pypi.org/project/mock-generator
+
+  :pypi:`pytest-mock-helper`
+     *last release*: Jan 24, 2018,
+     *status*: N/A,
+     *requires*: pytest
+
+     Help you mock HTTP call and generate mock code
+
+  :pypi:`pytest-mockito`
+     *last release*: Jul 11, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Base fixtures for mockito
+
+  :pypi:`pytest-mockredis`
+     *last release*: Jan 02, 2018,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     An in-memory mock of a Redis server that runs in a separate thread. This is to be used for unit-tests that require a Redis database.
+
+  :pypi:`pytest-mock-resources`
+     *last release*: Jun 09, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=1.0)
+
+     A pytest plugin for easily instantiating reproducible mock resources.
+
+  :pypi:`pytest-mock-server`
+     *last release*: Jan 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Mock server plugin for pytest
+
+  :pypi:`pytest-mockservers`
+     *last release*: Mar 31, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=4.3.0)
+
+     A set of fixtures to test your requests to HTTP/UDP servers
+
+  :pypi:`pytest-mocktcp`
+     *last release*: Oct 11, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin for testing TCP clients
+
+  :pypi:`pytest-modified-env`
+     *last release*: Jan 29, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest plugin to fail a test if it leaves modified \`os.environ\` afterwards.
+
+  :pypi:`pytest-modifyjunit`
+     *last release*: Jan 10, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Utility for adding additional properties to junit xml for IDM QE
+
+  :pypi:`pytest-modifyscope`
+     *last release*: Apr 12, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest plugin to modify fixture scope
+
+  :pypi:`pytest-molecule`
+     *last release*: Mar 29, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.0.0)
+
+     PyTest Molecule Plugin :: discover and run molecule tests
+
+  :pypi:`pytest-mongo`
+     *last release*: Jun 07, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     MongoDB process and client fixtures plugin for Pytest.
+
+  :pypi:`pytest-mongodb`
+     *last release*: May 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for MongoDB fixtures
+
+  :pypi:`pytest-monitor`
+     *last release*: Oct 22, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest plugin for analyzing resource usage.
+
+  :pypi:`pytest-monkeyplus`
+     *last release*: Sep 18, 2012,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest's monkeypatch subclass with extra functionalities
+
+  :pypi:`pytest-monkeytype`
+     *last release*: Jul 29, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest-monkeytype: Generate Monkeytype annotations from your pytest tests.
+
+  :pypi:`pytest-moto`
+     *last release*: Aug 28, 2015,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     Fixtures for integration tests of AWS services,uses moto mocking library.
+
+  :pypi:`pytest-motor`
+     *last release*: Jul 21, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     A pytest plugin for motor, the non-blocking MongoDB driver.
+
+  :pypi:`pytest-mp`
+     *last release*: May 23, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A test batcher for multiprocessed Pytest runs
+
+  :pypi:`pytest-mpi`
+     *last release*: Jan 08, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin to collect information from tests
+
+  :pypi:`pytest-mpiexec`
+     *last release*: Apr 13, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin for running individual tests with mpiexec
+
+  :pypi:`pytest-mpl`
+     *last release*: Jul 23, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to help with testing figures output from Matplotlib
+
+  :pypi:`pytest-mproc`
+     *last release*: Nov 15, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6)
+
+     low-startup-overhead, scalable, distributed-testing pytest plugin
+
+  :pypi:`pytest-mqtt`
+     *last release*: Mar 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (<8) ; extra == 'test'
+
+     pytest-mqtt supports testing systems based on MQTT
+
+  :pypi:`pytest-multihost`
+     *last release*: Apr 07, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Utility for writing multi-host tests for pytest
+
+  :pypi:`pytest-multilog`
+     *last release*: Jan 17, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     Multi-process logs handling and other helpers for pytest
+
+  :pypi:`pytest-multithreading`
+     *last release*: Dec 07, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     a pytest plugin for th and concurrent testing
+
+  :pypi:`pytest-multithreading-allure`
+     *last release*: Nov 25, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest_multithreading_allure
+
+  :pypi:`pytest-mutagen`
+     *last release*: Jul 24, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=5.4)
+
+     Add the mutation testing feature to pytest
+
+  :pypi:`pytest-mypy`
+     *last release*: Dec 18, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2) ; python_version >= "3.10"
+
+     Mypy static type checker plugin for Pytest
+
+  :pypi:`pytest-mypyd`
+     *last release*: Aug 20, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (<4.7,>=2.8) ; python_version < "3.5"
+
+     Mypy static type checker plugin for Pytest
+
+  :pypi:`pytest-mypy-plugins`
+     *last release*: May 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.0)
+
+     pytest plugin for writing tests for mypy plugins
+
+  :pypi:`pytest-mypy-plugins-shim`
+     *last release*: Apr 12, 2021,
+     *status*: N/A,
+     *requires*: pytest>=6.0.0
+
+     Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy.
+
+  :pypi:`pytest-mypy-testing`
+     *last release*: Feb 25, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7,<8
+
+     Pytest plugin to check mypy output.
+
+  :pypi:`pytest-mysql`
+     *last release*: Mar 27, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2)
+
+     MySQL process and client fixtures for pytest
+
+  :pypi:`pytest-needle`
+     *last release*: Dec 10, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (<5.0.0,>=3.0.0)
+
+     pytest plugin for visual testing websites using selenium
+
+  :pypi:`pytest-neo`
+     *last release*: Jan 08, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=6.2.0)
+
+     pytest-neo is a plugin for pytest that shows tests like screen of Matrix.
+
+  :pypi:`pytest-netdut`
+     *last release*: Jun 05, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     "Automated software testing for switches using pytest"
+
+  :pypi:`pytest-network`
+     *last release*: May 07, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     A simple plugin to disable network on socket level.
+
+  :pypi:`pytest-network-endpoints`
+     *last release*: Mar 06, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Network endpoints plugin for pytest
+
+  :pypi:`pytest-never-sleep`
+     *last release*: May 05, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.5.1)
+
+     pytest plugin helps to avoid adding tests without mock \`time.sleep\`
+
+  :pypi:`pytest-nginx`
+     *last release*: Aug 12, 2017,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     nginx fixture for pytest
+
+  :pypi:`pytest-nginx-iplweb`
+     *last release*: Mar 01, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     nginx fixture for pytest - iplweb temporary fork
+
+  :pypi:`pytest-ngrok`
+     *last release*: Jan 20, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-ngsfixtures`
+     *last release*: Sep 06, 2019,
+     *status*: 2 - Pre-Alpha,
+     *requires*: pytest (>=5.0.0)
+
+     pytest ngs fixtures
+
+  :pypi:`pytest-nhsd-apim`
+     *last release*: Jun 07, 2023,
+     *status*: N/A,
+     *requires*: pytest (==6.2.5)
+
+     Pytest plugin accessing NHSDigital's APIM proxies
+
+  :pypi:`pytest-nice`
+     *last release*: May 04, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A pytest plugin that alerts user of failed test cases with screen notifications
+
+  :pypi:`pytest-nice-parametrize`
+     *last release*: Apr 17, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A small snippet for nicer PyTest's Parametrize
+
+  :pypi:`pytest-nlcov`
+     *last release*: Jul 07, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin to get the coverage of the new lines (based on git diff) only
+
+  :pypi:`pytest-nocustom`
+     *last release*: Jul 07, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Run all tests without custom markers
+
+  :pypi:`pytest-nodev`
+     *last release*: Jul 21, 2016,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.1)
+
+     Test-driven source code search for Python.
+
+  :pypi:`pytest-nogarbage`
+     *last release*: Aug 29, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6.0)
+
+     Ensure a test produces no garbage
+
+  :pypi:`pytest-notice`
+     *last release*: Nov 05, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Send pytest execution result email
+
+  :pypi:`pytest-notification`
+     *last release*: Jun 19, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=4)
+
+     A pytest plugin for sending a desktop notification and playing a sound upon completion of tests
+
+  :pypi:`pytest-notifier`
+     *last release*: Jun 12, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     A pytest plugin to notify test result
+
+  :pypi:`pytest-notimplemented`
+     *last release*: Aug 27, 2019,
+     *status*: N/A,
+     *requires*: pytest (>=5.1,<6.0)
+
+     Pytest markers for not implemented features and tests.
+
+  :pypi:`pytest-notion`
+     *last release*: Aug 07, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     A PyTest Reporter to send test runs to Notion.so
+
+  :pypi:`pytest-nunit`
+     *last release*: Oct 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6.0)
+
+     A pytest plugin for generating NUnit3 test result XML output
+
+  :pypi:`pytest-oar`
+     *last release*: May 02, 2023,
+     *status*: N/A,
+     *requires*: pytest>=6.0.1
+
+     PyTest plugin for the OAR testing framework
+
+  :pypi:`pytest-object-getter`
+     *last release*: Jul 31, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Import any object from a 3rd party module while mocking its namespace on demand.
+
+  :pypi:`pytest-ochrus`
+     *last release*: Feb 21, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest results data-base and HTML reporter
+
+  :pypi:`pytest-odoo`
+     *last release*: Nov 17, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.2.0)
+
+     py.test plugin to run Odoo tests
+
+  :pypi:`pytest-odoo-fixtures`
+     *last release*: Jun 25, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Project description
+
+  :pypi:`pytest-oerp`
+     *last release*: Feb 28, 2012,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to test OpenERP modules
+
+  :pypi:`pytest-offline`
+     *last release*: Mar 09, 2023,
+     *status*: 1 - Planning,
+     *requires*: pytest (>=7.0.0,<8.0.0)
+
+
+
+  :pypi:`pytest-ogsm-plugin`
+     *last release*: May 16, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     针对特定项目定制化插件,优化了pytest报告展示方式,并添加了项目所需特定参数
+
+  :pypi:`pytest-ok`
+     *last release*: Apr 01, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     The ultimate pytest output plugin
+
+  :pypi:`pytest-only`
+     *last release*: Jun 14, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (<7.1); python_version <= "3.6"
+
+     Use @pytest.mark.only to run a single test
+
+  :pypi:`pytest-oot`
+     *last release*: Sep 18, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Run object-oriented tests in a simple format
+
+  :pypi:`pytest-openfiles`
+     *last release*: Apr 16, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin for detecting inadvertent open file handles
+
+  :pypi:`pytest-opentelemetry`
+     *last release*: Mar 15, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin for instrumenting test runs via OpenTelemetry
+
+  :pypi:`pytest-opentmi`
+     *last release*: Jun 02, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0)
+
+     pytest plugin for publish results to opentmi
+
+  :pypi:`pytest-operator`
+     *last release*: Sep 28, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Fixtures for Operators
+
+  :pypi:`pytest-optional`
+     *last release*: Oct 07, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     include/exclude values of fixtures in pytest
+
+  :pypi:`pytest-optional-tests`
+     *last release*: Jul 09, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.5.0)
+
+     Easy declaration of optional tests (i.e., that are not run by default)
+
+  :pypi:`pytest-orchestration`
+     *last release*: Jul 18, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin for orchestrating tests
+
+  :pypi:`pytest-order`
+     *last release*: Mar 10, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.0) ; python_version < "3.10"
+
+     pytest plugin to run your tests in a specific order
+
+  :pypi:`pytest-ordering`
+     *last release*: Nov 14, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to run your tests in a specific order
+
+  :pypi:`pytest-order-modify`
+     *last release*: Nov 04, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     新增run_marker 来自定义用例的执行顺序
+
+  :pypi:`pytest-osxnotify`
+     *last release*: May 15, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     OS X notifications for py.test results.
+
+  :pypi:`pytest-otel`
+     *last release*: Jan 18, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest-otel report OpenTelemetry traces about test executed
+
+  :pypi:`pytest-override-env-var`
+     *last release*: Feb 25, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest mark to override a value of an environment variable.
+
+  :pypi:`pytest-owner`
+     *last release*: Apr 25, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Add owner mark for tests
+
+  :pypi:`pytest-pact`
+     *last release*: Jan 07, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-pahrametahrize`
+     *last release*: Nov 24, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0,<7.0)
+
+     Parametrize your tests with a Boston accent.
+
+  :pypi:`pytest-parallel`
+     *last release*: Oct 10, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0.0)
+
+     a pytest plugin for parallel and concurrent testing
+
+  :pypi:`pytest-parallel-39`
+     *last release*: Jul 12, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0.0)
+
+     a pytest plugin for parallel and concurrent testing
+
+  :pypi:`pytest-parallelize-tests`
+     *last release*: Jan 27, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin that parallelizes test execution across multiple hosts
+
+  :pypi:`pytest-param`
+     *last release*: Sep 11, 2016,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.6.0)
+
+     pytest plugin to test all, first, last or random params
+
+  :pypi:`pytest-paramark`
+     *last release*: Jan 10, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.5.0)
+
+     Configure pytest fixtures using a combination of"parametrize" and markers
+
+  :pypi:`pytest-parametrization`
+     *last release*: May 22, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Simpler PyTest parametrization
+
+  :pypi:`pytest-parametrize-cases`
+     *last release*: Mar 13, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.1.2)
+
+     A more user-friendly way to write parametrized tests.
+
+  :pypi:`pytest-parametrized`
+     *last release*: Sep 13, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest decorator for parametrizing tests with default iterables.
+
+  :pypi:`pytest-parametrize-suite`
+     *last release*: Jan 19, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A simple pytest extension for creating a named test suite.
+
+  :pypi:`pytest-parawtf`
+     *last release*: Dec 03, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.6.0)
+
+     Finally spell paramete?ri[sz]e correctly
+
+  :pypi:`pytest-pass`
+     *last release*: Dec 04, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Check out https://github.com/elilutsky/pytest-pass
+
+  :pypi:`pytest-passrunner`
+     *last release*: Feb 10, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6.0)
+
+     Pytest plugin providing the 'run_on_pass' marker
+
+  :pypi:`pytest-paste-config`
+     *last release*: Sep 18, 2013,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Allow setting the path to a paste config file
+
+  :pypi:`pytest-patch`
+     *last release*: Apr 29, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=7.0.0)
+
+     An automagic \`patch\` fixture that can patch objects directly or by name.
+
+  :pypi:`pytest-patches`
+     *last release*: Aug 30, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A contextmanager pytest fixture for handling multiple mock patches
+
+  :pypi:`pytest-pdb`
+     *last release*: Jul 31, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin which adds pdb helper commands related to pytest.
+
+  :pypi:`pytest-peach`
+     *last release*: Apr 12, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.7)
+
+     pytest plugin for fuzzing with Peach API Security
+
+  :pypi:`pytest-pep257`
+     *last release*: Jul 09, 2016,
+     *status*: N/A,
+     *requires*: N/A
+
+     py.test plugin for pep257
+
+  :pypi:`pytest-pep8`
+     *last release*: Apr 27, 2014,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin to check PEP8 requirements
+
+  :pypi:`pytest-percent`
+     *last release*: May 21, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=5.2.0)
+
+     Change the exit code of pytest test sessions when a required percent of tests pass.
+
+  :pypi:`pytest-perf`
+     *last release*: Jun 02, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6) ; extra == 'testing'
+
+     Run performance tests against the mainline code.
+
+  :pypi:`pytest-performance`
+     *last release*: Sep 11, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.7.0)
+
+     A simple plugin to ensure the execution of critical sections of code has not been impacted
+
+  :pypi:`pytest-persistence`
+     *last release*: Jun 14, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest tool for persistent objects
+
+  :pypi:`pytest-pg`
+     *last release*: May 04, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.0.0)
+
+     A tiny plugin for pytest which runs PostgreSQL in Docker
+
+  :pypi:`pytest-pgsql`
+     *last release*: May 13, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0.0)
+
+     Pytest plugins and helpers for tests using a Postgres database.
+
+  :pypi:`pytest-phmdoctest`
+     *last release*: Apr 15, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.4.3)
+
+     pytest plugin to test Python examples in Markdown using phmdoctest.
+
+  :pypi:`pytest-picked`
+     *last release*: Dec 23, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     Run the tests related to the changed files
+
+  :pypi:`pytest-pigeonhole`
+     *last release*: Jun 25, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.4)
+
+
+
+  :pypi:`pytest-pikachu`
+     *last release*: Aug 05, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Show surprise when tests are passing
+
+  :pypi:`pytest-pilot`
+     *last release*: Oct 09, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Slice in your test base thanks to powerful markers.
+
+  :pypi:`pytest-pingguo-pytest-plugin`
+     *last release*: Oct 26, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pingguo test
+
+  :pypi:`pytest-pings`
+     *last release*: Jun 29, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=5.0.0)
+
+     🦊 The pytest plugin for Firefox Telemetry 📊
+
+  :pypi:`pytest-pinned`
+     *last release*: Sep 17, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple pytest plugin for pinning tests
+
+  :pypi:`pytest-pinpoint`
+     *last release*: Sep 25, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=4.4.0)
+
+     A pytest plugin which runs SBFL algorithms to detect faults.
+
+  :pypi:`pytest-pipeline`
+     *last release*: Jan 24, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest plugin for functional testing of data analysispipelines
+
+  :pypi:`pytest-platform-markers`
+     *last release*: Sep 09, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.6.0)
+
+     Markers for pytest to skip tests on specific platforms
+
+  :pypi:`pytest-play`
+     *last release*: Jun 12, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files
+
+  :pypi:`pytest-playbook`
+     *last release*: Jan 21, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=6.1.2,<7.0.0)
+
+     Pytest plugin for reading playbooks.
+
+  :pypi:`pytest-playwright`
+     *last release*: Apr 24, 2023,
+     *status*: N/A,
+     *requires*: pytest (<8.0.0,>=6.2.4)
+
+     A pytest wrapper with fixtures for Playwright to automate web browsers
+
+  :pypi:`pytest-playwrights`
+     *last release*: Dec 02, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest wrapper with fixtures for Playwright to automate web browsers
+
+  :pypi:`pytest-playwright-snapshot`
+     *last release*: Aug 19, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest wrapper for snapshot testing with playwright
+
+  :pypi:`pytest-playwright-visual`
+     *last release*: Apr 28, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest fixture for visual testing with Playwright
+
+  :pypi:`pytest-plone`
+     *last release*: Jan 05, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Pytest plugin to test Plone addons
+
+  :pypi:`pytest-plt`
+     *last release*: Aug 17, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Fixtures for quickly making Matplotlib plots in tests
+
+  :pypi:`pytest-plugin-helpers`
+     *last release*: Nov 23, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin to help developing and testing other plugins
+
+  :pypi:`pytest-plus`
+     *last release*: Dec 24, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.0.1)
+
+     PyTest Plus Plugin :: extends pytest functionality
+
+  :pypi:`pytest-pmisc`
+     *last release*: Mar 21, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-pointers`
+     *last release*: Dec 26, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin to define functions you test with special marks for better navigation and reports
+
+  :pypi:`pytest-pokie`
+     *last release*: May 22, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pokie plugin for pytest
+
+  :pypi:`pytest-polarion-cfme`
+     *last release*: Nov 13, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin for collecting test cases and recording test results
+
+  :pypi:`pytest-polarion-collect`
+     *last release*: Jun 18, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest plugin for collecting polarion test cases data
+
+  :pypi:`pytest-polecat`
+     *last release*: Aug 12, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Provides Polecat pytest fixtures
+
+  :pypi:`pytest-ponyorm`
+     *last release*: Oct 31, 2018,
+     *status*: N/A,
+     *requires*: pytest (>=3.1.1)
+
+     PonyORM in Pytest
+
+  :pypi:`pytest-poo`
+     *last release*: Mar 25, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.3.4)
+
+     Visualize your crappy tests
+
+  :pypi:`pytest-poo-fail`
+     *last release*: Feb 12, 2015,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Visualize your failed tests with poo
+
+  :pypi:`pytest-pop`
+     *last release*: May 09, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A pytest plugin to help with testing pop projects
+
+  :pypi:`pytest-portion`
+     *last release*: Jan 28, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Select a portion of the collected tests
+
+  :pypi:`pytest-postgres`
+     *last release*: Mar 22, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Run PostgreSQL in Docker container in Pytest.
+
+  :pypi:`pytest-postgresql`
+     *last release*: May 20, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2)
+
+     Postgresql fixtures and fixture factories for Pytest.
+
+  :pypi:`pytest-pot`
+     *last release*: Nov 20, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package for enhancing pytest
+
+  :pypi:`pytest-power`
+     *last release*: Dec 31, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=5.4)
+
+     pytest plugin with powerful fixtures
+
+  :pypi:`pytest-prefer-nested-dup-tests`
+     *last release*: Apr 27, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.1.1,<8.0.0)
+
+     A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages.
+
+  :pypi:`pytest-pretty`
+     *last release*: Apr 05, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7
+
+     pytest plugin for printing summary data as I want it
+
+  :pypi:`pytest-pretty-terminal`
+     *last release*: Jan 31, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.4.1)
+
+     pytest plugin for generating prettier terminal output
+
+  :pypi:`pytest-pride`
+     *last release*: Apr 02, 2016,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Minitest-style test colors
+
+  :pypi:`pytest-print`
+     *last release*: Jun 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7.3.2
+
+     pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout)
+
+  :pypi:`pytest-profiles`
+     *last release*: Dec 09, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.7.0)
+
+     pytest plugin for configuration profiles
+
+  :pypi:`pytest-profiling`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Profiling plugin for py.test
+
+  :pypi:`pytest-progress`
+     *last release*: Jan 31, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for instant test progress status
+
+  :pypi:`pytest-prometheus`
+     *last release*: Oct 03, 2017,
+     *status*: N/A,
+     *requires*: N/A
+
+     Report test pass / failures to a Prometheus PushGateway
+
+  :pypi:`pytest-prometheus-pushgateway`
+     *last release*: Sep 27, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest report plugin for Zulip
+
+  :pypi:`pytest-prosper`
+     *last release*: Sep 24, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     Test helpers for Prosper projects
+
+  :pypi:`pytest-pspec`
+     *last release*: Jun 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.0.0)
+
+     A rspec format reporter for Python ptest
+
+  :pypi:`pytest-psqlgraph`
+     *last release*: Oct 19, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0)
+
+     pytest plugin for testing applications that use psqlgraph
+
+  :pypi:`pytest-ptera`
+     *last release*: Mar 01, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.4,<7.0.0)
+
+     Use ptera probes in tests
+
+  :pypi:`pytest-pudb`
+     *last release*: Oct 25, 2018,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.0)
+
+     Pytest PuDB debugger integration
+
+  :pypi:`pytest-pumpkin-spice`
+     *last release*: Sep 18, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin that makes your test reporting pumpkin-spiced
+
+  :pypi:`pytest-purkinje`
+     *last release*: Oct 28, 2017,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     py.test plugin for purkinje test runner
+
+  :pypi:`pytest-pusher`
+     *last release*: Jan 06, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.6)
+
+     pytest plugin for push report to minio
+
+  :pypi:`pytest-py125`
+     *last release*: Dec 03, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-pycharm`
+     *last release*: Aug 13, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.3)
+
+     Plugin for py.test to enter PyCharm debugger on uncaught exceptions
+
+  :pypi:`pytest-pycodestyle`
+     *last release*: Oct 28, 2022,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to run pycodestyle
+
+  :pypi:`pytest-pydev`
+     *last release*: Nov 15, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     py.test plugin to connect to a remote debug server with PyDev or PyCharm.
+
+  :pypi:`pytest-pydocstyle`
+     *last release*: Jan 05, 2023,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to run pydocstyle
+
+  :pypi:`pytest-pylint`
+     *last release*: Sep 10, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.4)
+
+     pytest plugin to check source code with pylint
+
+  :pypi:`pytest-pymysql-autorecord`
+     *last release*: Sep 02, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Record PyMySQL queries and mock with the stored data.
+
+  :pypi:`pytest-pyodide`
+     *last release*: Jun 11, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     "Pytest plugin for testing applications that use Pyodide"
+
+  :pypi:`pytest-pypi`
+     *last release*: Mar 04, 2018,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Easily test your HTTP library against a local copy of pypi
+
+  :pypi:`pytest-pypom-navigation`
+     *last release*: Feb 18, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.0.7)
+
+     Core engine for cookiecutter-qa and pytest-play packages
+
+  :pypi:`pytest-pyppeteer`
+     *last release*: Apr 28, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5,<7.0.0)
+
+     A plugin to run pyppeteer in pytest
+
+  :pypi:`pytest-pyq`
+     *last release*: Mar 10, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest fixture "q" for pyq
+
+  :pypi:`pytest-pyramid`
+     *last release*: Dec 13, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite
+
+  :pypi:`pytest-pyramid-server`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pyramid server fixture for py.test
+
+  :pypi:`pytest-pyreport`
+     *last release*: May 08, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.3.1)
+
+     PyReport is a lightweight reporting plugin for Pytest that provides concise HTML report
+
+  :pypi:`pytest-pyright`
+     *last release*: Nov 20, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.0)
+
+     Pytest plugin for type checking code with Pyright
+
+  :pypi:`pytest-pyspec`
+     *last release*: Mar 12, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.2.1,<8.0.0)
+
+     A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it".
+
+  :pypi:`pytest-pystack`
+     *last release*: May 07, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     Plugin to run pystack after a timeout for a test suite.
+
+  :pypi:`pytest-pytestrail`
+     *last release*: Aug 27, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.8.0)
+
+     Pytest plugin for interaction with TestRail
+
+  :pypi:`pytest-pythonpath`
+     *last release*: Feb 10, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (<7,>=2.5.2)
+
+     pytest plugin for adding to the PYTHONPATH from command line or configs.
+
+  :pypi:`pytest-pytorch`
+     *last release*: May 25, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin for a better developer experience when working with the PyTorch test suite
+
+  :pypi:`pytest-pyvista`
+     *last release*: Mar 19, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest>=3.5.0
+
+     Pytest-pyvista package
+
+  :pypi:`pytest-qaseio`
+     *last release*: May 11, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.2.2,<8.0.0)
+
+     Pytest plugin for Qase.io integration
+
+  :pypi:`pytest-qasync`
+     *last release*: Jul 12, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.4.0)
+
+     Pytest support for qasync.
+
+  :pypi:`pytest-qatouch`
+     *last release*: Feb 14, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.0)
+
+     Pytest plugin for uploading test results to your QA Touch Testrun.
+
+  :pypi:`pytest-qgis`
+     *last release*: Jun 09, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.5)
+
+     A pytest plugin for testing QGIS python plugins
+
+  :pypi:`pytest-qml`
+     *last release*: Dec 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     Run QML Tests with pytest
+
+  :pypi:`pytest-qr`
+     *last release*: Nov 25, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to generate test result QR codes
+
+  :pypi:`pytest-qt`
+     *last release*: Oct 25, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0.0)
+
+     pytest support for PyQt and PySide applications
+
+  :pypi:`pytest-qt-app`
+     *last release*: Dec 23, 2015,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     QT app fixture for py.test
+
+  :pypi:`pytest-quarantine`
+     *last release*: Nov 24, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6)
+
+     A plugin for pytest to manage expected test failures
+
+  :pypi:`pytest-quickcheck`
+     *last release*: Nov 05, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.0)
+
+     pytest plugin to generate random data inspired by QuickCheck
+
+  :pypi:`pytest-rabbitmq`
+     *last release*: Jun 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2)
+
+     RabbitMQ process and client fixtures for pytest
+
+  :pypi:`pytest-race`
+     *last release*: Jun 07, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Race conditions tester for pytest
+
+  :pypi:`pytest-rage`
+     *last release*: Oct 21, 2011,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to implement PEP712
+
+  :pypi:`pytest-rail`
+     *last release*: May 02, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.6)
+
+     pytest plugin for creating TestRail runs and adding results
+
+  :pypi:`pytest-railflow-testrail-reporter`
+     *last release*: Jun 29, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Generate json reports along with specified metadata defined in test markers.
+
+  :pypi:`pytest-raises`
+     *last release*: Apr 23, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=3.2.2)
+
+     An implementation of pytest.raises as a pytest.mark fixture
+
+  :pypi:`pytest-raisesregexp`
+     *last release*: Dec 18, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     Simple pytest plugin to look for regex in Exceptions
+
+  :pypi:`pytest-raisin`
+     *last release*: Feb 06, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Plugin enabling the use of exception instances with pytest.raises
+
+  :pypi:`pytest-random`
+     *last release*: Apr 28, 2013,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     py.test plugin to randomize tests
+
+  :pypi:`pytest-randomly`
+     *last release*: May 11, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest plugin to randomly order tests and control random.seed.
+
+  :pypi:`pytest-randomness`
+     *last release*: May 30, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest plugin about random seed management
+
+  :pypi:`pytest-random-num`
+     *last release*: Oct 19, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Randomise the order in which pytest tests are run with some control over the randomness
+
+  :pypi:`pytest-random-order`
+     *last release*: Dec 03, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0.0)
+
+     Randomise the order in which pytest tests are run with some control over the randomness
+
+  :pypi:`pytest-readme`
+     *last release*: Sep 02, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Test your README.md file
+
+  :pypi:`pytest-reana`
+     *last release*: Dec 13, 2022,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest fixtures for REANA.
+
+  :pypi:`pytest-recorder`
+     *last release*: Mar 30, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs.
+
+  :pypi:`pytest-recording`
+     *last release*: Feb 16, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin that allows you recording of network interactions via VCR.py
+
+  :pypi:`pytest-recordings`
+     *last release*: Aug 13, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal
+
+  :pypi:`pytest-redis`
+     *last release*: Apr 19, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2)
+
+     Redis fixtures and fixture factories for Pytest.
+
+  :pypi:`pytest-redislite`
+     *last release*: Apr 05, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest plugin for testing code using Redis
+
+  :pypi:`pytest-redmine`
+     *last release*: Mar 19, 2018,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     Pytest plugin for redmine
+
+  :pypi:`pytest-ref`
+     *last release*: Nov 23, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin to store reference files to ease regression testing
+
+  :pypi:`pytest-reference-formatter`
+     *last release*: Oct 01, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Conveniently run pytest with a dot-formatted test reference.
+
+  :pypi:`pytest-regex`
+     *last release*: May 29, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Select pytest tests with regular expressions
+
+  :pypi:`pytest-regex-dependency`
+     *last release*: Jun 12, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Management of Pytest dependencies via regex patterns
+
+  :pypi:`pytest-regressions`
+     *last release*: Jan 13, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.0)
+
+     Easy to use fixtures to write regression tests.
+
+  :pypi:`pytest-regtest`
+     *last release*: Jul 08, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin for regression tests
+
+  :pypi:`pytest-relative-order`
+     *last release*: May 17, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     a pytest plugin that sorts tests using "before" and "after" markers
+
+  :pypi:`pytest-relaxed`
+     *last release*: May 23, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7)
+
+     Relaxed test discovery/organization for pytest
+
+  :pypi:`pytest-remfiles`
+     *last release*: Jul 01, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest plugin to create a temporary directory with remote files
+
+  :pypi:`pytest-remotedata`
+     *last release*: Dec 12, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin for controlling remote data access.
+
+  :pypi:`pytest-remote-response`
+     *last release*: Apr 26, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6)
+
+     Pytest plugin for capturing and mocking connection requests.
+
+  :pypi:`pytest-remove-stale-bytecode`
+     *last release*: Mar 04, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     py.test plugin to remove stale byte code files.
+
+  :pypi:`pytest-reorder`
+     *last release*: May 31, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Reorder tests depending on their paths and names.
+
+  :pypi:`pytest-repeat`
+     *last release*: Oct 31, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.6)
+
+     pytest plugin for repeating tests
+
+  :pypi:`pytest-replay`
+     *last release*: Jun 09, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.0.0)
+
+     Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests
+
+  :pypi:`pytest-repo-health`
+     *last release*: Apr 17, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     A pytest plugin to report on repository standards conformance
+
+  :pypi:`pytest-report`
+     *last release*: May 11, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Creates json report that is compatible with atom.io's linter message format
+
+  :pypi:`pytest-reporter`
+     *last release*: Jul 22, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Generate Pytest reports with templates
+
+  :pypi:`pytest-reporter-html1`
+     *last release*: Jun 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A basic HTML report template for Pytest
+
+  :pypi:`pytest-reporter-html-dots`
+     *last release*: Jan 22, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A basic HTML report for pytest using Jinja2 template engine.
+
+  :pypi:`pytest-reportinfra`
+     *last release*: Aug 11, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest plugin for reportinfra
+
+  :pypi:`pytest-reporting`
+     *last release*: Oct 25, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin to report summarized results in a table format
+
+  :pypi:`pytest-reportlog`
+     *last release*: May 22, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Replacement for the --resultlog option, focused in simplicity and extensibility
+
+  :pypi:`pytest-report-me`
+     *last release*: Dec 31, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin to generate report.
+
+  :pypi:`pytest-report-parameters`
+     *last release*: Jun 18, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.4.2)
+
+     pytest plugin for adding tests' parameters to junit report
+
+  :pypi:`pytest-reportportal`
+     *last release*: Jun 08, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=3.8.0)
+
+     Agent for Reporting results of tests to the Report Portal
+
+  :pypi:`pytest-reports`
+     *last release*: Jun 07, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     An interesting python package
+
+  :pypi:`pytest-reqs`
+     *last release*: May 12, 2019,
+     *status*: N/A,
+     *requires*: pytest (>=2.4.2)
+
+     pytest plugin to check pinned requirements
+
+  :pypi:`pytest-requests`
+     *last release*: Jun 24, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-requestselapsed`
+     *last release*: Aug 14, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     collect and show http requests elapsed time
+
+  :pypi:`pytest-requests-futures`
+     *last release*: Jul 06, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest Plugin to Mock Requests Futures
+
+  :pypi:`pytest-requires`
+     *last release*: Dec 21, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin to elegantly skip tests with optional requirements
+
+  :pypi:`pytest-reraise`
+     *last release*: Sep 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6)
+
+     Make multi-threaded pytest test cases fail when they should
+
+  :pypi:`pytest-rerun`
+     *last release*: Jul 08, 2019,
+     *status*: N/A,
+     *requires*: pytest (>=3.6)
+
+     Re-run only changed files in specified branch
+
+  :pypi:`pytest-rerunfailures`
+     *last release*: Mar 09, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.3)
+
+     pytest plugin to re-run tests to eliminate flaky failures
+
+  :pypi:`pytest-rerunfailures-all-logs`
+     *last release*: Mar 07, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin to re-run tests to eliminate flaky failures
+
+  :pypi:`pytest-reserial`
+     *last release*: Apr 26, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Pytest fixture for recording and replaying serial port traffic.
+
+  :pypi:`pytest-resilient-circuits`
+     *last release*: Jun 01, 2023,
+     *status*: N/A,
+     *requires*: pytest (~=4.6) ; python_version == "2.7"
+
+     Resilient Circuits fixtures for PyTest
+
+  :pypi:`pytest-resource`
+     *last release*: Nov 14, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Load resource fixture plugin to use with pytest
+
+  :pypi:`pytest-resource-path`
+     *last release*: May 01, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.5.0)
+
+     Provides path for uniform access to test resources in isolated directory
+
+  :pypi:`pytest-resource-usage`
+     *last release*: Nov 06, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7.0.0
+
+     Pytest plugin for reporting running time and peak memory usage
+
+  :pypi:`pytest-responsemock`
+     *last release*: Mar 10, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Simplified requests calls mocking for pytest
+
+  :pypi:`pytest-responses`
+     *last release*: Oct 11, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=2.5)
+
+     py.test integration for responses
+
+  :pypi:`pytest-rest-api`
+     *last release*: Aug 08, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.2,<8.0.0)
+
+
+
+  :pypi:`pytest-restrict`
+     *last release*: Jun 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest plugin to restrict the test types allowed
+
+  :pypi:`pytest-result-log`
+     *last release*: Apr 17, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7.2.0
+
+     Write the execution result of the case to the log
+
+  :pypi:`pytest-result-sender`
+     *last release*: Apr 20, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7.3.1
+
+
+
+  :pypi:`pytest-resume`
+     *last release*: Apr 22, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0)
+
+     A Pytest plugin to resuming from the last run test
+
+  :pypi:`pytest-rethinkdb`
+     *last release*: Jul 24, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A RethinkDB plugin for pytest.
+
+  :pypi:`pytest-retry`
+     *last release*: Aug 16, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.0.0)
+
+     Adds the ability to retry flaky tests in CI environments
+
+  :pypi:`pytest-retry-class`
+     *last release*: Mar 25, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=5.3)
+
+     A pytest plugin to rerun entire class on failure
+
+  :pypi:`pytest-reusable-testcases`
+     *last release*: Apr 28, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-reverse`
+     *last release*: Jun 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest plugin to reverse test order.
+
+  :pypi:`pytest-rich`
+     *last release*: Mar 03, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0)
+
+     Leverage rich for richer test session output
+
+  :pypi:`pytest-rich-reporter`
+     *last release*: Feb 17, 2022,
+     *status*: 1 - Planning,
+     *requires*: pytest (>=5.0.0)
+
+     A pytest plugin using Rich for beautiful test result formatting.
+
+  :pypi:`pytest-richtrace`
+     *last release*: Nov 05, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0,<8.0.0)
+
+
+
+  :pypi:`pytest-ringo`
+     *last release*: Sep 27, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin to test webapplications using the Ringo webframework
+
+  :pypi:`pytest-rmsis`
+     *last release*: Aug 10, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5.3.5)
+
+     Sycronise pytest results to Jira RMsis
+
+  :pypi:`pytest-rng`
+     *last release*: Aug 08, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Fixtures for seeding tests and making randomness reproducible
+
+  :pypi:`pytest-roast`
+     *last release*: Nov 09, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     pytest plugin for ROAST configuration override and fixtures
+
+  :pypi:`pytest-rocketchat`
+     *last release*: Apr 18, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest to Rocket.Chat reporting plugin
+
+  :pypi:`pytest-rotest`
+     *last release*: Sep 08, 2019,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest integration with rotest
+
+  :pypi:`pytest-rpc`
+     *last release*: Feb 22, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (~=3.6)
+
+     Extend py.test for RPC OpenStack testing.
+
+  :pypi:`pytest-rst`
+     *last release*: Jan 26, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Test code from RST documents with pytest
+
+  :pypi:`pytest-rt`
+     *last release*: May 05, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest data collector plugin for Testgr
+
+  :pypi:`pytest-rts`
+     *last release*: May 17, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     Coverage-based regression test selection (RTS) plugin for pytest
+
+  :pypi:`pytest-ruff`
+     *last release*: Jun 08, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest plugin to check ruff requirements.
+
+  :pypi:`pytest-run-changed`
+     *last release*: Apr 02, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     Pytest plugin that runs changed tests only
+
+  :pypi:`pytest-runfailed`
+     *last release*: Mar 24, 2016,
+     *status*: N/A,
+     *requires*: N/A
+
+     implement a --failed option for pytest
+
+  :pypi:`pytest-runner`
+     *last release*: Feb 25, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6) ; extra == 'testing'
+
+     Invoke py.test as distutils command with dependency resolution
+
+  :pypi:`pytest-run-subprocess`
+     *last release*: Nov 12, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest Plugin for running and testing subprocesses.
+
+  :pypi:`pytest-runtime-types`
+     *last release*: Feb 09, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     Checks type annotations on runtime while running tests.
+
+  :pypi:`pytest-runtime-xfail`
+     *last release*: Aug 26, 2021,
+     *status*: N/A,
+     *requires*: pytest>=5.0.0
+
+     Call runtime_xfail() to mark running test as xfail.
+
+  :pypi:`pytest-runtime-yoyo`
+     *last release*: Jun 12, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0)
+
+     run case mark timeout
+
+  :pypi:`pytest-ry-demo1`
+     *last release*: Mar 26, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     测试
+
+  :pypi:`pytest-saccharin`
+     *last release*: Oct 31, 2022,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest-saccharin is a updated fork of pytest-sugar, a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly).
+
+  :pypi:`pytest-salt`
+     *last release*: Jan 27, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest Salt Plugin
+
+  :pypi:`pytest-salt-containers`
+     *last release*: Nov 09, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A Pytest plugin that builds and creates docker containers
+
+  :pypi:`pytest-salt-factories`
+     *last release*: Dec 15, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     Pytest Salt Plugin
+
+  :pypi:`pytest-salt-from-filenames`
+     *last release*: Jan 29, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.1)
+
+     Simple PyTest Plugin For Salt's Test Suite Specifically
+
+  :pypi:`pytest-salt-runtests-bridge`
+     *last release*: Dec 05, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=4.1)
+
+     Simple PyTest Plugin For Salt's Test Suite Specifically
+
+  :pypi:`pytest-sanic`
+     *last release*: Oct 25, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=5.2)
+
+     a pytest plugin for Sanic
+
+  :pypi:`pytest-sanity`
+     *last release*: Dec 07, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-sa-pg`
+     *last release*: May 14, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-sbase`
+     *last release*: Jun 13, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A complete web automation framework for end-to-end testing.
+
+  :pypi:`pytest-scenario`
+     *last release*: Feb 06, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin for test scenarios
+
+  :pypi:`pytest-schedule`
+     *last release*: Jan 07, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     The job of test scheduling for humans.
+
+  :pypi:`pytest-schema`
+     *last release*: Mar 14, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.5.0)
+
+     👍 Validate return values against a schema-like object in testing
+
+  :pypi:`pytest-securestore`
+     *last release*: Nov 08, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     An encrypted password store for use within pytest cases
+
+  :pypi:`pytest-select`
+     *last release*: Jan 18, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0)
+
+     A pytest plugin which allows to (de-)select tests from a file.
+
+  :pypi:`pytest-selenium`
+     *last release*: May 28, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=6.0.0
+
+     pytest plugin for Selenium
+
+  :pypi:`pytest-seleniumbase`
+     *last release*: Jun 13, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A complete web automation framework for end-to-end testing.
+
+  :pypi:`pytest-selenium-enhancer`
+     *last release*: Apr 29, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for Selenium
+
+  :pypi:`pytest-selenium-pdiff`
+     *last release*: Apr 06, 2017,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     A pytest package implementing perceptualdiff for Selenium tests.
+
+  :pypi:`pytest-send-email`
+     *last release*: Dec 04, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Send pytest execution result email
+
+  :pypi:`pytest-sentry`
+     *last release*: Jan 05, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin to send testrun information to Sentry.io
+
+  :pypi:`pytest-sequence-markers`
+     *last release*: May 23, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest plugin for sequencing markers for execution of tests
+
+  :pypi:`pytest-server-fixtures`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Extensible server fixures for py.test
+
+  :pypi:`pytest-serverless`
+     *last release*: May 09, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Automatically mocks resources from serverless.yml in pytest using moto.
+
+  :pypi:`pytest-servers`
+     *last release*: Apr 15, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=6.2)
+
+     pytest servers
+
+  :pypi:`pytest-services`
+     *last release*: Oct 30, 2020,
+     *status*: 6 - Mature,
+     *requires*: N/A
+
+     Services plugin for pytest testing framework
+
+  :pypi:`pytest-session2file`
+     *last release*: Jan 26, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test.
+
+  :pypi:`pytest-session-fixture-globalize`
+     *last release*: May 15, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to make session fixtures behave as if written in conftest, even if it is written in some modules
+
+  :pypi:`pytest-session_to_file`
+     *last release*: Oct 01, 2015,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest-session_to_file is a py.test plugin for capturing and saving to file the stdout of py.test.
+
+  :pypi:`pytest-setupinfo`
+     *last release*: Jan 23, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Displaying setup info during pytest command run
+
+  :pypi:`pytest-sftpserver`
+     *last release*: Sep 16, 2019,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to locally test sftp server connections.
+
+  :pypi:`pytest-shard`
+     *last release*: Dec 11, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-share-hdf`
+     *last release*: Sep 21, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Plugin to save test data in HDF files and retrieve them for comparison
+
+  :pypi:`pytest-sharkreport`
+     *last release*: Jul 11, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=3.5)
+
+     this is pytest report plugin.
+
+  :pypi:`pytest-shell`
+     *last release*: Mar 27, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin to help with testing shell scripts / black box commands
+
+  :pypi:`pytest-shell-utilities`
+     *last release*: Sep 23, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     Pytest plugin to simplify running shell commands against the system
+
+  :pypi:`pytest-sheraf`
+     *last release*: Feb 11, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Versatile ZODB abstraction layer - pytest fixtures
+
+  :pypi:`pytest-sherlock`
+     *last release*: Jan 16, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.5.1)
+
+     pytest plugin help to find coupled tests
+
+  :pypi:`pytest-shortcuts`
+     *last release*: Oct 29, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Expand command-line shortcuts listed in pytest configuration
+
+  :pypi:`pytest-shutil`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A goodie-bag of unix shell and environment tools for py.test
+
+  :pypi:`pytest-simplehttpserver`
+     *last release*: Jun 24, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Simple pytest fixture to spin up an HTTP server
+
+  :pypi:`pytest-simple-plugin`
+     *last release*: Nov 27, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     Simple pytest plugin
+
+  :pypi:`pytest-simple-settings`
+     *last release*: Nov 17, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     simple-settings plugin for pytest
+
+  :pypi:`pytest-single-file-logging`
+     *last release*: May 05, 2016,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.1)
+
+     Allow for multiple processes to log to a single file
+
+  :pypi:`pytest-skip-markers`
+     *last release*: Dec 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.1.0)
+
+     Pytest Salt Plugin
+
+  :pypi:`pytest-skipper`
+     *last release*: Mar 26, 2017,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0.6)
+
+     A plugin that selects only tests with changes in execution path
+
+  :pypi:`pytest-skippy`
+     *last release*: Jan 27, 2018,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.3.4)
+
+     Automatically skip tests that don't need to run!
+
+  :pypi:`pytest-skip-slow`
+     *last release*: Feb 09, 2023,
+     *status*: N/A,
+     *requires*: pytest>=6.2.0
+
+     A pytest plugin to skip \`@pytest.mark.slow\` tests by default.
+
+  :pypi:`pytest-slack`
+     *last release*: Dec 15, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest to Slack reporting plugin
+
+  :pypi:`pytest-slow`
+     *last release*: Sep 28, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     A pytest plugin to skip \`@pytest.mark.slow\` tests by default.
+
+  :pypi:`pytest-slowest-first`
+     *last release*: Dec 11, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Sort tests by their last duration, slowest first
+
+  :pypi:`pytest-slow-last`
+     *last release*: Dec 10, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Run tests in order of execution time (faster tests first)
+
+  :pypi:`pytest-smartcollect`
+     *last release*: Oct 04, 2018,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     A plugin for collecting tests that touch changed code
+
+  :pypi:`pytest-smartcov`
+     *last release*: Sep 30, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Smart coverage plugin for pytest.
+
+  :pypi:`pytest-smell`
+     *last release*: Jun 26, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Automated bad smell detection tool for Pytest
+
+  :pypi:`pytest-smtp`
+     *last release*: Feb 20, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     Send email with pytest execution result
+
+  :pypi:`pytest-smtpd`
+     *last release*: May 15, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     An SMTP server for testing built on aiosmtpd
+
+  :pypi:`pytest-snail`
+     *last release*: Nov 04, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=5.0.1)
+
+     Plugin for adding a marker to slow running tests. 🐌
+
+  :pypi:`pytest-snapci`
+     *last release*: Nov 12, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     py.test plugin for Snap-CI
+
+  :pypi:`pytest-snapshot`
+     *last release*: Apr 23, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.0.0)
+
+     A plugin for snapshot testing with pytest.
+
+  :pypi:`pytest-snmpserver`
+     *last release*: May 12, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-snowflake-bdd`
+     *last release*: Jan 05, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.0)
+
+     Setup test data and run tests on snowflake in BDD style!
+
+  :pypi:`pytest-socket`
+     *last release*: Feb 03, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.6.3)
+
+     Pytest Plugin to disable socket calls during tests
+
+  :pypi:`pytest-sofaepione`
+     *last release*: Aug 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Test the installation of SOFA and the SofaEpione plugin.
+
+  :pypi:`pytest-soft-assertions`
+     *last release*: May 05, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-solidity`
+     *last release*: Jan 15, 2022,
+     *status*: 1 - Planning,
+     *requires*: pytest (<7,>=6.0.1) ; extra == 'tests'
+
+     A PyTest library plugin for Solidity language.
+
+  :pypi:`pytest-solr`
+     *last release*: May 11, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0.0)
+
+     Solr process and client fixtures for py.test.
+
+  :pypi:`pytest-sorter`
+     *last release*: Apr 20, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     A simple plugin to first execute tests that historically failed more
+
+  :pypi:`pytest-sosu`
+     *last release*: Feb 14, 2023,
+     *status*: 2 - Pre-Alpha,
+     *requires*: pytest
+
+     Unofficial PyTest plugin for Sauce Labs
+
+  :pypi:`pytest-sourceorder`
+     *last release*: Sep 01, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Test-ordering plugin for pytest
+
+  :pypi:`pytest-spark`
+     *last release*: Feb 23, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     pytest plugin to run the tests with support of pyspark.
+
+  :pypi:`pytest-spawner`
+     *last release*: Jul 31, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to spawn process and communicate with them.
+
+  :pypi:`pytest-spec`
+     *last release*: May 04, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION.
+
+  :pypi:`pytest-spec2md`
+     *last release*: Jun 26, 2022,
+     *status*: N/A,
+     *requires*: pytest (>7.0)
+
+     Library pytest-spec2md is a pytest plugin to create a markdown specification while running pytest.
+
+  :pypi:`pytest-speed`
+     *last release*: Jan 22, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest>=7
+
+     Modern benchmarking library for python with pytest integration.
+
+  :pypi:`pytest-sphinx`
+     *last release*: Sep 06, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.0)
+
+     Doctest plugin for pytest with support for Sphinx-specific doctest-directives
+
+  :pypi:`pytest-spiratest`
+     *last release*: Feb 08, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Exports unit tests as test runs in SpiraTest/Team/Plan
+
+  :pypi:`pytest-splinter`
+     *last release*: Sep 09, 2022,
+     *status*: 6 - Mature,
+     *requires*: pytest (>=3.0.0)
+
+     Splinter plugin for pytest testing framework
+
+  :pypi:`pytest-splinter4`
+     *last release*: Jun 11, 2022,
+     *status*: 6 - Mature,
+     *requires*: pytest (<8.0,>=7.1.2)
+
+     Pytest plugin for the splinter automation library
+
+  :pypi:`pytest-split`
+     *last release*: Apr 12, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5,<8)
+
+     Pytest plugin which splits the test suite to equally sized sub suites based on test execution time.
+
+  :pypi:`pytest-splitio`
+     *last release*: Sep 22, 2020,
+     *status*: N/A,
+     *requires*: pytest (<7,>=5.0)
+
+     Split.io SDK integration for e2e tests
+
+  :pypi:`pytest-split-tests`
+     *last release*: Jul 30, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.5)
+
+     A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups.
+
+  :pypi:`pytest-split-tests-tresorit`
+     *last release*: Feb 22, 2021,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-splunk-addon`
+     *last release*: Feb 22, 2023,
+     *status*: N/A,
+     *requires*: pytest (>5.4.0,<7.3)
+
+     A Dynamic test tool for Splunk Apps and Add-ons
+
+  :pypi:`pytest-splunk-addon-ui-smartx`
+     *last release*: Mar 07, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Library to support testing Splunk Add-on UX
+
+  :pypi:`pytest-splunk-env`
+     *last release*: Oct 22, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=6.1.1,<7.0.0)
+
+     pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud
+
+  :pypi:`pytest-sqitch`
+     *last release*: Apr 06, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     sqitch for pytest
+
+  :pypi:`pytest-sqlalchemy`
+     *last release*: Mar 13, 2018,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest plugin with sqlalchemy related fixtures
+
+  :pypi:`pytest-sqlalchemy-mock`
+     *last release*: Mar 15, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.0)
+
+     pytest sqlalchemy plugin for mock
+
+  :pypi:`pytest-sqlalchemy-session`
+     *last release*: May 19, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0)
+
+     A pytest plugin for preserving test isolation that use SQLAlchemy.
+
+  :pypi:`pytest-sql-bigquery`
+     *last release*: Dec 19, 2019,
+     *status*: N/A,
+     *requires*: pytest
+
+     Yet another SQL-testing framework for BigQuery provided by pytest plugin
+
+  :pypi:`pytest-sqlfluff`
+     *last release*: Dec 21, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin to use sqlfluff to enable format checking of sql files.
+
+  :pypi:`pytest-squadcast`
+     *last release*: Feb 22, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest report plugin for Squadcast
+
+  :pypi:`pytest-srcpaths`
+     *last release*: Oct 15, 2021,
+     *status*: N/A,
+     *requires*: pytest>=6.2.0
+
+     Add paths to sys.path
+
+  :pypi:`pytest-ssh`
+     *last release*: May 27, 2019,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest plugin for ssh command run
+
+  :pypi:`pytest-start-from`
+     *last release*: Apr 11, 2016,
+     *status*: N/A,
+     *requires*: N/A
+
+     Start pytest run from a given point
+
+  :pypi:`pytest-star-track-issue`
+     *last release*: Feb 10, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package to prevent Dependency Confusion attacks against Yandex.
+
+  :pypi:`pytest-static`
+     *last release*: May 07, 2023,
+     *status*: 1 - Planning,
+     *requires*: N/A
+
+     pytest-static
+
+  :pypi:`pytest-statsd`
+     *last release*: Nov 30, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0.0)
+
+     pytest plugin for reporting to graphite
+
+  :pypi:`pytest-stepfunctions`
+     *last release*: May 08, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A small description
+
+  :pypi:`pytest-steps`
+     *last release*: Sep 23, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Create step-wise / incremental tests in pytest.
+
+  :pypi:`pytest-stepwise`
+     *last release*: Dec 01, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Run a test suite one failing test at a time.
+
+  :pypi:`pytest-stf`
+     *last release*: Dec 04, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5.0)
+
+     pytest plugin for openSTF
+
+  :pypi:`pytest-stoq`
+     *last release*: Feb 09, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A plugin to pytest stoq
+
+  :pypi:`pytest-stress`
+     *last release*: Dec 07, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.6.0)
+
+     A Pytest plugin that allows you to loop tests for a user defined amount of time.
+
+  :pypi:`pytest-structlog`
+     *last release*: Dec 18, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Structured logging assertions
+
+  :pypi:`pytest-structmpd`
+     *last release*: Oct 17, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     provide structured temporary directory
+
+  :pypi:`pytest-stub`
+     *last release*: Apr 28, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Stub packages, modules and attributes.
+
+  :pypi:`pytest-stubprocess`
+     *last release*: Sep 17, 2018,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.5.0)
+
+     Provide stub implementations for subprocesses in Python tests
+
+  :pypi:`pytest-study`
+     *last release*: Sep 26, 2017,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.0)
+
+     A pytest plugin to organize long run tests (named studies) without interfering the regular tests
+
+  :pypi:`pytest-subprocess`
+     *last release*: Jan 28, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.0.0)
+
+     A plugin to fake subprocess for pytest
+
+  :pypi:`pytest-subtesthack`
+     *last release*: Jul 16, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A hack to explicitly set up and tear down fixtures.
+
+  :pypi:`pytest-subtests`
+     *last release*: May 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0)
+
+     unittest subTest() support and subtests fixture
+
+  :pypi:`pytest-subunit`
+     *last release*: Aug 29, 2017,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest-subunit is a plugin for py.test which outputs testsresult in subunit format.
+
+  :pypi:`pytest-sugar`
+     *last release*: Apr 10, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.0)
+
+     pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly).
+
+  :pypi:`pytest-suitemanager`
+     *last release*: Apr 28, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A simple plugin to use with pytest
+
+  :pypi:`pytest-svn`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     SVN repository fixture for py.test
+
+  :pypi:`pytest-symbols`
+     *last release*: Nov 20, 2017,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests.
+
+  :pypi:`pytest-system-statistics`
+     *last release*: Feb 16, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.0.0)
+
+     Pytest plugin to track and report system usage statistics
+
+  :pypi:`pytest-system-test-plugin`
+     *last release*: Feb 03, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pyst - Pytest System-Test Plugin
+
+  :pypi:`pytest-tagging`
+     *last release*: Apr 01, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.3,<8.0.0)
+
+     a pytest plugin to tag tests
+
+  :pypi:`pytest-takeltest`
+     *last release*: Feb 15, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     Fixtures for ansible, testinfra and molecule
+
+  :pypi:`pytest-talisker`
+     *last release*: Nov 28, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-tally`
+     *last release*: May 22, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.5)
+
+     A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard.
+
+  :pypi:`pytest-tap`
+     *last release*: Oct 27, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.0)
+
+     Test Anything Protocol (TAP) reporting plugin for pytest
+
+  :pypi:`pytest-tape`
+     *last release*: Mar 17, 2021,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     easy assertion with expected results saved to yaml files
+
+  :pypi:`pytest-target`
+     *last release*: Jan 21, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=6.1.2,<7.0.0)
+
+     Pytest plugin for remote target orchestration.
+
+  :pypi:`pytest-tblineinfo`
+     *last release*: Dec 01, 2015,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=2.0)
+
+     tblineinfo is a py.test plugin that insert the node id in the final py.test report when --tb=line option is used
+
+  :pypi:`pytest-tcpclient`
+     *last release*: Nov 16, 2022,
+     *status*: N/A,
+     *requires*: pytest (<8,>=7.1.3)
+
+     A pytest plugin for testing TCP clients
+
+  :pypi:`pytest-teamcity-logblock`
+     *last release*: May 15, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     py.test plugin to introduce block structure in teamcity build log, if output is not captured
+
+  :pypi:`pytest-telegram`
+     *last release*: Dec 10, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest to Telegram reporting plugin
+
+  :pypi:`pytest-telegram-notifier`
+     *last release*: Mar 17, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Telegram notification plugin for Pytest
+
+  :pypi:`pytest-tempdir`
+     *last release*: Oct 11, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.1)
+
+     Predictable and repeatable tempdir support.
+
+  :pypi:`pytest-terra-fixt`
+     *last release*: Sep 15, 2022,
+     *status*: N/A,
+     *requires*: pytest (==6.2.5)
+
+     Terraform and Terragrunt fixtures for pytest
+
+  :pypi:`pytest-terraform`
+     *last release*: Sep 01, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.0)
+
+     A pytest plugin for using terraform fixtures
+
+  :pypi:`pytest-terraform-fixture`
+     *last release*: Nov 14, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     generate terraform resources to use with pytest
+
+  :pypi:`pytest-testbook`
+     *last release*: Dec 11, 2016,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     A plugin to run tests written in Jupyter notebook
+
+  :pypi:`pytest-testconfig`
+     *last release*: Jan 11, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Test configuration plugin for pytest.
+
+  :pypi:`pytest-testdirectory`
+     *last release*: May 02, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A py.test plugin providing temporary directories in unit tests.
+
+  :pypi:`pytest-testdox`
+     *last release*: Apr 19, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.6.0)
+
+     A testdox format reporter for pytest
+
+  :pypi:`pytest-test-grouping`
+     *last release*: Feb 01, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.5)
+
+     A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups.
+
+  :pypi:`pytest-test-groups`
+     *last release*: Oct 25, 2016,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups.
+
+  :pypi:`pytest-testinfra`
+     *last release*: May 21, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (!=3.0.2)
+
+     Test infrastructures
+
+  :pypi:`pytest-testlink-adaptor`
+     *last release*: Dec 20, 2018,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.6)
+
+     pytest reporting plugin for testlink
+
+  :pypi:`pytest-testmon`
+     *last release*: Jun 16, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     selects tests affected by changed files and methods
+
+  :pypi:`pytest-testmon-dev`
+     *last release*: Mar 30, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (<8,>=5)
+
+     selects tests affected by changed files and methods
+
+  :pypi:`pytest-testmon-oc`
+     *last release*: Jun 01, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (<8,>=5)
+
+     nOly selects tests affected by changed files and methods
+
+  :pypi:`pytest-testmon-skip-libraries`
+     *last release*: Mar 03, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (<8,>=5)
+
+     selects tests affected by changed files and methods
+
+  :pypi:`pytest-testobject`
+     *last release*: Sep 24, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     Plugin to use TestObject Suites with Pytest
+
+  :pypi:`pytest-testpluggy`
+     *last release*: Jan 07, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     set your encoding
+
+  :pypi:`pytest-testrail`
+     *last release*: Aug 27, 2020,
+     *status*: N/A,
+     *requires*: pytest (>=3.6)
+
+     pytest plugin for creating TestRail runs and adding results
+
+  :pypi:`pytest-testrail2`
+     *last release*: Feb 10, 2023,
+     *status*: N/A,
+     *requires*: pytest (<8.0,>=7.2.0)
+
+     A pytest plugin to upload results to TestRail.
+
+  :pypi:`pytest-testrail-api-client`
+     *last release*: Dec 14, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     TestRail Api Python Client
+
+  :pypi:`pytest-testrail-appetize`
+     *last release*: Sep 29, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin for creating TestRail runs and adding results
+
+  :pypi:`pytest-testrail-client`
+     *last release*: Sep 29, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest plugin for Testrail
+
+  :pypi:`pytest-testrail-e2e`
+     *last release*: Oct 11, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=3.6)
+
+     pytest plugin for creating TestRail runs and adding results
+
+  :pypi:`pytest-testrail-integrator`
+     *last release*: Aug 01, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5)
+
+     Pytest plugin for sending report to testrail system.
+
+  :pypi:`pytest-testrail-ns`
+     *last release*: Aug 12, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest plugin for creating TestRail runs and adding results
+
+  :pypi:`pytest-testrail-plugin`
+     *last release*: Apr 21, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     PyTest plugin for TestRail
+
+  :pypi:`pytest-testrail-reporter`
+     *last release*: Sep 10, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-testreport`
+     *last release*: Dec 01, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+
+
+  :pypi:`pytest-testreport-new`
+     *last release*: Aug 15, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+
+
+  :pypi:`pytest-testslide`
+     *last release*: Jan 07, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (~=6.2)
+
+     TestSlide fixture for pytest
+
+  :pypi:`pytest-test-this`
+     *last release*: Sep 15, 2019,
+     *status*: 2 - Pre-Alpha,
+     *requires*: pytest (>=2.3)
+
+     Plugin for py.test to run relevant tests, based on naively checking if a test contains a reference to the symbol you supply
+
+  :pypi:`pytest-test-utils`
+     *last release*: Jul 14, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5)
+
+
+
+  :pypi:`pytest-tesults`
+     *last release*: Dec 23, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.5.0)
+
+     Tesults plugin for pytest
+
+  :pypi:`pytest-tezos`
+     *last release*: Jan 16, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest-ligo
+
+  :pypi:`pytest-th2-bdd`
+     *last release*: May 13, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     pytest_th2_bdd
+
+  :pypi:`pytest-thawgun`
+     *last release*: May 26, 2020,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     Pytest plugin for time travel
+
+  :pypi:`pytest-threadleak`
+     *last release*: Jul 03, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     Detects thread leaks
+
+  :pypi:`pytest-tick`
+     *last release*: Aug 31, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.5,<7.0.0)
+
+     Ticking on tests
+
+  :pypi:`pytest-time`
+     *last release*: Jun 16, 2023,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-timeit`
+     *last release*: Oct 13, 2016,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin to time test function runs
+
+  :pypi:`pytest-timeout`
+     *last release*: Jan 18, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=5.0.0)
+
+     pytest plugin to abort hanging tests
+
+  :pypi:`pytest-timeouts`
+     *last release*: Sep 21, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Linux-only Pytest plugin to control durations of various test case execution phases
+
+  :pypi:`pytest-timer`
+     *last release*: Jun 02, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     A timer plugin for pytest
+
+  :pypi:`pytest-timestamper`
+     *last release*: Jun 06, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest plugin to add a timestamp prefix to the pytest output
+
+  :pypi:`pytest-timestamps`
+     *last release*: Apr 01, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=5.2)
+
+     A simple plugin to view timestamps for each test
+
+  :pypi:`pytest-tipsi-django`
+     *last release*: Nov 17, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+
+
+  :pypi:`pytest-tipsi-testing`
+     *last release*: Nov 04, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.3.0)
+
+     Better fixtures management. Various helpers
+
+  :pypi:`pytest-tldr`
+     *last release*: Oct 26, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A pytest plugin that limits the output to just the things you need.
+
+  :pypi:`pytest-tm4j-reporter`
+     *last release*: Sep 01, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Cloud Jira Test Management (TM4J) PyTest reporter plugin
+
+  :pypi:`pytest-tmnet`
+     *last release*: Mar 01, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     A small example package
+
+  :pypi:`pytest-tmp-files`
+     *last release*: Apr 03, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     Utilities to create temporary file hierarchies in pytest.
+
+  :pypi:`pytest-tmpfs`
+     *last release*: Aug 29, 2022,
+     *status*: N/A,
+     *requires*: pytest
+
+     A pytest plugin that helps you on using a temporary filesystem for testing.
+
+  :pypi:`pytest-tmreport`
+     *last release*: Aug 12, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     this is a vue-element ui report for pytest
+
+  :pypi:`pytest-tmux`
+     *last release*: Apr 22, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin that enables tmux driven tests
+
+  :pypi:`pytest-todo`
+     *last release*: May 23, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     A small plugin for the pytest testing framework, marking TODO comments as failure
+
+  :pypi:`pytest-tomato`
+     *last release*: Mar 01, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-toolbelt`
+     *last release*: Aug 12, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+     This is just a collection of utilities for pytest, but don't really belong in pytest proper.
+
+  :pypi:`pytest-toolbox`
+     *last release*: Apr 07, 2018,
+     *status*: N/A,
+     *requires*: pytest (>=3.5.0)
+
+     Numerous useful plugins for pytest.
+
+  :pypi:`pytest-tools`
+     *last release*: Oct 21, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest tools
+
+  :pypi:`pytest-tornado`
+     *last release*: Jun 17, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.6)
+
+     A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.
+
+  :pypi:`pytest-tornado5`
+     *last release*: Nov 16, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.6)
+
+     A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.
+
+  :pypi:`pytest-tornado-yen3`
+     *last release*: Oct 15, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.
+
+  :pypi:`pytest-tornasync`
+     *last release*: Jul 15, 2019,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0)
+
+     py.test plugin for testing Python 3.5+ Tornado code
+
+  :pypi:`pytest-trace`
+     *last release*: Jun 19, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=4.6)
+
+     Save OpenTelemetry spans generated during testing
+
+  :pypi:`pytest-track`
+     *last release*: Feb 26, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.0)
+
+
+
+  :pypi:`pytest-translations`
+     *last release*: Nov 05, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Test your translation files.
+
+  :pypi:`pytest-travis-fold`
+     *last release*: Nov 29, 2017,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.6.0)
+
+     Folds captured output sections in Travis CI build log
+
+  :pypi:`pytest-trello`
+     *last release*: Nov 20, 2015,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Plugin for py.test that integrates trello using markers
+
+  :pypi:`pytest-trepan`
+     *last release*: Jul 28, 2018,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest plugin for trepan debugger.
+
+  :pypi:`pytest-trialtemp`
+     *last release*: Jun 08, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     py.test plugin for using the same _trial_temp working directory as trial
+
+  :pypi:`pytest-trio`
+     *last release*: Nov 01, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0)
+
+     Pytest plugin for trio
+
+  :pypi:`pytest-trytond`
+     *last release*: Nov 04, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5)
+
+     Pytest plugin for the Tryton server framework
+
+  :pypi:`pytest-tspwplib`
+     *last release*: Jan 08, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     A simple plugin to use with tspwplib
+
+  :pypi:`pytest-tst`
+     *last release*: Apr 27, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=5.0.0)
+
+     Customize pytest options, output and exit code to make it compatible with tst
+
+  :pypi:`pytest-tstcls`
+     *last release*: Mar 23, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Test Class Base
+
+  :pypi:`pytest-tui`
+     *last release*: Jun 12, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Text User Interface (TUI) and HTML report for Pytest test runs
+
+  :pypi:`pytest-tutorials`
+     *last release*: Mar 11, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-twilio-conversations-client-mock`
+     *last release*: Aug 02, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-twisted`
+     *last release*: Oct 16, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.3)
+
+     A twisted plugin for pytest.
+
+  :pypi:`pytest-typechecker`
+     *last release*: Feb 04, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.5,<7.0.0)
+
+     Run type checkers on specified test files
+
+  :pypi:`pytest-typhoon-config`
+     *last release*: Apr 07, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     A Typhoon HIL plugin that facilitates test parameter configuration at runtime
+
+  :pypi:`pytest-typhoon-xray`
+     *last release*: Jun 10, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Typhoon HIL plugin for pytest
+
+  :pypi:`pytest-tytest`
+     *last release*: May 25, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=5.4.2)
+
+     Typhoon HIL plugin for pytest
+
+  :pypi:`pytest-ubersmith`
+     *last release*: Apr 13, 2015,
+     *status*: N/A,
+     *requires*: N/A
+
+     Easily mock calls to ubersmith at the \`requests\` level.
+
+  :pypi:`pytest-ui`
+     *last release*: Jul 05, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Text User Interface for running python tests
+
+  :pypi:`pytest-ui-failed-screenshot`
+     *last release*: Dec 06, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     UI自动测试失败时自动截图,并将截图加入到测试报告中
+
+  :pypi:`pytest-ui-failed-screenshot-allure`
+     *last release*: Dec 06, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     UI自动测试失败时自动截图,并将截图加入到Allure测试报告中
+
+  :pypi:`pytest-unflakable`
+     *last release*: Mar 24, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.0)
+
+     Unflakable plugin for PyTest
+
+  :pypi:`pytest-unhandled-exception-exit-code`
+     *last release*: Jun 22, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=2.3)
+
+     Plugin for py.test set a different exit code on uncaught exceptions
+
+  :pypi:`pytest-unittest-filter`
+     *last release*: Jan 12, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.0)
+
+     A pytest plugin for filtering unittest-based test classes
+
+  :pypi:`pytest-unmarked`
+     *last release*: Aug 27, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Run only unmarked tests
+
+  :pypi:`pytest-unordered`
+     *last release*: Nov 28, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.0.0)
+
+     Test equality of unordered collections in pytest
+
+  :pypi:`pytest-unstable`
+     *last release*: Sep 27, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Set a test as unstable to return 0 even if it failed
+
+  :pypi:`pytest-unused-fixtures`
+     *last release*: Jun 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.3.2,<8.0.0)
+
+     A pytest plugin to list unused fixtures after a test run.
+
+  :pypi:`pytest-upload-report`
+     *last release*: Jun 18, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     pytest-upload-report is a plugin for pytest that upload your test report for test results.
+
+  :pypi:`pytest-utils`
+     *last release*: Feb 02, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.0.0,<8.0.0)
+
+     Some helpers for pytest.
+
+  :pypi:`pytest-vagrant`
+     *last release*: Sep 07, 2021,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     A py.test plugin providing access to vagrant.
+
+  :pypi:`pytest-valgrind`
+     *last release*: May 19, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-variables`
+     *last release*: May 27, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest>=7.0.0
+
+     pytest plugin for providing variables to tests/fixtures
+
+  :pypi:`pytest-variant`
+     *last release*: Jun 06, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Variant support for Pytest
+
+  :pypi:`pytest-vcr`
+     *last release*: Apr 26, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=3.6.0)
+
+     Plugin for managing VCR.py cassettes
+
+  :pypi:`pytest-vcr-delete-on-fail`
+     *last release*: Jun 20, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.2)
+
+     A pytest plugin that automates vcrpy cassettes deletion on test failure.
+
+  :pypi:`pytest-vcrpandas`
+     *last release*: Jan 12, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     Test from HTTP interactions to dataframe processed.
+
+  :pypi:`pytest-vcs`
+     *last release*: Sep 22, 2022,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-venv`
+     *last release*: Aug 04, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+     py.test fixture for creating a virtual environment
+
+  :pypi:`pytest-ver`
+     *last release*: Mar 22, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Pytest module with Verification Protocol, Verification Report and Trace Matrix
+
+  :pypi:`pytest-verbose-parametrize`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     More descriptive output for parametrized py.test tests
+
+  :pypi:`pytest-vimqf`
+     *last release*: Feb 08, 2021,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=6.2.2,<7.0.0)
+
+     A simple pytest plugin that will shrink pytest output when specified, to fit vim quickfix window.
+
+  :pypi:`pytest-virtualenv`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Virtualenv fixture for py.test
+
+  :pypi:`pytest-vnc`
+     *last release*: Feb 25, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     VNC client for Pytest
+
+  :pypi:`pytest-voluptuous`
+     *last release*: Jun 09, 2020,
+     *status*: N/A,
+     *requires*: pytest
+
+     Pytest plugin for asserting data against voluptuous schema.
+
+  :pypi:`pytest-vscodedebug`
+     *last release*: Dec 04, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     A pytest plugin to easily enable debugging tests within Visual Studio Code
+
+  :pypi:`pytest-vscode-pycharm-cls`
+     *last release*: Feb 01, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+     A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used.
+
+  :pypi:`pytest-vts`
+     *last release*: Jun 05, 2019,
+     *status*: N/A,
+     *requires*: pytest (>=2.3)
+
+     pytest plugin for automatic recording of http stubbed tests
+
+  :pypi:`pytest-vulture`
+     *last release*: Jun 01, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.0.0)
+
+     A pytest plugin to checks dead code with vulture
+
+  :pypi:`pytest-vw`
+     *last release*: Oct 07, 2015,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     pytest-vw makes your failing test cases succeed under CI tools scrutiny
+
+  :pypi:`pytest-vyper`
+     *last release*: May 28, 2020,
+     *status*: 2 - Pre-Alpha,
+     *requires*: N/A
+
+     Plugin for the vyper smart contract language.
+
+  :pypi:`pytest-wa-e2e-plugin`
+     *last release*: Feb 18, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.5.0)
+
+     Pytest plugin for testing whatsapp bots with end to end tests
+
+  :pypi:`pytest-wake`
+     *last release*: May 11, 2023,
+     *status*: N/A,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-watch`
+     *last release*: May 20, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     Local continuous test runner with pytest and watchdog.
+
+  :pypi:`pytest-watcher`
+     *last release*: Jun 11, 2023,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Automatically rerun your tests on file modifications
+
+  :pypi:`pytest-wdl`
+     *last release*: Nov 17, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: N/A
+
+     Pytest plugin for testing WDL workflows.
+
+  :pypi:`pytest-web3-data`
+     *last release*: Sep 15, 2022,
+     *status*: 4 - Beta,
+     *requires*: pytest
+
+
+
+  :pypi:`pytest-webdriver`
+     *last release*: May 28, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Selenium webdriver fixture for py.test
+
+  :pypi:`pytest-wetest`
+     *last release*: Nov 10, 2018,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Welian API Automation test framework pytest plugin
+
+  :pypi:`pytest-when`
+     *last release*: Jun 05, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7.3.1
+
+     Utility which makes mocking more readable and controllable
+
+  :pypi:`pytest-whirlwind`
+     *last release*: Jun 12, 2020,
+     *status*: N/A,
+     *requires*: N/A
+
+     Testing Tornado.
+
+  :pypi:`pytest-wholenodeid`
+     *last release*: Aug 26, 2015,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.0)
+
+     pytest addon for displaying the whole node id for failures
+
+  :pypi:`pytest-win32consoletitle`
+     *last release*: Aug 08, 2021,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest progress in console title (Win32 only)
+
+  :pypi:`pytest-winnotify`
+     *last release*: Apr 22, 2016,
+     *status*: N/A,
+     *requires*: N/A
+
+     Windows tray notifications for py.test results.
+
+  :pypi:`pytest-wiremock`
+     *last release*: Mar 27, 2022,
+     *status*: N/A,
+     *requires*: pytest (>=7.1.1,<8.0.0)
+
+     A pytest plugin for programmatically using wiremock in integration tests
+
+  :pypi:`pytest-with-docker`
+     *last release*: Nov 09, 2021,
+     *status*: N/A,
+     *requires*: pytest
+
+     pytest with docker helpers.
+
+  :pypi:`pytest-workflow`
+     *last release*: Jan 13, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7.0.0)
+
+     A pytest plugin for configuring workflow/pipeline tests using YAML files
+
+  :pypi:`pytest-xdist`
+     *last release*: May 19, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=6.2.0)
+
+     pytest xdist plugin for distributed testing, most importantly across multiple CPUs
+
+  :pypi:`pytest-xdist-debug-for-graingert`
+     *last release*: Jul 24, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.4.0)
+
+     pytest xdist plugin for distributed testing and loop-on-failing modes
+
+  :pypi:`pytest-xdist-forked`
+     *last release*: Feb 10, 2020,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.4.0)
+
+     forked from pytest-xdist
+
+  :pypi:`pytest-xdist-tracker`
+     *last release*: Nov 18, 2021,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=3.5.1)
+
+     pytest plugin helps to reproduce failures for particular xdist node
+
+  :pypi:`pytest-xdist-worker-stats`
+     *last release*: Jun 15, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=7.3.2,<8.0.0)
+
+     A pytest plugin to list worker statistics after a xdist run.
+
+  :pypi:`pytest-xfaillist`
+     *last release*: Sep 17, 2021,
+     *status*: N/A,
+     *requires*: pytest (>=6.2.2,<7.0.0)
+
+     Maintain a xfaillist in an additional file to avoid merge-conflicts.
+
+  :pypi:`pytest-xfiles`
+     *last release*: Feb 27, 2018,
+     *status*: N/A,
+     *requires*: N/A
+
+     Pytest fixtures providing data read from function, module or package related (x)files.
+
+  :pypi:`pytest-xlog`
+     *last release*: May 31, 2020,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     Extended logging for test and decorators
+
+  :pypi:`pytest-xlsx`
+     *last release*: Mar 01, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7.2.0
+
+     pytest plugin for generating test cases by xlsx(excel)
+
+  :pypi:`pytest-xpara`
+     *last release*: Oct 30, 2017,
+     *status*: 3 - Alpha,
+     *requires*: pytest
+
+     An extended parametrizing plugin of pytest.
+
+  :pypi:`pytest-xprocess`
+     *last release*: Jan 05, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8)
+
+     A pytest plugin for managing processes across test runs.
+
+  :pypi:`pytest-xray`
+     *last release*: May 30, 2019,
+     *status*: 3 - Alpha,
+     *requires*: N/A
+
+
+
+  :pypi:`pytest-xrayjira`
+     *last release*: Mar 17, 2020,
+     *status*: 3 - Alpha,
+     *requires*: pytest (==4.3.1)
+
+
+
+  :pypi:`pytest-xray-server`
+     *last release*: May 03, 2022,
+     *status*: 3 - Alpha,
+     *requires*: pytest (>=5.3.1)
+
+
+
+  :pypi:`pytest-xskynet`
+     *last release*: Feb 10, 2023,
+     *status*: N/A,
+     *requires*: N/A
+
+     A package to prevent Dependency Confusion attacks against Yandex.
+
+  :pypi:`pytest-xvfb`
+     *last release*: May 29, 2023,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=2.8.1)
+
+     A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests.
+
+  :pypi:`pytest-yaml`
+     *last release*: Oct 05, 2018,
+     *status*: N/A,
+     *requires*: pytest
+
+     This plugin is used to load yaml output to your test using pytest framework.
+
+  :pypi:`pytest-yaml-sanmu`
+     *last release*: May 28, 2023,
+     *status*: N/A,
+     *requires*: pytest>=7.2.0
+
+     pytest plugin for generating test cases by yaml
+
+  :pypi:`pytest-yamltree`
+     *last release*: Mar 02, 2020,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     Create or check file/directory trees described by YAML
+
+  :pypi:`pytest-yamlwsgi`
+     *last release*: May 11, 2010,
+     *status*: N/A,
+     *requires*: N/A
+
+     Run tests against wsgi apps defined in yaml
+
+  :pypi:`pytest-yaml-yoyo`
+     *last release*: Jun 08, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.0)
+
+     http/https API run by yaml
+
+  :pypi:`pytest-yapf`
+     *last release*: Jul 06, 2017,
+     *status*: 4 - Beta,
+     *requires*: pytest (>=3.1.1)
+
+     Run yapf
+
+  :pypi:`pytest-yapf3`
+     *last release*: Mar 29, 2023,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=7)
+
+     Validate your Python file format with yapf
+
+  :pypi:`pytest-yield`
+     *last release*: Jan 23, 2019,
+     *status*: N/A,
+     *requires*: N/A
+
+     PyTest plugin to run tests concurrently, each \`yield\` switch context to other one
+
+  :pypi:`pytest-yls`
+     *last release*: Mar 29, 2023,
+     *status*: N/A,
+     *requires*: pytest (>=7.2.2,<8.0.0)
+
+     Pytest plugin to test the YLS as a whole.
+
+  :pypi:`pytest-yuk`
+     *last release*: Mar 26, 2021,
+     *status*: N/A,
+     *requires*: pytest>=5.0.0
+
+     Display tests you are uneasy with, using 🤢/🤮 for pass/fail of tests marked with yuk.
+
+  :pypi:`pytest-zafira`
+     *last release*: Sep 18, 2019,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (==4.1.1)
+
+     A Zafira plugin for pytest
+
+  :pypi:`pytest-zap`
+     *last release*: May 12, 2014,
+     *status*: 4 - Beta,
+     *requires*: N/A
+
+     OWASP ZAP plugin for py.test.
+
+  :pypi:`pytest-zebrunner`
+     *last release*: Dec 12, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest (>=4.5.0)
+
+     Pytest connector for Zebrunner reporting
+
+  :pypi:`pytest-zest`
+     *last release*: Nov 17, 2022,
+     *status*: N/A,
+     *requires*: N/A
+
+     Zesty additions to pytest.
+
+  :pypi:`pytest-zigzag`
+     *last release*: Feb 27, 2019,
+     *status*: 4 - Beta,
+     *requires*: pytest (~=3.6)
+
+     Extend py.test for RPC OpenStack testing.
+
+  :pypi:`pytest-zulip`
+     *last release*: May 07, 2022,
+     *status*: 5 - Production/Stable,
+     *requires*: pytest
+
+     Pytest report plugin for Zulip
diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst
new file mode 100644 (file)
index 0000000..6e11d38
--- /dev/null
@@ -0,0 +1,2141 @@
+.. _`api-reference`:
+
+API Reference
+=============
+
+This page contains the full reference to pytest's API.
+
+.. contents::
+    :depth: 3
+    :local:
+
+Constants
+---------
+
+pytest.__version__
+~~~~~~~~~~~~~~~~~~
+
+The current pytest version, as a string::
+
+    >>> import pytest
+    >>> pytest.__version__
+    '7.0.0'
+
+
+.. _`version-tuple`:
+
+pytest.version_tuple
+~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 7.0
+
+The current pytest version, as a tuple::
+
+    >>> import pytest
+    >>> pytest.version_tuple
+    (7, 0, 0)
+
+For pre-releases, the last component will be a string with the prerelease version::
+
+    >>> import pytest
+    >>> pytest.version_tuple
+    (7, 0, '0rc1')
+
+
+Functions
+---------
+
+pytest.approx
+~~~~~~~~~~~~~
+
+.. autofunction:: pytest.approx
+
+pytest.fail
+~~~~~~~~~~~
+
+**Tutorial**: :ref:`skipping`
+
+.. autofunction:: pytest.fail(reason, [pytrace=True, msg=None])
+
+pytest.skip
+~~~~~~~~~~~
+
+.. autofunction:: pytest.skip(reason, [allow_module_level=False, msg=None])
+
+.. _`pytest.importorskip ref`:
+
+pytest.importorskip
+~~~~~~~~~~~~~~~~~~~
+
+.. autofunction:: pytest.importorskip
+
+pytest.xfail
+~~~~~~~~~~~~
+
+.. autofunction:: pytest.xfail
+
+pytest.exit
+~~~~~~~~~~~
+
+.. autofunction:: pytest.exit(reason, [returncode=False, msg=None])
+
+pytest.main
+~~~~~~~~~~~
+
+**Tutorial**: :ref:`pytest.main-usage`
+
+.. autofunction:: pytest.main
+
+pytest.param
+~~~~~~~~~~~~
+
+.. autofunction:: pytest.param(*values, [id], [marks])
+
+pytest.raises
+~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`assertraises`
+
+.. autofunction:: pytest.raises(expected_exception: Exception [, *, match])
+    :with: excinfo
+
+pytest.deprecated_call
+~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`ensuring_function_triggers`
+
+.. autofunction:: pytest.deprecated_call([match])
+    :with:
+
+pytest.register_assert_rewrite
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`assertion-rewriting`
+
+.. autofunction:: pytest.register_assert_rewrite
+
+pytest.warns
+~~~~~~~~~~~~
+
+**Tutorial**: :ref:`assertwarnings`
+
+.. autofunction:: pytest.warns(expected_warning: Exception, [match])
+    :with:
+
+pytest.freeze_includes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`freezing-pytest`
+
+.. autofunction:: pytest.freeze_includes
+
+.. _`marks ref`:
+
+Marks
+-----
+
+Marks can be used apply meta data to *test functions* (but not fixtures), which can then be accessed by
+fixtures or plugins.
+
+
+
+
+.. _`pytest.mark.filterwarnings ref`:
+
+pytest.mark.filterwarnings
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`filterwarnings`
+
+Add warning filters to marked test items.
+
+.. py:function:: pytest.mark.filterwarnings(filter)
+
+    :keyword str filter:
+        A *warning specification string*, which is composed of contents of the tuple ``(action, message, category, module, lineno)``
+        as specified in :ref:`python:warning-filter` section of
+        the Python documentation, separated by ``":"``. Optional fields can be omitted.
+        Module names passed for filtering are not regex-escaped.
+
+        For example:
+
+        .. code-block:: python
+
+            @pytest.mark.filterwarnings("ignore:.*usage will be deprecated.*:DeprecationWarning")
+            def test_foo():
+                ...
+
+
+.. _`pytest.mark.parametrize ref`:
+
+pytest.mark.parametrize
+~~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`parametrize`
+
+This mark has the same signature as :py:meth:`pytest.Metafunc.parametrize`; see there.
+
+
+.. _`pytest.mark.skip ref`:
+
+pytest.mark.skip
+~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`skip`
+
+Unconditionally skip a test function.
+
+.. py:function:: pytest.mark.skip(reason=None)
+
+    :keyword str reason: Reason why the test function is being skipped.
+
+
+.. _`pytest.mark.skipif ref`:
+
+pytest.mark.skipif
+~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`skipif`
+
+Skip a test function if a condition is ``True``.
+
+.. py:function:: pytest.mark.skipif(condition, *, reason=None)
+
+    :type condition: bool or str
+    :param condition: ``True/False`` if the condition should be skipped or a :ref:`condition string <string conditions>`.
+    :keyword str reason: Reason why the test function is being skipped.
+
+
+.. _`pytest.mark.usefixtures ref`:
+
+pytest.mark.usefixtures
+~~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`usefixtures`
+
+Mark a test function as using the given fixture names.
+
+.. py:function:: pytest.mark.usefixtures(*names)
+
+    :param args: The names of the fixture to use, as strings.
+
+.. note::
+
+    When using `usefixtures` in hooks, it can only load fixtures when applied to a test function before test setup
+    (for example in the `pytest_collection_modifyitems` hook).
+
+    Also note that this mark has no effect when applied to **fixtures**.
+
+
+
+.. _`pytest.mark.xfail ref`:
+
+pytest.mark.xfail
+~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`xfail`
+
+Marks a test function as *expected to fail*.
+
+.. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=False)
+
+    :type condition: bool or str
+    :param condition:
+        Condition for marking the test function as xfail (``True/False`` or a
+        :ref:`condition string <string conditions>`). If a bool, you also have
+        to specify ``reason`` (see :ref:`condition string <string conditions>`).
+    :keyword str reason:
+        Reason why the test function is marked as xfail.
+    :keyword Type[Exception] raises:
+        Exception subclass (or tuple of subclasses) expected to be raised by the test function; other exceptions will fail the test.
+    :keyword bool run:
+        If the test function should actually be executed. If ``False``, the function will always xfail and will
+        not be executed (useful if a function is segfaulting).
+    :keyword bool strict:
+        * If ``False`` (the default) the function will be shown in the terminal output as ``xfailed`` if it fails
+          and as ``xpass`` if it passes. In both cases this will not cause the test suite to fail as a whole. This
+          is particularly useful to mark *flaky* tests (tests that fail at random) to be tackled later.
+        * If ``True``, the function will be shown in the terminal output as ``xfailed`` if it fails, but if it
+          unexpectedly passes then it will **fail** the test suite. This is particularly useful to mark functions
+          that are always failing and there should be a clear indication if they unexpectedly start to pass (for example
+          a new release of a library fixes a known bug).
+
+
+Custom marks
+~~~~~~~~~~~~
+
+Marks are created dynamically using the factory object ``pytest.mark`` and applied as a decorator.
+
+For example:
+
+.. code-block:: python
+
+    @pytest.mark.timeout(10, "slow", method="thread")
+    def test_function():
+        ...
+
+Will create and attach a :class:`Mark <pytest.Mark>` object to the collected
+:class:`Item <pytest.Item>`, which can then be accessed by fixtures or hooks with
+:meth:`Node.iter_markers <_pytest.nodes.Node.iter_markers>`. The ``mark`` object will have the following attributes:
+
+.. code-block:: python
+
+    mark.args == (10, "slow")
+    mark.kwargs == {"method": "thread"}
+
+Example for using multiple custom markers:
+
+.. code-block:: python
+
+    @pytest.mark.timeout(10, "slow", method="thread")
+    @pytest.mark.slow
+    def test_function():
+        ...
+
+When :meth:`Node.iter_markers <_pytest.nodes.Node.iter_markers>` or :meth:`Node.iter_markers_with_node <_pytest.nodes.Node.iter_markers_with_node>` is used with multiple markers, the marker closest to the function will be iterated over first. The above example will result in ``@pytest.mark.slow`` followed by ``@pytest.mark.timeout(...)``.
+
+.. _`fixtures-api`:
+
+Fixtures
+--------
+
+**Tutorial**: :ref:`fixture`
+
+Fixtures are requested by test functions or other fixtures by declaring them as argument names.
+
+
+Example of a test requiring a fixture:
+
+.. code-block:: python
+
+    def test_output(capsys):
+        print("hello")
+        out, err = capsys.readouterr()
+        assert out == "hello\n"
+
+
+Example of a fixture requiring another fixture:
+
+.. code-block:: python
+
+    @pytest.fixture
+    def db_session(tmp_path):
+        fn = tmp_path / "db.file"
+        return connect(fn)
+
+For more details, consult the full :ref:`fixtures docs <fixture>`.
+
+
+.. _`pytest.fixture-api`:
+
+@pytest.fixture
+~~~~~~~~~~~~~~~
+
+.. autofunction:: pytest.fixture
+    :decorator:
+
+
+.. fixture:: capfd
+
+capfd
+~~~~~~
+
+**Tutorial**: :ref:`captures`
+
+.. autofunction:: _pytest.capture.capfd()
+    :no-auto-options:
+
+
+.. fixture:: capfdbinary
+
+capfdbinary
+~~~~~~~~~~~~
+
+**Tutorial**: :ref:`captures`
+
+.. autofunction:: _pytest.capture.capfdbinary()
+    :no-auto-options:
+
+
+.. fixture:: caplog
+
+caplog
+~~~~~~
+
+**Tutorial**: :ref:`logging`
+
+.. autofunction:: _pytest.logging.caplog()
+    :no-auto-options:
+
+    Returns a :class:`pytest.LogCaptureFixture` instance.
+
+.. autoclass:: pytest.LogCaptureFixture()
+    :members:
+
+
+.. fixture:: capsys
+
+capsys
+~~~~~~
+
+**Tutorial**: :ref:`captures`
+
+.. autofunction:: _pytest.capture.capsys()
+    :no-auto-options:
+
+.. autoclass:: pytest.CaptureFixture()
+    :members:
+
+.. fixture:: capsysbinary
+
+capsysbinary
+~~~~~~~~~~~~
+
+**Tutorial**: :ref:`captures`
+
+.. autofunction:: _pytest.capture.capsysbinary()
+    :no-auto-options:
+
+
+.. fixture:: cache
+
+config.cache
+~~~~~~~~~~~~
+
+**Tutorial**: :ref:`cache`
+
+The ``config.cache`` object allows other plugins and fixtures
+to store and retrieve values across test runs. To access it from fixtures
+request ``pytestconfig`` into your fixture and get it with ``pytestconfig.cache``.
+
+Under the hood, the cache plugin uses the simple
+``dumps``/``loads`` API of the :py:mod:`json` stdlib module.
+
+``config.cache`` is an instance of :class:`pytest.Cache`:
+
+.. autoclass:: pytest.Cache()
+   :members:
+
+
+.. fixture:: doctest_namespace
+
+doctest_namespace
+~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`doctest`
+
+.. autofunction:: _pytest.doctest.doctest_namespace()
+
+
+.. fixture:: monkeypatch
+
+monkeypatch
+~~~~~~~~~~~
+
+**Tutorial**: :ref:`monkeypatching`
+
+.. autofunction:: _pytest.monkeypatch.monkeypatch()
+    :no-auto-options:
+
+    Returns a :class:`~pytest.MonkeyPatch` instance.
+
+.. autoclass:: pytest.MonkeyPatch
+    :members:
+
+
+.. fixture:: pytestconfig
+
+pytestconfig
+~~~~~~~~~~~~
+
+.. autofunction:: _pytest.fixtures.pytestconfig()
+
+
+.. fixture:: pytester
+
+pytester
+~~~~~~~~
+
+.. versionadded:: 6.2
+
+Provides a :class:`~pytest.Pytester` instance that can be used to run and test pytest itself.
+
+It provides an empty directory where pytest can be executed in isolation, and contains facilities
+to write tests, configuration files, and match against expected output.
+
+To use it, include in your topmost ``conftest.py`` file:
+
+.. code-block:: python
+
+    pytest_plugins = "pytester"
+
+
+
+.. autoclass:: pytest.Pytester()
+    :members:
+
+.. autoclass:: pytest.RunResult()
+    :members:
+
+.. autoclass:: pytest.LineMatcher()
+    :members:
+    :special-members: __str__
+
+.. autoclass:: pytest.HookRecorder()
+    :members:
+
+.. autoclass:: pytest.RecordedHookCall()
+    :members:
+
+
+.. fixture:: record_property
+
+record_property
+~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`record_property example`
+
+.. autofunction:: _pytest.junitxml.record_property()
+
+
+.. fixture:: record_testsuite_property
+
+record_testsuite_property
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`record_testsuite_property example`
+
+.. autofunction:: _pytest.junitxml.record_testsuite_property()
+
+
+.. fixture:: recwarn
+
+recwarn
+~~~~~~~
+
+**Tutorial**: :ref:`assertwarnings`
+
+.. autofunction:: _pytest.recwarn.recwarn()
+    :no-auto-options:
+
+.. autoclass:: pytest.WarningsRecorder()
+    :members:
+
+
+.. fixture:: request
+
+request
+~~~~~~~
+
+**Example**: :ref:`request example`
+
+The ``request`` fixture is a special fixture providing information of the requesting test function.
+
+.. autoclass:: pytest.FixtureRequest()
+    :members:
+
+
+.. fixture:: testdir
+
+testdir
+~~~~~~~
+
+Identical to :fixture:`pytester`, but provides an instance whose methods return
+legacy ``py.path.local`` objects instead when applicable.
+
+New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
+
+.. autoclass:: pytest.Testdir()
+    :members:
+    :noindex: TimeoutExpired
+
+
+.. fixture:: tmp_path
+
+tmp_path
+~~~~~~~~
+
+**Tutorial**: :ref:`tmp_path`
+
+.. autofunction:: _pytest.tmpdir.tmp_path()
+    :no-auto-options:
+
+
+.. fixture:: tmp_path_factory
+
+tmp_path_factory
+~~~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`tmp_path_factory example`
+
+.. _`tmp_path_factory factory api`:
+
+``tmp_path_factory`` is an instance of :class:`~pytest.TempPathFactory`:
+
+.. autoclass:: pytest.TempPathFactory()
+    :members:
+
+
+.. fixture:: tmpdir
+
+tmpdir
+~~~~~~
+
+**Tutorial**: :ref:`tmpdir and tmpdir_factory`
+
+.. autofunction:: _pytest.legacypath.LegacyTmpdirPlugin.tmpdir()
+    :no-auto-options:
+
+
+.. fixture:: tmpdir_factory
+
+tmpdir_factory
+~~~~~~~~~~~~~~
+
+**Tutorial**: :ref:`tmpdir and tmpdir_factory`
+
+``tmpdir_factory`` is an instance of :class:`~pytest.TempdirFactory`:
+
+.. autoclass:: pytest.TempdirFactory()
+    :members:
+
+
+.. _`hook-reference`:
+
+Hooks
+-----
+
+**Tutorial**: :ref:`writing-plugins`
+
+.. currentmodule:: _pytest.hookspec
+
+Reference to all hooks which can be implemented by :ref:`conftest.py files <localplugin>` and :ref:`plugins <plugins>`.
+
+Bootstrapping hooks
+~~~~~~~~~~~~~~~~~~~
+
+Bootstrapping hooks called for plugins registered early enough (internal and setuptools plugins).
+
+.. hook:: pytest_load_initial_conftests
+.. autofunction:: pytest_load_initial_conftests
+.. hook:: pytest_cmdline_preparse
+.. autofunction:: pytest_cmdline_preparse
+.. hook:: pytest_cmdline_parse
+.. autofunction:: pytest_cmdline_parse
+.. hook:: pytest_cmdline_main
+.. autofunction:: pytest_cmdline_main
+
+.. _`initialization-hooks`:
+
+Initialization hooks
+~~~~~~~~~~~~~~~~~~~~
+
+Initialization hooks called for plugins and ``conftest.py`` files.
+
+.. hook:: pytest_addoption
+.. autofunction:: pytest_addoption
+.. hook:: pytest_addhooks
+.. autofunction:: pytest_addhooks
+.. hook:: pytest_configure
+.. autofunction:: pytest_configure
+.. hook:: pytest_unconfigure
+.. autofunction:: pytest_unconfigure
+.. hook:: pytest_sessionstart
+.. autofunction:: pytest_sessionstart
+.. hook:: pytest_sessionfinish
+.. autofunction:: pytest_sessionfinish
+
+.. hook:: pytest_plugin_registered
+.. autofunction:: pytest_plugin_registered
+
+Collection hooks
+~~~~~~~~~~~~~~~~
+
+``pytest`` calls the following hooks for collecting files and directories:
+
+.. hook:: pytest_collection
+.. autofunction:: pytest_collection
+.. hook:: pytest_ignore_collect
+.. autofunction:: pytest_ignore_collect
+.. hook:: pytest_collect_file
+.. autofunction:: pytest_collect_file
+.. hook:: pytest_pycollect_makemodule
+.. autofunction:: pytest_pycollect_makemodule
+
+For influencing the collection of objects in Python modules
+you can use the following hook:
+
+.. hook:: pytest_pycollect_makeitem
+.. autofunction:: pytest_pycollect_makeitem
+.. hook:: pytest_generate_tests
+.. autofunction:: pytest_generate_tests
+.. hook:: pytest_make_parametrize_id
+.. autofunction:: pytest_make_parametrize_id
+
+Hooks for influencing test skipping:
+
+.. hook:: pytest_markeval_namespace
+.. autofunction:: pytest_markeval_namespace
+
+After collection is complete, you can modify the order of
+items, delete or otherwise amend the test items:
+
+.. hook:: pytest_collection_modifyitems
+.. autofunction:: pytest_collection_modifyitems
+
+.. note::
+    If this hook is implemented in ``conftest.py`` files, it always receives all collected items, not only those
+    under the ``conftest.py`` where it is implemented.
+
+.. autofunction:: pytest_collection_finish
+
+Test running (runtest) hooks
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+All runtest related hooks receive a :py:class:`pytest.Item <pytest.Item>` object.
+
+.. hook:: pytest_runtestloop
+.. autofunction:: pytest_runtestloop
+.. hook:: pytest_runtest_protocol
+.. autofunction:: pytest_runtest_protocol
+.. hook:: pytest_runtest_logstart
+.. autofunction:: pytest_runtest_logstart
+.. hook:: pytest_runtest_logfinish
+.. autofunction:: pytest_runtest_logfinish
+.. hook:: pytest_runtest_setup
+.. autofunction:: pytest_runtest_setup
+.. hook:: pytest_runtest_call
+.. autofunction:: pytest_runtest_call
+.. hook:: pytest_runtest_teardown
+.. autofunction:: pytest_runtest_teardown
+.. hook:: pytest_runtest_makereport
+.. autofunction:: pytest_runtest_makereport
+
+For deeper understanding you may look at the default implementation of
+these hooks in ``_pytest.runner`` and maybe also
+in ``_pytest.pdb`` which interacts with ``_pytest.capture``
+and its input/output capturing in order to immediately drop
+into interactive debugging when a test failure occurs.
+
+.. hook:: pytest_pyfunc_call
+.. autofunction:: pytest_pyfunc_call
+
+Reporting hooks
+~~~~~~~~~~~~~~~
+
+Session related reporting hooks:
+
+.. hook:: pytest_collectstart
+.. autofunction:: pytest_collectstart
+.. hook:: pytest_make_collect_report
+.. autofunction:: pytest_make_collect_report
+.. hook:: pytest_itemcollected
+.. autofunction:: pytest_itemcollected
+.. hook:: pytest_collectreport
+.. autofunction:: pytest_collectreport
+.. hook:: pytest_deselected
+.. autofunction:: pytest_deselected
+.. hook:: pytest_report_header
+.. autofunction:: pytest_report_header
+.. hook:: pytest_report_collectionfinish
+.. autofunction:: pytest_report_collectionfinish
+.. hook:: pytest_report_teststatus
+.. autofunction:: pytest_report_teststatus
+.. hook:: pytest_report_to_serializable
+.. autofunction:: pytest_report_to_serializable
+.. hook:: pytest_report_from_serializable
+.. autofunction:: pytest_report_from_serializable
+.. hook:: pytest_terminal_summary
+.. autofunction:: pytest_terminal_summary
+.. hook:: pytest_fixture_setup
+.. autofunction:: pytest_fixture_setup
+.. hook:: pytest_fixture_post_finalizer
+.. autofunction:: pytest_fixture_post_finalizer
+.. hook:: pytest_warning_recorded
+.. autofunction:: pytest_warning_recorded
+
+Central hook for reporting about test execution:
+
+.. hook:: pytest_runtest_logreport
+.. autofunction:: pytest_runtest_logreport
+
+Assertion related hooks:
+
+.. hook:: pytest_assertrepr_compare
+.. autofunction:: pytest_assertrepr_compare
+.. hook:: pytest_assertion_pass
+.. autofunction:: pytest_assertion_pass
+
+
+Debugging/Interaction hooks
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+There are few hooks which can be used for special
+reporting or interaction with exceptions:
+
+.. hook:: pytest_internalerror
+.. autofunction:: pytest_internalerror
+.. hook:: pytest_keyboard_interrupt
+.. autofunction:: pytest_keyboard_interrupt
+.. hook:: pytest_exception_interact
+.. autofunction:: pytest_exception_interact
+.. hook:: pytest_enter_pdb
+.. autofunction:: pytest_enter_pdb
+.. hook:: pytest_leave_pdb
+.. autofunction:: pytest_leave_pdb
+
+
+Collection tree objects
+-----------------------
+
+These are the collector and item classes (collectively called "nodes") which
+make up the collection tree.
+
+Node
+~~~~
+
+.. autoclass:: _pytest.nodes.Node()
+    :members:
+
+Collector
+~~~~~~~~~
+
+.. autoclass:: pytest.Collector()
+    :members:
+    :show-inheritance:
+
+Item
+~~~~
+
+.. autoclass:: pytest.Item()
+    :members:
+    :show-inheritance:
+
+File
+~~~~
+
+.. autoclass:: pytest.File()
+    :members:
+    :show-inheritance:
+
+FSCollector
+~~~~~~~~~~~
+
+.. autoclass:: _pytest.nodes.FSCollector()
+    :members:
+    :show-inheritance:
+
+Session
+~~~~~~~
+
+.. autoclass:: pytest.Session()
+    :members:
+    :show-inheritance:
+
+Package
+~~~~~~~
+
+.. autoclass:: pytest.Package()
+    :members:
+    :show-inheritance:
+
+Module
+~~~~~~
+
+.. autoclass:: pytest.Module()
+    :members:
+    :show-inheritance:
+
+Class
+~~~~~
+
+.. autoclass:: pytest.Class()
+    :members:
+    :show-inheritance:
+
+Function
+~~~~~~~~
+
+.. autoclass:: pytest.Function()
+    :members:
+    :show-inheritance:
+
+FunctionDefinition
+~~~~~~~~~~~~~~~~~~
+
+.. autoclass:: _pytest.python.FunctionDefinition()
+    :members:
+    :show-inheritance:
+
+
+Objects
+-------
+
+Objects accessible from :ref:`fixtures <fixture>` or :ref:`hooks <hook-reference>`
+or importable from ``pytest``.
+
+
+CallInfo
+~~~~~~~~
+
+.. autoclass:: pytest.CallInfo()
+    :members:
+
+CollectReport
+~~~~~~~~~~~~~
+
+.. autoclass:: pytest.CollectReport()
+    :members:
+    :show-inheritance:
+    :inherited-members:
+
+Config
+~~~~~~
+
+.. autoclass:: pytest.Config()
+    :members:
+
+ExceptionInfo
+~~~~~~~~~~~~~
+
+.. autoclass:: pytest.ExceptionInfo()
+    :members:
+
+
+ExitCode
+~~~~~~~~
+
+.. autoclass:: pytest.ExitCode
+    :members:
+
+
+FixtureDef
+~~~~~~~~~~
+
+.. autoclass:: _pytest.fixtures.FixtureDef()
+    :members:
+    :show-inheritance:
+
+MarkDecorator
+~~~~~~~~~~~~~
+
+.. autoclass:: pytest.MarkDecorator()
+    :members:
+
+
+MarkGenerator
+~~~~~~~~~~~~~
+
+.. autoclass:: pytest.MarkGenerator()
+    :members:
+
+
+Mark
+~~~~
+
+.. autoclass:: pytest.Mark()
+    :members:
+
+
+Metafunc
+~~~~~~~~
+
+.. autoclass:: pytest.Metafunc()
+    :members:
+
+Parser
+~~~~~~
+
+.. autoclass:: pytest.Parser()
+    :members:
+
+OptionGroup
+~~~~~~~~~~~
+
+.. autoclass:: pytest.OptionGroup()
+    :members:
+
+PytestPluginManager
+~~~~~~~~~~~~~~~~~~~
+
+.. autoclass:: pytest.PytestPluginManager()
+    :members:
+    :undoc-members:
+    :inherited-members:
+    :show-inheritance:
+
+TestReport
+~~~~~~~~~~
+
+.. autoclass:: pytest.TestReport()
+    :members:
+    :show-inheritance:
+    :inherited-members:
+
+TestShortLogReport
+~~~~~~~~~~~~~~~~~~
+
+.. autoclass:: pytest.TestShortLogReport()
+    :members:
+
+Result
+~~~~~~~
+
+Result object used within :ref:`hook wrappers <hookwrapper>`, see :py:class:`Result in the pluggy documentation <pluggy.Result>` for more information.
+
+Stash
+~~~~~
+
+.. autoclass:: pytest.Stash
+    :special-members: __setitem__, __getitem__, __delitem__, __contains__, __len__
+    :members:
+
+.. autoclass:: pytest.StashKey
+    :show-inheritance:
+    :members:
+
+
+Global Variables
+----------------
+
+pytest treats some global variables in a special manner when defined in a test module or
+``conftest.py`` files.
+
+
+.. globalvar:: collect_ignore
+
+**Tutorial**: :ref:`customizing-test-collection`
+
+Can be declared in *conftest.py files* to exclude test directories or modules.
+Needs to be a list of paths (``str``, :class:`pathlib.Path` or any :class:`os.PathLike`).
+
+.. code-block:: python
+
+  collect_ignore = ["setup.py"]
+
+
+.. globalvar:: collect_ignore_glob
+
+**Tutorial**: :ref:`customizing-test-collection`
+
+Can be declared in *conftest.py files* to exclude test directories or modules
+with Unix shell-style wildcards. Needs to be ``list[str]`` where ``str`` can
+contain glob patterns.
+
+.. code-block:: python
+
+  collect_ignore_glob = ["*_ignore.py"]
+
+
+.. globalvar:: pytest_plugins
+
+**Tutorial**: :ref:`available installable plugins`
+
+Can be declared at the **global** level in *test modules* and *conftest.py files* to register additional plugins.
+Can be either a ``str`` or ``Sequence[str]``.
+
+.. code-block:: python
+
+    pytest_plugins = "myapp.testsupport.myplugin"
+
+.. code-block:: python
+
+    pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression")
+
+
+.. globalvar:: pytestmark
+
+**Tutorial**: :ref:`scoped-marking`
+
+Can be declared at the **global** level in *test modules* to apply one or more :ref:`marks <marks ref>` to all
+test functions and methods. Can be either a single mark or a list of marks (applied in left-to-right order).
+
+.. code-block:: python
+
+    import pytest
+
+    pytestmark = pytest.mark.webtest
+
+
+.. code-block:: python
+
+    import pytest
+
+    pytestmark = [pytest.mark.integration, pytest.mark.slow]
+
+
+Environment Variables
+---------------------
+
+Environment variables that can be used to change pytest's behavior.
+
+.. envvar:: CI
+
+When set (regardless of value), pytest acknowledges that is running in a CI process. Alternative to ``BUILD_NUMBER`` variable.
+
+.. envvar:: BUILD_NUMBER
+
+When set (regardless of value), pytest acknowledges that is running in a CI process. Alternative to CI variable.
+
+.. envvar:: PYTEST_ADDOPTS
+
+This contains a command-line (parsed by the py:mod:`shlex` module) that will be **prepended** to the command line given
+by the user, see :ref:`adding default options` for more information.
+
+.. envvar:: PYTEST_CURRENT_TEST
+
+This is not meant to be set by users, but is set by pytest internally with the name of the current test so other
+processes can inspect it, see :ref:`pytest current test env` for more information.
+
+.. envvar:: PYTEST_DEBUG
+
+When set, pytest will print tracing and debug information.
+
+.. envvar:: PYTEST_DISABLE_PLUGIN_AUTOLOAD
+
+When set, disables plugin auto-loading through setuptools entrypoints. Only explicitly specified plugins will be
+loaded.
+
+.. envvar:: PYTEST_PLUGINS
+
+Contains comma-separated list of modules that should be loaded as plugins:
+
+.. code-block:: bash
+
+    export PYTEST_PLUGINS=mymodule.plugin,xdist
+
+.. envvar:: PYTEST_THEME
+
+Sets a `pygment style <https://pygments.org/docs/styles/>`_ to use for the code output.
+
+.. envvar:: PYTEST_THEME_MODE
+
+Sets the :envvar:`PYTEST_THEME` to be either *dark* or *light*.
+
+.. envvar:: PY_COLORS
+
+When set to ``1``, pytest will use color in terminal output.
+When set to ``0``, pytest will not use color.
+``PY_COLORS`` takes precedence over ``NO_COLOR`` and ``FORCE_COLOR``.
+
+.. envvar:: NO_COLOR
+
+When set (regardless of value), pytest will not use color in terminal output.
+``PY_COLORS`` takes precedence over ``NO_COLOR``, which takes precedence over ``FORCE_COLOR``.
+See `no-color.org <https://no-color.org/>`__ for other libraries supporting this community standard.
+
+.. envvar:: FORCE_COLOR
+
+When set (regardless of value), pytest will use color in terminal output.
+``PY_COLORS`` and ``NO_COLOR`` take precedence over ``FORCE_COLOR``.
+
+Exceptions
+----------
+
+.. autoclass:: pytest.UsageError()
+    :show-inheritance:
+
+.. _`warnings ref`:
+
+Warnings
+--------
+
+Custom warnings generated in some situations such as improper usage or deprecated features.
+
+.. autoclass:: pytest.PytestWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestAssertRewriteWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestCacheWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestCollectionWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestConfigWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestDeprecationWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestExperimentalApiWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestReturnNotNoneWarning
+  :show-inheritance:
+
+.. autoclass:: pytest.PytestRemovedIn8Warning
+  :show-inheritance:
+
+.. autoclass:: pytest.PytestUnhandledCoroutineWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestUnknownMarkWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestUnraisableExceptionWarning
+   :show-inheritance:
+
+.. autoclass:: pytest.PytestUnhandledThreadExceptionWarning
+   :show-inheritance:
+
+
+Consult the :ref:`internal-warnings` section in the documentation for more information.
+
+
+.. _`ini options ref`:
+
+Configuration Options
+---------------------
+
+Here is a list of builtin configuration options that may be written in a ``pytest.ini`` (or ``.pytest.ini``),
+``pyproject.toml``, ``tox.ini``, or ``setup.cfg`` file, usually located at the root of your repository.
+
+To see each file format in details, see :ref:`config file formats`.
+
+.. warning::
+    Usage of ``setup.cfg`` is not recommended except for very simple use cases. ``.cfg``
+    files use a different parser than ``pytest.ini`` and ``tox.ini`` which might cause hard to track
+    down problems.
+    When possible, it is recommended to use the latter files, or ``pyproject.toml``, to hold your pytest configuration.
+
+Configuration options may be overwritten in the command-line by using ``-o/--override-ini``, which can also be
+passed multiple times. The expected format is ``name=value``. For example::
+
+   pytest -o console_output_style=classic -o cache_dir=/tmp/mycache
+
+
+.. confval:: addopts
+
+   Add the specified ``OPTS`` to the set of command line arguments as if they
+   had been specified by the user. Example: if you have this ini file content:
+
+   .. code-block:: ini
+
+        # content of pytest.ini
+        [pytest]
+        addopts = --maxfail=2 -rf  # exit after 2 failures, report fail info
+
+   issuing ``pytest test_hello.py`` actually means:
+
+   .. code-block:: bash
+
+        pytest --maxfail=2 -rf test_hello.py
+
+   Default is to add no options.
+
+
+.. confval:: cache_dir
+
+   Sets a directory where stores content of cache plugin. Default directory is
+   ``.pytest_cache`` which is created in :ref:`rootdir <rootdir>`. Directory may be
+   relative or absolute path. If setting relative path, then directory is created
+   relative to :ref:`rootdir <rootdir>`. Additionally path may contain environment
+   variables, that will be expanded. For more information about cache plugin
+   please refer to :ref:`cache_provider`.
+
+.. confval:: console_output_style
+
+   Sets the console output style while running tests:
+
+   * ``classic``: classic pytest output.
+   * ``progress``: like classic pytest output, but with a progress indicator.
+   * ``progress-even-when-capture-no``: allows the use of the progress indicator even when ``capture=no``.
+   * ``count``: like progress, but shows progress as the number of tests completed instead of a percent.
+
+   The default is ``progress``, but you can fallback to ``classic`` if you prefer or
+   the new mode is causing unexpected problems:
+
+   .. code-block:: ini
+
+        # content of pytest.ini
+        [pytest]
+        console_output_style = classic
+
+
+.. confval:: doctest_encoding
+
+
+
+   Default encoding to use to decode text files with docstrings.
+   :ref:`See how pytest handles doctests <doctest>`.
+
+
+.. confval:: doctest_optionflags
+
+   One or more doctest flag names from the standard ``doctest`` module.
+   :ref:`See how pytest handles doctests <doctest>`.
+
+
+.. confval:: empty_parameter_set_mark
+
+
+
+    Allows to pick the action for empty parametersets in parameterization
+
+    * ``skip`` skips tests with an empty parameterset (default)
+    * ``xfail`` marks tests with an empty parameterset as xfail(run=False)
+    * ``fail_at_collect`` raises an exception if parametrize collects an empty parameter set
+
+    .. code-block:: ini
+
+      # content of pytest.ini
+      [pytest]
+      empty_parameter_set_mark = xfail
+
+    .. note::
+
+      The default value of this option is planned to change to ``xfail`` in future releases
+      as this is considered less error prone, see :issue:`3155` for more details.
+
+
+.. confval:: faulthandler_timeout
+
+   Dumps the tracebacks of all threads if a test takes longer than ``X`` seconds to run (including
+   fixture setup and teardown). Implemented using the :func:`faulthandler.dump_traceback_later` function,
+   so all caveats there apply.
+
+   .. code-block:: ini
+
+        # content of pytest.ini
+        [pytest]
+        faulthandler_timeout=5
+
+   For more information please refer to :ref:`faulthandler`.
+
+.. confval:: filterwarnings
+
+
+
+   Sets a list of filters and actions that should be taken for matched
+   warnings. By default all warnings emitted during the test session
+   will be displayed in a summary at the end of the test session.
+
+   .. code-block:: ini
+
+        # content of pytest.ini
+        [pytest]
+        filterwarnings =
+            error
+            ignore::DeprecationWarning
+
+   This tells pytest to ignore deprecation warnings and turn all other warnings
+   into errors. For more information please refer to :ref:`warnings`.
+
+
+.. confval:: junit_duration_report
+
+    .. versionadded:: 4.1
+
+    Configures how durations are recorded into the JUnit XML report:
+
+    * ``total`` (the default): duration times reported include setup, call, and teardown times.
+    * ``call``: duration times reported include only call times, excluding setup and teardown.
+
+    .. code-block:: ini
+
+        [pytest]
+        junit_duration_report = call
+
+
+.. confval:: junit_family
+
+    .. versionadded:: 4.2
+    .. versionchanged:: 6.1
+        Default changed to ``xunit2``.
+
+    Configures the format of the generated JUnit XML file. The possible options are:
+
+    * ``xunit1`` (or ``legacy``): produces old style output, compatible with the xunit 1.0 format.
+    * ``xunit2``: produces `xunit 2.0 style output <https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__, which should be more compatible with latest Jenkins versions.  **This is the default**.
+
+    .. code-block:: ini
+
+        [pytest]
+        junit_family = xunit2
+
+
+.. confval:: junit_logging
+
+    .. versionadded:: 3.5
+    .. versionchanged:: 5.4
+        ``log``, ``all``, ``out-err`` options added.
+
+    Configures if captured output should be written to the JUnit XML file. Valid values are:
+
+    * ``log``: write only ``logging`` captured output.
+    * ``system-out``: write captured ``stdout`` contents.
+    * ``system-err``: write captured ``stderr`` contents.
+    * ``out-err``: write both captured ``stdout`` and ``stderr`` contents.
+    * ``all``: write captured ``logging``, ``stdout`` and ``stderr`` contents.
+    * ``no`` (the default): no captured output is written.
+
+    .. code-block:: ini
+
+        [pytest]
+        junit_logging = system-out
+
+
+.. confval:: junit_log_passing_tests
+
+    .. versionadded:: 4.6
+
+    If ``junit_logging != "no"``, configures if the captured output should be written
+    to the JUnit XML file for **passing** tests. Default is ``True``.
+
+    .. code-block:: ini
+
+        [pytest]
+        junit_log_passing_tests = False
+
+
+.. confval:: junit_suite_name
+
+    To set the name of the root test suite xml item, you can configure the ``junit_suite_name`` option in your config file:
+
+    .. code-block:: ini
+
+        [pytest]
+        junit_suite_name = my_suite
+
+.. confval:: log_auto_indent
+
+    Allow selective auto-indentation of multiline log messages.
+
+    Supports command line option ``--log-auto-indent [value]``
+    and config option ``log_auto_indent = [value]`` to set the
+    auto-indentation behavior for all logging.
+
+    ``[value]`` can be:
+        * True or "On" - Dynamically auto-indent multiline log messages
+        * False or "Off" or 0 - Do not auto-indent multiline log messages (the default behavior)
+        * [positive integer] - auto-indent multiline log messages by [value] spaces
+
+    .. code-block:: ini
+
+        [pytest]
+        log_auto_indent = False
+
+    Supports passing kwarg ``extra={"auto_indent": [value]}`` to
+    calls to ``logging.log()`` to specify auto-indentation behavior for
+    a specific entry in the log. ``extra`` kwarg overrides the value specified
+    on the command line or in the config.
+
+.. confval:: log_cli
+
+    Enable log display during test run (also known as :ref:`"live logging" <live_logs>`).
+    The default is ``False``.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_cli = True
+
+.. confval:: log_cli_date_format
+
+
+
+    Sets a :py:func:`time.strftime`-compatible string that will be used when formatting dates for live logging.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_cli_date_format = %Y-%m-%d %H:%M:%S
+
+    For more information, see :ref:`live_logs`.
+
+.. confval:: log_cli_format
+
+
+
+    Sets a :py:mod:`logging`-compatible string used to format live logging messages.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_cli_format = %(asctime)s %(levelname)s %(message)s
+
+    For more information, see :ref:`live_logs`.
+
+
+.. confval:: log_cli_level
+
+
+
+    Sets the minimum log message level that should be captured for live logging. The integer value or
+    the names of the levels can be used.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_cli_level = INFO
+
+    For more information, see :ref:`live_logs`.
+
+
+.. confval:: log_date_format
+
+
+
+    Sets a :py:func:`time.strftime`-compatible string that will be used when formatting dates for logging capture.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_date_format = %Y-%m-%d %H:%M:%S
+
+    For more information, see :ref:`logging`.
+
+
+.. confval:: log_file
+
+
+
+    Sets a file name relative to the current working directory where log messages should be written to, in addition
+    to the other logging facilities that are active.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_file = logs/pytest-logs.txt
+
+    For more information, see :ref:`logging`.
+
+
+.. confval:: log_file_date_format
+
+
+
+    Sets a :py:func:`time.strftime`-compatible string that will be used when formatting dates for the logging file.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_file_date_format = %Y-%m-%d %H:%M:%S
+
+    For more information, see :ref:`logging`.
+
+.. confval:: log_file_format
+
+
+
+    Sets a :py:mod:`logging`-compatible string used to format logging messages redirected to the logging file.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_file_format = %(asctime)s %(levelname)s %(message)s
+
+    For more information, see :ref:`logging`.
+
+.. confval:: log_file_level
+
+
+
+    Sets the minimum log message level that should be captured for the logging file. The integer value or
+    the names of the levels can be used.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_file_level = INFO
+
+    For more information, see :ref:`logging`.
+
+
+.. confval:: log_format
+
+
+
+    Sets a :py:mod:`logging`-compatible string used to format captured logging messages.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_format = %(asctime)s %(levelname)s %(message)s
+
+    For more information, see :ref:`logging`.
+
+
+.. confval:: log_level
+
+
+
+    Sets the minimum log message level that should be captured for logging capture. The integer value or
+    the names of the levels can be used.
+
+    .. code-block:: ini
+
+        [pytest]
+        log_level = INFO
+
+    For more information, see :ref:`logging`.
+
+
+.. confval:: markers
+
+    When the ``--strict-markers`` or ``--strict`` command-line arguments are used,
+    only known markers - defined in code by core pytest or some plugin - are allowed.
+
+    You can list additional markers in this setting to add them to the whitelist,
+    in which case you probably want to add ``--strict-markers`` to ``addopts``
+    to avoid future regressions:
+
+    .. code-block:: ini
+
+        [pytest]
+        addopts = --strict-markers
+        markers =
+            slow
+            serial
+
+    .. note::
+        The use of ``--strict-markers`` is highly preferred. ``--strict`` was kept for
+        backward compatibility only and may be confusing for others as it only applies to
+        markers and not to other options.
+
+.. confval:: minversion
+
+   Specifies a minimal pytest version required for running tests.
+
+   .. code-block:: ini
+
+        # content of pytest.ini
+        [pytest]
+        minversion = 3.0  # will fail if we run with pytest-2.8
+
+
+.. confval:: norecursedirs
+
+   Set the directory basename patterns to avoid when recursing
+   for test discovery.  The individual (fnmatch-style) patterns are
+   applied to the basename of a directory to decide if to recurse into it.
+   Pattern matching characters::
+
+        *       matches everything
+        ?       matches any single character
+        [seq]   matches any character in seq
+        [!seq]  matches any char not in seq
+
+   Default patterns are ``'*.egg'``, ``'.*'``, ``'_darcs'``, ``'build'``,
+   ``'CVS'``, ``'dist'``, ``'node_modules'``, ``'venv'``, ``'{arch}'``.
+   Setting a ``norecursedirs`` replaces the default.  Here is an example of
+   how to avoid certain directories:
+
+   .. code-block:: ini
+
+        [pytest]
+        norecursedirs = .svn _build tmp*
+
+   This would tell ``pytest`` to not look into typical subversion or
+   sphinx-build directories or into any ``tmp`` prefixed directory.
+
+   Additionally, ``pytest`` will attempt to intelligently identify and ignore a
+   virtualenv by the presence of an activation script.  Any directory deemed to
+   be the root of a virtual environment will not be considered during test
+   collection unless ``‑‑collect‑in‑virtualenv`` is given.  Note also that
+   ``norecursedirs`` takes precedence over ``‑‑collect‑in‑virtualenv``; e.g. if
+   you intend to run tests in a virtualenv with a base directory that matches
+   ``'.*'`` you *must* override ``norecursedirs`` in addition to using the
+   ``‑‑collect‑in‑virtualenv`` flag.
+
+
+.. confval:: python_classes
+
+   One or more name prefixes or glob-style patterns determining which classes
+   are considered for test collection. Search for multiple glob patterns by
+   adding a space between patterns. By default, pytest will consider any
+   class prefixed with ``Test`` as a test collection.  Here is an example of how
+   to collect tests from classes that end in ``Suite``:
+
+   .. code-block:: ini
+
+        [pytest]
+        python_classes = *Suite
+
+   Note that ``unittest.TestCase`` derived classes are always collected
+   regardless of this option, as ``unittest``'s own collection framework is used
+   to collect those tests.
+
+
+.. confval:: python_files
+
+   One or more Glob-style file patterns determining which python files
+   are considered as test modules. Search for multiple glob patterns by
+   adding a space between patterns:
+
+   .. code-block:: ini
+
+        [pytest]
+        python_files = test_*.py check_*.py example_*.py
+
+   Or one per line:
+
+   .. code-block:: ini
+
+        [pytest]
+        python_files =
+            test_*.py
+            check_*.py
+            example_*.py
+
+   By default, files matching ``test_*.py`` and ``*_test.py`` will be considered
+   test modules.
+
+
+.. confval:: python_functions
+
+   One or more name prefixes or glob-patterns determining which test functions
+   and methods are considered tests. Search for multiple glob patterns by
+   adding a space between patterns. By default, pytest will consider any
+   function prefixed with ``test`` as a test.  Here is an example of how
+   to collect test functions and methods that end in ``_test``:
+
+   .. code-block:: ini
+
+        [pytest]
+        python_functions = *_test
+
+   Note that this has no effect on methods that live on a ``unittest.TestCase``
+   derived class, as ``unittest``'s own collection framework is used
+   to collect those tests.
+
+   See :ref:`change naming conventions` for more detailed examples.
+
+
+.. confval:: pythonpath
+
+   Sets list of directories that should be added to the python search path.
+   Directories will be added to the head of :data:`sys.path`.
+   Similar to the :envvar:`PYTHONPATH` environment variable, the directories will be
+   included in where Python will look for imported modules.
+   Paths are relative to the :ref:`rootdir <rootdir>` directory.
+   Directories remain in path for the duration of the test session.
+
+   .. code-block:: ini
+
+        [pytest]
+        pythonpath = src1 src2
+
+   .. note::
+
+        ``pythonpath`` does not affect some imports that happen very early,
+        most notably plugins loaded using the ``-p`` command line option.
+
+
+.. confval:: required_plugins
+
+   A space separated list of plugins that must be present for pytest to run.
+   Plugins can be listed with or without version specifiers directly following
+   their name. Whitespace between different version specifiers is not allowed.
+   If any one of the plugins is not found, emit an error.
+
+   .. code-block:: ini
+
+       [pytest]
+       required_plugins = pytest-django>=3.0.0,<4.0.0 pytest-html pytest-xdist>=1.0.0
+
+
+.. confval:: testpaths
+
+   Sets list of directories that should be searched for tests when
+   no specific directories, files or test ids are given in the command line when
+   executing pytest from the :ref:`rootdir <rootdir>` directory.
+   File system paths may use shell-style wildcards, including the recursive
+   ``**`` pattern.
+
+   Useful when all project tests are in a known location to speed up
+   test collection and to avoid picking up undesired tests by accident.
+
+   .. code-block:: ini
+
+        [pytest]
+        testpaths = testing doc
+
+   This configuration means that executing:
+
+   .. code-block:: console
+
+       pytest
+
+   has the same practical effects as executing:
+
+   .. code-block:: console
+
+       pytest testing doc
+
+
+.. confval:: tmp_path_retention_count
+
+
+
+   How many sessions should we keep the `tmp_path` directories,
+   according to `tmp_path_retention_policy`.
+
+   .. code-block:: ini
+
+        [pytest]
+        tmp_path_retention_count = 3
+
+   Default: ``3``
+
+
+.. confval:: tmp_path_retention_policy
+
+
+
+   Controls which directories created by the `tmp_path` fixture are kept around,
+   based on test outcome.
+
+    * `all`: retains directories for all tests, regardless of the outcome.
+    * `failed`: retains directories only for tests with outcome `error` or `failed`.
+    * `none`: directories are always removed after each test ends, regardless of the outcome.
+
+   .. code-block:: ini
+
+        [pytest]
+        tmp_path_retention_policy = "all"
+
+   Default: ``all``
+
+
+.. confval:: usefixtures
+
+    List of fixtures that will be applied to all test functions; this is semantically the same to apply
+    the ``@pytest.mark.usefixtures`` marker to all test functions.
+
+
+    .. code-block:: ini
+
+        [pytest]
+        usefixtures =
+            clean_db
+
+
+.. confval:: xfail_strict
+
+    If set to ``True``, tests marked with ``@pytest.mark.xfail`` that actually succeed will by default fail the
+    test suite.
+    For more information, see :ref:`xfail strict tutorial`.
+
+
+    .. code-block:: ini
+
+        [pytest]
+        xfail_strict = True
+
+
+.. _`command-line-flags`:
+
+Command-line Flags
+------------------
+
+All the command-line flags can be obtained by running ``pytest --help``::
+
+    $ pytest --help
+    usage: pytest [options] [file_or_dir] [file_or_dir] [...]
+
+    positional arguments:
+      file_or_dir
+
+    general:
+      -k EXPRESSION         Only run tests which match the given substring
+                            expression. An expression is a Python evaluatable
+                            expression where all names are substring-matched
+                            against test names and their parent classes.
+                            Example: -k 'test_method or test_other' matches all
+                            test functions and classes whose name contains
+                            'test_method' or 'test_other', while -k 'not
+                            test_method' matches those that don't contain
+                            'test_method' in their names. -k 'not test_method
+                            and not test_other' will eliminate the matches.
+                            Additionally keywords are matched to classes and
+                            functions containing extra names in their
+                            'extra_keyword_matches' set, as well as functions
+                            which have names assigned directly to them. The
+                            matching is case-insensitive.
+      -m MARKEXPR           Only run tests matching given mark expression. For
+                            example: -m 'mark1 and not mark2'.
+      --markers             show markers (builtin, plugin and per-project ones).
+      -x, --exitfirst       Exit instantly on first error or failed test
+      --fixtures, --funcargs
+                            Show available fixtures, sorted by plugin appearance
+                            (fixtures with leading '_' are only shown with '-v')
+      --fixtures-per-test   Show fixtures per test
+      --pdb                 Start the interactive Python debugger on errors or
+                            KeyboardInterrupt
+      --pdbcls=modulename:classname
+                            Specify a custom interactive Python debugger for use
+                            with --pdb.For example:
+                            --pdbcls=IPython.terminal.debugger:TerminalPdb
+      --trace               Immediately break when running each test
+      --capture=method      Per-test capturing method: one of fd|sys|no|tee-sys
+      -s                    Shortcut for --capture=no
+      --runxfail            Report the results of xfail tests as if they were
+                            not marked
+      --lf, --last-failed   Rerun only the tests that failed at the last run (or
+                            all if none failed)
+      --ff, --failed-first  Run all tests, but run the last failures first. This
+                            may re-order tests and thus lead to repeated fixture
+                            setup/teardown.
+      --nf, --new-first     Run tests from new files first, then the rest of the
+                            tests sorted by file mtime
+      --cache-show=[CACHESHOW]
+                            Show cache contents, don't perform collection or
+                            tests. Optional argument: glob (default: '*').
+      --cache-clear         Remove all cache contents at start of test run
+      --lfnf={all,none}, --last-failed-no-failures={all,none}
+                            With ``--lf``, determines whether to execute tests
+                            when there are no previously (known) failures or
+                            when no cached ``lastfailed`` data was found.
+                            ``all`` (the default) runs the full test suite
+                            again. ``none`` just emits a message about no known
+                            failures and exits successfully.
+      --sw, --stepwise      Exit on test failure and continue from last failing
+                            test next time
+      --sw-skip, --stepwise-skip
+                            Ignore the first failing test but stop on the next
+                            failing test. Implicitly enables --stepwise.
+
+    Reporting:
+      --durations=N         Show N slowest setup/test durations (N=0 for all)
+      --durations-min=N     Minimal duration in seconds for inclusion in slowest
+                            list. Default: 0.005.
+      -v, --verbose         Increase verbosity
+      --no-header           Disable header
+      --no-summary          Disable summary
+      -q, --quiet           Decrease verbosity
+      --verbosity=VERBOSE   Set verbosity. Default: 0.
+      -r chars              Show extra test summary info as specified by chars:
+                            (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed,
+                            (p)assed, (P)assed with output, (a)ll except passed
+                            (p/P), or (A)ll. (w)arnings are enabled by default
+                            (see --disable-warnings), 'N' can be used to reset
+                            the list. (default: 'fE').
+      --disable-warnings, --disable-pytest-warnings
+                            Disable warnings summary
+      -l, --showlocals      Show locals in tracebacks (disabled by default)
+      --no-showlocals       Hide locals in tracebacks (negate --showlocals
+                            passed through addopts)
+      --tb=style            Traceback print mode
+                            (auto/long/short/line/native/no)
+      --show-capture={no,stdout,stderr,log,all}
+                            Controls how captured stdout/stderr/log is shown on
+                            failed tests. Default: all.
+      --full-trace          Don't cut any tracebacks (default is to cut)
+      --color=color         Color terminal output (yes/no/auto)
+      --code-highlight={yes,no}
+                            Whether code should be highlighted (only if --color
+                            is also enabled). Default: yes.
+      --pastebin=mode       Send failed|all info to bpaste.net pastebin service
+      --junit-xml=path      Create junit-xml style report file at given path
+      --junit-prefix=str    Prepend prefix to classnames in junit-xml output
+
+    pytest-warnings:
+      -W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS
+                            Set which warnings to report, see -W option of
+                            Python itself
+      --maxfail=num         Exit after first num failures or errors
+      --strict-config       Any warnings encountered while parsing the `pytest`
+                            section of the configuration file raise errors
+      --strict-markers      Markers not registered in the `markers` section of
+                            the configuration file raise errors
+      --strict              (Deprecated) alias to --strict-markers
+      -c FILE, --config-file=FILE
+                            Load configuration from `FILE` instead of trying to
+                            locate one of the implicit configuration files.
+      --continue-on-collection-errors
+                            Force test execution even if collection errors occur
+      --rootdir=ROOTDIR     Define root directory for tests. Can be relative
+                            path: 'root_dir', './root_dir',
+                            'root_dir/another_dir/'; absolute path:
+                            '/home/user/root_dir'; path with variables:
+                            '$HOME/root_dir'.
+
+    collection:
+      --collect-only, --co  Only collect tests, don't execute them
+      --pyargs              Try to interpret all arguments as Python packages
+      --ignore=path         Ignore path during collection (multi-allowed)
+      --ignore-glob=path    Ignore path pattern during collection (multi-
+                            allowed)
+      --deselect=nodeid_prefix
+                            Deselect item (via node id prefix) during collection
+                            (multi-allowed)
+      --confcutdir=dir      Only load conftest.py's relative to specified dir
+      --noconftest          Don't load any conftest.py files
+      --keep-duplicates     Keep duplicate tests
+      --collect-in-virtualenv
+                            Don't ignore tests in a local virtualenv directory
+      --import-mode={prepend,append,importlib}
+                            Prepend/append to sys.path when importing test
+                            modules and conftest files. Default: prepend.
+      --doctest-modules     Run doctests in all .py modules
+      --doctest-report={none,cdiff,ndiff,udiff,only_first_failure}
+                            Choose another output format for diffs on doctest
+                            failure
+      --doctest-glob=pat    Doctests file matching pattern, default: test*.txt
+      --doctest-ignore-import-errors
+                            Ignore doctest ImportErrors
+      --doctest-continue-on-failure
+                            For a given doctest, continue to run after the first
+                            failure
+
+    test session debugging and configuration:
+      --basetemp=dir        Base temporary directory for this test run.
+                            (Warning: this directory is removed if it exists.)
+      -V, --version         Display pytest version and information about
+                            plugins. When given twice, also display information
+                            about plugins.
+      -h, --help            Show help message and configuration info
+      -p name               Early-load given plugin module name or entry point
+                            (multi-allowed). To avoid loading of plugins, use
+                            the `no:` prefix, e.g. `no:doctest`.
+      --trace-config        Trace considerations of conftest.py files
+      --debug=[DEBUG_FILE_NAME]
+                            Store internal tracing debug information in this log
+                            file. This file is opened with 'w' and truncated as
+                            a result, care advised. Default: pytestdebug.log.
+      -o OVERRIDE_INI, --override-ini=OVERRIDE_INI
+                            Override ini option with "option=value" style, e.g.
+                            `-o xfail_strict=True -o cache_dir=cache`.
+      --assert=MODE         Control assertion debugging tools.
+                            'plain' performs no assertion debugging.
+                            'rewrite' (the default) rewrites assert statements
+                            in test modules on import to provide assert
+                            expression information.
+      --setup-only          Only setup fixtures, do not execute tests
+      --setup-show          Show setup of fixtures while executing tests
+      --setup-plan          Show what fixtures and tests would be executed but
+                            don't execute anything
+
+    logging:
+      --log-level=LEVEL     Level of messages to catch/display. Not set by
+                            default, so it depends on the root/parent log
+                            handler's effective level, where it is "WARNING" by
+                            default.
+      --log-format=LOG_FORMAT
+                            Log format used by the logging module
+      --log-date-format=LOG_DATE_FORMAT
+                            Log date format used by the logging module
+      --log-cli-level=LOG_CLI_LEVEL
+                            CLI logging level
+      --log-cli-format=LOG_CLI_FORMAT
+                            Log format used by the logging module
+      --log-cli-date-format=LOG_CLI_DATE_FORMAT
+                            Log date format used by the logging module
+      --log-file=LOG_FILE   Path to a file when logging will be written to
+      --log-file-level=LOG_FILE_LEVEL
+                            Log file logging level
+      --log-file-format=LOG_FILE_FORMAT
+                            Log format used by the logging module
+      --log-file-date-format=LOG_FILE_DATE_FORMAT
+                            Log date format used by the logging module
+      --log-auto-indent=LOG_AUTO_INDENT
+                            Auto-indent multiline messages passed to the logging
+                            module. Accepts true|on, false|off or an integer.
+      --log-disable=LOGGER_DISABLE
+                            Disable a logger by name. Can be passed multiple
+                            times.
+
+    [pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:
+
+      markers (linelist):   Markers for test functions
+      empty_parameter_set_mark (string):
+                            Default marker for empty parametersets
+      norecursedirs (args): Directory patterns to avoid for recursion
+      testpaths (args):     Directories to search for tests when no files or
+                            directories are given on the command line
+      filterwarnings (linelist):
+                            Each line specifies a pattern for
+                            warnings.filterwarnings. Processed after
+                            -W/--pythonwarnings.
+      usefixtures (args):   List of default fixtures to be used with this
+                            project
+      python_files (args):  Glob-style file patterns for Python test module
+                            discovery
+      python_classes (args):
+                            Prefixes or glob names for Python test class
+                            discovery
+      python_functions (args):
+                            Prefixes or glob names for Python test function and
+                            method discovery
+      disable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool):
+                            Disable string escape non-ASCII characters, might
+                            cause unwanted side effects(use at your own risk)
+      console_output_style (string):
+                            Console output: "classic", or with additional
+                            progress information ("progress" (percentage) |
+                            "count" | "progress-even-when-capture-no" (forces
+                            progress even when capture=no)
+      xfail_strict (bool):  Default for the strict parameter of xfail markers
+                            when not given explicitly (default: False)
+      tmp_path_retention_count (string):
+                            How many sessions should we keep the `tmp_path`
+                            directories, according to
+                            `tmp_path_retention_policy`.
+      tmp_path_retention_policy (string):
+                            Controls which directories created by the `tmp_path`
+                            fixture are kept around, based on test outcome.
+                            (all/failed/none)
+      enable_assertion_pass_hook (bool):
+                            Enables the pytest_assertion_pass hook. Make sure to
+                            delete any previously generated pyc cache files.
+      junit_suite_name (string):
+                            Test suite name for JUnit report
+      junit_logging (string):
+                            Write captured log messages to JUnit report: one of
+                            no|log|system-out|system-err|out-err|all
+      junit_log_passing_tests (bool):
+                            Capture log information for passing tests to JUnit
+                            report:
+      junit_duration_report (string):
+                            Duration time to report: one of total|call
+      junit_family (string):
+                            Emit XML for schema: one of legacy|xunit1|xunit2
+      doctest_optionflags (args):
+                            Option flags for doctests
+      doctest_encoding (string):
+                            Encoding used for doctest files
+      cache_dir (string):   Cache directory path
+      log_level (string):   Default value for --log-level
+      log_format (string):  Default value for --log-format
+      log_date_format (string):
+                            Default value for --log-date-format
+      log_cli (bool):       Enable log display during test run (also known as
+                            "live logging")
+      log_cli_level (string):
+                            Default value for --log-cli-level
+      log_cli_format (string):
+                            Default value for --log-cli-format
+      log_cli_date_format (string):
+                            Default value for --log-cli-date-format
+      log_file (string):    Default value for --log-file
+      log_file_level (string):
+                            Default value for --log-file-level
+      log_file_format (string):
+                            Default value for --log-file-format
+      log_file_date_format (string):
+                            Default value for --log-file-date-format
+      log_auto_indent (string):
+                            Default value for --log-auto-indent
+      pythonpath (paths):   Add paths to sys.path
+      faulthandler_timeout (string):
+                            Dump the traceback of all threads if a test takes
+                            more than TIMEOUT seconds to finish
+      addopts (args):       Extra command line options
+      minversion (string):  Minimally required pytest version
+      required_plugins (args):
+                            Plugins that must be present for pytest to run
+
+    Environment variables:
+      PYTEST_ADDOPTS           Extra command line options
+      PYTEST_PLUGINS           Comma-separated plugins to load during startup
+      PYTEST_DISABLE_PLUGIN_AUTOLOAD Set to disable plugin auto-loading
+      PYTEST_DEBUG             Set to enable debug tracing of pytest's internals
+
+
+    to see available markers type: pytest --markers
+    to see available fixtures type: pytest --fixtures
+    (shown according to specified file_or_dir or current dir if not specified; fixtures with leading '_' are only shown with the '-v' option
index fa37acfb4471a1452c33eb400143ec2c97efc543..b6059723cd5fb2951493c8764e8d70743e2d25b0 100644 (file)
@@ -1,5 +1,11 @@
 pallets-sphinx-themes
-pygments-pytest>=1.1.0
+pluggy>=1.0
+pygments-pytest>=2.3.0
 sphinx-removed-in>=0.2.0
-sphinx>=3.1,<4
+sphinx>=5,<6
 sphinxcontrib-trio
+sphinxcontrib-svg2pdfconverter
+# Pin packaging because it no longer handles 'latest' version, which
+# is the version that is assigned to the docs.
+# See https://github.com/pytest-dev/pytest/pull/10578#issuecomment-1348249045.
+packaging <22
diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst
deleted file mode 100644 (file)
index 2828205..0000000
+++ /dev/null
@@ -1,426 +0,0 @@
-.. _`skip and xfail`:
-
-.. _skipping:
-
-Skip and xfail: dealing with tests that cannot succeed
-======================================================
-
-You can mark test functions that cannot be run on certain platforms
-or that you expect to fail so pytest can deal with them accordingly and
-present a summary of the test session, while keeping the test suite *green*.
-
-A **skip** means that you expect your test to pass only if some conditions are met,
-otherwise pytest should skip running the test altogether. Common examples are skipping
-windows-only tests on non-windows platforms, or skipping tests that depend on an external
-resource which is not available at the moment (for example a database).
-
-An **xfail** means that you expect a test to fail for some reason.
-A common example is a test for a feature not yet implemented, or a bug not yet fixed.
-When a test passes despite being expected to fail (marked with ``pytest.mark.xfail``),
-it's an **xpass** and will be reported in the test summary.
-
-``pytest`` counts and lists *skip* and *xfail* tests separately. Detailed
-information about skipped/xfailed tests is not shown by default to avoid
-cluttering the output.  You can use the ``-r`` option to see details
-corresponding to the "short" letters shown in the test progress:
-
-.. code-block:: bash
-
-    pytest -rxXs  # show extra info on xfailed, xpassed, and skipped tests
-
-More details on the ``-r`` option can be found by running ``pytest -h``.
-
-(See :ref:`how to change command line options defaults`)
-
-.. _skipif:
-.. _skip:
-.. _`condition booleans`:
-
-Skipping test functions
------------------------
-
-
-
-The simplest way to skip a test function is to mark it with the ``skip`` decorator
-which may be passed an optional ``reason``:
-
-.. code-block:: python
-
-    @pytest.mark.skip(reason="no way of currently testing this")
-    def test_the_unknown():
-        ...
-
-
-Alternatively, it is also possible to skip imperatively during test execution or setup
-by calling the ``pytest.skip(reason)`` function:
-
-.. code-block:: python
-
-    def test_function():
-        if not valid_config():
-            pytest.skip("unsupported configuration")
-
-The imperative method is useful when it is not possible to evaluate the skip condition
-during import time.
-
-It is also possible to skip the whole module using
-``pytest.skip(reason, allow_module_level=True)`` at the module level:
-
-.. code-block:: python
-
-    import sys
-    import pytest
-
-    if not sys.platform.startswith("win"):
-        pytest.skip("skipping windows-only tests", allow_module_level=True)
-
-
-**Reference**: :ref:`pytest.mark.skip ref`
-
-``skipif``
-~~~~~~~~~~
-
-
-
-If you wish to skip something conditionally then you can use ``skipif`` instead.
-Here is an example of marking a test function to be skipped
-when run on an interpreter earlier than Python3.6:
-
-.. code-block:: python
-
-    import sys
-
-
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="requires python3.7 or higher")
-    def test_function():
-        ...
-
-If the condition evaluates to ``True`` during collection, the test function will be skipped,
-with the specified reason appearing in the summary when using ``-rs``.
-
-You can share ``skipif`` markers between modules.  Consider this test module:
-
-.. code-block:: python
-
-    # content of test_mymodule.py
-    import mymodule
-
-    minversion = pytest.mark.skipif(
-        mymodule.__versioninfo__ < (1, 1), reason="at least mymodule-1.1 required"
-    )
-
-
-    @minversion
-    def test_function():
-        ...
-
-You can import the marker and reuse it in another test module:
-
-.. code-block:: python
-
-    # test_myothermodule.py
-    from test_mymodule import minversion
-
-
-    @minversion
-    def test_anotherfunction():
-        ...
-
-For larger test suites it's usually a good idea to have one file
-where you define the markers which you then consistently apply
-throughout your test suite.
-
-Alternatively, you can use :ref:`condition strings
-<string conditions>` instead of booleans, but they can't be shared between modules easily
-so they are supported mainly for backward compatibility reasons.
-
-**Reference**: :ref:`pytest.mark.skipif ref`
-
-
-Skip all test functions of a class or module
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You can use the ``skipif`` marker (as any other marker) on classes:
-
-.. code-block:: python
-
-    @pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
-    class TestPosixCalls:
-        def test_function(self):
-            "will not be setup or run under 'win32' platform"
-
-If the condition is ``True``, this marker will produce a skip result for
-each of the test methods of that class.
-
-If you want to skip all test functions of a module, you may use the
-:globalvar:`pytestmark` global:
-
-.. code-block:: python
-
-    # test_module.py
-    pytestmark = pytest.mark.skipif(...)
-
-If multiple ``skipif`` decorators are applied to a test function, it
-will be skipped if any of the skip conditions is true.
-
-.. _`whole class- or module level`: mark.html#scoped-marking
-
-
-Skipping files or directories
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Sometimes you may need to skip an entire file or directory, for example if the
-tests rely on Python version-specific features or contain code that you do not
-wish pytest to run. In this case, you must exclude the files and directories
-from collection. Refer to :ref:`customizing-test-collection` for more
-information.
-
-
-Skipping on a missing import dependency
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-You can skip tests on a missing import by using :ref:`pytest.importorskip ref`
-at module level, within a test, or test setup function.
-
-.. code-block:: python
-
-    docutils = pytest.importorskip("docutils")
-
-If ``docutils`` cannot be imported here, this will lead to a skip outcome of
-the test. You can also skip based on the version number of a library:
-
-.. code-block:: python
-
-    docutils = pytest.importorskip("docutils", minversion="0.3")
-
-The version will be read from the specified
-module's ``__version__`` attribute.
-
-Summary
-~~~~~~~
-
-Here's a quick guide on how to skip tests in a module in different situations:
-
-1. Skip all tests in a module unconditionally:
-
-  .. code-block:: python
-
-        pytestmark = pytest.mark.skip("all tests still WIP")
-
-2. Skip all tests in a module based on some condition:
-
-  .. code-block:: python
-
-        pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="tests for linux only")
-
-3. Skip all tests in a module if some import is missing:
-
-  .. code-block:: python
-
-        pexpect = pytest.importorskip("pexpect")
-
-
-.. _xfail:
-
-XFail: mark test functions as expected to fail
-----------------------------------------------
-
-You can use the ``xfail`` marker to indicate that you
-expect a test to fail:
-
-.. code-block:: python
-
-    @pytest.mark.xfail
-    def test_function():
-        ...
-
-This test will run but no traceback will be reported when it fails. Instead, terminal
-reporting will list it in the "expected to fail" (``XFAIL``) or "unexpectedly
-passing" (``XPASS``) sections.
-
-Alternatively, you can also mark a test as ``XFAIL`` from within the test or its setup function
-imperatively:
-
-.. code-block:: python
-
-    def test_function():
-        if not valid_config():
-            pytest.xfail("failing configuration (but should work)")
-
-.. code-block:: python
-
-    def test_function2():
-        import slow_module
-
-        if slow_module.slow_function():
-            pytest.xfail("slow_module taking too long")
-
-These two examples illustrate situations where you don't want to check for a condition
-at the module level, which is when a condition would otherwise be evaluated for marks.
-
-This will make ``test_function`` ``XFAIL``. Note that no other code is executed after
-the :func:`pytest.xfail` call, differently from the marker. That's because it is implemented
-internally by raising a known exception.
-
-**Reference**: :ref:`pytest.mark.xfail ref`
-
-
-``condition`` parameter
-~~~~~~~~~~~~~~~~~~~~~~~
-
-If a test is only expected to fail under a certain condition, you can pass
-that condition as the first parameter:
-
-.. code-block:: python
-
-    @pytest.mark.xfail(sys.platform == "win32", reason="bug in a 3rd party library")
-    def test_function():
-        ...
-
-Note that you have to pass a reason as well (see the parameter description at
-:ref:`pytest.mark.xfail ref`).
-
-``reason`` parameter
-~~~~~~~~~~~~~~~~~~~~
-
-You can specify the motive of an expected failure with the ``reason`` parameter:
-
-.. code-block:: python
-
-    @pytest.mark.xfail(reason="known parser issue")
-    def test_function():
-        ...
-
-
-``raises`` parameter
-~~~~~~~~~~~~~~~~~~~~
-
-If you want to be more specific as to why the test is failing, you can specify
-a single exception, or a tuple of exceptions, in the ``raises`` argument.
-
-.. code-block:: python
-
-    @pytest.mark.xfail(raises=RuntimeError)
-    def test_function():
-        ...
-
-Then the test will be reported as a regular failure if it fails with an
-exception not mentioned in ``raises``.
-
-``run`` parameter
-~~~~~~~~~~~~~~~~~
-
-If a test should be marked as xfail and reported as such but should not be
-even executed, use the ``run`` parameter as ``False``:
-
-.. code-block:: python
-
-    @pytest.mark.xfail(run=False)
-    def test_function():
-        ...
-
-This is specially useful for xfailing tests that are crashing the interpreter and should be
-investigated later.
-
-.. _`xfail strict tutorial`:
-
-``strict`` parameter
-~~~~~~~~~~~~~~~~~~~~
-
-Both ``XFAIL`` and ``XPASS`` don't fail the test suite by default.
-You can change this by setting the ``strict`` keyword-only parameter to ``True``:
-
-.. code-block:: python
-
-    @pytest.mark.xfail(strict=True)
-    def test_function():
-        ...
-
-
-This will make ``XPASS`` ("unexpectedly passing") results from this test to fail the test suite.
-
-You can change the default value of the ``strict`` parameter using the
-``xfail_strict`` ini option:
-
-.. code-block:: ini
-
-    [pytest]
-    xfail_strict=true
-
-
-Ignoring xfail
-~~~~~~~~~~~~~~
-
-By specifying on the commandline:
-
-.. code-block:: bash
-
-    pytest --runxfail
-
-you can force the running and reporting of an ``xfail`` marked test
-as if it weren't marked at all. This also causes :func:`pytest.xfail` to produce no effect.
-
-Examples
-~~~~~~~~
-
-Here is a simple test file with the several usages:
-
-.. literalinclude:: example/xfail_demo.py
-
-Running it with the report-on-xfail option gives this output:
-
-.. code-block:: pytest
-
-    example $ pytest -rx xfail_demo.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR/example
-    collected 7 items
-
-    xfail_demo.py xxxxxxx                                                [100%]
-
-    ========================= short test summary info ==========================
-    XFAIL xfail_demo.py::test_hello
-    XFAIL xfail_demo.py::test_hello2
-      reason: [NOTRUN]
-    XFAIL xfail_demo.py::test_hello3
-      condition: hasattr(os, 'sep')
-    XFAIL xfail_demo.py::test_hello4
-      bug 110
-    XFAIL xfail_demo.py::test_hello5
-      condition: pytest.__version__[0] != "17"
-    XFAIL xfail_demo.py::test_hello6
-      reason: reason
-    XFAIL xfail_demo.py::test_hello7
-    ============================ 7 xfailed in 0.12s ============================
-
-.. _`skip/xfail with parametrize`:
-
-Skip/xfail with parametrize
----------------------------
-
-It is possible to apply markers like skip and xfail to individual
-test instances when using parametrize:
-
-.. code-block:: python
-
-    import pytest
-
-
-    @pytest.mark.parametrize(
-        ("n", "expected"),
-        [
-            (1, 2),
-            pytest.param(1, 0, marks=pytest.mark.xfail),
-            pytest.param(1, 3, marks=pytest.mark.xfail(reason="some bug")),
-            (2, 3),
-            (3, 4),
-            (4, 5),
-            pytest.param(
-                10, 11, marks=pytest.mark.skipif(sys.version_info >= (3, 0), reason="py2k")
-            ),
-        ],
-    )
-    def test_increment(n, expected):
-        assert n + 1 == expected
index 216ccb8dd8a46e5f0d6ad133c22d6b9d510cc999..b9b153a792e4f9a95496940a500dee55fd2a91a1 100644 (file)
@@ -11,9 +11,16 @@ Books
 - `Python Testing with pytest, by Brian Okken (2017)
   <https://pragprog.com/book/bopytest/python-testing-with-pytest>`_.
 
+- `Python Testing with pytest, Second Edition, by Brian Okken (2022)
+  <https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition>`_.
+
 Talks and blog postings
 ---------------------------------------------
 
+- Training: `pytest - simple, rapid and fun testing with Python <https://www.youtube.com/watch?v=ofPHJrAOaTE>`_, Florian Bruhin, PyConDE 2022
+
+- `pytest: Simple, rapid and fun testing with Python, <https://youtu.be/cSJ-X3TbQ1c?t=15752>`_ (@ 4:22:32), Florian Bruhin, WeAreDevelopers World Congress 2021
+
 - Webinar: `pytest: Test Driven Development für Python (German) <https://bruhin.software/ins-pytest/>`_, Florian Bruhin, via mylearning.ch, 2020
 
 - Webinar: `Simplify Your Tests with Fixtures <https://blog.jetbrains.com/pycharm/2020/08/webinar-recording-simplify-your-tests-with-fixtures-with-oliver-bestwalter/>`_, Oliver Bestwalter, via JetBrains, 2020
@@ -70,8 +77,8 @@ Talks and blog postings
 - `pytest introduction from Brian Okken (January 2013)
   <http://pythontesting.net/framework/pytest-introduction/>`_
 
-- pycon australia 2012 pytest talk from Brianna Laugher (`video <http://www.youtube.com/watch?v=DTNejE9EraI>`_, `slides <https://www.slideshare.net/pfctdayelise/funcargs-other-fun-with-pytest>`_, `code <https://gist.github.com/3386951>`_)
-- `pycon 2012 US talk video from Holger Krekel <http://www.youtube.com/watch?v=9LVqBQcFmyw>`_
+- pycon australia 2012 pytest talk from Brianna Laugher (`video <https://www.youtube.com/watch?v=DTNejE9EraI>`_, `slides <https://www.slideshare.net/pfctdayelise/funcargs-other-fun-with-pytest>`_, `code <https://gist.github.com/3386951>`_)
+- `pycon 2012 US talk video from Holger Krekel <https://www.youtube.com/watch?v=9LVqBQcFmyw>`_
 
 - `monkey patching done right`_ (blog post, consult `monkeypatch plugin`_ for up-to-date API)
 
@@ -101,9 +108,9 @@ Plugin specific examples:
 .. _`many examples in the docs for plugins`: plugins.html
 .. _`monkeypatch plugin`: monkeypatch.html
 .. _`application setup in test functions with fixtures`: fixture.html#interdependent-fixtures
-.. _`simultaneously test your code on all platforms`: http://tetamap.wordpress.com/2009/03/23/new-simultanously-test-your-code-on-all-platforms/
-.. _`monkey patching done right`: http://tetamap.wordpress.com/2009/03/03/monkeypatching-in-unit-tests-done-right/
-.. _`putting test-hooks into local or global plugins`: http://tetamap.wordpress.com/2009/05/14/putting-test-hooks-into-local-and-global-plugins/
-.. _`parametrizing tests, generalized`: http://tetamap.wordpress.com/2009/05/13/parametrizing-python-tests-generalized/
+.. _`simultaneously test your code on all platforms`: https://tetamap.wordpress.com//2009/03/23/new-simultanously-test-your-code-on-all-platforms/
+.. _`monkey patching done right`: https://tetamap.wordpress.com//2009/03/03/monkeypatching-in-unit-tests-done-right/
+.. _`putting test-hooks into local or global plugins`: https://tetamap.wordpress.com/2009/05/14/putting-test-hooks-into-local-and-global-plugins/
+.. _`parametrizing tests, generalized`: https://tetamap.wordpress.com/2009/05/13/parametrizing-python-tests-generalized/
 .. _`generating parametrized tests with fixtures`: parametrize.html#test-generators
 .. _`test generators and cached setup`: http://bruynooghe.blogspot.com/2010/06/pytest-test-generators-and-cached-setup.html
diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst
deleted file mode 100644 (file)
index adcba02..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-
-.. _`tmpdir handling`:
-.. _tmpdir:
-
-Temporary directories and files
-================================================
-
-The ``tmp_path`` fixture
-------------------------
-
-
-
-
-You can use the ``tmp_path`` fixture which will
-provide a temporary directory unique to the test invocation,
-created in the `base temporary directory`_.
-
-``tmp_path`` is a ``pathlib.Path`` object. Here is an example test usage:
-
-.. code-block:: python
-
-    # content of test_tmp_path.py
-    CONTENT = "content"
-
-
-    def test_create_file(tmp_path):
-        d = tmp_path / "sub"
-        d.mkdir()
-        p = d / "hello.txt"
-        p.write_text(CONTENT)
-        assert p.read_text() == CONTENT
-        assert len(list(tmp_path.iterdir())) == 1
-        assert 0
-
-Running this would result in a passed test except for the last
-``assert 0`` line which we use to look at values:
-
-.. code-block:: pytest
-
-    $ pytest test_tmp_path.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 1 item
-
-    test_tmp_path.py F                                                   [100%]
-
-    ================================= FAILURES =================================
-    _____________________________ test_create_file _____________________________
-
-    tmp_path = PosixPath('PYTEST_TMPDIR/test_create_file0')
-
-        def test_create_file(tmp_path):
-            d = tmp_path / "sub"
-            d.mkdir()
-            p = d / "hello.txt"
-            p.write_text(CONTENT)
-            assert p.read_text() == CONTENT
-            assert len(list(tmp_path.iterdir())) == 1
-    >       assert 0
-    E       assert 0
-
-    test_tmp_path.py:11: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_tmp_path.py::test_create_file - assert 0
-    ============================ 1 failed in 0.12s =============================
-
-.. _`tmp_path_factory example`:
-
-The ``tmp_path_factory`` fixture
---------------------------------
-
-
-
-
-The ``tmp_path_factory`` is a session-scoped fixture which can be used
-to create arbitrary temporary directories from any other fixture or test.
-
-It is intended to replace ``tmpdir_factory``, and returns :class:`pathlib.Path` instances.
-
-See :ref:`tmp_path_factory API <tmp_path_factory factory api>` for details.
-
-
-The 'tmpdir' fixture
---------------------
-
-You can use the ``tmpdir`` fixture which will
-provide a temporary directory unique to the test invocation,
-created in the `base temporary directory`_.
-
-``tmpdir`` is a `py.path.local`_ object which offers ``os.path`` methods
-and more.  Here is an example test usage:
-
-.. code-block:: python
-
-    # content of test_tmpdir.py
-    def test_create_file(tmpdir):
-        p = tmpdir.mkdir("sub").join("hello.txt")
-        p.write("content")
-        assert p.read() == "content"
-        assert len(tmpdir.listdir()) == 1
-        assert 0
-
-Running this would result in a passed test except for the last
-``assert 0`` line which we use to look at values:
-
-.. code-block:: pytest
-
-    $ pytest test_tmpdir.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 1 item
-
-    test_tmpdir.py F                                                     [100%]
-
-    ================================= FAILURES =================================
-    _____________________________ test_create_file _____________________________
-
-    tmpdir = local('PYTEST_TMPDIR/test_create_file0')
-
-        def test_create_file(tmpdir):
-            p = tmpdir.mkdir("sub").join("hello.txt")
-            p.write("content")
-            assert p.read() == "content"
-            assert len(tmpdir.listdir()) == 1
-    >       assert 0
-    E       assert 0
-
-    test_tmpdir.py:6: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_tmpdir.py::test_create_file - assert 0
-    ============================ 1 failed in 0.12s =============================
-
-.. _`tmpdir factory example`:
-
-The 'tmpdir_factory' fixture
-----------------------------
-
-
-
-The ``tmpdir_factory`` is a session-scoped fixture which can be used
-to create arbitrary temporary directories from any other fixture or test.
-
-For example, suppose your test suite needs a large image on disk, which is
-generated procedurally. Instead of computing the same image for each test
-that uses it into its own ``tmpdir``, you can generate it once per-session
-to save time:
-
-.. code-block:: python
-
-    # contents of conftest.py
-    import pytest
-
-
-    @pytest.fixture(scope="session")
-    def image_file(tmpdir_factory):
-        img = compute_expensive_image()
-        fn = tmpdir_factory.mktemp("data").join("img.png")
-        img.save(str(fn))
-        return fn
-
-
-    # contents of test_image.py
-    def test_histogram(image_file):
-        img = load_image(image_file)
-        # compute and test histogram
-
-See :ref:`tmpdir_factory API <tmpdir factory api>` for details.
-
-
-.. _`base temporary directory`:
-
-The default base temporary directory
------------------------------------------------
-
-Temporary directories are by default created as sub-directories of
-the system temporary directory.  The base name will be ``pytest-NUM`` where
-``NUM`` will be incremented with each test run.  Moreover, entries older
-than 3 temporary directories will be removed.
-
-You can override the default temporary directory setting like this:
-
-.. code-block:: bash
-
-    pytest --basetemp=mydir
-
-.. warning::
-
-    The contents of ``mydir`` will be completely removed, so make sure to use a directory
-    for that purpose only.
-
-When distributing tests on the local machine using ``pytest-xdist``, care is taken to
-automatically configure a basetemp directory for the sub processes such that all temporary
-data lands below a single per-test run basetemp directory.
-
-.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst
deleted file mode 100644 (file)
index 130e770..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-
-.. _`unittest.TestCase`:
-.. _`unittest`:
-
-unittest.TestCase Support
-=========================
-
-``pytest`` supports running Python ``unittest``-based tests out of the box.
-It's meant for leveraging existing ``unittest``-based test suites
-to use pytest as a test runner and also allow to incrementally adapt
-the test suite to take full advantage of pytest's features.
-
-To run an existing ``unittest``-style test suite using ``pytest``, type:
-
-.. code-block:: bash
-
-    pytest tests
-
-
-pytest will automatically collect ``unittest.TestCase`` subclasses and
-their ``test`` methods in ``test_*.py`` or ``*_test.py`` files.
-
-Almost all ``unittest`` features are supported:
-
-* ``@unittest.skip`` style decorators;
-* ``setUp/tearDown``;
-* ``setUpClass/tearDownClass``;
-* ``setUpModule/tearDownModule``;
-
-.. _`load_tests protocol`: https://docs.python.org/3/library/unittest.html#load-tests-protocol
-.. _`subtests`: https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests
-
-Up to this point pytest does not have support for the following features:
-
-* `load_tests protocol`_;
-* `subtests`_;
-
-Benefits out of the box
------------------------
-
-By running your test suite with pytest you can make use of several features,
-in most cases without having to modify existing code:
-
-* Obtain :ref:`more informative tracebacks <tbreportdemo>`;
-* :ref:`stdout and stderr <captures>` capturing;
-* :ref:`Test selection options <select-tests>` using ``-k`` and ``-m`` flags;
-* :ref:`maxfail`;
-* :ref:`--pdb <pdb-option>` command-line option for debugging on test failures
-  (see :ref:`note <pdb-unittest-note>` below);
-* Distribute tests to multiple CPUs using the `pytest-xdist <https://pypi.org/project/pytest-xdist/>`_ plugin;
-* Use :ref:`plain assert-statements <assert>` instead of ``self.assert*`` functions (`unittest2pytest
-  <https://pypi.org/project/unittest2pytest/>`__ is immensely helpful in this);
-
-
-pytest features in ``unittest.TestCase`` subclasses
----------------------------------------------------
-
-The following pytest features work in ``unittest.TestCase`` subclasses:
-
-* :ref:`Marks <mark>`: :ref:`skip <skip>`, :ref:`skipif <skipif>`, :ref:`xfail <xfail>`;
-* :ref:`Auto-use fixtures <mixing-fixtures>`;
-
-The following pytest features **do not** work, and probably
-never will due to different design philosophies:
-
-* :ref:`Fixtures <fixture>` (except for ``autouse`` fixtures, see :ref:`below <mixing-fixtures>`);
-* :ref:`Parametrization <parametrize>`;
-* :ref:`Custom hooks <writing-plugins>`;
-
-
-Third party plugins may or may not work well, depending on the plugin and the test suite.
-
-.. _mixing-fixtures:
-
-Mixing pytest fixtures into ``unittest.TestCase`` subclasses using marks
-------------------------------------------------------------------------
-
-Running your unittest with ``pytest`` allows you to use its
-:ref:`fixture mechanism <fixture>` with ``unittest.TestCase`` style
-tests.  Assuming you have at least skimmed the pytest fixture features,
-let's jump-start into an example that integrates a pytest ``db_class``
-fixture, setting up a class-cached database object, and then reference
-it from a unittest-style test:
-
-.. code-block:: python
-
-    # content of conftest.py
-
-    # we define a fixture function below and it will be "used" by
-    # referencing its name from tests
-
-    import pytest
-
-
-    @pytest.fixture(scope="class")
-    def db_class(request):
-        class DummyDB:
-            pass
-
-        # set a class attribute on the invoking test context
-        request.cls.db = DummyDB()
-
-This defines a fixture function ``db_class`` which - if used - is
-called once for each test class and which sets the class-level
-``db`` attribute to a ``DummyDB`` instance.  The fixture function
-achieves this by receiving a special ``request`` object which gives
-access to :ref:`the requesting test context <request-context>` such
-as the ``cls`` attribute, denoting the class from which the fixture
-is used.  This architecture de-couples fixture writing from actual test
-code and allows re-use of the fixture by a minimal reference, the fixture
-name.  So let's write an actual ``unittest.TestCase`` class using our
-fixture definition:
-
-.. code-block:: python
-
-    # content of test_unittest_db.py
-
-    import unittest
-    import pytest
-
-
-    @pytest.mark.usefixtures("db_class")
-    class MyTest(unittest.TestCase):
-        def test_method1(self):
-            assert hasattr(self, "db")
-            assert 0, self.db  # fail for demo purposes
-
-        def test_method2(self):
-            assert 0, self.db  # fail for demo purposes
-
-The ``@pytest.mark.usefixtures("db_class")`` class-decorator makes sure that
-the pytest fixture function ``db_class`` is called once per class.
-Due to the deliberately failing assert statements, we can take a look at
-the ``self.db`` values in the traceback:
-
-.. code-block:: pytest
-
-    $ pytest test_unittest_db.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 2 items
-
-    test_unittest_db.py FF                                               [100%]
-
-    ================================= FAILURES =================================
-    ___________________________ MyTest.test_method1 ____________________________
-
-    self = <test_unittest_db.MyTest testMethod=test_method1>
-
-        def test_method1(self):
-            assert hasattr(self, "db")
-    >       assert 0, self.db  # fail for demo purposes
-    E       AssertionError: <conftest.db_class.<locals>.DummyDB object at 0xdeadbeef>
-    E       assert 0
-
-    test_unittest_db.py:10: AssertionError
-    ___________________________ MyTest.test_method2 ____________________________
-
-    self = <test_unittest_db.MyTest testMethod=test_method2>
-
-        def test_method2(self):
-    >       assert 0, self.db  # fail for demo purposes
-    E       AssertionError: <conftest.db_class.<locals>.DummyDB object at 0xdeadbeef>
-    E       assert 0
-
-    test_unittest_db.py:13: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_unittest_db.py::MyTest::test_method1 - AssertionError: <conft...
-    FAILED test_unittest_db.py::MyTest::test_method2 - AssertionError: <conft...
-    ============================ 2 failed in 0.12s =============================
-
-This default pytest traceback shows that the two test methods
-share the same ``self.db`` instance which was our intention
-when writing the class-scoped fixture function above.
-
-
-Using autouse fixtures and accessing other fixtures
----------------------------------------------------
-
-Although it's usually better to explicitly declare use of fixtures you need
-for a given test, you may sometimes want to have fixtures that are
-automatically used in a given context.  After all, the traditional
-style of unittest-setup mandates the use of this implicit fixture writing
-and chances are, you are used to it or like it.
-
-You can flag fixture functions with ``@pytest.fixture(autouse=True)``
-and define the fixture function in the context where you want it used.
-Let's look at an ``initdir`` fixture which makes all test methods of a
-``TestCase`` class execute in a temporary directory with a
-pre-initialized ``samplefile.ini``.  Our ``initdir`` fixture itself uses
-the pytest builtin :ref:`tmpdir <tmpdir>` fixture to delegate the
-creation of a per-test temporary directory:
-
-.. code-block:: python
-
-    # content of test_unittest_cleandir.py
-    import pytest
-    import unittest
-
-
-    class MyTest(unittest.TestCase):
-        @pytest.fixture(autouse=True)
-        def initdir(self, tmpdir):
-            tmpdir.chdir()  # change to pytest-provided temporary directory
-            tmpdir.join("samplefile.ini").write("# testdata")
-
-        def test_method(self):
-            with open("samplefile.ini") as f:
-                s = f.read()
-            assert "testdata" in s
-
-Due to the ``autouse`` flag the ``initdir`` fixture function will be
-used for all methods of the class where it is defined.  This is a
-shortcut for using a ``@pytest.mark.usefixtures("initdir")`` marker
-on the class like in the previous example.
-
-Running this test module ...:
-
-.. code-block:: pytest
-
-    $ pytest -q test_unittest_cleandir.py
-    .                                                                    [100%]
-    1 passed in 0.12s
-
-... gives us one passed test because the ``initdir`` fixture function
-was executed ahead of the ``test_method``.
-
-.. note::
-
-   ``unittest.TestCase`` methods cannot directly receive fixture
-   arguments as implementing that is likely to inflict
-   on the ability to run general unittest.TestCase test suites.
-
-   The above ``usefixtures`` and ``autouse`` examples should help to mix in
-   pytest fixtures into unittest suites.
-
-   You can also gradually move away from subclassing from ``unittest.TestCase`` to *plain asserts*
-   and then start to benefit from the full pytest feature set step by step.
-
-.. _pdb-unittest-note:
-
-.. note::
-
-    Due to architectural differences between the two frameworks, setup and
-    teardown for ``unittest``-based tests is performed during the ``call`` phase
-    of testing instead of in ``pytest``'s standard ``setup`` and ``teardown``
-    stages. This can be important to understand in some situations, particularly
-    when reasoning about errors. For example, if a ``unittest``-based suite
-    exhibits errors during setup, ``pytest`` will report no errors during its
-    ``setup`` phase and will instead raise the error during ``call``.
diff --git a/doc/en/usage.rst b/doc/en/usage.rst
deleted file mode 100644 (file)
index fbd3333..0000000
+++ /dev/null
@@ -1,872 +0,0 @@
-
-.. _usage:
-
-Usage and Invocations
-==========================================
-
-
-.. _cmdline:
-
-Calling pytest through ``python -m pytest``
------------------------------------------------------
-
-
-
-You can invoke testing through the Python interpreter from the command line:
-
-.. code-block:: text
-
-    python -m pytest [...]
-
-This is almost equivalent to invoking the command line script ``pytest [...]``
-directly, except that calling via ``python`` will also add the current directory to ``sys.path``.
-
-Possible exit codes
---------------------------------------------------------------
-
-Running ``pytest`` can result in six different exit codes:
-
-:Exit code 0: All tests were collected and passed successfully
-:Exit code 1: Tests were collected and run but some of the tests failed
-:Exit code 2: Test execution was interrupted by the user
-:Exit code 3: Internal error happened while executing tests
-:Exit code 4: pytest command line usage error
-:Exit code 5: No tests were collected
-
-They are represented by the :class:`pytest.ExitCode` enum. The exit codes being a part of the public API can be imported and accessed directly using:
-
-.. code-block:: python
-
-    from pytest import ExitCode
-
-.. note::
-
-    If you would like to customize the exit code in some scenarios, specially when
-    no tests are collected, consider using the
-    `pytest-custom_exit_code <https://github.com/yashtodi94/pytest-custom_exit_code>`__
-    plugin.
-
-
-Getting help on version, option names, environment variables
---------------------------------------------------------------
-
-.. code-block:: bash
-
-    pytest --version   # shows where pytest was imported from
-    pytest --fixtures  # show available builtin function arguments
-    pytest -h | --help # show help on command line and config file options
-
-
-The full command-line flags can be found in the :ref:`reference <command-line-flags>`.
-
-.. _maxfail:
-
-Stopping after the first (or N) failures
----------------------------------------------------
-
-To stop the testing process after the first (N) failures:
-
-.. code-block:: bash
-
-    pytest -x           # stop after first failure
-    pytest --maxfail=2  # stop after two failures
-
-.. _select-tests:
-
-Specifying tests / selecting tests
----------------------------------------------------
-
-Pytest supports several ways to run and select tests from the command-line.
-
-**Run tests in a module**
-
-.. code-block:: bash
-
-    pytest test_mod.py
-
-**Run tests in a directory**
-
-.. code-block:: bash
-
-    pytest testing/
-
-**Run tests by keyword expressions**
-
-.. code-block:: bash
-
-    pytest -k "MyClass and not method"
-
-This will run tests which contain names that match the given *string expression* (case-insensitive),
-which can include Python operators that use filenames, class names and function names as variables.
-The example above will run ``TestMyClass.test_something``  but not ``TestMyClass.test_method_simple``.
-
-.. _nodeids:
-
-**Run tests by node ids**
-
-Each collected test is assigned a unique ``nodeid`` which consist of the module filename followed
-by specifiers like class names, function names and parameters from parametrization, separated by ``::`` characters.
-
-To run a specific test within a module:
-
-.. code-block:: bash
-
-    pytest test_mod.py::test_func
-
-
-Another example specifying a test method in the command line:
-
-.. code-block:: bash
-
-    pytest test_mod.py::TestClass::test_method
-
-**Run tests by marker expressions**
-
-.. code-block:: bash
-
-    pytest -m slow
-
-Will run all tests which are decorated with the ``@pytest.mark.slow`` decorator.
-
-For more information see :ref:`marks <mark>`.
-
-**Run tests from packages**
-
-.. code-block:: bash
-
-    pytest --pyargs pkg.testing
-
-This will import ``pkg.testing`` and use its filesystem location to find and run tests from.
-
-
-Modifying Python traceback printing
-----------------------------------------------
-
-Examples for modifying traceback printing:
-
-.. code-block:: bash
-
-    pytest --showlocals # show local variables in tracebacks
-    pytest -l           # show local variables (shortcut)
-
-    pytest --tb=auto    # (default) 'long' tracebacks for the first and last
-                         # entry, but 'short' style for the other entries
-    pytest --tb=long    # exhaustive, informative traceback formatting
-    pytest --tb=short   # shorter traceback format
-    pytest --tb=line    # only one line per failure
-    pytest --tb=native  # Python standard library formatting
-    pytest --tb=no      # no traceback at all
-
-The ``--full-trace`` causes very long traces to be printed on error (longer
-than ``--tb=long``). It also ensures that a stack trace is printed on
-**KeyboardInterrupt** (Ctrl+C).
-This is very useful if the tests are taking too long and you interrupt them
-with Ctrl+C to find out where the tests are *hanging*. By default no output
-will be shown (because KeyboardInterrupt is caught by pytest). By using this
-option you make sure a trace is shown.
-
-
-.. _`pytest.detailed_failed_tests_usage`:
-
-Detailed summary report
------------------------
-
-The ``-r`` flag can be used to display a "short test summary info" at the end of the test session,
-making it easy in large test suites to get a clear picture of all failures, skips, xfails, etc.
-
-It defaults to ``fE`` to list failures and errors.
-
-Example:
-
-.. code-block:: python
-
-    # content of test_example.py
-    import pytest
-
-
-    @pytest.fixture
-    def error_fixture():
-        assert 0
-
-
-    def test_ok():
-        print("ok")
-
-
-    def test_fail():
-        assert 0
-
-
-    def test_error(error_fixture):
-        pass
-
-
-    def test_skip():
-        pytest.skip("skipping this test")
-
-
-    def test_xfail():
-        pytest.xfail("xfailing this test")
-
-
-    @pytest.mark.xfail(reason="always xfail")
-    def test_xpass():
-        pass
-
-
-.. code-block:: pytest
-
-    $ pytest -ra
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 6 items
-
-    test_example.py .FEsxX                                               [100%]
-
-    ================================== ERRORS ==================================
-    _______________________ ERROR at setup of test_error _______________________
-
-        @pytest.fixture
-        def error_fixture():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:6: AssertionError
-    ================================= FAILURES =================================
-    ________________________________ test_fail _________________________________
-
-        def test_fail():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:14: AssertionError
-    ========================= short test summary info ==========================
-    SKIPPED [1] test_example.py:22: skipping this test
-    XFAIL test_example.py::test_xfail
-      reason: xfailing this test
-    XPASS test_example.py::test_xpass always xfail
-    ERROR test_example.py::test_error - assert 0
-    FAILED test_example.py::test_fail - assert 0
-    == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
-
-The ``-r`` options accepts a number of characters after it, with ``a`` used
-above meaning "all except passes".
-
-Here is the full list of available characters that can be used:
-
- - ``f`` - failed
- - ``E`` - error
- - ``s`` - skipped
- - ``x`` - xfailed
- - ``X`` - xpassed
- - ``p`` - passed
- - ``P`` - passed with output
-
-Special characters for (de)selection of groups:
-
- - ``a`` - all except ``pP``
- - ``A`` - all
- - ``N`` - none, this can be used to display nothing (since ``fE`` is the default)
-
-More than one character can be used, so for example to only see failed and skipped tests, you can execute:
-
-.. code-block:: pytest
-
-    $ pytest -rfs
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 6 items
-
-    test_example.py .FEsxX                                               [100%]
-
-    ================================== ERRORS ==================================
-    _______________________ ERROR at setup of test_error _______________________
-
-        @pytest.fixture
-        def error_fixture():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:6: AssertionError
-    ================================= FAILURES =================================
-    ________________________________ test_fail _________________________________
-
-        def test_fail():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:14: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_example.py::test_fail - assert 0
-    SKIPPED [1] test_example.py:22: skipping this test
-    == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
-
-Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had
-captured output:
-
-.. code-block:: pytest
-
-    $ pytest -rpP
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 6 items
-
-    test_example.py .FEsxX                                               [100%]
-
-    ================================== ERRORS ==================================
-    _______________________ ERROR at setup of test_error _______________________
-
-        @pytest.fixture
-        def error_fixture():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:6: AssertionError
-    ================================= FAILURES =================================
-    ________________________________ test_fail _________________________________
-
-        def test_fail():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:14: AssertionError
-    ================================== PASSES ==================================
-    _________________________________ test_ok __________________________________
-    --------------------------- Captured stdout call ---------------------------
-    ok
-    ========================= short test summary info ==========================
-    PASSED test_example.py::test_ok
-    == 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
-
-.. _pdb-option:
-
-Dropping to PDB_ (Python Debugger) on failures
------------------------------------------------
-
-.. _PDB: http://docs.python.org/library/pdb.html
-
-Python comes with a builtin Python debugger called PDB_.  ``pytest``
-allows one to drop into the PDB_ prompt via a command line option:
-
-.. code-block:: bash
-
-    pytest --pdb
-
-This will invoke the Python debugger on every failure (or KeyboardInterrupt).
-Often you might only want to do this for the first failing test to understand
-a certain failure situation:
-
-.. code-block:: bash
-
-    pytest -x --pdb   # drop to PDB on first failure, then end test session
-    pytest --pdb --maxfail=3  # drop to PDB for first three failures
-
-Note that on any failure the exception information is stored on
-``sys.last_value``, ``sys.last_type`` and ``sys.last_traceback``. In
-interactive use, this allows one to drop into postmortem debugging with
-any debug tool. One can also manually access the exception information,
-for example::
-
-    >>> import sys
-    >>> sys.last_traceback.tb_lineno
-    42
-    >>> sys.last_value
-    AssertionError('assert result == "ok"',)
-
-.. _trace-option:
-
-Dropping to PDB_ (Python Debugger) at the start of a test
-----------------------------------------------------------
-
-
-``pytest`` allows one to drop into the PDB_ prompt immediately at the start of each test via a command line option:
-
-.. code-block:: bash
-
-    pytest --trace
-
-This will invoke the Python debugger at the start of every test.
-
-.. _breakpoints:
-
-Setting breakpoints
--------------------
-
-.. versionadded: 2.4.0
-
-To set a breakpoint in your code use the native Python ``import pdb;pdb.set_trace()`` call
-in your code and pytest automatically disables its output capture for that test:
-
-* Output capture in other tests is not affected.
-* Any prior test output that has already been captured and will be processed as
-  such.
-* Output capture gets resumed when ending the debugger session (via the
-  ``continue`` command).
-
-
-.. _`breakpoint-builtin`:
-
-Using the builtin breakpoint function
--------------------------------------
-
-Python 3.7 introduces a builtin ``breakpoint()`` function.
-Pytest supports the use of ``breakpoint()`` with the following behaviours:
-
- - When ``breakpoint()`` is called and ``PYTHONBREAKPOINT`` is set to the default value, pytest will use the custom internal PDB trace UI instead of the system default ``Pdb``.
- - When tests are complete, the system will default back to the system ``Pdb`` trace UI.
- - With ``--pdb`` passed to pytest, the custom internal Pdb trace UI is used with both ``breakpoint()`` and failed tests/unhandled exceptions.
- - ``--pdbcls`` can be used to specify a custom debugger class.
-
-.. _durations:
-
-Profiling test execution duration
--------------------------------------
-
-.. versionchanged:: 6.0
-
-To get a list of the slowest 10 test durations over 1.0s long:
-
-.. code-block:: bash
-
-    pytest --durations=10 --durations-min=1.0
-
-By default, pytest will not show test durations that are too small (<0.005s) unless ``-vv`` is passed on the command-line.
-
-
-.. _faulthandler:
-
-Fault Handler
--------------
-
-.. versionadded:: 5.0
-
-The `faulthandler <https://docs.python.org/3/library/faulthandler.html>`__ standard module
-can be used to dump Python tracebacks on a segfault or after a timeout.
-
-The module is automatically enabled for pytest runs, unless the ``-p no:faulthandler`` is given
-on the command-line.
-
-Also the :confval:`faulthandler_timeout=X<faulthandler_timeout>` configuration option can be used
-to dump the traceback of all threads if a test takes longer than ``X``
-seconds to finish (not available on Windows).
-
-.. note::
-
-    This functionality has been integrated from the external
-    `pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin, with two
-    small differences:
-
-    * To disable it, use ``-p no:faulthandler`` instead of ``--no-faulthandler``: the former
-      can be used with any plugin, so it saves one option.
-
-    * The ``--faulthandler-timeout`` command-line option has become the
-      :confval:`faulthandler_timeout` configuration option. It can still be configured from
-      the command-line using ``-o faulthandler_timeout=X``.
-
-
-.. _unraisable:
-
-Warning about unraisable exceptions and unhandled thread exceptions
--------------------------------------------------------------------
-
-.. versionadded:: 6.2
-
-.. note::
-
-    These features only work on Python>=3.8.
-
-Unhandled exceptions are exceptions that are raised in a situation in which
-they cannot propagate to a caller. The most common case is an exception raised
-in a :meth:`__del__ <object.__del__>` implementation.
-
-Unhandled thread exceptions are exceptions raised in a :class:`~threading.Thread`
-but not handled, causing the thread to terminate uncleanly.
-
-Both types of exceptions are normally considered bugs, but may go unnoticed
-because they don't cause the program itself to crash. Pytest detects these
-conditions and issues a warning that is visible in the test run summary.
-
-The plugins are automatically enabled for pytest runs, unless the
-``-p no:unraisableexception`` (for unraisable exceptions) and
-``-p no:threadexception`` (for thread exceptions) options are given on the
-command-line.
-
-The warnings may be silenced selectivly using the :ref:`pytest.mark.filterwarnings ref`
-mark. The warning categories are :class:`pytest.PytestUnraisableExceptionWarning` and
-:class:`pytest.PytestUnhandledThreadExceptionWarning`.
-
-
-Creating JUnitXML format files
-----------------------------------------------------
-
-To create result files which can be read by Jenkins_ or other Continuous
-integration servers, use this invocation:
-
-.. code-block:: bash
-
-    pytest --junitxml=path
-
-to create an XML file at ``path``.
-
-
-
-To set the name of the root test suite xml item, you can configure the ``junit_suite_name`` option in your config file:
-
-.. code-block:: ini
-
-    [pytest]
-    junit_suite_name = my_suite
-
-.. versionadded:: 4.0
-
-JUnit XML specification seems to indicate that ``"time"`` attribute
-should report total test execution times, including setup and teardown
-(`1 <http://windyroad.com.au/dl/Open%20Source/JUnit.xsd>`_, `2
-<https://www.ibm.com/support/knowledgecenter/en/SSQ2R2_14.1.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html>`_).
-It is the default pytest behavior. To report just call durations
-instead, configure the ``junit_duration_report`` option like this:
-
-.. code-block:: ini
-
-    [pytest]
-    junit_duration_report = call
-
-.. _record_property example:
-
-record_property
-^^^^^^^^^^^^^^^
-
-If you want to log additional information for a test, you can use the
-``record_property`` fixture:
-
-.. code-block:: python
-
-    def test_function(record_property):
-        record_property("example_key", 1)
-        assert True
-
-This will add an extra property ``example_key="1"`` to the generated
-``testcase`` tag:
-
-.. code-block:: xml
-
-    <testcase classname="test_function" file="test_function.py" line="0" name="test_function" time="0.0009">
-      <properties>
-        <property name="example_key" value="1" />
-      </properties>
-    </testcase>
-
-Alternatively, you can integrate this functionality with custom markers:
-
-.. code-block:: python
-
-    # content of conftest.py
-
-
-    def pytest_collection_modifyitems(session, config, items):
-        for item in items:
-            for marker in item.iter_markers(name="test_id"):
-                test_id = marker.args[0]
-                item.user_properties.append(("test_id", test_id))
-
-And in your tests:
-
-.. code-block:: python
-
-    # content of test_function.py
-    import pytest
-
-
-    @pytest.mark.test_id(1501)
-    def test_function():
-        assert True
-
-Will result in:
-
-.. code-block:: xml
-
-    <testcase classname="test_function" file="test_function.py" line="0" name="test_function" time="0.0009">
-      <properties>
-        <property name="test_id" value="1501" />
-      </properties>
-    </testcase>
-
-.. warning::
-
-    Please note that using this feature will break schema verifications for the latest JUnitXML schema.
-    This might be a problem when used with some CI servers.
-
-record_xml_attribute
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-
-
-To add an additional xml attribute to a testcase element, you can use
-``record_xml_attribute`` fixture. This can also be used to override existing values:
-
-.. code-block:: python
-
-    def test_function(record_xml_attribute):
-        record_xml_attribute("assertions", "REQ-1234")
-        record_xml_attribute("classname", "custom_classname")
-        print("hello world")
-        assert True
-
-Unlike ``record_property``, this will not add a new child element.
-Instead, this will add an attribute ``assertions="REQ-1234"`` inside the generated
-``testcase`` tag and override the default ``classname`` with ``"classname=custom_classname"``:
-
-.. code-block:: xml
-
-    <testcase classname="custom_classname" file="test_function.py" line="0" name="test_function" time="0.003" assertions="REQ-1234">
-        <system-out>
-            hello world
-        </system-out>
-    </testcase>
-
-.. warning::
-
-    ``record_xml_attribute`` is an experimental feature, and its interface might be replaced
-    by something more powerful and general in future versions. The
-    functionality per-se will be kept, however.
-
-    Using this over ``record_xml_property`` can help when using ci tools to parse the xml report.
-    However, some parsers are quite strict about the elements and attributes that are allowed.
-    Many tools use an xsd schema (like the example below) to validate incoming xml.
-    Make sure you are using attribute names that are allowed by your parser.
-
-    Below is the Scheme used by Jenkins to validate the XML report:
-
-    .. code-block:: xml
-
-        <xs:element name="testcase">
-            <xs:complexType>
-                <xs:sequence>
-                    <xs:element ref="skipped" minOccurs="0" maxOccurs="1"/>
-                    <xs:element ref="error" minOccurs="0" maxOccurs="unbounded"/>
-                    <xs:element ref="failure" minOccurs="0" maxOccurs="unbounded"/>
-                    <xs:element ref="system-out" minOccurs="0" maxOccurs="unbounded"/>
-                    <xs:element ref="system-err" minOccurs="0" maxOccurs="unbounded"/>
-                </xs:sequence>
-                <xs:attribute name="name" type="xs:string" use="required"/>
-                <xs:attribute name="assertions" type="xs:string" use="optional"/>
-                <xs:attribute name="time" type="xs:string" use="optional"/>
-                <xs:attribute name="classname" type="xs:string" use="optional"/>
-                <xs:attribute name="status" type="xs:string" use="optional"/>
-            </xs:complexType>
-        </xs:element>
-
-.. warning::
-
-    Please note that using this feature will break schema verifications for the latest JUnitXML schema.
-    This might be a problem when used with some CI servers.
-
-.. _record_testsuite_property example:
-
-record_testsuite_property
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-.. versionadded:: 4.5
-
-If you want to add a properties node at the test-suite level, which may contains properties
-that are relevant to all tests, you can use the ``record_testsuite_property`` session-scoped fixture:
-
-The ``record_testsuite_property`` session-scoped fixture can be used to add properties relevant
-to all tests.
-
-.. code-block:: python
-
-    import pytest
-
-
-    @pytest.fixture(scope="session", autouse=True)
-    def log_global_env_facts(record_testsuite_property):
-        record_testsuite_property("ARCH", "PPC")
-        record_testsuite_property("STORAGE_TYPE", "CEPH")
-
-
-    class TestMe:
-        def test_foo(self):
-            assert True
-
-The fixture is a callable which receives ``name`` and ``value`` of a ``<property>`` tag
-added at the test-suite level of the generated xml:
-
-.. code-block:: xml
-
-    <testsuite errors="0" failures="0" name="pytest" skipped="0" tests="1" time="0.006">
-      <properties>
-        <property name="ARCH" value="PPC"/>
-        <property name="STORAGE_TYPE" value="CEPH"/>
-      </properties>
-      <testcase classname="test_me.TestMe" file="test_me.py" line="16" name="test_foo" time="0.000243663787842"/>
-    </testsuite>
-
-``name`` must be a string, ``value`` will be converted to a string and properly xml-escaped.
-
-The generated XML is compatible with the latest ``xunit`` standard, contrary to `record_property`_
-and `record_xml_attribute`_.
-
-
-Creating resultlog format files
-----------------------------------------------------
-
-
-To create plain-text machine-readable result files you can issue:
-
-.. code-block:: bash
-
-    pytest --resultlog=path
-
-and look at the content at the ``path`` location.  Such files are used e.g.
-by the `PyPy-test`_ web page to show test results over several revisions.
-
-.. warning::
-
-    This option is rarely used and is scheduled for removal in pytest 6.0.
-
-    If you use this option, consider using the new `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin instead.
-
-    See `the deprecation docs <https://docs.pytest.org/en/stable/deprecations.html#result-log-result-log>`__
-    for more information.
-
-
-.. _`PyPy-test`: http://buildbot.pypy.org/summary
-
-
-Sending test report to online pastebin service
------------------------------------------------------
-
-**Creating a URL for each test failure**:
-
-.. code-block:: bash
-
-    pytest --pastebin=failed
-
-This will submit test run information to a remote Paste service and
-provide a URL for each failure.  You may select tests as usual or add
-for example ``-x`` if you only want to send one particular failure.
-
-**Creating a URL for a whole test session log**:
-
-.. code-block:: bash
-
-    pytest --pastebin=all
-
-Currently only pasting to the http://bpaste.net service is implemented.
-
-.. versionchanged:: 5.2
-
-If creating the URL fails for any reason, a warning is generated instead of failing the
-entire test suite.
-
-Early loading plugins
----------------------
-
-You can early-load plugins (internal and external) explicitly in the command-line with the ``-p`` option::
-
-    pytest -p mypluginmodule
-
-The option receives a ``name`` parameter, which can be:
-
-* A full module dotted name, for example ``myproject.plugins``. This dotted name must be importable.
-* The entry-point name of a plugin. This is the name passed to ``setuptools`` when the plugin is
-  registered. For example to early-load the `pytest-cov <https://pypi.org/project/pytest-cov/>`__ plugin you can use::
-
-    pytest -p pytest_cov
-
-
-Disabling plugins
------------------
-
-To disable loading specific plugins at invocation time, use the ``-p`` option
-together with the prefix ``no:``.
-
-Example: to disable loading the plugin ``doctest``, which is responsible for
-executing doctest tests from text files, invoke pytest like this:
-
-.. code-block:: bash
-
-    pytest -p no:doctest
-
-.. _`pytest.main-usage`:
-
-Calling pytest from Python code
-----------------------------------------------------
-
-
-
-You can invoke ``pytest`` from Python code directly:
-
-.. code-block:: python
-
-    pytest.main()
-
-this acts as if you would call "pytest" from the command line.
-It will not raise ``SystemExit`` but return the exitcode instead.
-You can pass in options and arguments:
-
-.. code-block:: python
-
-    pytest.main(["-x", "mytestdir"])
-
-You can specify additional plugins to ``pytest.main``:
-
-.. code-block:: python
-
-    # content of myinvoke.py
-    import pytest
-
-
-    class MyPlugin:
-        def pytest_sessionfinish(self):
-            print("*** test run reporting finishing")
-
-
-    pytest.main(["-qq"], plugins=[MyPlugin()])
-
-Running it will show that ``MyPlugin`` was added and its
-hook was invoked:
-
-.. code-block:: pytest
-
-    $ python myinvoke.py
-    .FEsxX.                                                              [100%]*** test run reporting finishing
-
-    ================================== ERRORS ==================================
-    _______________________ ERROR at setup of test_error _______________________
-
-        @pytest.fixture
-        def error_fixture():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:6: AssertionError
-    ================================= FAILURES =================================
-    ________________________________ test_fail _________________________________
-
-        def test_fail():
-    >       assert 0
-    E       assert 0
-
-    test_example.py:14: AssertionError
-    ========================= short test summary info ==========================
-    FAILED test_example.py::test_fail - assert 0
-    ERROR test_example.py::test_error - assert 0
-
-.. note::
-
-    Calling ``pytest.main()`` will result in importing your tests and any modules
-    that they import. Due to the caching mechanism of python's import system,
-    making subsequent calls to ``pytest.main()`` from the same process will not
-    reflect changes to those files between the calls. For this reason, making
-    multiple calls to ``pytest.main()`` from the same process (in order to re-run
-    tests, for example) is not recommended.
-
-.. _jenkins: http://jenkins-ci.org/
diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst
deleted file mode 100644 (file)
index 5bbbcac..0000000
+++ /dev/null
@@ -1,430 +0,0 @@
-.. _`warnings`:
-
-Warnings Capture
-================
-
-
-
-Starting from version ``3.1``, pytest now automatically catches warnings during test execution
-and displays them at the end of the session:
-
-.. code-block:: python
-
-    # content of test_show_warnings.py
-    import warnings
-
-
-    def api_v1():
-        warnings.warn(UserWarning("api v1, should use functions from v2"))
-        return 1
-
-
-    def test_one():
-        assert api_v1() == 1
-
-Running pytest now produces this output:
-
-.. code-block:: pytest
-
-    $ pytest test_show_warnings.py
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR
-    collected 1 item
-
-    test_show_warnings.py .                                              [100%]
-
-    ============================= warnings summary =============================
-    test_show_warnings.py::test_one
-      $REGENDOC_TMPDIR/test_show_warnings.py:5: UserWarning: api v1, should use functions from v2
-        warnings.warn(UserWarning("api v1, should use functions from v2"))
-
-    -- Docs: https://docs.pytest.org/en/stable/warnings.html
-    ======================= 1 passed, 1 warning in 0.12s =======================
-
-The ``-W`` flag can be passed to control which warnings will be displayed or even turn
-them into errors:
-
-.. code-block:: pytest
-
-    $ pytest -q test_show_warnings.py -W error::UserWarning
-    F                                                                    [100%]
-    ================================= FAILURES =================================
-    _________________________________ test_one _________________________________
-
-        def test_one():
-    >       assert api_v1() == 1
-
-    test_show_warnings.py:10:
-    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
-
-        def api_v1():
-    >       warnings.warn(UserWarning("api v1, should use functions from v2"))
-    E       UserWarning: api v1, should use functions from v2
-
-    test_show_warnings.py:5: UserWarning
-    ========================= short test summary info ==========================
-    FAILED test_show_warnings.py::test_one - UserWarning: api v1, should use ...
-    1 failed in 0.12s
-
-The same option can be set in the ``pytest.ini`` or ``pyproject.toml`` file using the
-``filterwarnings`` ini option. For example, the configuration below will ignore all
-user warnings and specific deprecation warnings matching a regex, but will transform
-all other warnings into errors.
-
-.. code-block:: ini
-
-    # pytest.ini
-    [pytest]
-    filterwarnings =
-        error
-        ignore::UserWarning
-        ignore:function ham\(\) is deprecated:DeprecationWarning
-
-.. code-block:: toml
-
-    # pyproject.toml
-    [tool.pytest.ini_options]
-    filterwarnings = [
-        "error",
-        "ignore::UserWarning",
-        # note the use of single quote below to denote "raw" strings in TOML
-        'ignore:function ham\(\) is deprecated:DeprecationWarning',
-    ]
-
-
-When a warning matches more than one option in the list, the action for the last matching option
-is performed.
-
-Both ``-W`` command-line option and ``filterwarnings`` ini option are based on Python's own
-`-W option`_ and `warnings.simplefilter`_, so please refer to those sections in the Python
-documentation for other examples and advanced usage.
-
-.. _`filterwarnings`:
-
-``@pytest.mark.filterwarnings``
--------------------------------
-
-
-
-You can use the ``@pytest.mark.filterwarnings`` to add warning filters to specific test items,
-allowing you to have finer control of which warnings should be captured at test, class or
-even module level:
-
-.. code-block:: python
-
-    import warnings
-
-
-    def api_v1():
-        warnings.warn(UserWarning("api v1, should use functions from v2"))
-        return 1
-
-
-    @pytest.mark.filterwarnings("ignore:api v1")
-    def test_one():
-        assert api_v1() == 1
-
-
-Filters applied using a mark take precedence over filters passed on the command line or configured
-by the ``filterwarnings`` ini option.
-
-You may apply a filter to all tests of a class by using the ``filterwarnings`` mark as a class
-decorator or to all tests in a module by setting the :globalvar:`pytestmark` variable:
-
-.. code-block:: python
-
-    # turns all warnings into errors for this module
-    pytestmark = pytest.mark.filterwarnings("error")
-
-
-
-*Credits go to Florian Schulze for the reference implementation in the* `pytest-warnings`_
-*plugin.*
-
-.. _`-W option`: https://docs.python.org/3/using/cmdline.html#cmdoption-w
-.. _warnings.simplefilter: https://docs.python.org/3/library/warnings.html#warnings.simplefilter
-.. _`pytest-warnings`: https://github.com/fschulze/pytest-warnings
-
-Disabling warnings summary
---------------------------
-
-Although not recommended, you can use the ``--disable-warnings`` command-line option to suppress the
-warning summary entirely from the test run output.
-
-Disabling warning capture entirely
-----------------------------------
-
-This plugin is enabled by default but can be disabled entirely in your ``pytest.ini`` file with:
-
-    .. code-block:: ini
-
-        [pytest]
-        addopts = -p no:warnings
-
-Or passing ``-p no:warnings`` in the command-line. This might be useful if your test suites handles warnings
-using an external system.
-
-
-.. _`deprecation-warnings`:
-
-DeprecationWarning and PendingDeprecationWarning
-------------------------------------------------
-
-
-
-
-By default pytest will display ``DeprecationWarning`` and ``PendingDeprecationWarning`` warnings from
-user code and third-party libraries, as recommended by `PEP-0565 <https://www.python.org/dev/peps/pep-0565>`_.
-This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed.
-
-Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over
-(such as third-party libraries), in which case you might use the warning filters options (ini or marks) to ignore
-those warnings.
-
-For example:
-
-.. code-block:: ini
-
-    [pytest]
-    filterwarnings =
-        ignore:.*U.*mode is deprecated:DeprecationWarning
-
-
-This will ignore all warnings of type ``DeprecationWarning`` where the start of the message matches
-the regular expression ``".*U.*mode is deprecated"``.
-
-.. note::
-
-    If warnings are configured at the interpreter level, using
-    the `PYTHONWARNINGS <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS>`_ environment variable or the
-    ``-W`` command-line option, pytest will not configure any filters by default.
-
-    Also pytest doesn't follow ``PEP-0506`` suggestion of resetting all warning filters because
-    it might break test suites that configure warning filters themselves
-    by calling ``warnings.simplefilter`` (see issue `#2430 <https://github.com/pytest-dev/pytest/issues/2430>`_
-    for an example of that).
-
-
-.. _`ensuring a function triggers a deprecation warning`:
-
-.. _ensuring_function_triggers:
-
-Ensuring code triggers a deprecation warning
---------------------------------------------
-
-You can also use :func:`pytest.deprecated_call` for checking
-that a certain function call triggers a ``DeprecationWarning`` or
-``PendingDeprecationWarning``:
-
-.. code-block:: python
-
-    import pytest
-
-
-    def test_myfunction_deprecated():
-        with pytest.deprecated_call():
-            myfunction(17)
-
-This test will fail if ``myfunction`` does not issue a deprecation warning
-when called with a ``17`` argument.
-
-By default, ``DeprecationWarning`` and ``PendingDeprecationWarning`` will not be
-caught when using :func:`pytest.warns` or :ref:`recwarn <recwarn>` because
-the default Python warnings filters hide
-them. If you wish to record them in your own code, use
-``warnings.simplefilter('always')``:
-
-.. code-block:: python
-
-    import warnings
-    import pytest
-
-
-    def test_deprecation(recwarn):
-        warnings.simplefilter("always")
-        myfunction(17)
-        assert len(recwarn) == 1
-        assert recwarn.pop(DeprecationWarning)
-
-
-The :ref:`recwarn <recwarn>` fixture automatically ensures to reset the warnings
-filter at the end of the test, so no global state is leaked.
-
-.. _`asserting warnings`:
-
-.. _assertwarnings:
-
-.. _`asserting warnings with the warns function`:
-
-.. _warns:
-
-Asserting warnings with the warns function
-------------------------------------------
-
-
-
-You can check that code raises a particular warning using func:`pytest.warns`,
-which works in a similar manner to :ref:`raises <assertraises>`:
-
-.. code-block:: python
-
-    import warnings
-    import pytest
-
-
-    def test_warning():
-        with pytest.warns(UserWarning):
-            warnings.warn("my warning", UserWarning)
-
-The test will fail if the warning in question is not raised. The keyword
-argument ``match`` to assert that the exception matches a text or regex::
-
-    >>> with warns(UserWarning, match='must be 0 or None'):
-    ...     warnings.warn("value must be 0 or None", UserWarning)
-
-    >>> with warns(UserWarning, match=r'must be \d+$'):
-    ...     warnings.warn("value must be 42", UserWarning)
-
-    >>> with warns(UserWarning, match=r'must be \d+$'):
-    ...     warnings.warn("this is not here", UserWarning)
-    Traceback (most recent call last):
-      ...
-    Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted...
-
-You can also call func:`pytest.warns` on a function or code string:
-
-.. code-block:: python
-
-    pytest.warns(expected_warning, func, *args, **kwargs)
-    pytest.warns(expected_warning, "func(*args, **kwargs)")
-
-The function also returns a list of all raised warnings (as
-``warnings.WarningMessage`` objects), which you can query for
-additional information:
-
-.. code-block:: python
-
-    with pytest.warns(RuntimeWarning) as record:
-        warnings.warn("another warning", RuntimeWarning)
-
-    # check that only one warning was raised
-    assert len(record) == 1
-    # check that the message matches
-    assert record[0].message.args[0] == "another warning"
-
-Alternatively, you can examine raised warnings in detail using the
-:ref:`recwarn <recwarn>` fixture (see below).
-
-.. note::
-    ``DeprecationWarning`` and ``PendingDeprecationWarning`` are treated
-    differently; see :ref:`ensuring_function_triggers`.
-
-.. _`recording warnings`:
-
-.. _recwarn:
-
-Recording warnings
-------------------
-
-You can record raised warnings either using func:`pytest.warns` or with
-the ``recwarn`` fixture.
-
-To record with func:`pytest.warns` without asserting anything about the warnings,
-pass ``None`` as the expected warning type:
-
-.. code-block:: python
-
-    with pytest.warns(None) as record:
-        warnings.warn("user", UserWarning)
-        warnings.warn("runtime", RuntimeWarning)
-
-    assert len(record) == 2
-    assert str(record[0].message) == "user"
-    assert str(record[1].message) == "runtime"
-
-The ``recwarn`` fixture will record warnings for the whole function:
-
-.. code-block:: python
-
-    import warnings
-
-
-    def test_hello(recwarn):
-        warnings.warn("hello", UserWarning)
-        assert len(recwarn) == 1
-        w = recwarn.pop(UserWarning)
-        assert issubclass(w.category, UserWarning)
-        assert str(w.message) == "hello"
-        assert w.filename
-        assert w.lineno
-
-Both ``recwarn`` and func:`pytest.warns` return the same interface for recorded
-warnings: a WarningsRecorder instance. To view the recorded warnings, you can
-iterate over this instance, call ``len`` on it to get the number of recorded
-warnings, or index into it to get a particular recorded warning.
-
-.. currentmodule:: _pytest.warnings
-
-Full API: :class:`~_pytest.recwarn.WarningsRecorder`.
-
-.. _custom_failure_messages:
-
-Custom failure messages
------------------------
-
-Recording warnings provides an opportunity to produce custom test
-failure messages for when no warnings are issued or other conditions
-are met.
-
-.. code-block:: python
-
-    def test():
-        with pytest.warns(Warning) as record:
-            f()
-            if not record:
-                pytest.fail("Expected a warning!")
-
-If no warnings are issued when calling ``f``, then ``not record`` will
-evaluate to ``True``.  You can then call :func:`pytest.fail` with a
-custom error message.
-
-.. _internal-warnings:
-
-Internal pytest warnings
-------------------------
-
-pytest may generate its own warnings in some situations, such as improper usage or deprecated features.
-
-For example, pytest will emit a warning if it encounters a class that matches :confval:`python_classes` but also
-defines an ``__init__`` constructor, as this prevents the class from being instantiated:
-
-.. code-block:: python
-
-    # content of test_pytest_warnings.py
-    class Test:
-        def __init__(self):
-            pass
-
-        def test_foo(self):
-            assert 1 == 1
-
-.. code-block:: pytest
-
-    $ pytest test_pytest_warnings.py -q
-
-    ============================= warnings summary =============================
-    test_pytest_warnings.py:1
-      $REGENDOC_TMPDIR/test_pytest_warnings.py:1: PytestCollectionWarning: cannot collect test class 'Test' because it has a __init__ constructor (from: test_pytest_warnings.py)
-        class Test:
-
-    -- Docs: https://docs.pytest.org/en/stable/warnings.html
-    1 warning in 0.12s
-
-These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings.
-
-Please read our :ref:`backwards-compatibility` to learn how we proceed about deprecating and eventually removing
-features.
-
-The full list of warnings is listed in :ref:`the reference documentation <warnings ref>`.
diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst
deleted file mode 100644 (file)
index 908366d..0000000
+++ /dev/null
@@ -1,774 +0,0 @@
-.. _plugins:
-.. _`writing-plugins`:
-
-Writing plugins
-===============
-
-It is easy to implement `local conftest plugins`_ for your own project
-or `pip-installable plugins`_ that can be used throughout many projects,
-including third party projects.  Please refer to :ref:`using plugins` if you
-only want to use but not write plugins.
-
-A plugin contains one or multiple hook functions. :ref:`Writing hooks <writinghooks>`
-explains the basics and details of how you can write a hook function yourself.
-``pytest`` implements all aspects of configuration, collection, running and
-reporting by calling :ref:`well specified hooks <hook-reference>` of the following plugins:
-
-* builtin plugins: loaded from pytest's internal ``_pytest`` directory.
-
-* :ref:`external plugins <extplugins>`: modules discovered through
-  `setuptools entry points`_
-
-* `conftest.py plugins`_: modules auto-discovered in test directories
-
-In principle, each hook call is a ``1:N`` Python function call where ``N`` is the
-number of registered implementation functions for a given specification.
-All specifications and implementations follow the ``pytest_`` prefix
-naming convention, making them easy to distinguish and find.
-
-.. _`pluginorder`:
-
-Plugin discovery order at tool startup
---------------------------------------
-
-``pytest`` loads plugin modules at tool startup in the following way:
-
-1. by scanning the command line for the ``-p no:name`` option
-   and *blocking* that plugin from being loaded (even builtin plugins can
-   be blocked this way). This happens before normal command-line parsing.
-
-2. by loading all builtin plugins.
-
-3. by scanning the command line for the ``-p name`` option
-   and loading the specified plugin. This happens before normal command-line parsing.
-
-4. by loading all plugins registered through `setuptools entry points`_.
-
-5. by loading all plugins specified through the :envvar:`PYTEST_PLUGINS` environment variable.
-
-6. by loading all :file:`conftest.py` files as inferred by the command line
-   invocation:
-
-   - if no test paths are specified, use the current dir as a test path
-   - if exists, load ``conftest.py`` and ``test*/conftest.py`` relative
-     to the directory part of the first test path. After the ``conftest.py``
-     file is loaded, load all plugins specified in its
-     :globalvar:`pytest_plugins` variable if present.
-
-   Note that pytest does not find ``conftest.py`` files in deeper nested
-   sub directories at tool startup.  It is usually a good idea to keep
-   your ``conftest.py`` file in the top level test or project root directory.
-
-7. by recursively loading all plugins specified by the
-   :globalvar:`pytest_plugins` variable in ``conftest.py`` files.
-
-
-.. _`pytest/plugin`: http://bitbucket.org/pytest-dev/pytest/src/tip/pytest/plugin/
-.. _`conftest.py plugins`:
-.. _`localplugin`:
-.. _`local conftest plugins`:
-
-conftest.py: local per-directory plugins
-----------------------------------------
-
-Local ``conftest.py`` plugins contain directory-specific hook
-implementations.  Hook Session and test running activities will
-invoke all hooks defined in ``conftest.py`` files closer to the
-root of the filesystem.  Example of implementing the
-``pytest_runtest_setup`` hook so that is called for tests in the ``a``
-sub directory but not for other directories::
-
-    a/conftest.py:
-        def pytest_runtest_setup(item):
-            # called for running each test in 'a' directory
-            print("setting up", item)
-
-    a/test_sub.py:
-        def test_sub():
-            pass
-
-    test_flat.py:
-        def test_flat():
-            pass
-
-Here is how you might run it::
-
-     pytest test_flat.py --capture=no  # will not show "setting up"
-     pytest a/test_sub.py --capture=no  # will show "setting up"
-
-.. note::
-    If you have ``conftest.py`` files which do not reside in a
-    python package directory (i.e. one containing an ``__init__.py``) then
-    "import conftest" can be ambiguous because there might be other
-    ``conftest.py`` files as well on your ``PYTHONPATH`` or ``sys.path``.
-    It is thus good practice for projects to either put ``conftest.py``
-    under a package scope or to never import anything from a
-    ``conftest.py`` file.
-
-    See also: :ref:`pythonpath`.
-
-.. note::
-    Some hooks should be implemented only in plugins or conftest.py files situated at the
-    tests root directory due to how pytest discovers plugins during startup,
-    see the documentation of each hook for details.
-
-Writing your own plugin
------------------------
-
-.. _`setuptools`: https://pypi.org/project/setuptools/
-
-If you want to write a plugin, there are many real-life examples
-you can copy from:
-
-* a custom collection example plugin: :ref:`yaml plugin`
-* builtin plugins which provide pytest's own functionality
-* many `external plugins <http://plugincompat.herokuapp.com>`_ providing additional features
-
-All of these plugins implement :ref:`hooks <hook-reference>` and/or :ref:`fixtures <fixture>`
-to extend and add functionality.
-
-.. note::
-    Make sure to check out the excellent
-    `cookiecutter-pytest-plugin <https://github.com/pytest-dev/cookiecutter-pytest-plugin>`_
-    project, which is a `cookiecutter template <https://github.com/audreyr/cookiecutter>`_
-    for authoring plugins.
-
-    The template provides an excellent starting point with a working plugin,
-    tests running with tox, a comprehensive README file as well as a
-    pre-configured entry-point.
-
-Also consider :ref:`contributing your plugin to pytest-dev<submitplugin>`
-once it has some happy users other than yourself.
-
-
-.. _`setuptools entry points`:
-.. _`pip-installable plugins`:
-
-Making your plugin installable by others
-----------------------------------------
-
-If you want to make your plugin externally available, you
-may define a so-called entry point for your distribution so
-that ``pytest`` finds your plugin module.  Entry points are
-a feature that is provided by `setuptools`_. pytest looks up
-the ``pytest11`` entrypoint to discover its
-plugins and you can thus make your plugin available by defining
-it in your setuptools-invocation:
-
-.. sourcecode:: python
-
-    # sample ./setup.py file
-    from setuptools import setup
-
-    setup(
-        name="myproject",
-        packages=["myproject"],
-        # the following makes a plugin available to pytest
-        entry_points={"pytest11": ["name_of_plugin = myproject.pluginmodule"]},
-        # custom PyPI classifier for pytest plugins
-        classifiers=["Framework :: Pytest"],
-    )
-
-If a package is installed this way, ``pytest`` will load
-``myproject.pluginmodule`` as a plugin which can define
-:ref:`hooks <hook-reference>`.
-
-.. note::
-
-    Make sure to include ``Framework :: Pytest`` in your list of
-    `PyPI classifiers <https://pypi.org/classifiers/>`_
-    to make it easy for users to find your plugin.
-
-
-.. _assertion-rewriting:
-
-Assertion Rewriting
--------------------
-
-One of the main features of ``pytest`` is the use of plain assert
-statements and the detailed introspection of expressions upon
-assertion failures.  This is provided by "assertion rewriting" which
-modifies the parsed AST before it gets compiled to bytecode.  This is
-done via a :pep:`302` import hook which gets installed early on when
-``pytest`` starts up and will perform this rewriting when modules get
-imported.  However, since we do not want to test different bytecode
-from what you will run in production, this hook only rewrites test modules
-themselves (as defined by the :confval:`python_files` configuration option),
-and any modules which are part of plugins.
-Any other imported module will not be rewritten and normal assertion behaviour
-will happen.
-
-If you have assertion helpers in other modules where you would need
-assertion rewriting to be enabled you need to ask ``pytest``
-explicitly to rewrite this module before it gets imported.
-
-.. autofunction:: pytest.register_assert_rewrite
-    :noindex:
-
-This is especially important when you write a pytest plugin which is
-created using a package.  The import hook only treats ``conftest.py``
-files and any modules which are listed in the ``pytest11`` entrypoint
-as plugins.  As an example consider the following package::
-
-   pytest_foo/__init__.py
-   pytest_foo/plugin.py
-   pytest_foo/helper.py
-
-With the following typical ``setup.py`` extract:
-
-.. code-block:: python
-
-   setup(..., entry_points={"pytest11": ["foo = pytest_foo.plugin"]}, ...)
-
-In this case only ``pytest_foo/plugin.py`` will be rewritten.  If the
-helper module also contains assert statements which need to be
-rewritten it needs to be marked as such, before it gets imported.
-This is easiest by marking it for rewriting inside the
-``__init__.py`` module, which will always be imported first when a
-module inside a package is imported.  This way ``plugin.py`` can still
-import ``helper.py`` normally.  The contents of
-``pytest_foo/__init__.py`` will then need to look like this:
-
-.. code-block:: python
-
-   import pytest
-
-   pytest.register_assert_rewrite("pytest_foo.helper")
-
-
-Requiring/Loading plugins in a test module or conftest file
------------------------------------------------------------
-
-You can require plugins in a test module or a ``conftest.py`` file using :globalvar:`pytest_plugins`:
-
-.. code-block:: python
-
-    pytest_plugins = ["name1", "name2"]
-
-When the test module or conftest plugin is loaded the specified plugins
-will be loaded as well. Any module can be blessed as a plugin, including internal
-application modules:
-
-.. code-block:: python
-
-    pytest_plugins = "myapp.testsupport.myplugin"
-
-:globalvar:`pytest_plugins` are processed recursively, so note that in the example above
-if ``myapp.testsupport.myplugin`` also declares :globalvar:`pytest_plugins`, the contents
-of the variable will also be loaded as plugins, and so on.
-
-.. _`requiring plugins in non-root conftests`:
-
-.. note::
-    Requiring plugins using :globalvar:`pytest_plugins` variable in non-root
-    ``conftest.py`` files is deprecated.
-
-    This is important because ``conftest.py`` files implement per-directory
-    hook implementations, but once a plugin is imported, it will affect the
-    entire directory tree. In order to avoid confusion, defining
-    :globalvar:`pytest_plugins` in any ``conftest.py`` file which is not located in the
-    tests root directory is deprecated, and will raise a warning.
-
-This mechanism makes it easy to share fixtures within applications or even
-external applications without the need to create external plugins using
-the ``setuptools``'s entry point technique.
-
-Plugins imported by :globalvar:`pytest_plugins` will also automatically be marked
-for assertion rewriting (see :func:`pytest.register_assert_rewrite`).
-However for this to have any effect the module must not be
-imported already; if it was already imported at the time the
-:globalvar:`pytest_plugins` statement is processed, a warning will result and
-assertions inside the plugin will not be rewritten.  To fix this you
-can either call :func:`pytest.register_assert_rewrite` yourself before
-the module is imported, or you can arrange the code to delay the
-importing until after the plugin is registered.
-
-
-Accessing another plugin by name
---------------------------------
-
-If a plugin wants to collaborate with code from
-another plugin it can obtain a reference through
-the plugin manager like this:
-
-.. sourcecode:: python
-
-    plugin = config.pluginmanager.get_plugin("name_of_plugin")
-
-If you want to look at the names of existing plugins, use
-the ``--trace-config`` option.
-
-
-.. _registering-markers:
-
-Registering custom markers
---------------------------
-
-If your plugin uses any markers, you should register them so that they appear in
-pytest's help text and do not :ref:`cause spurious warnings <unknown-marks>`.
-For example, the following plugin would register ``cool_marker`` and
-``mark_with`` for all users:
-
-.. code-block:: python
-
-    def pytest_configure(config):
-        config.addinivalue_line("markers", "cool_marker: this one is for cool tests.")
-        config.addinivalue_line(
-            "markers", "mark_with(arg, arg2): this marker takes arguments."
-        )
-
-
-Testing plugins
----------------
-
-pytest comes with a plugin named ``pytester`` that helps you write tests for
-your plugin code. The plugin is disabled by default, so you will have to enable
-it before you can use it.
-
-You can do so by adding the following line to a ``conftest.py`` file in your
-testing directory:
-
-.. code-block:: python
-
-    # content of conftest.py
-
-    pytest_plugins = ["pytester"]
-
-Alternatively you can invoke pytest with the ``-p pytester`` command line
-option.
-
-This will allow you to use the :py:class:`testdir <_pytest.pytester.Testdir>`
-fixture for testing your plugin code.
-
-Let's demonstrate what you can do with the plugin with an example. Imagine we
-developed a plugin that provides a fixture ``hello`` which yields a function
-and we can invoke this function with one optional parameter. It will return a
-string value of ``Hello World!`` if we do not supply a value or ``Hello
-{value}!`` if we do supply a string value.
-
-.. code-block:: python
-
-    import pytest
-
-
-    def pytest_addoption(parser):
-        group = parser.getgroup("helloworld")
-        group.addoption(
-            "--name",
-            action="store",
-            dest="name",
-            default="World",
-            help='Default "name" for hello().',
-        )
-
-
-    @pytest.fixture
-    def hello(request):
-        name = request.config.getoption("name")
-
-        def _hello(name=None):
-            if not name:
-                name = request.config.getoption("name")
-            return "Hello {name}!".format(name=name)
-
-        return _hello
-
-
-Now the ``testdir`` fixture provides a convenient API for creating temporary
-``conftest.py`` files and test files. It also allows us to run the tests and
-return a result object, with which we can assert the tests' outcomes.
-
-.. code-block:: python
-
-    def test_hello(testdir):
-        """Make sure that our plugin works."""
-
-        # create a temporary conftest.py file
-        testdir.makeconftest(
-            """
-            import pytest
-
-            @pytest.fixture(params=[
-                "Brianna",
-                "Andreas",
-                "Floris",
-            ])
-            def name(request):
-                return request.param
-        """
-        )
-
-        # create a temporary pytest test file
-        testdir.makepyfile(
-            """
-            def test_hello_default(hello):
-                assert hello() == "Hello World!"
-
-            def test_hello_name(hello, name):
-                assert hello(name) == "Hello {0}!".format(name)
-        """
-        )
-
-        # run all tests with pytest
-        result = testdir.runpytest()
-
-        # check that all 4 tests passed
-        result.assert_outcomes(passed=4)
-
-
-Additionally it is possible to copy examples for an example folder before running pytest on it.
-
-.. code-block:: ini
-
-  # content of pytest.ini
-  [pytest]
-  pytester_example_dir = .
-
-
-.. code-block:: python
-
-    # content of test_example.py
-
-
-    def test_plugin(testdir):
-        testdir.copy_example("test_example.py")
-        testdir.runpytest("-k", "test_example")
-
-
-    def test_example():
-        pass
-
-.. code-block:: pytest
-
-    $ pytest
-    =========================== test session starts ============================
-    platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
-    cachedir: $PYTHON_PREFIX/.pytest_cache
-    rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
-    collected 2 items
-
-    test_example.py ..                                                   [100%]
-
-    ============================ 2 passed in 0.12s =============================
-
-For more information about the result object that ``runpytest()`` returns, and
-the methods that it provides please check out the :py:class:`RunResult
-<_pytest.pytester.RunResult>` documentation.
-
-
-
-
-.. _`writinghooks`:
-
-Writing hook functions
-======================
-
-
-.. _validation:
-
-hook function validation and execution
---------------------------------------
-
-pytest calls hook functions from registered plugins for any
-given hook specification.  Let's look at a typical hook function
-for the ``pytest_collection_modifyitems(session, config,
-items)`` hook which pytest calls after collection of all test items is
-completed.
-
-When we implement a ``pytest_collection_modifyitems`` function in our plugin
-pytest will during registration verify that you use argument
-names which match the specification and bail out if not.
-
-Let's look at a possible implementation:
-
-.. code-block:: python
-
-    def pytest_collection_modifyitems(config, items):
-        # called after collection is completed
-        # you can modify the ``items`` list
-        ...
-
-Here, ``pytest`` will pass in ``config`` (the pytest config object)
-and ``items`` (the list of collected test items) but will not pass
-in the ``session`` argument because we didn't list it in the function
-signature.  This dynamic "pruning" of arguments allows ``pytest`` to
-be "future-compatible": we can introduce new hook named parameters without
-breaking the signatures of existing hook implementations.  It is one of
-the reasons for the general long-lived compatibility of pytest plugins.
-
-Note that hook functions other than ``pytest_runtest_*`` are not
-allowed to raise exceptions.  Doing so will break the pytest run.
-
-
-
-.. _firstresult:
-
-firstresult: stop at first non-None result
--------------------------------------------
-
-Most calls to ``pytest`` hooks result in a **list of results** which contains
-all non-None results of the called hook functions.
-
-Some hook specifications use the ``firstresult=True`` option so that the hook
-call only executes until the first of N registered functions returns a
-non-None result which is then taken as result of the overall hook call.
-The remaining hook functions will not be called in this case.
-
-.. _`hookwrapper`:
-
-hookwrapper: executing around other hooks
--------------------------------------------------
-
-.. currentmodule:: _pytest.core
-
-
-
-pytest plugins can implement hook wrappers which wrap the execution
-of other hook implementations.  A hook wrapper is a generator function
-which yields exactly once. When pytest invokes hooks it first executes
-hook wrappers and passes the same arguments as to the regular hooks.
-
-At the yield point of the hook wrapper pytest will execute the next hook
-implementations and return their result to the yield point in the form of
-a :py:class:`Result <pluggy._Result>` instance which encapsulates a result or
-exception info.  The yield point itself will thus typically not raise
-exceptions (unless there are bugs).
-
-Here is an example definition of a hook wrapper:
-
-.. code-block:: python
-
-    import pytest
-
-
-    @pytest.hookimpl(hookwrapper=True)
-    def pytest_pyfunc_call(pyfuncitem):
-        do_something_before_next_hook_executes()
-
-        outcome = yield
-        # outcome.excinfo may be None or a (cls, val, tb) tuple
-
-        res = outcome.get_result()  # will raise if outcome was exception
-
-        post_process_result(res)
-
-        outcome.force_result(new_res)  # to override the return value to the plugin system
-
-Note that hook wrappers don't return results themselves, they merely
-perform tracing or other side effects around the actual hook implementations.
-If the result of the underlying hook is a mutable object, they may modify
-that result but it's probably better to avoid it.
-
-For more information, consult the
-:ref:`pluggy documentation about hookwrappers <pluggy:hookwrappers>`.
-
-.. _plugin-hookorder:
-
-Hook function ordering / call example
--------------------------------------
-
-For any given hook specification there may be more than one
-implementation and we thus generally view ``hook`` execution as a
-``1:N`` function call where ``N`` is the number of registered functions.
-There are ways to influence if a hook implementation comes before or
-after others, i.e.  the position in the ``N``-sized list of functions:
-
-.. code-block:: python
-
-    # Plugin 1
-    @pytest.hookimpl(tryfirst=True)
-    def pytest_collection_modifyitems(items):
-        # will execute as early as possible
-        ...
-
-
-    # Plugin 2
-    @pytest.hookimpl(trylast=True)
-    def pytest_collection_modifyitems(items):
-        # will execute as late as possible
-        ...
-
-
-    # Plugin 3
-    @pytest.hookimpl(hookwrapper=True)
-    def pytest_collection_modifyitems(items):
-        # will execute even before the tryfirst one above!
-        outcome = yield
-        # will execute after all non-hookwrappers executed
-
-Here is the order of execution:
-
-1. Plugin3's pytest_collection_modifyitems called until the yield point
-   because it is a hook wrapper.
-
-2. Plugin1's pytest_collection_modifyitems is called because it is marked
-   with ``tryfirst=True``.
-
-3. Plugin2's pytest_collection_modifyitems is called because it is marked
-   with ``trylast=True`` (but even without this mark it would come after
-   Plugin1).
-
-4. Plugin3's pytest_collection_modifyitems then executing the code after the yield
-   point.  The yield receives a :py:class:`Result <pluggy._Result>` instance which encapsulates
-   the result from calling the non-wrappers.  Wrappers shall not modify the result.
-
-It's possible to use ``tryfirst`` and ``trylast`` also in conjunction with
-``hookwrapper=True`` in which case it will influence the ordering of hookwrappers
-among each other.
-
-
-Declaring new hooks
-------------------------
-
-.. note::
-
-    This is a quick overview on how to add new hooks and how they work in general, but a more complete
-    overview can be found in `the pluggy documentation <https://pluggy.readthedocs.io/en/latest/>`__.
-
-.. currentmodule:: _pytest.hookspec
-
-Plugins and ``conftest.py`` files may declare new hooks that can then be
-implemented by other plugins in order to alter behaviour or interact with
-the new plugin:
-
-.. autofunction:: pytest_addhooks
-    :noindex:
-
-Hooks are usually declared as do-nothing functions that contain only
-documentation describing when the hook will be called and what return values
-are expected. The names of the functions must start with `pytest_` otherwise pytest won't recognize them.
-
-Here's an example. Let's assume this code is in the ``sample_hook.py`` module.
-
-.. code-block:: python
-
-    def pytest_my_hook(config):
-        """
-        Receives the pytest config and does things with it
-        """
-
-To register the hooks with pytest they need to be structured in their own module or class. This
-class or module can then be passed to the ``pluginmanager`` using the ``pytest_addhooks`` function
-(which itself is a hook exposed by pytest).
-
-.. code-block:: python
-
-    def pytest_addhooks(pluginmanager):
-        """ This example assumes the hooks are grouped in the 'sample_hook' module. """
-        from my_app.tests import sample_hook
-
-        pluginmanager.add_hookspecs(sample_hook)
-
-For a real world example, see `newhooks.py`_ from `xdist <https://github.com/pytest-dev/pytest-xdist>`_.
-
-.. _`newhooks.py`: https://github.com/pytest-dev/pytest-xdist/blob/974bd566c599dc6a9ea291838c6f226197208b46/xdist/newhooks.py
-
-Hooks may be called both from fixtures or from other hooks. In both cases, hooks are called
-through the ``hook`` object, available in the ``config`` object. Most hooks receive a
-``config`` object directly, while fixtures may use the ``pytestconfig`` fixture which provides the same object.
-
-.. code-block:: python
-
-    @pytest.fixture()
-    def my_fixture(pytestconfig):
-        # call the hook called "pytest_my_hook"
-        # 'result' will be a list of return values from all registered functions.
-        result = pytestconfig.hook.pytest_my_hook(config=pytestconfig)
-
-.. note::
-    Hooks receive parameters using only keyword arguments.
-
-Now your hook is ready to be used. To register a function at the hook, other plugins or users must
-now simply define the function ``pytest_my_hook`` with the correct signature in their ``conftest.py``.
-
-Example:
-
-.. code-block:: python
-
-    def pytest_my_hook(config):
-        """
-        Print all active hooks to the screen.
-        """
-        print(config.hook)
-
-
-.. _`addoptionhooks`:
-
-
-Using hooks in pytest_addoption
--------------------------------
-
-Occasionally, it is necessary to change the way in which command line options
-are defined by one plugin based on hooks in another plugin. For example,
-a plugin may expose a command line option for which another plugin needs
-to define the default value. The pluginmanager can be used to install and
-use hooks to accomplish this. The plugin would define and add the hooks
-and use pytest_addoption as follows:
-
-.. code-block:: python
-
-   # contents of hooks.py
-
-   # Use firstresult=True because we only want one plugin to define this
-   # default value
-   @hookspec(firstresult=True)
-   def pytest_config_file_default_value():
-       """ Return the default value for the config file command line option. """
-
-
-   # contents of myplugin.py
-
-
-   def pytest_addhooks(pluginmanager):
-       """ This example assumes the hooks are grouped in the 'hooks' module. """
-       from . import hook
-
-       pluginmanager.add_hookspecs(hook)
-
-
-   def pytest_addoption(parser, pluginmanager):
-       default_value = pluginmanager.hook.pytest_config_file_default_value()
-       parser.addoption(
-           "--config-file",
-           help="Config file to use, defaults to %(default)s",
-           default=default_value,
-       )
-
-The conftest.py that is using myplugin would simply define the hook as follows:
-
-.. code-block:: python
-
-    def pytest_config_file_default_value():
-        return "config.yaml"
-
-
-Optionally using hooks from 3rd party plugins
----------------------------------------------
-
-Using new hooks from plugins as explained above might be a little tricky
-because of the standard :ref:`validation mechanism <validation>`:
-if you depend on a plugin that is not installed, validation will fail and
-the error message will not make much sense to your users.
-
-One approach is to defer the hook implementation to a new plugin instead of
-declaring the hook functions directly in your plugin module, for example:
-
-.. code-block:: python
-
-    # contents of myplugin.py
-
-
-    class DeferPlugin:
-        """Simple plugin to defer pytest-xdist hook functions."""
-
-        def pytest_testnodedown(self, node, error):
-            """standard xdist hook function.
-            """
-
-
-    def pytest_configure(config):
-        if config.pluginmanager.hasplugin("xdist"):
-            config.pluginmanager.register(DeferPlugin())
-
-This has the added benefit of allowing you to conditionally install hooks
-depending on which plugins are installed.
diff --git a/doc/en/xunit_setup.rst b/doc/en/xunit_setup.rst
deleted file mode 100644 (file)
index 8b3366f..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-
-.. _`classic xunit`:
-.. _xunitsetup:
-
-classic xunit-style setup
-========================================
-
-This section describes a classic and popular way how you can implement
-fixtures (setup and teardown test state) on a per-module/class/function basis.
-
-
-.. note::
-
-    While these setup/teardown methods are simple and familiar to those
-    coming from a ``unittest`` or ``nose`` background, you may also consider
-    using pytest's more powerful :ref:`fixture mechanism
-    <fixture>` which leverages the concept of dependency injection, allowing
-    for a more modular and more scalable approach for managing test state,
-    especially for larger projects and for functional testing.  You can
-    mix both fixture mechanisms in the same file but
-    test methods of ``unittest.TestCase`` subclasses
-    cannot receive fixture arguments.
-
-
-Module level setup/teardown
---------------------------------------
-
-If you have multiple test functions and test classes in a single
-module you can optionally implement the following fixture methods
-which will usually be called once for all the functions:
-
-.. code-block:: python
-
-    def setup_module(module):
-        """ setup any state specific to the execution of the given module."""
-
-
-    def teardown_module(module):
-        """ teardown any state that was previously setup with a setup_module
-        method.
-        """
-
-As of pytest-3.0, the ``module`` parameter is optional.
-
-Class level setup/teardown
-----------------------------------
-
-Similarly, the following methods are called at class level before
-and after all test methods of the class are called:
-
-.. code-block:: python
-
-    @classmethod
-    def setup_class(cls):
-        """ setup any state specific to the execution of the given class (which
-        usually contains tests).
-        """
-
-
-    @classmethod
-    def teardown_class(cls):
-        """ teardown any state that was previously setup with a call to
-        setup_class.
-        """
-
-Method and function level setup/teardown
------------------------------------------------
-
-Similarly, the following methods are called around each method invocation:
-
-.. code-block:: python
-
-    def setup_method(self, method):
-        """ setup any state tied to the execution of the given method in a
-        class.  setup_method is invoked for every test method of a class.
-        """
-
-
-    def teardown_method(self, method):
-        """ teardown any state that was previously setup with a setup_method
-        call.
-        """
-
-As of pytest-3.0, the ``method`` parameter is optional.
-
-If you would rather define test functions directly at module level
-you can also use the following functions to implement fixtures:
-
-.. code-block:: python
-
-    def setup_function(function):
-        """ setup any state tied to the execution of the given function.
-        Invoked for every test function in the module.
-        """
-
-
-    def teardown_function(function):
-        """ teardown any state that was previously setup with a setup_function
-        call.
-        """
-
-As of pytest-3.0, the ``function`` parameter is optional.
-
-Remarks:
-
-* It is possible for setup/teardown pairs to be invoked multiple times
-  per testing process.
-
-* teardown functions are not called if the corresponding setup function existed
-  and failed/was skipped.
-
-* Prior to pytest-4.2, xunit-style functions did not obey the scope rules of fixtures, so
-  it was possible, for example, for a ``setup_method`` to be called before a
-  session-scoped autouse fixture.
-
-  Now the xunit-style functions are integrated with the fixture mechanism and obey the proper
-  scope rules of fixtures involved in the call.
-
-.. _`unittest.py module`: http://docs.python.org/library/unittest.html
diff --git a/extra/setup-py.test/setup.py b/extra/setup-py.test/setup.py
deleted file mode 100644 (file)
index d0560ce..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-import sys
-from distutils.core import setup
-
-if __name__ == "__main__":
-    if "sdist" not in sys.argv[1:]:
-        raise ValueError("please use 'pytest' pypi package instead of 'py.test'")
-    setup(
-        name="py.test",
-        version="0.0",
-        description="please use 'pytest' for installation",
-    )
index dd4be6c22d56a0c6d320ff247dcba1065d7a17b3..a4139a5c051a003c97964f590a17cc8c83f86e0e 100644 (file)
@@ -1,9 +1,8 @@
 [build-system]
 requires = [
   # sync with setup.py until we discard non-pep-517/518
-  "setuptools>=42.0",
-  "setuptools-scm[toml]>=3.4",
-  "wheel",
+  "setuptools>=45.0",
+  "setuptools-scm[toml]>=6.2.3",
 ]
 build-backend = "setuptools.build_meta"
 
@@ -26,8 +25,8 @@ filterwarnings = [
     # produced by older pyparsing<=2.2.0.
     "default:Using or importing the ABCs:DeprecationWarning:pyparsing.*",
     "default:the imp module is deprecated in favour of importlib:DeprecationWarning:nose.*",
-    # produced by python3.6/site.py itself (3.6.7 on Travis, could not trigger it with 3.6.8)."
-    "ignore:.*U.*mode is deprecated:DeprecationWarning:(?!(pytest|_pytest))",
+    # distutils is deprecated in 3.10, scheduled for removal in 3.12
+    "ignore:The distutils package is deprecated:DeprecationWarning",
     # produced by pytest-xdist
     "ignore:.*type argument to addoption.*:DeprecationWarning",
     # produced on execnet (pytest-xdist)
@@ -38,8 +37,19 @@ filterwarnings = [
     # Those are caught/handled by pyupgrade, and not easy to filter with the
     # module being the filename (with .py removed).
     "default:invalid escape sequence:DeprecationWarning",
+    # ignore not yet fixed warnings for hook markers
+    "default:.*not marked using pytest.hook.*",
+    "ignore:.*not marked using pytest.hook.*::xdist.*",
     # ignore use of unregistered marks, because we use many to test the implementation
     "ignore::_pytest.warning_types.PytestUnknownMarkWarning",
+    # https://github.com/benjaminp/six/issues/341
+    "ignore:_SixMetaPathImporter\\.exec_module\\(\\) not found; falling back to load_module\\(\\):ImportWarning",
+    # https://github.com/benjaminp/six/pull/352
+    "ignore:_SixMetaPathImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning",
+    # https://github.com/pypa/setuptools/pull/2517
+    "ignore:VendorImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning",
+    # https://github.com/pytest-dev/execnet/pull/127
+    "ignore:isSet\\(\\) is deprecated, use is_set\\(\\) instead:DeprecationWarning",
 ]
 pytester_example_dir = "testing/example_scripts"
 markers = [
@@ -103,4 +113,9 @@ template = "changelog/_template.rst"
   showcontent = true
 
 [tool.black]
-target-version = ['py36']
+target-version = ['py37']
+
+# check-wheel-contents is executed by the build-and-inspect-python-package action.
+[tool.check-wheel-contents]
+# W009: Wheel contains multiple toplevel library entries
+ignore = "W009"
diff --git a/scripts/append_codecov_token.py b/scripts/append_codecov_token.py
deleted file mode 100644 (file)
index 8eecb0f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-"""
-Appends the codecov token to the 'codecov.yml' file at the root of the repository.
-
-This is done by CI during PRs and builds on the pytest-dev repository so we can upload coverage, at least
-until codecov grows some native integration like it has with Travis and AppVeyor.
-
-See discussion in https://github.com/pytest-dev/pytest/pull/6441 for more information.
-"""
-import os.path
-from textwrap import dedent
-
-
-def main():
-    this_dir = os.path.dirname(__file__)
-    cov_file = os.path.join(this_dir, "..", "codecov.yml")
-
-    assert os.path.isfile(cov_file), "{cov_file} does not exist".format(
-        cov_file=cov_file
-    )
-
-    with open(cov_file, "a") as f:
-        # token from: https://codecov.io/gh/pytest-dev/pytest/settings
-        # use same URL to regenerate it if needed
-        text = dedent(
-            """
-            codecov:
-              token: "1eca3b1f-31a2-4fb8-a8c3-138b441b50a7"
-        """
-        )
-        f.write(text)
-
-    print("Token updated:", cov_file)
-
-
-if __name__ == "__main__":
-    main()
diff --git a/scripts/prepare-release-pr.py b/scripts/prepare-release-pr.py
new file mode 100644 (file)
index 0000000..a0e5e4d
--- /dev/null
@@ -0,0 +1,180 @@
+"""
+This script is part of the pytest release process which is triggered manually in the Actions
+tab of the repository.
+
+The user will need to enter the base branch to start the release from (for example
+``6.1.x`` or ``main``) and if it should be a major release.
+
+The appropriate version will be obtained based on the given branch automatically.
+
+After that, it will create a release using the `release` tox environment, and push a new PR.
+
+**Token**: currently the token from the GitHub Actions is used, pushed with
+`pytest bot <pytestbot@gmail.com>` commit author.
+"""
+import argparse
+import re
+from pathlib import Path
+from subprocess import check_call
+from subprocess import check_output
+from subprocess import run
+
+from colorama import Fore
+from colorama import init
+from github3.repos import Repository
+
+
+class InvalidFeatureRelease(Exception):
+    pass
+
+
+SLUG = "pytest-dev/pytest"
+
+PR_BODY = """\
+Created by the [prepare release pr](https://github.com/pytest-dev/pytest/actions/workflows/prepare-release-pr.yml)
+workflow.
+
+Once all builds pass and it has been **approved** by one or more maintainers,
+start the [deploy](https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml) workflow, using these parameters:
+
+* `Use workflow from`: `release-{version}`.
+* `Release version`: `{version}`.
+
+After the `deploy` workflow has been approved by a core maintainer, the package will be uploaded to PyPI automatically.
+"""
+
+
+def login(token: str) -> Repository:
+    import github3
+
+    github = github3.login(token=token)
+    owner, repo = SLUG.split("/")
+    return github.repository(owner, repo)
+
+
+def prepare_release_pr(
+    base_branch: str, is_major: bool, token: str, prerelease: str
+) -> None:
+    print()
+    print(f"Processing release for branch {Fore.CYAN}{base_branch}")
+
+    check_call(["git", "checkout", f"origin/{base_branch}"])
+
+    changelog = Path("changelog")
+
+    features = list(changelog.glob("*.feature.rst"))
+    breaking = list(changelog.glob("*.breaking.rst"))
+    is_feature_release = bool(features or breaking)
+
+    try:
+        version = find_next_version(
+            base_branch, is_major, is_feature_release, prerelease
+        )
+    except InvalidFeatureRelease as e:
+        print(f"{Fore.RED}{e}")
+        raise SystemExit(1)
+
+    print(f"Version: {Fore.CYAN}{version}")
+
+    release_branch = f"release-{version}"
+
+    run(
+        ["git", "config", "user.name", "pytest bot"],
+        check=True,
+    )
+    run(
+        ["git", "config", "user.email", "pytestbot@gmail.com"],
+        check=True,
+    )
+
+    run(
+        ["git", "checkout", "-b", release_branch, f"origin/{base_branch}"],
+        check=True,
+    )
+
+    print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} created.")
+
+    if is_major:
+        template_name = "release.major.rst"
+    elif prerelease:
+        template_name = "release.pre.rst"
+    elif is_feature_release:
+        template_name = "release.minor.rst"
+    else:
+        template_name = "release.patch.rst"
+
+    # important to use tox here because we have changed branches, so dependencies
+    # might have changed as well
+    cmdline = [
+        "tox",
+        "-e",
+        "release",
+        "--",
+        version,
+        template_name,
+        release_branch,  # doc_version
+        "--skip-check-links",
+    ]
+    print("Running", " ".join(cmdline))
+    run(
+        cmdline,
+        check=True,
+    )
+
+    oauth_url = f"https://{token}:x-oauth-basic@github.com/{SLUG}.git"
+    run(
+        ["git", "push", oauth_url, f"HEAD:{release_branch}", "--force"],
+        check=True,
+    )
+    print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} pushed.")
+
+    body = PR_BODY.format(version=version)
+    repo = login(token)
+    pr = repo.create_pull(
+        f"Prepare release {version}",
+        base=base_branch,
+        head=release_branch,
+        body=body,
+    )
+    print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.")
+
+
+def find_next_version(
+    base_branch: str, is_major: bool, is_feature_release: bool, prerelease: str
+) -> str:
+    output = check_output(["git", "tag"], encoding="UTF-8")
+    valid_versions = []
+    for v in output.splitlines():
+        m = re.match(r"\d.\d.\d+$", v.strip())
+        if m:
+            valid_versions.append(tuple(int(x) for x in v.split(".")))
+
+    valid_versions.sort()
+    last_version = valid_versions[-1]
+
+    if is_major:
+        return f"{last_version[0]+1}.0.0{prerelease}"
+    elif is_feature_release:
+        return f"{last_version[0]}.{last_version[1] + 1}.0{prerelease}"
+    else:
+        return f"{last_version[0]}.{last_version[1]}.{last_version[2] + 1}{prerelease}"
+
+
+def main() -> None:
+    init(autoreset=True)
+    parser = argparse.ArgumentParser()
+    parser.add_argument("base_branch")
+    parser.add_argument("token")
+    parser.add_argument("--major", action="store_true", default=False)
+    parser.add_argument("--prerelease", default="")
+    options = parser.parse_args()
+    prepare_release_pr(
+        base_branch=options.base_branch,
+        is_major=options.major,
+        token=options.token,
+        prerelease=options.prerelease,
+    )
+
+
+if __name__ == "__main__":
+    main()
index 2531b0221b97e90fdd61c3006b177c393e46607f..68cbd7adffd43aa99bcd473986d10f1c56684d9e 100644 (file)
@@ -1,7 +1,7 @@
 """
 Script used to publish GitHub release notes extracted from CHANGELOG.rst.
 
-This script is meant to be executed after a successful deployment in Travis.
+This script is meant to be executed after a successful deployment in GitHub actions.
 
 Uses the following environment variables:
 
@@ -12,11 +12,8 @@ Uses the following environment variables:
 
     https://github.com/settings/tokens
 
-  It should be encrypted using:
-
-    $travis encrypt GH_RELEASE_NOTES_TOKEN=<token> -r pytest-dev/pytest
-
-  And the contents pasted in the ``deploy.env.secure`` section in the ``travis.yml`` file.
+  This token should be set in a secret in the repository, which is exposed as an
+  environment variable in the main.yml workflow file.
 
 The script also requires ``pandoc`` to be previously installed in the system.
 
diff --git a/scripts/release-on-comment.py b/scripts/release-on-comment.py
deleted file mode 100644 (file)
index 44431a4..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-"""
-This script is part of the pytest release process which is triggered by comments
-in issues.
-
-This script is started by the `release-on-comment.yml` workflow, which always executes on
-`master` and is triggered by two comment related events:
-
-* https://help.github.com/en/actions/reference/events-that-trigger-workflows#issue-comment-event-issue_comment
-* https://help.github.com/en/actions/reference/events-that-trigger-workflows#issues-event-issues
-
-This script receives the payload and a secrets on the command line.
-
-The payload must contain a comment with a phrase matching this pseudo-regular expression:
-
-    @pytestbot please prepare (major )? release from <branch name>
-
-Then the appropriate version will be obtained based on the given branch name:
-
-* a major release from master if "major" appears in the phrase in that position
-* a feature or bug fix release from master (based if there are features in the current changelog
-  folder)
-* a bug fix from a maintenance branch
-
-After that, it will create a release using the `release` tox environment, and push a new PR.
-
-**Secret**: currently the secret is defined in the @pytestbot account, which the core maintainers
-have access to. There we created a new secret named `chatops` with write access to the repository.
-"""
-import argparse
-import json
-import os
-import re
-import traceback
-from pathlib import Path
-from subprocess import CalledProcessError
-from subprocess import check_call
-from subprocess import check_output
-from subprocess import run
-from textwrap import dedent
-from typing import Dict
-from typing import Optional
-from typing import Tuple
-
-from colorama import Fore
-from colorama import init
-from github3.repos import Repository
-
-
-class InvalidFeatureRelease(Exception):
-    pass
-
-
-SLUG = "pytest-dev/pytest"
-
-PR_BODY = """\
-Created automatically from {comment_url}.
-
-Once all builds pass and it has been **approved** by one or more maintainers, the build
-can be released by pushing a tag `{version}` to this repository.
-
-Closes #{issue_number}.
-"""
-
-
-def login(token: str) -> Repository:
-    import github3
-
-    github = github3.login(token=token)
-    owner, repo = SLUG.split("/")
-    return github.repository(owner, repo)
-
-
-def get_comment_data(payload: Dict) -> str:
-    if "comment" in payload:
-        return payload["comment"]
-    else:
-        return payload["issue"]
-
-
-def validate_and_get_issue_comment_payload(
-    issue_payload_path: Optional[Path],
-) -> Tuple[str, str, bool]:
-    payload = json.loads(issue_payload_path.read_text(encoding="UTF-8"))
-    body = get_comment_data(payload)["body"]
-    m = re.match(r"@pytestbot please prepare (major )?release from ([\w\-_\.]+)", body)
-    if m:
-        is_major, base_branch = m.group(1) is not None, m.group(2)
-    else:
-        is_major, base_branch = False, None
-    return payload, base_branch, is_major
-
-
-def print_and_exit(msg) -> None:
-    print(msg)
-    raise SystemExit(1)
-
-
-def trigger_release(payload_path: Path, token: str) -> None:
-    payload, base_branch, is_major = validate_and_get_issue_comment_payload(
-        payload_path
-    )
-    if base_branch is None:
-        url = get_comment_data(payload)["html_url"]
-        print_and_exit(
-            f"Comment {Fore.CYAN}{url}{Fore.RESET} did not match the trigger command."
-        )
-    print()
-    print(f"Precessing release for branch {Fore.CYAN}{base_branch}")
-
-    repo = login(token)
-
-    issue_number = payload["issue"]["number"]
-    issue = repo.issue(issue_number)
-
-    check_call(["git", "checkout", f"origin/{base_branch}"])
-
-    try:
-        version = find_next_version(base_branch, is_major)
-    except InvalidFeatureRelease as e:
-        issue.create_comment(str(e))
-        print_and_exit(f"{Fore.RED}{e}")
-
-    error_contents = ""
-    try:
-        print(f"Version: {Fore.CYAN}{version}")
-
-        release_branch = f"release-{version}"
-
-        run(
-            ["git", "config", "user.name", "pytest bot"],
-            text=True,
-            check=True,
-            capture_output=True,
-        )
-        run(
-            ["git", "config", "user.email", "pytestbot@gmail.com"],
-            text=True,
-            check=True,
-            capture_output=True,
-        )
-
-        run(
-            ["git", "checkout", "-b", release_branch, f"origin/{base_branch}"],
-            text=True,
-            check=True,
-            capture_output=True,
-        )
-
-        print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} created.")
-
-        # important to use tox here because we have changed branches, so dependencies
-        # might have changed as well
-        cmdline = ["tox", "-e", "release", "--", version, "--skip-check-links"]
-        print("Running", " ".join(cmdline))
-        run(
-            cmdline, text=True, check=True, capture_output=True,
-        )
-
-        oauth_url = f"https://{token}:x-oauth-basic@github.com/{SLUG}.git"
-        run(
-            ["git", "push", oauth_url, f"HEAD:{release_branch}", "--force"],
-            text=True,
-            check=True,
-            capture_output=True,
-        )
-        print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} pushed.")
-
-        body = PR_BODY.format(
-            comment_url=get_comment_data(payload)["html_url"],
-            version=version,
-            issue_number=issue_number,
-        )
-        pr = repo.create_pull(
-            f"Prepare release {version}",
-            base=base_branch,
-            head=release_branch,
-            body=body,
-        )
-        print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.")
-
-        comment = issue.create_comment(
-            f"As requested, opened a PR for release `{version}`: #{pr.number}."
-        )
-        print(f"Notified in original comment {Fore.CYAN}{comment.url}{Fore.RESET}.")
-
-    except CalledProcessError as e:
-        error_contents = f"CalledProcessError\noutput:\n{e.output}\nstderr:\n{e.stderr}"
-    except Exception:
-        error_contents = f"Exception:\n{traceback.format_exc()}"
-
-    if error_contents:
-        link = f"https://github.com/{SLUG}/actions/runs/{os.environ['GITHUB_RUN_ID']}"
-        msg = ERROR_COMMENT.format(
-            version=version, base_branch=base_branch, contents=error_contents, link=link
-        )
-        issue.create_comment(msg)
-        print_and_exit(f"{Fore.RED}{error_contents}")
-    else:
-        print(f"{Fore.GREEN}Success.")
-
-
-ERROR_COMMENT = """\
-The request to prepare release `{version}` from {base_branch} failed with:
-
-```
-{contents}
-```
-
-See: {link}.
-"""
-
-
-def find_next_version(base_branch: str, is_major: bool) -> str:
-    output = check_output(["git", "tag"], encoding="UTF-8")
-    valid_versions = []
-    for v in output.splitlines():
-        m = re.match(r"\d.\d.\d+$", v.strip())
-        if m:
-            valid_versions.append(tuple(int(x) for x in v.split(".")))
-
-    valid_versions.sort()
-    last_version = valid_versions[-1]
-
-    changelog = Path("changelog")
-
-    features = list(changelog.glob("*.feature.rst"))
-    breaking = list(changelog.glob("*.breaking.rst"))
-    is_feature_release = features or breaking
-
-    if is_feature_release and base_branch != "master":
-        msg = dedent(
-            f"""
-            Found features or breaking changes in `{base_branch}`, and feature releases can only be
-            created from `master`:
-        """
-        )
-        msg += "\n".join(f"* `{x.name}`" for x in sorted(features + breaking))
-        raise InvalidFeatureRelease(msg)
-
-    if is_major:
-        return f"{last_version[0]+1}.0.0"
-    elif is_feature_release:
-        return f"{last_version[0]}.{last_version[1] + 1}.0"
-    else:
-        return f"{last_version[0]}.{last_version[1]}.{last_version[2] + 1}"
-
-
-def main() -> None:
-    init(autoreset=True)
-    parser = argparse.ArgumentParser()
-    parser.add_argument("payload")
-    parser.add_argument("token")
-    options = parser.parse_args()
-    trigger_release(Path(options.payload), options.token)
-
-
-if __name__ == "__main__":
-    main()
diff --git a/scripts/release.major.rst b/scripts/release.major.rst
new file mode 100644 (file)
index 0000000..76e447f
--- /dev/null
@@ -0,0 +1,24 @@
+pytest-{version}
+=======================================
+
+The pytest team is proud to announce the {version} release!
+
+This release contains new features, improvements, bug fixes, and breaking changes, so users
+are encouraged to take a look at the CHANGELOG carefully:
+
+    https://docs.pytest.org/en/stable/changelog.html
+
+For complete documentation, please visit:
+
+    https://docs.pytest.org/en/stable/
+
+As usual, you can upgrade from PyPI via:
+
+    pip install -U pytest
+
+Thanks to all of the contributors to this release:
+
+{contributors}
+
+Happy testing,
+The pytest Development Team
index 76e447f0c6d9a832b27f81a4db2d1c3a34de2426..9a06d3d4140628176279d0a59daac15fd34b26ee 100644 (file)
@@ -3,8 +3,8 @@ pytest-{version}
 
 The pytest team is proud to announce the {version} release!
 
-This release contains new features, improvements, bug fixes, and breaking changes, so users
-are encouraged to take a look at the CHANGELOG carefully:
+This release contains new features, improvements, and bug fixes,
+the full list of changes is available in the changelog:
 
     https://docs.pytest.org/en/stable/changelog.html
 
diff --git a/scripts/release.pre.rst b/scripts/release.pre.rst
new file mode 100644 (file)
index 0000000..960fae7
--- /dev/null
@@ -0,0 +1,29 @@
+pytest-{version}
+=======================================
+
+The pytest team is proud to announce the {version} prerelease!
+
+This is a prerelease, not intended for production use, but to test the upcoming features and improvements
+in order to catch any major problems before the final version is released to the major public.
+
+We appreciate your help testing this out before the final release, making sure to report any
+regressions to our issue tracker:
+
+https://github.com/pytest-dev/pytest/issues
+
+When doing so, please include the string ``[prerelease]`` in the title.
+
+You can upgrade from PyPI via:
+
+    pip install pytest=={version}
+
+Users are encouraged to take a look at the CHANGELOG carefully:
+
+    https://docs.pytest.org/en/{doc_version}/changelog.html
+
+Thanks to all the contributors to this release:
+
+{contributors}
+
+Happy testing,
+The pytest Development Team
index 798e42e1fe0d4b206fcd34939d30b99b372f0fd0..19fef4284285a06b8d9284f4f5191140010cb359 100644 (file)
@@ -10,7 +10,7 @@ from colorama import Fore
 from colorama import init
 
 
-def announce(version):
+def announce(version, template_name, doc_version):
     """Generates a new release announcement entry in the docs."""
     # Get our list of authors
     stdout = check_output(["git", "describe", "--abbrev=0", "--tags"])
@@ -20,17 +20,20 @@ def announce(version):
     stdout = check_output(["git", "log", f"{last_version}..HEAD", "--format=%aN"])
     stdout = stdout.decode("utf-8")
 
-    contributors = set(stdout.splitlines())
+    contributors = {
+        name
+        for name in stdout.splitlines()
+        if not name.endswith("[bot]") and name != "pytest bot"
+    }
 
-    template_name = (
-        "release.minor.rst" if version.endswith(".0") else "release.patch.rst"
-    )
     template_text = (
         Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
     )
 
     contributors_text = "\n".join(f"* {name}" for name in sorted(contributors)) + "\n"
-    text = template_text.format(version=version, contributors=contributors_text)
+    text = template_text.format(
+        version=version, contributors=contributors_text, doc_version=doc_version
+    )
 
     target = Path(__file__).parent.joinpath(f"../doc/en/announce/release-{version}.rst")
     target.write_text(text, encoding="UTF-8")
@@ -63,7 +66,7 @@ def regen(version):
     print(f"{Fore.CYAN}[generate.regen] {Fore.RESET}Updating docs")
     check_call(
         ["tox", "-e", "regen"],
-        env={**os.environ, "SETUPTOOLS_SCM_PRETEND_VERSION": version},
+        env={**os.environ, "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST": version},
     )
 
 
@@ -81,9 +84,9 @@ def check_links():
     check_call(["tox", "-e", "docs-checklinks"])
 
 
-def pre_release(version, *, skip_check_links):
+def pre_release(version, template_name, doc_version, *, skip_check_links):
     """Generates new docs, release announcements and creates a local tag."""
-    announce(version)
+    announce(version, template_name, doc_version)
     regen(version)
     changelog(version, write_out=True)
     fix_formatting()
@@ -100,10 +103,7 @@ def pre_release(version, *, skip_check_links):
 
 
 def changelog(version, write_out=False):
-    if write_out:
-        addopts = []
-    else:
-        addopts = ["--draft"]
+    addopts = [] if write_out else ["--draft"]
     check_call(["towncrier", "--yes", "--version", version] + addopts)
 
 
@@ -111,9 +111,20 @@ def main():
     init(autoreset=True)
     parser = argparse.ArgumentParser()
     parser.add_argument("version", help="Release version")
+    parser.add_argument(
+        "template_name", help="Name of template file to use for release announcement"
+    )
+    parser.add_argument(
+        "doc_version", help="For prereleases, the version to link to in the docs"
+    )
     parser.add_argument("--skip-check-links", action="store_true", default=False)
     options = parser.parse_args()
-    pre_release(options.version, skip_check_links=options.skip_check_links)
+    pre_release(
+        options.version,
+        options.template_name,
+        options.doc_version,
+        skip_check_links=options.skip_check_links,
+    )
 
 
 if __name__ == "__main__":
diff --git a/scripts/report-coverage.sh b/scripts/report-coverage.sh
deleted file mode 100755 (executable)
index fbcf20c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -x
-
-if [ -z "$TOXENV" ]; then
-  python -m pip install coverage
-else
-  # Add last TOXENV to $PATH.
-  PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
-fi
-
-python -m coverage combine
-python -m coverage xml
-python -m coverage report -m
-# Set --connect-timeout to work around https://github.com/curl/curl/issues/4461
-curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh
-bash codecov-upload.sh -Z -X fix -f coverage.xml "$@"
index 81507b40b75fd9fb95f956a1a5429c918e34be8d..1f1068689a80ccb815f5e7cf8b971c0e8223e81c 100644 (file)
@@ -7,7 +7,9 @@ def main():
     Platform agnostic wrapper script for towncrier.
     Fixes the issue (#7251) where windows users are unable to natively run tox -e docs to build pytest docs.
     """
-    with open("doc/en/_changelog_towncrier_draft.rst", "w") as draft_file:
+    with open(
+        "doc/en/_changelog_towncrier_draft.rst", "w", encoding="utf-8"
+    ) as draft_file:
         return call(("towncrier", "--draft"), stdout=draft_file)
 
 
diff --git a/scripts/update-plugin-list.py b/scripts/update-plugin-list.py
new file mode 100644 (file)
index 0000000..2efe041
--- /dev/null
@@ -0,0 +1,171 @@
+import datetime
+import pathlib
+import re
+from textwrap import dedent
+from textwrap import indent
+
+import packaging.version
+import requests
+import tabulate
+import wcwidth
+from tqdm import tqdm
+
+FILE_HEAD = r"""
+.. _plugin-list:
+
+Pytest Plugin List
+==================
+
+Below is an automated compilation of ``pytest``` plugins available on `PyPI <https://pypi.org>`_.
+It includes PyPI projects whose names begin with "pytest-" and a handful of manually selected projects.
+Packages classified as inactive are excluded.
+
+For detailed insights into how this list is generated,
+please refer to `the update script <https://github.com/pytest-dev/pytest/blob/main/scripts/update-plugin-list.py>`_.
+
+.. warning::
+
+   Please be aware that this list is not a curated collection of projects
+   and does not undergo a systematic review process.
+   It serves purely as an informational resource to aid in the discovery of ``pytest`` plugins.
+
+   Do not presume any endorsement from the ``pytest`` project or its developers,
+   and always conduct your own quality assessment before incorporating any of these plugins into your own projects.
+
+
+.. The following conditional uses a different format for this list when
+   creating a PDF, because otherwise the table gets far too wide for the
+   page.
+
+"""
+DEVELOPMENT_STATUS_CLASSIFIERS = (
+    "Development Status :: 1 - Planning",
+    "Development Status :: 2 - Pre-Alpha",
+    "Development Status :: 3 - Alpha",
+    "Development Status :: 4 - Beta",
+    "Development Status :: 5 - Production/Stable",
+    "Development Status :: 6 - Mature",
+    "Development Status :: 7 - Inactive",
+)
+ADDITIONAL_PROJECTS = {  # set of additional projects to consider as plugins
+    "logassert",
+}
+
+
+def escape_rst(text: str) -> str:
+    """Rudimentary attempt to escape special RST characters to appear as
+    plain text."""
+    text = (
+        text.replace("*", "\\*")
+        .replace("<", "\\<")
+        .replace(">", "\\>")
+        .replace("`", "\\`")
+    )
+    text = re.sub(r"_\b", "", text)
+    return text
+
+
+def iter_plugins():
+    regex = r">([\d\w-]*)</a>"
+    response = requests.get("https://pypi.org/simple")
+
+    match_names = (match.groups()[0] for match in re.finditer(regex, response.text))
+    plugin_names = [
+        name
+        for name in match_names
+        if name.startswith("pytest-") or name in ADDITIONAL_PROJECTS
+    ]
+
+    for name in tqdm(plugin_names, smoothing=0):
+        response = requests.get(f"https://pypi.org/pypi/{name}/json")
+        if response.status_code == 404:
+            # Some packages, like pytest-azurepipelines42, are included in https://pypi.org/simple
+            # but return 404 on the JSON API. Skip.
+            continue
+        response.raise_for_status()
+        info = response.json()["info"]
+        if "Development Status :: 7 - Inactive" in info["classifiers"]:
+            continue
+        for classifier in DEVELOPMENT_STATUS_CLASSIFIERS:
+            if classifier in info["classifiers"]:
+                status = classifier[22:]
+                break
+        else:
+            status = "N/A"
+        requires = "N/A"
+        if info["requires_dist"]:
+            for requirement in info["requires_dist"]:
+                if re.match(r"pytest(?![-.\w])", requirement):
+                    requires = requirement
+                    break
+
+        def version_sort_key(version_string):
+            """
+            Return the sort key for the given version string
+            returned by the API.
+            """
+            try:
+                return packaging.version.parse(version_string)
+            except packaging.version.InvalidVersion:
+                # Use a hard-coded pre-release version.
+                return packaging.version.Version("0.0.0alpha")
+
+        releases = response.json()["releases"]
+        for release in sorted(releases, key=version_sort_key, reverse=True):
+            if releases[release]:
+                release_date = datetime.date.fromisoformat(
+                    releases[release][-1]["upload_time_iso_8601"].split("T")[0]
+                )
+                last_release = release_date.strftime("%b %d, %Y")
+                break
+        name = f':pypi:`{info["name"]}`'
+        summary = ""
+        if info["summary"]:
+            summary = escape_rst(info["summary"].replace("\n", ""))
+        yield {
+            "name": name,
+            "summary": summary.strip(),
+            "last release": last_release,
+            "status": status,
+            "requires": requires,
+        }
+
+
+def plugin_definitions(plugins):
+    """Return RST for the plugin list that fits better on a vertical page."""
+
+    for plugin in plugins:
+        yield dedent(
+            f"""
+            {plugin['name']}
+               *last release*: {plugin["last release"]},
+               *status*: {plugin["status"]},
+               *requires*: {plugin["requires"]}
+
+               {plugin["summary"]}
+            """
+        )
+
+
+def main():
+    plugins = list(iter_plugins())
+
+    reference_dir = pathlib.Path("doc", "en", "reference")
+
+    plugin_list = reference_dir / "plugin_list.rst"
+    with plugin_list.open("w", encoding="UTF-8") as f:
+        f.write(FILE_HEAD)
+        f.write(f"This list contains {len(plugins)} plugins.\n\n")
+        f.write(".. only:: not latex\n\n")
+
+        wcwidth  # reference library that must exist for tabulate to work
+        plugin_table = tabulate.tabulate(plugins, headers="keys", tablefmt="rst")
+        f.write(indent(plugin_table, "   "))
+        f.write("\n\n")
+
+        f.write(".. only:: latex\n\n")
+        f.write(indent("".join(plugin_definitions(plugins)), "  "))
+
+
+if __name__ == "__main__":
+    main()
index 14fdb6df5c020bdae5c240830024f9407ae67412..d6e04c373dd0868cd1c1fc542845c6dc68a1e4a9 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -6,87 +6,89 @@ long_description_content_type = text/x-rst
 url = https://docs.pytest.org/en/latest/
 author = Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
 license = MIT
-license_file = LICENSE
+license_files = LICENSE
 platforms = unix, linux, osx, cygwin, win32
-classifiers =
-    Development Status :: 6 - Mature
-    Intended Audience :: Developers
-    License :: OSI Approved :: MIT License
-    Operating System :: MacOS :: MacOS X
-    Operating System :: Microsoft :: Windows
-    Operating System :: POSIX
-    Programming Language :: Python :: 3
-    Programming Language :: Python :: 3 :: Only
-    Programming Language :: Python :: 3.6
-    Programming Language :: Python :: 3.7
-    Programming Language :: Python :: 3.8
-    Programming Language :: Python :: 3.9
-    Topic :: Software Development :: Libraries
-    Topic :: Software Development :: Testing
-    Topic :: Utilities
+classifiers = 
+       Development Status :: 6 - Mature
+       Intended Audience :: Developers
+       License :: OSI Approved :: MIT License
+       Operating System :: MacOS :: MacOS X
+       Operating System :: Microsoft :: Windows
+       Operating System :: POSIX
+       Programming Language :: Python :: 3
+       Programming Language :: Python :: 3 :: Only
+       Programming Language :: Python :: 3.7
+       Programming Language :: Python :: 3.8
+       Programming Language :: Python :: 3.9
+       Programming Language :: Python :: 3.10
+       Programming Language :: Python :: 3.11
+       Programming Language :: Python :: 3.12
+       Topic :: Software Development :: Libraries
+       Topic :: Software Development :: Testing
+       Topic :: Utilities
 keywords = test, unittest
-project_urls =
-    Changelog=https://docs.pytest.org/en/stable/changelog.html
-    Twitter=https://twitter.com/pytestdotorg
-    Source=https://github.com/pytest-dev/pytest
-    Tracker=https://github.com/pytest-dev/pytest/issues
+project_urls = 
+       Changelog=https://docs.pytest.org/en/stable/changelog.html
+       Twitter=https://twitter.com/pytestdotorg
+       Source=https://github.com/pytest-dev/pytest
+       Tracker=https://github.com/pytest-dev/pytest/issues
 
 [options]
-packages =
-    _pytest
-    _pytest._code
-    _pytest._io
-    _pytest.assertion
-    _pytest.config
-    _pytest.mark
-    pytest
-install_requires =
-    attrs>=19.2.0
-    iniconfig
-    packaging
-    pluggy>=0.12,<1.0.0a1
-    py>=1.8.2
-    toml
-    atomicwrites>=1.0;sys_platform=="win32"
-    colorama;sys_platform=="win32"
-    importlib-metadata>=0.12;python_version<"3.8"
-python_requires = >=3.6
-package_dir =
-    =src
-setup_requires =
-    setuptools>=>=42.0
-    setuptools-scm>=3.4
+packages = 
+       _pytest
+       _pytest._code
+       _pytest._io
+       _pytest._py
+       _pytest.assertion
+       _pytest.config
+       _pytest.mark
+       pytest
+py_modules = py
+install_requires = 
+       iniconfig
+       packaging
+       pluggy>=0.12,<2.0
+       colorama;sys_platform=="win32"
+       exceptiongroup>=1.0.0rc8;python_version<"3.11"
+       importlib-metadata>=0.12;python_version<"3.8"
+       tomli>=1.0.0;python_version<"3.11"
+python_requires = >=3.7
+package_dir = 
+       =src
+setup_requires = 
+       setuptools
+       setuptools-scm>=6.0
 zip_safe = no
 
 [options.entry_points]
-console_scripts =
-    pytest=pytest:console_main
-    py.test=pytest:console_main
+console_scripts = 
+       pytest=pytest:console_main
+       py.test=pytest:console_main
 
 [options.extras_require]
-testing =
-    argcomplete
-    hypothesis>=3.56
-    mock
-    nose
-    requests
-    xmlschema
+testing = 
+       argcomplete
+       attrs>=19.2.0
+       hypothesis>=3.56
+       mock
+       nose
+       pygments>=2.7.2
+       requests
+       setuptools
+       xmlschema
 
 [options.package_data]
 _pytest = py.typed
 pytest = py.typed
 
 [build_sphinx]
-source-dir = doc/en/
-build-dir = doc/build
+source_dir = doc/en/
+build_dir = doc/build
 all_files = 1
 
-[upload_sphinx]
-upload-dir = doc/en/build/html
-
 [check-manifest]
-ignore =
-    src/_pytest/_version.py
+ignore = 
+       src/_pytest/_version.py
 
 [devpi:upload]
 formats = sdist.tgz,bdist_wheel
@@ -96,7 +98,6 @@ mypy_path = src
 check_untyped_defs = True
 disallow_any_generics = True
 ignore_missing_imports = True
-no_implicit_optional = True
 show_error_codes = True
 strict_equality = True
 warn_redundant_casts = True
@@ -104,3 +105,8 @@ warn_return_any = True
 warn_unreachable = True
 warn_unused_configs = True
 no_implicit_reexport = True
+
+[egg_info]
+tag_build = 
+tag_date = 0
+
index 46c7827ed5ec62b4613bf31d8331f731a24d34a9..8a406c5c7512bb928f1909cf1f43461cb3efb64c 100644 (file)
@@ -1,8 +1,9 @@
-__all__ = ["__version__"]
+__all__ = ["__version__", "version_tuple"]
 
 try:
-    from ._version import version as __version__
-except ImportError:
+    from ._version import version as __version__, version_tuple
+except ImportError:  # pragma: no cover
     # broken installation, we don't even try
     # unknown only works because we do poor mans version compare
     __version__ = "unknown"
+    version_tuple = (0, 0, "unknown")  # type:ignore[assignment]
index 41d9d9407c773bf6a3c4eded476a49649fb80bb2..6a8083770aeef4af0bbec7c35811108678451f14 100644 (file)
@@ -78,15 +78,15 @@ class FastFilesCompleter:
 
     def __call__(self, prefix: str, **kwargs: Any) -> List[str]:
         # Only called on non option completions.
-        if os.path.sep in prefix[1:]:
-            prefix_dir = len(os.path.dirname(prefix) + os.path.sep)
+        if os.sep in prefix[1:]:
+            prefix_dir = len(os.path.dirname(prefix) + os.sep)
         else:
             prefix_dir = 0
         completion = []
         globbed = []
         if "*" not in prefix and "?" not in prefix:
             # We are on unix, otherwise no bash.
-            if not prefix or prefix[-1] == os.path.sep:
+            if not prefix or prefix[-1] == os.sep:
                 globbed.extend(glob(prefix + ".*"))
             prefix += "*"
         globbed.extend(glob(prefix))
@@ -108,7 +108,6 @@ if os.environ.get("_ARGCOMPLETE"):
     def try_argcomplete(parser: argparse.ArgumentParser) -> None:
         argcomplete.autocomplete(parser, always_complete_options=False)
 
-
 else:
 
     def try_argcomplete(parser: argparse.ArgumentParser) -> None:
index 423069330a54dac962a6fe83dbbd521abd665276..9b051332baf485841961181521fbdc5ac0ab4b17 100644 (file)
@@ -1,4 +1,7 @@
+import ast
+import dataclasses
 import inspect
+import os
 import re
 import sys
 import traceback
@@ -12,6 +15,7 @@ from types import FrameType
 from types import TracebackType
 from typing import Any
 from typing import Callable
+from typing import ClassVar
 from typing import Dict
 from typing import Generic
 from typing import Iterable
@@ -27,11 +31,8 @@ from typing import Type
 from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
-from weakref import ref
 
-import attr
 import pluggy
-import py
 
 import _pytest
 from _pytest._code.source import findsource
@@ -43,13 +44,20 @@ from _pytest._io.saferepr import safeformat
 from _pytest._io.saferepr import saferepr
 from _pytest.compat import final
 from _pytest.compat import get_real_func
+from _pytest.deprecated import check_ispytest
+from _pytest.pathlib import absolutepath
+from _pytest.pathlib import bestrelpath
 
 if TYPE_CHECKING:
+    from typing_extensions import Final
     from typing_extensions import Literal
-    from weakref import ReferenceType
+    from typing_extensions import SupportsIndex
 
     _TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"]
 
+if sys.version_info[:2] < (3, 11):
+    from exceptiongroup import BaseExceptionGroup
+
 
 class Code:
     """Wrapper around Python code objects."""
@@ -78,16 +86,16 @@ class Code:
         return self.raw.co_name
 
     @property
-    def path(self) -> Union[py.path.local, str]:
+    def path(self) -> Union[Path, str]:
         """Return a path object pointing to source code, or an ``str`` in
         case of ``OSError`` / non-existing file."""
         if not self.raw.co_filename:
             return ""
         try:
-            p = py.path.local(self.raw.co_filename)
+            p = absolutepath(self.raw.co_filename)
             # maybe don't try this checking
-            if not p.check():
-                raise OSError("py.path check failed.")
+            if not p.exists():
+                raise OSError("path check failed.")
             return p
         except OSError:
             # XXX maybe try harder like the weird logic
@@ -185,25 +193,25 @@ class Frame:
 class TracebackEntry:
     """A single entry in a Traceback."""
 
-    __slots__ = ("_rawentry", "_excinfo", "_repr_style")
+    __slots__ = ("_rawentry", "_repr_style")
 
     def __init__(
         self,
         rawentry: TracebackType,
-        excinfo: Optional["ReferenceType[ExceptionInfo[BaseException]]"] = None,
+        repr_style: Optional['Literal["short", "long"]'] = None,
     ) -> None:
-        self._rawentry = rawentry
-        self._excinfo = excinfo
-        self._repr_style: Optional['Literal["short", "long"]'] = None
+        self._rawentry: "Final" = rawentry
+        self._repr_style: "Final" = repr_style
+
+    def with_repr_style(
+        self, repr_style: Optional['Literal["short", "long"]']
+    ) -> "TracebackEntry":
+        return TracebackEntry(self._rawentry, repr_style)
 
     @property
     def lineno(self) -> int:
         return self._rawentry.tb_lineno - 1
 
-    def set_repr_style(self, mode: "Literal['short', 'long']") -> None:
-        assert mode in ("short", "long")
-        self._repr_style = mode
-
     @property
     def frame(self) -> Frame:
         return Frame(self._rawentry.tb_frame)
@@ -223,7 +231,7 @@ class TracebackEntry:
         return source.getstatement(self.lineno)
 
     @property
-    def path(self) -> Union[py.path.local, str]:
+    def path(self) -> Union[Path, str]:
         """Path to the source code."""
         return self.frame.code.path
 
@@ -235,7 +243,9 @@ class TracebackEntry:
     def getfirstlinesource(self) -> int:
         return self.frame.code.firstlineno
 
-    def getsource(self, astcache=None) -> Optional["Source"]:
+    def getsource(
+        self, astcache: Optional[Dict[Union[str, Path], ast.AST]] = None
+    ) -> Optional["Source"]:
         """Return failing source code."""
         # we use the passed in astcache to not reparse asttrees
         # within exception info printing
@@ -255,13 +265,13 @@ class TracebackEntry:
         except SyntaxError:
             end = self.lineno + 1
         else:
-            if key is not None:
+            if key is not None and astcache is not None:
                 astcache[key] = astnode
         return source[start:end]
 
     source = property(getsource)
 
-    def ishidden(self) -> bool:
+    def ishidden(self, excinfo: Optional["ExceptionInfo[BaseException]"]) -> bool:
         """Return True if the current frame has a var __tracebackhide__
         resolving to True.
 
@@ -270,9 +280,9 @@ class TracebackEntry:
 
         Mostly for internal use.
         """
-        tbh: Union[bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]] = (
-            False
-        )
+        tbh: Union[
+            bool, Callable[[Optional[ExceptionInfo[BaseException]]], bool]
+        ] = False
         for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals):
             # in normal cases, f_locals and f_globals are dictionaries
             # however via `exec(...)` / `eval(...)` they can be other types
@@ -285,7 +295,7 @@ class TracebackEntry:
             else:
                 break
         if tbh and callable(tbh):
-            return tbh(None if self._excinfo is None else self._excinfo())
+            return tbh(excinfo)
         return tbh
 
     def __str__(self) -> str:
@@ -318,16 +328,14 @@ class Traceback(List[TracebackEntry]):
     def __init__(
         self,
         tb: Union[TracebackType, Iterable[TracebackEntry]],
-        excinfo: Optional["ReferenceType[ExceptionInfo[BaseException]]"] = None,
     ) -> None:
         """Initialize from given python traceback object and ExceptionInfo."""
-        self._excinfo = excinfo
         if isinstance(tb, TracebackType):
 
             def f(cur: TracebackType) -> Iterable[TracebackEntry]:
                 cur_: Optional[TracebackType] = cur
                 while cur_ is not None:
-                    yield TracebackEntry(cur_, excinfo=excinfo)
+                    yield TracebackEntry(cur_)
                     cur_ = cur_.tb_next
 
             super().__init__(f(tb))
@@ -336,10 +344,10 @@ class Traceback(List[TracebackEntry]):
 
     def cut(
         self,
-        path=None,
+        path: Optional[Union["os.PathLike[str]", str]] = None,
         lineno: Optional[int] = None,
         firstlineno: Optional[int] = None,
-        excludepath: Optional[py.path.local] = None,
+        excludepath: Optional["os.PathLike[str]"] = None,
     ) -> "Traceback":
         """Return a Traceback instance wrapping part of this Traceback.
 
@@ -350,57 +358,64 @@ class Traceback(List[TracebackEntry]):
         for formatting reasons (removing some uninteresting bits that deal
         with handling of the exception/traceback).
         """
+        path_ = None if path is None else os.fspath(path)
+        excludepath_ = None if excludepath is None else os.fspath(excludepath)
         for x in self:
             code = x.frame.code
             codepath = code.path
+            if path is not None and str(codepath) != path_:
+                continue
             if (
-                (path is None or codepath == path)
-                and (
-                    excludepath is None
-                    or not isinstance(codepath, py.path.local)
-                    or not codepath.relto(excludepath)
-                )
-                and (lineno is None or x.lineno == lineno)
-                and (firstlineno is None or x.frame.code.firstlineno == firstlineno)
+                excludepath is not None
+                and isinstance(codepath, Path)
+                and excludepath_ in (str(p) for p in codepath.parents)  # type: ignore[operator]
             ):
-                return Traceback(x._rawentry, self._excinfo)
+                continue
+            if lineno is not None and x.lineno != lineno:
+                continue
+            if firstlineno is not None and x.frame.code.firstlineno != firstlineno:
+                continue
+            return Traceback(x._rawentry)
         return self
 
     @overload
-    def __getitem__(self, key: int) -> TracebackEntry:
+    def __getitem__(self, key: "SupportsIndex") -> TracebackEntry:
         ...
 
     @overload
     def __getitem__(self, key: slice) -> "Traceback":
         ...
 
-    def __getitem__(self, key: Union[int, slice]) -> Union[TracebackEntry, "Traceback"]:
+    def __getitem__(
+        self, key: Union["SupportsIndex", slice]
+    ) -> Union[TracebackEntry, "Traceback"]:
         if isinstance(key, slice):
             return self.__class__(super().__getitem__(key))
         else:
             return super().__getitem__(key)
 
     def filter(
-        self, fn: Callable[[TracebackEntry], bool] = lambda x: not x.ishidden()
+        self,
+        # TODO(py38): change to positional only.
+        _excinfo_or_fn: Union[
+            "ExceptionInfo[BaseException]",
+            Callable[[TracebackEntry], bool],
+        ],
     ) -> "Traceback":
-        """Return a Traceback instance with certain items removed
+        """Return a Traceback instance with certain items removed.
 
-        fn is a function that gets a single argument, a TracebackEntry
-        instance, and should return True when the item should be added
-        to the Traceback, False when not.
+        If the filter is an `ExceptionInfo`, removes all the ``TracebackEntry``s
+        which are hidden (see ishidden() above).
 
-        By default this removes all the TracebackEntries which are hidden
-        (see ishidden() above).
+        Otherwise, the filter is a function that gets a single argument, a
+        ``TracebackEntry`` instance, and should return True when the item should
+        be added to the ``Traceback``, False when not.
         """
-        return Traceback(filter(fn, self), self._excinfo)
-
-    def getcrashentry(self) -> TracebackEntry:
-        """Return last non-hidden traceback entry that lead to the exception of a traceback."""
-        for i in range(-1, -len(self) - 1, -1):
-            entry = self[i]
-            if not entry.ishidden():
-                return entry
-        return self[-1]
+        if isinstance(_excinfo_or_fn, ExceptionInfo):
+            fn = lambda x: not x.ishidden(_excinfo_or_fn)  # noqa: E731
+        else:
+            fn = _excinfo_or_fn
+        return Traceback(filter(fn, self))
 
     def recursionindex(self) -> Optional[int]:
         """Return the index of the frame/TracebackEntry where recursion originates if
@@ -418,52 +433,75 @@ class Traceback(List[TracebackEntry]):
                 f = entry.frame
                 loc = f.f_locals
                 for otherloc in values:
-                    if f.eval(
-                        co_equal,
-                        __recursioncache_locals_1=loc,
-                        __recursioncache_locals_2=otherloc,
-                    ):
+                    if otherloc == loc:
                         return i
             values.append(entry.frame.f_locals)
         return None
 
 
-co_equal = compile(
-    "__recursioncache_locals_1 == __recursioncache_locals_2", "?", "eval"
-)
-
-
-_E = TypeVar("_E", bound=BaseException, covariant=True)
+E = TypeVar("E", bound=BaseException, covariant=True)
 
 
 @final
-@attr.s(repr=False)
-class ExceptionInfo(Generic[_E]):
+@dataclasses.dataclass
+class ExceptionInfo(Generic[E]):
     """Wraps sys.exc_info() objects and offers help for navigating the traceback."""
 
-    _assert_start_repr = "AssertionError('assert "
+    _assert_start_repr: ClassVar = "AssertionError('assert "
 
-    _excinfo = attr.ib(type=Optional[Tuple[Type["_E"], "_E", TracebackType]])
-    _striptext = attr.ib(type=str, default="")
-    _traceback = attr.ib(type=Optional[Traceback], default=None)
+    _excinfo: Optional[Tuple[Type["E"], "E", TracebackType]]
+    _striptext: str
+    _traceback: Optional[Traceback]
+
+    def __init__(
+        self,
+        excinfo: Optional[Tuple[Type["E"], "E", TracebackType]],
+        striptext: str = "",
+        traceback: Optional[Traceback] = None,
+        *,
+        _ispytest: bool = False,
+    ) -> None:
+        check_ispytest(_ispytest)
+        self._excinfo = excinfo
+        self._striptext = striptext
+        self._traceback = traceback
 
     @classmethod
-    def from_exc_info(
+    def from_exception(
         cls,
-        exc_info: Tuple[Type[_E], _E, TracebackType],
+        # Ignoring error: "Cannot use a covariant type variable as a parameter".
+        # This is OK to ignore because this class is (conceptually) readonly.
+        # See https://github.com/python/mypy/issues/7049.
+        exception: E,  # type: ignore[misc]
         exprinfo: Optional[str] = None,
-    ) -> "ExceptionInfo[_E]":
-        """Return an ExceptionInfo for an existing exc_info tuple.
+    ) -> "ExceptionInfo[E]":
+        """Return an ExceptionInfo for an existing exception.
 
-        .. warning::
-
-            Experimental API
+        The exception must have a non-``None`` ``__traceback__`` attribute,
+        otherwise this function fails with an assertion error. This means that
+        the exception must have been raised, or added a traceback with the
+        :py:meth:`~BaseException.with_traceback()` method.
 
         :param exprinfo:
             A text string helping to determine if we should strip
             ``AssertionError`` from the output. Defaults to the exception
             message/``__str__()``.
+
+        .. versionadded:: 7.4
         """
+        assert (
+            exception.__traceback__
+        ), "Exceptions passed to ExcInfo.from_exception(...) must have a non-None __traceback__."
+        exc_info = (type(exception), exception, exception.__traceback__)
+        return cls.from_exc_info(exc_info, exprinfo)
+
+    @classmethod
+    def from_exc_info(
+        cls,
+        exc_info: Tuple[Type[E], E, TracebackType],
+        exprinfo: Optional[str] = None,
+    ) -> "ExceptionInfo[E]":
+        """Like :func:`from_exception`, but using old-style exc_info tuple."""
         _striptext = ""
         if exprinfo is None and isinstance(exc_info[1], AssertionError):
             exprinfo = getattr(exc_info[1], "msg", None)
@@ -472,7 +510,7 @@ class ExceptionInfo(Generic[_E]):
             if exprinfo and exprinfo.startswith(cls._assert_start_repr):
                 _striptext = "AssertionError: "
 
-        return cls(exc_info, _striptext)
+        return cls(exc_info, _striptext, _ispytest=True)
 
     @classmethod
     def from_current(
@@ -497,17 +535,17 @@ class ExceptionInfo(Generic[_E]):
         return ExceptionInfo.from_exc_info(exc_info, exprinfo)
 
     @classmethod
-    def for_later(cls) -> "ExceptionInfo[_E]":
+    def for_later(cls) -> "ExceptionInfo[E]":
         """Return an unfilled ExceptionInfo."""
-        return cls(None)
+        return cls(None, _ispytest=True)
 
-    def fill_unfilled(self, exc_info: Tuple[Type[_E], _E, TracebackType]) -> None:
+    def fill_unfilled(self, exc_info: Tuple[Type[E], E, TracebackType]) -> None:
         """Fill an unfilled ExceptionInfo created with ``for_later()``."""
         assert self._excinfo is None, "ExceptionInfo was already filled"
         self._excinfo = exc_info
 
     @property
-    def type(self) -> Type[_E]:
+    def type(self) -> Type[E]:
         """The exception class."""
         assert (
             self._excinfo is not None
@@ -515,7 +553,7 @@ class ExceptionInfo(Generic[_E]):
         return self._excinfo[0]
 
     @property
-    def value(self) -> _E:
+    def value(self) -> E:
         """The exception value."""
         assert (
             self._excinfo is not None
@@ -542,7 +580,7 @@ class ExceptionInfo(Generic[_E]):
     def traceback(self) -> Traceback:
         """The traceback."""
         if self._traceback is None:
-            self._traceback = Traceback(self.tb, excinfo=ref(self))
+            self._traceback = Traceback(self.tb)
         return self._traceback
 
     @traceback.setter
@@ -559,10 +597,10 @@ class ExceptionInfo(Generic[_E]):
     def exconly(self, tryshort: bool = False) -> str:
         """Return the exception as a string.
 
-        When 'tryshort' resolves to True, and the exception is a
-        _pytest._code._AssertionError, only the actual exception part of
-        the exception representation is returned (so 'AssertionError: ' is
-        removed from the beginning).
+        When 'tryshort' resolves to True, and the exception is an
+        AssertionError, only the actual exception part of the exception
+        representation is returned (so 'AssertionError: ' is removed from
+        the beginning).
         """
         lines = format_exception_only(self.type, self.value)
         text = "".join(lines)
@@ -581,18 +619,25 @@ class ExceptionInfo(Generic[_E]):
         """
         return isinstance(self.value, exc)
 
-    def _getreprcrash(self) -> "ReprFileLocation":
-        exconly = self.exconly(tryshort=True)
-        entry = self.traceback.getcrashentry()
-        path, lineno = entry.frame.code.raw.co_filename, entry.lineno
-        return ReprFileLocation(path, lineno + 1, exconly)
+    def _getreprcrash(self) -> Optional["ReprFileLocation"]:
+        # Find last non-hidden traceback entry that led to the exception of the
+        # traceback, or None if all hidden.
+        for i in range(-1, -len(self.traceback) - 1, -1):
+            entry = self.traceback[i]
+            if not entry.ishidden(self):
+                path, lineno = entry.frame.code.raw.co_filename, entry.lineno
+                exconly = self.exconly(tryshort=True)
+                return ReprFileLocation(path, lineno + 1, exconly)
+        return None
 
     def getrepr(
         self,
         showlocals: bool = False,
         style: "_TracebackStyle" = "long",
         abspath: bool = False,
-        tbfilter: bool = True,
+        tbfilter: Union[
+            bool, Callable[["ExceptionInfo[BaseException]"], Traceback]
+        ] = True,
         funcargs: bool = False,
         truncate_locals: bool = True,
         chain: bool = True,
@@ -604,14 +649,20 @@ class ExceptionInfo(Generic[_E]):
             Ignored if ``style=="native"``.
 
         :param str style:
-            long|short|no|native|value traceback style.
+            long|short|line|no|native|value traceback style.
 
         :param bool abspath:
             If paths should be changed to absolute or left unchanged.
 
-        :param bool tbfilter:
-            Hide entries that contain a local variable ``__tracebackhide__==True``.
-            Ignored if ``style=="native"``.
+        :param tbfilter:
+            A filter for traceback entries.
+
+            * If false, don't hide any entries.
+            * If true, hide internal entries and entries that contain a local
+              variable ``__tracebackhide__ = True``.
+            * If a callable, delegates the filtering to the callable.
+
+            Ignored if ``style`` is ``"native"``.
 
         :param bool funcargs:
             Show fixtures ("funcargs" for legacy purposes) per traceback entry.
@@ -628,12 +679,14 @@ class ExceptionInfo(Generic[_E]):
         """
         if style == "native":
             return ReprExceptionInfo(
-                ReprTracebackNative(
+                reprtraceback=ReprTracebackNative(
                     traceback.format_exception(
-                        self.type, self.value, self.traceback[0]._rawentry
+                        self.type,
+                        self.value,
+                        self.traceback[0]._rawentry if self.traceback else None,
                     )
                 ),
-                self._getreprcrash(),
+                reprcrash=self._getreprcrash(),
             )
 
         fmt = FormattedExcinfo(
@@ -654,30 +707,33 @@ class ExceptionInfo(Generic[_E]):
         If it matches `True` is returned, otherwise an `AssertionError` is raised.
         """
         __tracebackhide__ = True
-        msg = "Regex pattern {!r} does not match {!r}."
-        if regexp == str(self.value):
-            msg += " Did you mean to `re.escape()` the regex?"
-        assert re.search(regexp, str(self.value)), msg.format(regexp, str(self.value))
+        value = str(self.value)
+        msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}"
+        if regexp == value:
+            msg += "\n Did you mean to `re.escape()` the regex?"
+        assert re.search(regexp, value), msg
         # Return True to allow for "assert excinfo.match()".
         return True
 
 
-@attr.s
+@dataclasses.dataclass
 class FormattedExcinfo:
     """Presenting information about failing Functions and Generators."""
 
     # for traceback entries
-    flow_marker = ">"
-    fail_marker = "E"
-
-    showlocals = attr.ib(type=bool, default=False)
-    style = attr.ib(type="_TracebackStyle", default="long")
-    abspath = attr.ib(type=bool, default=True)
-    tbfilter = attr.ib(type=bool, default=True)
-    funcargs = attr.ib(type=bool, default=False)
-    truncate_locals = attr.ib(type=bool, default=True)
-    chain = attr.ib(type=bool, default=True)
-    astcache = attr.ib(default=attr.Factory(dict), init=False, repr=False)
+    flow_marker: ClassVar = ">"
+    fail_marker: ClassVar = "E"
+
+    showlocals: bool = False
+    style: "_TracebackStyle" = "long"
+    abspath: bool = True
+    tbfilter: Union[bool, Callable[[ExceptionInfo[BaseException]], Traceback]] = True
+    funcargs: bool = False
+    truncate_locals: bool = True
+    chain: bool = True
+    astcache: Dict[Union[str, Path], ast.AST] = dataclasses.field(
+        default_factory=dict, init=False, repr=False
+    )
 
     def _getindent(self, source: "Source") -> int:
         # Figure out indent for the given source.
@@ -717,11 +773,13 @@ class FormattedExcinfo:
     ) -> List[str]:
         """Return formatted and marked up source lines."""
         lines = []
-        if source is None or line_index >= len(source.lines):
+        if source is not None and line_index < 0:
+            line_index += len(source)
+        if source is None or line_index >= len(source.lines) or line_index < 0:
+            # `line_index` could still be outside `range(len(source.lines))` if
+            # we're processing AST with pathological position attributes.
             source = Source("???")
             line_index = 0
-        if line_index < 0:
-            line_index += len(source)
         space_prefix = "    "
         if short:
             lines.append(space_prefix + source.lines[line_index].strip())
@@ -781,12 +839,16 @@ class FormattedExcinfo:
 
     def repr_traceback_entry(
         self,
-        entry: TracebackEntry,
+        entry: Optional[TracebackEntry],
         excinfo: Optional[ExceptionInfo[BaseException]] = None,
     ) -> "ReprEntry":
         lines: List[str] = []
-        style = entry._repr_style if entry._repr_style is not None else self.style
-        if style in ("short", "long"):
+        style = (
+            entry._repr_style
+            if entry is not None and entry._repr_style is not None
+            else self.style
+        )
+        if style in ("short", "long") and entry is not None:
             source = self._getentrysource(entry)
             if source is None:
                 source = Source("???")
@@ -801,7 +863,8 @@ class FormattedExcinfo:
                 message = "in %s" % (entry.name)
             else:
                 message = excinfo and excinfo.typename or ""
-            path = self._makepath(entry.path)
+            entry_path = entry.path
+            path = self._makepath(entry_path)
             reprfileloc = ReprFileLocation(path, entry.lineno + 1, message)
             localsrepr = self.repr_locals(entry.locals)
             return ReprEntry(lines, reprargs, localsrepr, reprfileloc, style)
@@ -814,37 +877,43 @@ class FormattedExcinfo:
                 lines.extend(self.get_exconly(excinfo, indent=4))
             return ReprEntry(lines, None, None, None, style)
 
-    def _makepath(self, path):
-        if not self.abspath:
+    def _makepath(self, path: Union[Path, str]) -> str:
+        if not self.abspath and isinstance(path, Path):
             try:
-                np = py.path.local().bestrelpath(path)
+                np = bestrelpath(Path.cwd(), path)
             except OSError:
-                return path
+                return str(path)
             if len(np) < len(str(path)):
-                path = np
-        return path
+                return np
+        return str(path)
 
     def repr_traceback(self, excinfo: ExceptionInfo[BaseException]) -> "ReprTraceback":
         traceback = excinfo.traceback
-        if self.tbfilter:
-            traceback = traceback.filter()
+        if callable(self.tbfilter):
+            traceback = self.tbfilter(excinfo)
+        elif self.tbfilter:
+            traceback = traceback.filter(excinfo)
 
         if isinstance(excinfo.value, RecursionError):
             traceback, extraline = self._truncate_recursive_traceback(traceback)
         else:
             extraline = None
 
+        if not traceback:
+            if extraline is None:
+                extraline = "All traceback entries are hidden. Pass `--full-trace` to see hidden and internal frames."
+            entries = [self.repr_traceback_entry(None, excinfo)]
+            return ReprTraceback(entries, extraline, style=self.style)
+
         last = traceback[-1]
-        entries = []
         if self.style == "value":
-            reprentry = self.repr_traceback_entry(last, excinfo)
-            entries.append(reprentry)
+            entries = [self.repr_traceback_entry(last, excinfo)]
             return ReprTraceback(entries, None, style=self.style)
 
-        for index, entry in enumerate(traceback):
-            einfo = (last == entry) and excinfo or None
-            reprentry = self.repr_traceback_entry(entry, einfo)
-            entries.append(reprentry)
+        entries = [
+            self.repr_traceback_entry(entry, excinfo if last == entry else None)
+            for entry in traceback
+        ]
         return ReprTraceback(entries, extraline, style=self.style)
 
     def _truncate_recursive_traceback(
@@ -877,7 +946,7 @@ class FormattedExcinfo:
                 max_frames=max_frames,
                 total=len(traceback),
             )
-            # Type ignored because adding two instaces of a List subtype
+            # Type ignored because adding two instances of a List subtype
             # currently incorrectly has type List instead of the subtype.
             traceback = traceback[:max_frames] + traceback[-max_frames:]  # type: ignore
         else:
@@ -901,11 +970,24 @@ class FormattedExcinfo:
         seen: Set[int] = set()
         while e is not None and id(e) not in seen:
             seen.add(id(e))
+
             if excinfo_:
-                reprtraceback = self.repr_traceback(excinfo_)
-                reprcrash: Optional[ReprFileLocation] = (
-                    excinfo_._getreprcrash() if self.style != "value" else None
-                )
+                # Fall back to native traceback as a temporary workaround until
+                # full support for exception groups added to ExceptionInfo.
+                # See https://github.com/pytest-dev/pytest/issues/9159
+                if isinstance(e, BaseExceptionGroup):
+                    reprtraceback: Union[
+                        ReprTracebackNative, ReprTraceback
+                    ] = ReprTracebackNative(
+                        traceback.format_exception(
+                            type(excinfo_.value),
+                            excinfo_.value,
+                            excinfo_.traceback[0]._rawentry,
+                        )
+                    )
+                else:
+                    reprtraceback = self.repr_traceback(excinfo_)
+                reprcrash = excinfo_._getreprcrash()
             else:
                 # Fallback to native repr if the exception doesn't have a traceback:
                 # ExceptionInfo objects require a full traceback to work.
@@ -913,25 +995,17 @@ class FormattedExcinfo:
                     traceback.format_exception(type(e), e, None)
                 )
                 reprcrash = None
-
             repr_chain += [(reprtraceback, reprcrash, descr)]
+
             if e.__cause__ is not None and self.chain:
                 e = e.__cause__
-                excinfo_ = (
-                    ExceptionInfo((type(e), e, e.__traceback__))
-                    if e.__traceback__
-                    else None
-                )
+                excinfo_ = ExceptionInfo.from_exception(e) if e.__traceback__ else None
                 descr = "The above exception was the direct cause of the following exception:"
             elif (
                 e.__context__ is not None and not e.__suppress_context__ and self.chain
             ):
                 e = e.__context__
-                excinfo_ = (
-                    ExceptionInfo((type(e), e, e.__traceback__))
-                    if e.__traceback__
-                    else None
-                )
+                excinfo_ = ExceptionInfo.from_exception(e) if e.__traceback__ else None
                 descr = "During handling of the above exception, another exception occurred:"
             else:
                 e = None
@@ -939,7 +1013,7 @@ class FormattedExcinfo:
         return ExceptionChainRepr(repr_chain)
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class TerminalRepr:
     def __str__(self) -> str:
         # FYI this is called from pytest-xdist's serialization of exception
@@ -950,21 +1024,21 @@ class TerminalRepr:
         return io.getvalue().strip()
 
     def __repr__(self) -> str:
-        return "<{} instance at {:0x}>".format(self.__class__, id(self))
+        return f"<{self.__class__} instance at {id(self):0x}>"
 
     def toterminal(self, tw: TerminalWriter) -> None:
         raise NotImplementedError()
 
 
 # This class is abstract -- only subclasses are instantiated.
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ExceptionRepr(TerminalRepr):
     # Provided by subclasses.
-    reprcrash: Optional["ReprFileLocation"]
     reprtraceback: "ReprTraceback"
-
-    def __attrs_post_init__(self) -> None:
-        self.sections: List[Tuple[str, str, str]] = []
+    reprcrash: Optional["ReprFileLocation"]
+    sections: List[Tuple[str, str, str]] = dataclasses.field(
+        init=False, default_factory=list
+    )
 
     def addsection(self, name: str, content: str, sep: str = "-") -> None:
         self.sections.append((name, content, sep))
@@ -975,20 +1049,23 @@ class ExceptionRepr(TerminalRepr):
             tw.line(content)
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ExceptionChainRepr(ExceptionRepr):
-    chain = attr.ib(
-        type=Sequence[
-            Tuple["ReprTraceback", Optional["ReprFileLocation"], Optional[str]]
-        ]
-    )
+    chain: Sequence[Tuple["ReprTraceback", Optional["ReprFileLocation"], Optional[str]]]
 
-    def __attrs_post_init__(self) -> None:
-        super().__attrs_post_init__()
+    def __init__(
+        self,
+        chain: Sequence[
+            Tuple["ReprTraceback", Optional["ReprFileLocation"], Optional[str]]
+        ],
+    ) -> None:
         # reprcrash and reprtraceback of the outermost (the newest) exception
         # in the chain.
-        self.reprtraceback = self.chain[-1][0]
-        self.reprcrash = self.chain[-1][1]
+        super().__init__(
+            reprtraceback=chain[-1][0],
+            reprcrash=chain[-1][1],
+        )
+        self.chain = chain
 
     def toterminal(self, tw: TerminalWriter) -> None:
         for element in self.chain:
@@ -999,23 +1076,23 @@ class ExceptionChainRepr(ExceptionRepr):
         super().toterminal(tw)
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprExceptionInfo(ExceptionRepr):
-    reprtraceback = attr.ib(type="ReprTraceback")
-    reprcrash = attr.ib(type="ReprFileLocation")
+    reprtraceback: "ReprTraceback"
+    reprcrash: Optional["ReprFileLocation"]
 
     def toterminal(self, tw: TerminalWriter) -> None:
         self.reprtraceback.toterminal(tw)
         super().toterminal(tw)
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprTraceback(TerminalRepr):
-    reprentries = attr.ib(type=Sequence[Union["ReprEntry", "ReprEntryNative"]])
-    extraline = attr.ib(type=Optional[str])
-    style = attr.ib(type="_TracebackStyle")
+    reprentries: Sequence[Union["ReprEntry", "ReprEntryNative"]]
+    extraline: Optional[str]
+    style: "_TracebackStyle"
 
-    entrysep = "_ "
+    entrysep: ClassVar = "_ "
 
     def toterminal(self, tw: TerminalWriter) -> None:
         # The entries might have different styles.
@@ -1038,27 +1115,28 @@ class ReprTraceback(TerminalRepr):
 
 class ReprTracebackNative(ReprTraceback):
     def __init__(self, tblines: Sequence[str]) -> None:
-        self.style = "native"
         self.reprentries = [ReprEntryNative(tblines)]
         self.extraline = None
+        self.style = "native"
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprEntryNative(TerminalRepr):
-    lines = attr.ib(type=Sequence[str])
-    style: "_TracebackStyle" = "native"
+    lines: Sequence[str]
+
+    style: ClassVar["_TracebackStyle"] = "native"
 
     def toterminal(self, tw: TerminalWriter) -> None:
         tw.write("".join(self.lines))
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprEntry(TerminalRepr):
-    lines = attr.ib(type=Sequence[str])
-    reprfuncargs = attr.ib(type=Optional["ReprFuncArgs"])
-    reprlocals = attr.ib(type=Optional["ReprLocals"])
-    reprfileloc = attr.ib(type=Optional["ReprFileLocation"])
-    style = attr.ib(type="_TracebackStyle")
+    lines: Sequence[str]
+    reprfuncargs: Optional["ReprFuncArgs"]
+    reprlocals: Optional["ReprLocals"]
+    reprfileloc: Optional["ReprFileLocation"]
+    style: "_TracebackStyle"
 
     def _write_entry_lines(self, tw: TerminalWriter) -> None:
         """Write the source code portions of a list of traceback entries with syntax highlighting.
@@ -1106,8 +1184,8 @@ class ReprEntry(TerminalRepr):
 
     def toterminal(self, tw: TerminalWriter) -> None:
         if self.style == "short":
-            assert self.reprfileloc is not None
-            self.reprfileloc.toterminal(tw)
+            if self.reprfileloc:
+                self.reprfileloc.toterminal(tw)
             self._write_entry_lines(tw)
             if self.reprlocals:
                 self.reprlocals.toterminal(tw, indent=" " * 8)
@@ -1132,11 +1210,14 @@ class ReprEntry(TerminalRepr):
         )
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprFileLocation(TerminalRepr):
-    path = attr.ib(type=str, converter=str)
-    lineno = attr.ib(type=int)
-    message = attr.ib(type=str)
+    path: str
+    lineno: int
+    message: str
+
+    def __post_init__(self) -> None:
+        self.path = str(self.path)
 
     def toterminal(self, tw: TerminalWriter) -> None:
         # Filename and lineno output for each entry, using an output format
@@ -1149,18 +1230,18 @@ class ReprFileLocation(TerminalRepr):
         tw.line(f":{self.lineno}: {msg}")
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprLocals(TerminalRepr):
-    lines = attr.ib(type=Sequence[str])
+    lines: Sequence[str]
 
     def toterminal(self, tw: TerminalWriter, indent="") -> None:
         for line in self.lines:
             tw.line(indent + line)
 
 
-@attr.s(eq=False)
+@dataclasses.dataclass(eq=False)
 class ReprFuncArgs(TerminalRepr):
-    args = attr.ib(type=Sequence[Tuple[str, object]])
+    args: Sequence[Tuple[str, object]]
 
     def toterminal(self, tw: TerminalWriter) -> None:
         if self.args:
@@ -1181,7 +1262,7 @@ class ReprFuncArgs(TerminalRepr):
             tw.line("")
 
 
-def getfslineno(obj: object) -> Tuple[Union[str, py.path.local], int]:
+def getfslineno(obj: object) -> Tuple[Union[str, Path], int]:
     """Return source location (path, lineno) for the given object.
 
     If the source cannot be determined return ("", -1).
@@ -1203,7 +1284,7 @@ def getfslineno(obj: object) -> Tuple[Union[str, py.path.local], int]:
         except TypeError:
             return "", -1
 
-        fspath = fn and py.path.local(fn) or ""
+        fspath = fn and absolutepath(fn) or ""
         lineno = -1
         if fspath:
             try:
@@ -1225,7 +1306,6 @@ _PLUGGY_DIR = Path(pluggy.__file__.rstrip("oc"))
 if _PLUGGY_DIR.name == "__init__.py":
     _PLUGGY_DIR = _PLUGGY_DIR.parent
 _PYTEST_DIR = Path(_pytest.__file__).parent
-_PY_DIR = Path(py.__file__).parent
 
 
 def filter_traceback(entry: TracebackEntry) -> bool:
@@ -1253,7 +1333,5 @@ def filter_traceback(entry: TracebackEntry) -> bool:
         return False
     if _PYTEST_DIR in parents:
         return False
-    if _PY_DIR in parents:
-        return False
 
     return True
index 6f54057c0a9827f83b8f66b08cca011401baa199..208cfb80037a807f81bbb70229c25990c42bb011 100644 (file)
@@ -149,6 +149,11 @@ def get_statement_startend2(lineno: int, node: ast.AST) -> Tuple[int, Optional[i
     values: List[int] = []
     for x in ast.walk(node):
         if isinstance(x, (ast.stmt, ast.ExceptHandler)):
+            # Before Python 3.8, the lineno of a decorated class or function pointed at the decorator.
+            # Since Python 3.8, the lineno points to the class/def, so need to include the decorators.
+            if isinstance(x, (ast.ClassDef, ast.FunctionDef, ast.AsyncFunctionDef)):
+                for d in x.decorator_list:
+                    values.append(d.lineno - 1)
             values.append(x.lineno - 1)
             for name in ("finalbody", "orelse"):
                 val: Optional[List[ast.stmt]] = getattr(x, name, None)
index 5eb1e088905bdda7603aa42ba275c0b28b606d53..c701872238c19318fd211d5c1f6b4d6f76edb3ab 100644 (file)
@@ -12,7 +12,7 @@ def _try_repr_or_str(obj: object) -> str:
     except (KeyboardInterrupt, SystemExit):
         raise
     except BaseException:
-        return '{}("{}")'.format(type(obj).__name__, obj)
+        return f'{type(obj).__name__}("{obj}")'
 
 
 def _format_repr_exception(exc: BaseException, obj: object) -> str:
@@ -21,7 +21,7 @@ def _format_repr_exception(exc: BaseException, obj: object) -> str:
     except (KeyboardInterrupt, SystemExit):
         raise
     except BaseException as exc:
-        exc_info = "unpresentable exception ({})".format(_try_repr_or_str(exc))
+        exc_info = f"unpresentable exception ({_try_repr_or_str(exc)})"
     return "<[{} raised in repr()] {} object at 0x{:x}>".format(
         exc_info, type(obj).__name__, id(obj)
     )
@@ -36,22 +36,40 @@ def _ellipsize(s: str, maxsize: int) -> str:
 
 
 class SafeRepr(reprlib.Repr):
-    """repr.Repr that limits the resulting size of repr() and includes
-    information on exceptions raised during the call."""
+    """
+    repr.Repr that limits the resulting size of repr() and includes
+    information on exceptions raised during the call.
+    """
 
-    def __init__(self, maxsize: int) -> None:
+    def __init__(self, maxsize: Optional[int], use_ascii: bool = False) -> None:
+        """
+        :param maxsize:
+            If not None, will truncate the resulting repr to that specific size, using ellipsis
+            somewhere in the middle to hide the extra text.
+            If None, will not impose any size limits on the returning repr.
+        """
         super().__init__()
-        self.maxstring = maxsize
+        # ``maxstring`` is used by the superclass, and needs to be an int; using a
+        # very large number in case maxsize is None, meaning we want to disable
+        # truncation.
+        self.maxstring = maxsize if maxsize is not None else 1_000_000_000
         self.maxsize = maxsize
+        self.use_ascii = use_ascii
 
     def repr(self, x: object) -> str:
         try:
-            s = super().repr(x)
+            if self.use_ascii:
+                s = ascii(x)
+            else:
+                s = super().repr(x)
+
         except (KeyboardInterrupt, SystemExit):
             raise
         except BaseException as exc:
             s = _format_repr_exception(exc, x)
-        return _ellipsize(s, self.maxsize)
+        if self.maxsize is not None:
+            s = _ellipsize(s, self.maxsize)
+        return s
 
     def repr_instance(self, x: object, level: int) -> str:
         try:
@@ -60,7 +78,9 @@ class SafeRepr(reprlib.Repr):
             raise
         except BaseException as exc:
             s = _format_repr_exception(exc, x)
-        return _ellipsize(s, self.maxsize)
+        if self.maxsize is not None:
+            s = _ellipsize(s, self.maxsize)
+        return s
 
 
 def safeformat(obj: object) -> str:
@@ -75,7 +95,13 @@ def safeformat(obj: object) -> str:
         return _format_repr_exception(exc, obj)
 
 
-def saferepr(obj: object, maxsize: int = 240) -> str:
+# Maximum size of overall repr of objects to display during assertion errors.
+DEFAULT_REPR_MAX_SIZE = 240
+
+
+def saferepr(
+    obj: object, maxsize: Optional[int] = DEFAULT_REPR_MAX_SIZE, use_ascii: bool = False
+) -> str:
     """Return a size-limited safe repr-string for the given object.
 
     Failing __repr__ functions of user instances will be represented
@@ -83,9 +109,29 @@ def saferepr(obj: object, maxsize: int = 240) -> str:
     care to never raise exceptions itself.
 
     This function is a wrapper around the Repr/reprlib functionality of the
-    standard 2.6 lib.
+    stdlib.
     """
-    return SafeRepr(maxsize).repr(obj)
+
+    return SafeRepr(maxsize, use_ascii).repr(obj)
+
+
+def saferepr_unlimited(obj: object, use_ascii: bool = True) -> str:
+    """Return an unlimited-size safe repr-string for the given object.
+
+    As with saferepr, failing __repr__ functions of user instances
+    will be represented with a short exception info.
+
+    This function is a wrapper around simple repr.
+
+    Note: a cleaner solution would be to alter ``saferepr``this way
+    when maxsize=None, but that might affect some other code.
+    """
+    try:
+        if use_ascii:
+            return ascii(obj)
+        return repr(obj)
+    except Exception as exc:
+        return _format_repr_exception(exc, obj)
 
 
 class AlwaysDispatchingPrettyPrinter(pprint.PrettyPrinter):
@@ -107,7 +153,12 @@ class AlwaysDispatchingPrettyPrinter(pprint.PrettyPrinter):
         if objid in context or p is None:
             # Type ignored because _format is private.
             super()._format(  # type: ignore[misc]
-                object, stream, indent, allowance, context, level,
+                object,
+                stream,
+                indent,
+                allowance,
+                context,
+                level,
             )
             return
 
index 8edf4cd75fa91b69317556ea4bb5da6522d21d84..379035d858c92b405c02d13a2bd254ce131d2e5e 100644 (file)
@@ -195,16 +195,39 @@ class TerminalWriter:
 
     def _highlight(self, source: str) -> str:
         """Highlight the given source code if we have markup support."""
+        from _pytest.config.exceptions import UsageError
+
         if not self.hasmarkup or not self.code_highlight:
             return source
         try:
             from pygments.formatters.terminal import TerminalFormatter
             from pygments.lexers.python import PythonLexer
             from pygments import highlight
+            import pygments.util
         except ImportError:
             return source
         else:
-            highlighted: str = highlight(
-                source, PythonLexer(), TerminalFormatter(bg="dark")
-            )
-            return highlighted
+            try:
+                highlighted: str = highlight(
+                    source,
+                    PythonLexer(),
+                    TerminalFormatter(
+                        bg=os.getenv("PYTEST_THEME_MODE", "dark"),
+                        style=os.getenv("PYTEST_THEME"),
+                    ),
+                )
+                return highlighted
+            except pygments.util.ClassNotFound:
+                raise UsageError(
+                    "PYTEST_THEME environment variable had an invalid value: '{}'. "
+                    "Only valid pygment styles are allowed.".format(
+                        os.getenv("PYTEST_THEME")
+                    )
+                )
+            except pygments.util.OptionError:
+                raise UsageError(
+                    "PYTEST_THEME_MODE environment variable had an invalid value: '{}'. "
+                    "The only allowed values are 'dark' and 'light'.".format(
+                        os.getenv("PYTEST_THEME_MODE")
+                    )
+                )
diff --git a/src/_pytest/_py/__init__.py b/src/_pytest/_py/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/_pytest/_py/error.py b/src/_pytest/_py/error.py
new file mode 100644 (file)
index 0000000..0b8f2d5
--- /dev/null
@@ -0,0 +1,109 @@
+"""create errno-specific classes for IO or os calls."""
+from __future__ import annotations
+
+import errno
+import os
+import sys
+from typing import Callable
+from typing import TYPE_CHECKING
+from typing import TypeVar
+
+if TYPE_CHECKING:
+    from typing_extensions import ParamSpec
+
+    P = ParamSpec("P")
+
+R = TypeVar("R")
+
+
+class Error(EnvironmentError):
+    def __repr__(self) -> str:
+        return "{}.{} {!r}: {} ".format(
+            self.__class__.__module__,
+            self.__class__.__name__,
+            self.__class__.__doc__,
+            " ".join(map(str, self.args)),
+            # repr(self.args)
+        )
+
+    def __str__(self) -> str:
+        s = "[{}]: {}".format(
+            self.__class__.__doc__,
+            " ".join(map(str, self.args)),
+        )
+        return s
+
+
+_winerrnomap = {
+    2: errno.ENOENT,
+    3: errno.ENOENT,
+    17: errno.EEXIST,
+    18: errno.EXDEV,
+    13: errno.EBUSY,  # empty cd drive, but ENOMEDIUM seems unavailiable
+    22: errno.ENOTDIR,
+    20: errno.ENOTDIR,
+    267: errno.ENOTDIR,
+    5: errno.EACCES,  # anything better?
+}
+
+
+class ErrorMaker:
+    """lazily provides Exception classes for each possible POSIX errno
+    (as defined per the 'errno' module).  All such instances
+    subclass EnvironmentError.
+    """
+
+    _errno2class: dict[int, type[Error]] = {}
+
+    def __getattr__(self, name: str) -> type[Error]:
+        if name[0] == "_":
+            raise AttributeError(name)
+        eno = getattr(errno, name)
+        cls = self._geterrnoclass(eno)
+        setattr(self, name, cls)
+        return cls
+
+    def _geterrnoclass(self, eno: int) -> type[Error]:
+        try:
+            return self._errno2class[eno]
+        except KeyError:
+            clsname = errno.errorcode.get(eno, "UnknownErrno%d" % (eno,))
+            errorcls = type(
+                clsname,
+                (Error,),
+                {"__module__": "py.error", "__doc__": os.strerror(eno)},
+            )
+            self._errno2class[eno] = errorcls
+            return errorcls
+
+    def checked_call(
+        self, func: Callable[P, R], *args: P.args, **kwargs: P.kwargs
+    ) -> R:
+        """Call a function and raise an errno-exception if applicable."""
+        __tracebackhide__ = True
+        try:
+            return func(*args, **kwargs)
+        except Error:
+            raise
+        except OSError as value:
+            if not hasattr(value, "errno"):
+                raise
+            errno = value.errno
+            if sys.platform == "win32":
+                try:
+                    cls = self._geterrnoclass(_winerrnomap[errno])
+                except KeyError:
+                    raise value
+            else:
+                # we are not on Windows, or we got a proper OSError
+                cls = self._geterrnoclass(errno)
+
+            raise cls(f"{func.__name__}{args!r}")
+
+
+_error_maker = ErrorMaker()
+checked_call = _error_maker.checked_call
+
+
+def __getattr__(attr: str) -> type[Error]:
+    return getattr(_error_maker, attr)  # type: ignore[no-any-return]
diff --git a/src/_pytest/_py/path.py b/src/_pytest/_py/path.py
new file mode 100644 (file)
index 0000000..73a070d
--- /dev/null
@@ -0,0 +1,1475 @@
+"""local path implementation."""
+from __future__ import annotations
+
+import atexit
+import fnmatch
+import importlib.util
+import io
+import os
+import posixpath
+import sys
+import uuid
+import warnings
+from contextlib import contextmanager
+from os.path import abspath
+from os.path import dirname
+from os.path import exists
+from os.path import isabs
+from os.path import isdir
+from os.path import isfile
+from os.path import islink
+from os.path import normpath
+from stat import S_ISDIR
+from stat import S_ISLNK
+from stat import S_ISREG
+from typing import Any
+from typing import Callable
+from typing import cast
+from typing import overload
+from typing import TYPE_CHECKING
+
+from . import error
+
+if TYPE_CHECKING:
+    from typing import Literal
+
+# Moved from local.py.
+iswin32 = sys.platform == "win32" or (getattr(os, "_name", False) == "nt")
+
+
+class Checkers:
+    _depend_on_existence = "exists", "link", "dir", "file"
+
+    def __init__(self, path):
+        self.path = path
+
+    def dotfile(self):
+        return self.path.basename.startswith(".")
+
+    def ext(self, arg):
+        if not arg.startswith("."):
+            arg = "." + arg
+        return self.path.ext == arg
+
+    def basename(self, arg):
+        return self.path.basename == arg
+
+    def basestarts(self, arg):
+        return self.path.basename.startswith(arg)
+
+    def relto(self, arg):
+        return self.path.relto(arg)
+
+    def fnmatch(self, arg):
+        return self.path.fnmatch(arg)
+
+    def endswith(self, arg):
+        return str(self.path).endswith(arg)
+
+    def _evaluate(self, kw):
+        from .._code.source import getrawcode
+
+        for name, value in kw.items():
+            invert = False
+            meth = None
+            try:
+                meth = getattr(self, name)
+            except AttributeError:
+                if name[:3] == "not":
+                    invert = True
+                    try:
+                        meth = getattr(self, name[3:])
+                    except AttributeError:
+                        pass
+            if meth is None:
+                raise TypeError(f"no {name!r} checker available for {self.path!r}")
+            try:
+                if getrawcode(meth).co_argcount > 1:
+                    if (not meth(value)) ^ invert:
+                        return False
+                else:
+                    if bool(value) ^ bool(meth()) ^ invert:
+                        return False
+            except (error.ENOENT, error.ENOTDIR, error.EBUSY):
+                # EBUSY feels not entirely correct,
+                # but its kind of necessary since ENOMEDIUM
+                # is not accessible in python
+                for name in self._depend_on_existence:
+                    if name in kw:
+                        if kw.get(name):
+                            return False
+                    name = "not" + name
+                    if name in kw:
+                        if not kw.get(name):
+                            return False
+        return True
+
+    _statcache: Stat
+
+    def _stat(self) -> Stat:
+        try:
+            return self._statcache
+        except AttributeError:
+            try:
+                self._statcache = self.path.stat()
+            except error.ELOOP:
+                self._statcache = self.path.lstat()
+            return self._statcache
+
+    def dir(self):
+        return S_ISDIR(self._stat().mode)
+
+    def file(self):
+        return S_ISREG(self._stat().mode)
+
+    def exists(self):
+        return self._stat()
+
+    def link(self):
+        st = self.path.lstat()
+        return S_ISLNK(st.mode)
+
+
+class NeverRaised(Exception):
+    pass
+
+
+class Visitor:
+    def __init__(self, fil, rec, ignore, bf, sort):
+        if isinstance(fil, str):
+            fil = FNMatcher(fil)
+        if isinstance(rec, str):
+            self.rec: Callable[[LocalPath], bool] = FNMatcher(rec)
+        elif not hasattr(rec, "__call__") and rec:
+            self.rec = lambda path: True
+        else:
+            self.rec = rec
+        self.fil = fil
+        self.ignore = ignore
+        self.breadthfirst = bf
+        self.optsort = cast(Callable[[Any], Any], sorted) if sort else (lambda x: x)
+
+    def gen(self, path):
+        try:
+            entries = path.listdir()
+        except self.ignore:
+            return
+        rec = self.rec
+        dirs = self.optsort(
+            [p for p in entries if p.check(dir=1) and (rec is None or rec(p))]
+        )
+        if not self.breadthfirst:
+            for subdir in dirs:
+                for p in self.gen(subdir):
+                    yield p
+        for p in self.optsort(entries):
+            if self.fil is None or self.fil(p):
+                yield p
+        if self.breadthfirst:
+            for subdir in dirs:
+                for p in self.gen(subdir):
+                    yield p
+
+
+class FNMatcher:
+    def __init__(self, pattern):
+        self.pattern = pattern
+
+    def __call__(self, path):
+        pattern = self.pattern
+
+        if (
+            pattern.find(path.sep) == -1
+            and iswin32
+            and pattern.find(posixpath.sep) != -1
+        ):
+            # Running on Windows, the pattern has no Windows path separators,
+            # and the pattern has one or more Posix path separators. Replace
+            # the Posix path separators with the Windows path separator.
+            pattern = pattern.replace(posixpath.sep, path.sep)
+
+        if pattern.find(path.sep) == -1:
+            name = path.basename
+        else:
+            name = str(path)  # path.strpath # XXX svn?
+            if not os.path.isabs(pattern):
+                pattern = "*" + path.sep + pattern
+        return fnmatch.fnmatch(name, pattern)
+
+
+def map_as_list(func, iter):
+    return list(map(func, iter))
+
+
+class Stat:
+    if TYPE_CHECKING:
+
+        @property
+        def size(self) -> int:
+            ...
+
+        @property
+        def mtime(self) -> float:
+            ...
+
+    def __getattr__(self, name: str) -> Any:
+        return getattr(self._osstatresult, "st_" + name)
+
+    def __init__(self, path, osstatresult):
+        self.path = path
+        self._osstatresult = osstatresult
+
+    @property
+    def owner(self):
+        if iswin32:
+            raise NotImplementedError("XXX win32")
+        import pwd
+
+        entry = error.checked_call(pwd.getpwuid, self.uid)  # type:ignore[attr-defined]
+        return entry[0]
+
+    @property
+    def group(self):
+        """Return group name of file."""
+        if iswin32:
+            raise NotImplementedError("XXX win32")
+        import grp
+
+        entry = error.checked_call(grp.getgrgid, self.gid)  # type:ignore[attr-defined]
+        return entry[0]
+
+    def isdir(self):
+        return S_ISDIR(self._osstatresult.st_mode)
+
+    def isfile(self):
+        return S_ISREG(self._osstatresult.st_mode)
+
+    def islink(self):
+        self.path.lstat()
+        return S_ISLNK(self._osstatresult.st_mode)
+
+
+def getuserid(user):
+    import pwd
+
+    if not isinstance(user, int):
+        user = pwd.getpwnam(user)[2]  # type:ignore[attr-defined]
+    return user
+
+
+def getgroupid(group):
+    import grp
+
+    if not isinstance(group, int):
+        group = grp.getgrnam(group)[2]  # type:ignore[attr-defined]
+    return group
+
+
+class LocalPath:
+    """Object oriented interface to os.path and other local filesystem
+    related information.
+    """
+
+    class ImportMismatchError(ImportError):
+        """raised on pyimport() if there is a mismatch of __file__'s"""
+
+    sep = os.sep
+
+    def __init__(self, path=None, expanduser=False):
+        """Initialize and return a local Path instance.
+
+        Path can be relative to the current directory.
+        If path is None it defaults to the current working directory.
+        If expanduser is True, tilde-expansion is performed.
+        Note that Path instances always carry an absolute path.
+        Note also that passing in a local path object will simply return
+        the exact same path object. Use new() to get a new copy.
+        """
+        if path is None:
+            self.strpath = error.checked_call(os.getcwd)
+        else:
+            try:
+                path = os.fspath(path)
+            except TypeError:
+                raise ValueError(
+                    "can only pass None, Path instances "
+                    "or non-empty strings to LocalPath"
+                )
+            if expanduser:
+                path = os.path.expanduser(path)
+            self.strpath = abspath(path)
+
+    if sys.platform != "win32":
+
+        def chown(self, user, group, rec=0):
+            """Change ownership to the given user and group.
+            user and group may be specified by a number or
+            by a name.  if rec is True change ownership
+            recursively.
+            """
+            uid = getuserid(user)
+            gid = getgroupid(group)
+            if rec:
+                for x in self.visit(rec=lambda x: x.check(link=0)):
+                    if x.check(link=0):
+                        error.checked_call(os.chown, str(x), uid, gid)
+            error.checked_call(os.chown, str(self), uid, gid)
+
+        def readlink(self) -> str:
+            """Return value of a symbolic link."""
+            # https://github.com/python/mypy/issues/12278
+            return error.checked_call(os.readlink, self.strpath)  # type: ignore[arg-type,return-value]
+
+        def mklinkto(self, oldname):
+            """Posix style hard link to another name."""
+            error.checked_call(os.link, str(oldname), str(self))
+
+        def mksymlinkto(self, value, absolute=1):
+            """Create a symbolic link with the given value (pointing to another name)."""
+            if absolute:
+                error.checked_call(os.symlink, str(value), self.strpath)
+            else:
+                base = self.common(value)
+                # with posix local paths '/' is always a common base
+                relsource = self.__class__(value).relto(base)
+                reldest = self.relto(base)
+                n = reldest.count(self.sep)
+                target = self.sep.join(("..",) * n + (relsource,))
+                error.checked_call(os.symlink, target, self.strpath)
+
+    def __div__(self, other):
+        return self.join(os.fspath(other))
+
+    __truediv__ = __div__  # py3k
+
+    @property
+    def basename(self):
+        """Basename part of path."""
+        return self._getbyspec("basename")[0]
+
+    @property
+    def dirname(self):
+        """Dirname part of path."""
+        return self._getbyspec("dirname")[0]
+
+    @property
+    def purebasename(self):
+        """Pure base name of the path."""
+        return self._getbyspec("purebasename")[0]
+
+    @property
+    def ext(self):
+        """Extension of the path (including the '.')."""
+        return self._getbyspec("ext")[0]
+
+    def read_binary(self):
+        """Read and return a bytestring from reading the path."""
+        with self.open("rb") as f:
+            return f.read()
+
+    def read_text(self, encoding):
+        """Read and return a Unicode string from reading the path."""
+        with self.open("r", encoding=encoding) as f:
+            return f.read()
+
+    def read(self, mode="r"):
+        """Read and return a bytestring from reading the path."""
+        with self.open(mode) as f:
+            return f.read()
+
+    def readlines(self, cr=1):
+        """Read and return a list of lines from the path. if cr is False, the
+        newline will be removed from the end of each line."""
+        mode = "r"
+
+        if not cr:
+            content = self.read(mode)
+            return content.split("\n")
+        else:
+            f = self.open(mode)
+            try:
+                return f.readlines()
+            finally:
+                f.close()
+
+    def load(self):
+        """(deprecated) return object unpickled from self.read()"""
+        f = self.open("rb")
+        try:
+            import pickle
+
+            return error.checked_call(pickle.load, f)
+        finally:
+            f.close()
+
+    def move(self, target):
+        """Move this path to target."""
+        if target.relto(self):
+            raise error.EINVAL(target, "cannot move path into a subdirectory of itself")
+        try:
+            self.rename(target)
+        except error.EXDEV:  # invalid cross-device link
+            self.copy(target)
+            self.remove()
+
+    def fnmatch(self, pattern):
+        """Return true if the basename/fullname matches the glob-'pattern'.
+
+        valid pattern characters::
+
+            *       matches everything
+            ?       matches any single character
+            [seq]   matches any character in seq
+            [!seq]  matches any char not in seq
+
+        If the pattern contains a path-separator then the full path
+        is used for pattern matching and a '*' is prepended to the
+        pattern.
+
+        if the pattern doesn't contain a path-separator the pattern
+        is only matched against the basename.
+        """
+        return FNMatcher(pattern)(self)
+
+    def relto(self, relpath):
+        """Return a string which is the relative part of the path
+        to the given 'relpath'.
+        """
+        if not isinstance(relpath, (str, LocalPath)):
+            raise TypeError(f"{relpath!r}: not a string or path object")
+        strrelpath = str(relpath)
+        if strrelpath and strrelpath[-1] != self.sep:
+            strrelpath += self.sep
+        # assert strrelpath[-1] == self.sep
+        # assert strrelpath[-2] != self.sep
+        strself = self.strpath
+        if sys.platform == "win32" or getattr(os, "_name", None) == "nt":
+            if os.path.normcase(strself).startswith(os.path.normcase(strrelpath)):
+                return strself[len(strrelpath) :]
+        elif strself.startswith(strrelpath):
+            return strself[len(strrelpath) :]
+        return ""
+
+    def ensure_dir(self, *args):
+        """Ensure the path joined with args is a directory."""
+        return self.ensure(*args, **{"dir": True})
+
+    def bestrelpath(self, dest):
+        """Return a string which is a relative path from self
+        (assumed to be a directory) to dest such that
+        self.join(bestrelpath) == dest and if not such
+        path can be determined return dest.
+        """
+        try:
+            if self == dest:
+                return os.curdir
+            base = self.common(dest)
+            if not base:  # can be the case on windows
+                return str(dest)
+            self2base = self.relto(base)
+            reldest = dest.relto(base)
+            if self2base:
+                n = self2base.count(self.sep) + 1
+            else:
+                n = 0
+            lst = [os.pardir] * n
+            if reldest:
+                lst.append(reldest)
+            target = dest.sep.join(lst)
+            return target
+        except AttributeError:
+            return str(dest)
+
+    def exists(self):
+        return self.check()
+
+    def isdir(self):
+        return self.check(dir=1)
+
+    def isfile(self):
+        return self.check(file=1)
+
+    def parts(self, reverse=False):
+        """Return a root-first list of all ancestor directories
+        plus the path itself.
+        """
+        current = self
+        lst = [self]
+        while 1:
+            last = current
+            current = current.dirpath()
+            if last == current:
+                break
+            lst.append(current)
+        if not reverse:
+            lst.reverse()
+        return lst
+
+    def common(self, other):
+        """Return the common part shared with the other path
+        or None if there is no common part.
+        """
+        last = None
+        for x, y in zip(self.parts(), other.parts()):
+            if x != y:
+                return last
+            last = x
+        return last
+
+    def __add__(self, other):
+        """Return new path object with 'other' added to the basename"""
+        return self.new(basename=self.basename + str(other))
+
+    def visit(self, fil=None, rec=None, ignore=NeverRaised, bf=False, sort=False):
+        """Yields all paths below the current one
+
+        fil is a filter (glob pattern or callable), if not matching the
+        path will not be yielded, defaulting to None (everything is
+        returned)
+
+        rec is a filter (glob pattern or callable) that controls whether
+        a node is descended, defaulting to None
+
+        ignore is an Exception class that is ignoredwhen calling dirlist()
+        on any of the paths (by default, all exceptions are reported)
+
+        bf if True will cause a breadthfirst search instead of the
+        default depthfirst. Default: False
+
+        sort if True will sort entries within each directory level.
+        """
+        yield from Visitor(fil, rec, ignore, bf, sort).gen(self)
+
+    def _sortlist(self, res, sort):
+        if sort:
+            if hasattr(sort, "__call__"):
+                warnings.warn(
+                    DeprecationWarning(
+                        "listdir(sort=callable) is deprecated and breaks on python3"
+                    ),
+                    stacklevel=3,
+                )
+                res.sort(sort)
+            else:
+                res.sort()
+
+    def __fspath__(self):
+        return self.strpath
+
+    def __hash__(self):
+        s = self.strpath
+        if iswin32:
+            s = s.lower()
+        return hash(s)
+
+    def __eq__(self, other):
+        s1 = os.fspath(self)
+        try:
+            s2 = os.fspath(other)
+        except TypeError:
+            return False
+        if iswin32:
+            s1 = s1.lower()
+            try:
+                s2 = s2.lower()
+            except AttributeError:
+                return False
+        return s1 == s2
+
+    def __ne__(self, other):
+        return not (self == other)
+
+    def __lt__(self, other):
+        return os.fspath(self) < os.fspath(other)
+
+    def __gt__(self, other):
+        return os.fspath(self) > os.fspath(other)
+
+    def samefile(self, other):
+        """Return True if 'other' references the same file as 'self'."""
+        other = os.fspath(other)
+        if not isabs(other):
+            other = abspath(other)
+        if self == other:
+            return True
+        if not hasattr(os.path, "samefile"):
+            return False
+        return error.checked_call(os.path.samefile, self.strpath, other)
+
+    def remove(self, rec=1, ignore_errors=False):
+        """Remove a file or directory (or a directory tree if rec=1).
+        if ignore_errors is True, errors while removing directories will
+        be ignored.
+        """
+        if self.check(dir=1, link=0):
+            if rec:
+                # force remove of readonly files on windows
+                if iswin32:
+                    self.chmod(0o700, rec=1)
+                import shutil
+
+                error.checked_call(
+                    shutil.rmtree, self.strpath, ignore_errors=ignore_errors
+                )
+            else:
+                error.checked_call(os.rmdir, self.strpath)
+        else:
+            if iswin32:
+                self.chmod(0o700)
+            error.checked_call(os.remove, self.strpath)
+
+    def computehash(self, hashtype="md5", chunksize=524288):
+        """Return hexdigest of hashvalue for this file."""
+        try:
+            try:
+                import hashlib as mod
+            except ImportError:
+                if hashtype == "sha1":
+                    hashtype = "sha"
+                mod = __import__(hashtype)
+            hash = getattr(mod, hashtype)()
+        except (AttributeError, ImportError):
+            raise ValueError(f"Don't know how to compute {hashtype!r} hash")
+        f = self.open("rb")
+        try:
+            while 1:
+                buf = f.read(chunksize)
+                if not buf:
+                    return hash.hexdigest()
+                hash.update(buf)
+        finally:
+            f.close()
+
+    def new(self, **kw):
+        """Create a modified version of this path.
+        the following keyword arguments modify various path parts::
+
+          a:/some/path/to/a/file.ext
+          xx                           drive
+          xxxxxxxxxxxxxxxxx            dirname
+                            xxxxxxxx   basename
+                            xxxx       purebasename
+                                 xxx   ext
+        """
+        obj = object.__new__(self.__class__)
+        if not kw:
+            obj.strpath = self.strpath
+            return obj
+        drive, dirname, basename, purebasename, ext = self._getbyspec(
+            "drive,dirname,basename,purebasename,ext"
+        )
+        if "basename" in kw:
+            if "purebasename" in kw or "ext" in kw:
+                raise ValueError("invalid specification %r" % kw)
+        else:
+            pb = kw.setdefault("purebasename", purebasename)
+            try:
+                ext = kw["ext"]
+            except KeyError:
+                pass
+            else:
+                if ext and not ext.startswith("."):
+                    ext = "." + ext
+            kw["basename"] = pb + ext
+
+        if "dirname" in kw and not kw["dirname"]:
+            kw["dirname"] = drive
+        else:
+            kw.setdefault("dirname", dirname)
+        kw.setdefault("sep", self.sep)
+        obj.strpath = normpath("%(dirname)s%(sep)s%(basename)s" % kw)
+        return obj
+
+    def _getbyspec(self, spec: str) -> list[str]:
+        """See new for what 'spec' can be."""
+        res = []
+        parts = self.strpath.split(self.sep)
+
+        args = filter(None, spec.split(","))
+        for name in args:
+            if name == "drive":
+                res.append(parts[0])
+            elif name == "dirname":
+                res.append(self.sep.join(parts[:-1]))
+            else:
+                basename = parts[-1]
+                if name == "basename":
+                    res.append(basename)
+                else:
+                    i = basename.rfind(".")
+                    if i == -1:
+                        purebasename, ext = basename, ""
+                    else:
+                        purebasename, ext = basename[:i], basename[i:]
+                    if name == "purebasename":
+                        res.append(purebasename)
+                    elif name == "ext":
+                        res.append(ext)
+                    else:
+                        raise ValueError("invalid part specification %r" % name)
+        return res
+
+    def dirpath(self, *args, **kwargs):
+        """Return the directory path joined with any given path arguments."""
+        if not kwargs:
+            path = object.__new__(self.__class__)
+            path.strpath = dirname(self.strpath)
+            if args:
+                path = path.join(*args)
+            return path
+        return self.new(basename="").join(*args, **kwargs)
+
+    def join(self, *args: os.PathLike[str], abs: bool = False) -> LocalPath:
+        """Return a new path by appending all 'args' as path
+        components.  if abs=1 is used restart from root if any
+        of the args is an absolute path.
+        """
+        sep = self.sep
+        strargs = [os.fspath(arg) for arg in args]
+        strpath = self.strpath
+        if abs:
+            newargs: list[str] = []
+            for arg in reversed(strargs):
+                if isabs(arg):
+                    strpath = arg
+                    strargs = newargs
+                    break
+                newargs.insert(0, arg)
+        # special case for when we have e.g. strpath == "/"
+        actual_sep = "" if strpath.endswith(sep) else sep
+        for arg in strargs:
+            arg = arg.strip(sep)
+            if iswin32:
+                # allow unix style paths even on windows.
+                arg = arg.strip("/")
+                arg = arg.replace("/", sep)
+            strpath = strpath + actual_sep + arg
+            actual_sep = sep
+        obj = object.__new__(self.__class__)
+        obj.strpath = normpath(strpath)
+        return obj
+
+    def open(self, mode="r", ensure=False, encoding=None):
+        """Return an opened file with the given mode.
+
+        If ensure is True, create parent directories if needed.
+        """
+        if ensure:
+            self.dirpath().ensure(dir=1)
+        if encoding:
+            return error.checked_call(io.open, self.strpath, mode, encoding=encoding)
+        return error.checked_call(open, self.strpath, mode)
+
+    def _fastjoin(self, name):
+        child = object.__new__(self.__class__)
+        child.strpath = self.strpath + self.sep + name
+        return child
+
+    def islink(self):
+        return islink(self.strpath)
+
+    def check(self, **kw):
+        """Check a path for existence and properties.
+
+        Without arguments, return True if the path exists, otherwise False.
+
+        valid checkers::
+
+            file=1    # is a file
+            file=0    # is not a file (may not even exist)
+            dir=1     # is a dir
+            link=1    # is a link
+            exists=1  # exists
+
+        You can specify multiple checker definitions, for example::
+
+            path.check(file=1, link=1)  # a link pointing to a file
+        """
+        if not kw:
+            return exists(self.strpath)
+        if len(kw) == 1:
+            if "dir" in kw:
+                return not kw["dir"] ^ isdir(self.strpath)
+            if "file" in kw:
+                return not kw["file"] ^ isfile(self.strpath)
+        if not kw:
+            kw = {"exists": 1}
+        return Checkers(self)._evaluate(kw)
+
+    _patternchars = set("*?[" + os.sep)
+
+    def listdir(self, fil=None, sort=None):
+        """List directory contents, possibly filter by the given fil func
+        and possibly sorted.
+        """
+        if fil is None and sort is None:
+            names = error.checked_call(os.listdir, self.strpath)
+            return map_as_list(self._fastjoin, names)
+        if isinstance(fil, str):
+            if not self._patternchars.intersection(fil):
+                child = self._fastjoin(fil)
+                if exists(child.strpath):
+                    return [child]
+                return []
+            fil = FNMatcher(fil)
+        names = error.checked_call(os.listdir, self.strpath)
+        res = []
+        for name in names:
+            child = self._fastjoin(name)
+            if fil is None or fil(child):
+                res.append(child)
+        self._sortlist(res, sort)
+        return res
+
+    def size(self) -> int:
+        """Return size of the underlying file object"""
+        return self.stat().size
+
+    def mtime(self) -> float:
+        """Return last modification time of the path."""
+        return self.stat().mtime
+
+    def copy(self, target, mode=False, stat=False):
+        """Copy path to target.
+
+        If mode is True, will copy copy permission from path to target.
+        If stat is True, copy permission, last modification
+        time, last access time, and flags from path to target.
+        """
+        if self.check(file=1):
+            if target.check(dir=1):
+                target = target.join(self.basename)
+            assert self != target
+            copychunked(self, target)
+            if mode:
+                copymode(self.strpath, target.strpath)
+            if stat:
+                copystat(self, target)
+        else:
+
+            def rec(p):
+                return p.check(link=0)
+
+            for x in self.visit(rec=rec):
+                relpath = x.relto(self)
+                newx = target.join(relpath)
+                newx.dirpath().ensure(dir=1)
+                if x.check(link=1):
+                    newx.mksymlinkto(x.readlink())
+                    continue
+                elif x.check(file=1):
+                    copychunked(x, newx)
+                elif x.check(dir=1):
+                    newx.ensure(dir=1)
+                if mode:
+                    copymode(x.strpath, newx.strpath)
+                if stat:
+                    copystat(x, newx)
+
+    def rename(self, target):
+        """Rename this path to target."""
+        target = os.fspath(target)
+        return error.checked_call(os.rename, self.strpath, target)
+
+    def dump(self, obj, bin=1):
+        """Pickle object into path location"""
+        f = self.open("wb")
+        import pickle
+
+        try:
+            error.checked_call(pickle.dump, obj, f, bin)
+        finally:
+            f.close()
+
+    def mkdir(self, *args):
+        """Create & return the directory joined with args."""
+        p = self.join(*args)
+        error.checked_call(os.mkdir, os.fspath(p))
+        return p
+
+    def write_binary(self, data, ensure=False):
+        """Write binary data into path.   If ensure is True create
+        missing parent directories.
+        """
+        if ensure:
+            self.dirpath().ensure(dir=1)
+        with self.open("wb") as f:
+            f.write(data)
+
+    def write_text(self, data, encoding, ensure=False):
+        """Write text data into path using the specified encoding.
+        If ensure is True create missing parent directories.
+        """
+        if ensure:
+            self.dirpath().ensure(dir=1)
+        with self.open("w", encoding=encoding) as f:
+            f.write(data)
+
+    def write(self, data, mode="w", ensure=False):
+        """Write data into path.   If ensure is True create
+        missing parent directories.
+        """
+        if ensure:
+            self.dirpath().ensure(dir=1)
+        if "b" in mode:
+            if not isinstance(data, bytes):
+                raise ValueError("can only process bytes")
+        else:
+            if not isinstance(data, str):
+                if not isinstance(data, bytes):
+                    data = str(data)
+                else:
+                    data = data.decode(sys.getdefaultencoding())
+        f = self.open(mode)
+        try:
+            f.write(data)
+        finally:
+            f.close()
+
+    def _ensuredirs(self):
+        parent = self.dirpath()
+        if parent == self:
+            return self
+        if parent.check(dir=0):
+            parent._ensuredirs()
+        if self.check(dir=0):
+            try:
+                self.mkdir()
+            except error.EEXIST:
+                # race condition: file/dir created by another thread/process.
+                # complain if it is not a dir
+                if self.check(dir=0):
+                    raise
+        return self
+
+    def ensure(self, *args, **kwargs):
+        """Ensure that an args-joined path exists (by default as
+        a file). if you specify a keyword argument 'dir=True'
+        then the path is forced to be a directory path.
+        """
+        p = self.join(*args)
+        if kwargs.get("dir", 0):
+            return p._ensuredirs()
+        else:
+            p.dirpath()._ensuredirs()
+            if not p.check(file=1):
+                p.open("wb").close()
+            return p
+
+    @overload
+    def stat(self, raising: Literal[True] = ...) -> Stat:
+        ...
+
+    @overload
+    def stat(self, raising: Literal[False]) -> Stat | None:
+        ...
+
+    def stat(self, raising: bool = True) -> Stat | None:
+        """Return an os.stat() tuple."""
+        if raising:
+            return Stat(self, error.checked_call(os.stat, self.strpath))
+        try:
+            return Stat(self, os.stat(self.strpath))
+        except KeyboardInterrupt:
+            raise
+        except Exception:
+            return None
+
+    def lstat(self) -> Stat:
+        """Return an os.lstat() tuple."""
+        return Stat(self, error.checked_call(os.lstat, self.strpath))
+
+    def setmtime(self, mtime=None):
+        """Set modification time for the given path.  if 'mtime' is None
+        (the default) then the file's mtime is set to current time.
+
+        Note that the resolution for 'mtime' is platform dependent.
+        """
+        if mtime is None:
+            return error.checked_call(os.utime, self.strpath, mtime)
+        try:
+            return error.checked_call(os.utime, self.strpath, (-1, mtime))
+        except error.EINVAL:
+            return error.checked_call(os.utime, self.strpath, (self.atime(), mtime))
+
+    def chdir(self):
+        """Change directory to self and return old current directory"""
+        try:
+            old = self.__class__()
+        except error.ENOENT:
+            old = None
+        error.checked_call(os.chdir, self.strpath)
+        return old
+
+    @contextmanager
+    def as_cwd(self):
+        """
+        Return a context manager, which changes to the path's dir during the
+        managed "with" context.
+        On __enter__ it returns the old dir, which might be ``None``.
+        """
+        old = self.chdir()
+        try:
+            yield old
+        finally:
+            if old is not None:
+                old.chdir()
+
+    def realpath(self):
+        """Return a new path which contains no symbolic links."""
+        return self.__class__(os.path.realpath(self.strpath))
+
+    def atime(self):
+        """Return last access time of the path."""
+        return self.stat().atime
+
+    def __repr__(self):
+        return "local(%r)" % self.strpath
+
+    def __str__(self):
+        """Return string representation of the Path."""
+        return self.strpath
+
+    def chmod(self, mode, rec=0):
+        """Change permissions to the given mode. If mode is an
+        integer it directly encodes the os-specific modes.
+        if rec is True perform recursively.
+        """
+        if not isinstance(mode, int):
+            raise TypeError(f"mode {mode!r} must be an integer")
+        if rec:
+            for x in self.visit(rec=rec):
+                error.checked_call(os.chmod, str(x), mode)
+        error.checked_call(os.chmod, self.strpath, mode)
+
+    def pypkgpath(self):
+        """Return the Python package path by looking for the last
+        directory upwards which still contains an __init__.py.
+        Return None if a pkgpath can not be determined.
+        """
+        pkgpath = None
+        for parent in self.parts(reverse=True):
+            if parent.isdir():
+                if not parent.join("__init__.py").exists():
+                    break
+                if not isimportable(parent.basename):
+                    break
+                pkgpath = parent
+        return pkgpath
+
+    def _ensuresyspath(self, ensuremode, path):
+        if ensuremode:
+            s = str(path)
+            if ensuremode == "append":
+                if s not in sys.path:
+                    sys.path.append(s)
+            else:
+                if s != sys.path[0]:
+                    sys.path.insert(0, s)
+
+    def pyimport(self, modname=None, ensuresyspath=True):
+        """Return path as an imported python module.
+
+        If modname is None, look for the containing package
+        and construct an according module name.
+        The module will be put/looked up in sys.modules.
+        if ensuresyspath is True then the root dir for importing
+        the file (taking __init__.py files into account) will
+        be prepended to sys.path if it isn't there already.
+        If ensuresyspath=="append" the root dir will be appended
+        if it isn't already contained in sys.path.
+        if ensuresyspath is False no modification of syspath happens.
+
+        Special value of ensuresyspath=="importlib" is intended
+        purely for using in pytest, it is capable only of importing
+        separate .py files outside packages, e.g. for test suite
+        without any __init__.py file. It effectively allows having
+        same-named test modules in different places and offers
+        mild opt-in via this option. Note that it works only in
+        recent versions of python.
+        """
+        if not self.check():
+            raise error.ENOENT(self)
+
+        if ensuresyspath == "importlib":
+            if modname is None:
+                modname = self.purebasename
+            spec = importlib.util.spec_from_file_location(modname, str(self))
+            if spec is None or spec.loader is None:
+                raise ImportError(
+                    f"Can't find module {modname} at location {str(self)}"
+                )
+            mod = importlib.util.module_from_spec(spec)
+            spec.loader.exec_module(mod)
+            return mod
+
+        pkgpath = None
+        if modname is None:
+            pkgpath = self.pypkgpath()
+            if pkgpath is not None:
+                pkgroot = pkgpath.dirpath()
+                names = self.new(ext="").relto(pkgroot).split(self.sep)
+                if names[-1] == "__init__":
+                    names.pop()
+                modname = ".".join(names)
+            else:
+                pkgroot = self.dirpath()
+                modname = self.purebasename
+
+            self._ensuresyspath(ensuresyspath, pkgroot)
+            __import__(modname)
+            mod = sys.modules[modname]
+            if self.basename == "__init__.py":
+                return mod  # we don't check anything as we might
+                # be in a namespace package ... too icky to check
+            modfile = mod.__file__
+            assert modfile is not None
+            if modfile[-4:] in (".pyc", ".pyo"):
+                modfile = modfile[:-1]
+            elif modfile.endswith("$py.class"):
+                modfile = modfile[:-9] + ".py"
+            if modfile.endswith(os.sep + "__init__.py"):
+                if self.basename != "__init__.py":
+                    modfile = modfile[:-12]
+            try:
+                issame = self.samefile(modfile)
+            except error.ENOENT:
+                issame = False
+            if not issame:
+                ignore = os.getenv("PY_IGNORE_IMPORTMISMATCH")
+                if ignore != "1":
+                    raise self.ImportMismatchError(modname, modfile, self)
+            return mod
+        else:
+            try:
+                return sys.modules[modname]
+            except KeyError:
+                # we have a custom modname, do a pseudo-import
+                import types
+
+                mod = types.ModuleType(modname)
+                mod.__file__ = str(self)
+                sys.modules[modname] = mod
+                try:
+                    with open(str(self), "rb") as f:
+                        exec(f.read(), mod.__dict__)
+                except BaseException:
+                    del sys.modules[modname]
+                    raise
+                return mod
+
+    def sysexec(self, *argv: os.PathLike[str], **popen_opts: Any) -> str:
+        """Return stdout text from executing a system child process,
+        where the 'self' path points to executable.
+        The process is directly invoked and not through a system shell.
+        """
+        from subprocess import Popen, PIPE
+
+        popen_opts.pop("stdout", None)
+        popen_opts.pop("stderr", None)
+        proc = Popen(
+            [str(self)] + [str(arg) for arg in argv],
+            **popen_opts,
+            stdout=PIPE,
+            stderr=PIPE,
+        )
+        stdout: str | bytes
+        stdout, stderr = proc.communicate()
+        ret = proc.wait()
+        if isinstance(stdout, bytes):
+            stdout = stdout.decode(sys.getdefaultencoding())
+        if ret != 0:
+            if isinstance(stderr, bytes):
+                stderr = stderr.decode(sys.getdefaultencoding())
+            raise RuntimeError(
+                ret,
+                ret,
+                str(self),
+                stdout,
+                stderr,
+            )
+        return stdout
+
+    @classmethod
+    def sysfind(cls, name, checker=None, paths=None):
+        """Return a path object found by looking at the systems
+        underlying PATH specification. If the checker is not None
+        it will be invoked to filter matching paths.  If a binary
+        cannot be found, None is returned
+        Note: This is probably not working on plain win32 systems
+        but may work on cygwin.
+        """
+        if isabs(name):
+            p = local(name)
+            if p.check(file=1):
+                return p
+        else:
+            if paths is None:
+                if iswin32:
+                    paths = os.environ["Path"].split(";")
+                    if "" not in paths and "." not in paths:
+                        paths.append(".")
+                    try:
+                        systemroot = os.environ["SYSTEMROOT"]
+                    except KeyError:
+                        pass
+                    else:
+                        paths = [
+                            path.replace("%SystemRoot%", systemroot) for path in paths
+                        ]
+                else:
+                    paths = os.environ["PATH"].split(":")
+            tryadd = []
+            if iswin32:
+                tryadd += os.environ["PATHEXT"].split(os.pathsep)
+            tryadd.append("")
+
+            for x in paths:
+                for addext in tryadd:
+                    p = local(x).join(name, abs=True) + addext
+                    try:
+                        if p.check(file=1):
+                            if checker:
+                                if not checker(p):
+                                    continue
+                            return p
+                    except error.EACCES:
+                        pass
+        return None
+
+    @classmethod
+    def _gethomedir(cls):
+        try:
+            x = os.environ["HOME"]
+        except KeyError:
+            try:
+                x = os.environ["HOMEDRIVE"] + os.environ["HOMEPATH"]
+            except KeyError:
+                return None
+        return cls(x)
+
+    # """
+    # special class constructors for local filesystem paths
+    # """
+    @classmethod
+    def get_temproot(cls):
+        """Return the system's temporary directory
+        (where tempfiles are usually created in)
+        """
+        import tempfile
+
+        return local(tempfile.gettempdir())
+
+    @classmethod
+    def mkdtemp(cls, rootdir=None):
+        """Return a Path object pointing to a fresh new temporary directory
+        (which we created ourself).
+        """
+        import tempfile
+
+        if rootdir is None:
+            rootdir = cls.get_temproot()
+        return cls(error.checked_call(tempfile.mkdtemp, dir=str(rootdir)))
+
+    @classmethod
+    def make_numbered_dir(
+        cls, prefix="session-", rootdir=None, keep=3, lock_timeout=172800
+    ):  # two days
+        """Return unique directory with a number greater than the current
+        maximum one.  The number is assumed to start directly after prefix.
+        if keep is true directories with a number less than (maxnum-keep)
+        will be removed. If .lock files are used (lock_timeout non-zero),
+        algorithm is multi-process safe.
+        """
+        if rootdir is None:
+            rootdir = cls.get_temproot()
+
+        nprefix = prefix.lower()
+
+        def parse_num(path):
+            """Parse the number out of a path (if it matches the prefix)"""
+            nbasename = path.basename.lower()
+            if nbasename.startswith(nprefix):
+                try:
+                    return int(nbasename[len(nprefix) :])
+                except ValueError:
+                    pass
+
+        def create_lockfile(path):
+            """Exclusively create lockfile. Throws when failed"""
+            mypid = os.getpid()
+            lockfile = path.join(".lock")
+            if hasattr(lockfile, "mksymlinkto"):
+                lockfile.mksymlinkto(str(mypid))
+            else:
+                fd = error.checked_call(
+                    os.open, str(lockfile), os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644
+                )
+                with os.fdopen(fd, "w") as f:
+                    f.write(str(mypid))
+            return lockfile
+
+        def atexit_remove_lockfile(lockfile):
+            """Ensure lockfile is removed at process exit"""
+            mypid = os.getpid()
+
+            def try_remove_lockfile():
+                # in a fork() situation, only the last process should
+                # remove the .lock, otherwise the other processes run the
+                # risk of seeing their temporary dir disappear.  For now
+                # we remove the .lock in the parent only (i.e. we assume
+                # that the children finish before the parent).
+                if os.getpid() != mypid:
+                    return
+                try:
+                    lockfile.remove()
+                except error.Error:
+                    pass
+
+            atexit.register(try_remove_lockfile)
+
+        # compute the maximum number currently in use with the prefix
+        lastmax = None
+        while True:
+            maxnum = -1
+            for path in rootdir.listdir():
+                num = parse_num(path)
+                if num is not None:
+                    maxnum = max(maxnum, num)
+
+            # make the new directory
+            try:
+                udir = rootdir.mkdir(prefix + str(maxnum + 1))
+                if lock_timeout:
+                    lockfile = create_lockfile(udir)
+                    atexit_remove_lockfile(lockfile)
+            except (error.EEXIST, error.ENOENT, error.EBUSY):
+                # race condition (1): another thread/process created the dir
+                #                     in the meantime - try again
+                # race condition (2): another thread/process spuriously acquired
+                #                     lock treating empty directory as candidate
+                #                     for removal - try again
+                # race condition (3): another thread/process tried to create the lock at
+                #                     the same time (happened in Python 3.3 on Windows)
+                # https://ci.appveyor.com/project/pytestbot/py/build/1.0.21/job/ffi85j4c0lqwsfwa
+                if lastmax == maxnum:
+                    raise
+                lastmax = maxnum
+                continue
+            break
+
+        def get_mtime(path):
+            """Read file modification time"""
+            try:
+                return path.lstat().mtime
+            except error.Error:
+                pass
+
+        garbage_prefix = prefix + "garbage-"
+
+        def is_garbage(path):
+            """Check if path denotes directory scheduled for removal"""
+            bn = path.basename
+            return bn.startswith(garbage_prefix)
+
+        # prune old directories
+        udir_time = get_mtime(udir)
+        if keep and udir_time:
+            for path in rootdir.listdir():
+                num = parse_num(path)
+                if num is not None and num <= (maxnum - keep):
+                    try:
+                        # try acquiring lock to remove directory as exclusive user
+                        if lock_timeout:
+                            create_lockfile(path)
+                    except (error.EEXIST, error.ENOENT, error.EBUSY):
+                        path_time = get_mtime(path)
+                        if not path_time:
+                            # assume directory doesn't exist now
+                            continue
+                        if abs(udir_time - path_time) < lock_timeout:
+                            # assume directory with lockfile exists
+                            # and lock timeout hasn't expired yet
+                            continue
+
+                    # path dir locked for exclusive use
+                    # and scheduled for removal to avoid another thread/process
+                    # treating it as a new directory or removal candidate
+                    garbage_path = rootdir.join(garbage_prefix + str(uuid.uuid4()))
+                    try:
+                        path.rename(garbage_path)
+                        garbage_path.remove(rec=1)
+                    except KeyboardInterrupt:
+                        raise
+                    except Exception:  # this might be error.Error, WindowsError ...
+                        pass
+                if is_garbage(path):
+                    try:
+                        path.remove(rec=1)
+                    except KeyboardInterrupt:
+                        raise
+                    except Exception:  # this might be error.Error, WindowsError ...
+                        pass
+
+        # make link...
+        try:
+            username = os.environ["USER"]  # linux, et al
+        except KeyError:
+            try:
+                username = os.environ["USERNAME"]  # windows
+            except KeyError:
+                username = "current"
+
+        src = str(udir)
+        dest = src[: src.rfind("-")] + "-" + username
+        try:
+            os.unlink(dest)
+        except OSError:
+            pass
+        try:
+            os.symlink(src, dest)
+        except (OSError, AttributeError, NotImplementedError):
+            pass
+
+        return udir
+
+
+def copymode(src, dest):
+    """Copy permission from src to dst."""
+    import shutil
+
+    shutil.copymode(src, dest)
+
+
+def copystat(src, dest):
+    """Copy permission,  last modification time,
+    last access time, and flags from src to dst."""
+    import shutil
+
+    shutil.copystat(str(src), str(dest))
+
+
+def copychunked(src, dest):
+    chunksize = 524288  # half a meg of bytes
+    fsrc = src.open("rb")
+    try:
+        fdest = dest.open("wb")
+        try:
+            while 1:
+                buf = fsrc.read(chunksize)
+                if not buf:
+                    break
+                fdest.write(buf)
+        finally:
+            fdest.close()
+    finally:
+        fsrc.close()
+
+
+def isimportable(name):
+    if name and (name[0].isalpha() or name[0] == "_"):
+        name = name.replace("_", "")
+        return not name or name.isalnum()
+
+
+local = LocalPath
diff --git a/src/_pytest/_version.py b/src/_pytest/_version.py
new file mode 100644 (file)
index 0000000..d530ef4
--- /dev/null
@@ -0,0 +1,16 @@
+# file generated by setuptools_scm
+# don't change, don't track in version control
+TYPE_CHECKING = False
+if TYPE_CHECKING:
+    from typing import Tuple, Union
+    VERSION_TUPLE = Tuple[Union[int, str], ...]
+else:
+    VERSION_TUPLE = object
+
+version: str
+__version__: str
+__version_tuple__: VERSION_TUPLE
+version_tuple: VERSION_TUPLE
+
+__version__ = version = '7.4.3'
+__version_tuple__ = version_tuple = (7, 4, 3)
index a18cf198df0662966a99ce86384f7a8b03e6e27f..a46e58136ba771e0d0a6cf32d3ad08cddf5135e2 100644 (file)
@@ -39,7 +39,7 @@ def pytest_addoption(parser: Parser) -> None:
         "enable_assertion_pass_hook",
         type="bool",
         default=False,
-        help="Enables the pytest_assertion_pass hook."
+        help="Enables the pytest_assertion_pass hook. "
         "Make sure to delete any previously generated pyc cache files.",
     )
 
@@ -53,7 +53,7 @@ def register_assert_rewrite(*names: str) -> None:
     actually imported, usually in your __init__.py if you are a plugin
     using a package.
 
-    :raises TypeError: If the given module names are not strings.
+    :param names: The module names to register.
     """
     for name in names:
         if not isinstance(name, str):
@@ -88,13 +88,13 @@ class AssertionState:
 
 def install_importhook(config: Config) -> rewrite.AssertionRewritingHook:
     """Try to install the rewrite hook, raise SystemError if it fails."""
-    config._store[assertstate_key] = AssertionState(config, "rewrite")
-    config._store[assertstate_key].hook = hook = rewrite.AssertionRewritingHook(config)
+    config.stash[assertstate_key] = AssertionState(config, "rewrite")
+    config.stash[assertstate_key].hook = hook = rewrite.AssertionRewritingHook(config)
     sys.meta_path.insert(0, hook)
-    config._store[assertstate_key].trace("installed rewrite import hook")
+    config.stash[assertstate_key].trace("installed rewrite import hook")
 
     def undo() -> None:
-        hook = config._store[assertstate_key].hook
+        hook = config.stash[assertstate_key].hook
         if hook is not None and hook in sys.meta_path:
             sys.meta_path.remove(hook)
 
@@ -104,9 +104,9 @@ def install_importhook(config: Config) -> rewrite.AssertionRewritingHook:
 
 def pytest_collection(session: "Session") -> None:
     # This hook is only called when test modules are collected
-    # so for example not in the master process of pytest-xdist
+    # so for example not in the managing process of pytest-xdist
     # (which does not collect test modules).
-    assertstate = session.config._store.get(assertstate_key, None)
+    assertstate = session.config.stash.get(assertstate_key, None)
     if assertstate:
         if assertstate.hook is not None:
             assertstate.hook.set_session(session)
@@ -153,6 +153,7 @@ def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]:
 
     saved_assert_hooks = util._reprcompare, util._assertion_pass
     util._reprcompare = callbinrepr
+    util._config = item.config
 
     if ihook.pytest_assertion_pass.get_hookimpls():
 
@@ -164,10 +165,11 @@ def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]:
     yield
 
     util._reprcompare, util._assertion_pass = saved_assert_hooks
+    util._config = None
 
 
 def pytest_sessionfinish(session: "Session") -> None:
-    assertstate = session.config._store.get(assertstate_key, None)
+    assertstate = session.config.stash.get(assertstate_key, None)
     if assertstate:
         if assertstate.hook is not None:
             assertstate.hook.set_session(None)
index 805d4c8b35b1f56a99d98e0f9815d5c24e2d2c55..fd23552973e8435c864782932b0a9667c6366cad 100644 (file)
@@ -13,12 +13,14 @@ import struct
 import sys
 import tokenize
 import types
+from collections import defaultdict
 from pathlib import Path
 from pathlib import PurePath
 from typing import Callable
 from typing import Dict
 from typing import IO
 from typing import Iterable
+from typing import Iterator
 from typing import List
 from typing import Optional
 from typing import Sequence
@@ -27,8 +29,7 @@ from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import Union
 
-import py
-
+from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
 from _pytest._io.saferepr import saferepr
 from _pytest._version import version
 from _pytest.assertion import util
@@ -37,21 +38,39 @@ from _pytest.assertion.util import (  # noqa: F401
 )
 from _pytest.config import Config
 from _pytest.main import Session
+from _pytest.pathlib import absolutepath
 from _pytest.pathlib import fnmatch_ex
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 
 if TYPE_CHECKING:
     from _pytest.assertion import AssertionState
 
+if sys.version_info >= (3, 8):
+    namedExpr = ast.NamedExpr
+    astNameConstant = ast.Constant
+    astStr = ast.Constant
+    astNum = ast.Constant
+else:
+    namedExpr = ast.Expr
+    astNameConstant = ast.NameConstant
+    astStr = ast.Str
+    astNum = ast.Num
+
+
+class Sentinel:
+    pass
 
-assertstate_key = StoreKey["AssertionState"]()
 
+assertstate_key = StashKey["AssertionState"]()
 
 # pytest caches rewritten pycs in pycache dirs
 PYTEST_TAG = f"{sys.implementation.cache_tag}-pytest-{version}"
 PYC_EXT = ".py" + (__debug__ and "c" or "o")
 PYC_TAIL = "." + PYTEST_TAG + PYC_EXT
 
+# Special marker that denotes we have just left a scope definition
+_SCOPE_END_MARKER = Sentinel()
+
 
 class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader):
     """PEP302/PEP451 import hook which rewrites asserts."""
@@ -63,7 +82,7 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
         except ValueError:
             self.fnpats = ["test_*.py", "*_test.py"]
         self.session: Optional[Session] = None
-        self._rewritten_names: Set[str] = set()
+        self._rewritten_names: Dict[str, Path] = {}
         self._must_rewrite: Set[str] = set()
         # flag to guard against trying to rewrite a pyc file while we are already writing another pyc file,
         # which might result in infinite recursion (#3506)
@@ -87,7 +106,7 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
     ) -> Optional[importlib.machinery.ModuleSpec]:
         if self._writing_pyc:
             return None
-        state = self.config._store[assertstate_key]
+        state = self.config.stash[assertstate_key]
         if self._early_rewrite_bailout(name, state):
             return None
         state.trace("find_module called for: %s" % name)
@@ -99,9 +118,6 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
             spec is None
             # this is a namespace package (without `__init__.py`)
             # there's nothing to rewrite there
-            # python3.6: `namespace`
-            # python3.7+: `None`
-            or spec.origin == "namespace"
             or spec.origin is None
             # we can only rewrite source files
             or not isinstance(spec.loader, importlib.machinery.SourceFileLoader)
@@ -131,9 +147,9 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
         assert module.__spec__ is not None
         assert module.__spec__.origin is not None
         fn = Path(module.__spec__.origin)
-        state = self.config._store[assertstate_key]
+        state = self.config.stash[assertstate_key]
 
-        self._rewritten_names.add(module.__name__)
+        self._rewritten_names[module.__name__] = fn
 
         # The requested module looks like a test file, so rewrite it. This is
         # the most magical part of the process: load the source, rewrite the
@@ -182,7 +198,7 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
             for initial_path in self.session._initialpaths:
                 # Make something as c:/projects/my_project/path.py ->
                 #     ['c:', 'projects', 'my_project', 'path.py']
-                parts = str(initial_path).split(os.path.sep)
+                parts = str(initial_path).split(os.sep)
                 # add 'path' to basenames to be checked.
                 self._basenames_to_check_rewrite.add(os.path.splitext(parts[-1])[0])
 
@@ -192,7 +208,7 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
             return False
 
         # For matching the name it must be as if it was a filename.
-        path = PurePath(os.path.sep.join(parts) + ".py")
+        path = PurePath(*parts).with_suffix(".py")
 
         for pat in self.fnpats:
             # if the pattern contains subdirectories ("tests/**.py" for example) we can't bail out based
@@ -215,7 +231,7 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
             return True
 
         if self.session is not None:
-            if self.session.isinitpath(py.path.local(fn)):
+            if self.session.isinitpath(absolutepath(fn)):
                 state.trace(f"matched test file (was specified on cmdline): {fn!r}")
                 return True
 
@@ -275,6 +291,22 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
         with open(pathname, "rb") as f:
             return f.read()
 
+    if sys.version_info >= (3, 10):
+        if sys.version_info >= (3, 12):
+            from importlib.resources.abc import TraversableResources
+        else:
+            from importlib.abc import TraversableResources
+
+        def get_resource_reader(self, name: str) -> TraversableResources:  # type: ignore
+            if sys.version_info < (3, 11):
+                from importlib.readers import FileReader
+            else:
+                from importlib.resources.readers import FileReader
+
+            return FileReader(  # type:ignore[no-any-return]
+                types.SimpleNamespace(path=self._rewritten_names[name])
+            )
+
 
 def _write_pyc_fp(
     fp: IO[bytes], source_stat: os.stat_result, co: types.CodeType
@@ -284,9 +316,8 @@ def _write_pyc_fp(
     # import. However, there's little reason to deviate.
     fp.write(importlib.util.MAGIC_NUMBER)
     # https://www.python.org/dev/peps/pep-0552/
-    if sys.version_info >= (3, 7):
-        flags = b"\x00\x00\x00\x00"
-        fp.write(flags)
+    flags = b"\x00\x00\x00\x00"
+    fp.write(flags)
     # as of now, bytecode header expects 32-bit numbers for size and mtime (#4903)
     mtime = int(source_stat.st_mtime) & 0xFFFFFFFF
     size = source_stat.st_size & 0xFFFFFFFF
@@ -295,65 +326,39 @@ def _write_pyc_fp(
     fp.write(marshal.dumps(co))
 
 
-if sys.platform == "win32":
-    from atomicwrites import atomic_write
-
-    def _write_pyc(
-        state: "AssertionState",
-        co: types.CodeType,
-        source_stat: os.stat_result,
-        pyc: Path,
-    ) -> bool:
-        try:
-            with atomic_write(os.fspath(pyc), mode="wb", overwrite=True) as fp:
-                _write_pyc_fp(fp, source_stat, co)
-        except OSError as e:
-            state.trace(f"error writing pyc file at {pyc}: {e}")
-            # we ignore any failure to write the cache file
-            # there are many reasons, permission-denied, pycache dir being a
-            # file etc.
-            return False
-        return True
-
-
-else:
-
-    def _write_pyc(
-        state: "AssertionState",
-        co: types.CodeType,
-        source_stat: os.stat_result,
-        pyc: Path,
-    ) -> bool:
-        proc_pyc = f"{pyc}.{os.getpid()}"
-        try:
-            fp = open(proc_pyc, "wb")
-        except OSError as e:
-            state.trace(f"error writing pyc file at {proc_pyc}: errno={e.errno}")
-            return False
-
-        try:
+def _write_pyc(
+    state: "AssertionState",
+    co: types.CodeType,
+    source_stat: os.stat_result,
+    pyc: Path,
+) -> bool:
+    proc_pyc = f"{pyc}.{os.getpid()}"
+    try:
+        with open(proc_pyc, "wb") as fp:
             _write_pyc_fp(fp, source_stat, co)
-            os.rename(proc_pyc, os.fspath(pyc))
-        except OSError as e:
-            state.trace(f"error writing pyc file at {pyc}: {e}")
-            # we ignore any failure to write the cache file
-            # there are many reasons, permission-denied, pycache dir being a
-            # file etc.
-            return False
-        finally:
-            fp.close()
-        return True
+    except OSError as e:
+        state.trace(f"error writing pyc file at {proc_pyc}: errno={e.errno}")
+        return False
+
+    try:
+        os.replace(proc_pyc, pyc)
+    except OSError as e:
+        state.trace(f"error writing pyc file at {pyc}: {e}")
+        # we ignore any failure to write the cache file
+        # there are many reasons, permission-denied, pycache dir being a
+        # file etc.
+        return False
+    return True
 
 
 def _rewrite_test(fn: Path, config: Config) -> Tuple[os.stat_result, types.CodeType]:
     """Read and rewrite *fn* and return the code object."""
-    fn_ = os.fspath(fn)
-    stat = os.stat(fn_)
-    with open(fn_, "rb") as f:
-        source = f.read()
-    tree = ast.parse(source, filename=fn_)
-    rewrite_asserts(tree, source, fn_, config)
-    co = compile(tree, fn_, "exec", dont_inherit=True)
+    stat = os.stat(fn)
+    source = fn.read_bytes()
+    strfn = str(fn)
+    tree = ast.parse(source, filename=strfn)
+    rewrite_asserts(tree, source, strfn, config)
+    co = compile(tree, strfn, "exec", dont_inherit=True)
     return stat, co
 
 
@@ -365,35 +370,33 @@ def _read_pyc(
     Return rewritten code if successful or None if not.
     """
     try:
-        fp = open(os.fspath(pyc), "rb")
+        fp = open(pyc, "rb")
     except OSError:
         return None
     with fp:
-        # https://www.python.org/dev/peps/pep-0552/
-        has_flags = sys.version_info >= (3, 7)
         try:
-            stat_result = os.stat(os.fspath(source))
+            stat_result = os.stat(source)
             mtime = int(stat_result.st_mtime)
             size = stat_result.st_size
-            data = fp.read(16 if has_flags else 12)
+            data = fp.read(16)
         except OSError as e:
             trace(f"_read_pyc({source}): OSError {e}")
             return None
         # Check for invalid or out of date pyc file.
-        if len(data) != (16 if has_flags else 12):
+        if len(data) != (16):
             trace("_read_pyc(%s): invalid pyc (too short)" % source)
             return None
         if data[:4] != importlib.util.MAGIC_NUMBER:
             trace("_read_pyc(%s): invalid pyc (bad magic number)" % source)
             return None
-        if has_flags and data[4:8] != b"\x00\x00\x00\x00":
+        if data[4:8] != b"\x00\x00\x00\x00":
             trace("_read_pyc(%s): invalid pyc (unsupported flags)" % source)
             return None
-        mtime_data = data[8 if has_flags else 4 : 12 if has_flags else 8]
+        mtime_data = data[8:12]
         if int.from_bytes(mtime_data, "little") != mtime & 0xFFFFFFFF:
             trace("_read_pyc(%s): out of date" % source)
             return None
-        size_data = data[12 if has_flags else 8 : 16 if has_flags else 12]
+        size_data = data[12:16]
         if int.from_bytes(size_data, "little") != size & 0xFFFFFFFF:
             trace("_read_pyc(%s): invalid pyc (incorrect size)" % source)
             return None
@@ -428,7 +431,18 @@ def _saferepr(obj: object) -> str:
     sequences, especially '\n{' and '\n}' are likely to be present in
     JSON reprs.
     """
-    return saferepr(obj).replace("\n", "\\n")
+    maxsize = _get_maxsize_for_saferepr(util._config)
+    return saferepr(obj, maxsize=maxsize).replace("\n", "\\n")
+
+
+def _get_maxsize_for_saferepr(config: Optional[Config]) -> Optional[int]:
+    """Get `maxsize` configuration for saferepr based on the given config object."""
+    verbosity = config.getoption("verbose") if config is not None else 0
+    if verbosity >= 2:
+        return None
+    if verbosity >= 1:
+        return DEFAULT_REPR_MAX_SIZE * 10
+    return DEFAULT_REPR_MAX_SIZE
 
 
 def _format_assertmsg(obj: object) -> str:
@@ -495,7 +509,7 @@ def _call_assertion_pass(lineno: int, orig: str, expl: str) -> None:
 
 def _check_if_assertion_pass_impl() -> bool:
     """Check if any plugins implement the pytest_assertion_pass hook
-    in order not to generate explanation unecessarily (might be expensive)."""
+    in order not to generate explanation unnecessarily (might be expensive)."""
     return True if util._assertion_pass else False
 
 
@@ -528,21 +542,14 @@ BINOP_MAP = {
 }
 
 
-def set_location(node, lineno, col_offset):
-    """Set node location information recursively."""
-
-    def _fix(node, lineno, col_offset):
-        if "lineno" in node._attributes:
-            node.lineno = lineno
-        if "col_offset" in node._attributes:
-            node.col_offset = col_offset
-        for child in ast.iter_child_nodes(node):
-            _fix(child, lineno, col_offset)
-
-    _fix(node, lineno, col_offset)
-    return node
+def traverse_node(node: ast.AST) -> Iterator[ast.AST]:
+    """Recursively yield node and all its children in depth-first order."""
+    yield node
+    for child in ast.iter_child_nodes(node):
+        yield from traverse_node(child)
 
 
+@functools.lru_cache(maxsize=1)
 def _get_assertion_exprs(src: bytes) -> Dict[int, str]:
     """Return a mapping from {lineno: "assertion test expression"}."""
     ret: Dict[int, str] = {}
@@ -646,8 +653,14 @@ class AssertionRewriter(ast.NodeVisitor):
        .push_format_context() and .pop_format_context() which allows
        to build another %-formatted string while already building one.
 
-    This state is reset on every new assert statement visited and used
-    by the other visitors.
+    :scope: A tuple containing the current scope used for variables_overwrite.
+
+    :variables_overwrite: A dict filled with references to variables
+       that change value within an assert. This happens when a variable is
+       reassigned with the walrus operator
+
+    This state, except the variables_overwrite,  is reset on every new assert
+    statement visited and used by the other visitors.
     """
 
     def __init__(
@@ -663,35 +676,35 @@ class AssertionRewriter(ast.NodeVisitor):
         else:
             self.enable_assertion_pass_hook = False
         self.source = source
-
-    @functools.lru_cache(maxsize=1)
-    def _assert_expr_to_lineno(self) -> Dict[int, str]:
-        return _get_assertion_exprs(self.source)
+        self.scope: tuple[ast.AST, ...] = ()
+        self.variables_overwrite: defaultdict[
+            tuple[ast.AST, ...], Dict[str, str]
+        ] = defaultdict(dict)
 
     def run(self, mod: ast.Module) -> None:
         """Find all assert statements in *mod* and rewrite them."""
         if not mod.body:
             # Nothing to do.
             return
-        # Insert some special imports at the top of the module but after any
-        # docstrings and __future__ imports.
-        aliases = [
-            ast.alias("builtins", "@py_builtins"),
-            ast.alias("_pytest.assertion.rewrite", "@pytest_ar"),
-        ]
+
+        # We'll insert some special imports at the top of the module, but after any
+        # docstrings and __future__ imports, so first figure out where that is.
         doc = getattr(mod, "docstring", None)
         expect_docstring = doc is None
         if doc is not None and self.is_rewrite_disabled(doc):
             return
         pos = 0
-        lineno = 1
+        item = None
         for item in mod.body:
             if (
                 expect_docstring
                 and isinstance(item, ast.Expr)
-                and isinstance(item.value, ast.Str)
+                and isinstance(item.value, astStr)
             ):
-                doc = item.value.s
+                if sys.version_info >= (3, 8):
+                    doc = item.value.value
+                else:
+                    doc = item.value.s
                 if self.is_rewrite_disabled(doc):
                     return
                 expect_docstring = False
@@ -710,14 +723,39 @@ class AssertionRewriter(ast.NodeVisitor):
             lineno = item.decorator_list[0].lineno
         else:
             lineno = item.lineno
+        # Now actually insert the special imports.
+        if sys.version_info >= (3, 10):
+            aliases = [
+                ast.alias("builtins", "@py_builtins", lineno=lineno, col_offset=0),
+                ast.alias(
+                    "_pytest.assertion.rewrite",
+                    "@pytest_ar",
+                    lineno=lineno,
+                    col_offset=0,
+                ),
+            ]
+        else:
+            aliases = [
+                ast.alias("builtins", "@py_builtins"),
+                ast.alias("_pytest.assertion.rewrite", "@pytest_ar"),
+            ]
         imports = [
             ast.Import([alias], lineno=lineno, col_offset=0) for alias in aliases
         ]
         mod.body[pos:pos] = imports
+
         # Collect asserts.
-        nodes: List[ast.AST] = [mod]
+        self.scope = (mod,)
+        nodes: List[Union[ast.AST, Sentinel]] = [mod]
         while nodes:
             node = nodes.pop()
+            if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
+                self.scope = tuple((*self.scope, node))
+                nodes.append(_SCOPE_END_MARKER)
+            if node == _SCOPE_END_MARKER:
+                self.scope = self.scope[:-1]
+                continue
+            assert isinstance(node, ast.AST)
             for name, field in ast.iter_fields(node):
                 if isinstance(field, list):
                     new: List[ast.AST] = []
@@ -806,7 +844,7 @@ class AssertionRewriter(ast.NodeVisitor):
         current = self.stack.pop()
         if self.stack:
             self.explanation_specifiers = self.stack[-1]
-        keys = [ast.Str(key) for key in current.keys()]
+        keys = [astStr(key) for key in current.keys()]
         format_dict = ast.Dict(keys, list(current.values()))
         form = ast.BinOp(expl_expr, ast.Mod(), format_dict)
         name = "@py_format" + str(next(self.variable_counter))
@@ -840,7 +878,7 @@ class AssertionRewriter(ast.NodeVisitor):
                     "assertion is always true, perhaps remove parentheses?"
                 ),
                 category=None,
-                filename=os.fspath(self.module_path),
+                filename=self.module_path,
                 lineno=assert_.lineno,
             )
 
@@ -860,16 +898,16 @@ class AssertionRewriter(ast.NodeVisitor):
         negation = ast.UnaryOp(ast.Not(), top_condition)
 
         if self.enable_assertion_pass_hook:  # Experimental pytest_assertion_pass hook
-            msg = self.pop_format_context(ast.Str(explanation))
+            msg = self.pop_format_context(astStr(explanation))
 
             # Failed
             if assert_.msg:
                 assertmsg = self.helper("_format_assertmsg", assert_.msg)
                 gluestr = "\n>assert "
             else:
-                assertmsg = ast.Str("")
+                assertmsg = astStr("")
                 gluestr = "assert "
-            err_explanation = ast.BinOp(ast.Str(gluestr), ast.Add(), msg)
+            err_explanation = ast.BinOp(astStr(gluestr), ast.Add(), msg)
             err_msg = ast.BinOp(assertmsg, ast.Add(), err_explanation)
             err_name = ast.Name("AssertionError", ast.Load())
             fmt = self.helper("_format_explanation", err_msg)
@@ -881,12 +919,12 @@ class AssertionRewriter(ast.NodeVisitor):
 
             # Passed
             fmt_pass = self.helper("_format_explanation", msg)
-            orig = self._assert_expr_to_lineno()[assert_.lineno]
+            orig = _get_assertion_exprs(self.source)[assert_.lineno]
             hook_call_pass = ast.Expr(
                 self.helper(
                     "_call_assertion_pass",
-                    ast.Num(assert_.lineno),
-                    ast.Str(orig),
+                    astNum(assert_.lineno),
+                    astStr(orig),
                     fmt_pass,
                 )
             )
@@ -905,7 +943,7 @@ class AssertionRewriter(ast.NodeVisitor):
                 variables = [
                     ast.Name(name, ast.Store()) for name in self.format_variables
                 ]
-                clear_format = ast.Assign(variables, ast.NameConstant(None))
+                clear_format = ast.Assign(variables, astNameConstant(None))
                 self.statements.append(clear_format)
 
         else:  # Original assertion rewriting
@@ -916,9 +954,9 @@ class AssertionRewriter(ast.NodeVisitor):
                 assertmsg = self.helper("_format_assertmsg", assert_.msg)
                 explanation = "\n>assert " + explanation
             else:
-                assertmsg = ast.Str("")
+                assertmsg = astStr("")
                 explanation = "assert " + explanation
-            template = ast.BinOp(assertmsg, ast.Add(), ast.Str(explanation))
+            template = ast.BinOp(assertmsg, ast.Add(), astStr(explanation))
             msg = self.pop_format_context(template)
             fmt = self.helper("_format_explanation", msg)
             err_name = ast.Name("AssertionError", ast.Load())
@@ -930,21 +968,34 @@ class AssertionRewriter(ast.NodeVisitor):
         # Clear temporary variables by setting them to None.
         if self.variables:
             variables = [ast.Name(name, ast.Store()) for name in self.variables]
-            clear = ast.Assign(variables, ast.NameConstant(None))
+            clear = ast.Assign(variables, astNameConstant(None))
             self.statements.append(clear)
-        # Fix line numbers.
+        # Fix locations (line numbers/column offsets).
         for stmt in self.statements:
-            set_location(stmt, assert_.lineno, assert_.col_offset)
+            for node in traverse_node(stmt):
+                ast.copy_location(node, assert_)
         return self.statements
 
+    def visit_NamedExpr(self, name: namedExpr) -> Tuple[namedExpr, str]:
+        # This method handles the 'walrus operator' repr of the target
+        # name if it's a local variable or _should_repr_global_name()
+        # thinks it's acceptable.
+        locs = ast.Call(self.builtin("locals"), [], [])
+        target_id = name.target.id  # type: ignore[attr-defined]
+        inlocs = ast.Compare(astStr(target_id), [ast.In()], [locs])
+        dorepr = self.helper("_should_repr_global_name", name)
+        test = ast.BoolOp(ast.Or(), [inlocs, dorepr])
+        expr = ast.IfExp(test, self.display(name), astStr(target_id))
+        return name, self.explanation_param(expr)
+
     def visit_Name(self, name: ast.Name) -> Tuple[ast.Name, str]:
         # Display the repr of the name if it's a local variable or
         # _should_repr_global_name() thinks it's acceptable.
         locs = ast.Call(self.builtin("locals"), [], [])
-        inlocs = ast.Compare(ast.Str(name.id), [ast.In()], [locs])
+        inlocs = ast.Compare(astStr(name.id), [ast.In()], [locs])
         dorepr = self.helper("_should_repr_global_name", name)
         test = ast.BoolOp(ast.Or(), [inlocs, dorepr])
-        expr = ast.IfExp(test, self.display(name), ast.Str(name.id))
+        expr = ast.IfExp(test, self.display(name), astStr(name.id))
         return name, self.explanation_param(expr)
 
     def visit_BoolOp(self, boolop: ast.BoolOp) -> Tuple[ast.Name, str]:
@@ -963,10 +1014,26 @@ class AssertionRewriter(ast.NodeVisitor):
                 # cond is set in a prior loop iteration below
                 self.expl_stmts.append(ast.If(cond, fail_inner, []))  # noqa
                 self.expl_stmts = fail_inner
+                # Check if the left operand is a namedExpr and the value has already been visited
+                if (
+                    isinstance(v, ast.Compare)
+                    and isinstance(v.left, namedExpr)
+                    and v.left.target.id
+                    in [
+                        ast_expr.id
+                        for ast_expr in boolop.values[:i]
+                        if hasattr(ast_expr, "id")
+                    ]
+                ):
+                    pytest_temp = self.variable()
+                    self.variables_overwrite[self.scope][
+                        v.left.target.id
+                    ] = v.left  # type:ignore[assignment]
+                    v.left.target.id = pytest_temp
             self.push_format_context()
             res, expl = self.visit(v)
             body.append(ast.Assign([ast.Name(res_var, ast.Store())], res))
-            expl_format = self.pop_format_context(ast.Str(expl))
+            expl_format = self.pop_format_context(astStr(expl))
             call = ast.Call(app, [expl_format], [])
             self.expl_stmts.append(ast.Expr(call))
             if i < levels:
@@ -978,7 +1045,7 @@ class AssertionRewriter(ast.NodeVisitor):
                 self.statements = body = inner
         self.statements = save
         self.expl_stmts = fail_save
-        expl_template = self.helper("_format_boolop", expl_list, ast.Num(is_or))
+        expl_template = self.helper("_format_boolop", expl_list, astNum(is_or))
         expl = self.pop_format_context(expl_template)
         return ast.Name(res_var, ast.Load()), self.explanation_param(expl)
 
@@ -1002,10 +1069,22 @@ class AssertionRewriter(ast.NodeVisitor):
         new_args = []
         new_kwargs = []
         for arg in call.args:
+            if isinstance(arg, ast.Name) and arg.id in self.variables_overwrite.get(
+                self.scope, {}
+            ):
+                arg = self.variables_overwrite[self.scope][
+                    arg.id
+                ]  # type:ignore[assignment]
             res, expl = self.visit(arg)
             arg_expls.append(expl)
             new_args.append(res)
         for keyword in call.keywords:
+            if isinstance(
+                keyword.value, ast.Name
+            ) and keyword.value.id in self.variables_overwrite.get(self.scope, {}):
+                keyword.value = self.variables_overwrite[self.scope][
+                    keyword.value.id
+                ]  # type:ignore[assignment]
             res, expl = self.visit(keyword.value)
             new_kwargs.append(ast.keyword(keyword.arg, res))
             if keyword.arg:
@@ -1038,6 +1117,17 @@ class AssertionRewriter(ast.NodeVisitor):
 
     def visit_Compare(self, comp: ast.Compare) -> Tuple[ast.expr, str]:
         self.push_format_context()
+        # We first check if we have overwritten a variable in the previous assert
+        if isinstance(
+            comp.left, ast.Name
+        ) and comp.left.id in self.variables_overwrite.get(self.scope, {}):
+            comp.left = self.variables_overwrite[self.scope][
+                comp.left.id
+            ]  # type:ignore[assignment]
+        if isinstance(comp.left, namedExpr):
+            self.variables_overwrite[self.scope][
+                comp.left.target.id
+            ] = comp.left  # type:ignore[assignment]
         left_res, left_expl = self.visit(comp.left)
         if isinstance(comp.left, (ast.Compare, ast.BoolOp)):
             left_expl = f"({left_expl})"
@@ -1049,14 +1139,23 @@ class AssertionRewriter(ast.NodeVisitor):
         syms = []
         results = [left_res]
         for i, op, next_operand in it:
+            if (
+                isinstance(next_operand, namedExpr)
+                and isinstance(left_res, ast.Name)
+                and next_operand.target.id == left_res.id
+            ):
+                next_operand.target.id = self.variable()
+                self.variables_overwrite[self.scope][
+                    left_res.id
+                ] = next_operand  # type:ignore[assignment]
             next_res, next_expl = self.visit(next_operand)
             if isinstance(next_operand, (ast.Compare, ast.BoolOp)):
                 next_expl = f"({next_expl})"
             results.append(next_res)
             sym = BINOP_MAP[op.__class__]
-            syms.append(ast.Str(sym))
+            syms.append(astStr(sym))
             expl = f"{left_expl} {sym} {next_expl}"
-            expls.append(ast.Str(expl))
+            expls.append(astStr(expl))
             res_expr = ast.Compare(left_res, [op], [next_res])
             self.statements.append(ast.Assign([store_names[i]], res_expr))
             left_res, left_expl = next_res, next_expl
@@ -1072,6 +1171,7 @@ class AssertionRewriter(ast.NodeVisitor):
             res: ast.expr = ast.BoolOp(ast.And(), load_names)
         else:
             res = load_names[0]
+
         return res, self.explanation_param(self.pop_format_context(expl_call))
 
 
@@ -1081,7 +1181,7 @@ def try_makedirs(cache_dir: Path) -> bool:
     Returns True if successful or if it already exists.
     """
     try:
-        os.makedirs(os.fspath(cache_dir), exist_ok=True)
+        os.makedirs(cache_dir, exist_ok=True)
     except (FileNotFoundError, NotADirectoryError, FileExistsError):
         # One of the path components was not a directory:
         # - we're in a zip file
index 5ba9ddca75a1313c0b90677bb7ac3d3923638e19..dfd6f65d281a887540f81121b6dc2a0422ff191f 100644 (file)
@@ -3,10 +3,10 @@
 Current default behaviour is to truncate assertion explanations at
 ~8 terminal lines, unless running in "-vv" mode or running on CI.
 """
-import os
 from typing import List
 from typing import Optional
 
+from _pytest.assertion import util
 from _pytest.nodes import Item
 
 
@@ -27,13 +27,7 @@ def truncate_if_required(
 def _should_truncate_item(item: Item) -> bool:
     """Whether or not this test item is eligible for truncation."""
     verbose = item.config.option.verbose
-    return verbose < 2 and not _running_on_ci()
-
-
-def _running_on_ci() -> bool:
-    """Check if we're currently running on a CI system."""
-    env_vars = ["CI", "BUILD_NUMBER"]
-    return any(var in os.environ for var in env_vars)
+    return verbose < 2 and not util.running_on_ci()
 
 
 def _truncate_explanation(
@@ -44,9 +38,9 @@ def _truncate_explanation(
     """Truncate given list of strings that makes up the assertion explanation.
 
     Truncates to either 8 lines, or 640 characters - whichever the input reaches
-    first. The remaining lines will be replaced by a usage message.
+    first, taking the truncation explanation into account. The remaining lines
+    will be replaced by a usage message.
     """
-
     if max_lines is None:
         max_lines = DEFAULT_MAX_LINES
     if max_chars is None:
@@ -54,35 +48,56 @@ def _truncate_explanation(
 
     # Check if truncation required
     input_char_count = len("".join(input_lines))
-    if len(input_lines) <= max_lines and input_char_count <= max_chars:
+    # The length of the truncation explanation depends on the number of lines
+    # removed but is at least 68 characters:
+    # The real value is
+    # 64 (for the base message:
+    # '...\n...Full output truncated (1 line hidden), use '-vv' to show")'
+    # )
+    # + 1 (for plural)
+    # + int(math.log10(len(input_lines) - max_lines)) (number of hidden line, at least 1)
+    # + 3 for the '...' added to the truncated line
+    # But if there's more than 100 lines it's very likely that we're going to
+    # truncate, so we don't need the exact value using log10.
+    tolerable_max_chars = (
+        max_chars + 70  # 64 + 1 (for plural) + 2 (for '99') + 3 for '...'
+    )
+    # The truncation explanation add two lines to the output
+    tolerable_max_lines = max_lines + 2
+    if (
+        len(input_lines) <= tolerable_max_lines
+        and input_char_count <= tolerable_max_chars
+    ):
         return input_lines
-
-    # Truncate first to max_lines, and then truncate to max_chars if max_chars
-    # is exceeded.
+    # Truncate first to max_lines, and then truncate to max_chars if necessary
     truncated_explanation = input_lines[:max_lines]
-    truncated_explanation = _truncate_by_char_count(truncated_explanation, max_chars)
-
-    # Add ellipsis to final line
-    truncated_explanation[-1] = truncated_explanation[-1] + "..."
+    truncated_char = True
+    # We reevaluate the need to truncate chars following removal of some lines
+    if len("".join(truncated_explanation)) > tolerable_max_chars:
+        truncated_explanation = _truncate_by_char_count(
+            truncated_explanation, max_chars
+        )
+    else:
+        truncated_char = False
 
-    # Append useful message to explanation
     truncated_line_count = len(input_lines) - len(truncated_explanation)
-    truncated_line_count += 1  # Account for the part-truncated final line
-    msg = "...Full output truncated"
-    if truncated_line_count == 1:
-        msg += f" ({truncated_line_count} line hidden)"
+    if truncated_explanation[-1]:
+        # Add ellipsis and take into account part-truncated final line
+        truncated_explanation[-1] = truncated_explanation[-1] + "..."
+        if truncated_char:
+            # It's possible that we did not remove any char from this line
+            truncated_line_count += 1
     else:
-        msg += f" ({truncated_line_count} lines hidden)"
-    msg += f", {USAGE_MSG}"
-    truncated_explanation.extend(["", str(msg)])
-    return truncated_explanation
+        # Add proper ellipsis when we were able to fit a full line exactly
+        truncated_explanation[-1] = "..."
+    return truncated_explanation + [
+        "",
+        f"...Full output truncated ({truncated_line_count} line"
+        f"{'' if truncated_line_count == 1 else 's'} hidden), {USAGE_MSG}",
+    ]
 
 
 def _truncate_by_char_count(input_lines: List[str], max_chars: int) -> List[str]:
-    # Check if truncation required
-    if len("".join(input_lines)) <= max_chars:
-        return input_lines
-
     # Find point at which input length exceeds total allowed length
     iterated_char_count = 0
     for iterated_index, input_line in enumerate(input_lines):
index da1ffd15e376c2de7813c2651a77cc3c5955bd1d..fc5dfdbd5ba60c9c88cfaaf93ade5805422da824 100644 (file)
@@ -1,5 +1,6 @@
 """Utilities for assertion debugging."""
 import collections.abc
+import os
 import pprint
 from typing import AbstractSet
 from typing import Any
@@ -9,12 +10,14 @@ from typing import List
 from typing import Mapping
 from typing import Optional
 from typing import Sequence
+from unicodedata import normalize
 
 import _pytest._code
 from _pytest import outcomes
 from _pytest._io.saferepr import _pformat_dispatch
-from _pytest._io.saferepr import safeformat
 from _pytest._io.saferepr import saferepr
+from _pytest._io.saferepr import saferepr_unlimited
+from _pytest.config import Config
 
 # The _reprcompare attribute on the util module is used by the new assertion
 # interpretation code and assertion rewriter to detect this plugin was
@@ -26,6 +29,9 @@ _reprcompare: Optional[Callable[[str, object, object], Optional[str]]] = None
 # when pytest_runtest_setup is called.
 _assertion_pass: Optional[Callable[[int, str, str], None]] = None
 
+# Config object which is assigned during pytest_runtest_protocol.
+_config: Optional[Config] = None
+
 
 def format_explanation(explanation: str) -> str:
     r"""Format an explanation.
@@ -130,20 +136,53 @@ def isiterable(obj: Any) -> bool:
         return False
 
 
-def assertrepr_compare(config, op: str, left: Any, right: Any) -> Optional[List[str]]:
+def has_default_eq(
+    obj: object,
+) -> bool:
+    """Check if an instance of an object contains the default eq
+
+    First, we check if the object's __eq__ attribute has __code__,
+    if so, we check the equally of the method code filename (__code__.co_filename)
+    to the default one generated by the dataclass and attr module
+    for dataclasses the default co_filename is <string>, for attrs class, the __eq__ should contain "attrs eq generated"
+    """
+    # inspired from https://github.com/willmcgugan/rich/blob/07d51ffc1aee6f16bd2e5a25b4e82850fb9ed778/rich/pretty.py#L68
+    if hasattr(obj.__eq__, "__code__") and hasattr(obj.__eq__.__code__, "co_filename"):
+        code_filename = obj.__eq__.__code__.co_filename
+
+        if isattrs(obj):
+            return "attrs generated eq" in code_filename
+
+        return code_filename == "<string>"  # data class
+    return True
+
+
+def assertrepr_compare(
+    config, op: str, left: Any, right: Any, use_ascii: bool = False
+) -> Optional[List[str]]:
     """Return specialised explanations for some operators/operands."""
     verbose = config.getoption("verbose")
+
+    # Strings which normalize equal are often hard to distinguish when printed; use ascii() to make this easier.
+    # See issue #3246.
+    use_ascii = (
+        isinstance(left, str)
+        and isinstance(right, str)
+        and normalize("NFD", left) == normalize("NFD", right)
+    )
+
     if verbose > 1:
-        left_repr = safeformat(left)
-        right_repr = safeformat(right)
+        left_repr = saferepr_unlimited(left, use_ascii=use_ascii)
+        right_repr = saferepr_unlimited(right, use_ascii=use_ascii)
     else:
         # XXX: "15 chars indentation" is wrong
         #      ("E       AssertionError: assert "); should use term width.
         maxsize = (
             80 - 15 - len(op) - 2
         ) // 2  # 15 chars indentation, 1 space around op
-        left_repr = saferepr(left, maxsize=maxsize)
-        right_repr = saferepr(right, maxsize=maxsize)
+
+        left_repr = saferepr(left, maxsize=maxsize, use_ascii=use_ascii)
+        right_repr = saferepr(right, maxsize=maxsize, use_ascii=use_ascii)
 
     summary = f"{left_repr} {op} {right_repr}"
 
@@ -175,7 +214,15 @@ def _compare_eq_any(left: Any, right: Any, verbose: int = 0) -> List[str]:
     if istext(left) and istext(right):
         explanation = _diff_text(left, right, verbose)
     else:
-        if type(left) == type(right) and (
+        from _pytest.python_api import ApproxBase
+
+        if isinstance(left, ApproxBase) or isinstance(right, ApproxBase):
+            # Although the common order should be obtained == expected, this ensures both ways
+            approx_side = left if isinstance(left, ApproxBase) else right
+            other_side = right if isinstance(left, ApproxBase) else left
+
+            explanation = approx_side._repr_compare(other_side)
+        elif type(left) == type(right) and (
             isdatacls(left) or isattrs(left) or isnamedtuple(left)
         ):
             # Note: unlike dataclasses/attrs, namedtuples compare only the
@@ -189,11 +236,11 @@ def _compare_eq_any(left: Any, right: Any, verbose: int = 0) -> List[str]:
             explanation = _compare_eq_set(left, right, verbose)
         elif isdict(left) and isdict(right):
             explanation = _compare_eq_dict(left, right, verbose)
-        elif verbose > 0:
-            explanation = _compare_eq_verbose(left, right)
+
         if isiterable(left) and isiterable(right):
             expl = _compare_eq_iterable(left, right, verbose)
             explanation.extend(expl)
+
     return explanation
 
 
@@ -245,18 +292,6 @@ def _diff_text(left: str, right: str, verbose: int = 0) -> List[str]:
     return explanation
 
 
-def _compare_eq_verbose(left: Any, right: Any) -> List[str]:
-    keepends = True
-    left_lines = repr(left).splitlines(keepends)
-    right_lines = repr(right).splitlines(keepends)
-
-    explanation: List[str] = []
-    explanation += ["+" + line for line in left_lines]
-    explanation += ["-" + line for line in right_lines]
-
-    return explanation
-
-
 def _surrounding_parens_on_own_lines(lines: List[str]) -> None:
     """Move opening/closing parenthesis/bracket to own lines."""
     opening = lines[0][:1]
@@ -272,8 +307,8 @@ def _surrounding_parens_on_own_lines(lines: List[str]) -> None:
 def _compare_eq_iterable(
     left: Iterable[Any], right: Iterable[Any], verbose: int = 0
 ) -> List[str]:
-    if not verbose:
-        return ["Use -v to get the full diff"]
+    if verbose <= 0 and not running_on_ci():
+        return ["Use -v to get more diff"]
     # dynamic import to speedup pytest
     import difflib
 
@@ -412,9 +447,13 @@ def _compare_eq_dict(
 
 
 def _compare_eq_cls(left: Any, right: Any, verbose: int) -> List[str]:
+    if not has_default_eq(left):
+        return []
     if isdatacls(left):
-        all_fields = left.__dataclass_fields__
-        fields_to_check = [field for field, info in all_fields.items() if info.compare]
+        import dataclasses
+
+        all_fields = dataclasses.fields(left)
+        fields_to_check = [info.name for info in all_fields if info.compare]
     elif isattrs(left):
         all_fields = left.__attrs_attrs__
         fields_to_check = [field.name for field in all_fields if getattr(field, "eq")]
@@ -475,3 +514,9 @@ def _notin_text(term: str, text: str, verbose: int = 0) -> List[str]:
         else:
             newdiff.append(line)
     return newdiff
+
+
+def running_on_ci() -> bool:
+    """Check if we're currently running on a CI system."""
+    env_vars = ["CI", "BUILD_NUMBER"]
+    return any(var in os.environ for var in env_vars)
index 03acd03109e74ac1770b672acee2d42d77790cc0..1ecb865058010787b2cc90d14d218c6e3eb589c9 100755 (executable)
@@ -1,6 +1,7 @@
 """Implementation of the cache provider."""
 # This plugin was not named "cache" to avoid conflicts with the external
 # pytest-cache version.
+import dataclasses
 import json
 import os
 from pathlib import Path
@@ -12,9 +13,6 @@ from typing import Optional
 from typing import Set
 from typing import Union
 
-import attr
-import py
-
 from .pathlib import resolve_from_str
 from .pathlib import rm_rf
 from .reports import CollectReport
@@ -29,11 +27,10 @@ from _pytest.deprecated import check_ispytest
 from _pytest.fixtures import fixture
 from _pytest.fixtures import FixtureRequest
 from _pytest.main import Session
-from _pytest.python import Module
+from _pytest.nodes import File
 from _pytest.python import Package
 from _pytest.reports import TestReport
 
-
 README_CONTENT = """\
 # pytest cache directory #
 
@@ -42,27 +39,29 @@ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
 
 **Do not** commit this to version control.
 
-See [the docs](https://docs.pytest.org/en/stable/cache.html) for more information.
+See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
 """
 
 CACHEDIR_TAG_CONTENT = b"""\
 Signature: 8a477f597d28d172789f06886806bc55
 # This file is a cache directory tag created by pytest.
 # For information about cache directory tags, see:
-#      http://www.bford.info/cachedir/spec.html
+#      https://bford.info/cachedir/spec.html
 """
 
 
 @final
-@attr.s(init=False)
+@dataclasses.dataclass
 class Cache:
-    _cachedir = attr.ib(type=Path, repr=False)
-    _config = attr.ib(type=Config, repr=False)
+    """Instance of the `cache` fixture."""
+
+    _cachedir: Path = dataclasses.field(repr=False)
+    _config: Config = dataclasses.field(repr=False)
 
-    # sub-directory under cache-dir for directories created by "makedir"
+    # Sub-directory under cache-dir for directories created by `mkdir()`.
     _CACHE_PREFIX_DIRS = "d"
 
-    # sub-directory under cache-dir for values created by "set"
+    # Sub-directory under cache-dir for values created by `set()`.
     _CACHE_PREFIX_VALUES = "v"
 
     def __init__(
@@ -120,13 +119,15 @@ class Cache:
             stacklevel=3,
         )
 
-    def makedir(self, name: str) -> py.path.local:
+    def mkdir(self, name: str) -> Path:
         """Return a directory path object with the given name.
 
         If the directory does not yet exist, it will be created. You can use
         it to manage files to e.g. store/retrieve database dumps across test
         sessions.
 
+        .. versionadded:: 7.0
+
         :param name:
             Must be a string not containing a ``/`` separator.
             Make sure the name contains your plugin or application
@@ -137,7 +138,7 @@ class Cache:
             raise ValueError("name is not allowed to contain path separators")
         res = self._cachedir.joinpath(self._CACHE_PREFIX_DIRS, path)
         res.mkdir(exist_ok=True, parents=True)
-        return py.path.local(res)
+        return res
 
     def _getvaluepath(self, key: str) -> Path:
         return self._cachedir.joinpath(self._CACHE_PREFIX_VALUES, Path(key))
@@ -156,7 +157,7 @@ class Cache:
         """
         path = self._getvaluepath(key)
         try:
-            with path.open("r") as f:
+            with path.open("r", encoding="UTF-8") as f:
                 return json.load(f)
         except (ValueError, OSError):
             return default
@@ -178,16 +179,22 @@ class Cache:
             else:
                 cache_dir_exists_already = self._cachedir.exists()
                 path.parent.mkdir(exist_ok=True, parents=True)
-        except OSError:
-            self.warn("could not create cache path {path}", path=path, _ispytest=True)
+        except OSError as exc:
+            self.warn(
+                f"could not create cache path {path}: {exc}",
+                _ispytest=True,
+            )
             return
         if not cache_dir_exists_already:
             self._ensure_supporting_files()
-        data = json.dumps(value, indent=2, sort_keys=True)
+        data = json.dumps(value, ensure_ascii=False, indent=2)
         try:
-            f = path.open("w")
-        except OSError:
-            self.warn("cache could not write path {path}", path=path, _ispytest=True)
+            f = path.open("w", encoding="UTF-8")
+        except OSError as exc:
+            self.warn(
+                f"cache could not write path {path}: {exc}",
+                _ispytest=True,
+            )
         else:
             with f:
                 f.write(data)
@@ -195,7 +202,7 @@ class Cache:
     def _ensure_supporting_files(self) -> None:
         """Create supporting files in the cache dir that are not really part of the cache."""
         readme_path = self._cachedir / "README.md"
-        readme_path.write_text(README_CONTENT)
+        readme_path.write_text(README_CONTENT, encoding="UTF-8")
 
         gitignore_path = self._cachedir.joinpath(".gitignore")
         msg = "# Created by pytest automatically.\n*\n"
@@ -212,19 +219,31 @@ class LFPluginCollWrapper:
 
     @hookimpl(hookwrapper=True)
     def pytest_make_collect_report(self, collector: nodes.Collector):
-        if isinstance(collector, Session):
+        if isinstance(collector, (Session, Package)):
             out = yield
             res: CollectReport = out.get_result()
 
             # Sort any lf-paths to the beginning.
             lf_paths = self.lfplugin._last_failed_paths
+
+            # Use stable sort to priorize last failed.
+            def sort_key(node: Union[nodes.Item, nodes.Collector]) -> bool:
+                # Package.path is the __init__.py file, we need the directory.
+                if isinstance(node, Package):
+                    path = node.path.parent
+                else:
+                    path = node.path
+                return path in lf_paths
+
             res.result = sorted(
-                res.result, key=lambda x: 0 if Path(str(x.fspath)) in lf_paths else 1,
+                res.result,
+                key=sort_key,
+                reverse=True,
             )
             return
 
-        elif isinstance(collector, Module):
-            if Path(str(collector.fspath)) in self.lfplugin._last_failed_paths:
+        elif isinstance(collector, File):
+            if collector.path in self.lfplugin._last_failed_paths:
                 out = yield
                 res = out.get_result()
                 result = res.result
@@ -245,7 +264,7 @@ class LFPluginCollWrapper:
                     for x in result
                     if x.nodeid in lastfailed
                     # Include any passed arguments (not trivial to filter).
-                    or session.isinitpath(x.fspath)
+                    or session.isinitpath(x.path)
                     # Keep all sub-collectors.
                     or isinstance(x, nodes.Collector)
                 ]
@@ -261,11 +280,10 @@ class LFPluginCollSkipfiles:
     def pytest_make_collect_report(
         self, collector: nodes.Collector
     ) -> Optional[CollectReport]:
-        # Packages are Modules, but _last_failed_paths only contains
-        # test-bearing paths and doesn't try to include the paths of their
-        # packages, so don't filter them.
-        if isinstance(collector, Module) and not isinstance(collector, Package):
-            if Path(str(collector.fspath)) not in self.lfplugin._last_failed_paths:
+        # Packages are Files, but we only want to skip test-bearing Files,
+        # so don't filter Packages.
+        if isinstance(collector, File) and not isinstance(collector, Package):
+            if collector.path not in self.lfplugin._last_failed_paths:
                 self.lfplugin._skipped_files += 1
 
                 return CollectReport(
@@ -294,9 +312,14 @@ class LFPlugin:
             )
 
     def get_last_failed_paths(self) -> Set[Path]:
-        """Return a set with all Paths()s of the previously failed nodeids."""
+        """Return a set with all Paths of the previously failed nodeids and
+        their parents."""
         rootpath = self.config.rootpath
-        result = {rootpath / nodeid.split("::")[0] for nodeid in self.lastfailed}
+        result = set()
+        for nodeid in self.lastfailed:
+            path = rootpath / nodeid.split("::")[0]
+            result.add(path)
+            result.update(path.parents)
         return {x for x in result if x.exists()}
 
     def pytest_report_collectionfinish(self) -> Optional[str]:
@@ -414,7 +437,7 @@ class NFPlugin:
             self.cached_nodeids.update(item.nodeid for item in items)
 
     def _get_increasing_order(self, items: Iterable[nodes.Item]) -> List[nodes.Item]:
-        return sorted(items, key=lambda item: item.fspath.mtime(), reverse=True)  # type: ignore[no-any-return]
+        return sorted(items, key=lambda item: item.path.stat().st_mtime, reverse=True)  # type: ignore[no-any-return]
 
     def pytest_sessionfinish(self) -> None:
         config = self.config
@@ -435,7 +458,7 @@ def pytest_addoption(parser: Parser) -> None:
         "--last-failed",
         action="store_true",
         dest="lf",
-        help="rerun only the tests that failed "
+        help="Rerun only the tests that failed "
         "at the last run (or all if none failed)",
     )
     group.addoption(
@@ -443,7 +466,7 @@ def pytest_addoption(parser: Parser) -> None:
         "--failed-first",
         action="store_true",
         dest="failedfirst",
-        help="run all tests, but run the last failures first.\n"
+        help="Run all tests, but run the last failures first. "
         "This may re-order tests and thus lead to "
         "repeated fixture setup/teardown.",
     )
@@ -452,7 +475,7 @@ def pytest_addoption(parser: Parser) -> None:
         "--new-first",
         action="store_true",
         dest="newfirst",
-        help="run tests from new files first, then the rest of the tests "
+        help="Run tests from new files first, then the rest of the tests "
         "sorted by file mtime",
     )
     group.addoption(
@@ -461,7 +484,7 @@ def pytest_addoption(parser: Parser) -> None:
         nargs="?",
         dest="cacheshow",
         help=(
-            "show cache contents, don't perform collection or tests. "
+            "Show cache contents, don't perform collection or tests. "
             "Optional argument: glob (default: '*')."
         ),
     )
@@ -469,12 +492,12 @@ def pytest_addoption(parser: Parser) -> None:
         "--cache-clear",
         action="store_true",
         dest="cacheclear",
-        help="remove all cache contents at start of test run.",
+        help="Remove all cache contents at start of test run",
     )
     cache_dir_default = ".pytest_cache"
     if "TOX_ENV_DIR" in os.environ:
         cache_dir_default = os.path.join(os.environ["TOX_ENV_DIR"], cache_dir_default)
-    parser.addini("cache_dir", default=cache_dir_default, help="cache directory path.")
+    parser.addini("cache_dir", default=cache_dir_default, help="Cache directory path")
     group.addoption(
         "--lfnf",
         "--last-failed-no-failures",
@@ -482,12 +505,16 @@ def pytest_addoption(parser: Parser) -> None:
         dest="last_failed_no_failures",
         choices=("all", "none"),
         default="all",
-        help="which tests to run with no previously (known) failures.",
+        help="With ``--lf``, determines whether to execute tests when there "
+        "are no previously (known) failures or when no "
+        "cached ``lastfailed`` data was found. "
+        "``all`` (the default) runs the full test suite again. "
+        "``none`` just emits a message about no known failures and exits successfully.",
     )
 
 
 def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
-    if config.option.cacheshow:
+    if config.option.cacheshow and not config.option.help:
         from _pytest.main import wrap_session
 
         return wrap_session(config, cacheshow)
@@ -567,8 +594,8 @@ def cacheshow(config: Config, session: Session) -> int:
         contents = sorted(ddir.rglob(glob))
         tw.sep("-", "cache directories for %r" % glob)
         for p in contents:
-            # if p.check(dir=1):
-            #    print("%s/" % p.relto(basedir))
+            # if p.is_dir():
+            #    print("%s/" % p.relative_to(basedir))
             if p.is_file():
                 key = str(p.relative_to(basedir))
                 tw.line(f"{key} is a file of length {p.stat().st_size:d}")
index 086302658cbd482c6427defc41f3cf0151caa97a..a8ca0869f337e2a232540145e27e86c085b41a59 100644 (file)
@@ -1,19 +1,26 @@
 """Per-test stdout/stderr capturing mechanism."""
+import abc
+import collections
 import contextlib
-import functools
 import io
 import os
 import sys
 from io import UnsupportedOperation
 from tempfile import TemporaryFile
+from types import TracebackType
 from typing import Any
 from typing import AnyStr
+from typing import BinaryIO
 from typing import Generator
 from typing import Generic
+from typing import Iterable
 from typing import Iterator
+from typing import List
+from typing import NamedTuple
 from typing import Optional
 from typing import TextIO
 from typing import Tuple
+from typing import Type
 from typing import TYPE_CHECKING
 from typing import Union
 
@@ -29,6 +36,7 @@ from _pytest.nodes import File
 from _pytest.nodes import Item
 
 if TYPE_CHECKING:
+    from typing_extensions import Final
     from typing_extensions import Literal
 
     _CaptureMethod = Literal["fd", "sys", "no", "tee-sys"]
@@ -42,14 +50,14 @@ def pytest_addoption(parser: Parser) -> None:
         default="fd",
         metavar="method",
         choices=["fd", "sys", "no", "tee-sys"],
-        help="per-test capturing method: one of fd|sys|no|tee-sys.",
+        help="Per-test capturing method: one of fd|sys|no|tee-sys",
     )
     group._addoption(
         "-s",
         action="store_const",
         const="no",
         dest="capture",
-        help="shortcut for --capture=no.",
+        help="Shortcut for --capture=no",
     )
 
 
@@ -68,32 +76,8 @@ def _colorama_workaround() -> None:
             pass
 
 
-def _readline_workaround() -> None:
-    """Ensure readline is imported so that it attaches to the correct stdio
-    handles on Windows.
-
-    Pdb uses readline support where available--when not running from the Python
-    prompt, the readline module is not imported until running the pdb REPL.  If
-    running pytest with the --pdb option this means the readline module is not
-    imported until after I/O capture has been started.
-
-    This is a problem for pyreadline, which is often used to implement readline
-    support on Windows, as it does not attach to the correct handles for stdout
-    and/or stdin if they have been redirected by the FDCapture mechanism.  This
-    workaround ensures that readline is imported before I/O capture is setup so
-    that it can attach to the actual stdin/out for the console.
-
-    See https://github.com/pytest-dev/pytest/pull/1281.
-    """
-    if sys.platform.startswith("win32"):
-        try:
-            import readline  # noqa: F401
-        except ImportError:
-            pass
-
-
-def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
-    """Workaround for Windows Unicode console handling on Python>=3.6.
+def _windowsconsoleio_workaround(stream: TextIO) -> None:
+    """Workaround for Windows Unicode console handling.
 
     Python 3.6 implemented Unicode console handling for Windows. This works
     by reading/writing to the raw console handle using
@@ -136,7 +120,7 @@ def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
             buffering = -1
 
         return io.TextIOWrapper(
-            open(os.dup(f.fileno()), mode, buffering),  # type: ignore[arg-type]
+            open(os.dup(f.fileno()), mode, buffering),
             f.encoding,
             f.errors,
             f.newlines,
@@ -152,9 +136,8 @@ def _py36_windowsconsoleio_workaround(stream: TextIO) -> None:
 def pytest_load_initial_conftests(early_config: Config):
     ns = early_config.known_args_namespace
     if ns.capture == "fd":
-        _py36_windowsconsoleio_workaround(sys.stdout)
+        _windowsconsoleio_workaround(sys.stdout)
     _colorama_workaround()
-    _readline_workaround()
     pluginmanager = early_config.pluginmanager
     capman = CaptureManager(ns.capture)
     pluginmanager.register(capman, "capturemanager")
@@ -210,53 +193,151 @@ class TeeCaptureIO(CaptureIO):
         return self._other.write(s)
 
 
-class DontReadFromInput:
-    encoding = None
+class DontReadFromInput(TextIO):
+    @property
+    def encoding(self) -> str:
+        return sys.__stdin__.encoding
 
-    def read(self, *args):
+    def read(self, size: int = -1) -> str:
         raise OSError(
             "pytest: reading from stdin while output is captured!  Consider using `-s`."
         )
 
     readline = read
-    readlines = read
-    __next__ = read
 
-    def __iter__(self):
+    def __next__(self) -> str:
+        return self.readline()
+
+    def readlines(self, hint: Optional[int] = -1) -> List[str]:
+        raise OSError(
+            "pytest: reading from stdin while output is captured!  Consider using `-s`."
+        )
+
+    def __iter__(self) -> Iterator[str]:
         return self
 
     def fileno(self) -> int:
         raise UnsupportedOperation("redirected stdin is pseudofile, has no fileno()")
 
+    def flush(self) -> None:
+        raise UnsupportedOperation("redirected stdin is pseudofile, has no flush()")
+
     def isatty(self) -> bool:
         return False
 
     def close(self) -> None:
         pass
 
-    @property
-    def buffer(self):
+    def readable(self) -> bool:
+        return False
+
+    def seek(self, offset: int, whence: int = 0) -> int:
+        raise UnsupportedOperation("redirected stdin is pseudofile, has no seek(int)")
+
+    def seekable(self) -> bool:
+        return False
+
+    def tell(self) -> int:
+        raise UnsupportedOperation("redirected stdin is pseudofile, has no tell()")
+
+    def truncate(self, size: Optional[int] = None) -> int:
+        raise UnsupportedOperation("cannot truncate stdin")
+
+    def write(self, data: str) -> int:
+        raise UnsupportedOperation("cannot write to stdin")
+
+    def writelines(self, lines: Iterable[str]) -> None:
+        raise UnsupportedOperation("Cannot write to stdin")
+
+    def writable(self) -> bool:
+        return False
+
+    def __enter__(self) -> "DontReadFromInput":
         return self
 
+    def __exit__(
+        self,
+        type: Optional[Type[BaseException]],
+        value: Optional[BaseException],
+        traceback: Optional[TracebackType],
+    ) -> None:
+        pass
+
+    @property
+    def buffer(self) -> BinaryIO:
+        # The str/bytes doesn't actually matter in this type, so OK to fake.
+        return self  # type: ignore[return-value]
+
 
 # Capture classes.
 
 
+class CaptureBase(abc.ABC, Generic[AnyStr]):
+    EMPTY_BUFFER: AnyStr
+
+    @abc.abstractmethod
+    def __init__(self, fd: int) -> None:
+        raise NotImplementedError()
+
+    @abc.abstractmethod
+    def start(self) -> None:
+        raise NotImplementedError()
+
+    @abc.abstractmethod
+    def done(self) -> None:
+        raise NotImplementedError()
+
+    @abc.abstractmethod
+    def suspend(self) -> None:
+        raise NotImplementedError()
+
+    @abc.abstractmethod
+    def resume(self) -> None:
+        raise NotImplementedError()
+
+    @abc.abstractmethod
+    def writeorg(self, data: AnyStr) -> None:
+        raise NotImplementedError()
+
+    @abc.abstractmethod
+    def snap(self) -> AnyStr:
+        raise NotImplementedError()
+
+
 patchsysdict = {0: "stdin", 1: "stdout", 2: "stderr"}
 
 
-class NoCapture:
-    EMPTY_BUFFER = None
-    __init__ = start = done = suspend = resume = lambda *args: None
+class NoCapture(CaptureBase[str]):
+    EMPTY_BUFFER = ""
 
+    def __init__(self, fd: int) -> None:
+        pass
 
-class SysCaptureBinary:
+    def start(self) -> None:
+        pass
 
-    EMPTY_BUFFER = b""
+    def done(self) -> None:
+        pass
+
+    def suspend(self) -> None:
+        pass
 
-    def __init__(self, fd: int, tmpfile=None, *, tee: bool = False) -> None:
+    def resume(self) -> None:
+        pass
+
+    def snap(self) -> str:
+        return ""
+
+    def writeorg(self, data: str) -> None:
+        pass
+
+
+class SysCaptureBase(CaptureBase[AnyStr]):
+    def __init__(
+        self, fd: int, tmpfile: Optional[TextIO] = None, *, tee: bool = False
+    ) -> None:
         name = patchsysdict[fd]
-        self._old = getattr(sys, name)
+        self._old: TextIO = getattr(sys, name)
         self.name = name
         if tmpfile is None:
             if name == "stdin":
@@ -296,14 +377,6 @@ class SysCaptureBinary:
         setattr(sys, self.name, self.tmpfile)
         self._state = "started"
 
-    def snap(self):
-        self._assert_state("snap", ("started", "suspended"))
-        self.tmpfile.seek(0)
-        res = self.tmpfile.buffer.read()
-        self.tmpfile.seek(0)
-        self.tmpfile.truncate()
-        return res
-
     def done(self) -> None:
         self._assert_state("done", ("initialized", "started", "suspended", "done"))
         if self._state == "done":
@@ -325,36 +398,43 @@ class SysCaptureBinary:
         setattr(sys, self.name, self.tmpfile)
         self._state = "started"
 
-    def writeorg(self, data) -> None:
+
+class SysCaptureBinary(SysCaptureBase[bytes]):
+    EMPTY_BUFFER = b""
+
+    def snap(self) -> bytes:
+        self._assert_state("snap", ("started", "suspended"))
+        self.tmpfile.seek(0)
+        res = self.tmpfile.buffer.read()
+        self.tmpfile.seek(0)
+        self.tmpfile.truncate()
+        return res
+
+    def writeorg(self, data: bytes) -> None:
         self._assert_state("writeorg", ("started", "suspended"))
         self._old.flush()
         self._old.buffer.write(data)
         self._old.buffer.flush()
 
 
-class SysCapture(SysCaptureBinary):
-    EMPTY_BUFFER = ""  # type: ignore[assignment]
+class SysCapture(SysCaptureBase[str]):
+    EMPTY_BUFFER = ""
 
-    def snap(self):
+    def snap(self) -> str:
+        self._assert_state("snap", ("started", "suspended"))
+        assert isinstance(self.tmpfile, CaptureIO)
         res = self.tmpfile.getvalue()
         self.tmpfile.seek(0)
         self.tmpfile.truncate()
         return res
 
-    def writeorg(self, data):
+    def writeorg(self, data: str) -> None:
         self._assert_state("writeorg", ("started", "suspended"))
         self._old.write(data)
         self._old.flush()
 
 
-class FDCaptureBinary:
-    """Capture IO to/from a given OS-level file descriptor.
-
-    snap() produces `bytes`.
-    """
-
-    EMPTY_BUFFER = b""
-
+class FDCaptureBase(CaptureBase[AnyStr]):
     def __init__(self, targetfd: int) -> None:
         self.targetfd = targetfd
 
@@ -363,7 +443,7 @@ class FDCaptureBinary:
         except OSError:
             # FD capturing is conceptually simple -- create a temporary file,
             # redirect the FD to it, redirect back when done. But when the
-            # target FD is invalid it throws a wrench into this loveley scheme.
+            # target FD is invalid it throws a wrench into this lovely scheme.
             #
             # Tests themselves shouldn't care if the FD is valid, FD capturing
             # should work regardless of external circumstances. So falling back
@@ -379,8 +459,8 @@ class FDCaptureBinary:
         self.targetfd_save = os.dup(targetfd)
 
         if targetfd == 0:
-            self.tmpfile = open(os.devnull)
-            self.syscapture = SysCapture(targetfd)
+            self.tmpfile = open(os.devnull, encoding="utf-8")
+            self.syscapture: CaptureBase[str] = SysCapture(targetfd)
         else:
             self.tmpfile = EncodedFile(
                 TemporaryFile(buffering=0),
@@ -392,7 +472,7 @@ class FDCaptureBinary:
             if targetfd in patchsysdict:
                 self.syscapture = SysCapture(targetfd, self.tmpfile)
             else:
-                self.syscapture = NoCapture()
+                self.syscapture = NoCapture(targetfd)
 
         self._state = "initialized"
 
@@ -419,14 +499,6 @@ class FDCaptureBinary:
         self.syscapture.start()
         self._state = "started"
 
-    def snap(self):
-        self._assert_state("snap", ("started", "suspended"))
-        self.tmpfile.seek(0)
-        res = self.tmpfile.buffer.read()
-        self.tmpfile.seek(0)
-        self.tmpfile.truncate()
-        return res
-
     def done(self) -> None:
         """Stop capturing, restore streams, return original capture file,
         seeked to position zero."""
@@ -459,22 +531,38 @@ class FDCaptureBinary:
         os.dup2(self.tmpfile.fileno(), self.targetfd)
         self._state = "started"
 
-    def writeorg(self, data):
+
+class FDCaptureBinary(FDCaptureBase[bytes]):
+    """Capture IO to/from a given OS-level file descriptor.
+
+    snap() produces `bytes`.
+    """
+
+    EMPTY_BUFFER = b""
+
+    def snap(self) -> bytes:
+        self._assert_state("snap", ("started", "suspended"))
+        self.tmpfile.seek(0)
+        res = self.tmpfile.buffer.read()
+        self.tmpfile.seek(0)
+        self.tmpfile.truncate()
+        return res
+
+    def writeorg(self, data: bytes) -> None:
         """Write to original file descriptor."""
         self._assert_state("writeorg", ("started", "suspended"))
         os.write(self.targetfd_save, data)
 
 
-class FDCapture(FDCaptureBinary):
+class FDCapture(FDCaptureBase[str]):
     """Capture IO to/from a given OS-level file descriptor.
 
     snap() produces text.
     """
 
-    # Ignore type because it doesn't match the type in the superclass (bytes).
-    EMPTY_BUFFER = ""  # type: ignore
+    EMPTY_BUFFER = ""
 
-    def snap(self):
+    def snap(self) -> str:
         self._assert_state("snap", ("started", "suspended"))
         self.tmpfile.seek(0)
         res = self.tmpfile.read()
@@ -482,81 +570,57 @@ class FDCapture(FDCaptureBinary):
         self.tmpfile.truncate()
         return res
 
-    def writeorg(self, data):
+    def writeorg(self, data: str) -> None:
         """Write to original file descriptor."""
-        super().writeorg(data.encode("utf-8"))  # XXX use encoding of original stream
+        self._assert_state("writeorg", ("started", "suspended"))
+        # XXX use encoding of original stream
+        os.write(self.targetfd_save, data.encode("utf-8"))
 
 
 # MultiCapture
 
 
-# This class was a namedtuple, but due to mypy limitation[0] it could not be
-# made generic, so was replaced by a regular class which tries to emulate the
-# pertinent parts of a namedtuple. If the mypy limitation is ever lifted, can
-# make it a namedtuple again.
-# [0]: https://github.com/python/mypy/issues/685
-@final
-@functools.total_ordering
-class CaptureResult(Generic[AnyStr]):
-    """The result of :method:`CaptureFixture.readouterr`."""
-
-    __slots__ = ("out", "err")
-
-    def __init__(self, out: AnyStr, err: AnyStr) -> None:
-        self.out: AnyStr = out
-        self.err: AnyStr = err
-
-    def __len__(self) -> int:
-        return 2
-
-    def __iter__(self) -> Iterator[AnyStr]:
-        return iter((self.out, self.err))
+# Generic NamedTuple only supported since Python 3.11.
+if sys.version_info >= (3, 11) or TYPE_CHECKING:
 
-    def __getitem__(self, item: int) -> AnyStr:
-        return tuple(self)[item]
+    @final
+    class CaptureResult(NamedTuple, Generic[AnyStr]):
+        """The result of :method:`CaptureFixture.readouterr`."""
 
-    def _replace(
-        self, *, out: Optional[AnyStr] = None, err: Optional[AnyStr] = None
-    ) -> "CaptureResult[AnyStr]":
-        return CaptureResult(
-            out=self.out if out is None else out, err=self.err if err is None else err
-        )
-
-    def count(self, value: AnyStr) -> int:
-        return tuple(self).count(value)
-
-    def index(self, value) -> int:
-        return tuple(self).index(value)
+        out: AnyStr
+        err: AnyStr
 
-    def __eq__(self, other: object) -> bool:
-        if not isinstance(other, (CaptureResult, tuple)):
-            return NotImplemented
-        return tuple(self) == tuple(other)
+else:
 
-    def __hash__(self) -> int:
-        return hash(tuple(self))
+    class CaptureResult(
+        collections.namedtuple("CaptureResult", ["out", "err"]), Generic[AnyStr]
+    ):
+        """The result of :method:`CaptureFixture.readouterr`."""
 
-    def __lt__(self, other: object) -> bool:
-        if not isinstance(other, (CaptureResult, tuple)):
-            return NotImplemented
-        return tuple(self) < tuple(other)
-
-    def __repr__(self) -> str:
-        return f"CaptureResult(out={self.out!r}, err={self.err!r})"
+        __slots__ = ()
 
 
 class MultiCapture(Generic[AnyStr]):
     _state = None
     _in_suspended = False
 
-    def __init__(self, in_, out, err) -> None:
-        self.in_ = in_
-        self.out = out
-        self.err = err
+    def __init__(
+        self,
+        in_: Optional[CaptureBase[AnyStr]],
+        out: Optional[CaptureBase[AnyStr]],
+        err: Optional[CaptureBase[AnyStr]],
+    ) -> None:
+        self.in_: Optional[CaptureBase[AnyStr]] = in_
+        self.out: Optional[CaptureBase[AnyStr]] = out
+        self.err: Optional[CaptureBase[AnyStr]] = err
 
     def __repr__(self) -> str:
         return "<MultiCapture out={!r} err={!r} in_={!r} _state={!r} _in_suspended={!r}>".format(
-            self.out, self.err, self.in_, self._state, self._in_suspended,
+            self.out,
+            self.err,
+            self.in_,
+            self._state,
+            self._in_suspended,
         )
 
     def start_capturing(self) -> None:
@@ -572,8 +636,10 @@ class MultiCapture(Generic[AnyStr]):
         """Pop current snapshot out/err capture and flush to orig streams."""
         out, err = self.readouterr()
         if out:
+            assert self.out is not None
             self.out.writeorg(out)
         if err:
+            assert self.err is not None
             self.err.writeorg(err)
         return out, err
 
@@ -594,6 +660,7 @@ class MultiCapture(Generic[AnyStr]):
         if self.err:
             self.err.resume()
         if self._in_suspended:
+            assert self.in_ is not None
             self.in_.resume()
             self._in_suspended = False
 
@@ -614,15 +681,10 @@ class MultiCapture(Generic[AnyStr]):
         return self._state == "started"
 
     def readouterr(self) -> CaptureResult[AnyStr]:
-        if self.out:
-            out = self.out.snap()
-        else:
-            out = ""
-        if self.err:
-            err = self.err.snap()
-        else:
-            err = ""
-        return CaptureResult(out, err)
+        out = self.out.snap() if self.out else ""
+        err = self.err.snap() if self.err else ""
+        # TODO: This type error is real, need to fix.
+        return CaptureResult(out, err)  # type: ignore[arg-type]
 
 
 def _get_multicapture(method: "_CaptureMethod") -> MultiCapture[str]:
@@ -662,7 +724,7 @@ class CaptureManager:
     """
 
     def __init__(self, method: "_CaptureMethod") -> None:
-        self._method = method
+        self._method: Final = method
         self._global_capturing: Optional[MultiCapture[str]] = None
         self._capture_fixture: Optional[CaptureFixture[Any]] = None
 
@@ -831,19 +893,25 @@ class CaptureFixture(Generic[AnyStr]):
     :fixture:`capfd` and :fixture:`capfdbinary` fixtures."""
 
     def __init__(
-        self, captureclass, request: SubRequest, *, _ispytest: bool = False
+        self,
+        captureclass: Type[CaptureBase[AnyStr]],
+        request: SubRequest,
+        *,
+        _ispytest: bool = False,
     ) -> None:
         check_ispytest(_ispytest)
-        self.captureclass = captureclass
+        self.captureclass: Type[CaptureBase[AnyStr]] = captureclass
         self.request = request
         self._capture: Optional[MultiCapture[AnyStr]] = None
-        self._captured_out = self.captureclass.EMPTY_BUFFER
-        self._captured_err = self.captureclass.EMPTY_BUFFER
+        self._captured_out: AnyStr = self.captureclass.EMPTY_BUFFER
+        self._captured_err: AnyStr = self.captureclass.EMPTY_BUFFER
 
     def _start(self) -> None:
         if self._capture is None:
             self._capture = MultiCapture(
-                in_=None, out=self.captureclass(1), err=self.captureclass(2),
+                in_=None,
+                out=self.captureclass(1),
+                err=self.captureclass(2),
             )
             self._capture.start_capturing()
 
@@ -891,7 +959,9 @@ class CaptureFixture(Generic[AnyStr]):
     @contextlib.contextmanager
     def disabled(self) -> Generator[None, None, None]:
         """Temporarily disable capturing while inside the ``with`` block."""
-        capmanager = self.request.config.pluginmanager.getplugin("capturemanager")
+        capmanager: CaptureManager = self.request.config.pluginmanager.getplugin(
+            "capturemanager"
+        )
         with capmanager.global_and_fixture_disabled():
             yield
 
@@ -901,14 +971,25 @@ class CaptureFixture(Generic[AnyStr]):
 
 @fixture
 def capsys(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
-    """Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
+    r"""Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
 
     The captured output is made available via ``capsys.readouterr()`` method
     calls, which return a ``(out, err)`` namedtuple.
     ``out`` and ``err`` will be ``text`` objects.
+
+    Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
+
+    Example:
+
+    .. code-block:: python
+
+        def test_output(capsys):
+            print("hello")
+            captured = capsys.readouterr()
+            assert captured.out == "hello\n"
     """
-    capman = request.config.pluginmanager.getplugin("capturemanager")
-    capture_fixture = CaptureFixture[str](SysCapture, request, _ispytest=True)
+    capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
+    capture_fixture = CaptureFixture(SysCapture, request, _ispytest=True)
     capman.set_fixture(capture_fixture)
     capture_fixture._start()
     yield capture_fixture
@@ -918,14 +999,25 @@ def capsys(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
 
 @fixture
 def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
-    """Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
+    r"""Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
 
     The captured output is made available via ``capsysbinary.readouterr()``
     method calls, which return a ``(out, err)`` namedtuple.
     ``out`` and ``err`` will be ``bytes`` objects.
+
+    Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
+
+    Example:
+
+    .. code-block:: python
+
+        def test_output(capsysbinary):
+            print("hello")
+            captured = capsysbinary.readouterr()
+            assert captured.out == b"hello\n"
     """
-    capman = request.config.pluginmanager.getplugin("capturemanager")
-    capture_fixture = CaptureFixture[bytes](SysCaptureBinary, request, _ispytest=True)
+    capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
+    capture_fixture = CaptureFixture(SysCaptureBinary, request, _ispytest=True)
     capman.set_fixture(capture_fixture)
     capture_fixture._start()
     yield capture_fixture
@@ -935,14 +1027,25 @@ def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None,
 
 @fixture
 def capfd(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
-    """Enable text capturing of writes to file descriptors ``1`` and ``2``.
+    r"""Enable text capturing of writes to file descriptors ``1`` and ``2``.
 
     The captured output is made available via ``capfd.readouterr()`` method
     calls, which return a ``(out, err)`` namedtuple.
     ``out`` and ``err`` will be ``text`` objects.
+
+    Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
+
+    Example:
+
+    .. code-block:: python
+
+        def test_system_echo(capfd):
+            os.system('echo "hello"')
+            captured = capfd.readouterr()
+            assert captured.out == "hello\n"
     """
-    capman = request.config.pluginmanager.getplugin("capturemanager")
-    capture_fixture = CaptureFixture[str](FDCapture, request, _ispytest=True)
+    capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
+    capture_fixture = CaptureFixture(FDCapture, request, _ispytest=True)
     capman.set_fixture(capture_fixture)
     capture_fixture._start()
     yield capture_fixture
@@ -952,14 +1055,26 @@ def capfd(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
 
 @fixture
 def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
-    """Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
+    r"""Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
 
     The captured output is made available via ``capfd.readouterr()`` method
     calls, which return a ``(out, err)`` namedtuple.
     ``out`` and ``err`` will be ``byte`` objects.
+
+    Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
+
+    Example:
+
+    .. code-block:: python
+
+        def test_system_echo(capfdbinary):
+            os.system('echo "hello"')
+            captured = capfdbinary.readouterr()
+            assert captured.out == b"hello\n"
+
     """
-    capman = request.config.pluginmanager.getplugin("capturemanager")
-    capture_fixture = CaptureFixture[bytes](FDCaptureBinary, request, _ispytest=True)
+    capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager")
+    capture_fixture = CaptureFixture(FDCaptureBinary, request, _ispytest=True)
     capman.set_fixture(capture_fixture)
     capture_fixture._start()
     yield capture_fixture
index c7f86ea9c0add4dc54c65827e2c7ea50673f7a50..1d0add7363e273d09adf1b15738be4afb31e0522 100644 (file)
@@ -1,58 +1,75 @@
 """Python version compatibility code."""
+from __future__ import annotations
+
+import dataclasses
 import enum
 import functools
 import inspect
-import re
+import os
 import sys
-from contextlib import contextmanager
 from inspect import Parameter
 from inspect import signature
 from pathlib import Path
 from typing import Any
 from typing import Callable
 from typing import Generic
-from typing import Optional
-from typing import Tuple
+from typing import NoReturn
 from typing import TYPE_CHECKING
 from typing import TypeVar
-from typing import Union
 
-import attr
+import py
 
-from _pytest.outcomes import fail
-from _pytest.outcomes import TEST_OUTCOME
+# fmt: off
+# Workaround for https://github.com/sphinx-doc/sphinx/issues/10351.
+# If `overload` is imported from `compat` instead of from `typing`,
+# Sphinx doesn't recognize it as `overload` and the API docs for
+# overloaded functions look good again. But type checkers handle
+# it fine.
+# fmt: on
+if True:
+    from typing import overload as overload
 
 if TYPE_CHECKING:
-    from typing import NoReturn
     from typing_extensions import Final
 
 
 _T = TypeVar("_T")
 _S = TypeVar("_S")
 
+#: constant to prepare valuing pylib path replacements/lazy proxies later on
+#  intended for removal in pytest 8.0 or 9.0
+
+# fmt: off
+# intentional space to create a fake difference for the verification
+LEGACY_PATH = py.path. local
+# fmt: on
+
+
+def legacy_path(path: str | os.PathLike[str]) -> LEGACY_PATH:
+    """Internal wrapper to prepare lazy proxies for legacy_path instances"""
+    return LEGACY_PATH(path)
+
 
 # fmt: off
 # Singleton type for NOTSET, as described in:
 # https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions
 class NotSetType(enum.Enum):
     token = 0
-NOTSET: "Final" = NotSetType.token  # noqa: E305
+NOTSET: Final = NotSetType.token  # noqa: E305
 # fmt: on
 
 if sys.version_info >= (3, 8):
-    from importlib import metadata as importlib_metadata
+    import importlib.metadata
+
+    importlib_metadata = importlib.metadata
 else:
-    import importlib_metadata  # noqa: F401
+    import importlib_metadata as importlib_metadata  # noqa: F401
 
 
 def _format_args(func: Callable[..., Any]) -> str:
     return str(signature(func))
 
 
-# The type of re.compile objects is not exposed in Python.
-REGEX_TYPE = type(re.compile(""))
-
-
 def is_generator(func: object) -> bool:
     genfunc = inspect.isgeneratorfunction(func)
     return genfunc and not iscoroutinefunction(func)
@@ -76,7 +93,7 @@ def is_async_function(func: object) -> bool:
     return iscoroutinefunction(func) or inspect.isasyncgenfunction(func)
 
 
-def getlocation(function, curdir: Optional[str] = None) -> str:
+def getlocation(function, curdir: str | None = None) -> str:
     function = get_real_func(function)
     fn = Path(inspect.getfile(function))
     lineno = function.__code__.co_firstlineno
@@ -114,8 +131,8 @@ def getfuncargnames(
     *,
     name: str = "",
     is_method: bool = False,
-    cls: Optional[type] = None,
-) -> Tuple[str, ...]:
+    cls: type | None = None,
+) -> tuple[str, ...]:
     """Return the names of a function's mandatory arguments.
 
     Should return the names of all function arguments that:
@@ -142,8 +159,11 @@ def getfuncargnames(
     try:
         parameters = signature(function).parameters
     except (ValueError, TypeError) as e:
+        from _pytest.outcomes import fail
+
         fail(
-            f"Could not determine arguments of {function!r}: {e}", pytrace=False,
+            f"Could not determine arguments of {function!r}: {e}",
+            pytrace=False,
         )
 
     arg_names = tuple(
@@ -162,7 +182,12 @@ def getfuncargnames(
     # it's passed as an unbound method or function, remove the first
     # parameter name.
     if is_method or (
-        cls and not isinstance(cls.__dict__.get(name, None), staticmethod)
+        # Not using `getattr` because we don't want to resolve the staticmethod.
+        # Not using `cls.__dict__` because we want to check the entire MRO.
+        cls
+        and not isinstance(
+            inspect.getattr_static(cls, name, default=None), staticmethod
+        )
     ):
         arg_names = arg_names[1:]
     # Remove any names that will be replaced with mocks.
@@ -171,18 +196,7 @@ def getfuncargnames(
     return arg_names
 
 
-if sys.version_info < (3, 7):
-
-    @contextmanager
-    def nullcontext():
-        yield
-
-
-else:
-    from contextlib import nullcontext as nullcontext  # noqa: F401
-
-
-def get_default_arg_names(function: Callable[..., Any]) -> Tuple[str, ...]:
+def get_default_arg_names(function: Callable[..., Any]) -> tuple[str, ...]:
     # Note: this code intentionally mirrors the code at the beginning of
     # getfuncargnames, to get the arguments which were excluded from its result
     # because they had default values.
@@ -213,7 +227,7 @@ def _bytes_to_ascii(val: bytes) -> str:
     return val.decode("ascii", "backslashreplace")
 
 
-def ascii_escaped(val: Union[bytes, str]) -> str:
+def ascii_escaped(val: bytes | str) -> str:
     r"""If val is pure ASCII, return it as an str, otherwise, escape
     bytes objects into a sequence of escaped bytes:
 
@@ -237,7 +251,7 @@ def ascii_escaped(val: Union[bytes, str]) -> str:
     return _translate_non_printable(ret)
 
 
-@attr.s
+@dataclasses.dataclass
 class _PytestWrapper:
     """Dummy wrapper around a function object for internal use only.
 
@@ -246,7 +260,7 @@ class _PytestWrapper:
     decorator to issue warnings when the fixture function is called directly.
     """
 
-    obj = attr.ib()
+    obj: Any
 
 
 def get_real_func(obj):
@@ -308,6 +322,8 @@ def safe_getattr(object: Any, name: str, default: Any) -> Any:
     are derived from BaseException instead of Exception (for more details
     check #2707).
     """
+    from _pytest.outcomes import TEST_OUTCOME
+
     try:
         return getattr(object, name, default)
     except TEST_OUTCOME:
@@ -338,8 +354,6 @@ else:
 if sys.version_info >= (3, 8):
     from functools import cached_property as cached_property
 else:
-    from typing import overload
-    from typing import Type
 
     class cached_property(Generic[_S, _T]):
         __slots__ = ("func", "__doc__")
@@ -350,12 +364,12 @@ else:
 
         @overload
         def __get__(
-            self, instance: None, owner: Optional[Type[_S]] = ...
-        ) -> "cached_property[_S, _T]":
+            self, instance: None, owner: type[_S] | None = ...
+        ) -> cached_property[_S, _T]:
             ...
 
         @overload
-        def __get__(self, instance: _S, owner: Optional[Type[_S]] = ...) -> _T:
+        def __get__(self, instance: _S, owner: type[_S] | None = ...) -> _T:
             ...
 
         def __get__(self, instance, owner=None):
@@ -365,6 +379,27 @@ else:
             return value
 
 
+def get_user_id() -> int | None:
+    """Return the current process's real user id or None if it could not be
+    determined.
+
+    :return: The user id or None if it could not be determined.
+    """
+    # mypy follows the version and platform checking expectation of PEP 484:
+    # https://mypy.readthedocs.io/en/stable/common_issues.html?highlight=platform#python-version-and-system-platform-checks
+    # Containment checks are too complex for mypy v1.5.0 and cause failure.
+    if sys.platform == "win32" or sys.platform == "emscripten":
+        # win32 does not have a getuid() function.
+        # Emscripten has a return 0 stub.
+        return None
+    else:
+        # On other platforms, a return value of -1 is assumed to indicate that
+        # the current process's real user id could not be determined.
+        ERROR = -1
+        uid = os.getuid()
+        return uid if uid != ERROR else None
+
+
 # Perform exhaustiveness checking.
 #
 # Consider this example:
@@ -396,5 +431,5 @@ else:
 # previously.
 #
 # This also work for Enums (if you use `is` to compare) and Literals.
-def assert_never(value: "NoReturn") -> "NoReturn":
-    assert False, "Unhandled value: {} ({})".format(value, type(value).__name__)
+def assert_never(value: NoReturn) -> NoReturn:
+    assert False, f"Unhandled value: {value} ({type(value).__name__})"
index bd9e2883f9f4ce58c2cbc82112f502e954cdd1f5..e3990d175dfc067ec55e5adcab21c150c249fe8c 100644 (file)
@@ -1,9 +1,10 @@
 """Command line options, ini-file and conftest.py processing."""
 import argparse
 import collections.abc
-import contextlib
 import copy
+import dataclasses
 import enum
+import glob
 import inspect
 import os
 import re
@@ -13,9 +14,12 @@ import types
 import warnings
 from functools import lru_cache
 from pathlib import Path
+from textwrap import dedent
+from types import FunctionType
 from types import TracebackType
 from typing import Any
 from typing import Callable
+from typing import cast
 from typing import Dict
 from typing import Generator
 from typing import IO
@@ -31,8 +35,6 @@ from typing import Type
 from typing import TYPE_CHECKING
 from typing import Union
 
-import attr
-import py
 from pluggy import HookimplMarker
 from pluggy import HookspecMarker
 from pluggy import PluginManager
@@ -47,17 +49,20 @@ from _pytest._code import ExceptionInfo
 from _pytest._code import filter_traceback
 from _pytest._io import TerminalWriter
 from _pytest.compat import final
-from _pytest.compat import importlib_metadata
+from _pytest.compat import importlib_metadata  # type: ignore[attr-defined]
 from _pytest.outcomes import fail
 from _pytest.outcomes import Skipped
+from _pytest.pathlib import absolutepath
 from _pytest.pathlib import bestrelpath
 from _pytest.pathlib import import_path
 from _pytest.pathlib import ImportMode
-from _pytest.store import Store
+from _pytest.pathlib import resolve_package_path
+from _pytest.pathlib import safe_exists
+from _pytest.stash import Stash
 from _pytest.warning_types import PytestConfigWarning
+from _pytest.warning_types import warn_explicit_for
 
 if TYPE_CHECKING:
-
     from _pytest._code.code import _TracebackStyle
     from _pytest.terminal import TerminalReporter
     from .argparsing import Argument
@@ -103,7 +108,7 @@ class ExitCode(enum.IntEnum):
 class ConftestImportFailure(Exception):
     def __init__(
         self,
-        path: py.path.local,
+        path: Path,
         excinfo: Tuple[Type[Exception], Exception, TracebackType],
     ) -> None:
         super().__init__(path, excinfo)
@@ -128,12 +133,14 @@ def filter_traceback_for_conftest_import_failure(
 
 
 def main(
-    args: Optional[Union[List[str], py.path.local]] = None,
+    args: Optional[Union[List[str], "os.PathLike[str]"]] = None,
     plugins: Optional[Sequence[Union[str, _PluggyPlugin]]] = None,
 ) -> Union[int, ExitCode]:
     """Perform an in-process test run.
 
-    :param args: List of command line arguments.
+    :param args:
+        List of command line arguments. If `None` or not given, defaults to reading
+        arguments directly from the process command line (:data:`sys.argv`).
     :param plugins: List of plugin objects to be auto-registered during initialization.
 
     :returns: An exit code.
@@ -142,7 +149,7 @@ def main(
         try:
             config = _prepareconfig(args, plugins)
         except ConftestImportFailure as e:
-            exc_info = ExceptionInfo(e.excinfo)
+            exc_info = ExceptionInfo.from_exc_info(e.excinfo)
             tw = TerminalWriter(sys.stderr)
             tw.line(f"ImportError while loading conftest '{e.path}'.", red=True)
             exc_info.traceback = exc_info.traceback.filter(
@@ -235,6 +242,7 @@ default_plugins = essential_plugins + (
     "unittest",
     "capture",
     "skipping",
+    "legacypath",
     "tmpdir",
     "monkeypatch",
     "recwarn",
@@ -251,6 +259,7 @@ default_plugins = essential_plugins + (
     "warnings",
     "logging",
     "reports",
+    "python_path",
     *(["unraisableexception", "threadexception"] if sys.version_info >= (3, 8) else []),
     "faulthandler",
 )
@@ -269,7 +278,9 @@ def get_config(
     config = Config(
         pluginmanager,
         invocation_params=Config.InvocationParams(
-            args=args or (), plugins=plugins, dir=Path.cwd(),
+            args=args or (),
+            plugins=plugins,
+            dir=Path.cwd(),
         ),
     )
 
@@ -285,7 +296,7 @@ def get_config(
 
 def get_plugin_manager() -> "PytestPluginManager":
     """Obtain a new instance of the
-    :py:class:`_pytest.config.PytestPluginManager`, with default plugins
+    :py:class:`pytest.PytestPluginManager`, with default plugins
     already loaded.
 
     This function can be used by integration with other tools, like hooking
@@ -295,15 +306,17 @@ def get_plugin_manager() -> "PytestPluginManager":
 
 
 def _prepareconfig(
-    args: Optional[Union[py.path.local, List[str]]] = None,
+    args: Optional[Union[List[str], "os.PathLike[str]"]] = None,
     plugins: Optional[Sequence[Union[str, _PluggyPlugin]]] = None,
 ) -> "Config":
     if args is None:
         args = sys.argv[1:]
-    elif isinstance(args, py.path.local):
-        args = [str(args)]
+    elif isinstance(args, os.PathLike):
+        args = [os.fspath(args)]
     elif not isinstance(args, list):
-        msg = "`args` parameter expected to be a list of strings, got: {!r} (type: {})"
+        msg = (  # type:ignore[unreachable]
+            "`args` parameter expected to be a list of strings, got: {!r} (type: {})"
+        )
         raise TypeError(msg.format(args, type(args)))
 
     config = get_config(args, plugins)
@@ -324,6 +337,46 @@ def _prepareconfig(
         raise
 
 
+def _get_directory(path: Path) -> Path:
+    """Get the directory of a path - itself if already a directory."""
+    if path.is_file():
+        return path.parent
+    else:
+        return path
+
+
+def _get_legacy_hook_marks(
+    method: Any,
+    hook_type: str,
+    opt_names: Tuple[str, ...],
+) -> Dict[str, bool]:
+    if TYPE_CHECKING:
+        # abuse typeguard from importlib to avoid massive method type union thats lacking a alias
+        assert inspect.isroutine(method)
+    known_marks: set[str] = {m.name for m in getattr(method, "pytestmark", [])}
+    must_warn: list[str] = []
+    opts: dict[str, bool] = {}
+    for opt_name in opt_names:
+        opt_attr = getattr(method, opt_name, AttributeError)
+        if opt_attr is not AttributeError:
+            must_warn.append(f"{opt_name}={opt_attr}")
+            opts[opt_name] = True
+        elif opt_name in known_marks:
+            must_warn.append(f"{opt_name}=True")
+            opts[opt_name] = True
+        else:
+            opts[opt_name] = False
+    if must_warn:
+        hook_opts = ", ".join(must_warn)
+        message = _pytest.deprecated.HOOK_LEGACY_MARKING.format(
+            type=hook_type,
+            fullname=method.__qualname__,
+            hook_opts=hook_opts,
+        )
+        warn_explicit_for(cast(FunctionType, method), message)
+    return opts
+
+
 @final
 class PytestPluginManager(PluginManager):
     """A :py:class:`pluggy.PluginManager <pluggy.PluginManager>` with
@@ -338,15 +391,25 @@ class PytestPluginManager(PluginManager):
         import _pytest.assertion
 
         super().__init__("pytest")
-        # The objects are module objects, only used generically.
-        self._conftest_plugins: Set[types.ModuleType] = set()
 
-        # State related to local conftest plugins.
-        self._dirpath2confmods: Dict[py.path.local, List[types.ModuleType]] = {}
-        self._conftestpath2mod: Dict[Path, types.ModuleType] = {}
-        self._confcutdir: Optional[py.path.local] = None
+        # -- State related to local conftest plugins.
+        # All loaded conftest modules.
+        self._conftest_plugins: Set[types.ModuleType] = set()
+        # All conftest modules applicable for a directory.
+        # This includes the directory's own conftest modules as well
+        # as those of its parent directories.
+        self._dirpath2confmods: Dict[Path, List[types.ModuleType]] = {}
+        # Cutoff directory above which conftests are no longer discovered.
+        self._confcutdir: Optional[Path] = None
+        # If set, conftest loading is skipped.
         self._noconftest = False
-        self._duplicatepaths: Set[py.path.local] = set()
+
+        # _getconftestmodules()'s call to _get_directory() causes a stat
+        # storm when it's called potentially thousands of times in a test
+        # session (#9478), often with the same path, so cache it.
+        self._get_directory = lru_cache(256)(_get_directory)
+
+        self._duplicatepaths: Set[Path] = set()
 
         # plugins that were explicitly skipped with pytest.skip
         # list of (module name, skip reason)
@@ -362,7 +425,10 @@ class PytestPluginManager(PluginManager):
             encoding: str = getattr(err, "encoding", "utf8")
             try:
                 err = open(
-                    os.dup(err.fileno()), mode=err.mode, buffering=1, encoding=encoding,
+                    os.dup(err.fileno()),
+                    mode=err.mode,
+                    buffering=1,
+                    encoding=encoding,
                 )
             except Exception:
                 pass
@@ -379,45 +445,34 @@ class PytestPluginManager(PluginManager):
         # so we avoid accessing possibly non-readable attributes
         # (see issue #1073).
         if not name.startswith("pytest_"):
-            return
+            return None
         # Ignore names which can not be hooks.
         if name == "pytest_plugins":
-            return
+            return None
 
-        method = getattr(plugin, name)
         opts = super().parse_hookimpl_opts(plugin, name)
+        if opts is not None:
+            return opts
 
+        method = getattr(plugin, name)
         # Consider only actual functions for hooks (#3775).
         if not inspect.isroutine(method):
-            return
-
+            return None
         # Collect unmarked hooks as long as they have the `pytest_' prefix.
-        if opts is None and name.startswith("pytest_"):
-            opts = {}
-        if opts is not None:
-            # TODO: DeprecationWarning, people should use hookimpl
-            # https://github.com/pytest-dev/pytest/issues/4562
-            known_marks = {m.name for m in getattr(method, "pytestmark", [])}
-
-            for name in ("tryfirst", "trylast", "optionalhook", "hookwrapper"):
-                opts.setdefault(name, hasattr(method, name) or name in known_marks)
-        return opts
+        return _get_legacy_hook_marks(  # type: ignore[return-value]
+            method, "impl", ("tryfirst", "trylast", "optionalhook", "hookwrapper")
+        )
 
     def parse_hookspec_opts(self, module_or_class, name: str):
         opts = super().parse_hookspec_opts(module_or_class, name)
         if opts is None:
             method = getattr(module_or_class, name)
-
             if name.startswith("pytest_"):
-                # todo: deprecate hookspec hacks
-                # https://github.com/pytest-dev/pytest/issues/4562
-                known_marks = {m.name for m in getattr(method, "pytestmark", [])}
-                opts = {
-                    "firstresult": hasattr(method, "firstresult")
-                    or "firstresult" in known_marks,
-                    "historic": hasattr(method, "historic")
-                    or "historic" in known_marks,
-                }
+                opts = _get_legacy_hook_marks(  # type: ignore[assignment]
+                    method,
+                    "spec",
+                    ("firstresult", "historic"),
+                )
         return opts
 
     def register(
@@ -459,19 +514,29 @@ class PytestPluginManager(PluginManager):
         config.addinivalue_line(
             "markers",
             "tryfirst: mark a hook implementation function such that the "
-            "plugin machinery will try to call it first/as early as possible.",
+            "plugin machinery will try to call it first/as early as possible. "
+            "DEPRECATED, use @pytest.hookimpl(tryfirst=True) instead.",
         )
         config.addinivalue_line(
             "markers",
             "trylast: mark a hook implementation function such that the "
-            "plugin machinery will try to call it last/as late as possible.",
+            "plugin machinery will try to call it last/as late as possible. "
+            "DEPRECATED, use @pytest.hookimpl(trylast=True) instead.",
         )
         self._configured = True
 
     #
     # Internal API for local conftest plugin handling.
     #
-    def _set_initial_conftests(self, namespace: argparse.Namespace) -> None:
+    def _set_initial_conftests(
+        self,
+        args: Sequence[Union[str, Path]],
+        pyargs: bool,
+        noconftest: bool,
+        rootpath: Path,
+        confcutdir: Optional[Path],
+        importmode: Union[ImportMode, str],
+    ) -> None:
         """Load initial conftest files given a preparsed "namespace".
 
         As conftest files may add their own command line options which have
@@ -479,69 +544,81 @@ class PytestPluginManager(PluginManager):
         All builtin and 3rd party plugins will have been loaded, however, so
         common options will not confuse our logic here.
         """
-        current = py.path.local()
-        self._confcutdir = (
-            current.join(namespace.confcutdir, abs=True)
-            if namespace.confcutdir
-            else None
-        )
-        self._noconftest = namespace.noconftest
-        self._using_pyargs = namespace.pyargs
-        testpaths = namespace.file_or_dir
+        current = Path.cwd()
+        self._confcutdir = absolutepath(current / confcutdir) if confcutdir else None
+        self._noconftest = noconftest
+        self._using_pyargs = pyargs
         foundanchor = False
-        for testpath in testpaths:
-            path = str(testpath)
+        for intitial_path in args:
+            path = str(intitial_path)
             # remove node-id syntax
             i = path.find("::")
             if i != -1:
                 path = path[:i]
-            anchor = current.join(path, abs=1)
-            if anchor.exists():  # we found some file object
-                self._try_load_conftest(anchor, namespace.importmode)
+            anchor = absolutepath(current / path)
+
+            # Ensure we do not break if what appears to be an anchor
+            # is in fact a very long option (#10169, #11394).
+            if safe_exists(anchor):
+                self._try_load_conftest(anchor, importmode, rootpath)
                 foundanchor = True
         if not foundanchor:
-            self._try_load_conftest(current, namespace.importmode)
+            self._try_load_conftest(current, importmode, rootpath)
+
+    def _is_in_confcutdir(self, path: Path) -> bool:
+        """Whether a path is within the confcutdir.
+
+        When false, should not load conftest.
+        """
+        if self._confcutdir is None:
+            return True
+        return path not in self._confcutdir.parents
 
     def _try_load_conftest(
-        self, anchor: py.path.local, importmode: Union[str, ImportMode]
+        self, anchor: Path, importmode: Union[str, ImportMode], rootpath: Path
     ) -> None:
-        self._getconftestmodules(anchor, importmode)
+        self._getconftestmodules(anchor, importmode, rootpath)
         # let's also consider test* subdirs
-        if anchor.check(dir=1):
-            for x in anchor.listdir("test*"):
-                if x.check(dir=1):
-                    self._getconftestmodules(x, importmode)
+        if anchor.is_dir():
+            for x in anchor.glob("test*"):
+                if x.is_dir():
+                    self._getconftestmodules(x, importmode, rootpath)
 
-    @lru_cache(maxsize=128)
     def _getconftestmodules(
-        self, path: py.path.local, importmode: Union[str, ImportMode],
-    ) -> List[types.ModuleType]:
+        self, path: Path, importmode: Union[str, ImportMode], rootpath: Path
+    ) -> Sequence[types.ModuleType]:
         if self._noconftest:
             return []
 
-        if path.isfile():
-            directory = path.dirpath()
-        else:
-            directory = path
+        directory = self._get_directory(path)
+
+        # Optimization: avoid repeated searches in the same directory.
+        # Assumes always called with same importmode and rootpath.
+        existing_clist = self._dirpath2confmods.get(directory)
+        if existing_clist is not None:
+            return existing_clist
 
         # XXX these days we may rather want to use config.rootpath
         # and allow users to opt into looking into the rootdir parent
         # directories instead of requiring to specify confcutdir.
         clist = []
-        for parent in directory.parts():
-            if self._confcutdir and self._confcutdir.relto(parent):
-                continue
-            conftestpath = parent.join("conftest.py")
-            if conftestpath.isfile():
-                mod = self._importconftest(conftestpath, importmode)
-                clist.append(mod)
+        for parent in reversed((directory, *directory.parents)):
+            if self._is_in_confcutdir(parent):
+                conftestpath = parent / "conftest.py"
+                if conftestpath.is_file():
+                    mod = self._importconftest(conftestpath, importmode, rootpath)
+                    clist.append(mod)
         self._dirpath2confmods[directory] = clist
         return clist
 
     def _rget_with_confmod(
-        self, name: str, path: py.path.local, importmode: Union[str, ImportMode],
+        self,
+        name: str,
+        path: Path,
+        importmode: Union[str, ImportMode],
+        rootpath: Path,
     ) -> Tuple[types.ModuleType, Any]:
-        modules = self._getconftestmodules(path, importmode)
+        modules = self._getconftestmodules(path, importmode, rootpath=rootpath)
         for mod in reversed(modules):
             try:
                 return mod, getattr(mod, name)
@@ -550,24 +627,18 @@ class PytestPluginManager(PluginManager):
         raise KeyError(name)
 
     def _importconftest(
-        self, conftestpath: py.path.local, importmode: Union[str, ImportMode],
+        self, conftestpath: Path, importmode: Union[str, ImportMode], rootpath: Path
     ) -> types.ModuleType:
-        # Use a resolved Path object as key to avoid loading the same conftest
-        # twice with build systems that create build directories containing
-        # symlinks to actual files.
-        # Using Path().resolve() is better than py.path.realpath because
-        # it resolves to the correct path/drive in case-insensitive file systems (#5792)
-        key = Path(str(conftestpath)).resolve()
-
-        with contextlib.suppress(KeyError):
-            return self._conftestpath2mod[key]
+        existing = self.get_plugin(str(conftestpath))
+        if existing is not None:
+            return cast(types.ModuleType, existing)
 
-        pkgpath = conftestpath.pypkgpath()
+        pkgpath = resolve_package_path(conftestpath)
         if pkgpath is None:
-            _ensure_removed_sysmodule(conftestpath.purebasename)
+            _ensure_removed_sysmodule(conftestpath.stem)
 
         try:
-            mod = import_path(conftestpath, mode=importmode)
+            mod = import_path(conftestpath, mode=importmode, root=rootpath)
         except Exception as e:
             assert e.__traceback__ is not None
             exc_info = (type(e), e, e.__traceback__)
@@ -576,11 +647,10 @@ class PytestPluginManager(PluginManager):
         self._check_non_top_pytest_plugins(mod, conftestpath)
 
         self._conftest_plugins.add(mod)
-        self._conftestpath2mod[key] = mod
-        dirpath = conftestpath.dirpath()
+        dirpath = conftestpath.parent
         if dirpath in self._dirpath2confmods:
             for path, mods in self._dirpath2confmods.items():
-                if path and path.relto(dirpath) or path == dirpath:
+                if dirpath in path.parents or path == dirpath:
                     assert mod not in mods
                     mods.append(mod)
         self.trace(f"loading conftestmodule {mod!r}")
@@ -588,7 +658,9 @@ class PytestPluginManager(PluginManager):
         return mod
 
     def _check_non_top_pytest_plugins(
-        self, mod: types.ModuleType, conftestpath: py.path.local,
+        self,
+        mod: types.ModuleType,
+        conftestpath: Path,
     ) -> None:
         if (
             hasattr(mod, "pytest_plugins")
@@ -614,6 +686,7 @@ class PytestPluginManager(PluginManager):
     def consider_preparse(
         self, args: Sequence[str], *, exclude_only: bool = False
     ) -> None:
+        """:meta private:"""
         i = 0
         n = len(args)
         while i < n:
@@ -630,11 +703,13 @@ class PytestPluginManager(PluginManager):
                     parg = opt[2:]
                 else:
                     continue
+                parg = parg.strip()
                 if exclude_only and not parg.startswith("no:"):
                     continue
                 self.consider_pluginarg(parg)
 
     def consider_pluginarg(self, arg: str) -> None:
+        """:meta private:"""
         if arg.startswith("no:"):
             name = arg[3:]
             if name in essential_plugins:
@@ -660,12 +735,15 @@ class PytestPluginManager(PluginManager):
             self.import_plugin(arg, consider_entry_points=True)
 
     def consider_conftest(self, conftestmodule: types.ModuleType) -> None:
+        """:meta private:"""
         self.register(conftestmodule, name=conftestmodule.__file__)
 
     def consider_env(self) -> None:
+        """:meta private:"""
         self._import_plugin_specs(os.environ.get("PYTEST_PLUGINS"))
 
     def consider_module(self, mod: types.ModuleType) -> None:
+        """:meta private:"""
         self._import_plugin_specs(getattr(mod, "pytest_plugins", []))
 
     def _import_plugin_specs(
@@ -703,7 +781,7 @@ class PytestPluginManager(PluginManager):
             __import__(importspec)
         except ImportError as e:
             raise ImportError(
-                'Error importing plugin "{}": {}'.format(modname, str(e.args[0]))
+                f'Error importing plugin "{modname}": {e.args[0]}'
             ).with_traceback(e.__traceback__) from e
 
         except Skipped as e:
@@ -790,7 +868,8 @@ def _iter_rewritable_modules(package_files: Iterable[str]) -> Iterator[str]:
         if is_simple_module:
             module_name, _ = os.path.splitext(fn)
             # we ignore "setup.py" at the root of the distribution
-            if module_name != "setup":
+            # as well as editable installation finder modules made by setuptools
+            if module_name != "setup" and not module_name.startswith("__editable__"):
                 seen_some = True
                 yield module_name
         elif is_package:
@@ -814,15 +893,12 @@ def _iter_rewritable_modules(package_files: Iterable[str]) -> Iterator[str]:
             yield from _iter_rewritable_modules(new_package_files)
 
 
-def _args_converter(args: Iterable[str]) -> Tuple[str, ...]:
-    return tuple(args)
-
-
 @final
 class Config:
     """Access to configuration values, pluginmanager and plugin hooks.
 
     :param PytestPluginManager pluginmanager:
+        A pytest PluginManager.
 
     :param InvocationParams invocation_params:
         Object containing parameters regarding the :func:`pytest.main`
@@ -830,7 +906,7 @@ class Config:
     """
 
     @final
-    @attr.s(frozen=True)
+    @dataclasses.dataclass(frozen=True)
     class InvocationParams:
         """Holds parameters passed during :func:`pytest.main`.
 
@@ -846,21 +922,36 @@ class Config:
             Plugins accessing ``InvocationParams`` must be aware of that.
         """
 
-        args = attr.ib(type=Tuple[str, ...], converter=_args_converter)
-        """The command-line arguments as passed to :func:`pytest.main`.
-
-        :type: Tuple[str, ...]
-        """
-        plugins = attr.ib(type=Optional[Sequence[Union[str, _PluggyPlugin]]])
-        """Extra plugins, might be `None`.
-
-        :type: Optional[Sequence[Union[str, plugin]]]
+        args: Tuple[str, ...]
+        """The command-line arguments as passed to :func:`pytest.main`."""
+        plugins: Optional[Sequence[Union[str, _PluggyPlugin]]]
+        """Extra plugins, might be `None`."""
+        dir: Path
+        """The directory from which :func:`pytest.main` was invoked."""
+
+        def __init__(
+            self,
+            *,
+            args: Iterable[str],
+            plugins: Optional[Sequence[Union[str, _PluggyPlugin]]],
+            dir: Path,
+        ) -> None:
+            object.__setattr__(self, "args", tuple(args))
+            object.__setattr__(self, "plugins", plugins)
+            object.__setattr__(self, "dir", dir)
+
+    class ArgsSource(enum.Enum):
+        """Indicates the source of the test arguments.
+
+        .. versionadded:: 7.2
         """
-        dir = attr.ib(type=Path)
-        """The directory from which :func:`pytest.main` was invoked.
 
-        :type: pathlib.Path
-        """
+        #: Command line arguments.
+        ARGS = enum.auto()
+        #: Invocation directory.
+        INCOVATION_DIR = enum.auto()
+        #: 'testpaths' configuration value.
+        TESTPATHS = enum.auto()
 
     def __init__(
         self,
@@ -891,6 +982,7 @@ class Config:
         self._parser = Parser(
             usage=f"%(prog)s [options] [{_a}] [{_a}] [...]",
             processopt=self._processopt,
+            _ispytest=True,
         )
         self.pluginmanager = pluginmanager
         """The plugin manager handles plugin registration and hook invocation.
@@ -898,37 +990,36 @@ class Config:
         :type: PytestPluginManager
         """
 
+        self.stash = Stash()
+        """A place where plugins can store information on the config for their
+        own use.
+
+        :type: Stash
+        """
+        # Deprecated alias. Was never public. Can be removed in a few releases.
+        self._store = self.stash
+
+        from .compat import PathAwareHookProxy
+
         self.trace = self.pluginmanager.trace.root.get("config")
-        self.hook = self.pluginmanager.hook
+        self.hook = PathAwareHookProxy(self.pluginmanager.hook)
         self._inicache: Dict[str, Any] = {}
         self._override_ini: Sequence[str] = ()
         self._opt2dest: Dict[str, str] = {}
         self._cleanup: List[Callable[[], None]] = []
-        # A place where plugins can store information on the config for their
-        # own use. Currently only intended for internal plugins.
-        self._store = Store()
         self.pluginmanager.register(self, "pytestconfig")
         self._configured = False
         self.hook.pytest_addoption.call_historic(
             kwargs=dict(parser=self._parser, pluginmanager=self.pluginmanager)
         )
+        self.args_source = Config.ArgsSource.ARGS
+        self.args: List[str] = []
 
         if TYPE_CHECKING:
             from _pytest.cacheprovider import Cache
 
             self.cache: Optional[Cache] = None
 
-    @property
-    def invocation_dir(self) -> py.path.local:
-        """The directory from which pytest was invoked.
-
-        Prefer to use :attr:`invocation_params.dir <InvocationParams.dir>`,
-        which is a :class:`pathlib.Path`.
-
-        :type: py.path.local
-        """
-        return py.path.local(str(self.invocation_params.dir))
-
     @property
     def rootpath(self) -> Path:
         """The path to the :ref:`rootdir <rootdir>`.
@@ -939,16 +1030,6 @@ class Config:
         """
         return self._rootpath
 
-    @property
-    def rootdir(self) -> py.path.local:
-        """The path to the :ref:`rootdir <rootdir>`.
-
-        Prefer to use :attr:`rootpath`, which is a :class:`pathlib.Path`.
-
-        :type: py.path.local
-        """
-        return py.path.local(str(self.rootpath))
-
     @property
     def inipath(self) -> Optional[Path]:
         """The path to the :ref:`configfile <configfiles>`.
@@ -959,19 +1040,9 @@ class Config:
         """
         return self._inipath
 
-    @property
-    def inifile(self) -> Optional[py.path.local]:
-        """The path to the :ref:`configfile <configfiles>`.
-
-        Prefer to use :attr:`inipath`, which is a :class:`pathlib.Path`.
-
-        :type: Optional[py.path.local]
-        """
-        return py.path.local(str(self.inipath)) if self.inipath else None
-
     def add_cleanup(self, func: Callable[[], None]) -> None:
         """Add a function to be called when the config object gets out of
-        use (usually coninciding with pytest_unconfigure)."""
+        use (usually coinciding with pytest_unconfigure)."""
         self._cleanup.append(func)
 
     def _do_configure(self) -> None:
@@ -991,9 +1062,10 @@ class Config:
             fin()
 
     def get_terminal_writer(self) -> TerminalWriter:
-        terminalreporter: TerminalReporter = self.pluginmanager.get_plugin(
+        terminalreporter: Optional[TerminalReporter] = self.pluginmanager.get_plugin(
             "terminalreporter"
         )
+        assert terminalreporter is not None
         return terminalreporter._tw
 
     def pytest_cmdline_parse(
@@ -1002,7 +1074,6 @@ class Config:
         try:
             self.parse(args)
         except UsageError:
-
             # Handle --version and --help here in a minimal fashion.
             # This gets done via helpconfig normally, but its
             # pytest_cmdline_main is not called in case of errors.
@@ -1067,7 +1138,26 @@ class Config:
 
     @hookimpl(trylast=True)
     def pytest_load_initial_conftests(self, early_config: "Config") -> None:
-        self.pluginmanager._set_initial_conftests(early_config.known_args_namespace)
+        # We haven't fully parsed the command line arguments yet, so
+        # early_config.args it not set yet. But we need it for
+        # discovering the initial conftests. So "pre-run" the logic here.
+        # It will be done for real in `parse()`.
+        args, args_source = early_config._decide_args(
+            args=early_config.known_args_namespace.file_or_dir,
+            pyargs=early_config.known_args_namespace.pyargs,
+            testpaths=early_config.getini("testpaths"),
+            invocation_dir=early_config.invocation_params.dir,
+            rootpath=early_config.rootpath,
+            warn=False,
+        )
+        self.pluginmanager._set_initial_conftests(
+            args=args,
+            pyargs=early_config.known_args_namespace.pyargs,
+            noconftest=early_config.known_args_namespace.noconftest,
+            rootpath=early_config.rootpath,
+            confcutdir=early_config.known_args_namespace.confcutdir,
+            importmode=early_config.known_args_namespace.importmode,
+        )
 
     def _initini(self, args: Sequence[str]) -> None:
         ns, unknown_args = self._parser.parse_known_and_unknown_args(
@@ -1084,11 +1174,11 @@ class Config:
         self.inicfg = inicfg
         self._parser.extra_info["rootdir"] = str(self.rootpath)
         self._parser.extra_info["inifile"] = str(self.inipath)
-        self._parser.addini("addopts", "extra command line options", "args")
-        self._parser.addini("minversion", "minimally required pytest version")
+        self._parser.addini("addopts", "Extra command line options", "args")
+        self._parser.addini("minversion", "Minimally required pytest version")
         self._parser.addini(
             "required_plugins",
-            "plugins that must be present for pytest to run",
+            "Plugins that must be present for pytest to run",
             type="args",
             default=[],
         )
@@ -1146,6 +1236,49 @@ class Config:
 
         return args
 
+    def _decide_args(
+        self,
+        *,
+        args: List[str],
+        pyargs: List[str],
+        testpaths: List[str],
+        invocation_dir: Path,
+        rootpath: Path,
+        warn: bool,
+    ) -> Tuple[List[str], ArgsSource]:
+        """Decide the args (initial paths/nodeids) to use given the relevant inputs.
+
+        :param warn: Whether can issue warnings.
+        """
+        if args:
+            source = Config.ArgsSource.ARGS
+            result = args
+        else:
+            if invocation_dir == rootpath:
+                source = Config.ArgsSource.TESTPATHS
+                if pyargs:
+                    result = testpaths
+                else:
+                    result = []
+                    for path in testpaths:
+                        result.extend(sorted(glob.iglob(path, recursive=True)))
+                    if testpaths and not result:
+                        if warn:
+                            warning_text = (
+                                "No files were found in testpaths; "
+                                "consider removing or adjusting your testpaths configuration. "
+                                "Searching recursively from the current directory instead."
+                            )
+                            self.issue_config_time_warning(
+                                PytestConfigWarning(warning_text), stacklevel=3
+                            )
+            else:
+                result = []
+            if not result:
+                source = Config.ArgsSource.INCOVATION_DIR
+                result = [str(invocation_dir)]
+        return result, source
+
     def _preparse(self, args: List[str], addopts: bool = True) -> None:
         if addopts:
             env_addopts = os.environ.get("PYTEST_ADDOPTS", "")
@@ -1184,8 +1317,11 @@ class Config:
                 _pytest.deprecated.STRICT_OPTION, stacklevel=2
             )
 
-        if self.known_args_namespace.confcutdir is None and self.inipath is not None:
-            confcutdir = str(self.inipath.parent)
+        if self.known_args_namespace.confcutdir is None:
+            if self.inipath is not None:
+                confcutdir = str(self.inipath.parent)
+            else:
+                confcutdir = str(self.rootpath)
             self.known_args_namespace.confcutdir = confcutdir
         try:
             self.hook.pytest_load_initial_conftests(
@@ -1204,8 +1340,8 @@ class Config:
 
     @hookimpl(hookwrapper=True)
     def pytest_collection(self) -> Generator[None, None, None]:
-        """Validate invalid ini keys after collection is done so we take in account
-        options added by late-loading conftest files."""
+        Validate invalid ini keys after collection is done so we take in account
+        # options added by late-loading conftest files.
         yield
         self._validate_config_options()
 
@@ -1225,7 +1361,11 @@ class Config:
             if Version(minver) > Version(pytest.__version__):
                 raise pytest.UsageError(
                     "%s: 'minversion' requires pytest-%s, actual pytest-%s'"
-                    % (self.inipath, minver, pytest.__version__,)
+                    % (
+                        self.inipath,
+                        minver,
+                        pytest.__version__,
+                    )
                 )
 
     def _validate_config_options(self) -> None:
@@ -1247,14 +1387,16 @@ class Config:
         missing_plugins = []
         for required_plugin in required_plugins:
             try:
-                spec = Requirement(required_plugin)
+                req = Requirement(required_plugin)
             except InvalidRequirement:
                 missing_plugins.append(required_plugin)
                 continue
 
-            if spec.name not in plugin_dist_info:
+            if req.name not in plugin_dist_info:
                 missing_plugins.append(required_plugin)
-            elif Version(plugin_dist_info[spec.name]) not in spec.specifier:
+            elif not req.specifier.contains(
+                Version(plugin_dist_info[req.name]), prereleases=True
+            ):
                 missing_plugins.append(required_plugin)
 
         if missing_plugins:
@@ -1274,8 +1416,8 @@ class Config:
 
     def parse(self, args: List[str], addopts: bool = True) -> None:
         # Parse given cmdline arguments into this config object.
-        assert not hasattr(
-            self, "args"
+        assert (
+            self.args == []
         ), "can only parse cmdline args at most once per Config object"
         self.hook.pytest_addhooks.call_historic(
             kwargs=dict(pluginmanager=self.pluginmanager)
@@ -1288,12 +1430,14 @@ class Config:
             args = self._parser.parse_setoption(
                 args, self.option, namespace=self.option
             )
-            if not args:
-                if self.invocation_params.dir == self.rootpath:
-                    args = self.getini("testpaths")
-                if not args:
-                    args = [str(self.invocation_params.dir)]
-            self.args = args
+            self.args, self.args_source = self._decide_args(
+                args=args,
+                pyargs=self.known_args_namespace.pyargs,
+                testpaths=self.getini("testpaths"),
+                invocation_dir=self.invocation_params.dir,
+                rootpath=self.rootpath,
+                warn=True,
+            )
         except PrintHelp:
             pass
 
@@ -1323,14 +1467,6 @@ class Config:
         if records:
             frame = sys._getframe(stacklevel - 1)
             location = frame.f_code.co_filename, frame.f_lineno, frame.f_code.co_name
-            self.hook.pytest_warning_captured.call_historic(
-                kwargs=dict(
-                    warning_message=records[0],
-                    when="config",
-                    item=None,
-                    location=location,
-                )
-            )
             self.hook.pytest_warning_recorded.call_historic(
                 kwargs=dict(
                     warning_message=records[0],
@@ -1352,8 +1488,8 @@ class Config:
         """Return configuration value from an :ref:`ini file <configfiles>`.
 
         If the specified name hasn't been registered through a prior
-        :py:func:`parser.addini <_pytest.config.argparsing.Parser.addini>`
-        call (usually from a plugin), a ValueError is raised.
+        :func:`parser.addini <pytest.Parser.addini>` call (usually from a
+        plugin), a ValueError is raised.
         """
         try:
             return self._inicache[name]
@@ -1361,6 +1497,12 @@ class Config:
             self._inicache[name] = val = self._getini(name)
             return val
 
+    # Meant for easy monkeypatching by legacypath plugin.
+    # Can be inlined back (with no cover removed) once legacypath is gone.
+    def _getini_unknown_type(self, name: str, type: str, value: Union[str, List[str]]):
+        msg = f"unknown configuration type: {type}"
+        raise ValueError(msg, value)  # pragma: no cover
+
     def _getini(self, name: str):
         try:
             description, type, default = self._parser._inidict[name]
@@ -1393,12 +1535,12 @@ class Config:
         #     a_line_list = ["tests", "acceptance"]
         #   in this case, we already have a list ready to use.
         #
-        if type == "pathlist":
+        if type == "paths":
             # TODO: This assert is probably not valid in all cases.
             assert self.inipath is not None
             dp = self.inipath.parent
             input_values = shlex.split(value) if isinstance(value, str) else value
-            return [py.path.local(str(dp / x)) for x in input_values]
+            return [dp / x for x in input_values]
         elif type == "args":
             return shlex.split(value) if isinstance(value, str) else value
         elif type == "linelist":
@@ -1408,25 +1550,31 @@ class Config:
                 return value
         elif type == "bool":
             return _strtobool(str(value).strip())
-        else:
-            assert type in [None, "string"]
+        elif type == "string":
             return value
+        elif type is None:
+            return value
+        else:
+            return self._getini_unknown_type(name, type, value)
 
     def _getconftest_pathlist(
-        self, name: str, path: py.path.local
-    ) -> Optional[List[py.path.local]]:
+        self, name: str, path: Path, rootpath: Path
+    ) -> Optional[List[Path]]:
         try:
             mod, relroots = self.pluginmanager._rget_with_confmod(
-                name, path, self.getoption("importmode")
+                name, path, self.getoption("importmode"), rootpath
             )
         except KeyError:
             return None
-        modpath = py.path.local(mod.__file__).dirpath()
-        values: List[py.path.local] = []
+        assert mod.__file__ is not None
+        modpath = Path(mod.__file__).parent
+        values: List[Path] = []
         for relroot in relroots:
-            if not isinstance(relroot, py.path.local):
+            if isinstance(relroot, os.PathLike):
+                relroot = Path(relroot)
+            else:
                 relroot = relroot.replace("/", os.sep)
-                relroot = modpath.join(relroot, abs=True)
+                relroot = absolutepath(modpath / relroot)
             values.append(relroot)
         return values
 
@@ -1498,7 +1646,8 @@ class Config:
                     "(are you using python -O?)\n"
                 )
             self.issue_config_time_warning(
-                PytestConfigWarning(warning_text), stacklevel=3,
+                PytestConfigWarning(warning_text),
+                stacklevel=3,
             )
 
     def _warn_about_skipped_plugins(self) -> None:
@@ -1563,20 +1712,57 @@ def _strtobool(val: str) -> bool:
 @lru_cache(maxsize=50)
 def parse_warning_filter(
     arg: str, *, escape: bool
-) -> Tuple[str, str, Type[Warning], str, int]:
+) -> Tuple["warnings._ActionKind", str, Type[Warning], str, int]:
     """Parse a warnings filter string.
 
-    This is copied from warnings._setoption, but does not apply the filter,
-    only parses it, and makes the escaping optional.
+    This is copied from warnings._setoption with the following changes:
+
+    * Does not apply the filter.
+    * Escaping is optional.
+    * Raises UsageError so we get nice error messages on failure.
     """
+    __tracebackhide__ = True
+    error_template = dedent(
+        f"""\
+        while parsing the following warning configuration:
+
+          {arg}
+
+        This error occurred:
+
+        {{error}}
+        """
+    )
+
     parts = arg.split(":")
     if len(parts) > 5:
-        raise warnings._OptionError(f"too many fields (max 5): {arg!r}")
+        doc_url = (
+            "https://docs.python.org/3/library/warnings.html#describing-warning-filters"
+        )
+        error = dedent(
+            f"""\
+            Too many fields ({len(parts)}), expected at most 5 separated by colons:
+
+              action:message:category:module:line
+
+            For more information please consult: {doc_url}
+            """
+        )
+        raise UsageError(error_template.format(error=error))
+
     while len(parts) < 5:
         parts.append("")
-    action_, message, category_, module, lineno_ = [s.strip() for s in parts]
-    action: str = warnings._getaction(action_)  # type: ignore[attr-defined]
-    category: Type[Warning] = warnings._getcategory(category_)  # type: ignore[attr-defined]
+    action_, message, category_, module, lineno_ = (s.strip() for s in parts)
+    try:
+        action: "warnings._ActionKind" = warnings._getaction(action_)  # type: ignore[attr-defined]
+    except warnings._OptionError as e:
+        raise UsageError(error_template.format(error=str(e)))
+    try:
+        category: Type[Warning] = _resolve_warning_category(category_)
+    except Exception:
+        exc_info = ExceptionInfo.from_current()
+        exception_text = exc_info.getrepr(style="native")
+        raise UsageError(error_template.format(error=exception_text))
     if message and escape:
         message = re.escape(message)
     if module and escape:
@@ -1585,14 +1771,38 @@ def parse_warning_filter(
         try:
             lineno = int(lineno_)
             if lineno < 0:
-                raise ValueError
-        except (ValueError, OverflowError) as e:
-            raise warnings._OptionError(f"invalid lineno {lineno_!r}") from e
+                raise ValueError("number is negative")
+        except ValueError as e:
+            raise UsageError(
+                error_template.format(error=f"invalid lineno {lineno_!r}: {e}")
+            )
     else:
         lineno = 0
     return action, message, category, module, lineno
 
 
+def _resolve_warning_category(category: str) -> Type[Warning]:
+    """
+    Copied from warnings._getcategory, but changed so it lets exceptions (specially ImportErrors)
+    propagate so we can get access to their tracebacks (#9218).
+    """
+    __tracebackhide__ = True
+    if not category:
+        return Warning
+
+    if "." not in category:
+        import builtins as m
+
+        klass = category
+    else:
+        module, _, klass = category.rpartition(".")
+        m = __import__(module, None, None, [klass])
+    cat = getattr(m, klass)
+    if not issubclass(cat, Warning):
+        raise UsageError(f"{cat} is not a Warning subclass")
+    return cast(Type[Warning], cat)
+
+
 def apply_warning_filters(
     config_filters: Iterable[str], cmdline_filters: Iterable[str]
 ) -> None:
index 9a481965526d4fcb2d2561535230ba474c1430c9..d3f01916b615d220069c9a2da97647a3a44aaf74 100644 (file)
@@ -1,4 +1,5 @@
 import argparse
+import os
 import sys
 import warnings
 from gettext import gettext
@@ -8,20 +9,22 @@ from typing import cast
 from typing import Dict
 from typing import List
 from typing import Mapping
+from typing import NoReturn
 from typing import Optional
 from typing import Sequence
 from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import Union
 
-import py
-
 import _pytest._io
 from _pytest.compat import final
 from _pytest.config.exceptions import UsageError
+from _pytest.deprecated import ARGUMENT_PERCENT_DEFAULT
+from _pytest.deprecated import ARGUMENT_TYPE_STR
+from _pytest.deprecated import ARGUMENT_TYPE_STR_CHOICE
+from _pytest.deprecated import check_ispytest
 
 if TYPE_CHECKING:
-    from typing import NoReturn
     from typing_extensions import Literal
 
 FILE_OR_DIR = "file_or_dir"
@@ -41,8 +44,11 @@ class Parser:
         self,
         usage: Optional[str] = None,
         processopt: Optional[Callable[["Argument"], None]] = None,
+        *,
+        _ispytest: bool = False,
     ) -> None:
-        self._anonymous = OptionGroup("custom options", parser=self)
+        check_ispytest(_ispytest)
+        self._anonymous = OptionGroup("Custom options", parser=self, _ispytest=True)
         self._groups: List[OptionGroup] = []
         self._processopt = processopt
         self._usage = usage
@@ -60,19 +66,20 @@ class Parser:
     ) -> "OptionGroup":
         """Get (or create) a named option Group.
 
-        :name: Name of the option group.
-        :description: Long description for --help output.
-        :after: Name of another group, used for ordering --help output.
+        :param name: Name of the option group.
+        :param description: Long description for --help output.
+        :param after: Name of another group, used for ordering --help output.
+        :returns: The option group.
 
         The returned group object has an ``addoption`` method with the same
-        signature as :py:func:`parser.addoption
-        <_pytest.config.argparsing.Parser.addoption>` but will be shown in the
-        respective group in the output of ``pytest. --help``.
+        signature as :func:`parser.addoption <pytest.Parser.addoption>` but
+        will be shown in the respective group in the output of
+        ``pytest --help``.
         """
         for group in self._groups:
             if group.name == name:
                 return group
-        group = OptionGroup(name, description, parser=self)
+        group = OptionGroup(name, description, parser=self, _ispytest=True)
         i = 0
         for i, grp in enumerate(self._groups):
             if grp.name == after:
@@ -83,10 +90,11 @@ class Parser:
     def addoption(self, *opts: str, **attrs: Any) -> None:
         """Register a command line option.
 
-        :opts: Option names, can be short or long options.
-        :attrs: Same attributes which the ``add_argument()`` function of the
-           `argparse library <https://docs.python.org/library/argparse.html>`_
-           accepts.
+        :param opts:
+            Option names, can be short or long options.
+        :param attrs:
+            Same attributes as the argparse library's :py:func:`add_argument()
+            <argparse.ArgumentParser.add_argument>` function accepts.
 
         After command line parsing, options are available on the pytest config
         object via ``config.option.NAME`` where ``NAME`` is usually set
@@ -97,14 +105,14 @@ class Parser:
 
     def parse(
         self,
-        args: Sequence[Union[str, py.path.local]],
+        args: Sequence[Union[str, "os.PathLike[str]"]],
         namespace: Optional[argparse.Namespace] = None,
     ) -> argparse.Namespace:
         from _pytest._argcomplete import try_argcomplete
 
         self.optparser = self._getparser()
         try_argcomplete(self.optparser)
-        strargs = [str(x) if isinstance(x, py.path.local) else x for x in args]
+        strargs = [os.fspath(x) for x in args]
         return self.optparser.parse_args(strargs, namespace=namespace)
 
     def _getparser(self) -> "MyOptionParser":
@@ -128,7 +136,7 @@ class Parser:
 
     def parse_setoption(
         self,
-        args: Sequence[Union[str, py.path.local]],
+        args: Sequence[Union[str, "os.PathLike[str]"]],
         option: argparse.Namespace,
         namespace: Optional[argparse.Namespace] = None,
     ) -> List[str]:
@@ -139,21 +147,29 @@ class Parser:
 
     def parse_known_args(
         self,
-        args: Sequence[Union[str, py.path.local]],
+        args: Sequence[Union[str, "os.PathLike[str]"]],
         namespace: Optional[argparse.Namespace] = None,
     ) -> argparse.Namespace:
-        """Parse and return a namespace object with known arguments at this point."""
+        """Parse the known arguments at this point.
+
+        :returns: An argparse namespace object.
+        """
         return self.parse_known_and_unknown_args(args, namespace=namespace)[0]
 
     def parse_known_and_unknown_args(
         self,
-        args: Sequence[Union[str, py.path.local]],
+        args: Sequence[Union[str, "os.PathLike[str]"]],
         namespace: Optional[argparse.Namespace] = None,
     ) -> Tuple[argparse.Namespace, List[str]]:
-        """Parse and return a namespace object with known arguments, and
-        the remaining arguments unknown at this point."""
+        """Parse the known arguments at this point, and also return the
+        remaining unknown arguments.
+
+        :returns:
+            A tuple containing an argparse namespace object for the known
+            arguments, and a list of the unknown arguments.
+        """
         optparser = self._getparser()
-        strargs = [str(x) if isinstance(x, py.path.local) else x for x in args]
+        strargs = [os.fspath(x) for x in args]
         return optparser.parse_known_args(strargs, namespace=namespace)
 
     def addini(
@@ -161,22 +177,35 @@ class Parser:
         name: str,
         help: str,
         type: Optional[
-            "Literal['string', 'pathlist', 'args', 'linelist', 'bool']"
+            "Literal['string', 'paths', 'pathlist', 'args', 'linelist', 'bool']"
         ] = None,
-        default=None,
+        default: Any = None,
     ) -> None:
         """Register an ini-file option.
 
-        :name: Name of the ini-variable.
-        :type: Type of the variable, can be ``string``, ``pathlist``, ``args``,
-               ``linelist`` or ``bool``.  Defaults to ``string`` if ``None`` or
-               not passed.
-        :default: Default value if no ini-file option exists but is queried.
+        :param name:
+            Name of the ini-variable.
+        :param type:
+            Type of the variable. Can be:
+
+                * ``string``: a string
+                * ``bool``: a boolean
+                * ``args``: a list of strings, separated as in a shell
+                * ``linelist``: a list of strings, separated by line breaks
+                * ``paths``: a list of :class:`pathlib.Path`, separated as in a shell
+                * ``pathlist``: a list of ``py.path``, separated as in a shell
+
+            .. versionadded:: 7.0
+                The ``paths`` variable type.
+
+            Defaults to ``string`` if ``None`` or not passed.
+        :param default:
+            Default value if no ini-file option exists but is queried.
 
         The value of ini-variables can be retrieved via a call to
-        :py:func:`config.getini(name) <_pytest.config.Config.getini>`.
+        :py:func:`config.getini(name) <pytest.Config.getini>`.
         """
-        assert type in (None, "string", "pathlist", "args", "linelist", "bool")
+        assert type in (None, "string", "paths", "pathlist", "args", "linelist", "bool")
         self._inidict[name] = (help, type, default)
         self._ininames.append(name)
 
@@ -208,17 +237,12 @@ class Argument:
     _typ_map = {"int": int, "string": str, "float": float, "complex": complex}
 
     def __init__(self, *names: str, **attrs: Any) -> None:
-        """Store parms in private vars for use in add_argument."""
+        """Store params in private vars for use in add_argument."""
         self._attrs = attrs
         self._short_opts: List[str] = []
         self._long_opts: List[str] = []
         if "%default" in (attrs.get("help") or ""):
-            warnings.warn(
-                'pytest now uses argparse. "%default" should be'
-                ' changed to "%(default)s" ',
-                DeprecationWarning,
-                stacklevel=3,
-            )
+            warnings.warn(ARGUMENT_PERCENT_DEFAULT, stacklevel=3)
         try:
             typ = attrs["type"]
         except KeyError:
@@ -228,11 +252,7 @@ class Argument:
             if isinstance(typ, str):
                 if typ == "choice":
                     warnings.warn(
-                        "`type` argument to addoption() is the string %r."
-                        " For choices this is optional and can be omitted, "
-                        " but when supplied should be a type (for example `str` or `int`)."
-                        " (options: %s)" % (typ, names),
-                        DeprecationWarning,
+                        ARGUMENT_TYPE_STR_CHOICE.format(typ=typ, names=names),
                         stacklevel=4,
                     )
                     # argparse expects a type here take it from
@@ -240,11 +260,7 @@ class Argument:
                     attrs["type"] = type(attrs["choices"][0])
                 else:
                     warnings.warn(
-                        "`type` argument to addoption() is the string %r, "
-                        " but when supplied should be a type (for example `str` or `int`)."
-                        " (options: %s)" % (typ, names),
-                        DeprecationWarning,
-                        stacklevel=4,
+                        ARGUMENT_TYPE_STR.format(typ=typ, names=names), stacklevel=4
                     )
                     attrs["type"] = Argument._typ_map[typ]
                 # Used in test_parseopt -> test_parse_defaultgetter.
@@ -332,32 +348,46 @@ class Argument:
 
 
 class OptionGroup:
+    """A group of options shown in its own section."""
+
     def __init__(
-        self, name: str, description: str = "", parser: Optional[Parser] = None
+        self,
+        name: str,
+        description: str = "",
+        parser: Optional[Parser] = None,
+        *,
+        _ispytest: bool = False,
     ) -> None:
+        check_ispytest(_ispytest)
         self.name = name
         self.description = description
         self.options: List[Argument] = []
         self.parser = parser
 
-    def addoption(self, *optnames: str, **attrs: Any) -> None:
+    def addoption(self, *opts: str, **attrs: Any) -> None:
         """Add an option to this group.
 
         If a shortened version of a long option is specified, it will
-        be suppressed in the help. addoption('--twowords', '--two-words')
-        results in help showing '--two-words' only, but --twowords gets
-        accepted **and** the automatic destination is in args.twowords.
+        be suppressed in the help. ``addoption('--twowords', '--two-words')``
+        results in help showing ``--two-words`` only, but ``--twowords`` gets
+        accepted **and** the automatic destination is in ``args.twowords``.
+
+        :param opts:
+            Option names, can be short or long options.
+        :param attrs:
+            Same attributes as the argparse library's :py:func:`add_argument()
+            <argparse.ArgumentParser.add_argument>` function accepts.
         """
-        conflict = set(optnames).intersection(
+        conflict = set(opts).intersection(
             name for opt in self.options for name in opt.names()
         )
         if conflict:
             raise ValueError("option names %s already added" % conflict)
-        option = Argument(*optnames, **attrs)
+        option = Argument(*opts, **attrs)
         self._addoption_instance(option, shortupper=False)
 
-    def _addoption(self, *optnames: str, **attrs: Any) -> None:
-        option = Argument(*optnames, **attrs)
+    def _addoption(self, *opts: str, **attrs: Any) -> None:
+        option = Argument(*opts, **attrs)
         self._addoption_instance(option, shortupper=True)
 
     def _addoption_instance(self, option: "Argument", shortupper: bool = False) -> None:
@@ -378,8 +408,7 @@ class MyOptionParser(argparse.ArgumentParser):
         prog: Optional[str] = None,
     ) -> None:
         self._parser = parser
-        argparse.ArgumentParser.__init__(
-            self,
+        super().__init__(
             prog=prog,
             usage=parser._usage,
             add_help=False,
@@ -390,7 +419,7 @@ class MyOptionParser(argparse.ArgumentParser):
         # an usage error to provide more contextual information to the user.
         self.extra_info = extra_info if extra_info else {}
 
-    def error(self, message: str) -> "NoReturn":
+    def error(self, message: str) -> NoReturn:
         """Transform argparse error message into UsageError."""
         msg = f"{self.prog}: error: {message}"
 
@@ -472,7 +501,7 @@ class DropShorterLongHelpFormatter(argparse.HelpFormatter):
         super().__init__(*args, **kwargs)
 
     def _format_action_invocation(self, action: argparse.Action) -> str:
-        orgstr = argparse.HelpFormatter._format_action_invocation(self, action)
+        orgstr = super()._format_action_invocation(action)
         if orgstr and orgstr[0] != "-":  # only optional arguments
             return orgstr
         res: Optional[str] = getattr(action, "_formatted_action_invocation", None)
diff --git a/src/_pytest/config/compat.py b/src/_pytest/config/compat.py
new file mode 100644 (file)
index 0000000..5bd922a
--- /dev/null
@@ -0,0 +1,70 @@
+import functools
+import warnings
+from pathlib import Path
+from typing import Optional
+
+from ..compat import LEGACY_PATH
+from ..compat import legacy_path
+from ..deprecated import HOOK_LEGACY_PATH_ARG
+from _pytest.nodes import _check_path
+
+# hookname: (Path, LEGACY_PATH)
+imply_paths_hooks = {
+    "pytest_ignore_collect": ("collection_path", "path"),
+    "pytest_collect_file": ("file_path", "path"),
+    "pytest_pycollect_makemodule": ("module_path", "path"),
+    "pytest_report_header": ("start_path", "startdir"),
+    "pytest_report_collectionfinish": ("start_path", "startdir"),
+}
+
+
+class PathAwareHookProxy:
+    """
+    this helper wraps around hook callers
+    until pluggy supports fixingcalls, this one will do
+
+    it currently doesn't return full hook caller proxies for fixed hooks,
+    this may have to be changed later depending on bugs
+    """
+
+    def __init__(self, hook_caller):
+        self.__hook_caller = hook_caller
+
+    def __dir__(self):
+        return dir(self.__hook_caller)
+
+    def __getattr__(self, key, _wraps=functools.wraps):
+        hook = getattr(self.__hook_caller, key)
+        if key not in imply_paths_hooks:
+            self.__dict__[key] = hook
+            return hook
+        else:
+            path_var, fspath_var = imply_paths_hooks[key]
+
+            @_wraps(hook)
+            def fixed_hook(**kw):
+                path_value: Optional[Path] = kw.pop(path_var, None)
+                fspath_value: Optional[LEGACY_PATH] = kw.pop(fspath_var, None)
+                if fspath_value is not None:
+                    warnings.warn(
+                        HOOK_LEGACY_PATH_ARG.format(
+                            pylib_path_arg=fspath_var, pathlib_path_arg=path_var
+                        ),
+                        stacklevel=2,
+                    )
+                if path_value is not None:
+                    if fspath_value is not None:
+                        _check_path(path_value, fspath_value)
+                    else:
+                        fspath_value = legacy_path(path_value)
+                else:
+                    assert fspath_value is not None
+                    path_value = Path(fspath_value)
+
+                kw[path_var] = path_value
+                kw[fspath_var] = fspath_value
+                return hook(**kw)
+
+            fixed_hook.__name__ = key
+            self.__dict__[key] = fixed_hook
+            return fixed_hook
index 2edf54536ba1022b7d436c2c7e5496073d499687..02674ffae3b757001bc3c688bb914c3425b810dd 100644 (file)
@@ -1,4 +1,5 @@
 import os
+import sys
 from pathlib import Path
 from typing import Dict
 from typing import Iterable
@@ -15,6 +16,7 @@ from .exceptions import UsageError
 from _pytest.outcomes import fail
 from _pytest.pathlib import absolutepath
 from _pytest.pathlib import commonpath
+from _pytest.pathlib import safe_exists
 
 if TYPE_CHECKING:
     from . import Config
@@ -64,9 +66,16 @@ def load_config_dict_from_file(
 
     # '.toml' files are considered if they contain a [tool.pytest.ini_options] table.
     elif filepath.suffix == ".toml":
-        import toml
+        if sys.version_info >= (3, 11):
+            import tomllib
+        else:
+            import tomli as tomllib
 
-        config = toml.load(str(filepath))
+        toml_text = filepath.read_text(encoding="utf-8")
+        try:
+            config = tomllib.loads(toml_text)
+        except tomllib.TOMLDecodeError as exc:
+            raise UsageError(f"{filepath}: {exc}") from exc
 
         result = config.get("tool", {}).get("pytest", {}).get("ini_options", None)
         if result is not None:
@@ -83,13 +92,12 @@ def load_config_dict_from_file(
 
 def locate_config(
     args: Iterable[Path],
-) -> Tuple[
-    Optional[Path], Optional[Path], Dict[str, Union[str, List[str]]],
-]:
+) -> Tuple[Optional[Path], Optional[Path], Dict[str, Union[str, List[str]]]]:
     """Search in the list of arguments for a valid ini-file for pytest,
     and return a tuple of (rootdir, inifile, cfg-dict)."""
     config_names = [
         "pytest.ini",
+        ".pytest.ini",
         "pyproject.toml",
         "tox.ini",
         "setup.cfg",
@@ -144,14 +152,6 @@ def get_dirs_from_args(args: Iterable[str]) -> List[Path]:
             return path
         return path.parent
 
-    def safe_exists(path: Path) -> bool:
-        # This can throw on paths that contain characters unrepresentable at the OS level,
-        # or with invalid syntax on Windows (https://bugs.python.org/issue35306)
-        try:
-            return path.exists()
-        except OSError:
-            return False
-
     # These look like paths but may not exist
     possible_paths = (
         absolutepath(get_file_part_from_node_id(arg))
@@ -178,7 +178,7 @@ def determine_setup(
         inipath: Optional[Path] = inipath_
         inicfg = load_config_dict_from_file(inipath_) or {}
         if rootdir_cmd_arg is None:
-            rootdir = get_common_ancestor(dirs)
+            rootdir = inipath_.parent
     else:
         ancestor = get_common_ancestor(dirs)
         rootdir, inipath, inicfg = locate_config([ancestor])
@@ -196,8 +196,7 @@ def determine_setup(
                     else:
                         cwd = Path.cwd()
                     rootdir = get_common_ancestor([cwd, ancestor])
-                    is_fs_root = os.path.splitdrive(str(rootdir))[1] == "/"
-                    if is_fs_root:
+                    if is_fs_root(rootdir):
                         rootdir = ancestor
     if rootdir_cmd_arg:
         rootdir = absolutepath(os.path.expandvars(rootdir_cmd_arg))
@@ -209,3 +208,11 @@ def determine_setup(
             )
     assert rootdir is not None
     return rootdir, inipath, inicfg or {}
+
+
+def is_fs_root(p: Path) -> bool:
+    r"""
+    Return True if the given path is pointing to the root of the
+    file system ("/" on Unix and "C:\\" on Windows for example).
+    """
+    return os.path.splitdrive(str(p))[1] == os.sep
index d3a5c6173f3a3857a65b05ec7b5ae4568e0a4840..a3f80802cabecd2f2e10bb68224474f2c42dbc7d 100644 (file)
@@ -3,6 +3,7 @@ import argparse
 import functools
 import sys
 import types
+import unittest
 from typing import Any
 from typing import Callable
 from typing import Generator
@@ -46,21 +47,21 @@ def pytest_addoption(parser: Parser) -> None:
         "--pdb",
         dest="usepdb",
         action="store_true",
-        help="start the interactive Python debugger on errors or KeyboardInterrupt.",
+        help="Start the interactive Python debugger on errors or KeyboardInterrupt",
     )
     group._addoption(
         "--pdbcls",
         dest="usepdb_cls",
         metavar="modulename:classname",
         type=_validate_usepdb_cls,
-        help="start a custom interactive Python debugger on errors. "
+        help="Specify a custom interactive Python debugger for use with --pdb."
         "For example: --pdbcls=IPython.terminal.debugger:TerminalPdb",
     )
     group._addoption(
         "--trace",
         dest="trace",
         action="store_true",
-        help="Immediately break when running each test.",
+        help="Immediately break when running each test",
     )
 
 
@@ -88,7 +89,7 @@ def pytest_configure(config: Config) -> None:
             pytestPDB._config,
         ) = pytestPDB._saved.pop()
 
-    config._cleanup.append(fin)
+    config.add_cleanup(fin)
 
 
 class pytestPDB:
@@ -293,7 +294,9 @@ class PdbInvoke:
             sys.stdout.write(out)
             sys.stdout.write(err)
         assert call.excinfo is not None
-        _enter_pdb(node, call.excinfo, report)
+
+        if not isinstance(call.excinfo.value, unittest.SkipTest):
+            _enter_pdb(node, call.excinfo, report)
 
     def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None:
         tb = _postmortem_traceback(excinfo)
index 19b31d665380a1eb34e0017ed1b8947e453717b0..b9c10df7a00840351a33e87de091a380572090fc 100644 (file)
@@ -11,6 +11,7 @@ in case of warnings which need to format their messages.
 from warnings import warn
 
 from _pytest.warning_types import PytestDeprecationWarning
+from _pytest.warning_types import PytestRemovedIn8Warning
 from _pytest.warning_types import UnformattedWarning
 
 # set of plugins which have been integrated into the core; we use this list to ignore
@@ -21,49 +22,105 @@ DEPRECATED_EXTERNAL_PLUGINS = {
     "pytest_faulthandler",
 }
 
-
-FILLFUNCARGS = UnformattedWarning(
-    PytestDeprecationWarning,
-    "{name} is deprecated, use "
-    "function._request._fillfixtures() instead if you cannot avoid reaching into internals.",
+NOSE_SUPPORT = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "Support for nose tests is deprecated and will be removed in a future release.\n"
+    "{nodeid} is using nose method: `{method}` ({stage})\n"
+    "See docs: https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose",
 )
 
-PYTEST_COLLECT_MODULE = UnformattedWarning(
-    PytestDeprecationWarning,
-    "pytest.collect.{name} was moved to pytest.{name}\n"
-    "Please update to the new name.",
+NOSE_SUPPORT_METHOD = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "Support for nose tests is deprecated and will be removed in a future release.\n"
+    "{nodeid} is using nose-specific method: `{method}(self)`\n"
+    "To remove this warning, rename it to `{method}_method(self)`\n"
+    "See docs: https://docs.pytest.org/en/stable/deprecations.html#support-for-tests-written-for-nose",
 )
 
+
+# This can be* removed pytest 8, but it's harmless and common, so no rush to remove.
+# * If you're in the future: "could have been".
 YIELD_FIXTURE = PytestDeprecationWarning(
     "@pytest.yield_fixture is deprecated.\n"
     "Use @pytest.fixture instead; they are the same."
 )
 
-MINUS_K_DASH = PytestDeprecationWarning(
-    "The `-k '-expr'` syntax to -k is deprecated.\nUse `-k 'not expr'` instead."
-)
-
-MINUS_K_COLON = PytestDeprecationWarning(
-    "The `-k 'expr:'` syntax to -k is deprecated.\n"
-    "Please open an issue if you use this and want a replacement."
-)
-
-WARNING_CAPTURED_HOOK = PytestDeprecationWarning(
-    "The pytest_warning_captured is deprecated and will be removed in a future release.\n"
-    "Please use pytest_warning_recorded instead."
+WARNING_CMDLINE_PREPARSE_HOOK = PytestRemovedIn8Warning(
+    "The pytest_cmdline_preparse hook is deprecated and will be removed in a future release. \n"
+    "Please use pytest_load_initial_conftests hook instead."
 )
 
-FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestDeprecationWarning(
+FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestRemovedIn8Warning(
     "The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated; "
     "use self.session.gethookproxy() and self.session.isinitpath() instead. "
 )
 
-STRICT_OPTION = PytestDeprecationWarning(
+STRICT_OPTION = PytestRemovedIn8Warning(
     "The --strict option is deprecated, use --strict-markers instead."
 )
 
+# This deprecation is never really meant to be removed.
 PRIVATE = PytestDeprecationWarning("A private pytest class or function was used.")
 
+ARGUMENT_PERCENT_DEFAULT = PytestRemovedIn8Warning(
+    'pytest now uses argparse. "%default" should be changed to "%(default)s"',
+)
+
+ARGUMENT_TYPE_STR_CHOICE = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "`type` argument to addoption() is the string {typ!r}."
+    " For choices this is optional and can be omitted, "
+    " but when supplied should be a type (for example `str` or `int`)."
+    " (options: {names})",
+)
+
+ARGUMENT_TYPE_STR = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "`type` argument to addoption() is the string {typ!r}, "
+    " but when supplied should be a type (for example `str` or `int`)."
+    " (options: {names})",
+)
+
+
+HOOK_LEGACY_PATH_ARG = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "The ({pylib_path_arg}: py.path.local) argument is deprecated, please use ({pathlib_path_arg}: pathlib.Path)\n"
+    "see https://docs.pytest.org/en/latest/deprecations.html"
+    "#py-path-local-arguments-for-hooks-replaced-with-pathlib-path",
+)
+
+NODE_CTOR_FSPATH_ARG = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "The (fspath: py.path.local) argument to {node_type_name} is deprecated. "
+    "Please use the (path: pathlib.Path) argument instead.\n"
+    "See https://docs.pytest.org/en/latest/deprecations.html"
+    "#fspath-argument-for-node-constructors-replaced-with-pathlib-path",
+)
+
+WARNS_NONE_ARG = PytestRemovedIn8Warning(
+    "Passing None has been deprecated.\n"
+    "See https://docs.pytest.org/en/latest/how-to/capture-warnings.html"
+    "#additional-use-cases-of-warnings-in-tests"
+    " for alternatives in common use cases."
+)
+
+KEYWORD_MSG_ARG = UnformattedWarning(
+    PytestRemovedIn8Warning,
+    "pytest.{func}(msg=...) is now deprecated, use pytest.{func}(reason=...) instead",
+)
+
+INSTANCE_COLLECTOR = PytestRemovedIn8Warning(
+    "The pytest.Instance collector type is deprecated and is no longer used. "
+    "See https://docs.pytest.org/en/latest/deprecations.html#the-pytest-instance-collector",
+)
+HOOK_LEGACY_MARKING = UnformattedWarning(
+    PytestDeprecationWarning,
+    "The hook{type} {fullname} uses old-style configuration options (marks or attributes).\n"
+    "Please use the pytest.hook{type}({hook_opts}) decorator instead\n"
+    " to configure the hooks.\n"
+    " See https://docs.pytest.org/en/latest/deprecations.html"
+    "#configuring-hook-specs-impls-using-markers",
+)
 
 # You want to make some `__init__` or function "private".
 #
@@ -82,6 +139,8 @@ PRIVATE = PytestDeprecationWarning("A private pytest class or function was used.
 #
 # All other calls will get the default _ispytest=False and trigger
 # the warning (possibly error in the future).
+
+
 def check_ispytest(ispytest: bool) -> None:
     if not ispytest:
         warn(PRIVATE, stacklevel=3)
index 64e8f0e0eee4e92933bd70d0d64c5e450c45d97f..ca41a98ea9cd86a04187936721e0f80e1cddd054 100644 (file)
@@ -1,12 +1,15 @@
 """Discover and run doctests in modules and test files."""
 import bdb
+import functools
 import inspect
+import os
 import platform
 import sys
 import traceback
 import types
 import warnings
 from contextlib import contextmanager
+from pathlib import Path
 from typing import Any
 from typing import Callable
 from typing import Dict
@@ -21,9 +24,6 @@ from typing import Type
 from typing import TYPE_CHECKING
 from typing import Union
 
-import py.path
-
-import pytest
 from _pytest import outcomes
 from _pytest._code.code import ExceptionInfo
 from _pytest._code.code import ReprFileLocation
@@ -32,10 +32,15 @@ from _pytest._io import TerminalWriter
 from _pytest.compat import safe_getattr
 from _pytest.config import Config
 from _pytest.config.argparsing import Parser
+from _pytest.fixtures import fixture
 from _pytest.fixtures import FixtureRequest
 from _pytest.nodes import Collector
+from _pytest.nodes import Item
 from _pytest.outcomes import OutcomeException
+from _pytest.outcomes import skip
+from _pytest.pathlib import fnmatch_ex
 from _pytest.pathlib import import_path
+from _pytest.python import Module
 from _pytest.python_api import approx
 from _pytest.warning_types import PytestWarning
 
@@ -65,26 +70,26 @@ CHECKER_CLASS: Optional[Type["doctest.OutputChecker"]] = None
 def pytest_addoption(parser: Parser) -> None:
     parser.addini(
         "doctest_optionflags",
-        "option flags for doctests",
+        "Option flags for doctests",
         type="args",
         default=["ELLIPSIS"],
     )
     parser.addini(
-        "doctest_encoding", "encoding used for doctest files", default="utf-8"
+        "doctest_encoding", "Encoding used for doctest files", default="utf-8"
     )
     group = parser.getgroup("collect")
     group.addoption(
         "--doctest-modules",
         action="store_true",
         default=False,
-        help="run doctests in all .py modules",
+        help="Run doctests in all .py modules",
         dest="doctestmodules",
     )
     group.addoption(
         "--doctest-report",
         type=str.lower,
         default="udiff",
-        help="choose another output format for diffs on doctest failure",
+        help="Choose another output format for diffs on doctest failure",
         choices=DOCTEST_REPORT_CHOICES,
         dest="doctestreport",
     )
@@ -93,21 +98,21 @@ def pytest_addoption(parser: Parser) -> None:
         action="append",
         default=[],
         metavar="pat",
-        help="doctests file matching pattern, default: test*.txt",
+        help="Doctests file matching pattern, default: test*.txt",
         dest="doctestglob",
     )
     group.addoption(
         "--doctest-ignore-import-errors",
         action="store_true",
         default=False,
-        help="ignore doctest ImportErrors",
+        help="Ignore doctest ImportErrors",
         dest="doctest_ignore_import_errors",
     )
     group.addoption(
         "--doctest-continue-on-failure",
         action="store_true",
         default=False,
-        help="for a given doctest, continue to run after the first failure",
+        help="For a given doctest, continue to run after the first failure",
         dest="doctest_continue_on_failure",
     )
 
@@ -119,34 +124,38 @@ def pytest_unconfigure() -> None:
 
 
 def pytest_collect_file(
-    path: py.path.local, parent: Collector,
+    file_path: Path,
+    parent: Collector,
 ) -> Optional[Union["DoctestModule", "DoctestTextfile"]]:
     config = parent.config
-    if path.ext == ".py":
-        if config.option.doctestmodules and not _is_setup_py(path):
-            mod: DoctestModule = DoctestModule.from_parent(parent, fspath=path)
+    if file_path.suffix == ".py":
+        if config.option.doctestmodules and not any(
+            (_is_setup_py(file_path), _is_main_py(file_path))
+        ):
+            mod: DoctestModule = DoctestModule.from_parent(parent, path=file_path)
             return mod
-    elif _is_doctest(config, path, parent):
-        txt: DoctestTextfile = DoctestTextfile.from_parent(parent, fspath=path)
+    elif _is_doctest(config, file_path, parent):
+        txt: DoctestTextfile = DoctestTextfile.from_parent(parent, path=file_path)
         return txt
     return None
 
 
-def _is_setup_py(path: py.path.local) -> bool:
-    if path.basename != "setup.py":
+def _is_setup_py(path: Path) -> bool:
+    if path.name != "setup.py":
         return False
-    contents = path.read_binary()
+    contents = path.read_bytes()
     return b"setuptools" in contents or b"distutils" in contents
 
 
-def _is_doctest(config: Config, path: py.path.local, parent) -> bool:
-    if path.ext in (".txt", ".rst") and parent.session.isinitpath(path):
+def _is_doctest(config: Config, path: Path, parent: Collector) -> bool:
+    if path.suffix in (".txt", ".rst") and parent.session.isinitpath(path):
         return True
     globs = config.getoption("doctestglob") or ["test*.txt"]
-    for glob in globs:
-        if path.check(fnmatch=glob):
-            return True
-    return False
+    return any(fnmatch_ex(glob, path) for glob in globs)
+
+
+def _is_main_py(path: Path) -> bool:
+    return path.name == "__main__.py"
 
 
 class ReprFailDoctest(TerminalRepr):
@@ -185,13 +194,15 @@ def _init_runner_class() -> Type["doctest.DocTestRunner"]:
             optionflags: int = 0,
             continue_on_failure: bool = True,
         ) -> None:
-            doctest.DebugRunner.__init__(
-                self, checker=checker, verbose=verbose, optionflags=optionflags
-            )
+            super().__init__(checker=checker, verbose=verbose, optionflags=optionflags)
             self.continue_on_failure = continue_on_failure
 
         def report_failure(
-            self, out, test: "doctest.DocTest", example: "doctest.Example", got: str,
+            self,
+            out,
+            test: "doctest.DocTest",
+            example: "doctest.Example",
+            got: str,
         ) -> None:
             failure = doctest.DocTestFailure(test, example, got)
             if self.continue_on_failure:
@@ -239,7 +250,7 @@ def _get_runner(
     )
 
 
-class DoctestItem(pytest.Item):
+class DoctestItem(Item):
     def __init__(
         self,
         name: str,
@@ -262,7 +273,7 @@ class DoctestItem(pytest.Item):
         runner: "doctest.DocTestRunner",
         dtest: "doctest.DocTest",
     ):
-        # incompatible signature due to to imposed limits on sublcass
+        # incompatible signature due to imposed limits on subclass
         """The public named constructor."""
         return super().from_parent(name=name, parent=parent, runner=runner, dtest=dtest)
 
@@ -301,13 +312,14 @@ class DoctestItem(pytest.Item):
 
     # TODO: Type ignored -- breaks Liskov Substitution.
     def repr_failure(  # type: ignore[override]
-        self, excinfo: ExceptionInfo[BaseException],
+        self,
+        excinfo: ExceptionInfo[BaseException],
     ) -> Union[str, TerminalRepr]:
         import doctest
 
         failures: Optional[
             Sequence[Union[doctest.DocTestFailure, doctest.UnexpectedException]]
-        ] = (None)
+        ] = None
         if isinstance(
             excinfo.value, (doctest.DocTestFailure, doctest.UnexpectedException)
         ):
@@ -315,61 +327,57 @@ class DoctestItem(pytest.Item):
         elif isinstance(excinfo.value, MultipleDoctestFailures):
             failures = excinfo.value.failures
 
-        if failures is not None:
-            reprlocation_lines = []
-            for failure in failures:
-                example = failure.example
-                test = failure.test
-                filename = test.filename
-                if test.lineno is None:
-                    lineno = None
-                else:
-                    lineno = test.lineno + example.lineno + 1
-                message = type(failure).__name__
-                # TODO: ReprFileLocation doesn't expect a None lineno.
-                reprlocation = ReprFileLocation(filename, lineno, message)  # type: ignore[arg-type]
-                checker = _get_checker()
-                report_choice = _get_report_choice(
-                    self.config.getoption("doctestreport")
-                )
-                if lineno is not None:
-                    assert failure.test.docstring is not None
-                    lines = failure.test.docstring.splitlines(False)
-                    # add line numbers to the left of the error message
-                    assert test.lineno is not None
-                    lines = [
-                        "%03d %s" % (i + test.lineno + 1, x)
-                        for (i, x) in enumerate(lines)
-                    ]
-                    # trim docstring error lines to 10
-                    lines = lines[max(example.lineno - 9, 0) : example.lineno + 1]
-                else:
-                    lines = [
-                        "EXAMPLE LOCATION UNKNOWN, not showing all tests of that example"
-                    ]
-                    indent = ">>>"
-                    for line in example.source.splitlines():
-                        lines.append(f"??? {indent} {line}")
-                        indent = "..."
-                if isinstance(failure, doctest.DocTestFailure):
-                    lines += checker.output_difference(
-                        example, failure.got, report_choice
-                    ).split("\n")
-                else:
-                    inner_excinfo = ExceptionInfo(failure.exc_info)
-                    lines += ["UNEXPECTED EXCEPTION: %s" % repr(inner_excinfo.value)]
-                    lines += [
-                        x.strip("\n")
-                        for x in traceback.format_exception(*failure.exc_info)
-                    ]
-                reprlocation_lines.append((reprlocation, lines))
-            return ReprFailDoctest(reprlocation_lines)
-        else:
+        if failures is None:
             return super().repr_failure(excinfo)
 
-    def reportinfo(self):
+        reprlocation_lines = []
+        for failure in failures:
+            example = failure.example
+            test = failure.test
+            filename = test.filename
+            if test.lineno is None:
+                lineno = None
+            else:
+                lineno = test.lineno + example.lineno + 1
+            message = type(failure).__name__
+            # TODO: ReprFileLocation doesn't expect a None lineno.
+            reprlocation = ReprFileLocation(filename, lineno, message)  # type: ignore[arg-type]
+            checker = _get_checker()
+            report_choice = _get_report_choice(self.config.getoption("doctestreport"))
+            if lineno is not None:
+                assert failure.test.docstring is not None
+                lines = failure.test.docstring.splitlines(False)
+                # add line numbers to the left of the error message
+                assert test.lineno is not None
+                lines = [
+                    "%03d %s" % (i + test.lineno + 1, x) for (i, x) in enumerate(lines)
+                ]
+                # trim docstring error lines to 10
+                lines = lines[max(example.lineno - 9, 0) : example.lineno + 1]
+            else:
+                lines = [
+                    "EXAMPLE LOCATION UNKNOWN, not showing all tests of that example"
+                ]
+                indent = ">>>"
+                for line in example.source.splitlines():
+                    lines.append(f"??? {indent} {line}")
+                    indent = "..."
+            if isinstance(failure, doctest.DocTestFailure):
+                lines += checker.output_difference(
+                    example, failure.got, report_choice
+                ).split("\n")
+            else:
+                inner_excinfo = ExceptionInfo.from_exc_info(failure.exc_info)
+                lines += ["UNEXPECTED EXCEPTION: %s" % repr(inner_excinfo.value)]
+                lines += [
+                    x.strip("\n") for x in traceback.format_exception(*failure.exc_info)
+                ]
+            reprlocation_lines.append((reprlocation, lines))
+        return ReprFailDoctest(reprlocation_lines)
+
+    def reportinfo(self) -> Tuple[Union["os.PathLike[str]", str], Optional[int], str]:
         assert self.dtest is not None
-        return self.fspath, self.dtest.lineno, "[doctest] %s" % self.name
+        return self.path, self.dtest.lineno, "[doctest] %s" % self.name
 
 
 def _get_flag_lookup() -> Dict[str, int]:
@@ -407,7 +415,7 @@ def _get_continue_on_failure(config):
     return continue_on_failure
 
 
-class DoctestTextfile(pytest.Module):
+class DoctestTextfile(Module):
     obj = None
 
     def collect(self) -> Iterable[DoctestItem]:
@@ -416,9 +424,9 @@ class DoctestTextfile(pytest.Module):
         # Inspired by doctest.testfile; ideally we would use it directly,
         # but it doesn't support passing a custom checker.
         encoding = self.config.getini("doctest_encoding")
-        text = self.fspath.read_text(encoding)
-        filename = str(self.fspath)
-        name = self.fspath.basename
+        text = self.path.read_text(encoding)
+        filename = str(self.path)
+        name = self.path.name
         globs = {"__name__": "__main__"}
 
         optionflags = get_optionflags(self)
@@ -445,7 +453,7 @@ def _check_all_skipped(test: "doctest.DocTest") -> None:
 
     all_skipped = all(x.options.get(doctest.SKIP, False) for x in test.examples)
     if all_skipped:
-        pytest.skip("all tests skipped by +SKIP option")
+        skip("all tests skipped by +SKIP option")
 
 
 def _is_mocked(obj: object) -> bool:
@@ -487,7 +495,7 @@ def _patch_unwrap_mock_aware() -> Generator[None, None, None]:
         inspect.unwrap = real_unwrap
 
 
-class DoctestModule(pytest.Module):
+class DoctestModule(Module):
     def collect(self) -> Iterable[DoctestItem]:
         import doctest
 
@@ -500,15 +508,22 @@ class DoctestModule(pytest.Module):
 
             def _find_lineno(self, obj, source_lines):
                 """Doctest code does not take into account `@property`, this
-                is a hackish way to fix it.
+                is a hackish way to fix it. https://bugs.python.org/issue17446
 
-                https://bugs.python.org/issue17446
+                Wrapped Doctests will need to be unwrapped so the correct
+                line number is returned. This will be reported upstream. #8796
                 """
                 if isinstance(obj, property):
                     obj = getattr(obj, "fget", obj)
+
+                if hasattr(obj, "__wrapped__"):
+                    # Get the main obj in case of it being wrapped
+                    obj = inspect.unwrap(obj)
+
                 # Type ignored because this is a private function.
-                return doctest.DocTestFinder._find_lineno(  # type: ignore
-                    self, obj, source_lines,
+                return super()._find_lineno(  # type:ignore[misc]
+                    obj,
+                    source_lines,
                 )
 
             def _find(
@@ -517,22 +532,46 @@ class DoctestModule(pytest.Module):
                 if _is_mocked(obj):
                     return
                 with _patch_unwrap_mock_aware():
-
                     # Type ignored because this is a private function.
-                    doctest.DocTestFinder._find(  # type: ignore
-                        self, tests, obj, name, module, source_lines, globs, seen
+                    super()._find(  # type:ignore[misc]
+                        tests, obj, name, module, source_lines, globs, seen
                     )
 
-        if self.fspath.basename == "conftest.py":
+            if sys.version_info < (3, 13):
+
+                def _from_module(self, module, object):
+                    """`cached_property` objects are never considered a part
+                    of the 'current module'. As such they are skipped by doctest.
+                    Here we override `_from_module` to check the underlying
+                    function instead. https://github.com/python/cpython/issues/107995
+                    """
+                    if hasattr(functools, "cached_property") and isinstance(
+                        object, functools.cached_property
+                    ):
+                        object = object.func
+
+                    # Type ignored because this is a private function.
+                    return super()._from_module(module, object)  # type: ignore[misc]
+
+            else:  # pragma: no cover
+                pass
+
+        if self.path.name == "conftest.py":
             module = self.config.pluginmanager._importconftest(
-                self.fspath, self.config.getoption("importmode")
+                self.path,
+                self.config.getoption("importmode"),
+                rootpath=self.config.rootpath,
             )
         else:
             try:
-                module = import_path(self.fspath)
+                module = import_path(
+                    self.path,
+                    root=self.config.rootpath,
+                    mode=self.config.getoption("importmode"),
+                )
             except ImportError:
                 if self.config.getvalue("doctest_ignore_import_errors"):
-                    pytest.skip("unable to import module %r" % self.fspath)
+                    skip("unable to import module %r" % self.path)
                 else:
                     raise
         # Uses internal doctest module parsing mechanism.
@@ -603,7 +642,7 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]:
         )
 
         def check_output(self, want: str, got: str, optionflags: int) -> bool:
-            if doctest.OutputChecker.check_output(self, want, got, optionflags):
+            if super().check_output(want, got, optionflags):
                 return True
 
             allow_unicode = optionflags & _get_allow_unicode_flag()
@@ -627,7 +666,7 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]:
             if allow_number:
                 got = self._remove_unwanted_precision(want, got)
 
-            return doctest.OutputChecker.check_output(self, want, got, optionflags)
+            return super().check_output(want, got, optionflags)
 
         def _remove_unwanted_precision(self, want: str, got: str) -> str:
             wants = list(self._number_re.finditer(want))
@@ -640,13 +679,10 @@ def _init_checker_class() -> Type["doctest.OutputChecker"]:
                 exponent: Optional[str] = w.group("exponent1")
                 if exponent is None:
                     exponent = w.group("exponent2")
-                if fraction is None:
-                    precision = 0
-                else:
-                    precision = len(fraction)
+                precision = 0 if fraction is None else len(fraction)
                 if exponent is not None:
                     precision -= int(exponent)
-                if float(w.group()) == approx(float(g.group()), abs=10 ** -precision):
+                if float(w.group()) == approx(float(g.group()), abs=10**-precision):
                     # They're close enough. Replace the text we actually
                     # got with the text we want, so that it will match when we
                     # check the string literally.
@@ -717,8 +753,19 @@ def _get_report_choice(key: str) -> int:
     }[key]
 
 
-@pytest.fixture(scope="session")
+@fixture(scope="session")
 def doctest_namespace() -> Dict[str, Any]:
     """Fixture that returns a :py:class:`dict` that will be injected into the
-    namespace of doctests."""
+    namespace of doctests.
+
+    Usually this fixture is used in conjunction with another ``autouse`` fixture:
+
+    .. code-block:: python
+
+        @pytest.fixture(autouse=True)
+        def add_np(doctest_namespace):
+            doctest_namespace["np"] = numpy
+
+    For more details: :ref:`doctest_namespace`.
+    """
     return dict()
index ff673b5b164e94b7e8348cc50e4fdb846be6e787..36040bffffc4b4a411c70bc2519ff5138d1ea9c0 100644 (file)
@@ -1,23 +1,22 @@
-import io
 import os
 import sys
 from typing import Generator
-from typing import TextIO
 
 import pytest
 from _pytest.config import Config
 from _pytest.config.argparsing import Parser
 from _pytest.nodes import Item
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 
 
-fault_handler_stderr_key = StoreKey[TextIO]()
+fault_handler_stderr_fd_key = StashKey[int]()
+fault_handler_originally_enabled_key = StashKey[bool]()
 
 
 def pytest_addoption(parser: Parser) -> None:
     help = (
         "Dump the traceback of all threads if a test takes "
-        "more than TIMEOUT seconds to finish."
+        "more than TIMEOUT seconds to finish"
     )
     parser.addini("faulthandler_timeout", help, default=0.0)
 
@@ -25,92 +24,71 @@ def pytest_addoption(parser: Parser) -> None:
 def pytest_configure(config: Config) -> None:
     import faulthandler
 
-    if not faulthandler.is_enabled():
-        # faulthhandler is not enabled, so install plugin that does the actual work
-        # of enabling faulthandler before each test executes.
-        config.pluginmanager.register(FaultHandlerHooks(), "faulthandler-hooks")
-    else:
-        # Do not handle dumping to stderr if faulthandler is already enabled, so warn
-        # users that the option is being ignored.
-        timeout = FaultHandlerHooks.get_timeout_config_value(config)
-        if timeout > 0:
-            config.issue_config_time_warning(
-                pytest.PytestConfigWarning(
-                    "faulthandler module enabled before pytest configuration step, "
-                    "'faulthandler_timeout' option ignored"
-                ),
-                stacklevel=2,
-            )
-
-
-class FaultHandlerHooks:
-    """Implements hooks that will actually install fault handler before tests execute,
-    as well as correctly handle pdb and internal errors."""
-
-    def pytest_configure(self, config: Config) -> None:
-        import faulthandler
+    config.stash[fault_handler_stderr_fd_key] = os.dup(get_stderr_fileno())
+    config.stash[fault_handler_originally_enabled_key] = faulthandler.is_enabled()
+    faulthandler.enable(file=config.stash[fault_handler_stderr_fd_key])
+
 
-        stderr_fd_copy = os.dup(self._get_stderr_fileno())
-        config._store[fault_handler_stderr_key] = open(stderr_fd_copy, "w")
-        faulthandler.enable(file=config._store[fault_handler_stderr_key])
+def pytest_unconfigure(config: Config) -> None:
+    import faulthandler
 
-    def pytest_unconfigure(self, config: Config) -> None:
+    faulthandler.disable()
+    # Close the dup file installed during pytest_configure.
+    if fault_handler_stderr_fd_key in config.stash:
+        os.close(config.stash[fault_handler_stderr_fd_key])
+        del config.stash[fault_handler_stderr_fd_key]
+    if config.stash.get(fault_handler_originally_enabled_key, False):
+        # Re-enable the faulthandler if it was originally enabled.
+        faulthandler.enable(file=get_stderr_fileno())
+
+
+def get_stderr_fileno() -> int:
+    try:
+        fileno = sys.stderr.fileno()
+        # The Twisted Logger will return an invalid file descriptor since it is not backed
+        # by an FD. So, let's also forward this to the same code path as with pytest-xdist.
+        if fileno == -1:
+            raise AttributeError()
+        return fileno
+    except (AttributeError, ValueError):
+        # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
+        # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
+        # This is potentially dangerous, but the best we can do.
+        return sys.__stderr__.fileno()
+
+
+def get_timeout_config_value(config: Config) -> float:
+    return float(config.getini("faulthandler_timeout") or 0.0)
+
+
+@pytest.hookimpl(hookwrapper=True, trylast=True)
+def pytest_runtest_protocol(item: Item) -> Generator[None, None, None]:
+    timeout = get_timeout_config_value(item.config)
+    if timeout > 0:
         import faulthandler
 
-        faulthandler.disable()
-        # close our dup file installed during pytest_configure
-        # re-enable the faulthandler, attaching it to the default sys.stderr
-        # so we can see crashes after pytest has finished, usually during
-        # garbage collection during interpreter shutdown
-        config._store[fault_handler_stderr_key].close()
-        del config._store[fault_handler_stderr_key]
-        faulthandler.enable(file=self._get_stderr_fileno())
-
-    @staticmethod
-    def _get_stderr_fileno():
+        stderr = item.config.stash[fault_handler_stderr_fd_key]
+        faulthandler.dump_traceback_later(timeout, file=stderr)
         try:
-            fileno = sys.stderr.fileno()
-            # The Twisted Logger will return an invalid file descriptor since it is not backed
-            # by an FD. So, let's also forward this to the same code path as with pytest-xdist.
-            if fileno == -1:
-                raise AttributeError()
-            return fileno
-        except (AttributeError, io.UnsupportedOperation):
-            # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
-            # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
-            # This is potentially dangerous, but the best we can do.
-            return sys.__stderr__.fileno()
-
-    @staticmethod
-    def get_timeout_config_value(config):
-        return float(config.getini("faulthandler_timeout") or 0.0)
-
-    @pytest.hookimpl(hookwrapper=True, trylast=True)
-    def pytest_runtest_protocol(self, item: Item) -> Generator[None, None, None]:
-        timeout = self.get_timeout_config_value(item.config)
-        stderr = item.config._store[fault_handler_stderr_key]
-        if timeout > 0 and stderr is not None:
-            import faulthandler
-
-            faulthandler.dump_traceback_later(timeout, file=stderr)
-            try:
-                yield
-            finally:
-                faulthandler.cancel_dump_traceback_later()
-        else:
             yield
+        finally:
+            faulthandler.cancel_dump_traceback_later()
+    else:
+        yield
 
-    @pytest.hookimpl(tryfirst=True)
-    def pytest_enter_pdb(self) -> None:
-        """Cancel any traceback dumping due to timeout before entering pdb."""
-        import faulthandler
 
-        faulthandler.cancel_dump_traceback_later()
+@pytest.hookimpl(tryfirst=True)
+def pytest_enter_pdb() -> None:
+    """Cancel any traceback dumping due to timeout before entering pdb."""
+    import faulthandler
 
-    @pytest.hookimpl(tryfirst=True)
-    def pytest_exception_interact(self) -> None:
-        """Cancel any traceback dumping due to an interactive exception being
-        raised."""
-        import faulthandler
+    faulthandler.cancel_dump_traceback_later()
+
+
+@pytest.hookimpl(tryfirst=True)
+def pytest_exception_interact() -> None:
+    """Cancel any traceback dumping due to an interactive exception being
+    raised."""
+    import faulthandler
 
-        faulthandler.cancel_dump_traceback_later()
+    faulthandler.cancel_dump_traceback_later()
index 273bcafd39369f504f8e6c5ad339ec850124e69b..0462504efafebf5bddf1ffefef02493118054cc2 100644 (file)
@@ -1,3 +1,4 @@
+import dataclasses
 import functools
 import inspect
 import os
@@ -5,6 +6,8 @@ import sys
 import warnings
 from collections import defaultdict
 from collections import deque
+from contextlib import suppress
+from pathlib import Path
 from types import TracebackType
 from typing import Any
 from typing import Callable
@@ -15,8 +18,9 @@ from typing import Generic
 from typing import Iterable
 from typing import Iterator
 from typing import List
+from typing import MutableMapping
+from typing import NoReturn
 from typing import Optional
-from typing import overload
 from typing import Sequence
 from typing import Set
 from typing import Tuple
@@ -25,9 +29,6 @@ from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
 
-import attr
-import py
-
 import _pytest
 from _pytest import nodes
 from _pytest._code import getfslineno
@@ -45,47 +46,49 @@ from _pytest.compat import getimfunc
 from _pytest.compat import getlocation
 from _pytest.compat import is_generator
 from _pytest.compat import NOTSET
+from _pytest.compat import NotSetType
+from _pytest.compat import overload
 from _pytest.compat import safe_getattr
 from _pytest.config import _PluggyPlugin
 from _pytest.config import Config
 from _pytest.config.argparsing import Parser
 from _pytest.deprecated import check_ispytest
-from _pytest.deprecated import FILLFUNCARGS
 from _pytest.deprecated import YIELD_FIXTURE
 from _pytest.mark import Mark
 from _pytest.mark import ParameterSet
 from _pytest.mark.structures import MarkDecorator
 from _pytest.outcomes import fail
+from _pytest.outcomes import skip
 from _pytest.outcomes import TEST_OUTCOME
 from _pytest.pathlib import absolutepath
-from _pytest.store import StoreKey
+from _pytest.pathlib import bestrelpath
+from _pytest.scope import HIGH_SCOPES
+from _pytest.scope import Scope
+from _pytest.stash import StashKey
+
 
 if TYPE_CHECKING:
     from typing import Deque
-    from typing import NoReturn
-    from typing_extensions import Literal
 
+    from _pytest.scope import _ScopeName
     from _pytest.main import Session
     from _pytest.python import CallSpec2
-    from _pytest.python import Function
     from _pytest.python import Metafunc
 
-    _Scope = Literal["session", "package", "module", "class", "function"]
-
 
 # The value of the fixture -- return/yield of the fixture function (type variable).
-_FixtureValue = TypeVar("_FixtureValue")
+FixtureValue = TypeVar("FixtureValue")
 # The type of the fixture function (type variable).
-_FixtureFunction = TypeVar("_FixtureFunction", bound=Callable[..., object])
+FixtureFunction = TypeVar("FixtureFunction", bound=Callable[..., object])
 # The type of a fixture function (type alias generic in fixture value).
 _FixtureFunc = Union[
-    Callable[..., _FixtureValue], Callable[..., Generator[_FixtureValue, None, None]]
+    Callable[..., FixtureValue], Callable[..., Generator[FixtureValue, None, None]]
 ]
 # The type of FixtureDef.cached_result (type alias generic in fixture value).
 _FixtureCachedResult = Union[
     Tuple[
         # The result.
-        _FixtureValue,
+        FixtureValue,
         # Cache key.
         object,
         None,
@@ -100,52 +103,54 @@ _FixtureCachedResult = Union[
 ]
 
 
-@attr.s(frozen=True)
-class PseudoFixtureDef(Generic[_FixtureValue]):
-    cached_result = attr.ib(type="_FixtureCachedResult[_FixtureValue]")
-    scope = attr.ib(type="_Scope")
+@dataclasses.dataclass(frozen=True)
+class PseudoFixtureDef(Generic[FixtureValue]):
+    cached_result: "_FixtureCachedResult[FixtureValue]"
+    _scope: Scope
 
 
 def pytest_sessionstart(session: "Session") -> None:
     session._fixturemanager = FixtureManager(session)
 
 
-def get_scope_package(node, fixturedef: "FixtureDef[object]"):
-    import pytest
+def get_scope_package(
+    node: nodes.Item,
+    fixturedef: "FixtureDef[object]",
+) -> Optional[Union[nodes.Item, nodes.Collector]]:
+    from _pytest.python import Package
 
-    cls = pytest.Package
-    current = node
+    current: Optional[Union[nodes.Item, nodes.Collector]] = node
     fixture_package_name = "{}/{}".format(fixturedef.baseid, "__init__.py")
     while current and (
-        type(current) is not cls or fixture_package_name != current.nodeid
+        not isinstance(current, Package) or fixture_package_name != current.nodeid
     ):
-        current = current.parent
+        current = current.parent  # type: ignore[assignment]
     if current is None:
         return node.session
     return current
 
 
 def get_scope_node(
-    node: nodes.Node, scope: "_Scope"
+    node: nodes.Node, scope: Scope
 ) -> Optional[Union[nodes.Item, nodes.Collector]]:
     import _pytest.python
 
-    if scope == "function":
+    if scope is Scope.Function:
         return node.getparent(nodes.Item)
-    elif scope == "class":
+    elif scope is Scope.Class:
         return node.getparent(_pytest.python.Class)
-    elif scope == "module":
+    elif scope is Scope.Module:
         return node.getparent(_pytest.python.Module)
-    elif scope == "package":
+    elif scope is Scope.Package:
         return node.getparent(_pytest.python.Package)
-    elif scope == "session":
+    elif scope is Scope.Session:
         return node.getparent(_pytest.main.Session)
     else:
         assert_never(scope)
 
 
 # Used for storing artificial fixturedefs for direct parametrization.
-name2pseudofixturedef_key = StoreKey[Dict[str, "FixtureDef[Any]"]]()
+name2pseudofixturedef_key = StashKey[Dict[str, "FixtureDef[Any]"]]()
 
 
 def add_funcarg_pseudo_fixture_def(
@@ -162,7 +167,7 @@ def add_funcarg_pseudo_fixture_def(
         return
     # Collect funcargs of all callspecs into a list of values.
     arg2params: Dict[str, List[object]] = {}
-    arg2scope: Dict[str, _Scope] = {}
+    arg2scope: Dict[str, Scope] = {}
     for callspec in metafunc._calls:
         for argname, argvalue in callspec.funcargs.items():
             assert argname not in callspec.params
@@ -171,8 +176,8 @@ def add_funcarg_pseudo_fixture_def(
             callspec.indices[argname] = len(arg2params_list)
             arg2params_list.append(argvalue)
             if argname not in arg2scope:
-                scopenum = callspec._arg2scopenum.get(argname, scopenum_function)
-                arg2scope[argname] = scopes[scopenum]
+                scope = callspec._arg2scope.get(argname, Scope.Function)
+                arg2scope[argname] = scope
         callspec.funcargs.clear()
 
     # Register artificial FixtureDef's so that later at test execution
@@ -185,17 +190,19 @@ def add_funcarg_pseudo_fixture_def(
         # node related to the scope.
         scope = arg2scope[argname]
         node = None
-        if scope != "function":
+        if scope is not Scope.Function:
             node = get_scope_node(collector, scope)
             if node is None:
-                assert scope == "class" and isinstance(collector, _pytest.python.Module)
+                assert scope is Scope.Class and isinstance(
+                    collector, _pytest.python.Module
+                )
                 # Use module-level collector for class-scope (for now).
                 node = collector
         if node is None:
             name2pseudofixturedef = None
         else:
             default: Dict[str, FixtureDef[Any]] = {}
-            name2pseudofixturedef = node._store.setdefault(
+            name2pseudofixturedef = node.stash.setdefault(
                 name2pseudofixturedef_key, default
             )
         if name2pseudofixturedef is not None and argname in name2pseudofixturedef:
@@ -219,25 +226,20 @@ def add_funcarg_pseudo_fixture_def(
 def getfixturemarker(obj: object) -> Optional["FixtureFunctionMarker"]:
     """Return fixturemarker or None if it doesn't exist or raised
     exceptions."""
-    try:
-        fixturemarker: Optional[FixtureFunctionMarker] = getattr(
-            obj, "_pytestfixturefunction", None
-        )
-    except TEST_OUTCOME:
-        # some objects raise errors like request (from flask import request)
-        # we don't expect them to be fixture functions
-        return None
-    return fixturemarker
+    return cast(
+        Optional[FixtureFunctionMarker],
+        safe_getattr(obj, "_pytestfixturefunction", None),
+    )
 
 
 # Parametrized fixture key, helper alias for code below.
 _Key = Tuple[object, ...]
 
 
-def get_parametrized_fixture_keys(item: nodes.Item, scopenum: int) -> Iterator[_Key]:
+def get_parametrized_fixture_keys(item: nodes.Item, scope: Scope) -> Iterator[_Key]:
     """Return list of keys for all parametrized arguments which match
-    the specified scope. """
-    assert scopenum < scopenum_function  # function
+    the specified scope."""
+    assert scope is not Scope.Function
     try:
         callspec = item.callspec  # type: ignore[attr-defined]
     except AttributeError:
@@ -248,67 +250,71 @@ def get_parametrized_fixture_keys(item: nodes.Item, scopenum: int) -> Iterator[_
         # sort this so that different calls to
         # get_parametrized_fixture_keys will be deterministic.
         for argname, param_index in sorted(cs.indices.items()):
-            if cs._arg2scopenum[argname] != scopenum:
+            if cs._arg2scope[argname] != scope:
                 continue
-            if scopenum == 0:  # session
+            if scope is Scope.Session:
                 key: _Key = (argname, param_index)
-            elif scopenum == 1:  # package
-                key = (argname, param_index, item.fspath.dirpath())
-            elif scopenum == 2:  # module
-                key = (argname, param_index, item.fspath)
-            elif scopenum == 3:  # class
+            elif scope is Scope.Package:
+                key = (argname, param_index, item.path.parent)
+            elif scope is Scope.Module:
+                key = (argname, param_index, item.path)
+            elif scope is Scope.Class:
                 item_cls = item.cls  # type: ignore[attr-defined]
-                key = (argname, param_index, item.fspath, item_cls)
+                key = (argname, param_index, item.path, item_cls)
+            else:
+                assert_never(scope)
             yield key
 
 
 # Algorithm for sorting on a per-parametrized resource setup basis.
-# It is called for scopenum==0 (session) first and performs sorting
+# It is called for Session scope first and performs sorting
 # down to the lower scopes such as to minimize number of "high scope"
 # setups and teardowns.
 
 
 def reorder_items(items: Sequence[nodes.Item]) -> List[nodes.Item]:
-    argkeys_cache: Dict[int, Dict[nodes.Item, Dict[_Key, None]]] = {}
-    items_by_argkey: Dict[int, Dict[_Key, Deque[nodes.Item]]] = {}
-    for scopenum in range(0, scopenum_function):
+    argkeys_cache: Dict[Scope, Dict[nodes.Item, Dict[_Key, None]]] = {}
+    items_by_argkey: Dict[Scope, Dict[_Key, Deque[nodes.Item]]] = {}
+    for scope in HIGH_SCOPES:
         d: Dict[nodes.Item, Dict[_Key, None]] = {}
-        argkeys_cache[scopenum] = d
+        argkeys_cache[scope] = d
         item_d: Dict[_Key, Deque[nodes.Item]] = defaultdict(deque)
-        items_by_argkey[scopenum] = item_d
+        items_by_argkey[scope] = item_d
         for item in items:
-            keys = dict.fromkeys(get_parametrized_fixture_keys(item, scopenum), None)
+            keys = dict.fromkeys(get_parametrized_fixture_keys(item, scope), None)
             if keys:
                 d[item] = keys
                 for key in keys:
                     item_d[key].append(item)
     items_dict = dict.fromkeys(items, None)
-    return list(reorder_items_atscope(items_dict, argkeys_cache, items_by_argkey, 0))
+    return list(
+        reorder_items_atscope(items_dict, argkeys_cache, items_by_argkey, Scope.Session)
+    )
 
 
 def fix_cache_order(
     item: nodes.Item,
-    argkeys_cache: Dict[int, Dict[nodes.Item, Dict[_Key, None]]],
-    items_by_argkey: Dict[int, Dict[_Key, "Deque[nodes.Item]"]],
+    argkeys_cache: Dict[Scope, Dict[nodes.Item, Dict[_Key, None]]],
+    items_by_argkey: Dict[Scope, Dict[_Key, "Deque[nodes.Item]"]],
 ) -> None:
-    for scopenum in range(0, scopenum_function):
-        for key in argkeys_cache[scopenum].get(item, []):
-            items_by_argkey[scopenum][key].appendleft(item)
+    for scope in HIGH_SCOPES:
+        for key in argkeys_cache[scope].get(item, []):
+            items_by_argkey[scope][key].appendleft(item)
 
 
 def reorder_items_atscope(
     items: Dict[nodes.Item, None],
-    argkeys_cache: Dict[int, Dict[nodes.Item, Dict[_Key, None]]],
-    items_by_argkey: Dict[int, Dict[_Key, "Deque[nodes.Item]"]],
-    scopenum: int,
+    argkeys_cache: Dict[Scope, Dict[nodes.Item, Dict[_Key, None]]],
+    items_by_argkey: Dict[Scope, Dict[_Key, "Deque[nodes.Item]"]],
+    scope: Scope,
 ) -> Dict[nodes.Item, None]:
-    if scopenum >= scopenum_function or len(items) < 3:
+    if scope is Scope.Function or len(items) < 3:
         return items
     ignore: Set[Optional[_Key]] = set()
     items_deque = deque(items)
     items_done: Dict[nodes.Item, None] = {}
-    scoped_items_by_argkey = items_by_argkey[scopenum]
-    scoped_argkeys_cache = argkeys_cache[scopenum]
+    scoped_items_by_argkey = items_by_argkey[scope]
+    scoped_argkeys_cache = argkeys_cache[scope]
     while items_deque:
         no_argkey_group: Dict[nodes.Item, None] = {}
         slicing_argkey = None
@@ -334,7 +340,7 @@ def reorder_items_atscope(
                 break
         if no_argkey_group:
             no_argkey_group = reorder_items_atscope(
-                no_argkey_group, argkeys_cache, items_by_argkey, scopenum + 1
+                no_argkey_group, argkeys_cache, items_by_argkey, scope.next_lower()
             )
             for item in no_argkey_group:
                 items_done[item] = None
@@ -342,57 +348,22 @@ def reorder_items_atscope(
     return items_done
 
 
-def _fillfuncargs(function: "Function") -> None:
-    """Fill missing fixtures for a test function, old public API (deprecated)."""
-    warnings.warn(FILLFUNCARGS.format(name="pytest._fillfuncargs()"), stacklevel=2)
-    _fill_fixtures_impl(function)
-
-
-def fillfixtures(function: "Function") -> None:
-    """Fill missing fixtures for a test function (deprecated)."""
-    warnings.warn(
-        FILLFUNCARGS.format(name="_pytest.fixtures.fillfixtures()"), stacklevel=2
-    )
-    _fill_fixtures_impl(function)
-
-
-def _fill_fixtures_impl(function: "Function") -> None:
-    """Internal implementation to fill fixtures on the given function object."""
-    try:
-        request = function._request
-    except AttributeError:
-        # XXX this special code path is only expected to execute
-        # with the oejskit plugin.  It uses classes with funcargs
-        # and we thus have to work a bit to allow this.
-        fm = function.session._fixturemanager
-        assert function.parent is not None
-        fi = fm.getfixtureinfo(function.parent, function.obj, None)
-        function._fixtureinfo = fi
-        request = function._request = FixtureRequest(function, _ispytest=True)
-        request._fillfixtures()
-        # Prune out funcargs for jstests.
-        newfuncargs = {}
-        for name in fi.argnames:
-            newfuncargs[name] = function.funcargs[name]
-        function.funcargs = newfuncargs
-    else:
-        request._fillfixtures()
-
-
-def get_direct_param_fixture_func(request):
+def get_direct_param_fixture_func(request: "FixtureRequest") -> Any:
     return request.param
 
 
-@attr.s(slots=True)
+@dataclasses.dataclass
 class FuncFixtureInfo:
+    __slots__ = ("argnames", "initialnames", "names_closure", "name2fixturedefs")
+
     # Original function argument names.
-    argnames = attr.ib(type=Tuple[str, ...])
+    argnames: Tuple[str, ...]
     # Argnames that function immediately requires. These include argnames +
     # fixture names specified via usefixtures and via autouse=True in fixture
     # definitions.
-    initialnames = attr.ib(type=Tuple[str, ...])
-    names_closure = attr.ib(type=List[str])
-    name2fixturedefs = attr.ib(type=Dict[str, Sequence["FixtureDef[Any]"]])
+    initialnames: Tuple[str, ...]
+    names_closure: List[str]
+    name2fixturedefs: Dict[str, Sequence["FixtureDef[Any]"]]
 
     def prune_dependency_tree(self) -> None:
         """Recompute names_closure from initialnames and name2fixturedefs.
@@ -435,13 +406,26 @@ class FixtureRequest:
         self._pyfuncitem = pyfuncitem
         #: Fixture for which this request is being performed.
         self.fixturename: Optional[str] = None
-        #: Scope string, one of "function", "class", "module", "session".
-        self.scope: _Scope = "function"
+        self._scope = Scope.Function
         self._fixture_defs: Dict[str, FixtureDef[Any]] = {}
         fixtureinfo: FuncFixtureInfo = pyfuncitem._fixtureinfo
         self._arg2fixturedefs = fixtureinfo.name2fixturedefs.copy()
         self._arg2index: Dict[str, int] = {}
-        self._fixturemanager: FixtureManager = (pyfuncitem.session._fixturemanager)
+        self._fixturemanager: FixtureManager = pyfuncitem.session._fixturemanager
+        # Notes on the type of `param`:
+        # -`request.param` is only defined in parametrized fixtures, and will raise
+        #   AttributeError otherwise. Python typing has no notion of "undefined", so
+        #   this cannot be reflected in the type.
+        # - Technically `param` is only (possibly) defined on SubRequest, not
+        #   FixtureRequest, but the typing of that is still in flux so this cheats.
+        # - In the future we might consider using a generic for the param type, but
+        #   for now just using Any.
+        self.param: Any
+
+    @property
+    def scope(self) -> "_ScopeName":
+        """Scope string, one of "function", "class", "module", "package", "session"."""
+        return self._scope.value
 
     @property
     def fixturenames(self) -> List[str]:
@@ -453,7 +437,23 @@ class FixtureRequest:
     @property
     def node(self):
         """Underlying collection node (depends on current request scope)."""
-        return self._getscopeitem(self.scope)
+        scope = self._scope
+        if scope is Scope.Function:
+            # This might also be a non-function Item despite its attribute name.
+            node: Optional[Union[nodes.Item, nodes.Collector]] = self._pyfuncitem
+        elif scope is Scope.Package:
+            # FIXME: _fixturedef is not defined on FixtureRequest (this class),
+            # but on FixtureRequest (a subclass).
+            node = get_scope_package(self._pyfuncitem, self._fixturedef)  # type: ignore[attr-defined]
+        else:
+            node = get_scope_node(self._pyfuncitem, scope)
+        if node is None and scope is Scope.Class:
+            # Fallback to function item itself.
+            node = self._pyfuncitem
+        assert node, 'Could not obtain a node for scope "{}" for function {!r}'.format(
+            scope, self._pyfuncitem
+        )
+        return node
 
     def _getnextfixturedef(self, argname: str) -> "FixtureDef[Any]":
         fixturedefs = self._arg2fixturedefs.get(argname, None)
@@ -515,17 +515,18 @@ class FixtureRequest:
         return self._pyfuncitem.getparent(_pytest.python.Module).obj
 
     @property
-    def fspath(self) -> py.path.local:
-        """The file system path of the test module which collected this test."""
+    def path(self) -> Path:
+        """Path where the test function was collected."""
         if self.scope not in ("function", "class", "module", "package"):
-            raise AttributeError(f"module not available in {self.scope}-scoped context")
+            raise AttributeError(f"path not available in {self.scope}-scoped context")
         # TODO: Remove ignore once _pyfuncitem is properly typed.
-        return self._pyfuncitem.fspath  # type: ignore
+        return self._pyfuncitem.path  # type: ignore
 
     @property
-    def keywords(self):
+    def keywords(self) -> MutableMapping[str, Any]:
         """Keywords/markers dictionary for the underlying node."""
-        return self.node.keywords
+        node: nodes.Node = self.node
+        return node.keywords
 
     @property
     def session(self) -> "Session":
@@ -533,16 +534,10 @@ class FixtureRequest:
         return self._pyfuncitem.session  # type: ignore[no-any-return]
 
     def addfinalizer(self, finalizer: Callable[[], object]) -> None:
-        """Add finalizer/teardown function to be called after the last test
-        within the requesting test context finished execution."""
+        """Add finalizer/teardown function to be called without arguments after
+        the last test within the requesting test context finished execution."""
         # XXX usually this method is shadowed by fixturedef specific ones.
-        self._addfinalizer(finalizer, scope=self.scope)
-
-    def _addfinalizer(self, finalizer: Callable[[], object], scope) -> None:
-        colitem = self._getscopeitem(scope)
-        self._pyfuncitem.session._setupstate.addfinalizer(
-            finalizer=finalizer, colitem=colitem
-        )
+        self.node.addfinalizer(finalizer)
 
     def applymarker(self, marker: Union[str, MarkDecorator]) -> None:
         """Apply a marker to a single test function invocation.
@@ -551,13 +546,16 @@ class FixtureRequest:
         on all function invocations.
 
         :param marker:
-            A :py:class:`_pytest.mark.MarkDecorator` object created by a call
-            to ``pytest.mark.NAME(...)``.
+            An object created by a call to ``pytest.mark.NAME(...)``.
         """
         self.node.add_marker(marker)
 
-    def raiseerror(self, msg: Optional[str]) -> "NoReturn":
-        """Raise a FixtureLookupError with the given message."""
+    def raiseerror(self, msg: Optional[str]) -> NoReturn:
+        """Raise a FixtureLookupError exception.
+
+        :param msg:
+            An optional custom error message.
+        """
         raise self._fixturemanager.FixtureLookupError(None, self, msg)
 
     def _fillfixtures(self) -> None:
@@ -575,11 +573,20 @@ class FixtureRequest:
         setup time, you may use this function to retrieve it inside a fixture
         or test function body.
 
+        This method can be used during the test setup phase or the test run
+        phase, but during the test teardown phase a fixture's value may not
+        be available.
+
+        :param argname:
+            The fixture name.
         :raises pytest.FixtureLookupError:
             If the given fixture could not be found.
         """
         fixturedef = self._get_active_fixturedef(argname)
-        assert fixturedef.cached_result is not None
+        assert fixturedef.cached_result is not None, (
+            f'The fixture value for "{argname}" is not available.  '
+            "This can happen when the fixture has already been torn down."
+        )
         return fixturedef.cached_result[0]
 
     def _get_active_fixturedef(
@@ -593,8 +600,7 @@ class FixtureRequest:
             except FixtureLookupError:
                 if argname == "request":
                     cached_result = (self, [0], None)
-                    scope: _Scope = "function"
-                    return PseudoFixtureDef(cached_result, scope)
+                    return PseudoFixtureDef(cached_result, Scope.Function)
                 raise
         # Remove indent to prevent the python3 exception
         # from leaking into the call.
@@ -605,14 +611,11 @@ class FixtureRequest:
     def _get_fixturestack(self) -> List["FixtureDef[Any]"]:
         current = self
         values: List[FixtureDef[Any]] = []
-        while 1:
-            fixturedef = getattr(current, "_fixturedef", None)
-            if fixturedef is None:
-                values.reverse()
-                return values
-            values.append(fixturedef)
-            assert isinstance(current, SubRequest)
+        while isinstance(current, SubRequest):
+            values.append(current._fixturedef)  # type: ignore[has-type]
             current = current._parent_request
+        values.reverse()
+        return values
 
     def _compute_fixture_value(self, fixturedef: "FixtureDef[object]") -> None:
         """Create a SubRequest based on "self" and call the execute method
@@ -626,10 +629,19 @@ class FixtureRequest:
         # (latter managed by fixturedef)
         argname = fixturedef.argname
         funcitem = self._pyfuncitem
-        scope = fixturedef.scope
+        scope = fixturedef._scope
         try:
-            param = funcitem.callspec.getparam(argname)
-        except (AttributeError, ValueError):
+            callspec = funcitem.callspec
+        except AttributeError:
+            callspec = None
+        if callspec is not None and argname in callspec.params:
+            param = callspec.params[argname]
+            param_index = callspec.indices[argname]
+            # If a parametrize invocation set a scope it will override
+            # the static scope defined with the fixture function.
+            with suppress(KeyError):
+                scope = callspec._arg2scope[argname]
+        else:
             param = NOTSET
             param_index = 0
             has_params = fixturedef.params is not None
@@ -648,12 +660,13 @@ class FixtureRequest:
             if has_params:
                 frame = inspect.stack()[3]
                 frameinfo = inspect.getframeinfo(frame[0])
-                source_path = py.path.local(frameinfo.filename)
+                source_path = absolutepath(frameinfo.filename)
                 source_lineno = frameinfo.lineno
-                rel_source_path = source_path.relto(funcitem.config.rootdir)
-                if rel_source_path:
-                    source_path_str = rel_source_path
-                else:
+                try:
+                    source_path_str = str(
+                        source_path.relative_to(funcitem.config.rootpath)
+                    )
+                except ValueError:
                     source_path_str = str(source_path)
                 msg = (
                     "The requested fixture has no parameter defined for test:\n"
@@ -662,26 +675,19 @@ class FixtureRequest:
                     "\n\nRequested here:\n{}:{}".format(
                         funcitem.nodeid,
                         fixturedef.argname,
-                        getlocation(fixturedef.func, funcitem.config.rootdir),
+                        getlocation(fixturedef.func, funcitem.config.rootpath),
                         source_path_str,
                         source_lineno,
                     )
                 )
                 fail(msg, pytrace=False)
-        else:
-            param_index = funcitem.callspec.indices[argname]
-            # If a parametrize invocation set a scope it will override
-            # the static scope defined with the fixture function.
-            paramscopenum = funcitem.callspec._arg2scopenum.get(argname)
-            if paramscopenum is not None:
-                scope = scopes[paramscopenum]
 
         subrequest = SubRequest(
             self, scope, param, param_index, fixturedef, _ispytest=True
         )
 
         # Check if a higher-level scoped fixture accesses a lower level one.
-        subrequest._check_scope(argname, self.scope, scope)
+        subrequest._check_scope(argname, self._scope, scope)
         try:
             # Call the fixture function.
             fixturedef.execute(request=subrequest)
@@ -692,23 +698,23 @@ class FixtureRequest:
         self, fixturedef: "FixtureDef[object]", subrequest: "SubRequest"
     ) -> None:
         # If fixture function failed it might have registered finalizers.
-        self.session._setupstate.addfinalizer(
-            functools.partial(fixturedef.finish, request=subrequest), subrequest.node
-        )
+        subrequest.node.addfinalizer(lambda: fixturedef.finish(request=subrequest))
 
     def _check_scope(
-        self, argname: str, invoking_scope: "_Scope", requested_scope: "_Scope",
+        self,
+        argname: str,
+        invoking_scope: Scope,
+        requested_scope: Scope,
     ) -> None:
         if argname == "request":
             return
-        if scopemismatch(invoking_scope, requested_scope):
+        if invoking_scope > requested_scope:
             # Try to report something helpful.
-            lines = self._factorytraceback()
+            text = "\n".join(self._factorytraceback())
             fail(
-                "ScopeMismatch: You tried to access the %r scoped "
-                "fixture %r with a %r scoped request object, "
-                "involved factories\n%s"
-                % ((requested_scope, argname, invoking_scope, "\n".join(lines))),
+                f"ScopeMismatch: You tried to access the {requested_scope.value} scoped "
+                f"fixture {argname} with a {invoking_scope.value} scoped request object, "
+                f"involved factories:\n{text}",
                 pytrace=False,
             )
 
@@ -717,29 +723,15 @@ class FixtureRequest:
         for fixturedef in self._get_fixturestack():
             factory = fixturedef.func
             fs, lineno = getfslineno(factory)
-            p = self._pyfuncitem.session.fspath.bestrelpath(fs)
+            if isinstance(fs, Path):
+                session: Session = self._pyfuncitem.session
+                p = bestrelpath(session.path, fs)
+            else:
+                p = fs
             args = _format_args(factory)
             lines.append("%s:%d:  def %s%s" % (p, lineno + 1, factory.__name__, args))
         return lines
 
-    def _getscopeitem(self, scope: "_Scope") -> Union[nodes.Item, nodes.Collector]:
-        if scope == "function":
-            # This might also be a non-function Item despite its attribute name.
-            node: Optional[Union[nodes.Item, nodes.Collector]] = self._pyfuncitem
-        elif scope == "package":
-            # FIXME: _fixturedef is not defined on FixtureRequest (this class),
-            # but on FixtureRequest (a subclass).
-            node = get_scope_package(self._pyfuncitem, self._fixturedef)  # type: ignore[attr-defined]
-        else:
-            node = get_scope_node(self._pyfuncitem, scope)
-        if node is None and scope == "class":
-            # Fallback to function item itself.
-            node = self._pyfuncitem
-        assert node, 'Could not obtain a node for scope "{}" for function {!r}'.format(
-            scope, self._pyfuncitem
-        )
-        return node
-
     def __repr__(self) -> str:
         return "<FixtureRequest for %r>" % (self.node)
 
@@ -751,8 +743,8 @@ class SubRequest(FixtureRequest):
     def __init__(
         self,
         request: "FixtureRequest",
-        scope: "_Scope",
-        param,
+        scope: Scope,
+        param: Any,
         param_index: int,
         fixturedef: "FixtureDef[object]",
         *,
@@ -764,7 +756,7 @@ class SubRequest(FixtureRequest):
         if param is not NOTSET:
             self.param = param
         self.param_index = param_index
-        self.scope = scope
+        self._scope = scope
         self._fixturedef = fixturedef
         self._pyfuncitem = request._pyfuncitem
         self._fixture_defs = request._fixture_defs
@@ -776,8 +768,8 @@ class SubRequest(FixtureRequest):
         return f"<SubRequest {self.fixturename!r} for {self._pyfuncitem!r}>"
 
     def addfinalizer(self, finalizer: Callable[[], object]) -> None:
-        """Add finalizer/teardown function to be called after the last test
-        within the requesting test context finished execution."""
+        """Add finalizer/teardown function to be called without arguments after
+        the last test within the requesting test context finished execution."""
         self._fixturedef.addfinalizer(finalizer)
 
     def _schedule_finalizers(
@@ -793,29 +785,6 @@ class SubRequest(FixtureRequest):
         super()._schedule_finalizers(fixturedef, subrequest)
 
 
-scopes: List["_Scope"] = ["session", "package", "module", "class", "function"]
-scopenum_function = scopes.index("function")
-
-
-def scopemismatch(currentscope: "_Scope", newscope: "_Scope") -> bool:
-    return scopes.index(newscope) > scopes.index(currentscope)
-
-
-def scope2index(scope: str, descr: str, where: Optional[str] = None) -> int:
-    """Look up the index of ``scope`` and raise a descriptive value error
-    if not defined."""
-    strscopes: Sequence[str] = scopes
-    try:
-        return strscopes.index(scope)
-    except ValueError:
-        fail(
-            "{} {}got an unexpected scope value '{}'".format(
-                descr, f"from {where} " if where else "", scope
-            ),
-            pytrace=False,
-        )
-
-
 @final
 class FixtureLookupError(LookupError):
     """Could not return a requested fixture (missing or invalid)."""
@@ -846,7 +815,7 @@ class FixtureLookupError(LookupError):
                 error_msg = "file %s, line %s: source code not available"
                 addline(error_msg % (fspath, lineno + 1))
             else:
-                addline("file {}, line {}".format(fspath, lineno + 1))
+                addline(f"file {fspath}, line {lineno + 1}")
                 for i, line in enumerate(lines):
                     line = line.rstrip()
                     addline("  " + line)
@@ -876,7 +845,7 @@ class FixtureLookupError(LookupError):
 class FixtureLookupErrorRepr(TerminalRepr):
     def __init__(
         self,
-        filename: Union[str, py.path.local],
+        filename: Union[str, "os.PathLike[str]"],
         firstlineno: int,
         tblines: Sequence[str],
         errorstring: str,
@@ -895,30 +864,31 @@ class FixtureLookupErrorRepr(TerminalRepr):
         lines = self.errorstring.split("\n")
         if lines:
             tw.line(
-                "{}       {}".format(FormattedExcinfo.fail_marker, lines[0].strip()),
+                f"{FormattedExcinfo.fail_marker}       {lines[0].strip()}",
                 red=True,
             )
             for line in lines[1:]:
                 tw.line(
-                    f"{FormattedExcinfo.flow_marker}       {line.strip()}", red=True,
+                    f"{FormattedExcinfo.flow_marker}       {line.strip()}",
+                    red=True,
                 )
         tw.line()
-        tw.line("%s:%d" % (self.filename, self.firstlineno + 1))
+        tw.line("%s:%d" % (os.fspath(self.filename), self.firstlineno + 1))
 
 
-def fail_fixturefunc(fixturefunc, msg: str) -> "NoReturn":
+def fail_fixturefunc(fixturefunc, msg: str) -> NoReturn:
     fs, lineno = getfslineno(fixturefunc)
-    location = "{}:{}".format(fs, lineno + 1)
+    location = f"{fs}:{lineno + 1}"
     source = _pytest._code.Source(fixturefunc)
     fail(msg + ":\n\n" + str(source.indent()) + "\n" + location, pytrace=False)
 
 
 def call_fixture_func(
-    fixturefunc: "_FixtureFunc[_FixtureValue]", request: FixtureRequest, kwargs
-) -> _FixtureValue:
+    fixturefunc: "_FixtureFunc[FixtureValue]", request: FixtureRequest, kwargs
+) -> FixtureValue:
     if is_generator(fixturefunc):
         fixturefunc = cast(
-            Callable[..., Generator[_FixtureValue, None, None]], fixturefunc
+            Callable[..., Generator[FixtureValue, None, None]], fixturefunc
         )
         generator = fixturefunc(**kwargs)
         try:
@@ -928,7 +898,7 @@ def call_fixture_func(
         finalizer = functools.partial(_teardown_yield_fixture, fixturefunc, generator)
         request.addfinalizer(finalizer)
     else:
-        fixturefunc = cast(Callable[..., _FixtureValue], fixturefunc)
+        fixturefunc = cast(Callable[..., FixtureValue], fixturefunc)
         fixture_result = fixturefunc(**kwargs)
     return fixture_result
 
@@ -946,10 +916,10 @@ def _teardown_yield_fixture(fixturefunc, it) -> None:
 
 
 def _eval_scope_callable(
-    scope_callable: "Callable[[str, Config], _Scope]",
+    scope_callable: "Callable[[str, Config], _ScopeName]",
     fixture_name: str,
     config: Config,
-) -> "_Scope":
+) -> "_ScopeName":
     try:
         # Type ignored because there is no typing mechanism to specify
         # keyword arguments, currently.
@@ -971,50 +941,77 @@ def _eval_scope_callable(
 
 
 @final
-class FixtureDef(Generic[_FixtureValue]):
-    """A container for a factory definition."""
+class FixtureDef(Generic[FixtureValue]):
+    """A container for a fixture definition."""
 
     def __init__(
         self,
         fixturemanager: "FixtureManager",
         baseid: Optional[str],
         argname: str,
-        func: "_FixtureFunc[_FixtureValue]",
-        scope: "Union[_Scope, Callable[[str, Config], _Scope]]",
+        func: "_FixtureFunc[FixtureValue]",
+        scope: Union[Scope, "_ScopeName", Callable[[str, Config], "_ScopeName"], None],
         params: Optional[Sequence[object]],
         unittest: bool = False,
         ids: Optional[
-            Union[
-                Tuple[Union[None, str, float, int, bool], ...],
-                Callable[[Any], Optional[object]],
-            ]
+            Union[Tuple[Optional[object], ...], Callable[[Any], Optional[object]]]
         ] = None,
     ) -> None:
         self._fixturemanager = fixturemanager
+        # The "base" node ID for the fixture.
+        #
+        # This is a node ID prefix. A fixture is only available to a node (e.g.
+        # a `Function` item) if the fixture's baseid is a parent of the node's
+        # nodeid (see the `iterparentnodeids` function for what constitutes a
+        # "parent" and a "prefix" in this context).
+        #
+        # For a fixture found in a Collector's object (e.g. a `Module`s module,
+        # a `Class`'s class), the baseid is the Collector's nodeid.
+        #
+        # For a fixture found in a conftest plugin, the baseid is the conftest's
+        # directory path relative to the rootdir.
+        #
+        # For other plugins, the baseid is the empty string (always matches).
         self.baseid = baseid or ""
+        # Whether the fixture was found from a node or a conftest in the
+        # collection tree. Will be false for fixtures defined in non-conftest
+        # plugins.
         self.has_location = baseid is not None
+        # The fixture factory function.
         self.func = func
+        # The name by which the fixture may be requested.
         self.argname = argname
-        if callable(scope):
-            scope_ = _eval_scope_callable(scope, argname, fixturemanager.config)
-        else:
-            scope_ = scope
-        self.scopenum = scope2index(
-            # TODO: Check if the `or` here is really necessary.
-            scope_ or "function",  # type: ignore[unreachable]
-            descr=f"Fixture '{func.__name__}'",
-            where=baseid,
-        )
-        self.scope = scope_
+        if scope is None:
+            scope = Scope.Function
+        elif callable(scope):
+            scope = _eval_scope_callable(scope, argname, fixturemanager.config)
+        if isinstance(scope, str):
+            scope = Scope.from_user(
+                scope, descr=f"Fixture '{func.__name__}'", where=baseid
+            )
+        self._scope = scope
+        # If the fixture is directly parametrized, the parameter values.
         self.params: Optional[Sequence[object]] = params
-        self.argnames: Tuple[str, ...] = getfuncargnames(
-            func, name=argname, is_method=unittest
-        )
-        self.unittest = unittest
+        # If the fixture is directly parametrized, a tuple of explicit IDs to
+        # assign to the parameter values, or a callable to generate an ID given
+        # a parameter value.
         self.ids = ids
-        self.cached_result: Optional[_FixtureCachedResult[_FixtureValue]] = None
+        # The names requested by the fixtures.
+        self.argnames = getfuncargnames(func, name=argname, is_method=unittest)
+        # Whether the fixture was collected from a unittest TestCase class.
+        # Note that it really only makes sense to define autouse fixtures in
+        # unittest TestCases.
+        self.unittest = unittest
+        # If the fixture was executed, the current value of the fixture.
+        # Can change if the fixture is executed with different parameters.
+        self.cached_result: Optional[_FixtureCachedResult[FixtureValue]] = None
         self._finalizers: List[Callable[[], object]] = []
 
+    @property
+    def scope(self) -> "_ScopeName":
+        """Scope string, one of "function", "class", "module", "package", "session"."""
+        return self._scope.value
+
     def addfinalizer(self, finalizer: Callable[[], object]) -> None:
         self._finalizers.append(finalizer)
 
@@ -1033,15 +1030,15 @@ class FixtureDef(Generic[_FixtureValue]):
             if exc:
                 raise exc
         finally:
-            hook = self._fixturemanager.session.gethookproxy(request.node.fspath)
-            hook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
+            ihook = request.node.ihook
+            ihook.pytest_fixture_post_finalizer(fixturedef=self, request=request)
             # Even if finalization fails, we invalidate the cached fixture
             # value and remove all finalizers because they may be bound methods
             # which will keep instances alive.
             self.cached_result = None
             self._finalizers = []
 
-    def execute(self, request: SubRequest) -> _FixtureValue:
+    def execute(self, request: SubRequest) -> FixtureValue:
         # Get required arguments and register our own finish()
         # with their finalization.
         for argname in self.argnames:
@@ -1068,8 +1065,8 @@ class FixtureDef(Generic[_FixtureValue]):
             self.finish(request)
             assert self.cached_result is None
 
-        hook = self._fixturemanager.session.gethookproxy(request.node.fspath)
-        result = hook.pytest_fixture_setup(fixturedef=self, request=request)
+        ihook = request.node.ihook
+        result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
         return result
 
     def cache_key(self, request: SubRequest) -> object:
@@ -1082,8 +1079,8 @@ class FixtureDef(Generic[_FixtureValue]):
 
 
 def resolve_fixture_function(
-    fixturedef: FixtureDef[_FixtureValue], request: FixtureRequest
-) -> "_FixtureFunc[_FixtureValue]":
+    fixturedef: FixtureDef[FixtureValue], request: FixtureRequest
+) -> "_FixtureFunc[FixtureValue]":
     """Get the actual callable that can be called to obtain the fixture
     value, dealing with unittest-specific instances and bound methods."""
     fixturefunc = fixturedef.func
@@ -1109,15 +1106,15 @@ def resolve_fixture_function(
 
 
 def pytest_fixture_setup(
-    fixturedef: FixtureDef[_FixtureValue], request: SubRequest
-) -> _FixtureValue:
+    fixturedef: FixtureDef[FixtureValue], request: SubRequest
+) -> FixtureValue:
     """Execution of fixture setup."""
     kwargs = {}
     for argname in fixturedef.argnames:
         fixdef = request._get_active_fixturedef(argname)
         assert fixdef.cached_result is not None
         result, arg_cache_key, exc = fixdef.cached_result
-        request._check_scope(argname, request.scope, fixdef.scope)
+        request._check_scope(argname, request._scope, fixdef._scope)
         kwargs[argname] = result
 
     fixturefunc = resolve_fixture_function(fixturedef, request)
@@ -1127,6 +1124,10 @@ def pytest_fixture_setup(
     except TEST_OUTCOME:
         exc_info = sys.exc_info()
         assert exc_info[0] is not None
+        if isinstance(
+            exc_info[1], skip.Exception
+        ) and not fixturefunc.__name__.startswith("xunit_setup"):
+            exc_info[1]._use_item_location = True  # type: ignore[attr-defined]
         fixturedef.cached_result = (None, my_cache_key, exc_info)
         raise
     fixturedef.cached_result = (result, my_cache_key, None)
@@ -1134,18 +1135,8 @@ def pytest_fixture_setup(
 
 
 def _ensure_immutable_ids(
-    ids: Optional[
-        Union[
-            Iterable[Union[None, str, float, int, bool]],
-            Callable[[Any], Optional[object]],
-        ]
-    ],
-) -> Optional[
-    Union[
-        Tuple[Union[None, str, float, int, bool], ...],
-        Callable[[Any], Optional[object]],
-    ]
-]:
+    ids: Optional[Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]]
+) -> Optional[Union[Tuple[Optional[object], ...], Callable[[Any], Optional[object]]]]:
     if ids is None:
         return None
     if callable(ids):
@@ -1160,14 +1151,15 @@ def _params_converter(
 
 
 def wrap_function_to_error_out_if_called_directly(
-    function: _FixtureFunction, fixture_marker: "FixtureFunctionMarker",
-) -> _FixtureFunction:
+    function: FixtureFunction,
+    fixture_marker: "FixtureFunctionMarker",
+) -> FixtureFunction:
     """Wrap the given fixture function so we can raise an error about it being called directly,
     instead of used as an argument in a test function."""
     message = (
         'Fixture "{name}" called directly. Fixtures are not meant to be called directly,\n'
         "but are created automatically when test functions request them as parameters.\n"
-        "See https://docs.pytest.org/en/stable/fixture.html for more information about fixtures, and\n"
+        "See https://docs.pytest.org/en/stable/explanation/fixtures.html for more information about fixtures, and\n"
         "https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directly about how to update your code."
     ).format(name=fixture_marker.name or function.__name__)
 
@@ -1179,26 +1171,26 @@ def wrap_function_to_error_out_if_called_directly(
     # further than this point and lose useful wrappings like @mock.patch (#3774).
     result.__pytest_wrapped__ = _PytestWrapper(function)  # type: ignore[attr-defined]
 
-    return cast(_FixtureFunction, result)
+    return cast(FixtureFunction, result)
 
 
 @final
-@attr.s(frozen=True)
+@dataclasses.dataclass(frozen=True)
 class FixtureFunctionMarker:
-    scope = attr.ib(type="Union[_Scope, Callable[[str, Config], _Scope]]")
-    params = attr.ib(type=Optional[Tuple[object, ...]], converter=_params_converter)
-    autouse = attr.ib(type=bool, default=False)
-    ids = attr.ib(
-        type=Union[
-            Tuple[Union[None, str, float, int, bool], ...],
-            Callable[[Any], Optional[object]],
-        ],
-        default=None,
-        converter=_ensure_immutable_ids,
-    )
-    name = attr.ib(type=Optional[str], default=None)
+    scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]"
+    params: Optional[Tuple[object, ...]]
+    autouse: bool = False
+    ids: Optional[
+        Union[Tuple[Optional[object], ...], Callable[[Any], Optional[object]]]
+    ] = None
+    name: Optional[str] = None
+
+    _ispytest: dataclasses.InitVar[bool] = False
+
+    def __post_init__(self, _ispytest: bool) -> None:
+        check_ispytest(_ispytest)
 
-    def __call__(self, function: _FixtureFunction) -> _FixtureFunction:
+    def __call__(self, function: FixtureFunction) -> FixtureFunction:
         if inspect.isclass(function):
             raise ValueError("class fixtures not supported (maybe in the future)")
 
@@ -1226,54 +1218,45 @@ class FixtureFunctionMarker:
 
 @overload
 def fixture(
-    fixture_function: _FixtureFunction,
+    fixture_function: FixtureFunction,
     *,
-    scope: "Union[_Scope, Callable[[str, Config], _Scope]]" = ...,
+    scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = ...,
     params: Optional[Iterable[object]] = ...,
     autouse: bool = ...,
     ids: Optional[
-        Union[
-            Iterable[Union[None, str, float, int, bool]],
-            Callable[[Any], Optional[object]],
-        ]
+        Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]
     ] = ...,
     name: Optional[str] = ...,
-) -> _FixtureFunction:
+) -> FixtureFunction:
     ...
 
 
 @overload
-def fixture(
+def fixture(  # noqa: F811
     fixture_function: None = ...,
     *,
-    scope: "Union[_Scope, Callable[[str, Config], _Scope]]" = ...,
+    scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = ...,
     params: Optional[Iterable[object]] = ...,
     autouse: bool = ...,
     ids: Optional[
-        Union[
-            Iterable[Union[None, str, float, int, bool]],
-            Callable[[Any], Optional[object]],
-        ]
+        Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]
     ] = ...,
     name: Optional[str] = None,
 ) -> FixtureFunctionMarker:
     ...
 
 
-def fixture(
-    fixture_function: Optional[_FixtureFunction] = None,
+def fixture(  # noqa: F811
+    fixture_function: Optional[FixtureFunction] = None,
     *,
-    scope: "Union[_Scope, Callable[[str, Config], _Scope]]" = "function",
+    scope: "Union[_ScopeName, Callable[[str, Config], _ScopeName]]" = "function",
     params: Optional[Iterable[object]] = None,
     autouse: bool = False,
     ids: Optional[
-        Union[
-            Iterable[Union[None, str, float, int, bool]],
-            Callable[[Any], Optional[object]],
-        ]
+        Union[Sequence[Optional[object]], Callable[[Any], Optional[object]]]
     ] = None,
     name: Optional[str] = None,
-) -> Union[FixtureFunctionMarker, _FixtureFunction]:
+) -> Union[FixtureFunctionMarker, FixtureFunction]:
     """Decorator to mark a fixture factory function.
 
     This decorator can be used, with or without parameters, to define a
@@ -1312,7 +1295,7 @@ def fixture(
         the fixture.
 
     :param ids:
-        List of string ids each corresponding to the params so that they are
+        Sequence of ids each corresponding to the params so that they are
         part of the test id. If no ids are provided they will be generated
         automatically from the params.
 
@@ -1325,7 +1308,12 @@ def fixture(
         ``@pytest.fixture(name='<fixturename>')``.
     """
     fixture_marker = FixtureFunctionMarker(
-        scope=scope, params=params, autouse=autouse, ids=ids, name=name,
+        scope=scope,
+        params=tuple(params) if params is not None else None,
+        autouse=autouse,
+        ids=None if ids is None else ids if callable(ids) else tuple(ids),
+        name=name,
+        _ispytest=True,
     )
 
     # Direct decoration.
@@ -1363,7 +1351,8 @@ def yield_fixture(
 
 @fixture(scope="session")
 def pytestconfig(request: FixtureRequest) -> Config:
-    """Session-scoped fixture that returns the :class:`_pytest.config.Config` object.
+    """Session-scoped fixture that returns the session's :class:`pytest.Config`
+    object.
 
     Example::
 
@@ -1380,7 +1369,7 @@ def pytest_addoption(parser: Parser) -> None:
         "usefixtures",
         type="args",
         default=[],
-        help="list of default fixtures to be used with this project",
+        help="List of default fixtures to be used with this project",
     )
 
 
@@ -1537,15 +1526,15 @@ class FixtureManager:
                     arg2fixturedefs[argname] = fixturedefs
                     merge(fixturedefs[-1].argnames)
 
-        def sort_by_scope(arg_name: str) -> int:
+        def sort_by_scope(arg_name: str) -> Scope:
             try:
                 fixturedefs = arg2fixturedefs[arg_name]
             except KeyError:
-                return scopes.index("function")
+                return Scope.Function
             else:
-                return fixturedefs[-1].scopenum
+                return fixturedefs[-1]._scope
 
-        fixturenames_closure.sort(key=sort_by_scope)
+        fixturenames_closure.sort(key=sort_by_scope, reverse=True)
         return initialnames, fixturenames_closure, arg2fixturedefs
 
     def pytest_generate_tests(self, metafunc: "Metafunc") -> None:
@@ -1597,13 +1586,52 @@ class FixtureManager:
         # Separate parametrized setups.
         items[:] = reorder_items(items)
 
+    @overload
     def parsefactories(
-        self, node_or_obj, nodeid=NOTSET, unittest: bool = False
+        self,
+        node_or_obj: nodes.Node,
+        *,
+        unittest: bool = ...,
     ) -> None:
+        raise NotImplementedError()
+
+    @overload
+    def parsefactories(  # noqa: F811
+        self,
+        node_or_obj: object,
+        nodeid: Optional[str],
+        *,
+        unittest: bool = ...,
+    ) -> None:
+        raise NotImplementedError()
+
+    def parsefactories(  # noqa: F811
+        self,
+        node_or_obj: Union[nodes.Node, object],
+        nodeid: Union[str, NotSetType, None] = NOTSET,
+        *,
+        unittest: bool = False,
+    ) -> None:
+        """Collect fixtures from a collection node or object.
+
+        Found fixtures are parsed into `FixtureDef`s and saved.
+
+        If `node_or_object` is a collection node (with an underlying Python
+        object), the node's object is traversed and the node's nodeid is used to
+        determine the fixtures' visibilty. `nodeid` must not be specified in
+        this case.
+
+        If `node_or_object` is an object (e.g. a plugin), the object is
+        traversed and the given `nodeid` is used to determine the fixtures'
+        visibility. `nodeid` must be specified in this case; None and "" mean
+        total visibility.
+        """
         if nodeid is not NOTSET:
             holderobj = node_or_obj
         else:
-            holderobj = node_or_obj.obj
+            assert isinstance(node_or_obj, nodes.Node)
+            holderobj = cast(object, node_or_obj.obj)  # type: ignore[attr-defined]
+            assert isinstance(node_or_obj.nodeid, str)
             nodeid = node_or_obj.nodeid
         if holderobj in self._holderobjseen:
             return
@@ -1611,6 +1639,11 @@ class FixtureManager:
         self._holderobjseen.add(holderobj)
         autousenames = []
         for name in dir(holderobj):
+            # ugly workaround for one of the fspath deprecated property of node
+            # todo: safely generalize
+            if isinstance(holderobj, nodes.Node) and name == "fspath":
+                continue
+
             # The attribute can be an arbitrary descriptor, so the attribute
             # access below can raise. safe_getatt() ignores such exceptions.
             obj = safe_getattr(holderobj, name, None)
index 8b93ed5f7f86f89c4182a65bf434c100093f5ca3..9f8ea231feddf4168064a1e7b03f36c9adac303e 100644 (file)
@@ -9,16 +9,15 @@ from typing import Union
 def freeze_includes() -> List[str]:
     """Return a list of module names used by pytest that should be
     included by cx_freeze."""
-    import py
     import _pytest
 
-    result = list(_iter_all_modules(py))
-    result += list(_iter_all_modules(_pytest))
+    result = list(_iter_all_modules(_pytest))
     return result
 
 
 def _iter_all_modules(
-    package: Union[str, types.ModuleType], prefix: str = "",
+    package: Union[str, types.ModuleType],
+    prefix: str = "",
 ) -> Iterator[str]:
     """Iterate over the names of all modules that can be found in the given
     package, recursively.
index 4384d07b2616499145238149176197db54113e1f..ea16c438823a98d164662fa5a83fa6a416e5722e 100644 (file)
@@ -6,13 +6,12 @@ from typing import List
 from typing import Optional
 from typing import Union
 
-import py
-
 import pytest
 from _pytest.config import Config
 from _pytest.config import ExitCode
 from _pytest.config import PrintHelp
 from _pytest.config.argparsing import Parser
+from _pytest.terminal import TerminalReporter
 
 
 class HelpAction(Action):
@@ -51,7 +50,7 @@ def pytest_addoption(parser: Parser) -> None:
         action="count",
         default=0,
         dest="version",
-        help="display pytest version and information about plugins."
+        help="Display pytest version and information about plugins. "
         "When given twice, also display information about plugins.",
     )
     group._addoption(
@@ -59,7 +58,7 @@ def pytest_addoption(parser: Parser) -> None:
         "--help",
         action=HelpAction,
         dest="help",
-        help="show help message and configuration info",
+        help="Show help message and configuration info",
     )
     group._addoption(
         "-p",
@@ -67,7 +66,7 @@ def pytest_addoption(parser: Parser) -> None:
         dest="plugins",
         default=[],
         metavar="name",
-        help="early-load given plugin module name or entry point (multi-allowed).\n"
+        help="Early-load given plugin module name or entry point (multi-allowed). "
         "To avoid loading of plugins, use the `no:` prefix, e.g. "
         "`no:doctest`.",
     )
@@ -76,21 +75,26 @@ def pytest_addoption(parser: Parser) -> None:
         "--trace-config",
         action="store_true",
         default=False,
-        help="trace considerations of conftest.py files.",
+        help="Trace considerations of conftest.py files",
     )
     group.addoption(
         "--debug",
-        action="store_true",
+        action="store",
+        nargs="?",
+        const="pytestdebug.log",
         dest="debug",
-        default=False,
-        help="store internal tracing debug information in 'pytestdebug.log'.",
+        metavar="DEBUG_FILE_NAME",
+        help="Store internal tracing debug information in this log file. "
+        "This file is opened with 'w' and truncated as a result, care advised. "
+        "Default: pytestdebug.log.",
     )
     group._addoption(
         "-o",
         "--override-ini",
         dest="override_ini",
         action="append",
-        help='override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`.',
+        help='Override ini option with "option=value" style, '
+        "e.g. `-o xfail_strict=True -o cache_dir=cache`.",
     )
 
 
@@ -98,15 +102,16 @@ def pytest_addoption(parser: Parser) -> None:
 def pytest_cmdline_parse():
     outcome = yield
     config: Config = outcome.get_result()
+
     if config.option.debug:
-        path = os.path.abspath("pytestdebug.log")
-        debugfile = open(path, "w")
+        # --debug | --debug <file.log> was provided.
+        path = config.option.debug
+        debugfile = open(path, "w", encoding="utf-8")
         debugfile.write(
-            "versions pytest-%s, py-%s, "
+            "versions pytest-%s, "
             "python-%s\ncwd=%s\nargs=%s\n\n"
             % (
                 pytest.__version__,
-                py.__version__,
                 ".".join(map(str, sys.version_info)),
                 os.getcwd(),
                 config.invocation_params.args,
@@ -114,11 +119,11 @@ def pytest_cmdline_parse():
         )
         config.trace.root.setwriter(debugfile.write)
         undo_tracing = config.pluginmanager.enable_tracing()
-        sys.stderr.write("writing pytestdebug information to %s\n" % path)
+        sys.stderr.write("writing pytest debug information to %s\n" % path)
 
         def unset_tracing() -> None:
             debugfile.close()
-            sys.stderr.write("wrote pytestdebug information to %s\n" % debugfile.name)
+            sys.stderr.write("wrote pytest debug information to %s\n" % debugfile.name)
             config.trace.root.setwriter(None)
             undo_tracing()
 
@@ -127,7 +132,7 @@ def pytest_cmdline_parse():
 
 def showversion(config: Config) -> None:
     if config.option.version > 1:
-        sys.stderr.write(
+        sys.stdout.write(
             "This is pytest version {}, imported from {}\n".format(
                 pytest.__version__, pytest.__file__
             )
@@ -135,9 +140,9 @@ def showversion(config: Config) -> None:
         plugininfo = getpluginversioninfo(config)
         if plugininfo:
             for line in plugininfo:
-                sys.stderr.write(line + "\n")
+                sys.stdout.write(line + "\n")
     else:
-        sys.stderr.write(f"pytest {pytest.__version__}\n")
+        sys.stdout.write(f"pytest {pytest.__version__}\n")
 
 
 def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
@@ -155,12 +160,16 @@ def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
 def showhelp(config: Config) -> None:
     import textwrap
 
-    reporter = config.pluginmanager.get_plugin("terminalreporter")
+    reporter: Optional[TerminalReporter] = config.pluginmanager.get_plugin(
+        "terminalreporter"
+    )
+    assert reporter is not None
     tw = reporter._tw
     tw.write(config._parser.optparser.format_help())
     tw.line()
     tw.line(
-        "[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:"
+        "[pytest] ini-options in the first "
+        "pytest.ini|tox.ini|setup.cfg|pyproject.toml file found:"
     )
     tw.line()
 
@@ -200,12 +209,12 @@ def showhelp(config: Config) -> None:
                     tw.line(indent + line)
 
     tw.line()
-    tw.line("environment variables:")
+    tw.line("Environment variables:")
     vars = [
-        ("PYTEST_ADDOPTS", "extra command line options"),
-        ("PYTEST_PLUGINS", "comma-separated plugins to load during startup"),
-        ("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "set to disable plugin auto-loading"),
-        ("PYTEST_DEBUG", "set to enable debug tracing of pytest's internals"),
+        ("PYTEST_ADDOPTS", "Extra command line options"),
+        ("PYTEST_PLUGINS", "Comma-separated plugins to load during startup"),
+        ("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "Set to disable plugin auto-loading"),
+        ("PYTEST_DEBUG", "Set to enable debug tracing of pytest's internals"),
     ]
     for name, help in vars:
         tw.line(f"  {name:<24} {help}")
@@ -243,7 +252,7 @@ def getpluginversioninfo(config: Config) -> List[str]:
 def pytest_report_header(config: Config) -> List[str]:
     lines = []
     if config.option.debug or config.option.traceconfig:
-        lines.append(f"using: pytest-{pytest.__version__} pylib-{py.__version__}")
+        lines.append(f"using: pytest-{pytest.__version__}")
 
         verinfo = getpluginversioninfo(config)
         if verinfo:
index e499b742c7ed55b5d5cc37f09249a2c41d498c64..1f7c368f79284aa3b657cc251dc87f146f40f32d 100644 (file)
@@ -1,5 +1,6 @@
 """Hook specifications for pytest plugins which are invoked by pytest itself
 and by builtin plugins."""
+from pathlib import Path
 from typing import Any
 from typing import Dict
 from typing import List
@@ -10,10 +11,9 @@ from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import Union
 
-import py.path
 from pluggy import HookspecMarker
 
-from _pytest.deprecated import WARNING_CAPTURED_HOOK
+from _pytest.deprecated import WARNING_CMDLINE_PREPARSE_HOOK
 
 if TYPE_CHECKING:
     import pdb
@@ -21,7 +21,7 @@ if TYPE_CHECKING:
     from typing_extensions import Literal
 
     from _pytest._code.code import ExceptionRepr
-    from _pytest.code import ExceptionInfo
+    from _pytest._code.code import ExceptionInfo
     from _pytest.config import Config
     from _pytest.config import ExitCode
     from _pytest.config import PytestPluginManager
@@ -33,14 +33,16 @@ if TYPE_CHECKING:
     from _pytest.nodes import Collector
     from _pytest.nodes import Item
     from _pytest.outcomes import Exit
+    from _pytest.python import Class
     from _pytest.python import Function
     from _pytest.python import Metafunc
     from _pytest.python import Module
-    from _pytest.python import PyCollector
     from _pytest.reports import CollectReport
     from _pytest.reports import TestReport
     from _pytest.runner import CallInfo
     from _pytest.terminal import TerminalReporter
+    from _pytest.terminal import TestShortLogReport
+    from _pytest.compat import LEGACY_PATH
 
 
 hookspec = HookspecMarker("pytest")
@@ -55,7 +57,7 @@ def pytest_addhooks(pluginmanager: "PytestPluginManager") -> None:
     """Called at plugin registration time to allow adding new hooks via a call to
     ``pluginmanager.add_hookspecs(module_or_class, prefix)``.
 
-    :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager.
+    :param pytest.PytestPluginManager pluginmanager: The pytest plugin manager.
 
     .. note::
         This hook is incompatible with ``hookwrapper=True``.
@@ -69,7 +71,7 @@ def pytest_plugin_registered(
     """A new pytest plugin got registered.
 
     :param plugin: The plugin module or instance.
-    :param _pytest.config.PytestPluginManager manager: pytest plugin manager.
+    :param pytest.PytestPluginManager manager: pytest plugin manager.
 
     .. note::
         This hook is incompatible with ``hookwrapper=True``.
@@ -87,24 +89,24 @@ def pytest_addoption(parser: "Parser", pluginmanager: "PytestPluginManager") ->
         files situated at the tests root directory due to how pytest
         :ref:`discovers plugins during startup <pluginorder>`.
 
-    :param _pytest.config.argparsing.Parser parser:
+    :param pytest.Parser parser:
         To add command line options, call
-        :py:func:`parser.addoption(...) <_pytest.config.argparsing.Parser.addoption>`.
+        :py:func:`parser.addoption(...) <pytest.Parser.addoption>`.
         To add ini-file values call :py:func:`parser.addini(...)
-        <_pytest.config.argparsing.Parser.addini>`.
+        <pytest.Parser.addini>`.
 
-    :param _pytest.config.PytestPluginManager pluginmanager:
-        pytest plugin manager, which can be used to install :py:func:`hookspec`'s
+    :param pytest.PytestPluginManager pluginmanager:
+        The pytest plugin manager, which can be used to install :py:func:`hookspec`'s
         or :py:func:`hookimpl`'s and allow one plugin to call another plugin's hooks
         to change how command line options are added.
 
     Options can later be accessed through the
-    :py:class:`config <_pytest.config.Config>` object, respectively:
+    :py:class:`config <pytest.Config>` object, respectively:
 
-    - :py:func:`config.getoption(name) <_pytest.config.Config.getoption>` to
+    - :py:func:`config.getoption(name) <pytest.Config.getoption>` to
       retrieve the value of a command line option.
 
-    - :py:func:`config.getini(name) <_pytest.config.Config.getini>` to retrieve
+    - :py:func:`config.getini(name) <pytest.Config.getini>` to retrieve
       a value read from an ini-style file.
 
     The config object is passed around on many internal objects via the ``.config``
@@ -128,7 +130,7 @@ def pytest_configure(config: "Config") -> None:
     .. note::
         This hook is incompatible with ``hookwrapper=True``.
 
-    :param _pytest.config.Config config: The pytest config object.
+    :param pytest.Config config: The pytest config object.
     """
 
 
@@ -142,7 +144,7 @@ def pytest_configure(config: "Config") -> None:
 def pytest_cmdline_parse(
     pluginmanager: "PytestPluginManager", args: List[str]
 ) -> Optional["Config"]:
-    """Return an initialized config object, parsing the specified args.
+    """Return an initialized :class:`~pytest.Config`, parsing the specified args.
 
     Stops at first non-None result, see :ref:`firstresult`.
 
@@ -151,22 +153,24 @@ def pytest_cmdline_parse(
         ``plugins`` arg when using `pytest.main`_ to perform an in-process
         test run.
 
-    :param _pytest.config.PytestPluginManager pluginmanager: Pytest plugin manager.
-    :param List[str] args: List of arguments passed on the command line.
+    :param pluginmanager: The pytest plugin manager.
+    :param args: List of arguments passed on the command line.
+    :returns: A pytest config object.
     """
 
 
+@hookspec(warn_on_impl=WARNING_CMDLINE_PREPARSE_HOOK)
 def pytest_cmdline_preparse(config: "Config", args: List[str]) -> None:
     """(**Deprecated**) modify command line arguments before option parsing.
 
     This hook is considered deprecated and will be removed in a future pytest version. Consider
-    using :func:`pytest_load_initial_conftests` instead.
+    using :hook:`pytest_load_initial_conftests` instead.
 
     .. note::
         This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
 
-    :param _pytest.config.Config config: The pytest config object.
-    :param List[str] args: Arguments passed on the command line.
+    :param config: The pytest config object.
+    :param args: Arguments passed on the command line.
     """
 
 
@@ -175,12 +179,10 @@ def pytest_cmdline_main(config: "Config") -> Optional[Union["ExitCode", int]]:
     """Called for performing the main command line action. The default
     implementation will invoke the configure hooks and runtest_mainloop.
 
-    .. note::
-        This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
-
     Stops at first non-None result, see :ref:`firstresult`.
 
-    :param _pytest.config.Config config: The pytest config object.
+    :param config: The pytest config object.
+    :returns: The exit code.
     """
 
 
@@ -193,9 +195,9 @@ def pytest_load_initial_conftests(
     .. note::
         This hook will not be called for ``conftest.py`` files, only for setuptools plugins.
 
-    :param _pytest.config.Config early_config: The pytest config object.
-    :param List[str] args: Arguments passed on the command line.
-    :param _pytest.config.argparsing.Parser parser: To add command line options.
+    :param early_config: The pytest config object.
+    :param args: Arguments passed on the command line.
+    :param parser: To add command line options.
     """
 
 
@@ -237,7 +239,7 @@ def pytest_collection(session: "Session") -> Optional[object]:
     for example the terminal plugin uses it to start displaying the collection
     counter (and returns `None`).
 
-    :param pytest.Session session: The pytest session object.
+    :param session: The pytest session object.
     """
 
 
@@ -247,21 +249,23 @@ def pytest_collection_modifyitems(
     """Called after collection has been performed. May filter or re-order
     the items in-place.
 
-    :param pytest.Session session: The pytest session object.
-    :param _pytest.config.Config config: The pytest config object.
-    :param List[pytest.Item] items: List of item objects.
+    :param session: The pytest session object.
+    :param config: The pytest config object.
+    :param items: List of item objects.
     """
 
 
 def pytest_collection_finish(session: "Session") -> None:
     """Called after collection has been performed and modified.
 
-    :param pytest.Session session: The pytest session object.
+    :param session: The pytest session object.
     """
 
 
 @hookspec(firstresult=True)
-def pytest_ignore_collect(path: py.path.local, config: "Config") -> Optional[bool]:
+def pytest_ignore_collect(
+    collection_path: Path, path: "LEGACY_PATH", config: "Config"
+) -> Optional[bool]:
     """Return True to prevent considering this path for collection.
 
     This hook is consulted for all files and directories prior to calling
@@ -269,19 +273,31 @@ def pytest_ignore_collect(path: py.path.local, config: "Config") -> Optional[boo
 
     Stops at first non-None result, see :ref:`firstresult`.
 
-    :param py.path.local path: The path to analyze.
-    :param _pytest.config.Config config: The pytest config object.
+    :param collection_path: The path to analyze.
+    :param path: The path to analyze (deprecated).
+    :param config: The pytest config object.
+
+    .. versionchanged:: 7.0.0
+        The ``collection_path`` parameter was added as a :class:`pathlib.Path`
+        equivalent of the ``path`` parameter. The ``path`` parameter
+        has been deprecated.
     """
 
 
 def pytest_collect_file(
-    path: py.path.local, parent: "Collector"
+    file_path: Path, path: "LEGACY_PATH", parent: "Collector"
 ) -> "Optional[Collector]":
-    """Create a Collector for the given path, or None if not relevant.
+    """Create a :class:`~pytest.Collector` for the given path, or None if not relevant.
 
     The new node needs to have the specified ``parent`` as a parent.
 
-    :param py.path.local path: The path to collect.
+    :param file_path: The path to analyze.
+    :param path: The path to collect (deprecated).
+
+    .. versionchanged:: 7.0.0
+        The ``file_path`` parameter was added as a :class:`pathlib.Path`
+        equivalent of the ``path`` parameter. The ``path`` parameter
+        has been deprecated.
     """
 
 
@@ -289,29 +305,48 @@ def pytest_collect_file(
 
 
 def pytest_collectstart(collector: "Collector") -> None:
-    """Collector starts collecting."""
+    """Collector starts collecting.
+
+    :param collector:
+        The collector.
+    """
 
 
 def pytest_itemcollected(item: "Item") -> None:
-    """We just collected a test item."""
+    """We just collected a test item.
+
+    :param item:
+        The item.
+    """
 
 
 def pytest_collectreport(report: "CollectReport") -> None:
-    """Collector finished collecting."""
+    """Collector finished collecting.
+
+    :param report:
+        The collect report.
+    """
 
 
 def pytest_deselected(items: Sequence["Item"]) -> None:
     """Called for deselected test items, e.g. by keyword.
 
     May be called multiple times.
+
+    :param items:
+        The items.
     """
 
 
 @hookspec(firstresult=True)
 def pytest_make_collect_report(collector: "Collector") -> "Optional[CollectReport]":
-    """Perform ``collector.collect()`` and return a CollectReport.
+    """Perform :func:`collector.collect() <pytest.Collector.collect>` and return
+    a :class:`~pytest.CollectReport`.
 
     Stops at first non-None result, see :ref:`firstresult`.
+
+    :param collector:
+        The collector.
     """
 
 
@@ -321,26 +356,44 @@ def pytest_make_collect_report(collector: "Collector") -> "Optional[CollectRepor
 
 
 @hookspec(firstresult=True)
-def pytest_pycollect_makemodule(path: py.path.local, parent) -> Optional["Module"]:
-    """Return a Module collector or None for the given path.
+def pytest_pycollect_makemodule(
+    module_path: Path, path: "LEGACY_PATH", parent
+) -> Optional["Module"]:
+    """Return a :class:`pytest.Module` collector or None for the given path.
 
     This hook will be called for each matching test module path.
-    The pytest_collect_file hook needs to be used if you want to
+    The :hook:`pytest_collect_file` hook needs to be used if you want to
     create test modules for files that do not match as a test module.
 
     Stops at first non-None result, see :ref:`firstresult`.
 
-    :param py.path.local path: The path of module to collect.
+    :param module_path: The path of the module to collect.
+    :param path: The path of the module to collect (deprecated).
+
+    .. versionchanged:: 7.0.0
+        The ``module_path`` parameter was added as a :class:`pathlib.Path`
+        equivalent of the ``path`` parameter.
+
+        The ``path`` parameter has been deprecated in favor of ``fspath``.
     """
 
 
 @hookspec(firstresult=True)
 def pytest_pycollect_makeitem(
-    collector: "PyCollector", name: str, obj: object
+    collector: Union["Module", "Class"], name: str, obj: object
 ) -> Union[None, "Item", "Collector", List[Union["Item", "Collector"]]]:
     """Return a custom item/collector for a Python object in a module, or None.
 
     Stops at first non-None result, see :ref:`firstresult`.
+
+    :param collector:
+        The module/class collector.
+    :param name:
+        The name of the object in the module/class.
+    :param obj:
+        The object.
+    :returns:
+        The created items/collectors.
     """
 
 
@@ -349,11 +402,18 @@ def pytest_pyfunc_call(pyfuncitem: "Function") -> Optional[object]:
     """Call underlying test function.
 
     Stops at first non-None result, see :ref:`firstresult`.
+
+    :param pyfuncitem:
+        The function item.
     """
 
 
 def pytest_generate_tests(metafunc: "Metafunc") -> None:
-    """Generate (multiple) parametrized calls to a test function."""
+    """Generate (multiple) parametrized calls to a test function.
+
+    :param metafunc:
+        The :class:`~pytest.Metafunc` helper for the test function.
+    """
 
 
 @hookspec(firstresult=True)
@@ -368,7 +428,7 @@ def pytest_make_parametrize_id(
 
     Stops at first non-None result, see :ref:`firstresult`.
 
-    :param _pytest.config.Config config: The pytest config object.
+    :param config: The pytest config object.
     :param val: The parametrized value.
     :param str argname: The automatic parameter name produced by pytest.
     """
@@ -393,7 +453,7 @@ def pytest_runtestloop(session: "Session") -> Optional[object]:
     If at any point ``session.shouldfail`` or ``session.shouldstop`` are set, the
     loop is terminated after the runtest protocol for the current item is finished.
 
-    :param pytest.Session session: The pytest session object.
+    :param session: The pytest session object.
 
     Stops at first non-None result, see :ref:`firstresult`.
     The return value is not used, but only stops further processing.
@@ -443,10 +503,12 @@ def pytest_runtest_logstart(
 ) -> None:
     """Called at the start of running the runtest protocol for a single item.
 
-    See :func:`pytest_runtest_protocol` for a description of the runtest protocol.
+    See :hook:`pytest_runtest_protocol` for a description of the runtest protocol.
 
-    :param str nodeid: Full node ID of the item.
-    :param location: A tuple of ``(filename, lineno, testname)``.
+    :param nodeid: Full node ID of the item.
+    :param location: A tuple of ``(filename, lineno, testname)``
+        where ``filename`` is a file path relative to ``config.rootpath``
+        and ``lineno`` is 0-based.
     """
 
 
@@ -455,10 +517,12 @@ def pytest_runtest_logfinish(
 ) -> None:
     """Called at the end of running the runtest protocol for a single item.
 
-    See :func:`pytest_runtest_protocol` for a description of the runtest protocol.
+    See :hook:`pytest_runtest_protocol` for a description of the runtest protocol.
 
-    :param str nodeid: Full node ID of the item.
-    :param location: A tuple of ``(filename, lineno, testname)``.
+    :param nodeid: Full node ID of the item.
+    :param location: A tuple of ``(filename, lineno, testname)``
+        where ``filename`` is a file path relative to ``config.rootpath``
+        and ``lineno`` is 0-based.
     """
 
 
@@ -469,6 +533,9 @@ def pytest_runtest_setup(item: "Item") -> None:
     parents (which haven't been setup yet). This includes obtaining the
     values of fixtures required by the item (which haven't been obtained
     yet).
+
+    :param item:
+        The item.
     """
 
 
@@ -476,6 +543,9 @@ def pytest_runtest_call(item: "Item") -> None:
     """Called to run the test for test item (the call phase).
 
     The default implementation calls ``item.runtest()``.
+
+    :param item:
+        The item.
     """
 
 
@@ -487,11 +557,13 @@ def pytest_runtest_teardown(item: "Item", nextitem: Optional["Item"]) -> None:
     includes running the teardown phase of fixtures required by the item (if
     they go out of scope).
 
+    :param item:
+        The item.
     :param nextitem:
         The scheduled-to-be-next test item (None if no further test item is
-        scheduled). This argument can be used to perform exact teardowns,
-        i.e. calling just enough finalizers so that nextitem only needs to
-        call setup-functions.
+        scheduled). This argument is used to perform exact teardowns, i.e.
+        calling just enough finalizers so that nextitem only needs to call
+        setup functions.
     """
 
 
@@ -499,38 +571,49 @@ def pytest_runtest_teardown(item: "Item", nextitem: Optional["Item"]) -> None:
 def pytest_runtest_makereport(
     item: "Item", call: "CallInfo[None]"
 ) -> Optional["TestReport"]:
-    """Called to create a :py:class:`_pytest.reports.TestReport` for each of
+    """Called to create a :class:`~pytest.TestReport` for each of
     the setup, call and teardown runtest phases of a test item.
 
-    See :func:`pytest_runtest_protocol` for a description of the runtest protocol.
+    See :hook:`pytest_runtest_protocol` for a description of the runtest protocol.
 
-    :param CallInfo[None] call: The ``CallInfo`` for the phase.
+    :param item: The item.
+    :param call: The :class:`~pytest.CallInfo` for the phase.
 
     Stops at first non-None result, see :ref:`firstresult`.
     """
 
 
 def pytest_runtest_logreport(report: "TestReport") -> None:
-    """Process the :py:class:`_pytest.reports.TestReport` produced for each
+    """Process the :class:`~pytest.TestReport` produced for each
     of the setup, call and teardown runtest phases of an item.
 
-    See :func:`pytest_runtest_protocol` for a description of the runtest protocol.
+    See :hook:`pytest_runtest_protocol` for a description of the runtest protocol.
     """
 
 
 @hookspec(firstresult=True)
 def pytest_report_to_serializable(
-    config: "Config", report: Union["CollectReport", "TestReport"],
+    config: "Config",
+    report: Union["CollectReport", "TestReport"],
 ) -> Optional[Dict[str, Any]]:
     """Serialize the given report object into a data structure suitable for
-    sending over the wire, e.g. converted to JSON."""
+    sending over the wire, e.g. converted to JSON.
+
+    :param config: The pytest config object.
+    :param report: The report.
+    """
 
 
 @hookspec(firstresult=True)
 def pytest_report_from_serializable(
-    config: "Config", data: Dict[str, Any],
+    config: "Config",
+    data: Dict[str, Any],
 ) -> Optional[Union["CollectReport", "TestReport"]]:
-    """Restore a report object previously serialized with pytest_report_to_serializable()."""
+    """Restore a report object previously serialized with
+    :hook:`pytest_report_to_serializable`.
+
+    :param config: The pytest config object.
+    """
 
 
 # -------------------------------------------------------------------------
@@ -544,7 +627,12 @@ def pytest_fixture_setup(
 ) -> Optional[object]:
     """Perform fixture setup execution.
 
-    :returns: The return value of the call to the fixture function.
+    :param fixturdef:
+        The fixture definition object.
+    :param request:
+        The fixture request object.
+    :returns:
+        The return value of the call to the fixture function.
 
     Stops at first non-None result, see :ref:`firstresult`.
 
@@ -560,7 +648,13 @@ def pytest_fixture_post_finalizer(
 ) -> None:
     """Called after fixture teardown, but before the cache is cleared, so
     the fixture result ``fixturedef.cached_result`` is still available (not
-    ``None``)."""
+    ``None``).
+
+    :param fixturdef:
+        The fixture definition object.
+    :param request:
+        The fixture request object.
+    """
 
 
 # -------------------------------------------------------------------------
@@ -572,24 +666,25 @@ def pytest_sessionstart(session: "Session") -> None:
     """Called after the ``Session`` object has been created and before performing collection
     and entering the run test loop.
 
-    :param pytest.Session session: The pytest session object.
+    :param session: The pytest session object.
     """
 
 
 def pytest_sessionfinish(
-    session: "Session", exitstatus: Union[int, "ExitCode"],
+    session: "Session",
+    exitstatus: Union[int, "ExitCode"],
 ) -> None:
     """Called after whole test run finished, right before returning the exit status to the system.
 
-    :param pytest.Session session: The pytest session object.
-    :param int exitstatus: The status which pytest will return to the system.
+    :param session: The pytest session object.
+    :param exitstatus: The status which pytest will return to the system.
     """
 
 
 def pytest_unconfigure(config: "Config") -> None:
     """Called before test process is exited.
 
-    :param _pytest.config.Config config: The pytest config object.
+    :param config: The pytest config object.
     """
 
 
@@ -608,12 +703,15 @@ def pytest_assertrepr_compare(
     *in* a string will be escaped. Note that all but the first line will
     be indented slightly, the intention is for the first line to be a summary.
 
-    :param _pytest.config.Config config: The pytest config object.
+    :param config: The pytest config object.
+    :param op: The operator, e.g. `"=="`, `"!="`, `"not in"`.
+    :param left: The left operand.
+    :param right: The right operand.
     """
 
 
 def pytest_assertion_pass(item: "Item", lineno: int, orig: str, expl: str) -> None:
-    """**(Experimental)** Called whenever an assertion passes.
+    """Called whenever an assertion passes.
 
     .. versionadded:: 5.0
 
@@ -633,17 +731,10 @@ def pytest_assertion_pass(item: "Item", lineno: int, orig: str, expl: str) -> No
     You need to **clean the .pyc** files in your project directory and interpreter libraries
     when enabling this option, as assertions will require to be re-written.
 
-    :param pytest.Item item: pytest item object of current test.
-    :param int lineno: Line number of the assert statement.
-    :param str orig: String with the original assertion.
-    :param str expl: String with the assert explanation.
-
-    .. note::
-
-        This hook is **experimental**, so its parameters or even the hook itself might
-        be changed/removed without warning in any future pytest release.
-
-        If you find this hook useful, please share your feedback in an issue.
+    :param item: pytest item object of current test.
+    :param lineno: Line number of the assert statement.
+    :param orig: String with the original assertion.
+    :param expl: String with the assert explanation.
     """
 
 
@@ -652,13 +743,14 @@ def pytest_assertion_pass(item: "Item", lineno: int, orig: str, expl: str) -> No
 # -------------------------------------------------------------------------
 
 
-def pytest_report_header(
-    config: "Config", startdir: py.path.local
+def pytest_report_header(  # type:ignore[empty-body]
+    config: "Config", start_path: Path, startdir: "LEGACY_PATH"
 ) -> Union[str, List[str]]:
     """Return a string or list of strings to be displayed as header info for terminal reporting.
 
-    :param _pytest.config.Config config: The pytest config object.
-    :param py.path.local startdir: The starting dir.
+    :param config: The pytest config object.
+    :param start_path: The starting dir.
+    :param startdir: The starting dir (deprecated).
 
     .. note::
 
@@ -672,11 +764,19 @@ def pytest_report_header(
         This function should be implemented only in plugins or ``conftest.py``
         files situated at the tests root directory due to how pytest
         :ref:`discovers plugins during startup <pluginorder>`.
+
+    .. versionchanged:: 7.0.0
+        The ``start_path`` parameter was added as a :class:`pathlib.Path`
+        equivalent of the ``startdir`` parameter. The ``startdir`` parameter
+        has been deprecated.
     """
 
 
-def pytest_report_collectionfinish(
-    config: "Config", startdir: py.path.local, items: Sequence["Item"],
+def pytest_report_collectionfinish(  # type:ignore[empty-body]
+    config: "Config",
+    start_path: Path,
+    startdir: "LEGACY_PATH",
+    items: Sequence["Item"],
 ) -> Union[str, List[str]]:
     """Return a string or list of strings to be displayed after collection
     has finished successfully.
@@ -685,8 +785,9 @@ def pytest_report_collectionfinish(
 
     .. versionadded:: 3.2
 
-    :param _pytest.config.Config config: The pytest config object.
-    :param py.path.local startdir: The starting dir.
+    :param config: The pytest config object.
+    :param start_path: The starting dir.
+    :param startdir: The starting dir (deprecated).
     :param items: List of pytest items that are going to be executed; this list should not be modified.
 
     .. note::
@@ -695,15 +796,18 @@ def pytest_report_collectionfinish(
         ran before it.
         If you want to have your line(s) displayed first, use
         :ref:`trylast=True <plugin-hookorder>`.
+
+    .. versionchanged:: 7.0.0
+        The ``start_path`` parameter was added as a :class:`pathlib.Path`
+        equivalent of the ``startdir`` parameter. The ``startdir`` parameter
+        has been deprecated.
     """
 
 
 @hookspec(firstresult=True)
-def pytest_report_teststatus(
+def pytest_report_teststatus(  # type:ignore[empty-body]
     report: Union["CollectReport", "TestReport"], config: "Config"
-) -> Tuple[
-    str, str, Union[str, Mapping[str, bool]],
-]:
+) -> "TestShortLogReport | Tuple[str, str, Union[str, Tuple[str, Mapping[str, bool]]]]":
     """Return result-category, shortletter and verbose word for status
     reporting.
 
@@ -721,61 +825,29 @@ def pytest_report_teststatus(
     for example ``"rerun", "R", ("RERUN", {"yellow": True})``.
 
     :param report: The report object whose status is to be returned.
-    :param _pytest.config.Config config: The pytest config object.
+    :param config: The pytest config object.
+    :returns: The test status.
 
     Stops at first non-None result, see :ref:`firstresult`.
     """
 
 
 def pytest_terminal_summary(
-    terminalreporter: "TerminalReporter", exitstatus: "ExitCode", config: "Config",
+    terminalreporter: "TerminalReporter",
+    exitstatus: "ExitCode",
+    config: "Config",
 ) -> None:
     """Add a section to terminal summary reporting.
 
-    :param _pytest.terminal.TerminalReporter terminalreporter: The internal terminal reporter object.
-    :param int exitstatus: The exit status that will be reported back to the OS.
-    :param _pytest.config.Config config: The pytest config object.
+    :param terminalreporter: The internal terminal reporter object.
+    :param exitstatus: The exit status that will be reported back to the OS.
+    :param config: The pytest config object.
 
     .. versionadded:: 4.2
         The ``config`` parameter.
     """
 
 
-@hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK)
-def pytest_warning_captured(
-    warning_message: "warnings.WarningMessage",
-    when: "Literal['config', 'collect', 'runtest']",
-    item: Optional["Item"],
-    location: Optional[Tuple[str, int, str]],
-) -> None:
-    """(**Deprecated**) Process a warning captured by the internal pytest warnings plugin.
-
-    .. deprecated:: 6.0
-
-    This hook is considered deprecated and will be removed in a future pytest version.
-    Use :func:`pytest_warning_recorded` instead.
-
-    :param warnings.WarningMessage warning_message:
-        The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
-        the same attributes as the parameters of :py:func:`warnings.showwarning`.
-
-    :param str when:
-        Indicates when the warning was captured. Possible values:
-
-        * ``"config"``: during pytest configuration/initialization stage.
-        * ``"collect"``: during test collection.
-        * ``"runtest"``: during test execution.
-
-    :param pytest.Item|None item:
-        The item being executed if ``when`` is ``"runtest"``, otherwise ``None``.
-
-    :param tuple location:
-        When available, holds information about the execution context of the captured
-        warning (filename, linenumber, function). ``function`` evaluates to <module>
-        when the execution context is at the module level.
-    """
-
-
 @hookspec(historic=True)
 def pytest_warning_recorded(
     warning_message: "warnings.WarningMessage",
@@ -785,21 +857,21 @@ def pytest_warning_recorded(
 ) -> None:
     """Process a warning captured by the internal pytest warnings plugin.
 
-    :param warnings.WarningMessage warning_message:
+    :param warning_message:
         The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains
         the same attributes as the parameters of :py:func:`warnings.showwarning`.
 
-    :param str when:
+    :param when:
         Indicates when the warning was captured. Possible values:
 
         * ``"config"``: during pytest configuration/initialization stage.
         * ``"collect"``: during test collection.
         * ``"runtest"``: during test execution.
 
-    :param str nodeid:
+    :param nodeid:
         Full id of the item.
 
-    :param tuple|None location:
+    :param location:
         When available, holds information about the execution context of the captured
         warning (filename, linenumber, function). ``function`` evaluates to <module>
         when the execution context is at the module level.
@@ -813,7 +885,9 @@ def pytest_warning_recorded(
 # -------------------------------------------------------------------------
 
 
-def pytest_markeval_namespace(config: "Config") -> Dict[str, Any]:
+def pytest_markeval_namespace(  # type:ignore[empty-body]
+    config: "Config",
+) -> Dict[str, Any]:
     """Called when constructing the globals dictionary used for
     evaluating string conditions in xfail/skipif markers.
 
@@ -824,7 +898,7 @@ def pytest_markeval_namespace(config: "Config") -> Dict[str, Any]:
 
     .. versionadded:: 6.2
 
-    :param _pytest.config.Config config: The pytest config object.
+    :param config: The pytest config object.
     :returns: A dictionary of additional globals to add.
     """
 
@@ -835,19 +909,26 @@ def pytest_markeval_namespace(config: "Config") -> Dict[str, Any]:
 
 
 def pytest_internalerror(
-    excrepr: "ExceptionRepr", excinfo: "ExceptionInfo[BaseException]",
+    excrepr: "ExceptionRepr",
+    excinfo: "ExceptionInfo[BaseException]",
 ) -> Optional[bool]:
     """Called for internal errors.
 
     Return True to suppress the fallback handling of printing an
     INTERNALERROR message directly to sys.stderr.
+
+    :param excrepr: The exception repr object.
+    :param excinfo: The exception info.
     """
 
 
 def pytest_keyboard_interrupt(
     excinfo: "ExceptionInfo[Union[KeyboardInterrupt, Exit]]",
 ) -> None:
-    """Called for keyboard interrupt."""
+    """Called for keyboard interrupt.
+
+    :param excinfo: The exception info.
+    """
 
 
 def pytest_exception_interact(
@@ -858,14 +939,21 @@ def pytest_exception_interact(
     """Called when an exception was raised which can potentially be
     interactively handled.
 
-    May be called during collection (see :py:func:`pytest_make_collect_report`),
-    in which case ``report`` is a :py:class:`_pytest.reports.CollectReport`.
+    May be called during collection (see :hook:`pytest_make_collect_report`),
+    in which case ``report`` is a :class:`CollectReport`.
 
-    May be called during runtest of an item (see :py:func:`pytest_runtest_protocol`),
-    in which case ``report`` is a :py:class:`_pytest.reports.TestReport`.
+    May be called during runtest of an item (see :hook:`pytest_runtest_protocol`),
+    in which case ``report`` is a :class:`TestReport`.
 
     This hook is not called if the exception that was raised is an internal
     exception like ``skip.Exception``.
+
+    :param node:
+        The item or collector.
+    :param call:
+        The call information. Contains the exception.
+    :param report:
+        The collection or test report.
     """
 
 
@@ -875,8 +963,8 @@ def pytest_enter_pdb(config: "Config", pdb: "pdb.Pdb") -> None:
     Can be used by plugins to take special action just before the python
     debugger enters interactive mode.
 
-    :param _pytest.config.Config config: The pytest config object.
-    :param pdb.Pdb pdb: The Pdb instance.
+    :param config: The pytest config object.
+    :param pdb: The Pdb instance.
     """
 
 
@@ -886,6 +974,6 @@ def pytest_leave_pdb(config: "Config", pdb: "pdb.Pdb") -> None:
     Can be used by plugins to take special action just after the python
     debugger leaves interactive mode.
 
-    :param _pytest.config.Config config: The pytest config object.
-    :param pdb.Pdb pdb: The Pdb instance.
+    :param config: The pytest config object.
+    :param pdb: The Pdb instance.
     """
index c4761cd3b87a92189e8390567e1e912a7a85cdce..ed259e4c41d6e2169f42a3f0079b436ee45356f5 100644 (file)
@@ -30,11 +30,11 @@ from _pytest.config import filename_arg
 from _pytest.config.argparsing import Parser
 from _pytest.fixtures import FixtureRequest
 from _pytest.reports import TestReport
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 from _pytest.terminal import TerminalReporter
 
 
-xml_key = StoreKey["LogXML"]()
+xml_key = StashKey["LogXML"]()
 
 
 def bin_xml_escape(arg: object) -> str:
@@ -92,7 +92,7 @@ class _NodeReporter:
         self.xml = xml
         self.add_stats = self.xml.add_stats
         self.family = self.xml.family
-        self.duration = 0
+        self.duration = 0.0
         self.properties: List[Tuple[str, str]] = []
         self.nodes: List[ET.Element] = []
         self.attrs: Dict[str, str] = {}
@@ -231,7 +231,7 @@ class _NodeReporter:
             msg = f'failed on teardown with "{reason}"'
         else:
             msg = f'failed on setup with "{reason}"'
-        self._add_simple("error", msg, str(report.longrepr))
+        self._add_simple("error", bin_xml_escape(msg), str(report.longrepr))
 
     def append_skipped(self, report: TestReport) -> None:
         if hasattr(report, "wasxfail"):
@@ -256,7 +256,7 @@ class _NodeReporter:
     def finalize(self) -> None:
         data = self.to_xml()
         self.__dict__.clear()
-        # Type ignored becuase mypy doesn't like overriding a method.
+        # Type ignored because mypy doesn't like overriding a method.
         # Also the return value doesn't match...
         self.to_xml = lambda: data  # type: ignore[assignment]
 
@@ -267,7 +267,7 @@ def _warn_incompatibility_with_xunit2(
     """Emit a PytestWarning about the given fixture being incompatible with newer xunit revisions."""
     from _pytest.warning_types import PytestWarning
 
-    xml = request.config._store.get(xml_key, None)
+    xml = request.config.stash.get(xml_key, None)
     if xml is not None and xml.family not in ("xunit1", "legacy"):
         request.node.warn(
             PytestWarning(
@@ -322,7 +322,7 @@ def record_xml_attribute(request: FixtureRequest) -> Callable[[str, object], Non
 
     attr_func = add_attr_noop
 
-    xml = request.config._store.get(xml_key, None)
+    xml = request.config.stash.get(xml_key, None)
     if xml is not None:
         node_reporter = xml.node_reporter(request.node.nodeid)
         attr_func = node_reporter.add_attribute
@@ -354,13 +354,16 @@ def record_testsuite_property(request: FixtureRequest) -> Callable[[str, object]
             record_testsuite_property("ARCH", "PPC")
             record_testsuite_property("STORAGE_TYPE", "CEPH")
 
-    ``name`` must be a string, ``value`` will be converted to a string and properly xml-escaped.
+    :param name:
+        The property name.
+    :param value:
+        The property value. Will be converted to a string.
 
     .. warning::
 
         Currently this fixture **does not work** with the
-        `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See issue
-        `#7767 <https://github.com/pytest-dev/pytest/issues/7767>`__ for details.
+        `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
+        :issue:`7767` for details.
     """
 
     __tracebackhide__ = True
@@ -370,7 +373,7 @@ def record_testsuite_property(request: FixtureRequest) -> Callable[[str, object]
         __tracebackhide__ = True
         _check_record_param_type("name", name)
 
-    xml = request.config._store.get(xml_key, None)
+    xml = request.config.stash.get(xml_key, None)
     if xml is not None:
         record_func = xml.add_global_property  # noqa
     return record_func
@@ -386,7 +389,7 @@ def pytest_addoption(parser: Parser) -> None:
         metavar="path",
         type=functools.partial(filename_arg, optname="--junitxml"),
         default=None,
-        help="create junit-xml style report file at given path.",
+        help="Create junit-xml style report file at given path",
     )
     group.addoption(
         "--junitprefix",
@@ -394,7 +397,7 @@ def pytest_addoption(parser: Parser) -> None:
         action="store",
         metavar="str",
         default=None,
-        help="prepend prefix to classnames in junit-xml output",
+        help="Prepend prefix to classnames in junit-xml output",
     )
     parser.addini(
         "junit_suite_name", "Test suite name for JUnit report", default="pytest"
@@ -428,7 +431,7 @@ def pytest_configure(config: Config) -> None:
     # Prevent opening xmllog on worker nodes (xdist).
     if xmlpath and not hasattr(config, "workerinput"):
         junit_family = config.getini("junit_family")
-        config._store[xml_key] = LogXML(
+        config.stash[xml_key] = LogXML(
             xmlpath,
             config.option.junitprefix,
             config.getini("junit_suite_name"),
@@ -437,23 +440,19 @@ def pytest_configure(config: Config) -> None:
             junit_family,
             config.getini("junit_log_passing_tests"),
         )
-        config.pluginmanager.register(config._store[xml_key])
+        config.pluginmanager.register(config.stash[xml_key])
 
 
 def pytest_unconfigure(config: Config) -> None:
-    xml = config._store.get(xml_key, None)
+    xml = config.stash.get(xml_key, None)
     if xml:
-        del config._store[xml_key]
+        del config.stash[xml_key]
         config.pluginmanager.unregister(xml)
 
 
 def mangle_test_address(address: str) -> List[str]:
     path, possible_open_bracket, params = address.partition("[")
     names = path.split("::")
-    try:
-        names.remove("()")
-    except ValueError:
-        pass
     # Convert file path to dotted path.
     names[0] = names[0].replace(nodes.SEP, ".")
     names[0] = re.sub(r"\.py$", "", names[0])
@@ -486,7 +485,7 @@ class LogXML:
         )
         self.node_reporters: Dict[
             Tuple[Union[str, TestReport], object], _NodeReporter
-        ] = ({})
+        ] = {}
         self.node_reporters_ordered: List[_NodeReporter] = []
         self.global_properties: List[Tuple[str, str]] = []
 
@@ -503,6 +502,10 @@ class LogXML:
         # Local hack to handle xdist report order.
         workernode = getattr(report, "node", None)
         reporter = self.node_reporters.pop((nodeid, workernode))
+
+        for propname, propvalue in report.user_properties:
+            reporter.add_property(propname, str(propvalue))
+
         if reporter is not None:
             reporter.finalize()
 
@@ -600,9 +603,6 @@ class LogXML:
             reporter = self._opentestcase(report)
             reporter.write_captured_output(report)
 
-            for propname, propvalue in report.user_properties:
-                reporter.add_property(propname, str(propvalue))
-
             self.finalize(report)
             report_wid = getattr(report, "worker_id", None)
             report_ii = getattr(report, "item_index", None)
@@ -646,41 +646,41 @@ class LogXML:
 
     def pytest_sessionfinish(self) -> None:
         dirname = os.path.dirname(os.path.abspath(self.logfile))
-        if not os.path.isdir(dirname):
-            os.makedirs(dirname)
-        logfile = open(self.logfile, "w", encoding="utf-8")
-        suite_stop_time = timing.time()
-        suite_time_delta = suite_stop_time - self.suite_start_time
-
-        numtests = (
-            self.stats["passed"]
-            + self.stats["failure"]
-            + self.stats["skipped"]
-            + self.stats["error"]
-            - self.cnt_double_fail_tests
-        )
-        logfile.write('<?xml version="1.0" encoding="utf-8"?>')
-
-        suite_node = ET.Element(
-            "testsuite",
-            name=self.suite_name,
-            errors=str(self.stats["error"]),
-            failures=str(self.stats["failure"]),
-            skipped=str(self.stats["skipped"]),
-            tests=str(numtests),
-            time="%.3f" % suite_time_delta,
-            timestamp=datetime.fromtimestamp(self.suite_start_time).isoformat(),
-            hostname=platform.node(),
-        )
-        global_properties = self._get_global_properties_node()
-        if global_properties is not None:
-            suite_node.append(global_properties)
-        for node_reporter in self.node_reporters_ordered:
-            suite_node.append(node_reporter.to_xml())
-        testsuites = ET.Element("testsuites")
-        testsuites.append(suite_node)
-        logfile.write(ET.tostring(testsuites, encoding="unicode"))
-        logfile.close()
+        # exist_ok avoids filesystem race conditions between checking path existence and requesting creation
+        os.makedirs(dirname, exist_ok=True)
+
+        with open(self.logfile, "w", encoding="utf-8") as logfile:
+            suite_stop_time = timing.time()
+            suite_time_delta = suite_stop_time - self.suite_start_time
+
+            numtests = (
+                self.stats["passed"]
+                + self.stats["failure"]
+                + self.stats["skipped"]
+                + self.stats["error"]
+                - self.cnt_double_fail_tests
+            )
+            logfile.write('<?xml version="1.0" encoding="utf-8"?>')
+
+            suite_node = ET.Element(
+                "testsuite",
+                name=self.suite_name,
+                errors=str(self.stats["error"]),
+                failures=str(self.stats["failure"]),
+                skipped=str(self.stats["skipped"]),
+                tests=str(numtests),
+                time="%.3f" % suite_time_delta,
+                timestamp=datetime.fromtimestamp(self.suite_start_time).isoformat(),
+                hostname=platform.node(),
+            )
+            global_properties = self._get_global_properties_node()
+            if global_properties is not None:
+                suite_node.append(global_properties)
+            for node_reporter in self.node_reporters_ordered:
+                suite_node.append(node_reporter.to_xml())
+            testsuites = ET.Element("testsuites")
+            testsuites.append(suite_node)
+            logfile.write(ET.tostring(testsuites, encoding="unicode"))
 
     def pytest_terminal_summary(self, terminalreporter: TerminalReporter) -> None:
         terminalreporter.write_sep("-", f"generated xml file: {self.logfile}")
diff --git a/src/_pytest/legacypath.py b/src/_pytest/legacypath.py
new file mode 100644 (file)
index 0000000..af1d0c0
--- /dev/null
@@ -0,0 +1,479 @@
+"""Add backward compatibility support for the legacy py path type."""
+import dataclasses
+import shlex
+import subprocess
+from pathlib import Path
+from typing import List
+from typing import Optional
+from typing import TYPE_CHECKING
+from typing import Union
+
+from iniconfig import SectionWrapper
+
+from _pytest.cacheprovider import Cache
+from _pytest.compat import final
+from _pytest.compat import LEGACY_PATH
+from _pytest.compat import legacy_path
+from _pytest.config import Config
+from _pytest.config import hookimpl
+from _pytest.config import PytestPluginManager
+from _pytest.deprecated import check_ispytest
+from _pytest.fixtures import fixture
+from _pytest.fixtures import FixtureRequest
+from _pytest.main import Session
+from _pytest.monkeypatch import MonkeyPatch
+from _pytest.nodes import Collector
+from _pytest.nodes import Item
+from _pytest.nodes import Node
+from _pytest.pytester import HookRecorder
+from _pytest.pytester import Pytester
+from _pytest.pytester import RunResult
+from _pytest.terminal import TerminalReporter
+from _pytest.tmpdir import TempPathFactory
+
+if TYPE_CHECKING:
+    from typing_extensions import Final
+
+    import pexpect
+
+
+@final
+class Testdir:
+    """
+    Similar to :class:`Pytester`, but this class works with legacy legacy_path objects instead.
+
+    All methods just forward to an internal :class:`Pytester` instance, converting results
+    to `legacy_path` objects as necessary.
+    """
+
+    __test__ = False
+
+    CLOSE_STDIN: "Final" = Pytester.CLOSE_STDIN
+    TimeoutExpired: "Final" = Pytester.TimeoutExpired
+
+    def __init__(self, pytester: Pytester, *, _ispytest: bool = False) -> None:
+        check_ispytest(_ispytest)
+        self._pytester = pytester
+
+    @property
+    def tmpdir(self) -> LEGACY_PATH:
+        """Temporary directory where tests are executed."""
+        return legacy_path(self._pytester.path)
+
+    @property
+    def test_tmproot(self) -> LEGACY_PATH:
+        return legacy_path(self._pytester._test_tmproot)
+
+    @property
+    def request(self):
+        return self._pytester._request
+
+    @property
+    def plugins(self):
+        return self._pytester.plugins
+
+    @plugins.setter
+    def plugins(self, plugins):
+        self._pytester.plugins = plugins
+
+    @property
+    def monkeypatch(self) -> MonkeyPatch:
+        return self._pytester._monkeypatch
+
+    def make_hook_recorder(self, pluginmanager) -> HookRecorder:
+        """See :meth:`Pytester.make_hook_recorder`."""
+        return self._pytester.make_hook_recorder(pluginmanager)
+
+    def chdir(self) -> None:
+        """See :meth:`Pytester.chdir`."""
+        return self._pytester.chdir()
+
+    def finalize(self) -> None:
+        """See :meth:`Pytester._finalize`."""
+        return self._pytester._finalize()
+
+    def makefile(self, ext, *args, **kwargs) -> LEGACY_PATH:
+        """See :meth:`Pytester.makefile`."""
+        if ext and not ext.startswith("."):
+            # pytester.makefile is going to throw a ValueError in a way that
+            # testdir.makefile did not, because
+            # pathlib.Path is stricter suffixes than py.path
+            # This ext arguments is likely user error, but since testdir has
+            # allowed this, we will prepend "." as a workaround to avoid breaking
+            # testdir usage that worked before
+            ext = "." + ext
+        return legacy_path(self._pytester.makefile(ext, *args, **kwargs))
+
+    def makeconftest(self, source) -> LEGACY_PATH:
+        """See :meth:`Pytester.makeconftest`."""
+        return legacy_path(self._pytester.makeconftest(source))
+
+    def makeini(self, source) -> LEGACY_PATH:
+        """See :meth:`Pytester.makeini`."""
+        return legacy_path(self._pytester.makeini(source))
+
+    def getinicfg(self, source: str) -> SectionWrapper:
+        """See :meth:`Pytester.getinicfg`."""
+        return self._pytester.getinicfg(source)
+
+    def makepyprojecttoml(self, source) -> LEGACY_PATH:
+        """See :meth:`Pytester.makepyprojecttoml`."""
+        return legacy_path(self._pytester.makepyprojecttoml(source))
+
+    def makepyfile(self, *args, **kwargs) -> LEGACY_PATH:
+        """See :meth:`Pytester.makepyfile`."""
+        return legacy_path(self._pytester.makepyfile(*args, **kwargs))
+
+    def maketxtfile(self, *args, **kwargs) -> LEGACY_PATH:
+        """See :meth:`Pytester.maketxtfile`."""
+        return legacy_path(self._pytester.maketxtfile(*args, **kwargs))
+
+    def syspathinsert(self, path=None) -> None:
+        """See :meth:`Pytester.syspathinsert`."""
+        return self._pytester.syspathinsert(path)
+
+    def mkdir(self, name) -> LEGACY_PATH:
+        """See :meth:`Pytester.mkdir`."""
+        return legacy_path(self._pytester.mkdir(name))
+
+    def mkpydir(self, name) -> LEGACY_PATH:
+        """See :meth:`Pytester.mkpydir`."""
+        return legacy_path(self._pytester.mkpydir(name))
+
+    def copy_example(self, name=None) -> LEGACY_PATH:
+        """See :meth:`Pytester.copy_example`."""
+        return legacy_path(self._pytester.copy_example(name))
+
+    def getnode(self, config: Config, arg) -> Optional[Union[Item, Collector]]:
+        """See :meth:`Pytester.getnode`."""
+        return self._pytester.getnode(config, arg)
+
+    def getpathnode(self, path):
+        """See :meth:`Pytester.getpathnode`."""
+        return self._pytester.getpathnode(path)
+
+    def genitems(self, colitems: List[Union[Item, Collector]]) -> List[Item]:
+        """See :meth:`Pytester.genitems`."""
+        return self._pytester.genitems(colitems)
+
+    def runitem(self, source):
+        """See :meth:`Pytester.runitem`."""
+        return self._pytester.runitem(source)
+
+    def inline_runsource(self, source, *cmdlineargs):
+        """See :meth:`Pytester.inline_runsource`."""
+        return self._pytester.inline_runsource(source, *cmdlineargs)
+
+    def inline_genitems(self, *args):
+        """See :meth:`Pytester.inline_genitems`."""
+        return self._pytester.inline_genitems(*args)
+
+    def inline_run(self, *args, plugins=(), no_reraise_ctrlc: bool = False):
+        """See :meth:`Pytester.inline_run`."""
+        return self._pytester.inline_run(
+            *args, plugins=plugins, no_reraise_ctrlc=no_reraise_ctrlc
+        )
+
+    def runpytest_inprocess(self, *args, **kwargs) -> RunResult:
+        """See :meth:`Pytester.runpytest_inprocess`."""
+        return self._pytester.runpytest_inprocess(*args, **kwargs)
+
+    def runpytest(self, *args, **kwargs) -> RunResult:
+        """See :meth:`Pytester.runpytest`."""
+        return self._pytester.runpytest(*args, **kwargs)
+
+    def parseconfig(self, *args) -> Config:
+        """See :meth:`Pytester.parseconfig`."""
+        return self._pytester.parseconfig(*args)
+
+    def parseconfigure(self, *args) -> Config:
+        """See :meth:`Pytester.parseconfigure`."""
+        return self._pytester.parseconfigure(*args)
+
+    def getitem(self, source, funcname="test_func"):
+        """See :meth:`Pytester.getitem`."""
+        return self._pytester.getitem(source, funcname)
+
+    def getitems(self, source):
+        """See :meth:`Pytester.getitems`."""
+        return self._pytester.getitems(source)
+
+    def getmodulecol(self, source, configargs=(), withinit=False):
+        """See :meth:`Pytester.getmodulecol`."""
+        return self._pytester.getmodulecol(
+            source, configargs=configargs, withinit=withinit
+        )
+
+    def collect_by_name(
+        self, modcol: Collector, name: str
+    ) -> Optional[Union[Item, Collector]]:
+        """See :meth:`Pytester.collect_by_name`."""
+        return self._pytester.collect_by_name(modcol, name)
+
+    def popen(
+        self,
+        cmdargs,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.PIPE,
+        stdin=CLOSE_STDIN,
+        **kw,
+    ):
+        """See :meth:`Pytester.popen`."""
+        return self._pytester.popen(cmdargs, stdout, stderr, stdin, **kw)
+
+    def run(self, *cmdargs, timeout=None, stdin=CLOSE_STDIN) -> RunResult:
+        """See :meth:`Pytester.run`."""
+        return self._pytester.run(*cmdargs, timeout=timeout, stdin=stdin)
+
+    def runpython(self, script) -> RunResult:
+        """See :meth:`Pytester.runpython`."""
+        return self._pytester.runpython(script)
+
+    def runpython_c(self, command):
+        """See :meth:`Pytester.runpython_c`."""
+        return self._pytester.runpython_c(command)
+
+    def runpytest_subprocess(self, *args, timeout=None) -> RunResult:
+        """See :meth:`Pytester.runpytest_subprocess`."""
+        return self._pytester.runpytest_subprocess(*args, timeout=timeout)
+
+    def spawn_pytest(
+        self, string: str, expect_timeout: float = 10.0
+    ) -> "pexpect.spawn":
+        """See :meth:`Pytester.spawn_pytest`."""
+        return self._pytester.spawn_pytest(string, expect_timeout=expect_timeout)
+
+    def spawn(self, cmd: str, expect_timeout: float = 10.0) -> "pexpect.spawn":
+        """See :meth:`Pytester.spawn`."""
+        return self._pytester.spawn(cmd, expect_timeout=expect_timeout)
+
+    def __repr__(self) -> str:
+        return f"<Testdir {self.tmpdir!r}>"
+
+    def __str__(self) -> str:
+        return str(self.tmpdir)
+
+
+class LegacyTestdirPlugin:
+    @staticmethod
+    @fixture
+    def testdir(pytester: Pytester) -> Testdir:
+        """
+        Identical to :fixture:`pytester`, and provides an instance whose methods return
+        legacy ``LEGACY_PATH`` objects instead when applicable.
+
+        New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
+        """
+        return Testdir(pytester, _ispytest=True)
+
+
+@final
+@dataclasses.dataclass
+class TempdirFactory:
+    """Backward compatibility wrapper that implements :class:`py.path.local`
+    for :class:`TempPathFactory`.
+
+    .. note::
+        These days, it is preferred to use ``tmp_path_factory``.
+
+        :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.
+
+    """
+
+    _tmppath_factory: TempPathFactory
+
+    def __init__(
+        self, tmppath_factory: TempPathFactory, *, _ispytest: bool = False
+    ) -> None:
+        check_ispytest(_ispytest)
+        self._tmppath_factory = tmppath_factory
+
+    def mktemp(self, basename: str, numbered: bool = True) -> LEGACY_PATH:
+        """Same as :meth:`TempPathFactory.mktemp`, but returns a :class:`py.path.local` object."""
+        return legacy_path(self._tmppath_factory.mktemp(basename, numbered).resolve())
+
+    def getbasetemp(self) -> LEGACY_PATH:
+        """Same as :meth:`TempPathFactory.getbasetemp`, but returns a :class:`py.path.local` object."""
+        return legacy_path(self._tmppath_factory.getbasetemp().resolve())
+
+
+class LegacyTmpdirPlugin:
+    @staticmethod
+    @fixture(scope="session")
+    def tmpdir_factory(request: FixtureRequest) -> TempdirFactory:
+        """Return a :class:`pytest.TempdirFactory` instance for the test session."""
+        # Set dynamically by pytest_configure().
+        return request.config._tmpdirhandler  # type: ignore
+
+    @staticmethod
+    @fixture
+    def tmpdir(tmp_path: Path) -> LEGACY_PATH:
+        """Return a temporary directory path object which is unique to each test
+        function invocation, created as a sub directory of the base temporary
+        directory.
+
+        By default, a new base temporary directory is created each test session,
+        and old bases are removed after 3 sessions, to aid in debugging. If
+        ``--basetemp`` is used then it is cleared each session. See :ref:`base
+        temporary directory`.
+
+        The returned object is a `legacy_path`_ object.
+
+        .. note::
+            These days, it is preferred to use ``tmp_path``.
+
+            :ref:`About the tmpdir and tmpdir_factory fixtures<tmpdir and tmpdir_factory>`.
+
+        .. _legacy_path: https://py.readthedocs.io/en/latest/path.html
+        """
+        return legacy_path(tmp_path)
+
+
+def Cache_makedir(self: Cache, name: str) -> LEGACY_PATH:
+    """Return a directory path object with the given name.
+
+    Same as :func:`mkdir`, but returns a legacy py path instance.
+    """
+    return legacy_path(self.mkdir(name))
+
+
+def FixtureRequest_fspath(self: FixtureRequest) -> LEGACY_PATH:
+    """(deprecated) The file system path of the test module which collected this test."""
+    return legacy_path(self.path)
+
+
+def TerminalReporter_startdir(self: TerminalReporter) -> LEGACY_PATH:
+    """The directory from which pytest was invoked.
+
+    Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
+
+    :type: LEGACY_PATH
+    """
+    return legacy_path(self.startpath)
+
+
+def Config_invocation_dir(self: Config) -> LEGACY_PATH:
+    """The directory from which pytest was invoked.
+
+    Prefer to use :attr:`invocation_params.dir <InvocationParams.dir>`,
+    which is a :class:`pathlib.Path`.
+
+    :type: LEGACY_PATH
+    """
+    return legacy_path(str(self.invocation_params.dir))
+
+
+def Config_rootdir(self: Config) -> LEGACY_PATH:
+    """The path to the :ref:`rootdir <rootdir>`.
+
+    Prefer to use :attr:`rootpath`, which is a :class:`pathlib.Path`.
+
+    :type: LEGACY_PATH
+    """
+    return legacy_path(str(self.rootpath))
+
+
+def Config_inifile(self: Config) -> Optional[LEGACY_PATH]:
+    """The path to the :ref:`configfile <configfiles>`.
+
+    Prefer to use :attr:`inipath`, which is a :class:`pathlib.Path`.
+
+    :type: Optional[LEGACY_PATH]
+    """
+    return legacy_path(str(self.inipath)) if self.inipath else None
+
+
+def Session_stardir(self: Session) -> LEGACY_PATH:
+    """The path from which pytest was invoked.
+
+    Prefer to use ``startpath`` which is a :class:`pathlib.Path`.
+
+    :type: LEGACY_PATH
+    """
+    return legacy_path(self.startpath)
+
+
+def Config__getini_unknown_type(
+    self, name: str, type: str, value: Union[str, List[str]]
+):
+    if type == "pathlist":
+        # TODO: This assert is probably not valid in all cases.
+        assert self.inipath is not None
+        dp = self.inipath.parent
+        input_values = shlex.split(value) if isinstance(value, str) else value
+        return [legacy_path(str(dp / x)) for x in input_values]
+    else:
+        raise ValueError(f"unknown configuration type: {type}", value)
+
+
+def Node_fspath(self: Node) -> LEGACY_PATH:
+    """(deprecated) returns a legacy_path copy of self.path"""
+    return legacy_path(self.path)
+
+
+def Node_fspath_set(self: Node, value: LEGACY_PATH) -> None:
+    self.path = Path(value)
+
+
+@hookimpl(tryfirst=True)
+def pytest_load_initial_conftests(early_config: Config) -> None:
+    """Monkeypatch legacy path attributes in several classes, as early as possible."""
+    mp = MonkeyPatch()
+    early_config.add_cleanup(mp.undo)
+
+    # Add Cache.makedir().
+    mp.setattr(Cache, "makedir", Cache_makedir, raising=False)
+
+    # Add FixtureRequest.fspath property.
+    mp.setattr(FixtureRequest, "fspath", property(FixtureRequest_fspath), raising=False)
+
+    # Add TerminalReporter.startdir property.
+    mp.setattr(
+        TerminalReporter, "startdir", property(TerminalReporter_startdir), raising=False
+    )
+
+    # Add Config.{invocation_dir,rootdir,inifile} properties.
+    mp.setattr(Config, "invocation_dir", property(Config_invocation_dir), raising=False)
+    mp.setattr(Config, "rootdir", property(Config_rootdir), raising=False)
+    mp.setattr(Config, "inifile", property(Config_inifile), raising=False)
+
+    # Add Session.startdir property.
+    mp.setattr(Session, "startdir", property(Session_stardir), raising=False)
+
+    # Add pathlist configuration type.
+    mp.setattr(Config, "_getini_unknown_type", Config__getini_unknown_type)
+
+    # Add Node.fspath property.
+    mp.setattr(Node, "fspath", property(Node_fspath, Node_fspath_set), raising=False)
+
+
+@hookimpl
+def pytest_configure(config: Config) -> None:
+    """Installs the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed."""
+    if config.pluginmanager.has_plugin("tmpdir"):
+        mp = MonkeyPatch()
+        config.add_cleanup(mp.undo)
+        # Create TmpdirFactory and attach it to the config object.
+        #
+        # This is to comply with existing plugins which expect the handler to be
+        # available at pytest_configure time, but ideally should be moved entirely
+        # to the tmpdir_factory session fixture.
+        try:
+            tmp_path_factory = config._tmp_path_factory  # type: ignore[attr-defined]
+        except AttributeError:
+            # tmpdir plugin is blocked.
+            pass
+        else:
+            _tmpdirhandler = TempdirFactory(tmp_path_factory, _ispytest=True)
+            mp.setattr(config, "_tmpdirhandler", _tmpdirhandler, raising=False)
+
+        config.pluginmanager.register(LegacyTmpdirPlugin, "legacypath-tmpdir")
+
+
+@hookimpl
+def pytest_plugin_registered(plugin: object, manager: PytestPluginManager) -> None:
+    # pytester is not loaded by default and is commonly loaded from a conftest,
+    # so checking for it in `pytest_configure` is not enough.
+    is_pytester = plugin is manager.get_plugin("pytester")
+    if is_pytester and not manager.is_registered(LegacyTestdirPlugin):
+        manager.register(LegacyTestdirPlugin, "legacypath-pytester")
index 2e4847328abf9d9cc0179c32ef1e1e4e83b35c52..9f2f1c793593ec45a2aa2638ac343da369383f02 100644 (file)
@@ -1,10 +1,15 @@
 """Access and control log capturing."""
+import io
 import logging
 import os
 import re
-import sys
 from contextlib import contextmanager
+from contextlib import nullcontext
+from datetime import datetime
+from datetime import timedelta
+from datetime import timezone
 from io import StringIO
+from logging import LogRecord
 from pathlib import Path
 from typing import AbstractSet
 from typing import Dict
@@ -13,6 +18,7 @@ from typing import List
 from typing import Mapping
 from typing import Optional
 from typing import Tuple
+from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
 
@@ -20,7 +26,6 @@ from _pytest import nodes
 from _pytest._io import TerminalWriter
 from _pytest.capture import CaptureManager
 from _pytest.compat import final
-from _pytest.compat import nullcontext
 from _pytest.config import _strtobool
 from _pytest.config import Config
 from _pytest.config import create_terminal_writer
@@ -31,22 +36,46 @@ from _pytest.deprecated import check_ispytest
 from _pytest.fixtures import fixture
 from _pytest.fixtures import FixtureRequest
 from _pytest.main import Session
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 from _pytest.terminal import TerminalReporter
 
+if TYPE_CHECKING:
+    logging_StreamHandler = logging.StreamHandler[StringIO]
+
+    from typing_extensions import Literal
+else:
+    logging_StreamHandler = logging.StreamHandler
 
 DEFAULT_LOG_FORMAT = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s"
 DEFAULT_LOG_DATE_FORMAT = "%H:%M:%S"
 _ANSI_ESCAPE_SEQ = re.compile(r"\x1b\[[\d;]+m")
-caplog_handler_key = StoreKey["LogCaptureHandler"]()
-caplog_records_key = StoreKey[Dict[str, List[logging.LogRecord]]]()
+caplog_handler_key = StashKey["LogCaptureHandler"]()
+caplog_records_key = StashKey[Dict[str, List[logging.LogRecord]]]()
 
 
 def _remove_ansi_escape_sequences(text: str) -> str:
     return _ANSI_ESCAPE_SEQ.sub("", text)
 
 
-class ColoredLevelFormatter(logging.Formatter):
+class DatetimeFormatter(logging.Formatter):
+    """A logging formatter which formats record with
+    :func:`datetime.datetime.strftime` formatter instead of
+    :func:`time.strftime` in case of microseconds in format string.
+    """
+
+    def formatTime(self, record: LogRecord, datefmt=None) -> str:
+        if datefmt and "%f" in datefmt:
+            ct = self.converter(record.created)
+            tz = timezone(timedelta(seconds=ct.tm_gmtoff), ct.tm_zone)
+            # Construct `datetime.datetime` object from `struct_time`
+            # and msecs information from `record`
+            dt = datetime(*ct[0:6], microsecond=round(record.msecs * 1000), tzinfo=tz)
+            return dt.strftime(datefmt)
+        # Use `logging.Formatter` for non-microsecond formats
+        return super().formatTime(record, datefmt)
+
+
+class ColoredLevelFormatter(DatetimeFormatter):
     """A logging formatter which colorizes the %(levelname)..s part of the
     log format passed to __init__."""
 
@@ -59,32 +88,47 @@ class ColoredLevelFormatter(logging.Formatter):
         logging.DEBUG: {"purple"},
         logging.NOTSET: set(),
     }
-    LEVELNAME_FMT_REGEX = re.compile(r"%\(levelname\)([+-.]?\d*s)")
+    LEVELNAME_FMT_REGEX = re.compile(r"%\(levelname\)([+-.]?\d*(?:\.\d+)?s)")
 
     def __init__(self, terminalwriter: TerminalWriter, *args, **kwargs) -> None:
         super().__init__(*args, **kwargs)
+        self._terminalwriter = terminalwriter
         self._original_fmt = self._style._fmt
         self._level_to_fmt_mapping: Dict[int, str] = {}
 
+        for level, color_opts in self.LOGLEVEL_COLOROPTS.items():
+            self.add_color_level(level, *color_opts)
+
+    def add_color_level(self, level: int, *color_opts: str) -> None:
+        """Add or update color opts for a log level.
+
+        :param level:
+            Log level to apply a style to, e.g. ``logging.INFO``.
+        :param color_opts:
+            ANSI escape sequence color options. Capitalized colors indicates
+            background color, i.e. ``'green', 'Yellow', 'bold'`` will give bold
+            green text on yellow background.
+
+        .. warning::
+            This is an experimental API.
+        """
+
         assert self._fmt is not None
         levelname_fmt_match = self.LEVELNAME_FMT_REGEX.search(self._fmt)
         if not levelname_fmt_match:
             return
         levelname_fmt = levelname_fmt_match.group()
 
-        for level, color_opts in self.LOGLEVEL_COLOROPTS.items():
-            formatted_levelname = levelname_fmt % {
-                "levelname": logging.getLevelName(level)
-            }
-
-            # add ANSI escape sequences around the formatted levelname
-            color_kwargs = {name: True for name in color_opts}
-            colorized_formatted_levelname = terminalwriter.markup(
-                formatted_levelname, **color_kwargs
-            )
-            self._level_to_fmt_mapping[level] = self.LEVELNAME_FMT_REGEX.sub(
-                colorized_formatted_levelname, self._fmt
-            )
+        formatted_levelname = levelname_fmt % {"levelname": logging.getLevelName(level)}
+
+        # add ANSI escape sequences around the formatted levelname
+        color_kwargs = {name: True for name in color_opts}
+        colorized_formatted_levelname = self._terminalwriter.markup(
+            formatted_levelname, **color_kwargs
+        )
+        self._level_to_fmt_mapping[level] = self.LEVELNAME_FMT_REGEX.sub(
+            colorized_formatted_levelname, self._fmt
+        )
 
     def format(self, record: logging.LogRecord) -> str:
         fmt = self._level_to_fmt_mapping.get(record.levelno, self._original_fmt)
@@ -103,14 +147,6 @@ class PercentStyleMultiline(logging.PercentStyle):
         super().__init__(fmt)
         self._auto_indent = self._get_auto_indent(auto_indent)
 
-    @staticmethod
-    def _update_message(
-        record_dict: Dict[str, object], message: str
-    ) -> Dict[str, object]:
-        tmp = record_dict.copy()
-        tmp["message"] = message
-        return tmp
-
     @staticmethod
     def _get_auto_indent(auto_indent_option: Union[int, str, bool, None]) -> int:
         """Determine the current auto indentation setting.
@@ -176,7 +212,7 @@ class PercentStyleMultiline(logging.PercentStyle):
 
             if auto_indent:
                 lines = record.message.splitlines()
-                formatted = self._fmt % self._update_message(record.__dict__, lines[0])
+                formatted = self._fmt % {**record.__dict__, "message": lines[0]}
 
                 if auto_indent < 0:
                     indentation = _remove_ansi_escape_sequences(formatted).find(
@@ -205,7 +241,7 @@ def pytest_addoption(parser: Parser) -> None:
 
     def add_option_ini(option, dest, default=None, type=None, **kwargs):
         parser.addini(
-            dest, default=default, type=type, help="default value for " + option
+            dest, default=default, type=type, help="Default value for " + option
         )
         group.addoption(option, dest=dest, **kwargs)
 
@@ -215,8 +251,8 @@ def pytest_addoption(parser: Parser) -> None:
         default=None,
         metavar="LEVEL",
         help=(
-            "level of messages to catch/display.\n"
-            "Not set by default, so it depends on the root/parent log handler's"
+            "Level of messages to catch/display."
+            " Not set by default, so it depends on the root/parent log handler's"
             ' effective level, where it is "WARNING" by default.'
         ),
     )
@@ -224,58 +260,58 @@ def pytest_addoption(parser: Parser) -> None:
         "--log-format",
         dest="log_format",
         default=DEFAULT_LOG_FORMAT,
-        help="log format as used by the logging module.",
+        help="Log format used by the logging module",
     )
     add_option_ini(
         "--log-date-format",
         dest="log_date_format",
         default=DEFAULT_LOG_DATE_FORMAT,
-        help="log date format as used by the logging module.",
+        help="Log date format used by the logging module",
     )
     parser.addini(
         "log_cli",
         default=False,
         type="bool",
-        help='enable log display during test run (also known as "live logging").',
+        help='Enable log display during test run (also known as "live logging")',
     )
     add_option_ini(
-        "--log-cli-level", dest="log_cli_level", default=None, help="cli logging level."
+        "--log-cli-level", dest="log_cli_level", default=None, help="CLI logging level"
     )
     add_option_ini(
         "--log-cli-format",
         dest="log_cli_format",
         default=None,
-        help="log format as used by the logging module.",
+        help="Log format used by the logging module",
     )
     add_option_ini(
         "--log-cli-date-format",
         dest="log_cli_date_format",
         default=None,
-        help="log date format as used by the logging module.",
+        help="Log date format used by the logging module",
     )
     add_option_ini(
         "--log-file",
         dest="log_file",
         default=None,
-        help="path to a file when logging will be written to.",
+        help="Path to a file when logging will be written to",
     )
     add_option_ini(
         "--log-file-level",
         dest="log_file_level",
         default=None,
-        help="log file logging level.",
+        help="Log file logging level",
     )
     add_option_ini(
         "--log-file-format",
         dest="log_file_format",
         default=DEFAULT_LOG_FORMAT,
-        help="log format as used by the logging module.",
+        help="Log format used by the logging module",
     )
     add_option_ini(
         "--log-file-date-format",
         dest="log_file_date_format",
         default=DEFAULT_LOG_DATE_FORMAT,
-        help="log date format as used by the logging module.",
+        help="Log date format used by the logging module",
     )
     add_option_ini(
         "--log-auto-indent",
@@ -283,6 +319,13 @@ def pytest_addoption(parser: Parser) -> None:
         default=None,
         help="Auto-indent multiline messages passed to the logging module. Accepts true|on, false|off or an integer.",
     )
+    group.addoption(
+        "--log-disable",
+        action="append",
+        default=[],
+        dest="logger_disable",
+        help="Disable a logger by name. Can be passed multiple times.",
+    )
 
 
 _HandlerType = TypeVar("_HandlerType", bound=logging.Handler)
@@ -315,11 +358,9 @@ class catching_logs:
         root_logger.removeHandler(self.handler)
 
 
-class LogCaptureHandler(logging.StreamHandler):
+class LogCaptureHandler(logging_StreamHandler):
     """A logging handler that stores log records and the log text."""
 
-    stream: StringIO
-
     def __init__(self) -> None:
         """Create a new log handler."""
         super().__init__(StringIO())
@@ -334,6 +375,10 @@ class LogCaptureHandler(logging.StreamHandler):
         self.records = []
         self.stream = StringIO()
 
+    def clear(self) -> None:
+        self.records.clear()
+        self.stream = StringIO()
+
     def handleError(self, record: logging.LogRecord) -> None:
         if logging.raiseExceptions:
             # Fail the test if the log message is bad (emit failed).
@@ -353,11 +398,12 @@ class LogCaptureFixture:
         self._initial_handler_level: Optional[int] = None
         # Dict of log name -> log level.
         self._initial_logger_levels: Dict[Optional[str], int] = {}
+        self._initial_disabled_logging_level: Optional[int] = None
 
     def _finalize(self) -> None:
         """Finalize the fixture.
 
-        This restores the log levels changed by :meth:`set_level`.
+        This restores the log levels and the disabled logging levels changed by :meth:`set_level`.
         """
         # Restore log levels.
         if self._initial_handler_level is not None:
@@ -365,27 +411,30 @@ class LogCaptureFixture:
         for logger_name, level in self._initial_logger_levels.items():
             logger = logging.getLogger(logger_name)
             logger.setLevel(level)
+        # Disable logging at the original disabled logging level.
+        if self._initial_disabled_logging_level is not None:
+            logging.disable(self._initial_disabled_logging_level)
+            self._initial_disabled_logging_level = None
 
     @property
     def handler(self) -> LogCaptureHandler:
-        """Get the logging handler used by the fixture.
+        """Get the logging handler used by the fixture."""
+        return self._item.stash[caplog_handler_key]
 
-        :rtype: LogCaptureHandler
-        """
-        return self._item._store[caplog_handler_key]
-
-    def get_records(self, when: str) -> List[logging.LogRecord]:
+    def get_records(
+        self, when: "Literal['setup', 'call', 'teardown']"
+    ) -> List[logging.LogRecord]:
         """Get the logging records for one of the possible test phases.
 
-        :param str when:
-            Which test phase to obtain the records from. Valid values are: "setup", "call" and "teardown".
+        :param when:
+            Which test phase to obtain the records from.
+            Valid values are: "setup", "call" and "teardown".
 
         :returns: The list of captured records at the given stage.
-        :rtype: List[logging.LogRecord]
 
         .. versionadded:: 3.4
         """
-        return self._item._store[caplog_records_key].get(when, [])
+        return self._item.stash[caplog_records_key].get(when, [])
 
     @property
     def text(self) -> str:
@@ -429,17 +478,55 @@ class LogCaptureFixture:
 
     def clear(self) -> None:
         """Reset the list of log records and the captured log text."""
-        self.handler.reset()
+        self.handler.clear()
+
+    def _force_enable_logging(
+        self, level: Union[int, str], logger_obj: logging.Logger
+    ) -> int:
+        """Enable the desired logging level if the global level was disabled via ``logging.disabled``.
+
+        Only enables logging levels greater than or equal to the requested ``level``.
+
+        Does nothing if the desired ``level`` wasn't disabled.
+
+        :param level:
+            The logger level caplog should capture.
+            All logging is enabled if a non-standard logging level string is supplied.
+            Valid level strings are in :data:`logging._nameToLevel`.
+        :param logger_obj: The logger object to check.
+
+        :return: The original disabled logging level.
+        """
+        original_disable_level: int = logger_obj.manager.disable  # type: ignore[attr-defined]
+
+        if isinstance(level, str):
+            # Try to translate the level string to an int for `logging.disable()`
+            level = logging.getLevelName(level)
+
+        if not isinstance(level, int):
+            # The level provided was not valid, so just un-disable all logging.
+            logging.disable(logging.NOTSET)
+        elif not logger_obj.isEnabledFor(level):
+            # Each level is `10` away from other levels.
+            # https://docs.python.org/3/library/logging.html#logging-levels
+            disable_level = max(level - 10, logging.NOTSET)
+            logging.disable(disable_level)
+
+        return original_disable_level
 
     def set_level(self, level: Union[int, str], logger: Optional[str] = None) -> None:
-        """Set the level of a logger for the duration of a test.
+        """Set the threshold level of a logger for the duration of a test.
+
+        Logging messages which are less severe than this level will not be captured.
 
         .. versionchanged:: 3.4
             The levels of the loggers changed by this function will be
             restored to their initial values at the end of the test.
 
-        :param int level: The level.
-        :param str logger: The logger to update. If not given, the root logger.
+        Will enable the requested logging level if it was disabled via :meth:`logging.disable`.
+
+        :param level: The level.
+        :param logger: The logger to update. If not given, the root logger.
         """
         logger_obj = logging.getLogger(logger)
         # Save the original log-level to restore it during teardown.
@@ -448,28 +535,35 @@ class LogCaptureFixture:
         if self._initial_handler_level is None:
             self._initial_handler_level = self.handler.level
         self.handler.setLevel(level)
+        initial_disabled_logging_level = self._force_enable_logging(level, logger_obj)
+        if self._initial_disabled_logging_level is None:
+            self._initial_disabled_logging_level = initial_disabled_logging_level
 
     @contextmanager
     def at_level(
-        self, level: int, logger: Optional[str] = None
+        self, level: Union[int, str], logger: Optional[str] = None
     ) -> Generator[None, None, None]:
         """Context manager that sets the level for capturing of logs. After
         the end of the 'with' statement the level is restored to its original
         value.
 
-        :param int level: The level.
-        :param str logger: The logger to update. If not given, the root logger.
+        Will enable the requested logging level if it was disabled via :meth:`logging.disable`.
+
+        :param level: The level.
+        :param logger: The logger to update. If not given, the root logger.
         """
         logger_obj = logging.getLogger(logger)
         orig_level = logger_obj.level
         logger_obj.setLevel(level)
         handler_orig_level = self.handler.level
         self.handler.setLevel(level)
+        original_disable_level = self._force_enable_logging(level, logger_obj)
         try:
             yield
         finally:
             logger_obj.setLevel(orig_level)
             self.handler.setLevel(handler_orig_level)
+            logging.disable(original_disable_level)
 
 
 @fixture
@@ -555,7 +649,7 @@ class LoggingPlugin:
             config, "log_file_date_format", "log_date_format"
         )
 
-        log_file_formatter = logging.Formatter(
+        log_file_formatter = DatetimeFormatter(
             log_file_format, datefmt=log_file_date_format
         )
         self.log_file_handler.setFormatter(log_file_formatter)
@@ -566,6 +660,8 @@ class LoggingPlugin:
         )
         if self._log_cli_enabled():
             terminal_reporter = config.pluginmanager.get_plugin("terminalreporter")
+            # Guaranteed by `_log_cli_enabled()`.
+            assert terminal_reporter is not None
             capture_manager = config.pluginmanager.get_plugin("capturemanager")
             # if capturemanager plugin is disabled, live logging still works.
             self.log_cli_handler: Union[
@@ -579,6 +675,15 @@ class LoggingPlugin:
             get_option_ini(config, "log_auto_indent"),
         )
         self.log_cli_handler.setFormatter(log_cli_formatter)
+        self._disable_loggers(loggers_to_disable=config.option.logger_disable)
+
+    def _disable_loggers(self, loggers_to_disable: List[str]) -> None:
+        if not loggers_to_disable:
+            return
+
+        for name in loggers_to_disable:
+            logger = logging.getLogger(name)
+            logger.disabled = True
 
     def _create_formatter(self, log_format, log_date_format, auto_indent):
         # Color option doesn't exist if terminal plugin is disabled.
@@ -590,7 +695,7 @@ class LoggingPlugin:
                 create_terminal_writer(self._config), log_format, log_date_format
             )
         else:
-            formatter = logging.Formatter(log_format, log_date_format)
+            formatter = DatetimeFormatter(log_format, log_date_format)
 
         formatter._style = PercentStyleMultiline(
             formatter._style._fmt, auto_indent=auto_indent
@@ -614,17 +719,9 @@ class LoggingPlugin:
         if not fpath.parent.exists():
             fpath.parent.mkdir(exist_ok=True, parents=True)
 
-        stream = fpath.open(mode="w", encoding="UTF-8")
-        if sys.version_info >= (3, 7):
-            old_stream = self.log_file_handler.setStream(stream)
-        else:
-            old_stream = self.log_file_handler.stream
-            self.log_file_handler.acquire()
-            try:
-                self.log_file_handler.flush()
-                self.log_file_handler.stream = stream
-            finally:
-                self.log_file_handler.release()
+        # https://github.com/python/mypy/issues/11193
+        stream: io.TextIOWrapper = fpath.open(mode="w", encoding="UTF-8")  # type: ignore[assignment]
+        old_stream = self.log_file_handler.setStream(stream)
         if old_stream:
             old_stream.close()
 
@@ -685,14 +782,16 @@ class LoggingPlugin:
     def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, None]:
         """Implement the internals of the pytest_runtest_xxx() hooks."""
         with catching_logs(
-            self.caplog_handler, level=self.log_level,
+            self.caplog_handler,
+            level=self.log_level,
         ) as caplog_handler, catching_logs(
-            self.report_handler, level=self.log_level,
+            self.report_handler,
+            level=self.log_level,
         ) as report_handler:
             caplog_handler.reset()
             report_handler.reset()
-            item._store[caplog_records_key][when] = caplog_handler.records
-            item._store[caplog_handler_key] = caplog_handler
+            item.stash[caplog_records_key][when] = caplog_handler.records
+            item.stash[caplog_handler_key] = caplog_handler
 
             yield
 
@@ -704,7 +803,7 @@ class LoggingPlugin:
         self.log_cli_handler.set_when("setup")
 
         empty: Dict[str, List[logging.LogRecord]] = {}
-        item._store[caplog_records_key] = empty
+        item.stash[caplog_records_key] = empty
         yield from self._runtest_for(item, "setup")
 
     @hookimpl(hookwrapper=True)
@@ -718,8 +817,8 @@ class LoggingPlugin:
         self.log_cli_handler.set_when("teardown")
 
         yield from self._runtest_for(item, "teardown")
-        del item._store[caplog_records_key]
-        del item._store[caplog_handler_key]
+        del item.stash[caplog_records_key]
+        del item.stash[caplog_handler_key]
 
     @hookimpl
     def pytest_runtest_logfinish(self) -> None:
@@ -748,7 +847,7 @@ class _FileHandler(logging.FileHandler):
         pass
 
 
-class _LiveLoggingStreamHandler(logging.StreamHandler):
+class _LiveLoggingStreamHandler(logging_StreamHandler):
     """A logging StreamHandler used by the live logging feature: it will
     write a newline before the first log message in each test.
 
@@ -766,7 +865,7 @@ class _LiveLoggingStreamHandler(logging.StreamHandler):
         terminal_reporter: TerminalReporter,
         capture_manager: Optional[CaptureManager],
     ) -> None:
-        logging.StreamHandler.__init__(self, stream=terminal_reporter)  # type: ignore[arg-type]
+        super().__init__(stream=terminal_reporter)  # type: ignore[arg-type]
         self.capture_manager = capture_manager
         self.reset()
         self.set_when(None)
index 41a33d4494c42fc6788d4270992cba2609072e28..ea89a63fa1be1f38e1f397e6f68566a155e0f7ad 100644 (file)
@@ -1,5 +1,6 @@
 """Core implementation of the testing process: init, session, runtest loop."""
 import argparse
+import dataclasses
 import fnmatch
 import functools
 import importlib
@@ -12,7 +13,6 @@ from typing import FrozenSet
 from typing import Iterator
 from typing import List
 from typing import Optional
-from typing import overload
 from typing import Sequence
 from typing import Set
 from typing import Tuple
@@ -20,12 +20,10 @@ from typing import Type
 from typing import TYPE_CHECKING
 from typing import Union
 
-import attr
-import py
-
 import _pytest._code
 from _pytest import nodes
 from _pytest.compat import final
+from _pytest.compat import overload
 from _pytest.config import Config
 from _pytest.config import directory_arg
 from _pytest.config import ExitCode
@@ -37,6 +35,8 @@ from _pytest.fixtures import FixtureManager
 from _pytest.outcomes import exit
 from _pytest.pathlib import absolutepath
 from _pytest.pathlib import bestrelpath
+from _pytest.pathlib import fnmatch_ex
+from _pytest.pathlib import safe_exists
 from _pytest.pathlib import visit
 from _pytest.reports import CollectReport
 from _pytest.reports import TestReport
@@ -51,7 +51,7 @@ if TYPE_CHECKING:
 def pytest_addoption(parser: Parser) -> None:
     parser.addini(
         "norecursedirs",
-        "directory patterns to avoid for recursion",
+        "Directory patterns to avoid for recursion",
         type="args",
         default=[
             "*.egg",
@@ -67,26 +67,26 @@ def pytest_addoption(parser: Parser) -> None:
     )
     parser.addini(
         "testpaths",
-        "directories to search for tests when no files or directories are given in the "
-        "command line.",
+        "Directories to search for tests when no files or directories are given on the "
+        "command line",
         type="args",
         default=[],
     )
-    group = parser.getgroup("general", "running and selection options")
+    group = parser.getgroup("general", "Running and selection options")
     group._addoption(
         "-x",
         "--exitfirst",
         action="store_const",
         dest="maxfail",
         const=1,
-        help="exit instantly on first error or failed test.",
+        help="Exit instantly on first error or failed test",
     )
     group = parser.getgroup("pytest-warnings")
     group.addoption(
         "-W",
         "--pythonwarnings",
         action="append",
-        help="set which warnings to report, see -W option of python itself.",
+        help="Set which warnings to report, see -W option of Python itself",
     )
     parser.addini(
         "filterwarnings",
@@ -102,35 +102,40 @@ def pytest_addoption(parser: Parser) -> None:
         type=int,
         dest="maxfail",
         default=0,
-        help="exit after first num failures or errors.",
+        help="Exit after first num failures or errors",
     )
     group._addoption(
         "--strict-config",
         action="store_true",
-        help="any warnings encountered while parsing the `pytest` section of the configuration file raise errors.",
+        help="Any warnings encountered while parsing the `pytest` section of the "
+        "configuration file raise errors",
     )
     group._addoption(
         "--strict-markers",
         action="store_true",
-        help="markers not registered in the `markers` section of the configuration file raise errors.",
+        help="Markers not registered in the `markers` section of the configuration "
+        "file raise errors",
     )
     group._addoption(
-        "--strict", action="store_true", help="(deprecated) alias to --strict-markers.",
+        "--strict",
+        action="store_true",
+        help="(Deprecated) alias to --strict-markers",
     )
     group._addoption(
         "-c",
-        metavar="file",
+        "--config-file",
+        metavar="FILE",
         type=str,
         dest="inifilename",
-        help="load configuration from `file` instead of trying to locate one of the implicit "
-        "configuration files.",
+        help="Load configuration from `FILE` instead of trying to locate one of the "
+        "implicit configuration files.",
     )
     group._addoption(
         "--continue-on-collection-errors",
         action="store_true",
         default=False,
         dest="continue_on_collection_errors",
-        help="Force test execution even if collection errors occur.",
+        help="Force test execution even if collection errors occur",
     )
     group._addoption(
         "--rootdir",
@@ -147,30 +152,30 @@ def pytest_addoption(parser: Parser) -> None:
         "--collect-only",
         "--co",
         action="store_true",
-        help="only collect tests, don't execute them.",
+        help="Only collect tests, don't execute them",
     )
     group.addoption(
         "--pyargs",
         action="store_true",
-        help="try to interpret all arguments as python packages.",
+        help="Try to interpret all arguments as Python packages",
     )
     group.addoption(
         "--ignore",
         action="append",
         metavar="path",
-        help="ignore path during collection (multi-allowed).",
+        help="Ignore path during collection (multi-allowed)",
     )
     group.addoption(
         "--ignore-glob",
         action="append",
         metavar="path",
-        help="ignore path pattern during collection (multi-allowed).",
+        help="Ignore path pattern during collection (multi-allowed)",
     )
     group.addoption(
         "--deselect",
         action="append",
         metavar="nodeid_prefix",
-        help="deselect item (via node id prefix) during collection (multi-allowed).",
+        help="Deselect item (via node id prefix) during collection (multi-allowed)",
     )
     group.addoption(
         "--confcutdir",
@@ -178,14 +183,14 @@ def pytest_addoption(parser: Parser) -> None:
         default=None,
         metavar="dir",
         type=functools.partial(directory_arg, optname="--confcutdir"),
-        help="only load conftest.py's relative to specified dir.",
+        help="Only load conftest.py's relative to specified dir",
     )
     group.addoption(
         "--noconftest",
         action="store_true",
         dest="noconftest",
         default=False,
-        help="Don't load any conftest.py files.",
+        help="Don't load any conftest.py files",
     )
     group.addoption(
         "--keepduplicates",
@@ -193,7 +198,7 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         dest="keepduplicates",
         default=False,
-        help="Keep duplicate tests.",
+        help="Keep duplicate tests",
     )
     group.addoption(
         "--collect-in-virtualenv",
@@ -207,8 +212,8 @@ def pytest_addoption(parser: Parser) -> None:
         default="prepend",
         choices=["prepend", "append", "importlib"],
         dest="importmode",
-        help="prepend/append to sys.path when importing test modules and conftest files, "
-        "default is to prepend.",
+        help="Prepend/append to sys.path when importing test modules and conftest "
+        "files. Default: prepend.",
     )
 
     group = parser.getgroup("debugconfig", "test session debugging and configuration")
@@ -219,8 +224,8 @@ def pytest_addoption(parser: Parser) -> None:
         type=validate_basetemp,
         metavar="dir",
         help=(
-            "base temporary directory for this test run."
-            "(warning: this directory is removed if it exists)"
+            "Base temporary directory for this test run. "
+            "(Warning: this directory is removed if it exists.)"
         ),
     )
 
@@ -237,10 +242,7 @@ def validate_basetemp(path: str) -> str:
         """Return whether query is an ancestor of base."""
         if base == query:
             return True
-        for parent in base.parents:
-            if parent == query:
-                return True
-        return False
+        return query in base.parents
 
     # check if path is an ancestor of cwd
     if is_ancestor(Path.cwd(), Path(path).absolute()):
@@ -290,7 +292,7 @@ def wrap_session(
             except exit.Exception as exc:
                 if exc.returncode is not None:
                     session.exitstatus = exc.returncode
-                sys.stderr.write("{}: {}\n".format(type(exc).__name__, exc))
+                sys.stderr.write(f"{type(exc).__name__}: {exc}\n")
             else:
                 if isinstance(excinfo.value, SystemExit):
                     sys.stderr.write("mainloop: caught unexpected SystemExit!\n")
@@ -298,7 +300,7 @@ def wrap_session(
     finally:
         # Explicitly break reference cycle.
         excinfo = None  # type: ignore
-        session.startdir.chdir()
+        os.chdir(session.startpath)
         if initstate >= 2:
             try:
                 config.hook.pytest_sessionfinish(
@@ -307,7 +309,7 @@ def wrap_session(
             except exit.Exception as exc:
                 if exc.returncode is not None:
                     session.exitstatus = exc.returncode
-                sys.stderr.write("{}: {}\n".format(type(exc).__name__, exc))
+                sys.stderr.write(f"{type(exc).__name__}: {exc}\n")
         config._ensure_unconfigure()
     return session.exitstatus
 
@@ -353,11 +355,14 @@ def pytest_runtestloop(session: "Session") -> bool:
     return True
 
 
-def _in_venv(path: py.path.local) -> bool:
+def _in_venv(path: Path) -> bool:
     """Attempt to detect if ``path`` is the root of a Virtual Environment by
     checking for the existence of the appropriate activate script."""
-    bindir = path.join("Scripts" if sys.platform.startswith("win") else "bin")
-    if not bindir.isdir():
+    bindir = path.joinpath("Scripts" if sys.platform.startswith("win") else "bin")
+    try:
+        if not bindir.is_dir():
+            return False
+    except OSError:
         return False
     activates = (
         "activate",
@@ -367,33 +372,41 @@ def _in_venv(path: py.path.local) -> bool:
         "Activate.bat",
         "Activate.ps1",
     )
-    return any([fname.basename in activates for fname in bindir.listdir()])
+    return any(fname.name in activates for fname in bindir.iterdir())
 
 
-def pytest_ignore_collect(path: py.path.local, config: Config) -> Optional[bool]:
-    ignore_paths = config._getconftest_pathlist("collect_ignore", path=path.dirpath())
+def pytest_ignore_collect(collection_path: Path, config: Config) -> Optional[bool]:
+    ignore_paths = config._getconftest_pathlist(
+        "collect_ignore", path=collection_path.parent, rootpath=config.rootpath
+    )
     ignore_paths = ignore_paths or []
     excludeopt = config.getoption("ignore")
     if excludeopt:
-        ignore_paths.extend([py.path.local(x) for x in excludeopt])
+        ignore_paths.extend(absolutepath(x) for x in excludeopt)
 
-    if py.path.local(path) in ignore_paths:
+    if collection_path in ignore_paths:
         return True
 
     ignore_globs = config._getconftest_pathlist(
-        "collect_ignore_glob", path=path.dirpath()
+        "collect_ignore_glob", path=collection_path.parent, rootpath=config.rootpath
     )
     ignore_globs = ignore_globs or []
     excludeglobopt = config.getoption("ignore_glob")
     if excludeglobopt:
-        ignore_globs.extend([py.path.local(x) for x in excludeglobopt])
+        ignore_globs.extend(absolutepath(x) for x in excludeglobopt)
 
-    if any(fnmatch.fnmatch(str(path), str(glob)) for glob in ignore_globs):
+    if any(fnmatch.fnmatch(str(collection_path), str(glob)) for glob in ignore_globs):
         return True
 
     allow_in_venv = config.getoption("collect_in_virtualenv")
-    if not allow_in_venv and _in_venv(path):
+    if not allow_in_venv and _in_venv(collection_path):
         return True
+
+    if collection_path.is_dir():
+        norecursepatterns = config.getini("norecursedirs")
+        if any(fnmatch_ex(pat, collection_path) for pat in norecursepatterns):
+            return True
+
     return None
 
 
@@ -436,9 +449,11 @@ class Failed(Exception):
     """Signals a stop as failed test run."""
 
 
-@attr.s
+@dataclasses.dataclass
 class _bestrelpath_cache(Dict[Path, str]):
-    path = attr.ib(type=Path)
+    __slots__ = ("path",)
+
+    path: Path
 
     def __missing__(self, path: Path) -> str:
         r = bestrelpath(self.path, path)
@@ -448,6 +463,11 @@ class _bestrelpath_cache(Dict[Path, str]):
 
 @final
 class Session(nodes.FSCollector):
+    """The root of the collection tree.
+
+    ``Session`` collects the initial paths given as arguments to pytest.
+    """
+
     Interrupted = Interrupted
     Failed = Failed
     # Set on the session by runner.pytest_sessionstart.
@@ -458,15 +478,19 @@ class Session(nodes.FSCollector):
 
     def __init__(self, config: Config) -> None:
         super().__init__(
-            config.rootdir, parent=None, config=config, session=self, nodeid=""
+            path=config.rootpath,
+            fspath=None,
+            parent=None,
+            config=config,
+            session=self,
+            nodeid="",
         )
         self.testsfailed = 0
         self.testscollected = 0
         self.shouldstop: Union[bool, str] = False
         self.shouldfail: Union[bool, str] = False
         self.trace = config.trace.root.get("collection")
-        self.startdir = config.invocation_dir
-        self._initialpaths: FrozenSet[py.path.local] = frozenset()
+        self._initialpaths: FrozenSet[Path] = frozenset()
 
         self._bestrelpathcache: Dict[Path, str] = _bestrelpath_cache(config.rootpath)
 
@@ -474,7 +498,7 @@ class Session(nodes.FSCollector):
 
     @classmethod
     def from_config(cls, config: Config) -> "Session":
-        session: Session = cls._create(config)
+        session: Session = cls._create(config=config)
         return session
 
     def __repr__(self) -> str:
@@ -486,6 +510,14 @@ class Session(nodes.FSCollector):
             self.testscollected,
         )
 
+    @property
+    def startpath(self) -> Path:
+        """The path from which pytest was invoked.
+
+        .. versionadded:: 7.0.0
+        """
+        return self.config.invocation_params.dir
+
     def _node_location_to_relpath(self, node_path: Path) -> str:
         # bestrelpath is a quite slow function.
         return self._bestrelpathcache[node_path]
@@ -509,20 +541,28 @@ class Session(nodes.FSCollector):
 
     pytest_collectreport = pytest_runtest_logreport
 
-    def isinitpath(self, path: py.path.local) -> bool:
-        return path in self._initialpaths
+    def isinitpath(self, path: Union[str, "os.PathLike[str]"]) -> bool:
+        # Optimization: Path(Path(...)) is much slower than isinstance.
+        path_ = path if isinstance(path, Path) else Path(path)
+        return path_ in self._initialpaths
 
-    def gethookproxy(self, fspath: py.path.local):
+    def gethookproxy(self, fspath: "os.PathLike[str]"):
+        # Optimization: Path(Path(...)) is much slower than isinstance.
+        path = fspath if isinstance(fspath, Path) else Path(fspath)
+        pm = self.config.pluginmanager
         # Check if we have the common case of running
         # hooks with all conftest.py files.
-        pm = self.config.pluginmanager
         my_conftestmodules = pm._getconftestmodules(
-            fspath, self.config.getoption("importmode")
+            path,
+            self.config.getoption("importmode"),
+            rootpath=self.config.rootpath,
         )
         remove_mods = pm._conftest_plugins.difference(my_conftestmodules)
         if remove_mods:
             # One or more conftests are not in use at this fspath.
-            proxy = FSHookProxy(pm, remove_mods)
+            from .config.compat import PathAwareHookProxy
+
+            proxy = PathAwareHookProxy(FSHookProxy(pm, remove_mods))
         else:
             # All plugins are active for this fspath.
             proxy = self.config.hook
@@ -531,38 +571,35 @@ class Session(nodes.FSCollector):
     def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
         if direntry.name == "__pycache__":
             return False
-        path = py.path.local(direntry.path)
-        ihook = self.gethookproxy(path.dirpath())
-        if ihook.pytest_ignore_collect(path=path, config=self.config):
-            return False
-        norecursepatterns = self.config.getini("norecursedirs")
-        if any(path.check(fnmatch=pat) for pat in norecursepatterns):
+        fspath = Path(direntry.path)
+        ihook = self.gethookproxy(fspath.parent)
+        if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
             return False
         return True
 
     def _collectfile(
-        self, path: py.path.local, handle_dupes: bool = True
+        self, fspath: Path, handle_dupes: bool = True
     ) -> Sequence[nodes.Collector]:
         assert (
-            path.isfile()
+            fspath.is_file()
         ), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
-            path, path.isdir(), path.exists(), path.islink()
+            fspath, fspath.is_dir(), fspath.exists(), fspath.is_symlink()
         )
-        ihook = self.gethookproxy(path)
-        if not self.isinitpath(path):
-            if ihook.pytest_ignore_collect(path=path, config=self.config):
+        ihook = self.gethookproxy(fspath)
+        if not self.isinitpath(fspath):
+            if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
                 return ()
 
         if handle_dupes:
             keepduplicates = self.config.getoption("keepduplicates")
             if not keepduplicates:
                 duplicate_paths = self.config.pluginmanager._duplicatepaths
-                if path in duplicate_paths:
+                if fspath in duplicate_paths:
                     return ()
                 else:
-                    duplicate_paths.add(path)
+                    duplicate_paths.add(fspath)
 
-        return ihook.pytest_collect_file(path=path, parent=self)  # type: ignore[no-any-return]
+        return ihook.pytest_collect_file(file_path=fspath, parent=self)  # type: ignore[no-any-return]
 
     @overload
     def perform_collect(
@@ -571,18 +608,17 @@ class Session(nodes.FSCollector):
         ...
 
     @overload
-    def perform_collect(
+    def perform_collect(  # noqa: F811
         self, args: Optional[Sequence[str]] = ..., genitems: bool = ...
     ) -> Sequence[Union[nodes.Item, nodes.Collector]]:
         ...
 
-    def perform_collect(
+    def perform_collect(  # noqa: F811
         self, args: Optional[Sequence[str]] = None, genitems: bool = True
     ) -> Sequence[Union[nodes.Item, nodes.Collector]]:
         """Perform the collection phase for this session.
 
-        This is called by the default
-        :func:`pytest_collection <_pytest.hookspec.pytest_collection>` hook
+        This is called by the default :hook:`pytest_collection` hook
         implementation; see the documentation of this hook for more details.
         For testing purposes, it may also be called directly on a fresh
         ``Session``.
@@ -600,14 +636,14 @@ class Session(nodes.FSCollector):
         self.trace.root.indent += 1
 
         self._notfound: List[Tuple[str, Sequence[nodes.Collector]]] = []
-        self._initial_parts: List[Tuple[py.path.local, List[str]]] = []
+        self._initial_parts: List[Tuple[Path, List[str]]] = []
         self.items: List[nodes.Item] = []
 
         hook = self.config.hook
 
         items: Sequence[Union[nodes.Item, nodes.Collector]] = self.items
         try:
-            initialpaths: List[py.path.local] = []
+            initialpaths: List[Path] = []
             for arg in args:
                 fspath, parts = resolve_collection_argument(
                     self.config.invocation_params.dir,
@@ -622,9 +658,14 @@ class Session(nodes.FSCollector):
             self.trace.root.indent -= 1
             if self._notfound:
                 errors = []
-                for arg, cols in self._notfound:
-                    line = f"(no name {arg!r} in any of {cols!r})"
-                    errors.append(f"not found: {arg}\n{line}")
+                for arg, collectors in self._notfound:
+                    if collectors:
+                        errors.append(
+                            f"not found: {arg}\n(no name {arg!r} in any of {collectors!r})"
+                        )
+                    else:
+                        errors.append(f"found no collectors for {arg}")
+
                 raise UsageError(*errors)
             if not genitems:
                 items = rep.result
@@ -647,17 +688,15 @@ class Session(nodes.FSCollector):
         from _pytest.python import Package
 
         # Keep track of any collected nodes in here, so we don't duplicate fixtures.
-        node_cache1: Dict[py.path.local, Sequence[nodes.Collector]] = {}
-        node_cache2: Dict[
-            Tuple[Type[nodes.Collector], py.path.local], nodes.Collector
-        ] = ({})
+        node_cache1: Dict[Path, Sequence[nodes.Collector]] = {}
+        node_cache2: Dict[Tuple[Type[nodes.Collector], Path], nodes.Collector] = {}
 
         # Keep track of any collected collectors in matchnodes paths, so they
         # are not collected more than once.
-        matchnodes_cache: Dict[Tuple[Type[nodes.Collector], str], CollectReport] = ({})
+        matchnodes_cache: Dict[Tuple[Type[nodes.Collector], str], CollectReport] = {}
 
-        # Dirnames of pkgs with dunder-init files.
-        pkg_roots: Dict[str, Package] = {}
+        # Directories of pkgs with dunder-init files.
+        pkg_roots: Dict[Path, Package] = {}
 
         for argpath, names in self._initial_parts:
             self.trace("processing argument", (argpath, names))
@@ -668,59 +707,59 @@ class Session(nodes.FSCollector):
             # No point in finding packages when collecting doctests.
             if not self.config.getoption("doctestmodules", False):
                 pm = self.config.pluginmanager
-                for parent in reversed(argpath.parts()):
-                    if pm._confcutdir and pm._confcutdir.relto(parent):
+                for parent in (argpath, *argpath.parents):
+                    if not pm._is_in_confcutdir(argpath):
                         break
 
-                    if parent.isdir():
-                        pkginit = parent.join("__init__.py")
-                        if pkginit.isfile() and pkginit not in node_cache1:
+                    if parent.is_dir():
+                        pkginit = parent / "__init__.py"
+                        if pkginit.is_file() and pkginit not in node_cache1:
                             col = self._collectfile(pkginit, handle_dupes=False)
                             if col:
                                 if isinstance(col[0], Package):
-                                    pkg_roots[str(parent)] = col[0]
-                                node_cache1[col[0].fspath] = [col[0]]
+                                    pkg_roots[parent] = col[0]
+                                node_cache1[col[0].path] = [col[0]]
 
             # If it's a directory argument, recurse and look for any Subpackages.
             # Let the Package collector deal with subnodes, don't collect here.
-            if argpath.check(dir=1):
-                assert not names, "invalid arg {!r}".format((argpath, names))
+            if argpath.is_dir():
+                assert not names, f"invalid arg {(argpath, names)!r}"
 
-                seen_dirs: Set[py.path.local] = set()
-                for direntry in visit(str(argpath), self._recurse):
+                seen_dirs: Set[Path] = set()
+                for direntry in visit(argpath, self._recurse):
                     if not direntry.is_file():
                         continue
 
-                    path = py.path.local(direntry.path)
-                    dirpath = path.dirpath()
+                    path = Path(direntry.path)
+                    dirpath = path.parent
 
                     if dirpath not in seen_dirs:
                         # Collect packages first.
                         seen_dirs.add(dirpath)
-                        pkginit = dirpath.join("__init__.py")
+                        pkginit = dirpath / "__init__.py"
                         if pkginit.exists():
                             for x in self._collectfile(pkginit):
                                 yield x
                                 if isinstance(x, Package):
-                                    pkg_roots[str(dirpath)] = x
-                    if str(dirpath) in pkg_roots:
+                                    pkg_roots[dirpath] = x
+                    if dirpath in pkg_roots:
                         # Do not collect packages here.
                         continue
 
                     for x in self._collectfile(path):
-                        key = (type(x), x.fspath)
-                        if key in node_cache2:
-                            yield node_cache2[key]
+                        key2 = (type(x), x.path)
+                        if key2 in node_cache2:
+                            yield node_cache2[key2]
                         else:
-                            node_cache2[key] = x
+                            node_cache2[key2] = x
                             yield x
             else:
-                assert argpath.check(file=1)
+                assert argpath.is_file()
 
                 if argpath in node_cache1:
                     col = node_cache1[argpath]
                 else:
-                    collect_root = pkg_roots.get(argpath.dirname, self)
+                    collect_root = pkg_roots.get(argpath.parent, self)
                     col = collect_root._collectfile(argpath, handle_dupes=False)
                     if col:
                         node_cache1[argpath] = col
@@ -758,9 +797,6 @@ class Session(nodes.FSCollector):
                                     submatchnodes.append(r)
                             if submatchnodes:
                                 work.append((submatchnodes, matchnames[1:]))
-                            # XXX Accept IDs that don't have "()" for class instances.
-                            elif len(rep.result) == 1 and rep.result[0].name == "()":
-                                work.append((rep.result, matchnames))
                         else:
                             # Report collection failures here to avoid failing to run some test
                             # specified in the command line because the module could not be
@@ -780,9 +816,7 @@ class Session(nodes.FSCollector):
                 # first yielded item will be the __init__ Module itself, so
                 # just use that. If this special case isn't taken, then all the
                 # files in the package will be yielded.
-                if argpath.basename == "__init__.py" and isinstance(
-                    matching[0], Package
-                ):
+                if argpath.name == "__init__.py" and isinstance(matching[0], Package):
                     try:
                         yield next(iter(matching[0].collect()))
                     except StopIteration:
@@ -831,7 +865,7 @@ def search_pypath(module_name: str) -> str:
 
 def resolve_collection_argument(
     invocation_path: Path, arg: str, *, as_pypath: bool = False
-) -> Tuple[py.path.local, List[str]]:
+) -> Tuple[Path, List[str]]:
     """Parse path arguments optionally containing selection parts and return (fspath, names).
 
     Command-line arguments can point to files and/or directories, and optionally contain
@@ -841,7 +875,7 @@ def resolve_collection_argument(
 
     This function ensures the path exists, and returns a tuple:
 
-        (py.path.path("/full/path/to/pkg/tests/test_foo.py"), ["TestClass", "test_foo"])
+        (Path("/full/path/to/pkg/tests/test_foo.py"), ["TestClass", "test_foo"])
 
     When as_pypath is True, expects that the command-line argument actually contains
     module paths instead of file-system paths:
@@ -854,12 +888,15 @@ def resolve_collection_argument(
     If the path doesn't exist, raise UsageError.
     If the path is a directory and selection parts are present, raise UsageError.
     """
-    strpath, *parts = str(arg).split("::")
+    base, squacket, rest = str(arg).partition("[")
+    strpath, *parts = base.split("::")
+    if parts:
+        parts[-1] = f"{parts[-1]}{squacket}{rest}"
     if as_pypath:
         strpath = search_pypath(strpath)
     fspath = invocation_path / strpath
     fspath = absolutepath(fspath)
-    if not fspath.exists():
+    if not safe_exists(fspath):
         msg = (
             "module or package not found: {arg} (missing __init__.py?)"
             if as_pypath
@@ -873,4 +910,4 @@ def resolve_collection_argument(
             else "directory argument cannot contain :: selection parts: {arg}"
         )
         raise UsageError(msg.format(arg=arg))
-    return py.path.local(str(fspath)), parts
+    return fspath, parts
index 329a11c4ae852062d865f8bdafca8ae28ea167dd..de46b4c8a75e138843987a87d73bbd3b10755c2d 100644 (file)
@@ -1,5 +1,5 @@
 """Generic mechanism for marking and selecting python functions."""
-import warnings
+import dataclasses
 from typing import AbstractSet
 from typing import Collection
 from typing import List
@@ -7,8 +7,6 @@ from typing import Optional
 from typing import TYPE_CHECKING
 from typing import Union
 
-import attr
-
 from .expression import Expression
 from .expression import ParseError
 from .structures import EMPTY_PARAMETERSET_OPTION
@@ -23,9 +21,7 @@ from _pytest.config import ExitCode
 from _pytest.config import hookimpl
 from _pytest.config import UsageError
 from _pytest.config.argparsing import Parser
-from _pytest.deprecated import MINUS_K_COLON
-from _pytest.deprecated import MINUS_K_DASH
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 
 if TYPE_CHECKING:
     from _pytest.nodes import Item
@@ -41,7 +37,7 @@ __all__ = [
 ]
 
 
-old_mark_config_key = StoreKey[Optional[Config]]()
+old_mark_config_key = StashKey[Optional[Config]]()
 
 
 def param(
@@ -56,14 +52,17 @@ def param(
 
         @pytest.mark.parametrize(
             "test_input,expected",
-            [("3+5", 8), pytest.param("6*9", 42, marks=pytest.mark.xfail),],
+            [
+                ("3+5", 8),
+                pytest.param("6*9", 42, marks=pytest.mark.xfail),
+            ],
         )
         def test_eval(test_input, expected):
             assert eval(test_input) == expected
 
     :param values: Variable args of the values of the parameter set, in order.
-    :keyword marks: A single mark or a list of marks to be applied to this parameter set.
-    :keyword str id: The id to attribute to this parameter set.
+    :param marks: A single mark or a list of marks to be applied to this parameter set.
+    :param id: The id to attribute to this parameter set.
     """
     return ParameterSet.param(*values, marks=marks, id=id)
 
@@ -76,8 +75,8 @@ def pytest_addoption(parser: Parser) -> None:
         dest="keyword",
         default="",
         metavar="EXPRESSION",
-        help="only run tests which match the given substring expression. "
-        "An expression is a python evaluatable expression "
+        help="Only run tests which match the given substring expression. "
+        "An expression is a Python evaluatable expression "
         "where all names are substring-matched against test names "
         "and their parent classes. Example: -k 'test_method or test_"
         "other' matches all test functions and classes whose name "
@@ -96,7 +95,7 @@ def pytest_addoption(parser: Parser) -> None:
         dest="markexpr",
         default="",
         metavar="MARKEXPR",
-        help="only run tests matching given mark expression.\n"
+        help="Only run tests matching given mark expression. "
         "For example: -m 'mark1 and not mark2'.",
     )
 
@@ -106,8 +105,8 @@ def pytest_addoption(parser: Parser) -> None:
         help="show markers (builtin, plugin and per-project ones).",
     )
 
-    parser.addini("markers", "markers for test functions", "linelist")
-    parser.addini(EMPTY_PARAMETERSET_OPTION, "default marker for empty parametersets")
+    parser.addini("markers", "Markers for test functions", "linelist")
+    parser.addini(EMPTY_PARAMETERSET_OPTION, "Default marker for empty parametersets")
 
 
 @hookimpl(tryfirst=True)
@@ -130,7 +129,7 @@ def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
     return None
 
 
-@attr.s(slots=True)
+@dataclasses.dataclass
 class KeywordMatcher:
     """A matcher for keywords.
 
@@ -145,7 +144,9 @@ class KeywordMatcher:
     any item, as well as names directly assigned to test functions.
     """
 
-    _names = attr.ib(type=AbstractSet[str])
+    __slots__ = ("_names",)
+
+    _names: AbstractSet[str]
 
     @classmethod
     def from_item(cls, item: "Item") -> "KeywordMatcher":
@@ -155,7 +156,7 @@ class KeywordMatcher:
         import pytest
 
         for node in item.listchain():
-            if not isinstance(node, (pytest.Instance, pytest.Session)):
+            if not isinstance(node, pytest.Session):
                 mapped_names.add(node.name)
 
         # Add the names added as extra keywords to current or parent items.
@@ -186,32 +187,14 @@ def deselect_by_keyword(items: "List[Item]", config: Config) -> None:
     if not keywordexpr:
         return
 
-    if keywordexpr.startswith("-"):
-        # To be removed in pytest 7.0.0.
-        warnings.warn(MINUS_K_DASH, stacklevel=2)
-        keywordexpr = "not " + keywordexpr[1:]
-    selectuntil = False
-    if keywordexpr[-1:] == ":":
-        # To be removed in pytest 7.0.0.
-        warnings.warn(MINUS_K_COLON, stacklevel=2)
-        selectuntil = True
-        keywordexpr = keywordexpr[:-1]
-
-    try:
-        expression = Expression.compile(keywordexpr)
-    except ParseError as e:
-        raise UsageError(
-            f"Wrong expression passed to '-k': {keywordexpr}: {e}"
-        ) from None
+    expr = _parse_expression(keywordexpr, "Wrong expression passed to '-k'")
 
     remaining = []
     deselected = []
     for colitem in items:
-        if keywordexpr and not expression.evaluate(KeywordMatcher.from_item(colitem)):
+        if not expr.evaluate(KeywordMatcher.from_item(colitem)):
             deselected.append(colitem)
         else:
-            if selectuntil:
-                keywordexpr = None
             remaining.append(colitem)
 
     if deselected:
@@ -219,17 +202,19 @@ def deselect_by_keyword(items: "List[Item]", config: Config) -> None:
         items[:] = remaining
 
 
-@attr.s(slots=True)
+@dataclasses.dataclass
 class MarkMatcher:
     """A matcher for markers which are present.
 
     Tries to match on any marker names, attached to the given colitem.
     """
 
-    own_mark_names = attr.ib()
+    __slots__ = ("own_mark_names",)
+
+    own_mark_names: AbstractSet[str]
 
     @classmethod
-    def from_item(cls, item) -> "MarkMatcher":
+    def from_item(cls, item: "Item") -> "MarkMatcher":
         mark_names = {mark.name for mark in item.iter_markers()}
         return cls(mark_names)
 
@@ -242,31 +227,33 @@ def deselect_by_mark(items: "List[Item]", config: Config) -> None:
     if not matchexpr:
         return
 
-    try:
-        expression = Expression.compile(matchexpr)
-    except ParseError as e:
-        raise UsageError(f"Wrong expression passed to '-m': {matchexpr}: {e}") from None
-
-    remaining = []
-    deselected = []
+    expr = _parse_expression(matchexpr, "Wrong expression passed to '-m'")
+    remaining: List[Item] = []
+    deselected: List[Item] = []
     for item in items:
-        if expression.evaluate(MarkMatcher.from_item(item)):
+        if expr.evaluate(MarkMatcher.from_item(item)):
             remaining.append(item)
         else:
             deselected.append(item)
-
     if deselected:
         config.hook.pytest_deselected(items=deselected)
         items[:] = remaining
 
 
+def _parse_expression(expr: str, exc_message: str) -> Expression:
+    try:
+        return Expression.compile(expr)
+    except ParseError as e:
+        raise UsageError(f"{exc_message}: {expr}: {e}") from None
+
+
 def pytest_collection_modifyitems(items: "List[Item]", config: Config) -> None:
     deselect_by_keyword(items, config)
     deselect_by_mark(items, config)
 
 
 def pytest_configure(config: Config) -> None:
-    config._store[old_mark_config_key] = MARK_GEN._config
+    config.stash[old_mark_config_key] = MARK_GEN._config
     MARK_GEN._config = config
 
     empty_parameterset = config.getini(EMPTY_PARAMETERSET_OPTION)
@@ -279,4 +266,4 @@ def pytest_configure(config: Config) -> None:
 
 
 def pytest_unconfigure(config: Config) -> None:
-    MARK_GEN._config = config._store.get(old_mark_config_key, None)
+    MARK_GEN._config = config.stash.get(old_mark_config_key, None)
index dc3991b10c4b6a03542531543af52e7607f9e089..9287bcee50c59f8b750d86efc66be534804a7044 100644 (file)
@@ -6,7 +6,7 @@ expression: expr? EOF
 expr:       and_expr ('or' and_expr)*
 and_expr:   not_expr ('and' not_expr)*
 not_expr:   'not' not_expr | '(' expr ')' | ident
-ident:      (\w|:|\+|-|\.|\[|\])+
+ident:      (\w|:|\+|-|\.|\[|\]|\\|/)+
 
 The semantics are:
 
@@ -15,20 +15,22 @@ The semantics are:
 - or/and/not evaluate according to the usual boolean semantics.
 """
 import ast
+import dataclasses
 import enum
 import re
+import sys
 import types
 from typing import Callable
 from typing import Iterator
 from typing import Mapping
+from typing import NoReturn
 from typing import Optional
 from typing import Sequence
-from typing import TYPE_CHECKING
 
-import attr
-
-if TYPE_CHECKING:
-    from typing import NoReturn
+if sys.version_info >= (3, 8):
+    astNameConstant = ast.Constant
+else:
+    astNameConstant = ast.NameConstant
 
 
 __all__ = [
@@ -47,11 +49,12 @@ class TokenType(enum.Enum):
     EOF = "end of input"
 
 
-@attr.s(frozen=True, slots=True)
+@dataclasses.dataclass(frozen=True)
 class Token:
-    type = attr.ib(type=TokenType)
-    value = attr.ib(type=str)
-    pos = attr.ib(type=int)
+    __slots__ = ("type", "value", "pos")
+    type: TokenType
+    value: str
+    pos: int
 
 
 class ParseError(Exception):
@@ -88,7 +91,7 @@ class Scanner:
                 yield Token(TokenType.RPAREN, ")", pos)
                 pos += 1
             else:
-                match = re.match(r"(:?\w|:|\+|-|\.|\[|\])+", input[pos:])
+                match = re.match(r"(:?\w|:|\+|-|\.|\[|\]|\\|/)+", input[pos:])
                 if match:
                     value = match.group(0)
                     if value == "or":
@@ -102,7 +105,8 @@ class Scanner:
                     pos += len(value)
                 else:
                     raise ParseError(
-                        pos + 1, 'unexpected character "{}"'.format(input[pos]),
+                        pos + 1,
+                        f'unexpected character "{input[pos]}"',
                     )
         yield Token(TokenType.EOF, "", pos)
 
@@ -116,11 +120,12 @@ class Scanner:
             self.reject((type,))
         return None
 
-    def reject(self, expected: Sequence[TokenType]) -> "NoReturn":
+    def reject(self, expected: Sequence[TokenType]) -> NoReturn:
         raise ParseError(
             self.current.pos + 1,
             "expected {}; got {}".format(
-                " OR ".join(type.value for type in expected), self.current.type.value,
+                " OR ".join(type.value for type in expected),
+                self.current.type.value,
             ),
         )
 
@@ -133,7 +138,7 @@ IDENT_PREFIX = "$"
 
 def expression(s: Scanner) -> ast.Expression:
     if s.accept(TokenType.EOF):
-        ret: ast.expr = ast.NameConstant(False)
+        ret: ast.expr = astNameConstant(False)
     else:
         ret = expr(s)
         s.accept(TokenType.EOF, reject=True)
@@ -188,7 +193,7 @@ class MatcherAdapter(Mapping[str, bool]):
 class Expression:
     """A compiled match expression as used by -k and -m.
 
-    The expression can be evaulated against different matchers.
+    The expression can be evaluated against different matchers.
     """
 
     __slots__ = ("code",)
@@ -204,7 +209,9 @@ class Expression:
         """
         astexpr = expression(Scanner(input))
         code: types.CodeType = compile(
-            astexpr, filename="<pytest match expression>", mode="eval",
+            astexpr,
+            filename="<pytest match expression>",
+            mode="eval",
         )
         return Expression(code)
 
index 6c126cf4a29fa7768eb45093f3dead0922988532..55620f0429eea3d2a635382618cb8a9e9ba19710 100644 (file)
@@ -1,4 +1,5 @@
 import collections.abc
+import dataclasses
 import inspect
 import warnings
 from typing import Any
@@ -20,14 +21,13 @@ from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
 
-import attr
-
 from .._code import getfslineno
 from ..compat import ascii_escaped
 from ..compat import final
 from ..compat import NOTSET
 from ..compat import NotSetType
 from _pytest.config import Config
+from _pytest.deprecated import check_ispytest
 from _pytest.outcomes import fail
 from _pytest.warning_types import PytestUnknownMarkWarning
 
@@ -39,10 +39,7 @@ EMPTY_PARAMETERSET_OPTION = "empty_parameter_set_mark"
 
 
 def istestfunc(func) -> bool:
-    return (
-        hasattr(func, "__call__")
-        and getattr(func, "__name__", "<lambda>") != "<lambda>"
-    )
+    return callable(func) and getattr(func, "__name__", "<lambda>") != "<lambda>"
 
 
 def get_empty_parameterset_mark(
@@ -74,16 +71,11 @@ def get_empty_parameterset_mark(
     return mark
 
 
-class ParameterSet(
-    NamedTuple(
-        "ParameterSet",
-        [
-            ("values", Sequence[Union[object, NotSetType]]),
-            ("marks", Collection[Union["MarkDecorator", "Mark"]]),
-            ("id", Optional[str]),
-        ],
-    )
-):
+class ParameterSet(NamedTuple):
+    values: Sequence[Union[object, NotSetType]]
+    marks: Collection[Union["MarkDecorator", "Mark"]]
+    id: Optional[str]
+
     @classmethod
     def param(
         cls,
@@ -98,9 +90,7 @@ class ParameterSet(
 
         if id is not None:
             if not isinstance(id, str):
-                raise TypeError(
-                    "Expected id to be a string, got {}: {!r}".format(type(id), id)
-                )
+                raise TypeError(f"Expected id to be a string, got {type(id)}: {id!r}")
             id = ascii_escaped(id)
         return cls(values, marks, id)
 
@@ -135,12 +125,12 @@ class ParameterSet(
 
     @staticmethod
     def _parse_parametrize_args(
-        argnames: Union[str, List[str], Tuple[str, ...]],
+        argnames: Union[str, Sequence[str]],
         argvalues: Iterable[Union["ParameterSet", Sequence[object], object]],
         *args,
         **kwargs,
-    ) -> Tuple[Union[List[str], Tuple[str, ...]], bool]:
-        if not isinstance(argnames, (tuple, list)):
+    ) -> Tuple[Sequence[str], bool]:
+        if isinstance(argnames, str):
             argnames = [x.strip() for x in argnames.split(",") if x.strip()]
             force_tuple = len(argnames) == 1
         else:
@@ -159,12 +149,12 @@ class ParameterSet(
     @classmethod
     def _for_parametrize(
         cls,
-        argnames: Union[str, List[str], Tuple[str, ...]],
+        argnames: Union[str, Sequence[str]],
         argvalues: Iterable[Union["ParameterSet", Sequence[object], object]],
         func,
         config: Config,
         nodeid: str,
-    ) -> Tuple[Union[List[str], Tuple[str, ...]], List["ParameterSet"]]:
+    ) -> Tuple[Sequence[str], List["ParameterSet"]]:
         argnames, force_tuple = cls._parse_parametrize_args(argnames, argvalues)
         parameters = cls._parse_parametrize_parameters(argvalues, force_tuple)
         del argvalues
@@ -200,22 +190,43 @@ class ParameterSet(
 
 
 @final
-@attr.s(frozen=True)
+@dataclasses.dataclass(frozen=True)
 class Mark:
+    """A pytest mark."""
+
     #: Name of the mark.
-    name = attr.ib(type=str)
+    name: str
     #: Positional arguments of the mark decorator.
-    args = attr.ib(type=Tuple[Any, ...])
+    args: Tuple[Any, ...]
     #: Keyword arguments of the mark decorator.
-    kwargs = attr.ib(type=Mapping[str, Any])
+    kwargs: Mapping[str, Any]
 
     #: Source Mark for ids with parametrize Marks.
-    _param_ids_from = attr.ib(type=Optional["Mark"], default=None, repr=False)
+    _param_ids_from: Optional["Mark"] = dataclasses.field(default=None, repr=False)
     #: Resolved/generated ids with parametrize Marks.
-    _param_ids_generated = attr.ib(
-        type=Optional[Sequence[str]], default=None, repr=False
+    _param_ids_generated: Optional[Sequence[str]] = dataclasses.field(
+        default=None, repr=False
     )
 
+    def __init__(
+        self,
+        name: str,
+        args: Tuple[Any, ...],
+        kwargs: Mapping[str, Any],
+        param_ids_from: Optional["Mark"] = None,
+        param_ids_generated: Optional[Sequence[str]] = None,
+        *,
+        _ispytest: bool = False,
+    ) -> None:
+        """:meta private:"""
+        check_ispytest(_ispytest)
+        # Weirdness to bypass frozen=True.
+        object.__setattr__(self, "name", name)
+        object.__setattr__(self, "args", args)
+        object.__setattr__(self, "kwargs", kwargs)
+        object.__setattr__(self, "_param_ids_from", param_ids_from)
+        object.__setattr__(self, "_param_ids_generated", param_ids_generated)
+
     def _has_param_ids(self) -> bool:
         return "ids" in self.kwargs or len(self.args) >= 4
 
@@ -243,20 +254,21 @@ class Mark:
             self.args + other.args,
             dict(self.kwargs, **other.kwargs),
             param_ids_from=param_ids_from,
+            _ispytest=True,
         )
 
 
 # A generic parameter designating an object to which a Mark may
 # be applied -- a test function (callable) or class.
 # Note: a lambda is not allowed, but this can't be represented.
-_Markable = TypeVar("_Markable", bound=Union[Callable[..., object], type])
+Markable = TypeVar("Markable", bound=Union[Callable[..., object], type])
 
 
-@attr.s
+@dataclasses.dataclass
 class MarkDecorator:
     """A decorator for applying a mark on test functions and classes.
 
-    MarkDecorators are created with ``pytest.mark``::
+    ``MarkDecorators`` are created with ``pytest.mark``::
 
         mark1 = pytest.mark.NAME              # Simple MarkDecorator
         mark2 = pytest.mark.NAME(name1=value) # Parametrized MarkDecorator
@@ -267,7 +279,7 @@ class MarkDecorator:
         def test_function():
             pass
 
-    When a MarkDecorator is called it does the following:
+    When a ``MarkDecorator`` is called, it does the following:
 
     1. If called with a single class as its only positional argument and no
        additional keyword arguments, it attaches the mark to the class so it
@@ -276,19 +288,24 @@ class MarkDecorator:
     2. If called with a single function as its only positional argument and
        no additional keyword arguments, it attaches the mark to the function,
        containing all the arguments already stored internally in the
-       MarkDecorator.
+       ``MarkDecorator``.
 
-    3. When called in any other case, it returns a new MarkDecorator instance
-       with the original MarkDecorator's content updated with the arguments
-       passed to this call.
+    3. When called in any other case, it returns a new ``MarkDecorator``
+       instance with the original ``MarkDecorator``'s content updated with
+       the arguments passed to this call.
 
-    Note: The rules above prevent MarkDecorators from storing only a single
-    function or class reference as their positional argument with no
+    Note: The rules above prevent a ``MarkDecorator`` from storing only a
+    single function or class reference as its positional argument with no
     additional keyword or positional arguments. You can work around this by
     using `with_args()`.
     """
 
-    mark = attr.ib(type=Mark, validator=attr.validators.instance_of(Mark))
+    mark: Mark
+
+    def __init__(self, mark: Mark, *, _ispytest: bool = False) -> None:
+        """:meta private:"""
+        check_ispytest(_ispytest)
+        self.mark = mark
 
     @property
     def name(self) -> str:
@@ -307,27 +324,23 @@ class MarkDecorator:
 
     @property
     def markname(self) -> str:
+        """:meta private:"""
         return self.name  # for backward-compat (2.4.1 had this attr)
 
-    def __repr__(self) -> str:
-        return f"<MarkDecorator {self.mark!r}>"
-
     def with_args(self, *args: object, **kwargs: object) -> "MarkDecorator":
         """Return a MarkDecorator with extra arguments added.
 
         Unlike calling the MarkDecorator, with_args() can be used even
         if the sole argument is a callable/class.
-
-        :rtype: MarkDecorator
         """
-        mark = Mark(self.name, args, kwargs)
-        return self.__class__(self.mark.combined_with(mark))
+        mark = Mark(self.name, args, kwargs, _ispytest=True)
+        return MarkDecorator(self.mark.combined_with(mark), _ispytest=True)
 
     # Type ignored because the overloads overlap with an incompatible
     # return type. Not much we can do about that. Thankfully mypy picks
     # the first match so it works out even if we break the rules.
     @overload
-    def __call__(self, arg: _Markable) -> _Markable:  # type: ignore[misc]
+    def __call__(self, arg: Markable) -> Markable:  # type: ignore[misc]
         pass
 
     @overload
@@ -345,27 +358,54 @@ class MarkDecorator:
         return self.with_args(*args, **kwargs)
 
 
-def get_unpacked_marks(obj) -> List[Mark]:
-    """Obtain the unpacked marks that are stored on an object."""
-    mark_list = getattr(obj, "pytestmark", [])
-    if not isinstance(mark_list, list):
-        mark_list = [mark_list]
-    return normalize_mark_list(mark_list)
+def get_unpacked_marks(
+    obj: Union[object, type],
+    *,
+    consider_mro: bool = True,
+) -> List[Mark]:
+    """Obtain the unpacked marks that are stored on an object.
 
+    If obj is a class and consider_mro is true, return marks applied to
+    this class and all of its super-classes in MRO order. If consider_mro
+    is false, only return marks applied directly to this class.
+    """
+    if isinstance(obj, type):
+        if not consider_mro:
+            mark_lists = [obj.__dict__.get("pytestmark", [])]
+        else:
+            mark_lists = [
+                x.__dict__.get("pytestmark", []) for x in reversed(obj.__mro__)
+            ]
+        mark_list = []
+        for item in mark_lists:
+            if isinstance(item, list):
+                mark_list.extend(item)
+            else:
+                mark_list.append(item)
+    else:
+        mark_attribute = getattr(obj, "pytestmark", [])
+        if isinstance(mark_attribute, list):
+            mark_list = mark_attribute
+        else:
+            mark_list = [mark_attribute]
+    return list(normalize_mark_list(mark_list))
 
-def normalize_mark_list(mark_list: Iterable[Union[Mark, MarkDecorator]]) -> List[Mark]:
-    """Normalize marker decorating helpers to mark objects.
 
-    :type List[Union[Mark, Markdecorator]] mark_list:
-    :rtype: List[Mark]
+def normalize_mark_list(
+    mark_list: Iterable[Union[Mark, MarkDecorator]]
+) -> Iterable[Mark]:
     """
-    extracted = [
-        getattr(mark, "mark", mark) for mark in mark_list
-    ]  # unpack MarkDecorator
-    for mark in extracted:
-        if not isinstance(mark, Mark):
-            raise TypeError(f"got {mark!r} instead of Mark")
-    return [x for x in extracted if isinstance(x, Mark)]
+    Normalize an iterable of Mark or MarkDecorator objects into a list of marks
+    by retrieving the `mark` attribute on MarkDecorator instances.
+
+    :param mark_list: marks to normalize
+    :returns: A new list of the extracted Mark objects
+    """
+    for mark in mark_list:
+        mark_obj = getattr(mark, "mark", mark)
+        if not isinstance(mark_obj, Mark):
+            raise TypeError(f"got {repr(mark_obj)} instead of Mark")
+        yield mark_obj
 
 
 def store_mark(obj, mark: Mark) -> None:
@@ -376,17 +416,17 @@ def store_mark(obj, mark: Mark) -> None:
     assert isinstance(mark, Mark), mark
     # Always reassign name to avoid updating pytestmark in a reference that
     # was only borrowed.
-    obj.pytestmark = get_unpacked_marks(obj) + [mark]
+    obj.pytestmark = [*get_unpacked_marks(obj, consider_mro=False), mark]
 
 
 # Typing for builtin pytest marks. This is cheating; it gives builtin marks
 # special privilege, and breaks modularity. But practicality beats purity...
 if TYPE_CHECKING:
-    from _pytest.fixtures import _Scope
+    from _pytest.scope import _ScopeName
 
     class _SkipMarkDecorator(MarkDecorator):
-        @overload  # type: ignore[override,misc]
-        def __call__(self, arg: _Markable) -> _Markable:
+        @overload  # type: ignore[override,misc,no-overload-impl]
+        def __call__(self, arg: Markable) -> Markable:
             ...
 
         @overload
@@ -403,8 +443,8 @@ if TYPE_CHECKING:
             ...
 
     class _XfailMarkDecorator(MarkDecorator):
-        @overload  # type: ignore[override,misc]
-        def __call__(self, arg: _Markable) -> _Markable:
+        @overload  # type: ignore[override,misc,no-overload-impl]
+        def __call__(self, arg: Markable) -> Markable:
             ...
 
         @overload
@@ -422,7 +462,7 @@ if TYPE_CHECKING:
     class _ParametrizeMarkDecorator(MarkDecorator):
         def __call__(  # type: ignore[override]
             self,
-            argnames: Union[str, List[str], Tuple[str, ...]],
+            argnames: Union[str, Sequence[str]],
             argvalues: Iterable[Union[ParameterSet, Sequence[object], object]],
             *,
             indirect: Union[bool, Sequence[str]] = ...,
@@ -432,20 +472,16 @@ if TYPE_CHECKING:
                     Callable[[Any], Optional[object]],
                 ]
             ] = ...,
-            scope: Optional[_Scope] = ...,
+            scope: Optional[_ScopeName] = ...,
         ) -> MarkDecorator:
             ...
 
     class _UsefixturesMarkDecorator(MarkDecorator):
-        def __call__(  # type: ignore[override]
-            self, *fixtures: str
-        ) -> MarkDecorator:
+        def __call__(self, *fixtures: str) -> MarkDecorator:  # type: ignore[override]
             ...
 
     class _FilterwarningsMarkDecorator(MarkDecorator):
-        def __call__(  # type: ignore[override]
-            self, *filters: str
-        ) -> MarkDecorator:
+        def __call__(self, *filters: str) -> MarkDecorator:  # type: ignore[override]
             ...
 
 
@@ -465,9 +501,6 @@ class MarkGenerator:
     applies a 'slowtest' :class:`Mark` on ``test_function``.
     """
 
-    _config: Optional[Config] = None
-    _markers: Set[str] = set()
-
     # See TYPE_CHECKING above.
     if TYPE_CHECKING:
         skip: _SkipMarkDecorator
@@ -477,7 +510,13 @@ class MarkGenerator:
         usefixtures: _UsefixturesMarkDecorator
         filterwarnings: _FilterwarningsMarkDecorator
 
+    def __init__(self, *, _ispytest: bool = False) -> None:
+        check_ispytest(_ispytest)
+        self._config: Optional[Config] = None
+        self._markers: Set[str] = set()
+
     def __getattr__(self, name: str) -> MarkDecorator:
+        """Generate a new :class:`MarkDecorator` with the given name."""
         if name[0] == "_":
             raise AttributeError("Marker name must NOT start with underscore")
 
@@ -510,19 +549,21 @@ class MarkGenerator:
                 warnings.warn(
                     "Unknown pytest.mark.%s - is this a typo?  You can register "
                     "custom marks to avoid this warning - for details, see "
-                    "https://docs.pytest.org/en/stable/mark.html" % name,
+                    "https://docs.pytest.org/en/stable/how-to/mark.html" % name,
                     PytestUnknownMarkWarning,
                     2,
                 )
 
-        return MarkDecorator(Mark(name, (), {}))
+        return MarkDecorator(Mark(name, (), {}, _ispytest=True), _ispytest=True)
 
 
-MARK_GEN = MarkGenerator()
+MARK_GEN = MarkGenerator(_ispytest=True)
 
 
 @final
 class NodeKeywords(MutableMapping[str, Any]):
+    __slots__ = ("node", "parent", "_markers")
+
     def __init__(self, node: "Node") -> None:
         self.node = node
         self.parent = node.parent
@@ -539,21 +580,39 @@ class NodeKeywords(MutableMapping[str, Any]):
     def __setitem__(self, key: str, value: Any) -> None:
         self._markers[key] = value
 
+    # Note: we could've avoided explicitly implementing some of the methods
+    # below and use the collections.abc fallback, but that would be slow.
+
+    def __contains__(self, key: object) -> bool:
+        return (
+            key in self._markers
+            or self.parent is not None
+            and key in self.parent.keywords
+        )
+
+    def update(  # type: ignore[override]
+        self,
+        other: Union[Mapping[str, Any], Iterable[Tuple[str, Any]]] = (),
+        **kwds: Any,
+    ) -> None:
+        self._markers.update(other)
+        self._markers.update(kwds)
+
     def __delitem__(self, key: str) -> None:
         raise ValueError("cannot delete key in keywords dict")
 
     def __iter__(self) -> Iterator[str]:
-        seen = self._seen()
-        return iter(seen)
-
-    def _seen(self) -> Set[str]:
-        seen = set(self._markers)
+        # Doesn't need to be fast.
+        yield from self._markers
         if self.parent is not None:
-            seen.update(self.parent.keywords)
-        return seen
+            for keyword in self.parent.keywords:
+                # self._marks and self.parent.keywords can have duplicates.
+                if keyword not in self._markers:
+                    yield keyword
 
     def __len__(self) -> int:
-        return len(self._seen())
+        # Doesn't need to be fast.
+        return sum(1 for keyword in self)
 
     def __repr__(self) -> str:
         return f"<NodeKeywords for node {self.node}>"
index a052f693ac04d92e5c93950321840fd4f9e6ebf3..9e51ff335382c0437c90a156da9488d7df9bd528 100644 (file)
@@ -4,10 +4,10 @@ import re
 import sys
 import warnings
 from contextlib import contextmanager
-from pathlib import Path
 from typing import Any
 from typing import Generator
 from typing import List
+from typing import Mapping
 from typing import MutableMapping
 from typing import Optional
 from typing import overload
@@ -30,21 +30,26 @@ V = TypeVar("V")
 def monkeypatch() -> Generator["MonkeyPatch", None, None]:
     """A convenient fixture for monkey-patching.
 
-    The fixture provides these methods to modify objects, dictionaries or
-    os.environ::
+    The fixture provides these methods to modify objects, dictionaries, or
+    :data:`os.environ`:
 
-        monkeypatch.setattr(obj, name, value, raising=True)
-        monkeypatch.delattr(obj, name, raising=True)
-        monkeypatch.setitem(mapping, name, value)
-        monkeypatch.delitem(obj, name, raising=True)
-        monkeypatch.setenv(name, value, prepend=False)
-        monkeypatch.delenv(name, raising=True)
-        monkeypatch.syspath_prepend(path)
-        monkeypatch.chdir(path)
+    * :meth:`monkeypatch.setattr(obj, name, value, raising=True) <pytest.MonkeyPatch.setattr>`
+    * :meth:`monkeypatch.delattr(obj, name, raising=True) <pytest.MonkeyPatch.delattr>`
+    * :meth:`monkeypatch.setitem(mapping, name, value) <pytest.MonkeyPatch.setitem>`
+    * :meth:`monkeypatch.delitem(obj, name, raising=True) <pytest.MonkeyPatch.delitem>`
+    * :meth:`monkeypatch.setenv(name, value, prepend=None) <pytest.MonkeyPatch.setenv>`
+    * :meth:`monkeypatch.delenv(name, raising=True) <pytest.MonkeyPatch.delenv>`
+    * :meth:`monkeypatch.syspath_prepend(path) <pytest.MonkeyPatch.syspath_prepend>`
+    * :meth:`monkeypatch.chdir(path) <pytest.MonkeyPatch.chdir>`
+    * :meth:`monkeypatch.context() <pytest.MonkeyPatch.context>`
 
     All modifications will be undone after the requesting test function or
-    fixture has finished. The ``raising`` parameter determines if a KeyError
-    or AttributeError will be raised if the set/deletion operation has no target.
+    fixture has finished. The ``raising`` parameter determines if a :class:`KeyError`
+    or :class:`AttributeError` will be raised if the set/deletion operation does not have the
+    specified target.
+
+    To undo modifications done by the fixture in a contained scope,
+    use :meth:`context() <pytest.MonkeyPatch.context>`.
     """
     mpatch = MonkeyPatch()
     yield mpatch
@@ -56,7 +61,7 @@ def resolve(name: str) -> object:
     parts = name.split(".")
 
     used = parts.pop(0)
-    found = __import__(used)
+    found: object = __import__(used)
     for part in parts:
         used += "." + part
         try:
@@ -92,7 +97,7 @@ def annotated_getattr(obj: object, name: str, ann: str) -> object:
 
 
 def derive_importpath(import_path: str, raising: bool) -> Tuple[str, object]:
-    if not isinstance(import_path, str) or "." not in import_path:  # type: ignore[unreachable]
+    if not isinstance(import_path, str) or "." not in import_path:
         raise TypeError(f"must be absolute import path string, not {import_path!r}")
     module, attr = import_path.rsplit(".", 1)
     target = resolve(module)
@@ -116,7 +121,7 @@ class MonkeyPatch:
 
     Returned by the :fixture:`monkeypatch` fixture.
 
-    :versionchanged:: 6.2
+    .. versionchanged:: 6.2
         Can now also be used directly as `pytest.MonkeyPatch()`, for when
         the fixture is not available. In this case, use
         :meth:`with MonkeyPatch.context() as mp: <context>` or remember to call
@@ -125,7 +130,7 @@ class MonkeyPatch:
 
     def __init__(self) -> None:
         self._setattr: List[Tuple[object, str, object]] = []
-        self._setitem: List[Tuple[MutableMapping[Any, Any], object, object]] = ([])
+        self._setitem: List[Tuple[Mapping[Any, Any], object, object]] = []
         self._cwd: Optional[str] = None
         self._savesyspath: Optional[List[str]] = None
 
@@ -148,7 +153,7 @@ class MonkeyPatch:
 
         Useful in situations where it is desired to undo some patches before the test ends,
         such as mocking ``stdlib`` functions that might break pytest itself if mocked (for examples
-        of this see `#3290 <https://github.com/pytest-dev/pytest/issues/3290>`_.
+        of this see :issue:`3290`).
         """
         m = cls()
         try:
@@ -158,13 +163,21 @@ class MonkeyPatch:
 
     @overload
     def setattr(
-        self, target: str, name: object, value: Notset = ..., raising: bool = ...,
+        self,
+        target: str,
+        name: object,
+        value: Notset = ...,
+        raising: bool = ...,
     ) -> None:
         ...
 
     @overload
     def setattr(
-        self, target: object, name: str, value: object, raising: bool = ...,
+        self,
+        target: object,
+        name: str,
+        value: object,
+        raising: bool = ...,
     ) -> None:
         ...
 
@@ -175,16 +188,40 @@ class MonkeyPatch:
         value: object = notset,
         raising: bool = True,
     ) -> None:
-        """Set attribute value on target, memorizing the old value.
+        """
+        Set attribute value on target, memorizing the old value.
+
+        For example:
+
+        .. code-block:: python
+
+            import os
+
+            monkeypatch.setattr(os, "getcwd", lambda: "/")
+
+        The code above replaces the :func:`os.getcwd` function by a ``lambda`` which
+        always returns ``"/"``.
 
-        For convenience you can specify a string as ``target`` which
+        For convenience, you can specify a string as ``target`` which
         will be interpreted as a dotted import path, with the last part
-        being the attribute name. For example,
-        ``monkeypatch.setattr("os.getcwd", lambda: "/")``
-        would set the ``getcwd`` function of the ``os`` module.
+        being the attribute name:
 
-        Raises AttributeError if the attribute does not exist, unless
+        .. code-block:: python
+
+            monkeypatch.setattr("os.getcwd", lambda: "/")
+
+        Raises :class:`AttributeError` if the attribute does not exist, unless
         ``raising`` is set to False.
+
+        **Where to patch**
+
+        ``monkeypatch.setattr`` works by (temporarily) changing the object that a name points to with another one.
+        There can be many names pointing to any individual object, so for patching to work you must ensure
+        that you patch the name used by the system under test.
+
+        See the section :ref:`Where to patch <python:where-to-patch>` in the :mod:`unittest.mock`
+        docs for a complete explanation, which is meant for :func:`unittest.mock.patch` but
+        applies to ``monkeypatch.setattr`` as well.
         """
         __tracebackhide__ = True
         import inspect
@@ -254,12 +291,13 @@ class MonkeyPatch:
             self._setattr.append((target, name, oldval))
             delattr(target, name)
 
-    def setitem(self, dic: MutableMapping[K, V], name: K, value: V) -> None:
+    def setitem(self, dic: Mapping[K, V], name: K, value: V) -> None:
         """Set dictionary entry ``name`` to value."""
         self._setitem.append((dic, name, dic.get(name, notset)))
-        dic[name] = value
+        # Not all Mapping types support indexing, but MutableMapping doesn't support TypedDict
+        dic[name] = value  # type: ignore[index]
 
-    def delitem(self, dic: MutableMapping[K, V], name: K, raising: bool = True) -> None:
+    def delitem(self, dic: Mapping[K, V], name: K, raising: bool = True) -> None:
         """Delete ``name`` from dict.
 
         Raises ``KeyError`` if it doesn't exist, unless ``raising`` is set to
@@ -270,7 +308,8 @@ class MonkeyPatch:
                 raise KeyError(name)
         else:
             self._setitem.append((dic, name, dic.get(name, notset)))
-            del dic[name]
+            # Not all Mapping types support indexing, but MutableMapping doesn't support TypedDict
+            del dic[name]  # type: ignore[attr-defined]
 
     def setenv(self, name: str, value: str, prepend: Optional[str] = None) -> None:
         """Set environment variable ``name`` to ``value``.
@@ -305,14 +344,17 @@ class MonkeyPatch:
 
     def syspath_prepend(self, path) -> None:
         """Prepend ``path`` to ``sys.path`` list of import locations."""
-        from pkg_resources import fixup_namespace_packages
 
         if self._savesyspath is None:
             self._savesyspath = sys.path[:]
         sys.path.insert(0, str(path))
 
         # https://github.com/pypa/setuptools/blob/d8b901bc/docs/pkg_resources.txt#L162-L171
-        fixup_namespace_packages(str(path))
+        # this is only needed when pkg_resources was already loaded by the namespace package
+        if "pkg_resources" in sys.modules:
+            from pkg_resources import fixup_namespace_packages
+
+            fixup_namespace_packages(str(path))
 
         # A call to syspathinsert() usually means that the caller wants to
         # import some dynamically created files, thus with python3 we
@@ -325,20 +367,15 @@ class MonkeyPatch:
 
         invalidate_caches()
 
-    def chdir(self, path) -> None:
+    def chdir(self, path: Union[str, "os.PathLike[str]"]) -> None:
         """Change the current working directory to the specified path.
 
-        Path can be a string or a py.path.local object.
+        :param path:
+            The path to change into.
         """
         if self._cwd is None:
             self._cwd = os.getcwd()
-        if hasattr(path, "chdir"):
-            path.chdir()
-        elif isinstance(path, Path):
-            # Modern python uses the fspath protocol here LEGACY
-            os.chdir(str(path))
-        else:
-            os.chdir(path)
+        os.chdir(path)
 
     def undo(self) -> None:
         """Undo previous changes.
@@ -349,11 +386,14 @@ class MonkeyPatch:
         There is generally no need to call `undo()`, since it is
         called automatically during tear-down.
 
-        Note that the same `monkeypatch` fixture is used across a
-        single test function invocation. If `monkeypatch` is used both by
-        the test function itself and one of the test fixtures,
-        calling `undo()` will undo all of the changes made in
-        both functions.
+        .. note::
+            The same `monkeypatch` fixture is used across a
+            single test function invocation. If `monkeypatch` is used both by
+            the test function itself and one of the test fixtures,
+            calling `undo()` will undo all of the changes made in
+            both functions.
+
+            Prefer to use :meth:`context() <pytest.MonkeyPatch.context>` instead.
         """
         for obj, name, value in reversed(self._setattr):
             if value is not notset:
@@ -364,11 +404,13 @@ class MonkeyPatch:
         for dictionary, key, value in reversed(self._setitem):
             if value is notset:
                 try:
-                    del dictionary[key]
+                    # Not all Mapping types support indexing, but MutableMapping doesn't support TypedDict
+                    del dictionary[key]  # type: ignore[attr-defined]
                 except KeyError:
                     pass  # Was already deleted, so we have the desired state.
             else:
-                dictionary[key] = value
+                # Not all Mapping types support indexing, but MutableMapping doesn't support TypedDict
+                dictionary[key] = value  # type: ignore[index]
         self._setitem[:] = []
         if self._savesyspath is not None:
             sys.path[:] = self._savesyspath
index 27434fb6a67f2218cfb77927d52095eeefa88f24..667a02b77affbd4ad72cdb5fa8f35d483581141e 100644 (file)
@@ -1,10 +1,14 @@
 import os
 import warnings
+from inspect import signature
 from pathlib import Path
+from typing import Any
 from typing import Callable
+from typing import cast
 from typing import Iterable
 from typing import Iterator
 from typing import List
+from typing import MutableMapping
 from typing import Optional
 from typing import overload
 from typing import Set
@@ -14,22 +18,25 @@ from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
 
-import py
-
 import _pytest._code
 from _pytest._code import getfslineno
 from _pytest._code.code import ExceptionInfo
 from _pytest._code.code import TerminalRepr
+from _pytest._code.code import Traceback
 from _pytest.compat import cached_property
+from _pytest.compat import LEGACY_PATH
 from _pytest.config import Config
 from _pytest.config import ConftestImportFailure
 from _pytest.deprecated import FSCOLLECTOR_GETHOOKPROXY_ISINITPATH
+from _pytest.deprecated import NODE_CTOR_FSPATH_ARG
 from _pytest.mark.structures import Mark
 from _pytest.mark.structures import MarkDecorator
 from _pytest.mark.structures import NodeKeywords
 from _pytest.outcomes import fail
 from _pytest.pathlib import absolutepath
-from _pytest.store import Store
+from _pytest.pathlib import commonpath
+from _pytest.stash import Stash
+from _pytest.warning_types import PytestWarning
 
 if TYPE_CHECKING:
     # Imported here due to circular import.
@@ -39,7 +46,7 @@ if TYPE_CHECKING:
 
 SEP = "/"
 
-tracebackcutdir = py.path.local(_pytest.__file__).dirpath()
+tracebackcutdir = Path(_pytest.__file__).parent
 
 
 def iterparentnodeids(nodeid: str) -> Iterator[str]:
@@ -58,23 +65,62 @@ def iterparentnodeids(nodeid: str) -> Iterator[str]:
         "testing/code/test_excinfo.py::TestFormattedExcinfo"
         "testing/code/test_excinfo.py::TestFormattedExcinfo::test_repr_source"
 
-    Note that :: parts are only considered at the last / component.
+    Note that / components are only considered until the first ::.
     """
     pos = 0
-    sep = SEP
+    first_colons: Optional[int] = nodeid.find("::")
+    if first_colons == -1:
+        first_colons = None
+    # The root Session node - always present.
     yield ""
+    # Eagerly consume SEP parts until first colons.
     while True:
-        at = nodeid.find(sep, pos)
-        if at == -1 and sep == SEP:
-            sep = "::"
-        elif at == -1:
-            if nodeid:
-                yield nodeid
+        at = nodeid.find(SEP, pos, first_colons)
+        if at == -1:
             break
-        else:
-            if at:
-                yield nodeid[:at]
-            pos = at + len(sep)
+        if at > 0:
+            yield nodeid[:at]
+        pos = at + len(SEP)
+    # Eagerly consume :: parts.
+    while True:
+        at = nodeid.find("::", pos)
+        if at == -1:
+            break
+        if at > 0:
+            yield nodeid[:at]
+        pos = at + len("::")
+    # The node ID itself.
+    if nodeid:
+        yield nodeid
+
+
+def _check_path(path: Path, fspath: LEGACY_PATH) -> None:
+    if Path(fspath) != path:
+        raise ValueError(
+            f"Path({fspath!r}) != {path!r}\n"
+            "if both path and fspath are given they need to be equal"
+        )
+
+
+def _imply_path(
+    node_type: Type["Node"],
+    path: Optional[Path],
+    fspath: Optional[LEGACY_PATH],
+) -> Path:
+    if fspath is not None:
+        warnings.warn(
+            NODE_CTOR_FSPATH_ARG.format(
+                node_type_name=node_type.__name__,
+            ),
+            stacklevel=6,
+        )
+    if path is not None:
+        if fspath is not None:
+            _check_path(path, fspath)
+        return path
+    else:
+        assert fspath is not None
+        return Path(fspath)
 
 
 _NodeType = TypeVar("_NodeType", bound="Node")
@@ -87,20 +133,44 @@ class NodeMeta(type):
             "See "
             "https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent"
             " for more details."
-        ).format(name=self.__name__)
+        ).format(name=f"{self.__module__}.{self.__name__}")
         fail(msg, pytrace=False)
 
     def _create(self, *k, **kw):
-        return super().__call__(*k, **kw)
+        try:
+            return super().__call__(*k, **kw)
+        except TypeError:
+            sig = signature(getattr(self, "__init__"))
+            known_kw = {k: v for k, v in kw.items() if k in sig.parameters}
+            from .warning_types import PytestDeprecationWarning
+
+            warnings.warn(
+                PytestDeprecationWarning(
+                    f"{self} is not using a cooperative constructor and only takes {set(known_kw)}.\n"
+                    "See https://docs.pytest.org/en/stable/deprecations.html"
+                    "#constructors-of-custom-pytest-node-subclasses-should-take-kwargs "
+                    "for more details."
+                )
+            )
+
+            return super().__call__(*k, **known_kw)
 
 
 class Node(metaclass=NodeMeta):
-    """Base class for Collector and Item, the components of the test
-    collection tree.
+    r"""Base class of :class:`Collector` and :class:`Item`, the components of
+    the test collection tree.
 
-    Collector subclasses have children; Items are leaf nodes.
+    ``Collector``\'s are the internal nodes of the tree, and ``Item``\'s are the
+    leaf nodes.
     """
 
+    # Implemented in the legacypath plugin.
+    #: A ``LEGACY_PATH`` copy of the :attr:`path` attribute. Intended for usage
+    #: for methods not migrated to ``pathlib.Path`` yet, such as
+    #: :meth:`Item.reportinfo`. Will be deprecated in a future release, prefer
+    #: using :attr:`path` instead.
+    fspath: LEGACY_PATH
+
     # Use __slots__ to make attribute access faster.
     # Note that __dict__ is still available.
     __slots__ = (
@@ -108,7 +178,7 @@ class Node(metaclass=NodeMeta):
         "parent",
         "config",
         "session",
-        "fspath",
+        "path",
         "_nodeid",
         "_store",
         "__dict__",
@@ -120,36 +190,40 @@ class Node(metaclass=NodeMeta):
         parent: "Optional[Node]" = None,
         config: Optional[Config] = None,
         session: "Optional[Session]" = None,
-        fspath: Optional[py.path.local] = None,
+        fspath: Optional[LEGACY_PATH] = None,
+        path: Optional[Path] = None,
         nodeid: Optional[str] = None,
     ) -> None:
         #: A unique name within the scope of the parent node.
-        self.name = name
+        self.name: str = name
 
         #: The parent collector node.
         self.parent = parent
 
-        #: The pytest config object.
         if config:
+            #: The pytest config object.
             self.config: Config = config
         else:
             if not parent:
                 raise TypeError("config or parent must be provided")
             self.config = parent.config
 
-        #: The pytest session this node is part of.
         if session:
-            self.session = session
+            #: The pytest session this node is part of.
+            self.session: Session = session
         else:
             if not parent:
                 raise TypeError("session or parent must be provided")
             self.session = parent.session
 
+        if path is None and fspath is None:
+            path = getattr(parent, "path", None)
         #: Filesystem path where this node was collected from (can be None).
-        self.fspath = fspath or getattr(parent, "fspath", None)
+        self.path: Path = _imply_path(type(self), path, fspath=fspath)
 
+        # The explicit annotation is to avoid publicly exposing NodeKeywords.
         #: Keywords/markers collected from all scopes.
-        self.keywords = NodeKeywords(self)
+        self.keywords: MutableMapping[str, Any] = NodeKeywords(self)
 
         #: The marker objects belonging to this node.
         self.own_markers: List[Mark] = []
@@ -163,13 +237,13 @@ class Node(metaclass=NodeMeta):
         else:
             if not self.parent:
                 raise TypeError("nodeid or parent must be provided")
-            self._nodeid = self.parent.nodeid
-            if self.name != "()":
-                self._nodeid += "::" + self.name
+            self._nodeid = self.parent.nodeid + "::" + self.name
 
-        # A place where plugins can store information on the node for their
-        # own use. Currently only intended for internal plugins.
-        self._store = Store()
+        #: A place where plugins can store information on the node for their
+        #: own use.
+        self.stash: Stash = Stash()
+        # Deprecated alias. Was never public. Can be removed in a few releases.
+        self._store = self.stash
 
     @classmethod
     def from_parent(cls, parent: "Node", **kw):
@@ -192,7 +266,7 @@ class Node(metaclass=NodeMeta):
     @property
     def ihook(self):
         """fspath-sensitive hook proxy used to call pytest hooks."""
-        return self.session.gethookproxy(self.fspath)
+        return self.session.gethookproxy(self.path)
 
     def __repr__(self) -> str:
         return "<{} {}>".format(self.__class__.__name__, getattr(self, "name", None))
@@ -228,7 +302,10 @@ class Node(metaclass=NodeMeta):
         path, lineno = get_fslocation_from_item(self)
         assert lineno is not None
         warnings.warn_explicit(
-            warning, category=None, filename=str(path), lineno=lineno + 1,
+            warning,
+            category=None,
+            filename=str(path),
+            lineno=lineno + 1,
         )
 
     # Methods for ordering nodes.
@@ -249,7 +326,10 @@ class Node(metaclass=NodeMeta):
 
     def listchain(self) -> List["Node"]:
         """Return list of all parent collectors up to self, starting from
-        the root of collection tree."""
+        the root of collection tree.
+
+        :returns: The nodes.
+        """
         chain = []
         item: Optional[Node] = self
         while item is not None:
@@ -263,6 +343,8 @@ class Node(metaclass=NodeMeta):
     ) -> None:
         """Dynamically add a marker object to the node.
 
+        :param marker:
+            The marker.
         :param append:
             Whether to append the marker, or prepend it.
         """
@@ -284,6 +366,7 @@ class Node(metaclass=NodeMeta):
         """Iterate over all markers of the node.
 
         :param name: If given, filter the results by the name attribute.
+        :returns: An iterator of the markers of the node.
         """
         return (x[1] for x in self.iter_markers_with_node(name=name))
 
@@ -330,7 +413,8 @@ class Node(metaclass=NodeMeta):
         return [x.name for x in self.listchain()]
 
     def addfinalizer(self, fin: Callable[[], object]) -> None:
-        """Register a function to be called when this node is finalized.
+        """Register a function to be called without arguments when this node is
+        finalized.
 
         This method can only be called when this node is active
         in a setup chain, for example during self.setup().
@@ -339,15 +423,19 @@ class Node(metaclass=NodeMeta):
 
     def getparent(self, cls: Type[_NodeType]) -> Optional[_NodeType]:
         """Get the next parent node (including self) which is an instance of
-        the given class."""
+        the given class.
+
+        :param cls: The node class to search for.
+        :returns: The node, if found.
+        """
         current: Optional[Node] = self
         while current and not isinstance(current, cls):
             current = current.parent
         assert current is None or isinstance(current, cls)
         return current
 
-    def _prunetraceback(self, excinfo: ExceptionInfo[BaseException]) -> None:
-        pass
+    def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback:
+        return excinfo.traceback
 
     def _repr_failure_py(
         self,
@@ -357,19 +445,19 @@ class Node(metaclass=NodeMeta):
         from _pytest.fixtures import FixtureLookupError
 
         if isinstance(excinfo.value, ConftestImportFailure):
-            excinfo = ExceptionInfo(excinfo.value.excinfo)
+            excinfo = ExceptionInfo.from_exc_info(excinfo.value.excinfo)
         if isinstance(excinfo.value, fail.Exception):
             if not excinfo.value.pytrace:
                 style = "value"
         if isinstance(excinfo.value, FixtureLookupError):
             return excinfo.value.formatrepr()
+
+        tbfilter: Union[bool, Callable[[ExceptionInfo[BaseException]], Traceback]]
         if self.config.getoption("fulltrace", False):
             style = "long"
+            tbfilter = False
         else:
-            tb = _pytest._code.Traceback([excinfo.traceback[-1]])
-            self._prunetraceback(excinfo)
-            if len(excinfo.traceback) == 0:
-                excinfo.traceback = tb
+            tbfilter = self._traceback_filter
             if style == "auto":
                 style = "long"
         # XXX should excinfo.getrepr record all data and toterminal() process it?
@@ -400,7 +488,7 @@ class Node(metaclass=NodeMeta):
             abspath=abspath,
             showlocals=self.config.getoption("showlocals", False),
             style=style,
-            tbfilter=False,  # pruned already, or in --fulltrace mode.
+            tbfilter=tbfilter,
             truncate_locals=truncate_locals,
         )
 
@@ -411,21 +499,21 @@ class Node(metaclass=NodeMeta):
     ) -> Union[str, TerminalRepr]:
         """Return a representation of a collection or test failure.
 
+        .. seealso:: :ref:`non-python tests`
+
         :param excinfo: Exception information for the failure.
         """
         return self._repr_failure_py(excinfo, style)
 
 
-def get_fslocation_from_item(
-    node: "Node",
-) -> Tuple[Union[str, py.path.local], Optional[int]]:
+def get_fslocation_from_item(node: "Node") -> Tuple[Union[str, Path], Optional[int]]:
     """Try to extract the actual location from a node, depending on available attributes:
 
     * "location": a pair (path, lineno)
     * "obj": a Python object that the node wraps.
     * "fspath": just a path
 
-    :rtype: A tuple of (str|py.path.local, int) with filename and line number.
+    :rtype: A tuple of (str|Path, int) with filename and 0-based line number.
     """
     # See Item.location.
     location: Optional[Tuple[str, Optional[int], str]] = getattr(node, "location", None)
@@ -438,15 +526,17 @@ def get_fslocation_from_item(
 
 
 class Collector(Node):
-    """Collector instances create children through collect() and thus
-    iteratively build a tree."""
+    """Base class of all collectors.
+
+    Collector create children through `collect()` and thus iteratively build
+    the collection tree.
+    """
 
     class CollectError(Exception):
         """An error during collection, contains a custom message."""
 
     def collect(self) -> Iterable[Union["Item", "Collector"]]:
-        """Return a list of children (items and collectors) for this
-        collection node."""
+        """Collect children (items and collectors) for this collector."""
         raise NotImplementedError("abstract")
 
     # TODO: This omits the style= parameter which breaks Liskov Substitution.
@@ -471,60 +561,98 @@ class Collector(Node):
 
         return self._repr_failure_py(excinfo, style=tbstyle)
 
-    def _prunetraceback(self, excinfo: ExceptionInfo[BaseException]) -> None:
-        if hasattr(self, "fspath"):
+    def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback:
+        if hasattr(self, "path"):
             traceback = excinfo.traceback
-            ntraceback = traceback.cut(path=self.fspath)
+            ntraceback = traceback.cut(path=self.path)
             if ntraceback == traceback:
                 ntraceback = ntraceback.cut(excludepath=tracebackcutdir)
-            excinfo.traceback = ntraceback.filter()
+            return excinfo.traceback.filter(excinfo)
+        return excinfo.traceback
 
 
-def _check_initialpaths_for_relpath(session, fspath):
+def _check_initialpaths_for_relpath(session: "Session", path: Path) -> Optional[str]:
     for initial_path in session._initialpaths:
-        if fspath.common(initial_path) == initial_path:
-            return fspath.relto(initial_path)
+        if commonpath(path, initial_path) == initial_path:
+            rel = str(path.relative_to(initial_path))
+            return "" if rel == "." else rel
+    return None
 
 
 class FSCollector(Collector):
+    """Base class for filesystem collectors."""
+
     def __init__(
         self,
-        fspath: py.path.local,
-        parent=None,
+        fspath: Optional[LEGACY_PATH] = None,
+        path_or_parent: Optional[Union[Path, Node]] = None,
+        path: Optional[Path] = None,
+        name: Optional[str] = None,
+        parent: Optional[Node] = None,
         config: Optional[Config] = None,
         session: Optional["Session"] = None,
         nodeid: Optional[str] = None,
     ) -> None:
-        name = fspath.basename
-        if parent is not None:
-            rel = fspath.relto(parent.fspath)
-            if rel:
-                name = rel
-            name = name.replace(os.sep, SEP)
-        self.fspath = fspath
-
-        session = session or parent.session
+        if path_or_parent:
+            if isinstance(path_or_parent, Node):
+                assert parent is None
+                parent = cast(FSCollector, path_or_parent)
+            elif isinstance(path_or_parent, Path):
+                assert path is None
+                path = path_or_parent
+
+        path = _imply_path(type(self), path, fspath=fspath)
+        if name is None:
+            name = path.name
+            if parent is not None and parent.path != path:
+                try:
+                    rel = path.relative_to(parent.path)
+                except ValueError:
+                    pass
+                else:
+                    name = str(rel)
+                name = name.replace(os.sep, SEP)
+        self.path = path
+
+        if session is None:
+            assert parent is not None
+            session = parent.session
 
         if nodeid is None:
-            nodeid = self.fspath.relto(session.config.rootdir)
+            try:
+                nodeid = str(self.path.relative_to(session.config.rootpath))
+            except ValueError:
+                nodeid = _check_initialpaths_for_relpath(session, path)
 
-            if not nodeid:
-                nodeid = _check_initialpaths_for_relpath(session, fspath)
             if nodeid and os.sep != SEP:
                 nodeid = nodeid.replace(os.sep, SEP)
 
-        super().__init__(name, parent, config, session, nodeid=nodeid, fspath=fspath)
+        super().__init__(
+            name=name,
+            parent=parent,
+            config=config,
+            session=session,
+            nodeid=nodeid,
+            path=path,
+        )
 
     @classmethod
-    def from_parent(cls, parent, *, fspath, **kw):
+    def from_parent(
+        cls,
+        parent,
+        *,
+        fspath: Optional[LEGACY_PATH] = None,
+        path: Optional[Path] = None,
+        **kw,
+    ):
         """The public constructor."""
-        return super().from_parent(parent=parent, fspath=fspath, **kw)
+        return super().from_parent(parent=parent, fspath=fspath, path=path, **kw)
 
-    def gethookproxy(self, fspath: py.path.local):
+    def gethookproxy(self, fspath: "os.PathLike[str]"):
         warnings.warn(FSCOLLECTOR_GETHOOKPROXY_ISINITPATH, stacklevel=2)
         return self.session.gethookproxy(fspath)
 
-    def isinitpath(self, path: py.path.local) -> bool:
+    def isinitpath(self, path: Union[str, "os.PathLike[str]"]) -> bool:
         warnings.warn(FSCOLLECTOR_GETHOOKPROXY_ISINITPATH, stacklevel=2)
         return self.session.isinitpath(path)
 
@@ -537,7 +665,7 @@ class File(FSCollector):
 
 
 class Item(Node):
-    """A basic test invocation item.
+    """Base class of all test invocation items.
 
     Note that for a single function there might be multiple test invocation items.
     """
@@ -551,15 +679,64 @@ class Item(Node):
         config: Optional[Config] = None,
         session: Optional["Session"] = None,
         nodeid: Optional[str] = None,
+        **kw,
     ) -> None:
-        super().__init__(name, parent, config, session, nodeid=nodeid)
+        # The first two arguments are intentionally passed positionally,
+        # to keep plugins who define a node type which inherits from
+        # (pytest.Item, pytest.File) working (see issue #8435).
+        # They can be made kwargs when the deprecation above is done.
+        super().__init__(
+            name,
+            parent,
+            config=config,
+            session=session,
+            nodeid=nodeid,
+            **kw,
+        )
         self._report_sections: List[Tuple[str, str, str]] = []
 
         #: A list of tuples (name, value) that holds user defined properties
         #: for this test.
         self.user_properties: List[Tuple[str, object]] = []
 
+        self._check_item_and_collector_diamond_inheritance()
+
+    def _check_item_and_collector_diamond_inheritance(self) -> None:
+        """
+        Check if the current type inherits from both File and Collector
+        at the same time, emitting a warning accordingly (#8447).
+        """
+        cls = type(self)
+
+        # We inject an attribute in the type to avoid issuing this warning
+        # for the same class more than once, which is not helpful.
+        # It is a hack, but was deemed acceptable in order to avoid
+        # flooding the user in the common case.
+        attr_name = "_pytest_diamond_inheritance_warning_shown"
+        if getattr(cls, attr_name, False):
+            return
+        setattr(cls, attr_name, True)
+
+        problems = ", ".join(
+            base.__name__ for base in cls.__bases__ if issubclass(base, Collector)
+        )
+        if problems:
+            warnings.warn(
+                f"{cls.__name__} is an Item subclass and should not be a collector, "
+                f"however its bases {problems} are collectors.\n"
+                "Please split the Collectors and the Item into separate node types.\n"
+                "Pytest Doc example: https://docs.pytest.org/en/latest/example/nonpython.html\n"
+                "example pull request on a plugin: https://github.com/asmeurer/pytest-flakes/pull/40/",
+                PytestWarning,
+            )
+
     def runtest(self) -> None:
+        """Run the test case for this item.
+
+        Must be implemented by subclasses.
+
+        .. seealso:: :ref:`non-python tests`
+        """
         raise NotImplementedError("runtest must be implemented by Item subclass")
 
     def add_report_section(self, when: str, key: str, content: str) -> None:
@@ -579,13 +756,28 @@ class Item(Node):
         if content:
             self._report_sections.append((when, key, content))
 
-    def reportinfo(self) -> Tuple[Union[py.path.local, str], Optional[int], str]:
-        return self.fspath, None, ""
+    def reportinfo(self) -> Tuple[Union["os.PathLike[str]", str], Optional[int], str]:
+        """Get location information for this item for test reports.
+
+        Returns a tuple with three elements:
+
+        - The path of the test (default ``self.path``)
+        - The 0-based line number of the test (default ``None``)
+        - A name of the test to be shown (default ``""``)
+
+        .. seealso:: :ref:`non-python tests`
+        """
+        return self.path, None, ""
 
     @cached_property
     def location(self) -> Tuple[str, Optional[int], str]:
+        """
+        Returns a tuple of ``(relfspath, lineno, testname)`` for this item
+        where ``relfspath`` is file path relative to ``config.rootpath``
+        and lineno is a 0-based line number.
+        """
         location = self.reportinfo()
-        fspath = absolutepath(str(location[0]))
-        relfspath = self.session._node_location_to_relpath(fspath)
+        path = absolutepath(os.fspath(location[0]))
+        relfspath = self.session._node_location_to_relpath(path)
         assert type(location[2]) is str
         return (relfspath, location[1], location[2])
index bb8f99772ac9eb75e16a6e08ad9c6926409cdaba..273bd045fb6429c5ac8ce8af77eb1d5d074b0834 100644 (file)
@@ -1,39 +1,50 @@
 """Run testsuites written for nose."""
-from _pytest import python
-from _pytest import unittest
+import warnings
+
 from _pytest.config import hookimpl
+from _pytest.deprecated import NOSE_SUPPORT
+from _pytest.fixtures import getfixturemarker
 from _pytest.nodes import Item
+from _pytest.python import Function
+from _pytest.unittest import TestCaseFunction
 
 
 @hookimpl(trylast=True)
-def pytest_runtest_setup(item):
-    if is_potential_nosetest(item):
-        if not call_optional(item.obj, "setup"):
-            # Call module level setup if there is no object level one.
-            call_optional(item.parent.obj, "setup")
-        # XXX This implies we only call teardown when setup worked.
-        item.session._setupstate.addfinalizer((lambda: teardown_nose(item)), item)
-
-
-def teardown_nose(item):
-    if is_potential_nosetest(item):
-        if not call_optional(item.obj, "teardown"):
-            call_optional(item.parent.obj, "teardown")
-
-
-def is_potential_nosetest(item: Item) -> bool:
-    # Extra check needed since we do not do nose style setup/teardown
-    # on direct unittest style classes.
-    return isinstance(item, python.Function) and not isinstance(
-        item, unittest.TestCaseFunction
-    )
+def pytest_runtest_setup(item: Item) -> None:
+    if not isinstance(item, Function):
+        return
+    # Don't do nose style setup/teardown on direct unittest style classes.
+    if isinstance(item, TestCaseFunction):
+        return
+
+    # Capture the narrowed type of item for the teardown closure,
+    # see https://github.com/python/mypy/issues/2608
+    func = item
 
+    call_optional(func.obj, "setup", func.nodeid)
+    func.addfinalizer(lambda: call_optional(func.obj, "teardown", func.nodeid))
 
-def call_optional(obj, name):
+    # NOTE: Module- and class-level fixtures are handled in python.py
+    # with `pluginmanager.has_plugin("nose")` checks.
+    # It would have been nicer to implement them outside of core, but
+    # it's not straightforward.
+
+
+def call_optional(obj: object, name: str, nodeid: str) -> bool:
     method = getattr(obj, name, None)
-    isfixture = hasattr(method, "_pytestfixturefunction")
-    if method is not None and not isfixture and callable(method):
-        # If there's any problems allow the exception to raise rather than
-        # silently ignoring them.
-        method()
-        return True
+    if method is None:
+        return False
+    is_fixture = getfixturemarker(method) is not None
+    if is_fixture:
+        return False
+    if not callable(method):
+        return False
+    # Warn about deprecation of this plugin.
+    method_name = getattr(method, "__name__", str(method))
+    warnings.warn(
+        NOSE_SUPPORT.format(nodeid=nodeid, method=method_name, stage=name), stacklevel=2
+    )
+    # If there are any problems allow the exception to raise rather than
+    # silently ignoring it.
+    method()
+    return True
index 8f6203fd7fa64e525c0b545c8f2d5706c6edf1e8..1be97dda4ea2a791b956b56cdbfb6077183c3285 100644 (file)
@@ -1,17 +1,20 @@
 """Exception classes and constants handling test outcomes as well as
 functions creating them."""
 import sys
+import warnings
 from typing import Any
 from typing import Callable
 from typing import cast
+from typing import NoReturn
 from typing import Optional
 from typing import Type
 from typing import TypeVar
 
+from _pytest.deprecated import KEYWORD_MSG_ARG
+
 TYPE_CHECKING = False  # Avoid circular import through compat.
 
 if TYPE_CHECKING:
-    from typing import NoReturn
     from typing_extensions import Protocol
 else:
     # typing.Protocol is only available starting from Python 3.8. It is also
@@ -33,7 +36,7 @@ class OutcomeException(BaseException):
                 "Perhaps you meant to use a mark?"
             )
             raise TypeError(error_msg.format(type(self).__name__, type(msg).__name__))
-        BaseException.__init__(self, msg)
+        super().__init__(msg)
         self.msg = msg
         self.pytrace = pytrace
 
@@ -58,9 +61,14 @@ class Skipped(OutcomeException):
         msg: Optional[str] = None,
         pytrace: bool = True,
         allow_module_level: bool = False,
+        *,
+        _use_item_location: bool = False,
     ) -> None:
-        OutcomeException.__init__(self, msg=msg, pytrace=pytrace)
+        super().__init__(msg=msg, pytrace=pytrace)
         self.allow_module_level = allow_module_level
+        # If true, the skip location is reported as the item's location,
+        # instead of the place that raises the exception/calls skip().
+        self._use_item_location = _use_item_location
 
 
 class Failed(OutcomeException):
@@ -105,52 +113,125 @@ def _with_exception(exception_type: _ET) -> Callable[[_F], _WithException[_F, _E
 
 
 @_with_exception(Exit)
-def exit(msg: str, returncode: Optional[int] = None) -> "NoReturn":
+def exit(
+    reason: str = "", returncode: Optional[int] = None, *, msg: Optional[str] = None
+) -> NoReturn:
     """Exit testing process.
 
-    :param str msg: Message to display upon exit.
-    :param int returncode: Return code to be used when exiting pytest.
+    :param reason:
+        The message to show as the reason for exiting pytest.  reason has a default value
+        only because `msg` is deprecated.
+
+    :param returncode:
+        Return code to be used when exiting pytest.
+
+    :param msg:
+        Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead.
     """
     __tracebackhide__ = True
-    raise Exit(msg, returncode)
+    from _pytest.config import UsageError
+
+    if reason and msg:
+        raise UsageError(
+            "cannot pass reason and msg to exit(), `msg` is deprecated, use `reason`."
+        )
+    if not reason:
+        if msg is None:
+            raise UsageError("exit() requires a reason argument")
+        warnings.warn(KEYWORD_MSG_ARG.format(func="exit"), stacklevel=2)
+        reason = msg
+    raise Exit(reason, returncode)
 
 
 @_with_exception(Skipped)
-def skip(msg: str = "", *, allow_module_level: bool = False) -> "NoReturn":
+def skip(
+    reason: str = "", *, allow_module_level: bool = False, msg: Optional[str] = None
+) -> NoReturn:
     """Skip an executing test with the given message.
 
     This function should be called only during testing (setup, call or teardown) or
     during collection by using the ``allow_module_level`` flag.  This function can
     be called in doctests as well.
 
-    :param bool allow_module_level:
-        Allows this function to be called at module level, skipping the rest
-        of the module. Defaults to False.
+    :param reason:
+        The message to show the user as reason for the skip.
+
+    :param allow_module_level:
+        Allows this function to be called at module level.
+        Raising the skip exception at module level will stop
+        the execution of the module and prevent the collection of all tests in the module,
+        even those defined before the `skip` call.
+
+        Defaults to False.
+
+    :param msg:
+        Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead.
 
     .. note::
         It is better to use the :ref:`pytest.mark.skipif ref` marker when
         possible to declare a test to be skipped under certain conditions
         like mismatching platforms or dependencies.
-        Similarly, use the ``# doctest: +SKIP`` directive (see `doctest.SKIP
-        <https://docs.python.org/3/library/doctest.html#doctest.SKIP>`_)
+        Similarly, use the ``# doctest: +SKIP`` directive (see :py:data:`doctest.SKIP`)
         to skip a doctest statically.
     """
     __tracebackhide__ = True
-    raise Skipped(msg=msg, allow_module_level=allow_module_level)
+    reason = _resolve_msg_to_reason("skip", reason, msg)
+    raise Skipped(msg=reason, allow_module_level=allow_module_level)
 
 
 @_with_exception(Failed)
-def fail(msg: str = "", pytrace: bool = True) -> "NoReturn":
+def fail(reason: str = "", pytrace: bool = True, msg: Optional[str] = None) -> NoReturn:
     """Explicitly fail an executing test with the given message.
 
-    :param str msg:
+    :param reason:
         The message to show the user as reason for the failure.
-    :param bool pytrace:
+
+    :param pytrace:
         If False, msg represents the full failure information and no
         python traceback will be reported.
+
+    :param msg:
+        Same as ``reason``, but deprecated. Will be removed in a future version, use ``reason`` instead.
+    """
+    __tracebackhide__ = True
+    reason = _resolve_msg_to_reason("fail", reason, msg)
+    raise Failed(msg=reason, pytrace=pytrace)
+
+
+def _resolve_msg_to_reason(
+    func_name: str, reason: str, msg: Optional[str] = None
+) -> str:
+    """
+    Handles converting the deprecated msg parameter if provided into
+    reason, raising a deprecation warning.  This function will be removed
+    when the optional msg argument is removed from here in future.
+
+    :param str func_name:
+        The name of the offending function, this is formatted into the deprecation message.
+
+    :param str reason:
+        The reason= passed into either pytest.fail() or pytest.skip()
+
+    :param str msg:
+        The msg= passed into either pytest.fail() or pytest.skip().  This will
+        be converted into reason if it is provided to allow pytest.skip(msg=) or
+        pytest.fail(msg=) to continue working in the interim period.
+
+    :returns:
+        The value to use as reason.
+
     """
     __tracebackhide__ = True
-    raise Failed(msg=msg, pytrace=pytrace)
+    if msg is not None:
+        if reason:
+            from pytest import UsageError
+
+            raise UsageError(
+                f"Passing both ``reason`` and ``msg`` to pytest.{func_name}(...) is not permitted."
+            )
+        warnings.warn(KEYWORD_MSG_ARG.format(func=func_name), stacklevel=3)
+        reason = msg
+    return reason
 
 
 class XFailed(Failed):
@@ -158,11 +239,14 @@ class XFailed(Failed):
 
 
 @_with_exception(XFailed)
-def xfail(reason: str = "") -> "NoReturn":
+def xfail(reason: str = "") -> NoReturn:
     """Imperatively xfail an executing test or setup function with the given reason.
 
     This function should be called only during testing (setup, call or teardown).
 
+    :param reason:
+        The message to show the user as reason for the xfail.
+
     .. note::
         It is better to use the :ref:`pytest.mark.xfail ref` marker when
         possible to declare a test to be xfailed under certain conditions
@@ -178,12 +262,12 @@ def importorskip(
     """Import and return the requested module ``modname``, or skip the
     current test if the module cannot be imported.
 
-    :param str modname:
+    :param modname:
         The name of the module to import.
-    :param str minversion:
+    :param minversion:
         If given, the imported module's ``__version__`` attribute must be at
         least this minimal version, otherwise the test is still skipped.
-    :param str reason:
+    :param reason:
         If given, this reason is shown as the message when the module cannot
         be imported.
 
index 131873c174a6cb288034992c68fa46cb316a71dd..22c7a622373f5561273b424d180f5195d808fab3 100644 (file)
@@ -8,11 +8,11 @@ import pytest
 from _pytest.config import Config
 from _pytest.config import create_terminal_writer
 from _pytest.config.argparsing import Parser
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 from _pytest.terminal import TerminalReporter
 
 
-pastebinfile_key = StoreKey[IO[bytes]]()
+pastebinfile_key = StashKey[IO[bytes]]()
 
 
 def pytest_addoption(parser: Parser) -> None:
@@ -24,7 +24,7 @@ def pytest_addoption(parser: Parser) -> None:
         dest="pastebin",
         default=None,
         choices=["failed", "all"],
-        help="send failed|all info to bpaste.net pastebin service.",
+        help="Send failed|all info to bpaste.net pastebin service",
     )
 
 
@@ -37,26 +37,26 @@ def pytest_configure(config: Config) -> None:
         # when using pytest-xdist, for example.
         if tr is not None:
             # pastebin file will be UTF-8 encoded binary file.
-            config._store[pastebinfile_key] = tempfile.TemporaryFile("w+b")
+            config.stash[pastebinfile_key] = tempfile.TemporaryFile("w+b")
             oldwrite = tr._tw.write
 
             def tee_write(s, **kwargs):
                 oldwrite(s, **kwargs)
                 if isinstance(s, str):
                     s = s.encode("utf-8")
-                config._store[pastebinfile_key].write(s)
+                config.stash[pastebinfile_key].write(s)
 
             tr._tw.write = tee_write
 
 
 def pytest_unconfigure(config: Config) -> None:
-    if pastebinfile_key in config._store:
-        pastebinfile = config._store[pastebinfile_key]
+    if pastebinfile_key in config.stash:
+        pastebinfile = config.stash[pastebinfile_key]
         # Get terminal contents and delete file.
         pastebinfile.seek(0)
         sessionlog = pastebinfile.read()
         pastebinfile.close()
-        del config._store[pastebinfile_key]
+        del config.stash[pastebinfile_key]
         # Undo our patching in the terminal reporter.
         tr = config.pluginmanager.getplugin("terminalreporter")
         del tr._tw.__dict__["write"]
@@ -77,7 +77,7 @@ def create_new_paste(contents: Union[str, bytes]) -> str:
     from urllib.parse import urlencode
 
     params = {"code": contents, "lexer": "text", "expiry": "1week"}
-    url = "https://bpaste.net"
+    url = "https://bpa.st"
     try:
         response: str = (
             urlopen(url, data=urlencode(params).encode("ascii")).read().decode("utf-8")
@@ -86,7 +86,7 @@ def create_new_paste(contents: Union[str, bytes]) -> str:
         return "bad response: %s" % exc_info
     m = re.search(r'href="/raw/(\w+)"', response)
     if m:
-        return "{}/show/{}".format(url, m.group(1))
+        return f"{url}/show/{m.group(1)}"
     else:
         return "bad response: invalid format ('" + response + "')"
 
index 8875a28f84b62fe765b210a20c81c153fd0779bf..c2f8535f5f56289efd31aed019cd71771f789132 100644 (file)
@@ -6,6 +6,7 @@ import itertools
 import os
 import shutil
 import sys
+import types
 import uuid
 import warnings
 from enum import Enum
@@ -23,15 +24,17 @@ from pathlib import PurePath
 from posixpath import sep as posix_sep
 from types import ModuleType
 from typing import Callable
+from typing import Dict
 from typing import Iterable
 from typing import Iterator
+from typing import List
 from typing import Optional
 from typing import Set
+from typing import Tuple
+from typing import Type
 from typing import TypeVar
 from typing import Union
 
-import py
-
 from _pytest.compat import assert_never
 from _pytest.outcomes import skip
 from _pytest.warning_types import PytestWarning
@@ -64,28 +67,33 @@ def get_lock_path(path: _AnyPurePath) -> _AnyPurePath:
     return path.joinpath(".lock")
 
 
-def ensure_reset_dir(path: Path) -> None:
-    """Ensure the given path is an empty directory."""
-    if path.exists():
-        rm_rf(path)
-    path.mkdir()
-
-
-def on_rm_rf_error(func, path: str, exc, *, start_path: Path) -> bool:
+def on_rm_rf_error(
+    func,
+    path: str,
+    excinfo: Union[
+        BaseException,
+        Tuple[Type[BaseException], BaseException, Optional[types.TracebackType]],
+    ],
+    *,
+    start_path: Path,
+) -> bool:
     """Handle known read-only errors during rmtree.
 
     The returned value is used only by our own tests.
     """
-    exctype, excvalue = exc[:2]
+    if isinstance(excinfo, BaseException):
+        exc = excinfo
+    else:
+        exc = excinfo[1]
 
     # Another process removed the file in the middle of the "rm_rf" (xdist for example).
     # More context: https://github.com/pytest-dev/pytest/issues/5974#issuecomment-543799018
-    if isinstance(excvalue, FileNotFoundError):
+    if isinstance(exc, FileNotFoundError):
         return False
 
-    if not isinstance(excvalue, PermissionError):
+    if not isinstance(exc, PermissionError):
         warnings.warn(
-            PytestWarning(f"(rm_rf) error removing {path}\n{exctype}: {excvalue}")
+            PytestWarning(f"(rm_rf) error removing {path}\n{type(exc)}: {exc}")
         )
         return False
 
@@ -94,7 +102,7 @@ def on_rm_rf_error(func, path: str, exc, *, start_path: Path) -> bool:
             warnings.warn(
                 PytestWarning(
                     "(rm_rf) unknown function {} when removing {}:\n{}: {}".format(
-                        func, path, exctype, excvalue
+                        func, path, type(exc), exc
                     )
                 )
             )
@@ -157,7 +165,10 @@ def rm_rf(path: Path) -> None:
     are read-only."""
     path = ensure_extended_length_path(path)
     onerror = partial(on_rm_rf_error, start_path=path)
-    shutil.rmtree(str(path), onerror=onerror)
+    if sys.version_info >= (3, 12):
+        shutil.rmtree(str(path), onexc=onerror)
+    else:
+        shutil.rmtree(str(path), onerror=onerror)
 
 
 def find_prefixed(root: Path, prefix: str) -> Iterator[Path]:
@@ -214,7 +225,7 @@ def _force_symlink(
         pass
 
 
-def make_numbered_dir(root: Path, prefix: str) -> Path:
+def make_numbered_dir(root: Path, prefix: str, mode: int = 0o700) -> Path:
     """Create a directory with an increased number as suffix for the given prefix."""
     for i in range(10):
         # try up to 10 times to create the folder
@@ -222,7 +233,7 @@ def make_numbered_dir(root: Path, prefix: str) -> Path:
         new_number = max_existing + 1
         new_path = root.joinpath(f"{prefix}{new_number}")
         try:
-            new_path.mkdir()
+            new_path.mkdir(mode=mode)
         except Exception:
             pass
         else:
@@ -343,26 +354,43 @@ def cleanup_candidates(root: Path, prefix: str, keep: int) -> Iterator[Path]:
             yield path
 
 
+def cleanup_dead_symlinks(root: Path):
+    for left_dir in root.iterdir():
+        if left_dir.is_symlink():
+            if not left_dir.resolve().exists():
+                left_dir.unlink()
+
+
 def cleanup_numbered_dir(
     root: Path, prefix: str, keep: int, consider_lock_dead_if_created_before: float
 ) -> None:
     """Cleanup for lock driven numbered directories."""
+    if not root.exists():
+        return
     for path in cleanup_candidates(root, prefix, keep):
         try_cleanup(path, consider_lock_dead_if_created_before)
     for path in root.glob("garbage-*"):
         try_cleanup(path, consider_lock_dead_if_created_before)
 
+    cleanup_dead_symlinks(root)
+
 
 def make_numbered_dir_with_cleanup(
-    root: Path, prefix: str, keep: int, lock_timeout: float
+    root: Path,
+    prefix: str,
+    keep: int,
+    lock_timeout: float,
+    mode: int,
 ) -> Path:
     """Create a numbered dir with a cleanup lock and remove old ones."""
     e = None
     for i in range(10):
         try:
-            p = make_numbered_dir(root, prefix)
-            lock_path = create_cleanup_lock(p)
-            register_cleanup_lock_removal(lock_path)
+            p = make_numbered_dir(root, prefix, mode)
+            # Only lock the current dir when keep is not 0
+            if keep != 0:
+                lock_path = create_cleanup_lock(p)
+                register_cleanup_lock_removal(lock_path)
         except Exception as exc:
             e = exc
         else:
@@ -389,7 +417,7 @@ def resolve_from_str(input: str, rootpath: Path) -> Path:
         return rootpath.joinpath(input)
 
 
-def fnmatch_ex(pattern: str, path) -> bool:
+def fnmatch_ex(pattern: str, path: Union[str, "os.PathLike[str]"]) -> bool:
     """A port of FNMatcher from py.path.common which works with PurePath() instances.
 
     The difference between this algorithm and PurePath.match() is that the
@@ -456,9 +484,10 @@ class ImportPathMismatchError(ImportError):
 
 
 def import_path(
-    p: Union[str, py.path.local, Path],
+    p: Union[str, "os.PathLike[str]"],
     *,
     mode: Union[str, ImportMode] = ImportMode.prepend,
+    root: Path,
 ) -> ModuleType:
     """Import and return a module from the given path, which can be a file (a module) or
     a directory (a package).
@@ -467,14 +496,19 @@ def import_path(
 
     * `mode == ImportMode.prepend`: the directory containing the module (or package, taking
       `__init__.py` files into account) will be put at the *start* of `sys.path` before
-      being imported with `__import__.
+      being imported with `importlib.import_module`.
 
     * `mode == ImportMode.append`: same as `prepend`, but the directory will be appended
       to the end of `sys.path`, if not already in `sys.path`.
 
     * `mode == ImportMode.importlib`: uses more fine control mechanisms provided by `importlib`
-      to import the module, which avoids having to use `__import__` and muck with `sys.path`
-      at all. It effectively allows having same-named test modules in different places.
+      to import the module, which avoids having to muck with `sys.path` at all. It effectively
+      allows having same-named test modules in different places.
+
+    :param root:
+        Used as an anchor when mode == ImportMode.importlib to obtain
+        a unique name for the module being imported so it can safely be stored
+        into ``sys.modules``.
 
     :raises ImportPathMismatchError:
         If after importing the given `path` and the module `__file__`
@@ -482,13 +516,15 @@ def import_path(
     """
     mode = ImportMode(mode)
 
-    path = Path(str(p))
+    path = Path(p)
 
     if not path.exists():
         raise ImportError(path)
 
     if mode is ImportMode.importlib:
-        module_name = path.stem
+        module_name = module_name_from_path(path, root)
+        with contextlib.suppress(KeyError):
+            return sys.modules[module_name]
 
         for meta_importer in sys.meta_path:
             spec = meta_importer.find_spec(module_name, [str(path.parent)])
@@ -498,11 +534,11 @@ def import_path(
             spec = importlib.util.spec_from_file_location(module_name, str(path))
 
         if spec is None:
-            raise ImportError(
-                "Can't find module {} at location {}".format(module_name, str(path))
-            )
+            raise ImportError(f"Can't find module {module_name} at location {path}")
         mod = importlib.util.module_from_spec(spec)
+        sys.modules[module_name] = mod
         spec.loader.exec_module(mod)  # type: ignore[union-attr]
+        insert_missing_modules(sys.modules, module_name)
         return mod
 
     pkg_path = resolve_package_path(path)
@@ -537,10 +573,13 @@ def import_path(
     ignore = os.environ.get("PY_IGNORE_IMPORTMISMATCH", "")
     if ignore != "1":
         module_file = mod.__file__
+        if module_file is None:
+            raise ImportPathMismatchError(module_name, module_file, path)
+
         if module_file.endswith((".pyc", ".pyo")):
             module_file = module_file[:-1]
-        if module_file.endswith(os.path.sep + "__init__.py"):
-            module_file = module_file[: -(len(os.path.sep + "__init__.py"))]
+        if module_file.endswith(os.sep + "__init__.py"):
+            module_file = module_file[: -(len(os.sep + "__init__.py"))]
 
         try:
             is_same = _is_same(str(path), module_file)
@@ -560,13 +599,79 @@ if sys.platform.startswith("win"):
     def _is_same(f1: str, f2: str) -> bool:
         return Path(f1) == Path(f2) or os.path.samefile(f1, f2)
 
-
 else:
 
     def _is_same(f1: str, f2: str) -> bool:
         return os.path.samefile(f1, f2)
 
 
+def module_name_from_path(path: Path, root: Path) -> str:
+    """
+    Return a dotted module name based on the given path, anchored on root.
+
+    For example: path="projects/src/tests/test_foo.py" and root="/projects", the
+    resulting module name will be "src.tests.test_foo".
+    """
+    path = path.with_suffix("")
+    try:
+        relative_path = path.relative_to(root)
+    except ValueError:
+        # If we can't get a relative path to root, use the full path, except
+        # for the first part ("d:\\" or "/" depending on the platform, for example).
+        path_parts = path.parts[1:]
+    else:
+        # Use the parts for the relative path to the root path.
+        path_parts = relative_path.parts
+
+    # Module name for packages do not contain the __init__ file, unless
+    # the `__init__.py` file is at the root.
+    if len(path_parts) >= 2 and path_parts[-1] == "__init__":
+        path_parts = path_parts[:-1]
+
+    return ".".join(path_parts)
+
+
+def insert_missing_modules(modules: Dict[str, ModuleType], module_name: str) -> None:
+    """
+    Used by ``import_path`` to create intermediate modules when using mode=importlib.
+
+    When we want to import a module as "src.tests.test_foo" for example, we need
+    to create empty modules "src" and "src.tests" after inserting "src.tests.test_foo",
+    otherwise "src.tests.test_foo" is not importable by ``__import__``.
+    """
+    module_parts = module_name.split(".")
+    child_module: Union[ModuleType, None] = None
+    module: Union[ModuleType, None] = None
+    child_name: str = ""
+    while module_name:
+        if module_name not in modules:
+            try:
+                # If sys.meta_path is empty, calling import_module will issue
+                # a warning and raise ModuleNotFoundError. To avoid the
+                # warning, we check sys.meta_path explicitly and raise the error
+                # ourselves to fall back to creating a dummy module.
+                if not sys.meta_path:
+                    raise ModuleNotFoundError
+                module = importlib.import_module(module_name)
+            except ModuleNotFoundError:
+                module = ModuleType(
+                    module_name,
+                    doc="Empty module created by pytest's importmode=importlib.",
+                )
+        else:
+            module = modules[module_name]
+        if child_module:
+            # Add child attribute to the parent that can reference the child
+            # modules.
+            if not hasattr(module, child_name):
+                setattr(module, child_name, child_module)
+                modules[module_name] = module
+        # Keep track of the child module while moving up the tree.
+        child_module, child_name = module, module_name.rpartition(".")[-1]
+        module_parts.pop(-1)
+        module_name = ".".join(module_parts)
+
+
 def resolve_package_path(path: Path) -> Optional[Path]:
     """Return the Python package path by looking for the last
     directory upwards which still contains an __init__.py.
@@ -584,30 +689,38 @@ def resolve_package_path(path: Path) -> Optional[Path]:
     return result
 
 
+def scandir(path: Union[str, "os.PathLike[str]"]) -> List["os.DirEntry[str]"]:
+    """Scan a directory recursively, in breadth-first order.
+
+    The returned entries are sorted.
+    """
+    entries = []
+    with os.scandir(path) as s:
+        # Skip entries with symlink loops and other brokenness, so the caller
+        # doesn't have to deal with it.
+        for entry in s:
+            try:
+                entry.is_file()
+            except OSError as err:
+                if _ignore_error(err):
+                    continue
+                raise
+            entries.append(entry)
+    entries.sort(key=lambda entry: entry.name)
+    return entries
+
+
 def visit(
-    path: str, recurse: Callable[["os.DirEntry[str]"], bool]
+    path: Union[str, "os.PathLike[str]"], recurse: Callable[["os.DirEntry[str]"], bool]
 ) -> Iterator["os.DirEntry[str]"]:
     """Walk a directory recursively, in breadth-first order.
 
+    The `recurse` predicate determines whether a directory is recursed.
+
     Entries at each directory level are sorted.
     """
-
-    # Skip entries with symlink loops and other brokenness, so the caller doesn't
-    # have to deal with it.
-    entries = []
-    for entry in os.scandir(path):
-        try:
-            entry.is_file()
-        except OSError as err:
-            if _ignore_error(err):
-                continue
-            raise
-        entries.append(entry)
-
-    entries.sort(key=lambda entry: entry.name)
-
+    entries = scandir(path)
     yield from entries
-
     for entry in entries:
         if entry.is_dir() and recurse(entry):
             yield from visit(entry.path, recurse)
@@ -642,6 +755,8 @@ def bestrelpath(directory: Path, dest: Path) -> str:
 
     If no such path can be determined, returns dest.
     """
+    assert isinstance(directory, Path)
+    assert isinstance(dest, Path)
     if dest == directory:
         return os.curdir
     # Find the longest common directory.
@@ -659,3 +774,31 @@ def bestrelpath(directory: Path, dest: Path) -> str:
         # Forward from base to dest.
         *reldest.parts,
     )
+
+
+# Originates from py. path.local.copy(), with siginficant trims and adjustments.
+# TODO(py38): Replace with shutil.copytree(..., symlinks=True, dirs_exist_ok=True)
+def copytree(source: Path, target: Path) -> None:
+    """Recursively copy a source directory to target."""
+    assert source.is_dir()
+    for entry in visit(source, recurse=lambda entry: not entry.is_symlink()):
+        x = Path(entry)
+        relpath = x.relative_to(source)
+        newx = target / relpath
+        newx.parent.mkdir(exist_ok=True)
+        if x.is_symlink():
+            newx.symlink_to(os.readlink(x))
+        elif x.is_file():
+            shutil.copyfile(x, newx)
+        elif x.is_dir():
+            newx.mkdir(exist_ok=True)
+
+
+def safe_exists(p: Path) -> bool:
+    """Like Path.exists(), but account for input arguments that might be too long (#11394)."""
+    try:
+        return p.exists()
+    except (ValueError, OSError):
+        # ValueError: stat: path too long for Windows
+        # OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect
+        return False
index 6833eb02149d129c870d8e9fa9aa81149c796a9c..cdfc2c04ae1ed50ddbcf4836c378036c4928552a 100644 (file)
@@ -6,6 +6,7 @@ import collections.abc
 import contextlib
 import gc
 import importlib
+import locale
 import os
 import platform
 import re
@@ -20,6 +21,7 @@ from typing import Any
 from typing import Callable
 from typing import Dict
 from typing import Generator
+from typing import IO
 from typing import Iterable
 from typing import List
 from typing import Optional
@@ -32,8 +34,6 @@ from typing import TYPE_CHECKING
 from typing import Union
 from weakref import WeakKeyDictionary
 
-import attr
-import py
 from iniconfig import IniConfig
 from iniconfig import SectionWrapper
 
@@ -41,6 +41,8 @@ from _pytest import timing
 from _pytest._code import Source
 from _pytest.capture import _get_multicapture
 from _pytest.compat import final
+from _pytest.compat import NOTSET
+from _pytest.compat import NotSetType
 from _pytest.config import _PluggyPlugin
 from _pytest.config import Config
 from _pytest.config import ExitCode
@@ -58,13 +60,17 @@ from _pytest.nodes import Item
 from _pytest.outcomes import fail
 from _pytest.outcomes import importorskip
 from _pytest.outcomes import skip
+from _pytest.pathlib import bestrelpath
+from _pytest.pathlib import copytree
 from _pytest.pathlib import make_numbered_dir
 from _pytest.reports import CollectReport
 from _pytest.reports import TestReport
 from _pytest.tmpdir import TempPathFactory
 from _pytest.warning_types import PytestWarning
 
+
 if TYPE_CHECKING:
+    from typing_extensions import Final
     from typing_extensions import Literal
 
     import pexpect
@@ -84,7 +90,7 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         dest="lsof",
         default=False,
-        help="run FD checks if lsof is available",
+        help="Run FD checks if lsof is available",
     )
 
     parser.addoption(
@@ -93,13 +99,13 @@ def pytest_addoption(parser: Parser) -> None:
         dest="runpytest",
         choices=("inprocess", "subprocess"),
         help=(
-            "run pytest sub runs in tests using an 'inprocess' "
+            "Run pytest sub runs in tests using an 'inprocess' "
             "or 'subprocess' (python -m main) method"
         ),
     )
 
     parser.addini(
-        "pytester_example_dir", help="directory to take the pytester example files from"
+        "pytester_example_dir", help="Directory to take the pytester example files from"
     )
 
 
@@ -123,7 +129,8 @@ class LsofFdLeakChecker:
             stdout=subprocess.PIPE,
             stderr=subprocess.DEVNULL,
             check=True,
-            universal_newlines=True,
+            text=True,
+            encoding=locale.getpreferredencoding(False),
         ).stdout
 
         def isopen(line: str) -> bool:
@@ -207,7 +214,20 @@ def get_public_names(values: Iterable[str]) -> List[str]:
     return [x for x in values if x[0] != "_"]
 
 
-class ParsedCall:
+@final
+class RecordedHookCall:
+    """A recorded call to a hook.
+
+    The arguments to the hook call are set as attributes.
+    For example:
+
+    .. code-block:: python
+
+        calls = hook_recorder.getcalls("pytest_runtest_setup")
+        # Suppose pytest_runtest_setup was called once with `item=an_item`.
+        assert calls[0].item is an_item
+    """
+
     def __init__(self, name: str, kwargs) -> None:
         self.__dict__.update(kwargs)
         self._name = name
@@ -215,7 +235,7 @@ class ParsedCall:
     def __repr__(self) -> str:
         d = self.__dict__.copy()
         del d["_name"]
-        return f"<ParsedCall {self._name!r}(**{d!r})>"
+        return f"<RecordedHookCall {self._name!r}(**{d!r})>"
 
     if TYPE_CHECKING:
         # The class has undetermined attributes, this tells mypy about it.
@@ -223,20 +243,27 @@ class ParsedCall:
             ...
 
 
+@final
 class HookRecorder:
     """Record all hooks called in a plugin manager.
 
+    Hook recorders are created by :class:`Pytester`.
+
     This wraps all the hook calls in the plugin manager, recording each call
     before propagating the normal calls.
     """
 
-    def __init__(self, pluginmanager: PytestPluginManager) -> None:
+    def __init__(
+        self, pluginmanager: PytestPluginManager, *, _ispytest: bool = False
+    ) -> None:
+        check_ispytest(_ispytest)
+
         self._pluginmanager = pluginmanager
-        self.calls: List[ParsedCall] = []
+        self.calls: List[RecordedHookCall] = []
         self.ret: Optional[Union[int, ExitCode]] = None
 
         def before(hook_name: str, hook_impls, kwargs) -> None:
-            self.calls.append(ParsedCall(hook_name, kwargs))
+            self.calls.append(RecordedHookCall(hook_name, kwargs))
 
         def after(outcome, hook_name: str, hook_impls, kwargs) -> None:
             pass
@@ -246,7 +273,8 @@ class HookRecorder:
     def finish_recording(self) -> None:
         self._undo_wrapping()
 
-    def getcalls(self, names: Union[str, Iterable[str]]) -> List[ParsedCall]:
+    def getcalls(self, names: Union[str, Iterable[str]]) -> List[RecordedHookCall]:
+        """Get all recorded calls to hooks with the given names (or name)."""
         if isinstance(names, str):
             names = names.split()
         return [call for call in self.calls if call._name in names]
@@ -272,7 +300,7 @@ class HookRecorder:
             else:
                 fail(f"could not find {name!r} check {check!r}")
 
-    def popcall(self, name: str) -> ParsedCall:
+    def popcall(self, name: str) -> RecordedHookCall:
         __tracebackhide__ = True
         for i, call in enumerate(self.calls):
             if call._name == name:
@@ -282,7 +310,7 @@ class HookRecorder:
         lines.extend(["  %s" % x for x in self.calls])
         fail("\n".join(lines))
 
-    def getcall(self, name: str) -> ParsedCall:
+    def getcall(self, name: str) -> RecordedHookCall:
         values = self.getcalls(name)
         assert len(values) == 1, (name, values)
         return values[0]
@@ -291,13 +319,15 @@ class HookRecorder:
 
     @overload
     def getreports(
-        self, names: "Literal['pytest_collectreport']",
+        self,
+        names: "Literal['pytest_collectreport']",
     ) -> Sequence[CollectReport]:
         ...
 
     @overload
     def getreports(
-        self, names: "Literal['pytest_runtest_logreport']",
+        self,
+        names: "Literal['pytest_runtest_logreport']",
     ) -> Sequence[TestReport]:
         ...
 
@@ -354,13 +384,15 @@ class HookRecorder:
 
     @overload
     def getfailures(
-        self, names: "Literal['pytest_collectreport']",
+        self,
+        names: "Literal['pytest_collectreport']",
     ) -> Sequence[CollectReport]:
         ...
 
     @overload
     def getfailures(
-        self, names: "Literal['pytest_runtest_logreport']",
+        self,
+        names: "Literal['pytest_runtest_logreport']",
     ) -> Sequence[TestReport]:
         ...
 
@@ -419,7 +451,10 @@ class HookRecorder:
 
         outcomes = self.listoutcomes()
         assertoutcome(
-            outcomes, passed=passed, skipped=skipped, failed=failed,
+            outcomes,
+            passed=passed,
+            skipped=skipped,
+            failed=failed,
         )
 
     def clear(self) -> None:
@@ -444,7 +479,9 @@ def LineMatcher_fixture(request: FixtureRequest) -> Type["LineMatcher"]:
 
 
 @fixture
-def pytester(request: FixtureRequest, tmp_path_factory: TempPathFactory) -> "Pytester":
+def pytester(
+    request: FixtureRequest, tmp_path_factory: TempPathFactory, monkeypatch: MonkeyPatch
+) -> "Pytester":
     """
     Facilities to write tests/configuration files, execute pytest in isolation, and match
     against expected output, perfect for black-box testing of pytest plugins.
@@ -455,18 +492,7 @@ def pytester(request: FixtureRequest, tmp_path_factory: TempPathFactory) -> "Pyt
     It is particularly useful for testing plugins. It is similar to the :fixture:`tmp_path`
     fixture but provides methods which aid in testing pytest itself.
     """
-    return Pytester(request, tmp_path_factory, _ispytest=True)
-
-
-@fixture
-def testdir(pytester: "Pytester") -> "Testdir":
-    """
-    Identical to :fixture:`pytester`, and provides an instance whose methods return
-    legacy ``py.path.local`` objects instead when applicable.
-
-    New code should avoid using :fixture:`testdir` in favor of :fixture:`pytester`.
-    """
-    return Testdir(pytester, _ispytest=True)
+    return Pytester(request, tmp_path_factory, monkeypatch, _ispytest=True)
 
 
 @fixture
@@ -493,8 +519,9 @@ rex_session_duration = re.compile(r"\d+\.\d\ds")
 rex_outcome = re.compile(r"(\d+) (\w+)")
 
 
+@final
 class RunResult:
-    """The result of running a command."""
+    """The result of running a command from :class:`~pytest.Pytester`."""
 
     def __init__(
         self,
@@ -513,13 +540,13 @@ class RunResult:
         self.errlines = errlines
         """List of lines captured from stderr."""
         self.stdout = LineMatcher(outlines)
-        """:class:`LineMatcher` of stdout.
+        """:class:`~pytest.LineMatcher` of stdout.
 
-        Use e.g. :func:`str(stdout) <LineMatcher.__str__()>` to reconstruct stdout, or the commonly used
-        :func:`stdout.fnmatch_lines() <LineMatcher.fnmatch_lines()>` method.
+        Use e.g. :func:`str(stdout) <pytest.LineMatcher.__str__()>` to reconstruct stdout, or the commonly used
+        :func:`stdout.fnmatch_lines() <pytest.LineMatcher.fnmatch_lines()>` method.
         """
         self.stderr = LineMatcher(errlines)
-        """:class:`LineMatcher` of stderr."""
+        """:class:`~pytest.LineMatcher` of stderr."""
         self.duration = duration
         """Duration in seconds."""
 
@@ -573,9 +600,15 @@ class RunResult:
         errors: int = 0,
         xpassed: int = 0,
         xfailed: int = 0,
+        warnings: Optional[int] = None,
+        deselected: Optional[int] = None,
     ) -> None:
-        """Assert that the specified outcomes appear with the respective
-        numbers (0 means it didn't occur) in the text output from a test run."""
+        """
+        Assert that the specified outcomes appear with the respective
+        numbers (0 means it didn't occur) in the text output from a test run.
+
+        ``warnings`` and ``deselected`` are only checked if not None.
+        """
         __tracebackhide__ = True
         from _pytest.pytester_assertions import assert_outcomes
 
@@ -588,6 +621,8 @@ class RunResult:
             errors=errors,
             xpassed=xpassed,
             xfailed=xfailed,
+            warnings=warnings,
+            deselected=deselected,
         )
 
 
@@ -628,22 +663,12 @@ class Pytester:
     against expected output, perfect for black-box testing of pytest plugins.
 
     It attempts to isolate the test run from external factors as much as possible, modifying
-    the current working directory to ``path`` and environment variables during initialization.
-
-    Attributes:
-
-    :ivar Path path: temporary directory path used to create files/run tests from, etc.
-
-    :ivar plugins:
-       A list of plugins to use with :py:meth:`parseconfig` and
-       :py:meth:`runpytest`.  Initially this is an empty list but plugins can
-       be added to the list.  The type of items to add to the list depends on
-       the method using them so refer to them for details.
+    the current working directory to :attr:`path` and environment variables during initialization.
     """
 
     __test__ = False
 
-    CLOSE_STDIN = object
+    CLOSE_STDIN: "Final" = NOTSET
 
     class TimeoutExpired(Exception):
         pass
@@ -652,6 +677,7 @@ class Pytester:
         self,
         request: FixtureRequest,
         tmp_path_factory: TempPathFactory,
+        monkeypatch: MonkeyPatch,
         *,
         _ispytest: bool = False,
     ) -> None:
@@ -659,13 +685,17 @@ class Pytester:
         self._request = request
         self._mod_collections: WeakKeyDictionary[
             Collector, List[Union[Item, Collector]]
-        ] = (WeakKeyDictionary())
+        ] = WeakKeyDictionary()
         if request.function:
             name: str = request.function.__name__
         else:
             name = request.node.name
         self._name = name
         self._path: Path = tmp_path_factory.mktemp(name, numbered=True)
+        #: A list of plugins to use with :py:meth:`parseconfig` and
+        #: :py:meth:`runpytest`.  Initially this is an empty list but plugins can
+        #: be added to the list.  The type of items to add to the list depends on
+        #: the method using them so refer to them for details.
         self.plugins: List[Union[str, _PluggyPlugin]] = []
         self._cwd_snapshot = CwdSnapshot()
         self._sys_path_snapshot = SysPathsSnapshot()
@@ -675,7 +705,7 @@ class Pytester:
         self._method = self._request.config.getoption("--runpytest")
         self._test_tmproot = tmp_path_factory.mktemp(f"tmp-{name}", numbered=True)
 
-        self._monkeypatch = mp = MonkeyPatch()
+        self._monkeypatch = mp = monkeypatch
         mp.setenv("PYTEST_DEBUG_TEMPROOT", str(self._test_tmproot))
         # Ensure no unexpected caching via tox.
         mp.delenv("TOX_ENV_DIR", raising=False)
@@ -690,7 +720,7 @@ class Pytester:
 
     @property
     def path(self) -> Path:
-        """Temporary directory where files are created and pytest is executed."""
+        """Temporary directory path used to create files/run tests from, etc."""
         return self._path
 
     def __repr__(self) -> str:
@@ -707,7 +737,6 @@ class Pytester:
         self._sys_modules_snapshot.restore()
         self._sys_path_snapshot.restore()
         self._cwd_snapshot.restore()
-        self._monkeypatch.undo()
 
     def __take_sys_modules_snapshot(self) -> SysModulesSnapshot:
         # Some zope modules used by twisted-related tests keep internal state
@@ -722,8 +751,8 @@ class Pytester:
         return SysModulesSnapshot(preserve=preserve_module)
 
     def make_hook_recorder(self, pluginmanager: PytestPluginManager) -> HookRecorder:
-        """Create a new :py:class:`HookRecorder` for a PluginManager."""
-        pluginmanager.reprec = reprec = HookRecorder(pluginmanager)
+        """Create a new :class:`HookRecorder` for a :class:`PytestPluginManager`."""
+        pluginmanager.reprec = reprec = HookRecorder(pluginmanager, _ispytest=True)  # type: ignore[attr-defined]
         self._request.addfinalizer(reprec.finish_recording)
         return reprec
 
@@ -743,6 +772,11 @@ class Pytester:
     ) -> Path:
         items = list(files.items())
 
+        if ext and not ext.startswith("."):
+            raise ValueError(
+                f"pytester.makefile expects a file extension, try .{ext} instead of {ext}"
+            )
+
         def to_text(s: Union[Any, bytes]) -> str:
             return s.decode(encoding) if isinstance(s, bytes) else str(s)
 
@@ -764,9 +798,9 @@ class Pytester:
         return ret
 
     def makefile(self, ext: str, *args: str, **kwargs: str) -> Path:
-        r"""Create new file(s) in the test directory.
+        r"""Create new text file(s) in the test directory.
 
-        :param str ext:
+        :param ext:
             The extension the file(s) should use, including the dot, e.g. `.py`.
         :param args:
             All args are treated as strings and joined using newlines.
@@ -775,6 +809,8 @@ class Pytester:
         :param kwargs:
             Each keyword is the name of a file, while the value of it will
             be written as contents of the file.
+        :returns:
+            The first created file.
 
         Examples:
 
@@ -784,15 +820,29 @@ class Pytester:
 
             pytester.makefile(".ini", pytest="[pytest]\naddopts=-rs\n")
 
+        To create binary files, use :meth:`pathlib.Path.write_bytes` directly:
+
+        .. code-block:: python
+
+            filename = pytester.path.joinpath("foo.bin")
+            filename.write_bytes(b"...")
         """
         return self._makefile(ext, args, kwargs)
 
     def makeconftest(self, source: str) -> Path:
-        """Write a contest.py file with 'source' as contents."""
+        """Write a contest.py file.
+
+        :param source: The contents.
+        :returns: The conftest.py file.
+        """
         return self.makepyfile(conftest=source)
 
     def makeini(self, source: str) -> Path:
-        """Write a tox.ini file with 'source' as contents."""
+        """Write a tox.ini file.
+
+        :param source: The contents.
+        :returns: The tox.ini file.
+        """
         return self.makefile(".ini", tox=source)
 
     def getinicfg(self, source: str) -> SectionWrapper:
@@ -801,7 +851,10 @@ class Pytester:
         return IniConfig(str(p))["pytest"]
 
     def makepyprojecttoml(self, source: str) -> Path:
-        """Write a pyproject.toml file with 'source' as contents.
+        """Write a pyproject.toml file.
+
+        :param source: The contents.
+        :returns: The pyproject.ini file.
 
         .. versionadded:: 6.0
         """
@@ -850,23 +903,32 @@ class Pytester:
     def syspathinsert(
         self, path: Optional[Union[str, "os.PathLike[str]"]] = None
     ) -> None:
-        """Prepend a directory to sys.path, defaults to :py:attr:`tmpdir`.
+        """Prepend a directory to sys.path, defaults to :attr:`path`.
 
         This is undone automatically when this object dies at the end of each
         test.
+
+        :param path:
+            The path.
         """
         if path is None:
             path = self.path
 
         self._monkeypatch.syspath_prepend(str(path))
 
-    def mkdir(self, name: str) -> Path:
-        """Create a new (sub)directory."""
+    def mkdir(self, name: Union[str, "os.PathLike[str]"]) -> Path:
+        """Create a new (sub)directory.
+
+        :param name:
+            The name of the directory, relative to the pytester path.
+        :returns:
+            The created directory.
+        """
         p = self.path / name
         p.mkdir()
         return p
 
-    def mkpydir(self, name: str) -> Path:
+    def mkpydir(self, name: Union[str, "os.PathLike[str]"]) -> Path:
         """Create a new python package.
 
         This creates a (sub)directory with an empty ``__init__.py`` file so it
@@ -880,14 +942,15 @@ class Pytester:
     def copy_example(self, name: Optional[str] = None) -> Path:
         """Copy file from project's directory into the testdir.
 
-        :param str name: The name of the file to copy.
-        :return: path to the copied directory (inside ``self.path``).
-
+        :param name:
+            The name of the file to copy.
+        :return:
+            Path to the copied directory (inside ``self.path``).
         """
-        example_dir = self._request.config.getini("pytester_example_dir")
-        if example_dir is None:
+        example_dir_ = self._request.config.getini("pytester_example_dir")
+        if example_dir_ is None:
             raise ValueError("pytester_example_dir is unset, can't copy examples")
-        example_dir = Path(str(self._request.config.rootdir)) / example_dir
+        example_dir: Path = self._request.config.rootpath / example_dir_
 
         for extra_element in self._request.node.iter_markers("pytester_example_path"):
             assert extra_element.args
@@ -910,10 +973,7 @@ class Pytester:
             example_path = example_dir.joinpath(name)
 
         if example_path.is_dir() and not example_path.joinpath("__init__.py").is_file():
-            # TODO: py.path.local.copy can copy files to existing directories,
-            # while with shutil.copytree the destination directory cannot exist,
-            # we will need to roll our own in order to drop py.path.local completely
-            py.path.local(example_path).copy(py.path.local(self.path))
+            copytree(example_path, self.path)
             return self.path
         elif example_path.is_file():
             result = self.path.joinpath(example_path.name)
@@ -924,39 +984,44 @@ class Pytester:
                 f'example "{example_path}" is not found as a file or directory'
             )
 
-    Session = Session
-
     def getnode(
         self, config: Config, arg: Union[str, "os.PathLike[str]"]
-    ) -> Optional[Union[Collector, Item]]:
-        """Return the collection node of a file.
+    ) -> Union[Collector, Item]:
+        """Get the collection node of a file.
 
-        :param _pytest.config.Config config:
+        :param config:
            A pytest config.
            See :py:meth:`parseconfig` and :py:meth:`parseconfigure` for creating it.
-        :param py.path.local arg:
+        :param arg:
             Path to the file.
+        :returns:
+            The node.
         """
         session = Session.from_config(config)
         assert "::" not in str(arg)
-        p = py.path.local(arg)
+        p = Path(os.path.abspath(arg))
         config.hook.pytest_sessionstart(session=session)
         res = session.perform_collect([str(p)], genitems=False)[0]
         config.hook.pytest_sessionfinish(session=session, exitstatus=ExitCode.OK)
         return res
 
-    def getpathnode(self, path: Union[str, "os.PathLike[str]"]):
+    def getpathnode(
+        self, path: Union[str, "os.PathLike[str]"]
+    ) -> Union[Collector, Item]:
         """Return the collection node of a file.
 
         This is like :py:meth:`getnode` but uses :py:meth:`parseconfigure` to
         create the (configured) pytest Config instance.
 
-        :param py.path.local path: Path to the file.
+        :param path:
+            Path to the file.
+        :returns:
+            The node.
         """
-        path = py.path.local(path)
+        path = Path(path)
         config = self.parseconfigure(path)
         session = Session.from_config(config)
-        x = session.fspath.bestrelpath(path)
+        x = bestrelpath(session.path, path)
         config.hook.pytest_sessionstart(session=session)
         res = session.perform_collect([x], genitems=False)[0]
         config.hook.pytest_sessionfinish(session=session, exitstatus=ExitCode.OK)
@@ -967,6 +1032,11 @@ class Pytester:
 
         This recurses into the collection node and returns a list of all the
         test items contained within.
+
+        :param colitems:
+            The collection nodes.
+        :returns:
+            The collected items.
         """
         session = colitems[0].session
         result: List[Item] = []
@@ -997,10 +1067,7 @@ class Pytester:
         for the result.
 
         :param source: The source code of the test module.
-
         :param cmdlineargs: Any extra command line arguments to use.
-
-        :returns: :py:class:`HookRecorder` instance of the result.
         """
         p = self.makepyfile(source)
         values = list(cmdlineargs) + [p]
@@ -1038,8 +1105,6 @@ class Pytester:
         :param no_reraise_ctrlc:
             Typically we reraise keyboard interrupts from the child run. If
             True, the KeyboardInterrupt exception is captured.
-
-        :returns: A :py:class:`HookRecorder` instance.
         """
         # (maybe a cpython bug?) the importlib cache sometimes isn't updated
         # properly between file creation and inline_run (especially if imports
@@ -1077,7 +1142,7 @@ class Pytester:
                 class reprec:  # type: ignore
                     pass
 
-            reprec.ret = ret  # type: ignore
+            reprec.ret = ret
 
             # Typically we reraise keyboard interrupts from the child run
             # because it's our user requesting interruption of the testing.
@@ -1138,7 +1203,7 @@ class Pytester:
         self, *args: Union[str, "os.PathLike[str]"], **kwargs: Any
     ) -> RunResult:
         """Run pytest inline or in a subprocess, depending on the command line
-        option "--runpytest" and return a :py:class:`RunResult`."""
+        option "--runpytest" and return a :py:class:`~pytest.RunResult`."""
         new_args = self._ensure_basetemp(args)
         if self._method == "inprocess":
             return self.runpytest_inprocess(*new_args, **kwargs)
@@ -1158,15 +1223,16 @@ class Pytester:
         return new_args
 
     def parseconfig(self, *args: Union[str, "os.PathLike[str]"]) -> Config:
-        """Return a new pytest Config instance from given commandline args.
+        """Return a new pytest :class:`pytest.Config` instance from given
+        commandline args.
 
-        This invokes the pytest bootstrapping code in _pytest.config to create
-        a new :py:class:`_pytest.core.PluginManager` and call the
-        pytest_cmdline_parse hook to create a new
-        :py:class:`_pytest.config.Config` instance.
+        This invokes the pytest bootstrapping code in _pytest.config to create a
+        new :py:class:`pytest.PytestPluginManager` and call the
+        :hook:`pytest_cmdline_parse` hook to create a new :class:`pytest.Config`
+        instance.
 
-        If :py:attr:`plugins` has been populated they should be plugin modules
-        to be registered with the PluginManager.
+        If :attr:`plugins` has been populated they should be plugin modules
+        to be registered with the plugin manager.
         """
         import _pytest.config
 
@@ -1183,14 +1249,17 @@ class Pytester:
     def parseconfigure(self, *args: Union[str, "os.PathLike[str]"]) -> Config:
         """Return a new pytest configured Config instance.
 
-        Returns a new :py:class:`_pytest.config.Config` instance like
-        :py:meth:`parseconfig`, but also calls the pytest_configure hook.
+        Returns a new :py:class:`pytest.Config` instance like
+        :py:meth:`parseconfig`, but also calls the :hook:`pytest_configure`
+        hook.
         """
         config = self.parseconfig(*args)
         config._do_configure()
         return config
 
-    def getitem(self, source: str, funcname: str = "test_func") -> Item:
+    def getitem(
+        self, source: Union[str, "os.PathLike[str]"], funcname: str = "test_func"
+    ) -> Item:
         """Return the test item for a test function.
 
         Writes the source to a python file and runs pytest's collection on
@@ -1201,6 +1270,8 @@ class Pytester:
             The module source.
         :param funcname:
             The name of the test function for which to return a test item.
+        :returns:
+            The test item.
         """
         items = self.getitems(source)
         for item in items:
@@ -1210,7 +1281,7 @@ class Pytester:
             funcname, source, items
         )
 
-    def getitems(self, source: str) -> List[Item]:
+    def getitems(self, source: Union[str, "os.PathLike[str]"]) -> List[Item]:
         """Return all test items collected from the module.
 
         Writes the source to a Python file and runs pytest's collection on
@@ -1220,7 +1291,11 @@ class Pytester:
         return self.genitems([modcol])
 
     def getmodulecol(
-        self, source: Union[str, Path], configargs=(), *, withinit: bool = False
+        self,
+        source: Union[str, "os.PathLike[str]"],
+        configargs=(),
+        *,
+        withinit: bool = False,
     ):
         """Return the module collection node for ``source``.
 
@@ -1238,7 +1313,7 @@ class Pytester:
             Whether to also write an ``__init__.py`` file to the same
             directory to ensure it is a package.
         """
-        if isinstance(source, Path):
+        if isinstance(source, os.PathLike):
             path = self.path.joinpath(source)
             assert not withinit, "not supported for paths"
         else:
@@ -1254,7 +1329,7 @@ class Pytester:
     ) -> Optional[Union[Item, Collector]]:
         """Return the collection node for name from the module collection.
 
-        Searchs a module collection node for a collection node matching the
+        Searches a module collection node for a collection node matching the
         given name.
 
         :param modcol: A module collection node; see :py:meth:`getmodulecol`.
@@ -1269,16 +1344,16 @@ class Pytester:
 
     def popen(
         self,
-        cmdargs,
+        cmdargs: Sequence[Union[str, "os.PathLike[str]"]],
         stdout: Union[int, TextIO] = subprocess.PIPE,
         stderr: Union[int, TextIO] = subprocess.PIPE,
-        stdin=CLOSE_STDIN,
+        stdin: Union[NotSetType, bytes, IO[Any], int] = CLOSE_STDIN,
         **kw,
     ):
-        """Invoke subprocess.Popen.
+        """Invoke :py:class:`subprocess.Popen`.
 
-        Calls subprocess.Popen making sure the current working directory is
-        in the PYTHONPATH.
+        Calls :py:class:`subprocess.Popen` making sure the current working
+        directory is in ``PYTHONPATH``.
 
         You probably want to use :py:meth:`run` instead.
         """
@@ -1309,33 +1384,40 @@ class Pytester:
         self,
         *cmdargs: Union[str, "os.PathLike[str]"],
         timeout: Optional[float] = None,
-        stdin=CLOSE_STDIN,
+        stdin: Union[NotSetType, bytes, IO[Any], int] = CLOSE_STDIN,
     ) -> RunResult:
         """Run a command with arguments.
 
-        Run a process using subprocess.Popen saving the stdout and stderr.
+        Run a process using :py:class:`subprocess.Popen` saving the stdout and
+        stderr.
 
         :param cmdargs:
-            The sequence of arguments to pass to `subprocess.Popen()`, with path-like objects
-            being converted to ``str`` automatically.
+            The sequence of arguments to pass to :py:class:`subprocess.Popen`,
+            with path-like objects being converted to :py:class:`str`
+            automatically.
         :param timeout:
             The period in seconds after which to timeout and raise
             :py:class:`Pytester.TimeoutExpired`.
         :param stdin:
-            Optional standard input.  Bytes are being send, closing
-            the pipe, otherwise it is passed through to ``popen``.
-            Defaults to ``CLOSE_STDIN``, which translates to using a pipe
-            (``subprocess.PIPE``) that gets closed.
+            Optional standard input.
+
+            - If it is :py:attr:`CLOSE_STDIN` (Default), then this method calls
+              :py:class:`subprocess.Popen` with ``stdin=subprocess.PIPE``, and
+              the standard input is closed immediately after the new command is
+              started.
+
+            - If it is of type :py:class:`bytes`, these bytes are sent to the
+              standard input of the command.
 
-        :rtype: RunResult
+            - Otherwise, it is passed through to :py:class:`subprocess.Popen`.
+              For further information in this case, consult the document of the
+              ``stdin`` parameter in :py:class:`subprocess.Popen`.
+        :returns:
+            The result.
         """
         __tracebackhide__ = True
 
-        # TODO: Remove type ignore in next mypy release.
-        #       https://github.com/python/typeshed/pull/4582
-        cmdargs = tuple(
-            os.fspath(arg) if isinstance(arg, os.PathLike) else arg for arg in cmdargs  # type: ignore[misc]
-        )
+        cmdargs = tuple(os.fspath(arg) for arg in cmdargs)
         p1 = self.path.joinpath("stdout")
         p2 = self.path.joinpath("stderr")
         print("running:", *cmdargs)
@@ -1394,21 +1476,17 @@ class Pytester:
     def _getpytestargs(self) -> Tuple[str, ...]:
         return sys.executable, "-mpytest"
 
-    def runpython(self, script) -> RunResult:
-        """Run a python script using sys.executable as interpreter.
-
-        :rtype: RunResult
-        """
+    def runpython(self, script: "os.PathLike[str]") -> RunResult:
+        """Run a python script using sys.executable as interpreter."""
         return self.run(sys.executable, script)
 
-    def runpython_c(self, command):
-        """Run python -c "command".
-
-        :rtype: RunResult
-        """
+    def runpython_c(self, command: str) -> RunResult:
+        """Run ``python -c "command"``."""
         return self.run(sys.executable, "-c", command)
 
-    def runpytest_subprocess(self, *args, timeout: Optional[float] = None) -> RunResult:
+    def runpytest_subprocess(
+        self, *args: Union[str, "os.PathLike[str]"], timeout: Optional[float] = None
+    ) -> RunResult:
         """Run pytest as a subprocess with given arguments.
 
         Any plugins added to the :py:attr:`plugins` list will be added using the
@@ -1422,11 +1500,11 @@ class Pytester:
         :param timeout:
             The period in seconds after which to timeout and raise
             :py:class:`Pytester.TimeoutExpired`.
-
-        :rtype: RunResult
+        :returns:
+            The result.
         """
         __tracebackhide__ = True
-        p = make_numbered_dir(root=self.path, prefix="runpytest-")
+        p = make_numbered_dir(root=self.path, prefix="runpytest-", mode=0o700)
         args = ("--basetemp=%s" % p,) + args
         plugins = [x for x in self.plugins if isinstance(x, str)]
         if plugins:
@@ -1445,7 +1523,7 @@ class Pytester:
         The pexpect child is returned.
         """
         basetemp = self.path / "temp-pexpect"
-        basetemp.mkdir()
+        basetemp.mkdir(mode=0o700)
         invoke = " ".join(map(str, self._getpytestargs()))
         cmd = f"{invoke} --basetemp={basetemp} {string}"
         return self.spawn(cmd, expect_timeout=expect_timeout)
@@ -1475,7 +1553,7 @@ class LineComp:
     def assert_contains_lines(self, lines2: Sequence[str]) -> None:
         """Assert that ``lines2`` are contained (linearly) in :attr:`stringio`'s value.
 
-        Lines are matched using :func:`LineMatcher.fnmatch_lines`.
+        Lines are matched using :func:`LineMatcher.fnmatch_lines <pytest.LineMatcher.fnmatch_lines>`.
         """
         __tracebackhide__ = True
         val = self.stringio.getvalue()
@@ -1485,217 +1563,6 @@ class LineComp:
         LineMatcher(lines1).fnmatch_lines(lines2)
 
 
-@final
-@attr.s(repr=False, str=False, init=False)
-class Testdir:
-    """
-    Similar to :class:`Pytester`, but this class works with legacy py.path.local objects instead.
-
-    All methods just forward to an internal :class:`Pytester` instance, converting results
-    to `py.path.local` objects as necessary.
-    """
-
-    __test__ = False
-
-    CLOSE_STDIN = Pytester.CLOSE_STDIN
-    TimeoutExpired = Pytester.TimeoutExpired
-    Session = Pytester.Session
-
-    def __init__(self, pytester: Pytester, *, _ispytest: bool = False) -> None:
-        check_ispytest(_ispytest)
-        self._pytester = pytester
-
-    @property
-    def tmpdir(self) -> py.path.local:
-        """Temporary directory where tests are executed."""
-        return py.path.local(self._pytester.path)
-
-    @property
-    def test_tmproot(self) -> py.path.local:
-        return py.path.local(self._pytester._test_tmproot)
-
-    @property
-    def request(self):
-        return self._pytester._request
-
-    @property
-    def plugins(self):
-        return self._pytester.plugins
-
-    @plugins.setter
-    def plugins(self, plugins):
-        self._pytester.plugins = plugins
-
-    @property
-    def monkeypatch(self) -> MonkeyPatch:
-        return self._pytester._monkeypatch
-
-    def make_hook_recorder(self, pluginmanager) -> HookRecorder:
-        """See :meth:`Pytester.make_hook_recorder`."""
-        return self._pytester.make_hook_recorder(pluginmanager)
-
-    def chdir(self) -> None:
-        """See :meth:`Pytester.chdir`."""
-        return self._pytester.chdir()
-
-    def finalize(self) -> None:
-        """See :meth:`Pytester._finalize`."""
-        return self._pytester._finalize()
-
-    def makefile(self, ext, *args, **kwargs) -> py.path.local:
-        """See :meth:`Pytester.makefile`."""
-        return py.path.local(str(self._pytester.makefile(ext, *args, **kwargs)))
-
-    def makeconftest(self, source) -> py.path.local:
-        """See :meth:`Pytester.makeconftest`."""
-        return py.path.local(str(self._pytester.makeconftest(source)))
-
-    def makeini(self, source) -> py.path.local:
-        """See :meth:`Pytester.makeini`."""
-        return py.path.local(str(self._pytester.makeini(source)))
-
-    def getinicfg(self, source: str) -> SectionWrapper:
-        """See :meth:`Pytester.getinicfg`."""
-        return self._pytester.getinicfg(source)
-
-    def makepyprojecttoml(self, source) -> py.path.local:
-        """See :meth:`Pytester.makepyprojecttoml`."""
-        return py.path.local(str(self._pytester.makepyprojecttoml(source)))
-
-    def makepyfile(self, *args, **kwargs) -> py.path.local:
-        """See :meth:`Pytester.makepyfile`."""
-        return py.path.local(str(self._pytester.makepyfile(*args, **kwargs)))
-
-    def maketxtfile(self, *args, **kwargs) -> py.path.local:
-        """See :meth:`Pytester.maketxtfile`."""
-        return py.path.local(str(self._pytester.maketxtfile(*args, **kwargs)))
-
-    def syspathinsert(self, path=None) -> None:
-        """See :meth:`Pytester.syspathinsert`."""
-        return self._pytester.syspathinsert(path)
-
-    def mkdir(self, name) -> py.path.local:
-        """See :meth:`Pytester.mkdir`."""
-        return py.path.local(str(self._pytester.mkdir(name)))
-
-    def mkpydir(self, name) -> py.path.local:
-        """See :meth:`Pytester.mkpydir`."""
-        return py.path.local(str(self._pytester.mkpydir(name)))
-
-    def copy_example(self, name=None) -> py.path.local:
-        """See :meth:`Pytester.copy_example`."""
-        return py.path.local(str(self._pytester.copy_example(name)))
-
-    def getnode(self, config: Config, arg) -> Optional[Union[Item, Collector]]:
-        """See :meth:`Pytester.getnode`."""
-        return self._pytester.getnode(config, arg)
-
-    def getpathnode(self, path):
-        """See :meth:`Pytester.getpathnode`."""
-        return self._pytester.getpathnode(path)
-
-    def genitems(self, colitems: List[Union[Item, Collector]]) -> List[Item]:
-        """See :meth:`Pytester.genitems`."""
-        return self._pytester.genitems(colitems)
-
-    def runitem(self, source):
-        """See :meth:`Pytester.runitem`."""
-        return self._pytester.runitem(source)
-
-    def inline_runsource(self, source, *cmdlineargs):
-        """See :meth:`Pytester.inline_runsource`."""
-        return self._pytester.inline_runsource(source, *cmdlineargs)
-
-    def inline_genitems(self, *args):
-        """See :meth:`Pytester.inline_genitems`."""
-        return self._pytester.inline_genitems(*args)
-
-    def inline_run(self, *args, plugins=(), no_reraise_ctrlc: bool = False):
-        """See :meth:`Pytester.inline_run`."""
-        return self._pytester.inline_run(
-            *args, plugins=plugins, no_reraise_ctrlc=no_reraise_ctrlc
-        )
-
-    def runpytest_inprocess(self, *args, **kwargs) -> RunResult:
-        """See :meth:`Pytester.runpytest_inprocess`."""
-        return self._pytester.runpytest_inprocess(*args, **kwargs)
-
-    def runpytest(self, *args, **kwargs) -> RunResult:
-        """See :meth:`Pytester.runpytest`."""
-        return self._pytester.runpytest(*args, **kwargs)
-
-    def parseconfig(self, *args) -> Config:
-        """See :meth:`Pytester.parseconfig`."""
-        return self._pytester.parseconfig(*args)
-
-    def parseconfigure(self, *args) -> Config:
-        """See :meth:`Pytester.parseconfigure`."""
-        return self._pytester.parseconfigure(*args)
-
-    def getitem(self, source, funcname="test_func"):
-        """See :meth:`Pytester.getitem`."""
-        return self._pytester.getitem(source, funcname)
-
-    def getitems(self, source):
-        """See :meth:`Pytester.getitems`."""
-        return self._pytester.getitems(source)
-
-    def getmodulecol(self, source, configargs=(), withinit=False):
-        """See :meth:`Pytester.getmodulecol`."""
-        return self._pytester.getmodulecol(
-            source, configargs=configargs, withinit=withinit
-        )
-
-    def collect_by_name(
-        self, modcol: Collector, name: str
-    ) -> Optional[Union[Item, Collector]]:
-        """See :meth:`Pytester.collect_by_name`."""
-        return self._pytester.collect_by_name(modcol, name)
-
-    def popen(
-        self,
-        cmdargs,
-        stdout: Union[int, TextIO] = subprocess.PIPE,
-        stderr: Union[int, TextIO] = subprocess.PIPE,
-        stdin=CLOSE_STDIN,
-        **kw,
-    ):
-        """See :meth:`Pytester.popen`."""
-        return self._pytester.popen(cmdargs, stdout, stderr, stdin, **kw)
-
-    def run(self, *cmdargs, timeout=None, stdin=CLOSE_STDIN) -> RunResult:
-        """See :meth:`Pytester.run`."""
-        return self._pytester.run(*cmdargs, timeout=timeout, stdin=stdin)
-
-    def runpython(self, script) -> RunResult:
-        """See :meth:`Pytester.runpython`."""
-        return self._pytester.runpython(script)
-
-    def runpython_c(self, command):
-        """See :meth:`Pytester.runpython_c`."""
-        return self._pytester.runpython_c(command)
-
-    def runpytest_subprocess(self, *args, timeout=None) -> RunResult:
-        """See :meth:`Pytester.runpytest_subprocess`."""
-        return self._pytester.runpytest_subprocess(*args, timeout=timeout)
-
-    def spawn_pytest(
-        self, string: str, expect_timeout: float = 10.0
-    ) -> "pexpect.spawn":
-        """See :meth:`Pytester.spawn_pytest`."""
-        return self._pytester.spawn_pytest(string, expect_timeout=expect_timeout)
-
-    def spawn(self, cmd: str, expect_timeout: float = 10.0) -> "pexpect.spawn":
-        """See :meth:`Pytester.spawn`."""
-        return self._pytester.spawn(cmd, expect_timeout=expect_timeout)
-
-    def __repr__(self) -> str:
-        return f"<Testdir {self.tmpdir!r}>"
-
-    def __str__(self) -> str:
-        return str(self.tmpdir)
-
-
 class LineMatcher:
     """Flexible matching of text.
 
@@ -1827,7 +1694,7 @@ class LineMatcher:
             Match lines consecutively?
         """
         if not isinstance(lines2, collections.abc.Sequence):
-            raise TypeError("invalid type for lines2: {}".format(type(lines2).__name__))
+            raise TypeError(f"invalid type for lines2: {type(lines2).__name__}")
         lines2 = self._getlines(lines2)
         lines1 = self.lines[:]
         extralines = []
index 630c1d3331cbdad416724f3f8ed51c7804fc23b0..657e4db5fc318da80a0247be45208c0d4ece38dd 100644 (file)
@@ -4,6 +4,7 @@
 # hence cannot be subject to assertion rewriting, which requires a
 # module to not be already imported.
 from typing import Dict
+from typing import Optional
 from typing import Sequence
 from typing import Tuple
 from typing import Union
@@ -42,6 +43,8 @@ def assert_outcomes(
     errors: int = 0,
     xpassed: int = 0,
     xfailed: int = 0,
+    warnings: Optional[int] = None,
+    deselected: Optional[int] = None,
 ) -> None:
     """Assert that the specified outcomes appear with the respective
     numbers (0 means it didn't occur) in the text output from a test run."""
@@ -63,4 +66,10 @@ def assert_outcomes(
         "xpassed": xpassed,
         "xfailed": xfailed,
     }
+    if warnings is not None:
+        obtained["warnings"] = outcomes.get("warnings", 0)
+        expected["warnings"] = warnings
+    if deselected is not None:
+        obtained["deselected"] = outcomes.get("deselected", 0)
+        expected["deselected"] = deselected
     assert obtained == expected
index e48e7531c1913751428cc0fb2d672fd772fe1bcb..5f8be5d9b9e666157317466f97477334bf4335c8 100644 (file)
@@ -1,4 +1,5 @@
 """Python test discovery, setup and run of test functions."""
+import dataclasses
 import enum
 import fnmatch
 import inspect
@@ -10,6 +11,7 @@ import warnings
 from collections import Counter
 from collections import defaultdict
 from functools import partial
+from pathlib import Path
 from typing import Any
 from typing import Callable
 from typing import Dict
@@ -19,15 +21,13 @@ from typing import Iterator
 from typing import List
 from typing import Mapping
 from typing import Optional
+from typing import Pattern
 from typing import Sequence
 from typing import Set
 from typing import Tuple
-from typing import Type
 from typing import TYPE_CHECKING
 from typing import Union
 
-import py
-
 import _pytest
 from _pytest import fixtures
 from _pytest import nodes
@@ -35,9 +35,11 @@ from _pytest._code import filter_traceback
 from _pytest._code import getfslineno
 from _pytest._code.code import ExceptionInfo
 from _pytest._code.code import TerminalRepr
+from _pytest._code.code import Traceback
 from _pytest._io import TerminalWriter
 from _pytest._io.saferepr import saferepr
 from _pytest.compat import ascii_escaped
+from _pytest.compat import assert_never
 from _pytest.compat import final
 from _pytest.compat import get_default_arg_names
 from _pytest.compat import get_real_func
@@ -45,8 +47,8 @@ from _pytest.compat import getimfunc
 from _pytest.compat import getlocation
 from _pytest.compat import is_async_function
 from _pytest.compat import is_generator
+from _pytest.compat import LEGACY_PATH
 from _pytest.compat import NOTSET
-from _pytest.compat import REGEX_TYPE
 from _pytest.compat import safe_getattr
 from _pytest.compat import safe_isclass
 from _pytest.compat import STRING_TYPES
@@ -54,7 +56,9 @@ from _pytest.config import Config
 from _pytest.config import ExitCode
 from _pytest.config import hookimpl
 from _pytest.config.argparsing import Parser
-from _pytest.deprecated import FSCOLLECTOR_GETHOOKPROXY_ISINITPATH
+from _pytest.deprecated import check_ispytest
+from _pytest.deprecated import INSTANCE_COLLECTOR
+from _pytest.deprecated import NOSE_SUPPORT_METHOD
 from _pytest.fixtures import FuncFixtureInfo
 from _pytest.main import Session
 from _pytest.mark import MARK_GEN
@@ -65,16 +69,24 @@ from _pytest.mark.structures import MarkDecorator
 from _pytest.mark.structures import normalize_mark_list
 from _pytest.outcomes import fail
 from _pytest.outcomes import skip
+from _pytest.pathlib import bestrelpath
+from _pytest.pathlib import fnmatch_ex
 from _pytest.pathlib import import_path
 from _pytest.pathlib import ImportPathMismatchError
 from _pytest.pathlib import parts
 from _pytest.pathlib import visit
+from _pytest.scope import Scope
 from _pytest.warning_types import PytestCollectionWarning
+from _pytest.warning_types import PytestReturnNotNoneWarning
 from _pytest.warning_types import PytestUnhandledCoroutineWarning
 
 if TYPE_CHECKING:
     from typing_extensions import Literal
-    from _pytest.fixtures import _Scope
+
+    from _pytest.scope import _ScopeName
+
+
+_PYTEST_DIR = Path(_pytest.__file__).parent
 
 
 def pytest_addoption(parser: Parser) -> None:
@@ -85,7 +97,7 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         dest="showfixtures",
         default=False,
-        help="show available fixtures, sorted by plugin appearance "
+        help="Show available fixtures, sorted by plugin appearance "
         "(fixtures with leading '_' are only shown with '-v')",
     )
     group.addoption(
@@ -93,32 +105,32 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         dest="show_fixtures_per_test",
         default=False,
-        help="show fixtures per test",
+        help="Show fixtures per test",
     )
     parser.addini(
         "python_files",
         type="args",
         # NOTE: default is also used in AssertionRewritingHook.
         default=["test_*.py", "*_test.py"],
-        help="glob-style file patterns for Python test module discovery",
+        help="Glob-style file patterns for Python test module discovery",
     )
     parser.addini(
         "python_classes",
         type="args",
         default=["Test"],
-        help="prefixes or glob names for Python test class discovery",
+        help="Prefixes or glob names for Python test class discovery",
     )
     parser.addini(
         "python_functions",
         type="args",
         default=["test"],
-        help="prefixes or glob names for Python test function and method discovery",
+        help="Prefixes or glob names for Python test function and method discovery",
     )
     parser.addini(
         "disable_test_id_escaping_and_forfeit_all_rights_to_community_support",
         type="bool",
         default=False,
-        help="disable string escape non-ascii characters, might cause unwanted "
+        help="Disable string escape non-ASCII characters, might cause unwanted "
         "side effects(use at your own risk)",
     )
 
@@ -135,8 +147,7 @@ def pytest_cmdline_main(config: Config) -> Optional[Union[int, ExitCode]]:
 
 def pytest_generate_tests(metafunc: "Metafunc") -> None:
     for marker in metafunc.definition.iter_markers(name="parametrize"):
-        # TODO: Fix this type-ignore (overlapping kwargs).
-        metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker)  # type: ignore[misc]
+        metafunc.parametrize(*marker.args, **marker.kwargs, _param_mark=marker)
 
 
 def pytest_configure(config: Config) -> None:
@@ -148,14 +159,14 @@ def pytest_configure(config: Config) -> None:
         "or a list of tuples of values if argnames specifies multiple names. "
         "Example: @parametrize('arg1', [1,2]) would lead to two calls of the "
         "decorated test function, one with arg1=1 and another with arg1=2."
-        "see https://docs.pytest.org/en/stable/parametrize.html for more info "
+        "see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info "
         "and examples.",
     )
     config.addinivalue_line(
         "markers",
         "usefixtures(fixturename1, fixturename2, ...): mark tests as needing "
         "all of the specified fixtures. see "
-        "https://docs.pytest.org/en/stable/fixture.html#usefixtures ",
+        "https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures ",
     )
 
 
@@ -170,7 +181,7 @@ def async_warn_and_skip(nodeid: str) -> None:
     msg += "  - pytest-trio\n"
     msg += "  - pytest-twisted"
     warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid)))
-    skip(msg="async def function and no async plugin installed (see warnings)")
+    skip(reason="async def function and no async plugin installed (see warnings)")
 
 
 @hookimpl(trylast=True)
@@ -183,44 +194,54 @@ def pytest_pyfunc_call(pyfuncitem: "Function") -> Optional[object]:
     result = testfunction(**testargs)
     if hasattr(result, "__await__") or hasattr(result, "__aiter__"):
         async_warn_and_skip(pyfuncitem.nodeid)
+    elif result is not None:
+        warnings.warn(
+            PytestReturnNotNoneWarning(
+                f"Expected None, but {pyfuncitem.nodeid} returned {result!r}, which will be an error in a "
+                "future version of pytest.  Did you mean to use `assert` instead of `return`?"
+            )
+        )
     return True
 
 
-def pytest_collect_file(
-    path: py.path.local, parent: nodes.Collector
-) -> Optional["Module"]:
-    ext = path.ext
-    if ext == ".py":
-        if not parent.session.isinitpath(path):
+def pytest_collect_file(file_path: Path, parent: nodes.Collector) -> Optional["Module"]:
+    if file_path.suffix == ".py":
+        if not parent.session.isinitpath(file_path):
             if not path_matches_patterns(
-                path, parent.config.getini("python_files") + ["__init__.py"]
+                file_path, parent.config.getini("python_files") + ["__init__.py"]
             ):
                 return None
-        ihook = parent.session.gethookproxy(path)
-        module: Module = ihook.pytest_pycollect_makemodule(path=path, parent=parent)
+        ihook = parent.session.gethookproxy(file_path)
+        module: Module = ihook.pytest_pycollect_makemodule(
+            module_path=file_path, parent=parent
+        )
         return module
     return None
 
 
-def path_matches_patterns(path: py.path.local, patterns: Iterable[str]) -> bool:
+def path_matches_patterns(path: Path, patterns: Iterable[str]) -> bool:
     """Return whether path matches any of the patterns in the list of globs given."""
-    return any(path.fnmatch(pattern) for pattern in patterns)
+    return any(fnmatch_ex(pattern, path) for pattern in patterns)
 
 
-def pytest_pycollect_makemodule(path: py.path.local, parent) -> "Module":
-    if path.basename == "__init__.py":
-        pkg: Package = Package.from_parent(parent, fspath=path)
+def pytest_pycollect_makemodule(module_path: Path, parent) -> "Module":
+    if module_path.name == "__init__.py":
+        pkg: Package = Package.from_parent(parent, path=module_path)
         return pkg
-    mod: Module = Module.from_parent(parent, fspath=path)
+    mod: Module = Module.from_parent(parent, path=module_path)
     return mod
 
 
 @hookimpl(trylast=True)
-def pytest_pycollect_makeitem(collector: "PyCollector", name: str, obj: object):
+def pytest_pycollect_makeitem(
+    collector: Union["Module", "Class"], name: str, obj: object
+) -> Union[None, nodes.Item, nodes.Collector, List[Union[nodes.Item, nodes.Collector]]]:
+    assert isinstance(collector, (Class, Module)), type(collector)
     # Nothing was collected elsewhere, let's do it here.
     if safe_isclass(obj):
         if collector.istestclass(obj, name):
-            return Class.from_parent(collector, name=name, obj=obj)
+            klass: Class = Class.from_parent(collector, name=name, obj=obj)
+            return klass
     elif collector.istestfunction(obj, name):
         # mock seems to store unbound methods (issue473), normalize it.
         obj = getattr(obj, "__func__", obj)
@@ -239,31 +260,25 @@ def pytest_pycollect_makeitem(collector: "PyCollector", name: str, obj: object):
             )
         elif getattr(obj, "__test__", True):
             if is_generator(obj):
-                res = Function.from_parent(collector, name=name)
+                res: Function = Function.from_parent(collector, name=name)
                 reason = "yield tests were removed in pytest 4.0 - {name} will be ignored".format(
                     name=name
                 )
                 res.add_marker(MARK_GEN.xfail(run=False, reason=reason))
                 res.warn(PytestCollectionWarning(reason))
+                return res
             else:
-                res = list(collector._genfunctions(name, obj))
-            return res
-
+                return list(collector._genfunctions(name, obj))
+    return None
 
-class PyobjMixin:
-    _ALLOW_MARKERS = True
 
-    # Function and attributes that the mixin needs (for type-checking only).
-    if TYPE_CHECKING:
-        name: str = ""
-        parent: Optional[nodes.Node] = None
-        own_markers: List[Mark] = []
+class PyobjMixin(nodes.Node):
+    """this mix-in inherits from Node to carry over the typing information
 
-        def getparent(self, cls: Type[nodes._NodeType]) -> Optional[nodes._NodeType]:
-            ...
+    as its intended to always mix in before a node
+    its position in the mro is unaffected"""
 
-        def listchain(self) -> List[nodes.Node]:
-            ...
+    _ALLOW_MARKERS = True
 
     @property
     def module(self):
@@ -279,9 +294,13 @@ class PyobjMixin:
 
     @property
     def instance(self):
-        """Python instance object this node was collected from (can be None)."""
-        node = self.getparent(Instance)
-        return node.obj if node is not None else None
+        """Python instance object the function is bound to.
+
+        Returns None if not a test method, e.g. for a standalone test function,
+        a staticmethod, a class or a module.
+        """
+        node = self.getparent(Function)
+        return getattr(node.obj, "__self__", None) if node is not None else None
 
     @property
     def obj(self):
@@ -290,9 +309,12 @@ class PyobjMixin:
         if obj is None:
             self._obj = obj = self._getobj()
             # XXX evil hack
-            # used to avoid Instance collector marker duplication
+            # used to avoid Function marker duplication
             if self._ALLOW_MARKERS:
                 self.own_markers.extend(get_unpacked_marks(self.obj))
+                # This assumes that `obj` is called before there is a chance
+                # to add custom keys to `self.keywords`, so no fear of overriding.
+                self.keywords.update((mark.name, mark) for mark in self.own_markers)
         return obj
 
     @obj.setter
@@ -312,8 +334,6 @@ class PyobjMixin:
         chain.reverse()
         parts = []
         for node in chain:
-            if isinstance(node, Instance):
-                continue
             name = node.name
             if isinstance(node, Module):
                 name = os.path.splitext(name)[0]
@@ -325,22 +345,23 @@ class PyobjMixin:
         parts.reverse()
         return ".".join(parts)
 
-    def reportinfo(self) -> Tuple[Union[py.path.local, str], int, str]:
+    def reportinfo(self) -> Tuple[Union["os.PathLike[str]", str], Optional[int], str]:
         # XXX caching?
         obj = self.obj
         compat_co_firstlineno = getattr(obj, "compat_co_firstlineno", None)
         if isinstance(compat_co_firstlineno, int):
             # nose compatibility
             file_path = sys.modules[obj.__module__].__file__
+            assert file_path is not None
             if file_path.endswith(".pyc"):
                 file_path = file_path[:-1]
-            fspath: Union[py.path.local, str] = file_path
+            path: Union["os.PathLike[str]", str] = file_path
             lineno = compat_co_firstlineno
         else:
-            fspath, lineno = getfslineno(obj)
+            path, lineno = getfslineno(obj)
         modpath = self.getmodpath()
         assert isinstance(lineno, int)
-        return fspath, lineno, modpath
+        return path, lineno, modpath
 
 
 # As an optimization, these builtin attribute names are pre-ignored when
@@ -381,13 +402,10 @@ class PyCollector(PyobjMixin, nodes.Collector):
 
     def istestfunction(self, obj: object, name: str) -> bool:
         if self.funcnamefilter(name) or self.isnosetest(obj):
-            if isinstance(obj, staticmethod):
-                # staticmethods need to be unwrapped.
+            if isinstance(obj, (staticmethod, classmethod)):
+                # staticmethods and classmethods need to be unwrapped.
                 obj = safe_getattr(obj, "__func__", False)
-            return (
-                safe_getattr(obj, "__call__", False)
-                and fixtures.getfixturemarker(obj) is None
-            )
+            return callable(obj) and fixtures.getfixturemarker(obj) is None
         else:
             return False
 
@@ -413,15 +431,19 @@ class PyCollector(PyobjMixin, nodes.Collector):
         if not getattr(self.obj, "__test__", True):
             return []
 
-        # NB. we avoid random getattrs and peek in the __dict__ instead
-        # (XXX originally introduced from a PyPy need, still true?)
+        # Avoid random getattrs and peek in the __dict__ instead.
         dicts = [getattr(self.obj, "__dict__", {})]
-        for basecls in self.obj.__class__.__mro__:
-            dicts.append(basecls.__dict__)
+        if isinstance(self.obj, type):
+            for basecls in self.obj.__mro__:
+                dicts.append(basecls.__dict__)
+
+        # In each class, nodes should be definition ordered.
+        # __dict__ is definition ordered.
         seen: Set[str] = set()
-        values: List[Union[nodes.Item, nodes.Collector]] = []
+        dict_values: List[List[Union[nodes.Item, nodes.Collector]]] = []
         ihook = self.ihook
         for dic in dicts:
+            values: List[Union[nodes.Item, nodes.Collector]] = []
             # Note: seems like the dict can change during iteration -
             # be careful not to remove the list() without consideration.
             for name, obj in list(dic.items()):
@@ -439,13 +461,14 @@ class PyCollector(PyobjMixin, nodes.Collector):
                     values.extend(res)
                 else:
                     values.append(res)
+            dict_values.append(values)
 
-        def sort_key(item):
-            fspath, lineno, _ = item.reportinfo()
-            return (str(fspath), lineno)
-
-        values.sort(key=sort_key)
-        return values
+        # Between classes in the class hierarchy, reverse-MRO order -- nodes
+        # inherited from base classes should come before subclasses.
+        result = []
+        for values in reversed(dict_values):
+            result.extend(values)
+        return result
 
     def _genfunctions(self, name: str, funcobj) -> Iterator["Function"]:
         modulecol = self.getparent(Module)
@@ -453,26 +476,32 @@ class PyCollector(PyobjMixin, nodes.Collector):
         module = modulecol.obj
         clscol = self.getparent(Class)
         cls = clscol and clscol.obj or None
-        fm = self.session._fixturemanager
 
         definition = FunctionDefinition.from_parent(self, name=name, callobj=funcobj)
         fixtureinfo = definition._fixtureinfo
 
+        # pytest_generate_tests impls call metafunc.parametrize() which fills
+        # metafunc._calls, the outcome of the hook.
         metafunc = Metafunc(
-            definition, fixtureinfo, self.config, cls=cls, module=module
+            definition=definition,
+            fixtureinfo=fixtureinfo,
+            config=self.config,
+            cls=cls,
+            module=module,
+            _ispytest=True,
         )
         methods = []
         if hasattr(module, "pytest_generate_tests"):
             methods.append(module.pytest_generate_tests)
         if cls is not None and hasattr(cls, "pytest_generate_tests"):
             methods.append(cls().pytest_generate_tests)
-
         self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))
 
         if not metafunc._calls:
             yield Function.from_parent(self, name=name, fixtureinfo=fixtureinfo)
         else:
             # Add funcargs() as fixturedefs to fixtureinfo.arg2fixturedefs.
+            fm = self.session._fixturemanager
             fixtures.add_funcarg_pseudo_fixture_def(self, metafunc, fm)
 
             # Add_funcarg_pseudo_fixture_def may have shadowed some fixtures
@@ -486,7 +515,6 @@ class PyCollector(PyobjMixin, nodes.Collector):
                     self,
                     name=subname,
                     callspec=callspec,
-                    callobj=funcobj,
                     fixtureinfo=fixtureinfo,
                     keywords={callspec.id: True},
                     originalname=name,
@@ -494,7 +522,7 @@ class PyCollector(PyobjMixin, nodes.Collector):
 
 
 class Module(nodes.File, PyCollector):
-    """Collector for test classes and functions."""
+    """Collector for test classes and functions in a Python module."""
 
     def _getobj(self):
         return self._importtestmodule()
@@ -512,12 +540,23 @@ class Module(nodes.File, PyCollector):
         Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with
         other fixtures (#517).
         """
+        has_nose = self.config.pluginmanager.has_plugin("nose")
         setup_module = _get_first_non_fixture_func(
             self.obj, ("setUpModule", "setup_module")
         )
+        if setup_module is None and has_nose:
+            # The name "setup" is too common - only treat as fixture if callable.
+            setup_module = _get_first_non_fixture_func(self.obj, ("setup",))
+            if not callable(setup_module):
+                setup_module = None
         teardown_module = _get_first_non_fixture_func(
             self.obj, ("tearDownModule", "teardown_module")
         )
+        if teardown_module is None and has_nose:
+            teardown_module = _get_first_non_fixture_func(self.obj, ("teardown",))
+            # Same as "setup" above - only treat as fixture if callable.
+            if not callable(teardown_module):
+                teardown_module = None
 
         if setup_module is None and teardown_module is None:
             return
@@ -526,7 +565,7 @@ class Module(nodes.File, PyCollector):
             autouse=True,
             scope="module",
             # Use a unique name to speed up lookup.
-            name=f"xunit_setup_module_fixture_{self.obj.__name__}",
+            name=f"_xunit_setup_module_fixture_{self.obj.__name__}",
         )
         def xunit_setup_module_fixture(request) -> Generator[None, None, None]:
             if setup_module is not None:
@@ -555,7 +594,7 @@ class Module(nodes.File, PyCollector):
             autouse=True,
             scope="function",
             # Use a unique name to speed up lookup.
-            name=f"xunit_setup_function_fixture_{self.obj.__name__}",
+            name=f"_xunit_setup_function_fixture_{self.obj.__name__}",
         )
         def xunit_setup_function_fixture(request) -> Generator[None, None, None]:
             if request.instance is not None:
@@ -575,7 +614,7 @@ class Module(nodes.File, PyCollector):
         # We assume we are only called once per module.
         importmode = self.config.getoption("--import-mode")
         try:
-            mod = import_path(self.fspath, mode=importmode)
+            mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
         except SyntaxError as e:
             raise self.CollectError(
                 ExceptionInfo.from_current().getrepr(style="short")
@@ -601,41 +640,51 @@ class Module(nodes.File, PyCollector):
             )
             formatted_tb = str(exc_repr)
             raise self.CollectError(
-                "ImportError while importing test module '{fspath}'.\n"
+                "ImportError while importing test module '{path}'.\n"
                 "Hint: make sure your test modules/packages have valid Python names.\n"
                 "Traceback:\n"
-                "{traceback}".format(fspath=self.fspath, traceback=formatted_tb)
+                "{traceback}".format(path=self.path, traceback=formatted_tb)
             ) from e
         except skip.Exception as e:
             if e.allow_module_level:
                 raise
             raise self.CollectError(
-                "Using pytest.skip outside of a test is not allowed. "
-                "To decorate a test function, use the @pytest.mark.skip "
-                "or @pytest.mark.skipif decorators instead, and to skip a "
-                "module use `pytestmark = pytest.mark.{skip,skipif}."
+                "Using pytest.skip outside of a test will skip the entire module. "
+                "If that's your intention, pass `allow_module_level=True`. "
+                "If you want to skip a specific test or an entire class, "
+                "use the @pytest.mark.skip or @pytest.mark.skipif decorators."
             ) from e
         self.config.pluginmanager.consider_module(mod)
         return mod
 
 
 class Package(Module):
+    """Collector for files and directories in a Python packages -- directories
+    with an `__init__.py` file."""
+
     def __init__(
         self,
-        fspath: py.path.local,
+        fspath: Optional[LEGACY_PATH],
         parent: nodes.Collector,
         # NOTE: following args are unused:
         config=None,
         session=None,
         nodeid=None,
+        path: Optional[Path] = None,
     ) -> None:
         # NOTE: Could be just the following, but kept as-is for compat.
         # nodes.FSCollector.__init__(self, fspath, parent=parent)
         session = parent.session
         nodes.FSCollector.__init__(
-            self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
+            self,
+            fspath=fspath,
+            path=path,
+            parent=parent,
+            config=config,
+            session=session,
+            nodeid=nodeid,
         )
-        self.name = os.path.basename(str(fspath.dirname))
+        self.name = self.path.parent.name
 
     def setup(self) -> None:
         # Not using fixtures to call setup_module here because autouse fixtures
@@ -653,69 +702,58 @@ class Package(Module):
             func = partial(_call_with_optional_argument, teardown_module, self.obj)
             self.addfinalizer(func)
 
-    def gethookproxy(self, fspath: py.path.local):
-        warnings.warn(FSCOLLECTOR_GETHOOKPROXY_ISINITPATH, stacklevel=2)
-        return self.session.gethookproxy(fspath)
-
-    def isinitpath(self, path: py.path.local) -> bool:
-        warnings.warn(FSCOLLECTOR_GETHOOKPROXY_ISINITPATH, stacklevel=2)
-        return self.session.isinitpath(path)
-
     def _recurse(self, direntry: "os.DirEntry[str]") -> bool:
         if direntry.name == "__pycache__":
             return False
-        path = py.path.local(direntry.path)
-        ihook = self.session.gethookproxy(path.dirpath())
-        if ihook.pytest_ignore_collect(path=path, config=self.config):
-            return False
-        norecursepatterns = self.config.getini("norecursedirs")
-        if any(path.check(fnmatch=pat) for pat in norecursepatterns):
+        fspath = Path(direntry.path)
+        ihook = self.session.gethookproxy(fspath.parent)
+        if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
             return False
         return True
 
     def _collectfile(
-        self, path: py.path.local, handle_dupes: bool = True
+        self, fspath: Path, handle_dupes: bool = True
     ) -> Sequence[nodes.Collector]:
         assert (
-            path.isfile()
+            fspath.is_file()
         ), "{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})".format(
-            path, path.isdir(), path.exists(), path.islink()
+            fspath, fspath.is_dir(), fspath.exists(), fspath.is_symlink()
         )
-        ihook = self.session.gethookproxy(path)
-        if not self.session.isinitpath(path):
-            if ihook.pytest_ignore_collect(path=path, config=self.config):
+        ihook = self.session.gethookproxy(fspath)
+        if not self.session.isinitpath(fspath):
+            if ihook.pytest_ignore_collect(collection_path=fspath, config=self.config):
                 return ()
 
         if handle_dupes:
             keepduplicates = self.config.getoption("keepduplicates")
             if not keepduplicates:
                 duplicate_paths = self.config.pluginmanager._duplicatepaths
-                if path in duplicate_paths:
+                if fspath in duplicate_paths:
                     return ()
                 else:
-                    duplicate_paths.add(path)
+                    duplicate_paths.add(fspath)
 
-        return ihook.pytest_collect_file(path=path, parent=self)  # type: ignore[no-any-return]
+        return ihook.pytest_collect_file(file_path=fspath, parent=self)  # type: ignore[no-any-return]
 
     def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
-        this_path = self.fspath.dirpath()
-        init_module = this_path.join("__init__.py")
-        if init_module.check(file=1) and path_matches_patterns(
-            init_module, self.config.getini("python_files")
-        ):
-            yield Module.from_parent(self, fspath=init_module)
-        pkg_prefixes: Set[py.path.local] = set()
+        this_path = self.path.parent
+
+        # Always collect the __init__ first.
+        if path_matches_patterns(self.path, self.config.getini("python_files")):
+            yield Module.from_parent(self, path=self.path)
+
+        pkg_prefixes: Set[Path] = set()
         for direntry in visit(str(this_path), recurse=self._recurse):
-            path = py.path.local(direntry.path)
+            path = Path(direntry.path)
 
             # We will visit our own __init__.py file, in which case we skip it.
             if direntry.is_file():
-                if direntry.name == "__init__.py" and path.dirpath() == this_path:
+                if direntry.name == "__init__.py" and path.parent == this_path:
                     continue
 
             parts_ = parts(direntry.path)
             if any(
-                str(pkg_prefix) in parts_ and pkg_prefix.join("__init__.py") != path
+                str(pkg_prefix) in parts_ and pkg_prefix / "__init__.py" != path
                 for pkg_prefix in pkg_prefixes
             ):
                 continue
@@ -725,7 +763,7 @@ class Package(Module):
             elif not direntry.is_dir():
                 # Broken symlink or invalid/missing file.
                 continue
-            elif path.join("__init__.py").check(file=1):
+            elif path.joinpath("__init__.py").is_file():
                 pkg_prefixes.add(path)
 
 
@@ -741,22 +779,27 @@ def _call_with_optional_argument(func, arg) -> None:
         func()
 
 
-def _get_first_non_fixture_func(obj: object, names: Iterable[str]):
+def _get_first_non_fixture_func(obj: object, names: Iterable[str]) -> Optional[object]:
     """Return the attribute from the given object to be used as a setup/teardown
-    xunit-style function, but only if not marked as a fixture to avoid calling it twice."""
+    xunit-style function, but only if not marked as a fixture to avoid calling it twice.
+    """
     for name in names:
-        meth = getattr(obj, name, None)
+        meth: Optional[object] = getattr(obj, name, None)
         if meth is not None and fixtures.getfixturemarker(meth) is None:
             return meth
+    return None
 
 
 class Class(PyCollector):
-    """Collector for test methods."""
+    """Collector for test methods (and nested classes) in a Python class."""
 
     @classmethod
-    def from_parent(cls, parent, *, name, obj=None):
+    def from_parent(cls, parent, *, name, obj=None, **kw):
         """The public constructor."""
-        return super().from_parent(name=name, parent=parent)
+        return super().from_parent(name=name, parent=parent, **kw)
+
+    def newinstance(self):
+        return self.obj()
 
     def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
         if not safe_getattr(self.obj, "__test__", True):
@@ -785,7 +828,9 @@ class Class(PyCollector):
         self._inject_setup_class_fixture()
         self._inject_setup_method_fixture()
 
-        return [Instance.from_parent(self, name="()")]
+        self.session._fixturemanager.parsefactories(self.newinstance(), self.nodeid)
+
+        return super().collect()
 
     def _inject_setup_class_fixture(self) -> None:
         """Inject a hidden autouse, class scoped fixture into the collected class object
@@ -795,7 +840,7 @@ class Class(PyCollector):
         other fixtures (#517).
         """
         setup_class = _get_first_non_fixture_func(self.obj, ("setup_class",))
-        teardown_class = getattr(self.obj, "teardown_class", None)
+        teardown_class = _get_first_non_fixture_func(self.obj, ("teardown_class",))
         if setup_class is None and teardown_class is None:
             return
 
@@ -803,7 +848,7 @@ class Class(PyCollector):
             autouse=True,
             scope="class",
             # Use a unique name to speed up lookup.
-            name=f"xunit_setup_class_fixture_{self.obj.__qualname__}",
+            name=f"_xunit_setup_class_fixture_{self.obj.__qualname__}",
         )
         def xunit_setup_class_fixture(cls) -> Generator[None, None, None]:
             if setup_class is not None:
@@ -820,11 +865,24 @@ class Class(PyCollector):
         """Inject a hidden autouse, function scoped fixture into the collected class object
         that invokes setup_method/teardown_method if either or both are available.
 
-        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with
+        Using a fixture to invoke these methods ensures we play nicely and unsurprisingly with
         other fixtures (#517).
         """
-        setup_method = _get_first_non_fixture_func(self.obj, ("setup_method",))
-        teardown_method = getattr(self.obj, "teardown_method", None)
+        has_nose = self.config.pluginmanager.has_plugin("nose")
+        setup_name = "setup_method"
+        setup_method = _get_first_non_fixture_func(self.obj, (setup_name,))
+        emit_nose_setup_warning = False
+        if setup_method is None and has_nose:
+            setup_name = "setup"
+            emit_nose_setup_warning = True
+            setup_method = _get_first_non_fixture_func(self.obj, (setup_name,))
+        teardown_name = "teardown_method"
+        teardown_method = _get_first_non_fixture_func(self.obj, (teardown_name,))
+        emit_nose_teardown_warning = False
+        if teardown_method is None and has_nose:
+            teardown_name = "teardown"
+            emit_nose_teardown_warning = True
+            teardown_method = _get_first_non_fixture_func(self.obj, (teardown_name,))
         if setup_method is None and teardown_method is None:
             return
 
@@ -832,40 +890,47 @@ class Class(PyCollector):
             autouse=True,
             scope="function",
             # Use a unique name to speed up lookup.
-            name=f"xunit_setup_method_fixture_{self.obj.__qualname__}",
+            name=f"_xunit_setup_method_fixture_{self.obj.__qualname__}",
         )
         def xunit_setup_method_fixture(self, request) -> Generator[None, None, None]:
             method = request.function
             if setup_method is not None:
-                func = getattr(self, "setup_method")
+                func = getattr(self, setup_name)
                 _call_with_optional_argument(func, method)
+                if emit_nose_setup_warning:
+                    warnings.warn(
+                        NOSE_SUPPORT_METHOD.format(
+                            nodeid=request.node.nodeid, method="setup"
+                        ),
+                        stacklevel=2,
+                    )
             yield
             if teardown_method is not None:
-                func = getattr(self, "teardown_method")
+                func = getattr(self, teardown_name)
                 _call_with_optional_argument(func, method)
+                if emit_nose_teardown_warning:
+                    warnings.warn(
+                        NOSE_SUPPORT_METHOD.format(
+                            nodeid=request.node.nodeid, method="teardown"
+                        ),
+                        stacklevel=2,
+                    )
 
         self.obj.__pytest_setup_method = xunit_setup_method_fixture
 
 
-class Instance(PyCollector):
-    _ALLOW_MARKERS = False  # hack, destroy later
-    # Instances share the object with their parents in a way
-    # that duplicates markers instances if not taken out
-    # can be removed at node structure reorganization time.
+class InstanceDummy:
+    """Instance used to be a node type between Class and Function. It has been
+    removed in pytest 7.0. Some plugins exist which reference `pytest.Instance`
+    only to ignore it; this dummy class keeps them working. This will be removed
+    in pytest 8."""
 
-    def _getobj(self):
-        # TODO: Improve the type of `parent` such that assert/ignore aren't needed.
-        assert self.parent is not None
-        obj = self.parent.obj  # type: ignore[attr-defined]
-        return obj()
 
-    def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
-        self.session._fixturemanager.parsefactories(self)
-        return super().collect()
-
-    def newinstance(self):
-        self.obj = self._getobj()
-        return self.obj
+def __getattr__(name: str) -> object:
+    if name == "Instance":
+        warnings.warn(INSTANCE_COLLECTOR, 2)
+        return InstanceDummy
+    raise AttributeError(f"module {__name__} has no attribute {name}")
 
 
 def hasinit(obj: object) -> bool:
@@ -883,69 +948,243 @@ def hasnew(obj: object) -> bool:
 
 
 @final
-class CallSpec2:
-    def __init__(self, metafunc: "Metafunc") -> None:
-        self.metafunc = metafunc
-        self.funcargs: Dict[str, object] = {}
-        self._idlist: List[str] = []
-        self.params: Dict[str, object] = {}
-        # Used for sorting parametrized resources.
-        self._arg2scopenum: Dict[str, int] = {}
-        self.marks: List[Mark] = []
-        self.indices: Dict[str, int] = {}
-
-    def copy(self) -> "CallSpec2":
-        cs = CallSpec2(self.metafunc)
-        cs.funcargs.update(self.funcargs)
-        cs.params.update(self.params)
-        cs.marks.extend(self.marks)
-        cs.indices.update(self.indices)
-        cs._arg2scopenum.update(self._arg2scopenum)
-        cs._idlist = list(self._idlist)
-        return cs
-
-    def _checkargnotcontained(self, arg: str) -> None:
-        if arg in self.params or arg in self.funcargs:
-            raise ValueError(f"duplicate {arg!r}")
+@dataclasses.dataclass(frozen=True)
+class IdMaker:
+    """Make IDs for a parametrization."""
+
+    __slots__ = (
+        "argnames",
+        "parametersets",
+        "idfn",
+        "ids",
+        "config",
+        "nodeid",
+        "func_name",
+    )
 
-    def getparam(self, name: str) -> object:
+    # The argnames of the parametrization.
+    argnames: Sequence[str]
+    # The ParameterSets of the parametrization.
+    parametersets: Sequence[ParameterSet]
+    # Optionally, a user-provided callable to make IDs for parameters in a
+    # ParameterSet.
+    idfn: Optional[Callable[[Any], Optional[object]]]
+    # Optionally, explicit IDs for ParameterSets by index.
+    ids: Optional[Sequence[Optional[object]]]
+    # Optionally, the pytest config.
+    # Used for controlling ASCII escaping, and for calling the
+    # :hook:`pytest_make_parametrize_id` hook.
+    config: Optional[Config]
+    # Optionally, the ID of the node being parametrized.
+    # Used only for clearer error messages.
+    nodeid: Optional[str]
+    # Optionally, the ID of the function being parametrized.
+    # Used only for clearer error messages.
+    func_name: Optional[str]
+
+    def make_unique_parameterset_ids(self) -> List[str]:
+        """Make a unique identifier for each ParameterSet, that may be used to
+        identify the parametrization in a node ID.
+
+        Format is <prm_1_token>-...-<prm_n_token>[counter], where prm_x_token is
+        - user-provided id, if given
+        - else an id derived from the value, applicable for certain types
+        - else <argname><parameterset index>
+        The counter suffix is appended only in case a string wouldn't be unique
+        otherwise.
+        """
+        resolved_ids = list(self._resolve_ids())
+        # All IDs must be unique!
+        if len(resolved_ids) != len(set(resolved_ids)):
+            # Record the number of occurrences of each ID.
+            id_counts = Counter(resolved_ids)
+            # Map the ID to its next suffix.
+            id_suffixes: Dict[str, int] = defaultdict(int)
+            # Suffix non-unique IDs to make them unique.
+            for index, id in enumerate(resolved_ids):
+                if id_counts[id] > 1:
+                    resolved_ids[index] = f"{id}{id_suffixes[id]}"
+                    id_suffixes[id] += 1
+        return resolved_ids
+
+    def _resolve_ids(self) -> Iterable[str]:
+        """Resolve IDs for all ParameterSets (may contain duplicates)."""
+        for idx, parameterset in enumerate(self.parametersets):
+            if parameterset.id is not None:
+                # ID provided directly - pytest.param(..., id="...")
+                yield parameterset.id
+            elif self.ids and idx < len(self.ids) and self.ids[idx] is not None:
+                # ID provided in the IDs list - parametrize(..., ids=[...]).
+                yield self._idval_from_value_required(self.ids[idx], idx)
+            else:
+                # ID not provided - generate it.
+                yield "-".join(
+                    self._idval(val, argname, idx)
+                    for val, argname in zip(parameterset.values, self.argnames)
+                )
+
+    def _idval(self, val: object, argname: str, idx: int) -> str:
+        """Make an ID for a parameter in a ParameterSet."""
+        idval = self._idval_from_function(val, argname, idx)
+        if idval is not None:
+            return idval
+        idval = self._idval_from_hook(val, argname)
+        if idval is not None:
+            return idval
+        idval = self._idval_from_value(val)
+        if idval is not None:
+            return idval
+        return self._idval_from_argname(argname, idx)
+
+    def _idval_from_function(
+        self, val: object, argname: str, idx: int
+    ) -> Optional[str]:
+        """Try to make an ID for a parameter in a ParameterSet using the
+        user-provided id callable, if given."""
+        if self.idfn is None:
+            return None
         try:
-            return self.params[name]
-        except KeyError as e:
-            raise ValueError(name) from e
+            id = self.idfn(val)
+        except Exception as e:
+            prefix = f"{self.nodeid}: " if self.nodeid is not None else ""
+            msg = "error raised while trying to determine id of parameter '{}' at position {}"
+            msg = prefix + msg.format(argname, idx)
+            raise ValueError(msg) from e
+        if id is None:
+            return None
+        return self._idval_from_value(id)
+
+    def _idval_from_hook(self, val: object, argname: str) -> Optional[str]:
+        """Try to make an ID for a parameter in a ParameterSet by calling the
+        :hook:`pytest_make_parametrize_id` hook."""
+        if self.config:
+            id: Optional[str] = self.config.hook.pytest_make_parametrize_id(
+                config=self.config, val=val, argname=argname
+            )
+            return id
+        return None
+
+    def _idval_from_value(self, val: object) -> Optional[str]:
+        """Try to make an ID for a parameter in a ParameterSet from its value,
+        if the value type is supported."""
+        if isinstance(val, STRING_TYPES):
+            return _ascii_escaped_by_config(val, self.config)
+        elif val is None or isinstance(val, (float, int, bool, complex)):
+            return str(val)
+        elif isinstance(val, Pattern):
+            return ascii_escaped(val.pattern)
+        elif val is NOTSET:
+            # Fallback to default. Note that NOTSET is an enum.Enum.
+            pass
+        elif isinstance(val, enum.Enum):
+            return str(val)
+        elif isinstance(getattr(val, "__name__", None), str):
+            # Name of a class, function, module, etc.
+            name: str = getattr(val, "__name__")
+            return name
+        return None
+
+    def _idval_from_value_required(self, val: object, idx: int) -> str:
+        """Like _idval_from_value(), but fails if the type is not supported."""
+        id = self._idval_from_value(val)
+        if id is not None:
+            return id
+
+        # Fail.
+        if self.func_name is not None:
+            prefix = f"In {self.func_name}: "
+        elif self.nodeid is not None:
+            prefix = f"In {self.nodeid}: "
+        else:
+            prefix = ""
+        msg = (
+            f"{prefix}ids contains unsupported value {saferepr(val)} (type: {type(val)!r}) at index {idx}. "
+            "Supported types are: str, bytes, int, float, complex, bool, enum, regex or anything with a __name__."
+        )
+        fail(msg, pytrace=False)
 
-    @property
-    def id(self) -> str:
-        return "-".join(map(str, self._idlist))
+    @staticmethod
+    def _idval_from_argname(argname: str, idx: int) -> str:
+        """Make an ID for a parameter in a ParameterSet from the argument name
+        and the index of the ParameterSet."""
+        return str(argname) + str(idx)
+
+
+@final
+@dataclasses.dataclass(frozen=True)
+class CallSpec2:
+    """A planned parameterized invocation of a test function.
 
-    def setmulti2(
+    Calculated during collection for a given test function's Metafunc.
+    Once collection is over, each callspec is turned into a single Item
+    and stored in item.callspec.
+    """
+
+    # arg name -> arg value which will be passed to the parametrized test
+    # function (direct parameterization).
+    funcargs: Dict[str, object] = dataclasses.field(default_factory=dict)
+    # arg name -> arg value which will be passed to a fixture of the same name
+    # (indirect parametrization).
+    params: Dict[str, object] = dataclasses.field(default_factory=dict)
+    # arg name -> arg index.
+    indices: Dict[str, int] = dataclasses.field(default_factory=dict)
+    # Used for sorting parametrized resources.
+    _arg2scope: Dict[str, Scope] = dataclasses.field(default_factory=dict)
+    # Parts which will be added to the item's name in `[..]` separated by "-".
+    _idlist: List[str] = dataclasses.field(default_factory=list)
+    # Marks which will be applied to the item.
+    marks: List[Mark] = dataclasses.field(default_factory=list)
+
+    def setmulti(
         self,
+        *,
         valtypes: Mapping[str, "Literal['params', 'funcargs']"],
-        argnames: Sequence[str],
+        argnames: Iterable[str],
         valset: Iterable[object],
         id: str,
         marks: Iterable[Union[Mark, MarkDecorator]],
-        scopenum: int,
+        scope: Scope,
         param_index: int,
-    ) -> None:
+    ) -> "CallSpec2":
+        funcargs = self.funcargs.copy()
+        params = self.params.copy()
+        indices = self.indices.copy()
+        arg2scope = self._arg2scope.copy()
         for arg, val in zip(argnames, valset):
-            self._checkargnotcontained(arg)
+            if arg in params or arg in funcargs:
+                raise ValueError(f"duplicate parametrization of {arg!r}")
             valtype_for_arg = valtypes[arg]
             if valtype_for_arg == "params":
-                self.params[arg] = val
+                params[arg] = val
             elif valtype_for_arg == "funcargs":
-                self.funcargs[arg] = val
-            else:  # pragma: no cover
-                assert False, f"Unhandled valtype for arg: {valtype_for_arg}"
-            self.indices[arg] = param_index
-            self._arg2scopenum[arg] = scopenum
-        self._idlist.append(id)
-        self.marks.extend(normalize_mark_list(marks))
+                funcargs[arg] = val
+            else:
+                assert_never(valtype_for_arg)
+            indices[arg] = param_index
+            arg2scope[arg] = scope
+        return CallSpec2(
+            funcargs=funcargs,
+            params=params,
+            indices=indices,
+            _arg2scope=arg2scope,
+            _idlist=[*self._idlist, id],
+            marks=[*self.marks, *normalize_mark_list(marks)],
+        )
+
+    def getparam(self, name: str) -> object:
+        try:
+            return self.params[name]
+        except KeyError as e:
+            raise ValueError(name) from e
+
+    @property
+    def id(self) -> str:
+        return "-".join(self._idlist)
 
 
 @final
 class Metafunc:
-    """Objects passed to the :func:`pytest_generate_tests <_pytest.hookspec.pytest_generate_tests>` hook.
+    """Objects passed to the :hook:`pytest_generate_tests` hook.
 
     They help to inspect a test function and to generate tests according to
     test configuration or values specified in the class or module where a
@@ -959,11 +1198,15 @@ class Metafunc:
         config: Config,
         cls=None,
         module=None,
+        *,
+        _ispytest: bool = False,
     ) -> None:
+        check_ispytest(_ispytest)
+
         #: Access to the underlying :class:`_pytest.python.FunctionDefinition`.
         self.definition = definition
 
-        #: Access to the :class:`_pytest.config.Config` object for the test session.
+        #: Access to the :class:`pytest.Config` object for the test session.
         self.config = config
 
         #: The module object where the test function is defined in.
@@ -978,28 +1221,37 @@ class Metafunc:
         #: Class object where the test function is defined in or ``None``.
         self.cls = cls
 
-        self._calls: List[CallSpec2] = []
         self._arg2fixturedefs = fixtureinfo.name2fixturedefs
 
+        # Result of parametrize().
+        self._calls: List[CallSpec2] = []
+
     def parametrize(
         self,
-        argnames: Union[str, List[str], Tuple[str, ...]],
+        argnames: Union[str, Sequence[str]],
         argvalues: Iterable[Union[ParameterSet, Sequence[object], object]],
         indirect: Union[bool, Sequence[str]] = False,
         ids: Optional[
-            Union[
-                Iterable[Union[None, str, float, int, bool]],
-                Callable[[Any], Optional[object]],
-            ]
+            Union[Iterable[Optional[object]], Callable[[Any], Optional[object]]]
         ] = None,
-        scope: "Optional[_Scope]" = None,
+        scope: "Optional[_ScopeName]" = None,
         *,
         _param_mark: Optional[Mark] = None,
     ) -> None:
         """Add new invocations to the underlying test function using the list
-        of argvalues for the given argnames.  Parametrization is performed
-        during the collection phase.  If you need to setup expensive resources
-        see about setting indirect to do it rather at test setup time.
+        of argvalues for the given argnames. Parametrization is performed
+        during the collection phase. If you need to setup expensive resources
+        see about setting indirect to do it rather than at test setup time.
+
+        Can be called multiple times per test function (but only on different
+        argument names), in which case each call parametrizes all previous
+        parametrizations, e.g.
+
+        ::
+
+            unparametrized:         t
+            parametrize ["x", "y"]: t[x], t[y]
+            parametrize [1, 2]:     t[x-1], t[x-2], t[y-1], t[y-2]
 
         :param argnames:
             A comma-separated string denoting one or more argument names, or
@@ -1048,9 +1300,7 @@ class Metafunc:
             It will also override any fixture-function defined scope, allowing
             to set a dynamic scope using test context or configuration.
         """
-        from _pytest.fixtures import scope2index
-
-        argnames, parameters = ParameterSet._for_parametrize(
+        argnames, parametersets = ParameterSet._for_parametrize(
             argnames,
             argvalues,
             self.function,
@@ -1065,8 +1315,12 @@ class Metafunc:
                 pytrace=False,
             )
 
-        if scope is None:
-            scope = _find_parametrized_scope(argnames, self._arg2fixturedefs, indirect)
+        if scope is not None:
+            scope_ = Scope.from_user(
+                scope, descr=f"parametrize() call in {self.function.__name__}"
+            )
+        else:
+            scope_ = _find_parametrized_scope(argnames, self._arg2fixturedefs, indirect)
 
         self._validate_if_using_arg_names(argnames, indirect)
 
@@ -1078,58 +1332,57 @@ class Metafunc:
             if generated_ids is not None:
                 ids = generated_ids
 
-        ids = self._resolve_arg_ids(
-            argnames, ids, parameters, nodeid=self.definition.nodeid
+        ids = self._resolve_parameter_set_ids(
+            argnames, ids, parametersets, nodeid=self.definition.nodeid
         )
 
         # Store used (possibly generated) ids with parametrize Marks.
         if _param_mark and _param_mark._param_ids_from and generated_ids is None:
             object.__setattr__(_param_mark._param_ids_from, "_param_ids_generated", ids)
 
-        scopenum = scope2index(
-            scope, descr=f"parametrize() call in {self.function.__name__}"
-        )
-
         # Create the new calls: if we are parametrize() multiple times (by applying the decorator
         # more than once) then we accumulate those calls generating the cartesian product
         # of all calls.
         newcalls = []
-        for callspec in self._calls or [CallSpec2(self)]:
-            for param_index, (param_id, param_set) in enumerate(zip(ids, parameters)):
-                newcallspec = callspec.copy()
-                newcallspec.setmulti2(
-                    arg_values_types,
-                    argnames,
-                    param_set.values,
-                    param_id,
-                    param_set.marks,
-                    scopenum,
-                    param_index,
+        for callspec in self._calls or [CallSpec2()]:
+            for param_index, (param_id, param_set) in enumerate(
+                zip(ids, parametersets)
+            ):
+                newcallspec = callspec.setmulti(
+                    valtypes=arg_values_types,
+                    argnames=argnames,
+                    valset=param_set.values,
+                    id=param_id,
+                    marks=param_set.marks,
+                    scope=scope_,
+                    param_index=param_index,
                 )
                 newcalls.append(newcallspec)
         self._calls = newcalls
 
-    def _resolve_arg_ids(
+    def _resolve_parameter_set_ids(
         self,
         argnames: Sequence[str],
         ids: Optional[
-            Union[
-                Iterable[Union[None, str, float, int, bool]],
-                Callable[[Any], Optional[object]],
-            ]
+            Union[Iterable[Optional[object]], Callable[[Any], Optional[object]]]
         ],
-        parameters: Sequence[ParameterSet],
+        parametersets: Sequence[ParameterSet],
         nodeid: str,
     ) -> List[str]:
-        """Resolve the actual ids for the given argnames, based on the ``ids`` parameter given
-        to ``parametrize``.
+        """Resolve the actual ids for the given parameter sets.
 
-        :param List[str] argnames: List of argument names passed to ``parametrize()``.
-        :param ids: The ids parameter of the parametrized call (see docs).
-        :param List[ParameterSet] parameters: The list of parameter values, same size as ``argnames``.
-        :param str str: The nodeid of the item that generated this parametrized call.
-        :rtype: List[str]
-        :returns: The list of ids for each argname given.
+        :param argnames:
+            Argument names passed to ``parametrize()``.
+        :param ids:
+            The `ids` parameter of the ``parametrize()`` call (see docs).
+        :param parametersets:
+            The parameter sets, each containing a set of values corresponding
+            to ``argnames``.
+        :param nodeid str:
+            The nodeid of the definition item that generated this
+            parametrization.
+        :returns:
+            List with ids for each parameter set given.
         """
         if ids is None:
             idfn = None
@@ -1139,15 +1392,24 @@ class Metafunc:
             ids_ = None
         else:
             idfn = None
-            ids_ = self._validate_ids(ids, parameters, self.function.__name__)
-        return idmaker(argnames, parameters, idfn, ids_, self.config, nodeid=nodeid)
+            ids_ = self._validate_ids(ids, parametersets, self.function.__name__)
+        id_maker = IdMaker(
+            argnames,
+            parametersets,
+            idfn,
+            ids_,
+            self.config,
+            nodeid=nodeid,
+            func_name=self.function.__name__,
+        )
+        return id_maker.make_unique_parameterset_ids()
 
     def _validate_ids(
         self,
-        ids: Iterable[Union[None, str, float, int, bool]],
-        parameters: Sequence[ParameterSet],
+        ids: Iterable[Optional[object]],
+        parametersets: Sequence[ParameterSet],
         func_name: str,
-    ) -> List[Union[None, str]]:
+    ) -> List[Optional[object]]:
         try:
             num_ids = len(ids)  # type: ignore[arg-type]
         except TypeError:
@@ -1155,32 +1417,19 @@ class Metafunc:
                 iter(ids)
             except TypeError as e:
                 raise TypeError("ids must be a callable or an iterable") from e
-            num_ids = len(parameters)
+            num_ids = len(parametersets)
 
         # num_ids == 0 is a special case: https://github.com/pytest-dev/pytest/issues/1849
-        if num_ids != len(parameters) and num_ids != 0:
+        if num_ids != len(parametersets) and num_ids != 0:
             msg = "In {}: {} parameter sets specified, with different number of ids: {}"
-            fail(msg.format(func_name, len(parameters), num_ids), pytrace=False)
-
-        new_ids = []
-        for idx, id_value in enumerate(itertools.islice(ids, num_ids)):
-            if id_value is None or isinstance(id_value, str):
-                new_ids.append(id_value)
-            elif isinstance(id_value, (float, int, bool)):
-                new_ids.append(str(id_value))
-            else:
-                msg = (  # type: ignore[unreachable]
-                    "In {}: ids must be list of string/float/int/bool, "
-                    "found: {} (type: {!r}) at index {}"
-                )
-                fail(
-                    msg.format(func_name, saferepr(id_value), type(id_value), idx),
-                    pytrace=False,
-                )
-        return new_ids
+            fail(msg.format(func_name, len(parametersets), num_ids), pytrace=False)
+
+        return list(itertools.islice(ids, num_ids))
 
     def _resolve_arg_value_types(
-        self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
+        self,
+        argnames: Sequence[str],
+        indirect: Union[bool, Sequence[str]],
     ) -> Dict[str, "Literal['params', 'funcargs']"]:
         """Resolve if each parametrized argument must be considered a
         parameter to a fixture or a "funcarg" to the function, based on the
@@ -1218,7 +1467,9 @@ class Metafunc:
         return valtypes
 
     def _validate_if_using_arg_names(
-        self, argnames: Sequence[str], indirect: Union[bool, Sequence[str]],
+        self,
+        argnames: Sequence[str],
+        indirect: Union[bool, Sequence[str]],
     ) -> None:
         """Check if all argnames are being used, by default values, or directly/indirectly.
 
@@ -1252,7 +1503,7 @@ def _find_parametrized_scope(
     argnames: Sequence[str],
     arg2fixturedefs: Mapping[str, Sequence[fixtures.FixtureDef[object]]],
     indirect: Union[bool, Sequence[str]],
-) -> "fixtures._Scope":
+) -> Scope:
     """Find the most appropriate scope for a parametrized call based on its arguments.
 
     When there's at least one direct argument, always use "function" scope.
@@ -1270,17 +1521,14 @@ def _find_parametrized_scope(
     if all_arguments_are_fixtures:
         fixturedefs = arg2fixturedefs or {}
         used_scopes = [
-            fixturedef[0].scope
+            fixturedef[0]._scope
             for name, fixturedef in fixturedefs.items()
             if name in argnames
         ]
-        if used_scopes:
-            # Takes the most narrow scope from used fixtures.
-            for scope in reversed(fixtures.scopes):
-                if scope in used_scopes:
-                    return scope
+        # Takes the most narrow scope from used fixtures.
+        return min(used_scopes, default=Scope.Function)
 
-    return "function"
+    return Scope.Function
 
 
 def _ascii_escaped_by_config(val: Union[str, bytes], config: Optional[Config]) -> str:
@@ -1296,103 +1544,14 @@ def _ascii_escaped_by_config(val: Union[str, bytes], config: Optional[Config]) -
     return val if escape_option else ascii_escaped(val)  # type: ignore
 
 
-def _idval(
-    val: object,
-    argname: str,
-    idx: int,
-    idfn: Optional[Callable[[Any], Optional[object]]],
-    nodeid: Optional[str],
-    config: Optional[Config],
-) -> str:
-    if idfn:
-        try:
-            generated_id = idfn(val)
-            if generated_id is not None:
-                val = generated_id
-        except Exception as e:
-            prefix = f"{nodeid}: " if nodeid is not None else ""
-            msg = "error raised while trying to determine id of parameter '{}' at position {}"
-            msg = prefix + msg.format(argname, idx)
-            raise ValueError(msg) from e
-    elif config:
-        hook_id: Optional[str] = config.hook.pytest_make_parametrize_id(
-            config=config, val=val, argname=argname
-        )
-        if hook_id:
-            return hook_id
-
-    if isinstance(val, STRING_TYPES):
-        return _ascii_escaped_by_config(val, config)
-    elif val is None or isinstance(val, (float, int, bool)):
-        return str(val)
-    elif isinstance(val, REGEX_TYPE):
-        return ascii_escaped(val.pattern)
-    elif val is NOTSET:
-        # Fallback to default. Note that NOTSET is an enum.Enum.
-        pass
-    elif isinstance(val, enum.Enum):
-        return str(val)
-    elif isinstance(getattr(val, "__name__", None), str):
-        # Name of a class, function, module, etc.
-        name: str = getattr(val, "__name__")
-        return name
-    return str(argname) + str(idx)
-
-
-def _idvalset(
-    idx: int,
-    parameterset: ParameterSet,
-    argnames: Iterable[str],
-    idfn: Optional[Callable[[Any], Optional[object]]],
-    ids: Optional[List[Union[None, str]]],
-    nodeid: Optional[str],
-    config: Optional[Config],
-) -> str:
-    if parameterset.id is not None:
-        return parameterset.id
-    id = None if ids is None or idx >= len(ids) else ids[idx]
-    if id is None:
-        this_id = [
-            _idval(val, argname, idx, idfn, nodeid=nodeid, config=config)
-            for val, argname in zip(parameterset.values, argnames)
-        ]
-        return "-".join(this_id)
-    else:
-        return _ascii_escaped_by_config(id, config)
-
-
-def idmaker(
-    argnames: Iterable[str],
-    parametersets: Iterable[ParameterSet],
-    idfn: Optional[Callable[[Any], Optional[object]]] = None,
-    ids: Optional[List[Union[None, str]]] = None,
-    config: Optional[Config] = None,
-    nodeid: Optional[str] = None,
-) -> List[str]:
-    resolved_ids = [
-        _idvalset(
-            valindex, parameterset, argnames, idfn, ids, config=config, nodeid=nodeid
-        )
-        for valindex, parameterset in enumerate(parametersets)
-    ]
-
-    # All IDs must be unique!
-    unique_ids = set(resolved_ids)
-    if len(unique_ids) != len(resolved_ids):
-
-        # Record the number of occurrences of each test ID.
-        test_id_counts = Counter(resolved_ids)
-
-        # Map the test ID to its next suffix.
-        test_id_suffixes: Dict[str, int] = defaultdict(int)
-
-        # Suffix non-unique IDs to make them unique.
-        for index, test_id in enumerate(resolved_ids):
-            if test_id_counts[test_id] > 1:
-                resolved_ids[index] = "{}{}".format(test_id, test_id_suffixes[test_id])
-                test_id_suffixes[test_id] += 1
-
-    return resolved_ids
+def _pretty_fixture_path(func) -> str:
+    cwd = Path.cwd()
+    loc = Path(getlocation(func, str(cwd)))
+    prefix = Path("...", "_pytest")
+    try:
+        return str(prefix / loc.relative_to(_PYTEST_DIR))
+    except ValueError:
+        return bestrelpath(cwd, loc)
 
 
 def show_fixtures_per_test(config):
@@ -1405,27 +1564,27 @@ def _show_fixtures_per_test(config: Config, session: Session) -> None:
     import _pytest.config
 
     session.perform_collect()
-    curdir = py.path.local()
+    curdir = Path.cwd()
     tw = _pytest.config.create_terminal_writer(config)
     verbose = config.getvalue("verbose")
 
-    def get_best_relpath(func):
+    def get_best_relpath(func) -> str:
         loc = getlocation(func, str(curdir))
-        return curdir.bestrelpath(py.path.local(loc))
+        return bestrelpath(curdir, Path(loc))
 
     def write_fixture(fixture_def: fixtures.FixtureDef[object]) -> None:
         argname = fixture_def.argname
         if verbose <= 0 and argname.startswith("_"):
             return
-        if verbose > 0:
-            bestrel = get_best_relpath(fixture_def.func)
-            funcargspec = f"{argname} -- {bestrel}"
-        else:
-            funcargspec = argname
-        tw.line(funcargspec, green=True)
+        prettypath = _pretty_fixture_path(fixture_def.func)
+        tw.write(f"{argname}", green=True)
+        tw.write(f" -- {prettypath}", yellow=True)
+        tw.write("\n")
         fixture_doc = inspect.getdoc(fixture_def.func)
         if fixture_doc:
-            write_docstring(tw, fixture_doc)
+            write_docstring(
+                tw, fixture_doc.split("\n\n")[0] if verbose <= 0 else fixture_doc
+            )
         else:
             tw.line("    no docstring available", red=True)
 
@@ -1438,7 +1597,7 @@ def _show_fixtures_per_test(config: Config, session: Session) -> None:
         tw.line()
         tw.sep("-", f"fixtures used by {item.name}")
         # TODO: Fix this type ignore.
-        tw.sep("-", "({})".format(get_best_relpath(item.function)))  # type: ignore[attr-defined]
+        tw.sep("-", f"({get_best_relpath(item.function)})")  # type: ignore[attr-defined]
         # dict key not used in loop but needed for sorting.
         for _, fixturedefs in sorted(info.name2fixturedefs.items()):
             assert fixturedefs is not None
@@ -1461,7 +1620,7 @@ def _showfixtures_main(config: Config, session: Session) -> None:
     import _pytest.config
 
     session.perform_collect()
-    curdir = py.path.local()
+    curdir = Path.cwd()
     tw = _pytest.config.create_terminal_writer(config)
     verbose = config.getvalue("verbose")
 
@@ -1483,7 +1642,7 @@ def _showfixtures_main(config: Config, session: Session) -> None:
                 (
                     len(fixturedef.baseid),
                     fixturedef.func.__module__,
-                    curdir.bestrelpath(py.path.local(loc)),
+                    _pretty_fixture_path(fixturedef.func),
                     fixturedef.argname,
                     fixturedef,
                 )
@@ -1491,26 +1650,24 @@ def _showfixtures_main(config: Config, session: Session) -> None:
 
     available.sort()
     currentmodule = None
-    for baseid, module, bestrel, argname, fixturedef in available:
+    for baseid, module, prettypath, argname, fixturedef in available:
         if currentmodule != module:
             if not module.startswith("_pytest."):
                 tw.line()
                 tw.sep("-", f"fixtures defined from {module}")
                 currentmodule = module
-        if verbose <= 0 and argname[0] == "_":
+        if verbose <= 0 and argname.startswith("_"):
             continue
-        tw.write(argname, green=True)
+        tw.write(f"{argname}", green=True)
         if fixturedef.scope != "function":
             tw.write(" [%s scope]" % fixturedef.scope, cyan=True)
-        if verbose > 0:
-            tw.write(" -- %s" % bestrel, yellow=True)
+        tw.write(f" -- {prettypath}", yellow=True)
         tw.write("\n")
-        loc = getlocation(fixturedef.func, str(curdir))
         doc = inspect.getdoc(fixturedef.func)
         if doc:
-            write_docstring(tw, doc)
+            write_docstring(tw, doc.split("\n\n")[0] if verbose <= 0 else doc)
         else:
-            tw.line(f"    {loc}: no docstring available", red=True)
+            tw.line("    no docstring available", red=True)
         tw.line()
 
 
@@ -1520,28 +1677,28 @@ def write_docstring(tw: TerminalWriter, doc: str, indent: str = "    ") -> None:
 
 
 class Function(PyobjMixin, nodes.Item):
-    """An Item responsible for setting up and executing a Python test function.
+    """Item responsible for setting up and executing a Python test function.
 
-    param name:
+    :param name:
         The full function name, including any decorations like those
         added by parametrization (``my_func[my_param]``).
-    param parent:
+    :param parent:
         The parent Node.
-    param config:
+    :param config:
         The pytest Config object.
-    param callspec:
+    :param callspec:
         If given, this is function has been parametrized and the callspec contains
         meta information about the parametrization.
-    param callobj:
+    :param callobj:
         If given, the object which will be called when the Function is invoked,
         otherwise the callobj will be obtained from ``parent`` using ``originalname``.
-    param keywords:
+    :param keywords:
         Keywords bound to the function object for "-k" matching.
-    param session:
+    :param session:
         The pytest Session object.
-    param fixtureinfo:
+    :param fixtureinfo:
         Fixture information already resolved at this fixture node..
-    param originalname:
+    :param originalname:
         The attribute name to use for accessing the underlying function object.
         Defaults to ``name``. Set this if name is different from the original name,
         for example when it contains decorations like those added by parametrization
@@ -1558,7 +1715,7 @@ class Function(PyobjMixin, nodes.Item):
         config: Optional[Config] = None,
         callspec: Optional[CallSpec2] = None,
         callobj=NOTSET,
-        keywords=None,
+        keywords: Optional[Mapping[str, Any]] = None,
         session: Optional[Session] = None,
         fixtureinfo: Optional[FuncFixtureInfo] = None,
         originalname: Optional[str] = None,
@@ -1579,31 +1736,20 @@ class Function(PyobjMixin, nodes.Item):
         # Note: when FunctionDefinition is introduced, we should change ``originalname``
         # to a readonly property that returns FunctionDefinition.name.
 
-        self.keywords.update(self.obj.__dict__)
         self.own_markers.extend(get_unpacked_marks(self.obj))
         if callspec:
             self.callspec = callspec
-            # this is total hostile and a mess
-            # keywords are broken by design by now
-            # this will be redeemed later
-            for mark in callspec.marks:
-                # feel free to cry, this was broken for years before
-                # and keywords cant fix it per design
-                self.keywords[mark.name] = mark
-            self.own_markers.extend(normalize_mark_list(callspec.marks))
-        if keywords:
-            self.keywords.update(keywords)
+            self.own_markers.extend(callspec.marks)
 
         # todo: this is a hell of a hack
         # https://github.com/pytest-dev/pytest/issues/4569
-
-        self.keywords.update(
-            {
-                mark.name: True
-                for mark in self.iter_markers()
-                if mark.name not in self.keywords
-            }
-        )
+        # Note: the order of the updates is important here; indicates what
+        # takes priority (ctor argument over function attributes over markers).
+        # Take own_markers only; NodeKeywords handles parent traversal on its own.
+        self.keywords.update((mark.name, mark) for mark in self.own_markers)
+        self.keywords.update(self.obj.__dict__)
+        if keywords:
+            self.keywords.update(keywords)
 
         if fixtureinfo is None:
             fixtureinfo = self.session._fixturemanager.getfixtureinfo(
@@ -1629,7 +1775,12 @@ class Function(PyobjMixin, nodes.Item):
 
     def _getobj(self):
         assert self.parent is not None
-        return getattr(self.parent.obj, self.originalname)  # type: ignore[attr-defined]
+        if isinstance(self.parent, Class):
+            # Each Function gets a fresh class instance.
+            parent_obj = self.parent.newinstance()
+        else:
+            parent_obj = self.parent.obj  # type: ignore[attr-defined]
+        return getattr(parent_obj, self.originalname)
 
     @property
     def _pyfuncitem(self):
@@ -1641,12 +1792,9 @@ class Function(PyobjMixin, nodes.Item):
         self.ihook.pytest_pyfunc_call(pyfuncitem=self)
 
     def setup(self) -> None:
-        if isinstance(self.parent, Instance):
-            self.parent.newinstance()
-            self.obj = self._getobj()
         self._request._fillfixtures()
 
-    def _prunetraceback(self, excinfo: ExceptionInfo[BaseException]) -> None:
+    def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback:
         if hasattr(self, "_obj") and not self.config.getoption("fulltrace", False):
             code = _pytest._code.Code.from_function(get_real_func(self.obj))
             path, firstlineno = code.path, code.firstlineno
@@ -1658,18 +1806,26 @@ class Function(PyobjMixin, nodes.Item):
                     ntraceback = ntraceback.filter(filter_traceback)
                     if not ntraceback:
                         ntraceback = traceback
+            ntraceback = ntraceback.filter(excinfo)
 
-            excinfo.traceback = ntraceback.filter()
             # issue364: mark all but first and last frames to
             # only show a single-line message for each frame.
             if self.config.getoption("tbstyle", "auto") == "auto":
-                if len(excinfo.traceback) > 2:
-                    for entry in excinfo.traceback[1:-1]:
-                        entry.set_repr_style("short")
+                if len(ntraceback) > 2:
+                    ntraceback = Traceback(
+                        entry
+                        if i == 0 or i == len(ntraceback) - 1
+                        else entry.with_repr_style("short")
+                        for i, entry in enumerate(ntraceback)
+                    )
+
+            return ntraceback
+        return excinfo.traceback
 
     # TODO: Type ignored -- breaks Liskov Substitution.
     def repr_failure(  # type: ignore[override]
-        self, excinfo: ExceptionInfo[BaseException],
+        self,
+        excinfo: ExceptionInfo[BaseException],
     ) -> Union[str, TerminalRepr]:
         style = self.config.getoption("tbstyle", "auto")
         if style == "auto":
@@ -1678,10 +1834,8 @@ class Function(PyobjMixin, nodes.Item):
 
 
 class FunctionDefinition(Function):
-    """
-    This class is a step gap solution until we evolve to have actual function definition nodes
-    and manage to get rid of ``metafunc``.
-    """
+    """This class is a stop gap solution until we evolve to have actual function
+    definition nodes and manage to get rid of ``metafunc``."""
 
     def runtest(self) -> None:
         raise RuntimeError("function definitions are not supposed to be run as tests")
index 81ce4f89539b7718ca2b36ca916a58bef9ef2cdc..183356100c549a5f39eac69a9b9ab5ce992407f2 100644 (file)
@@ -1,7 +1,6 @@
 import math
 import pprint
-from collections.abc import Iterable
-from collections.abc import Mapping
+from collections.abc import Collection
 from collections.abc import Sized
 from decimal import Decimal
 from numbers import Complex
@@ -9,10 +8,12 @@ from types import TracebackType
 from typing import Any
 from typing import Callable
 from typing import cast
-from typing import Generic
+from typing import ContextManager
+from typing import List
+from typing import Mapping
 from typing import Optional
-from typing import overload
 from typing import Pattern
+from typing import Sequence
 from typing import Tuple
 from typing import Type
 from typing import TYPE_CHECKING
@@ -26,6 +27,7 @@ if TYPE_CHECKING:
 import _pytest._code
 from _pytest.compat import final
 from _pytest.compat import STRING_TYPES
+from _pytest.compat import overload
 from _pytest.outcomes import fail
 
 
@@ -38,6 +40,32 @@ def _non_numeric_type_error(value, at: Optional[str]) -> TypeError:
     )
 
 
+def _compare_approx(
+    full_object: object,
+    message_data: Sequence[Tuple[str, str, str]],
+    number_of_elements: int,
+    different_ids: Sequence[object],
+    max_abs_diff: float,
+    max_rel_diff: float,
+) -> List[str]:
+    message_list = list(message_data)
+    message_list.insert(0, ("Index", "Obtained", "Expected"))
+    max_sizes = [0, 0, 0]
+    for index, obtained, expected in message_list:
+        max_sizes[0] = max(max_sizes[0], len(index))
+        max_sizes[1] = max(max_sizes[1], len(obtained))
+        max_sizes[2] = max(max_sizes[2], len(expected))
+    explanation = [
+        f"comparison failed. Mismatched elements: {len(different_ids)} / {number_of_elements}:",
+        f"Max absolute difference: {max_abs_diff}",
+        f"Max relative difference: {max_rel_diff}",
+    ] + [
+        f"{indexes:<{max_sizes[0]}} | {obtained:<{max_sizes[1]}} | {expected:<{max_sizes[2]}}"
+        for indexes, obtained, expected in message_list
+    ]
+    return explanation
+
+
 # builtin pytest.approx helper
 
 
@@ -60,11 +88,24 @@ class ApproxBase:
     def __repr__(self) -> str:
         raise NotImplementedError
 
+    def _repr_compare(self, other_side: Any) -> List[str]:
+        return [
+            "comparison failed",
+            f"Obtained: {other_side}",
+            f"Expected: {self}",
+        ]
+
     def __eq__(self, actual) -> bool:
         return all(
             a == self._approx_scalar(x) for a, x in self._yield_comparisons(actual)
         )
 
+    def __bool__(self):
+        __tracebackhide__ = True
+        raise AssertionError(
+            "approx() is not supported in a boolean context.\nDid you mean: `assert a == approx(b)`?"
+        )
+
     # Ignore type because of https://github.com/python/mypy/issues/4266.
     __hash__ = None  # type: ignore
 
@@ -72,6 +113,8 @@ class ApproxBase:
         return not (actual == self)
 
     def _approx_scalar(self, x) -> "ApproxScalar":
+        if isinstance(x, Decimal):
+            return ApproxDecimal(x, rel=self.rel, abs=self.abs, nan_ok=self.nan_ok)
         return ApproxScalar(x, rel=self.rel, abs=self.abs, nan_ok=self.nan_ok)
 
     def _yield_comparisons(self, actual):
@@ -88,12 +131,13 @@ class ApproxBase:
         # a numeric type.  For this reason, the default is to do nothing.  The
         # classes that deal with sequences should reimplement this method to
         # raise if there are any non-numeric elements in the sequence.
-        pass
 
 
-def _recursive_list_map(f, x):
-    if isinstance(x, list):
-        return list(_recursive_list_map(f, xi) for xi in x)
+def _recursive_sequence_map(f, x):
+    """Recursively map a function over a sequence of arbitrary depth"""
+    if isinstance(x, (list, tuple)):
+        seq_type = type(x)
+        return seq_type(_recursive_sequence_map(f, xi) for xi in x)
     else:
         return f(x)
 
@@ -102,9 +146,71 @@ class ApproxNumpy(ApproxBase):
     """Perform approximate comparisons where the expected value is numpy array."""
 
     def __repr__(self) -> str:
-        list_scalars = _recursive_list_map(self._approx_scalar, self.expected.tolist())
+        list_scalars = _recursive_sequence_map(
+            self._approx_scalar, self.expected.tolist()
+        )
         return f"approx({list_scalars!r})"
 
+    def _repr_compare(self, other_side: "ndarray") -> List[str]:
+        import itertools
+        import math
+
+        def get_value_from_nested_list(
+            nested_list: List[Any], nd_index: Tuple[Any, ...]
+        ) -> Any:
+            """
+            Helper function to get the value out of a nested list, given an n-dimensional index.
+            This mimics numpy's indexing, but for raw nested python lists.
+            """
+            value: Any = nested_list
+            for i in nd_index:
+                value = value[i]
+            return value
+
+        np_array_shape = self.expected.shape
+        approx_side_as_seq = _recursive_sequence_map(
+            self._approx_scalar, self.expected.tolist()
+        )
+
+        if np_array_shape != other_side.shape:
+            return [
+                "Impossible to compare arrays with different shapes.",
+                f"Shapes: {np_array_shape} and {other_side.shape}",
+            ]
+
+        number_of_elements = self.expected.size
+        max_abs_diff = -math.inf
+        max_rel_diff = -math.inf
+        different_ids = []
+        for index in itertools.product(*(range(i) for i in np_array_shape)):
+            approx_value = get_value_from_nested_list(approx_side_as_seq, index)
+            other_value = get_value_from_nested_list(other_side, index)
+            if approx_value != other_value:
+                abs_diff = abs(approx_value.expected - other_value)
+                max_abs_diff = max(max_abs_diff, abs_diff)
+                if other_value == 0.0:
+                    max_rel_diff = math.inf
+                else:
+                    max_rel_diff = max(max_rel_diff, abs_diff / abs(other_value))
+                different_ids.append(index)
+
+        message_data = [
+            (
+                str(index),
+                str(get_value_from_nested_list(other_side, index)),
+                str(get_value_from_nested_list(approx_side_as_seq, index)),
+            )
+            for index in different_ids
+        ]
+        return _compare_approx(
+            self.expected,
+            message_data,
+            number_of_elements,
+            different_ids,
+            max_abs_diff,
+            max_rel_diff,
+        )
+
     def __eq__(self, actual) -> bool:
         import numpy as np
 
@@ -119,7 +225,7 @@ class ApproxNumpy(ApproxBase):
         if not np.isscalar(actual) and actual.shape != self.expected.shape:
             return False
 
-        return ApproxBase.__eq__(self, actual)
+        return super().__eq__(actual)
 
     def _yield_comparisons(self, actual):
         import numpy as np
@@ -145,6 +251,51 @@ class ApproxMapping(ApproxBase):
             {k: self._approx_scalar(v) for k, v in self.expected.items()}
         )
 
+    def _repr_compare(self, other_side: Mapping[object, float]) -> List[str]:
+        import math
+
+        approx_side_as_map = {
+            k: self._approx_scalar(v) for k, v in self.expected.items()
+        }
+
+        number_of_elements = len(approx_side_as_map)
+        max_abs_diff = -math.inf
+        max_rel_diff = -math.inf
+        different_ids = []
+        for (approx_key, approx_value), other_value in zip(
+            approx_side_as_map.items(), other_side.values()
+        ):
+            if approx_value != other_value:
+                if approx_value.expected is not None and other_value is not None:
+                    max_abs_diff = max(
+                        max_abs_diff, abs(approx_value.expected - other_value)
+                    )
+                    if approx_value.expected == 0.0:
+                        max_rel_diff = math.inf
+                    else:
+                        max_rel_diff = max(
+                            max_rel_diff,
+                            abs(
+                                (approx_value.expected - other_value)
+                                / approx_value.expected
+                            ),
+                        )
+                different_ids.append(approx_key)
+
+        message_data = [
+            (str(key), str(other_side[key]), str(approx_side_as_map[key]))
+            for key in different_ids
+        ]
+
+        return _compare_approx(
+            self.expected,
+            message_data,
+            number_of_elements,
+            different_ids,
+            max_abs_diff,
+            max_rel_diff,
+        )
+
     def __eq__(self, actual) -> bool:
         try:
             if set(actual.keys()) != set(self.expected.keys()):
@@ -152,7 +303,7 @@ class ApproxMapping(ApproxBase):
         except AttributeError:
             return False
 
-        return ApproxBase.__eq__(self, actual)
+        return super().__eq__(actual)
 
     def _yield_comparisons(self, actual):
         for k in self.expected.keys():
@@ -166,24 +317,65 @@ class ApproxMapping(ApproxBase):
                 raise TypeError(msg.format(key, value, pprint.pformat(self.expected)))
 
 
-class ApproxSequencelike(ApproxBase):
+class ApproxSequenceLike(ApproxBase):
     """Perform approximate comparisons where the expected value is a sequence of numbers."""
 
     def __repr__(self) -> str:
         seq_type = type(self.expected)
-        if seq_type not in (tuple, list, set):
+        if seq_type not in (tuple, list):
             seq_type = list
         return "approx({!r})".format(
             seq_type(self._approx_scalar(x) for x in self.expected)
         )
 
+    def _repr_compare(self, other_side: Sequence[float]) -> List[str]:
+        import math
+
+        if len(self.expected) != len(other_side):
+            return [
+                "Impossible to compare lists with different sizes.",
+                f"Lengths: {len(self.expected)} and {len(other_side)}",
+            ]
+
+        approx_side_as_map = _recursive_sequence_map(self._approx_scalar, self.expected)
+
+        number_of_elements = len(approx_side_as_map)
+        max_abs_diff = -math.inf
+        max_rel_diff = -math.inf
+        different_ids = []
+        for i, (approx_value, other_value) in enumerate(
+            zip(approx_side_as_map, other_side)
+        ):
+            if approx_value != other_value:
+                abs_diff = abs(approx_value.expected - other_value)
+                max_abs_diff = max(max_abs_diff, abs_diff)
+                if other_value == 0.0:
+                    max_rel_diff = math.inf
+                else:
+                    max_rel_diff = max(max_rel_diff, abs_diff / abs(other_value))
+                different_ids.append(i)
+
+        message_data = [
+            (str(i), str(other_side[i]), str(approx_side_as_map[i]))
+            for i in different_ids
+        ]
+
+        return _compare_approx(
+            self.expected,
+            message_data,
+            number_of_elements,
+            different_ids,
+            max_abs_diff,
+            max_rel_diff,
+        )
+
     def __eq__(self, actual) -> bool:
         try:
             if len(actual) != len(self.expected):
                 return False
         except TypeError:
             return False
-        return ApproxBase.__eq__(self, actual)
+        return super().__eq__(actual)
 
     def _yield_comparisons(self, actual):
         return zip(actual, self.expected)
@@ -210,7 +402,6 @@ class ApproxScalar(ApproxBase):
 
         For example, ``1.0 ± 1e-6``, ``(3+4j) ± 5e-6 ∠ ±180°``.
         """
-
         # Don't show a tolerance for values that aren't compared using
         # tolerances, i.e. non-numerics and infinities. Need to call abs to
         # handle complex numbers, e.g. (inf + 1j).
@@ -317,7 +508,7 @@ class ApproxScalar(ApproxBase):
 
         if relative_tolerance < 0:
             raise ValueError(
-                f"relative tolerance can't be negative: {absolute_tolerance}"
+                f"relative tolerance can't be negative: {relative_tolerance}"
             )
         if math.isnan(relative_tolerance):
             raise ValueError("relative tolerance can't be NaN.")
@@ -334,17 +525,15 @@ class ApproxDecimal(ApproxScalar):
 
 
 def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
-    """Assert that two numbers (or two sets of numbers) are equal to each other
+    """Assert that two numbers (or two ordered sequences of numbers) are equal to each other
     within some tolerance.
 
-    Due to the `intricacies of floating-point arithmetic`__, numbers that we
+    Due to the :doc:`python:tutorial/floatingpoint`, numbers that we
     would intuitively expect to be equal are not always so::
 
         >>> 0.1 + 0.2 == 0.3
         False
 
-    __ https://docs.python.org/3/tutorial/floatingpoint.html
-
     This problem is commonly encountered when writing tests, e.g. when making
     sure that floating-point values are what you expect them to be.  One way to
     deal with this problem is to assert that two floating-point numbers are
@@ -368,16 +557,11 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
         >>> 0.1 + 0.2 == approx(0.3)
         True
 
-    The same syntax also works for sequences of numbers::
+    The same syntax also works for ordered sequences of numbers::
 
         >>> (0.1 + 0.2, 0.2 + 0.4) == approx((0.3, 0.6))
         True
 
-    Dictionary *values*::
-
-        >>> {'a': 0.1 + 0.2, 'b': 0.2 + 0.4} == approx({'a': 0.3, 'b': 0.6})
-        True
-
     ``numpy`` arrays::
 
         >>> import numpy as np                                                          # doctest: +SKIP
@@ -390,6 +574,20 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
         >>> np.array([0.1, 0.2]) + np.array([0.2, 0.1]) == approx(0.3) # doctest: +SKIP
         True
 
+    Only ordered sequences are supported, because ``approx`` needs
+    to infer the relative position of the sequences without ambiguity. This means
+    ``sets`` and other unordered sequences are not supported.
+
+    Finally, dictionary *values* can also be compared::
+
+        >>> {'a': 0.1 + 0.2, 'b': 0.2 + 0.4} == approx({'a': 0.3, 'b': 0.6})
+        True
+
+    The comparison will be true if both mappings have the same keys and their
+    respective values match the expected tolerances.
+
+    **Tolerances**
+
     By default, ``approx`` considers numbers within a relative tolerance of
     ``1e-6`` (i.e. one part in a million) of its expected value to be equal.
     This treatment would lead to surprising results if the expected value was
@@ -449,27 +647,22 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
       both ``a`` and ``b``, this test is symmetric (i.e.  neither ``a`` nor
       ``b`` is a "reference value").  You have to specify an absolute tolerance
       if you want to compare to ``0.0`` because there is no tolerance by
-      default.  `More information...`__
-
-      __ https://docs.python.org/3/library/math.html#math.isclose
+      default.  More information: :py:func:`math.isclose`.
 
     - ``numpy.isclose(a, b, rtol=1e-5, atol=1e-8)``: True if the difference
       between ``a`` and ``b`` is less that the sum of the relative tolerance
       w.r.t. ``b`` and the absolute tolerance.  Because the relative tolerance
       is only calculated w.r.t. ``b``, this test is asymmetric and you can
       think of ``b`` as the reference value.  Support for comparing sequences
-      is provided by ``numpy.allclose``.  `More information...`__
-
-      __ https://numpy.org/doc/stable/reference/generated/numpy.isclose.html
+      is provided by :py:func:`numpy.allclose`.  More information:
+      :std:doc:`numpy:reference/generated/numpy.isclose`.
 
     - ``unittest.TestCase.assertAlmostEqual(a, b)``: True if ``a`` and ``b``
       are within an absolute tolerance of ``1e-7``.  No relative tolerance is
-      considered and the absolute tolerance cannot be changed, so this function
-      is not appropriate for very large or very small numbers.  Also, it's only
-      available in subclasses of ``unittest.TestCase`` and it's ugly because it
-      doesn't follow PEP8.  `More information...`__
-
-      __ https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertAlmostEqual
+      considered , so this function is not appropriate for very large or very
+      small numbers.  Also, it's only available in subclasses of ``unittest.TestCase``
+      and it's ugly because it doesn't follow PEP8.  More information:
+      :py:meth:`unittest.TestCase.assertAlmostEqual`.
 
     - ``a == pytest.approx(b, rel=1e-6, abs=1e-12)``: True if the relative
       tolerance is met w.r.t. ``b`` or if the absolute tolerance is met.
@@ -478,11 +671,22 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
       special case that you explicitly specify an absolute tolerance but not a
       relative tolerance, only the absolute tolerance is considered.
 
+    .. note::
+
+        ``approx`` can handle numpy arrays, but we recommend the
+        specialised test helpers in :std:doc:`numpy:reference/routines.testing`
+        if you need support for comparisons, NaNs, or ULP-based tolerances.
+
+        To match strings using regex, you can use
+        `Matches <https://github.com/asottile/re-assert#re_assertmatchespattern-str-args-kwargs>`_
+        from the
+        `re_assert package <https://github.com/asottile/re-assert>`_.
+
     .. warning::
 
        .. versionchanged:: 3.2
 
-       In order to avoid inconsistent behavior, ``TypeError`` is
+       In order to avoid inconsistent behavior, :py:exc:`TypeError` is
        raised for ``>``, ``>=``, ``<`` and ``<=`` comparisons.
        The example below illustrates the problem::
 
@@ -492,9 +696,7 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
        In the second example one expects ``approx(0.1).__le__(0.1 + 1e-10)``
        to be called. But instead, ``approx(0.1).__lt__(0.1 + 1e-10)`` is used to
        comparison. This is because the call hierarchy of rich comparisons
-       follows a fixed behavior. `More information...`__
-
-       __ https://docs.python.org/3/reference/datamodel.html#object.__ge__
+       follows a fixed behavior. More information: :py:meth:`object.__ge__`
 
     .. versionchanged:: 3.7.1
        ``approx`` raises ``TypeError`` when it encounters a dict value or
@@ -530,12 +732,19 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase:
         expected = _as_numpy_array(expected)
         cls = ApproxNumpy
     elif (
-        isinstance(expected, Iterable)
+        hasattr(expected, "__getitem__")
         and isinstance(expected, Sized)
         # Type ignored because the error is wrong -- not unreachable.
         and not isinstance(expected, STRING_TYPES)  # type: ignore[unreachable]
     ):
-        cls = ApproxSequencelike
+        cls = ApproxSequenceLike
+    elif (
+        isinstance(expected, Collection)
+        # Type ignored because the error is wrong -- not unreachable.
+        and not isinstance(expected, STRING_TYPES)  # type: ignore[unreachable]
+    ):
+        msg = f"pytest.approx() only supports ordered sequences, but got: {repr(expected)}"
+        raise TypeError(msg)
     else:
         cls = ApproxScalar
 
@@ -571,48 +780,49 @@ def _as_numpy_array(obj: object) -> Optional["ndarray"]:
 
 # builtin pytest.raises helper
 
-_E = TypeVar("_E", bound=BaseException)
+E = TypeVar("E", bound=BaseException)
 
 
 @overload
 def raises(
-    expected_exception: Union[Type[_E], Tuple[Type[_E], ...]],
+    expected_exception: Union[Type[E], Tuple[Type[E], ...]],
     *,
     match: Optional[Union[str, Pattern[str]]] = ...,
-) -> "RaisesContext[_E]":
+) -> "RaisesContext[E]":
     ...
 
 
 @overload
-def raises(
-    expected_exception: Union[Type[_E], Tuple[Type[_E], ...]],
+def raises(  # noqa: F811
+    expected_exception: Union[Type[E], Tuple[Type[E], ...]],
     func: Callable[..., Any],
     *args: Any,
     **kwargs: Any,
-) -> _pytest._code.ExceptionInfo[_E]:
+) -> _pytest._code.ExceptionInfo[E]:
     ...
 
 
-def raises(
-    expected_exception: Union[Type[_E], Tuple[Type[_E], ...]], *args: Any, **kwargs: Any
-) -> Union["RaisesContext[_E]", _pytest._code.ExceptionInfo[_E]]:
-    r"""Assert that a code block/function call raises ``expected_exception``
-    or raise a failure exception otherwise.
+def raises(  # noqa: F811
+    expected_exception: Union[Type[E], Tuple[Type[E], ...]], *args: Any, **kwargs: Any
+) -> Union["RaisesContext[E]", _pytest._code.ExceptionInfo[E]]:
+    r"""Assert that a code block/function call raises an exception.
 
-    :kwparam match:
+    :param typing.Type[E] | typing.Tuple[typing.Type[E], ...] expected_exception:
+        The expected exception type, or a tuple if one of multiple possible
+        exception types are expected.
+    :kwparam str | typing.Pattern[str] | None match:
         If specified, a string containing a regular expression,
         or a regular expression object, that is tested against the string
-        representation of the exception using ``re.search``. To match a literal
-        string that may contain `special characters`__, the pattern can
-        first be escaped with ``re.escape``.
+        representation of the exception using :func:`re.search`.
+
+        To match a literal string that may contain :ref:`special characters
+        <re-syntax>`, the pattern can first be escaped with :func:`re.escape`.
 
-        (This is only used when ``pytest.raises`` is used as a context manager,
+        (This is only used when :py:func:`pytest.raises` is used as a context manager,
         and passed through to the function otherwise.
-        When using ``pytest.raises`` as a function, you can use:
+        When using :py:func:`pytest.raises` as a function, you can use:
         ``pytest.raises(Exc, func, match="passed on").match("my pattern")``.)
 
-        __ https://docs.python.org/3/library/re.html#regular-expression-syntax
-
     .. currentmodule:: _pytest._code
 
     Use ``pytest.raises`` as a context manager, which will capture the exception of the given
@@ -708,12 +918,18 @@ def raises(
     """
     __tracebackhide__ = True
 
+    if not expected_exception:
+        raise ValueError(
+            f"Expected an exception type or a tuple of exception types, but got `{expected_exception!r}`. "
+            f"Raising exceptions is already understood as failing the test, so you don't need "
+            f"any special code to say 'this should never raise an exception'."
+        )
     if isinstance(expected_exception, type):
-        excepted_exceptions: Tuple[Type[_E], ...] = (expected_exception,)
+        expected_exceptions: Tuple[Type[E], ...] = (expected_exception,)
     else:
-        excepted_exceptions = expected_exception
-    for exc in excepted_exceptions:
-        if not isinstance(exc, type) or not issubclass(exc, BaseException):  # type: ignore[unreachable]
+        expected_exceptions = expected_exception
+    for exc in expected_exceptions:
+        if not isinstance(exc, type) or not issubclass(exc, BaseException):
             msg = "expected exception must be a BaseException type, not {}"  # type: ignore[unreachable]
             not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__
             raise TypeError(msg.format(not_a))
@@ -731,17 +947,11 @@ def raises(
     else:
         func = args[0]
         if not callable(func):
-            raise TypeError(
-                "{!r} object (type: {}) must be callable".format(func, type(func))
-            )
+            raise TypeError(f"{func!r} object (type: {type(func)}) must be callable")
         try:
             func(*args[1:], **kwargs)
         except expected_exception as e:
-            # We just caught the exception - there is a traceback.
-            assert e.__traceback__ is not None
-            return _pytest._code.ExceptionInfo.from_exc_info(
-                (type(e), e, e.__traceback__)
-            )
+            return _pytest._code.ExceptionInfo.from_exception(e)
     fail(message)
 
 
@@ -750,19 +960,19 @@ raises.Exception = fail.Exception  # type: ignore
 
 
 @final
-class RaisesContext(Generic[_E]):
+class RaisesContext(ContextManager[_pytest._code.ExceptionInfo[E]]):
     def __init__(
         self,
-        expected_exception: Union[Type[_E], Tuple[Type[_E], ...]],
+        expected_exception: Union[Type[E], Tuple[Type[E], ...]],
         message: str,
         match_expr: Optional[Union[str, Pattern[str]]] = None,
     ) -> None:
         self.expected_exception = expected_exception
         self.message = message
         self.match_expr = match_expr
-        self.excinfo: Optional[_pytest._code.ExceptionInfo[_E]] = None
+        self.excinfo: Optional[_pytest._code.ExceptionInfo[E]] = None
 
-    def __enter__(self) -> _pytest._code.ExceptionInfo[_E]:
+    def __enter__(self) -> _pytest._code.ExceptionInfo[E]:
         self.excinfo = _pytest._code.ExceptionInfo.for_later()
         return self.excinfo
 
@@ -779,7 +989,7 @@ class RaisesContext(Generic[_E]):
         if not issubclass(exc_type, self.expected_exception):
             return False
         # Cast to narrow the exception type now that it's verified.
-        exc_info = cast(Tuple[Type[_E], _E, TracebackType], (exc_type, exc_val, exc_tb))
+        exc_info = cast(Tuple[Type[E], E, TracebackType], (exc_type, exc_val, exc_tb))
         self.excinfo.fill_unfilled(exc_info)
         if self.match_expr is not None:
             self.excinfo.match(self.match_expr)
diff --git a/src/_pytest/python_path.py b/src/_pytest/python_path.py
new file mode 100644 (file)
index 0000000..cceabbc
--- /dev/null
@@ -0,0 +1,24 @@
+import sys
+
+import pytest
+from pytest import Config
+from pytest import Parser
+
+
+def pytest_addoption(parser: Parser) -> None:
+    parser.addini("pythonpath", type="paths", help="Add paths to sys.path", default=[])
+
+
+@pytest.hookimpl(tryfirst=True)
+def pytest_load_initial_conftests(early_config: Config) -> None:
+    # `pythonpath = a b` will set `sys.path` to `[a, b, x, y, z, ...]`
+    for path in reversed(early_config.getini("pythonpath")):
+        sys.path.insert(0, str(path))
+
+
+@pytest.hookimpl(trylast=True)
+def pytest_unconfigure(config: Config) -> None:
+    for path in config.getini("pythonpath"):
+        path_str = str(path)
+        if path_str in sys.path:
+            sys.path.remove(path_str)
index d872d9da401a7d3ec88925ef51d857e4e27b044f..d76ea020f1966a6768de88ca850ca93a9bcc227e 100644 (file)
@@ -1,6 +1,7 @@
 """Record warnings during test function execution."""
 import re
 import warnings
+from pprint import pformat
 from types import TracebackType
 from typing import Any
 from typing import Callable
@@ -8,7 +9,6 @@ from typing import Generator
 from typing import Iterator
 from typing import List
 from typing import Optional
-from typing import overload
 from typing import Pattern
 from typing import Tuple
 from typing import Type
@@ -16,7 +16,9 @@ from typing import TypeVar
 from typing import Union
 
 from _pytest.compat import final
+from _pytest.compat import overload
 from _pytest.deprecated import check_ispytest
+from _pytest.deprecated import WARNS_NONE_ARG
 from _pytest.fixtures import fixture
 from _pytest.outcomes import fail
 
@@ -28,7 +30,7 @@ T = TypeVar("T")
 def recwarn() -> Generator["WarningsRecorder", None, None]:
     """Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
 
-    See http://docs.python.org/library/warnings.html for information
+    See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
     on warning categories.
     """
     wrec = WarningsRecorder(_ispytest=True)
@@ -45,11 +47,13 @@ def deprecated_call(
 
 
 @overload
-def deprecated_call(func: Callable[..., T], *args: Any, **kwargs: Any) -> T:
+def deprecated_call(  # noqa: F811
+    func: Callable[..., T], *args: Any, **kwargs: Any
+) -> T:
     ...
 
 
-def deprecated_call(
+def deprecated_call(  # noqa: F811
     func: Optional[Callable[..., Any]] = None, *args: Any, **kwargs: Any
 ) -> Union["WarningsRecorder", Any]:
     """Assert that code produces a ``DeprecationWarning`` or ``PendingDeprecationWarning``.
@@ -83,7 +87,7 @@ def deprecated_call(
 
 @overload
 def warns(
-    expected_warning: Optional[Union[Type[Warning], Tuple[Type[Warning], ...]]],
+    expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = ...,
     *,
     match: Optional[Union[str, Pattern[str]]] = ...,
 ) -> "WarningsChecker":
@@ -91,8 +95,8 @@ def warns(
 
 
 @overload
-def warns(
-    expected_warning: Optional[Union[Type[Warning], Tuple[Type[Warning], ...]]],
+def warns(  # noqa: F811
+    expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]],
     func: Callable[..., T],
     *args: Any,
     **kwargs: Any,
@@ -100,23 +104,23 @@ def warns(
     ...
 
 
-def warns(
-    expected_warning: Optional[Union[Type[Warning], Tuple[Type[Warning], ...]]],
+def warns(  # noqa: F811
+    expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = Warning,
     *args: Any,
     match: Optional[Union[str, Pattern[str]]] = None,
     **kwargs: Any,
 ) -> Union["WarningsChecker", Any]:
     r"""Assert that code raises a particular class of warning.
 
-    Specifically, the parameter ``expected_warning`` can be a warning class or
-    sequence of warning classes, and the inside the ``with`` block must issue a warning of that class or
-    classes.
+    Specifically, the parameter ``expected_warning`` can be a warning class or sequence
+    of warning classes, and the code inside the ``with`` block must issue at least one
+    warning of that class or classes.
 
-    This helper produces a list of :class:`warnings.WarningMessage` objects,
-    one for each warning raised.
+    This helper produces a list of :class:`warnings.WarningMessage` objects, one for
+    each warning raised (regardless of whether it is an ``expected_warning`` or not).
 
-    This function can be used as a context manager, or any of the other ways
-    :func:`pytest.raises` can be used::
+    This function can be used as a context manager, which will capture all the raised
+    warnings inside it::
 
         >>> import pytest
         >>> with pytest.warns(RuntimeWarning):
@@ -135,31 +139,45 @@ def warns(
         ...     warnings.warn("this is not here", UserWarning)
         Traceback (most recent call last):
           ...
-        Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted...
+        Failed: DID NOT WARN. No warnings of type ...UserWarning... were emitted...
+
+    **Using with** ``pytest.mark.parametrize``
+
+    When using :ref:`pytest.mark.parametrize ref` it is possible to parametrize tests
+    such that some runs raise a warning and others do not.
+
+    This could be achieved in the same way as with exceptions, see
+    :ref:`parametrizing_conditional_raising` for an example.
 
     """
     __tracebackhide__ = True
     if not args:
         if kwargs:
-            msg = "Unexpected keyword arguments passed to pytest.warns: "
-            msg += ", ".join(sorted(kwargs))
-            msg += "\nUse context-manager form instead?"
-            raise TypeError(msg)
+            argnames = ", ".join(sorted(kwargs))
+            raise TypeError(
+                f"Unexpected keyword arguments passed to pytest.warns: {argnames}"
+                "\nUse context-manager form instead?"
+            )
         return WarningsChecker(expected_warning, match_expr=match, _ispytest=True)
     else:
         func = args[0]
         if not callable(func):
-            raise TypeError(
-                "{!r} object (type: {}) must be callable".format(func, type(func))
-            )
+            raise TypeError(f"{func!r} object (type: {type(func)}) must be callable")
         with WarningsChecker(expected_warning, _ispytest=True):
             return func(*args[1:], **kwargs)
 
 
-class WarningsRecorder(warnings.catch_warnings):
+class WarningsRecorder(warnings.catch_warnings):  # type:ignore[type-arg]
     """A context manager to record raised warnings.
 
+    Each recorded warning is an instance of :class:`warnings.WarningMessage`.
+
     Adapted from `warnings.catch_warnings`.
+
+    .. note::
+        ``DeprecationWarning`` and ``PendingDeprecationWarning`` are treated
+        differently; see :ref:`ensuring_function_triggers`.
+
     """
 
     def __init__(self, *, _ispytest: bool = False) -> None:
@@ -192,7 +210,7 @@ class WarningsRecorder(warnings.catch_warnings):
             if issubclass(w.category, cls):
                 return self._list.pop(i)
         __tracebackhide__ = True
-        raise AssertionError("%r not found in warning list" % cls)
+        raise AssertionError(f"{cls!r} not found in warning list")
 
     def clear(self) -> None:
         """Clear the list of recorded warnings."""
@@ -203,7 +221,7 @@ class WarningsRecorder(warnings.catch_warnings):
     def __enter__(self) -> "WarningsRecorder":  # type: ignore
         if self._entered:
             __tracebackhide__ = True
-            raise RuntimeError("Cannot enter %r twice" % self)
+            raise RuntimeError(f"Cannot enter {self!r} twice")
         _list = super().__enter__()
         # record=True means it's None.
         assert _list is not None
@@ -219,7 +237,7 @@ class WarningsRecorder(warnings.catch_warnings):
     ) -> None:
         if not self._entered:
             __tracebackhide__ = True
-            raise RuntimeError("Cannot exit %r without entering first" % self)
+            raise RuntimeError(f"Cannot exit {self!r} without entering first")
 
         super().__exit__(exc_type, exc_val, exc_tb)
 
@@ -234,7 +252,7 @@ class WarningsChecker(WarningsRecorder):
         self,
         expected_warning: Optional[
             Union[Type[Warning], Tuple[Type[Warning], ...]]
-        ] = None,
+        ] = Warning,
         match_expr: Optional[Union[str, Pattern[str]]] = None,
         *,
         _ispytest: bool = False,
@@ -244,6 +262,7 @@ class WarningsChecker(WarningsRecorder):
 
         msg = "exceptions must be derived from Warning, not %s"
         if expected_warning is None:
+            warnings.warn(WARNS_NONE_ARG, stacklevel=4)
             expected_warning_tup = None
         elif isinstance(expected_warning, tuple):
             for exc in expected_warning:
@@ -268,16 +287,17 @@ class WarningsChecker(WarningsRecorder):
 
         __tracebackhide__ = True
 
+        def found_str():
+            return pformat([record.message for record in self], indent=2)
+
         # only check if we're not currently handling an exception
         if exc_type is None and exc_val is None and exc_tb is None:
             if self.expected_warning is not None:
                 if not any(issubclass(r.category, self.expected_warning) for r in self):
                     __tracebackhide__ = True
                     fail(
-                        "DID NOT WARN. No warnings of type {} was emitted. "
-                        "The list of emitted warnings is: {}.".format(
-                            self.expected_warning, [each.message for each in self]
-                        )
+                        f"DID NOT WARN. No warnings of type {self.expected_warning} were emitted.\n"
+                        f"The list of emitted warnings is: {found_str()}."
                     )
                 elif self.match_expr is not None:
                     for r in self:
@@ -286,11 +306,8 @@ class WarningsChecker(WarningsRecorder):
                                 break
                     else:
                         fail(
-                            "DID NOT WARN. No warnings of type {} matching"
-                            " ('{}') was emitted. The list of emitted warnings"
-                            " is: {}.".format(
-                                self.expected_warning,
-                                self.match_expr,
-                                [each.message for each in self],
-                            )
+                            f"""\
+DID NOT WARN. No warnings of type {self.expected_warning} matching the regex were emitted.
+ Regex: {self.match_expr}
+ Emitted warnings: {found_str()}"""
                         )
index 58f12517c5b3b184a90e4db7271565685568274a..74e8794b23240fdf5d71730f2a3e5f01618e684b 100644 (file)
@@ -1,5 +1,6 @@
+import dataclasses
+import os
 from io import StringIO
-from pathlib import Path
 from pprint import pprint
 from typing import Any
 from typing import cast
@@ -7,6 +8,8 @@ from typing import Dict
 from typing import Iterable
 from typing import Iterator
 from typing import List
+from typing import Mapping
+from typing import NoReturn
 from typing import Optional
 from typing import Tuple
 from typing import Type
@@ -14,9 +17,6 @@ from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
 
-import attr
-import py
-
 from _pytest._code.code import ExceptionChainRepr
 from _pytest._code.code import ExceptionInfo
 from _pytest._code.code import ExceptionRepr
@@ -36,7 +36,6 @@ from _pytest.nodes import Item
 from _pytest.outcomes import skip
 
 if TYPE_CHECKING:
-    from typing import NoReturn
     from typing_extensions import Literal
 
     from _pytest.runner import CallInfo
@@ -65,6 +64,7 @@ class BaseReport:
     ]
     sections: List[Tuple[str, str]]
     nodeid: str
+    outcome: "Literal['passed', 'failed', 'skipped']"
 
     def __init__(self, **kw: Any) -> None:
         self.__dict__.update(kw)
@@ -76,7 +76,9 @@ class BaseReport:
 
     def toterminal(self, out: TerminalWriter) -> None:
         if hasattr(self, "node"):
-            out.line(getworkerinfoline(self.node))
+            worker_info = getworkerinfoline(self.node)
+            if worker_info:
+                out.line(worker_info)
 
         longrepr = self.longrepr
         if longrepr is None:
@@ -141,12 +143,24 @@ class BaseReport:
             content for (prefix, content) in self.get_sections("Captured stderr")
         )
 
-    passed = property(lambda x: x.outcome == "passed")
-    failed = property(lambda x: x.outcome == "failed")
-    skipped = property(lambda x: x.outcome == "skipped")
+    @property
+    def passed(self) -> bool:
+        """Whether the outcome is passed."""
+        return self.outcome == "passed"
+
+    @property
+    def failed(self) -> bool:
+        """Whether the outcome is failed."""
+        return self.outcome == "failed"
+
+    @property
+    def skipped(self) -> bool:
+        """Whether the outcome is skipped."""
+        return self.outcome == "skipped"
 
     @property
     def fspath(self) -> str:
+        """The path portion of the reported node, as a string."""
         return self.nodeid.split("::")[0]
 
     @property
@@ -214,7 +228,7 @@ class BaseReport:
 
 def _report_unserialization_failure(
     type_name: str, report_class: Type[BaseReport], reportdict
-) -> "NoReturn":
+) -> NoReturn:
     url = "https://github.com/pytest-dev/pytest/issues"
     stream = StringIO()
     pprint("-" * 100, stream=stream)
@@ -229,7 +243,10 @@ def _report_unserialization_failure(
 @final
 class TestReport(BaseReport):
     """Basic test report object (also used for setup and teardown calls if
-    they fail)."""
+    they fail).
+
+    Reports can contain arbitrary extra attributes.
+    """
 
     __test__ = False
 
@@ -237,7 +254,7 @@ class TestReport(BaseReport):
         self,
         nodeid: str,
         location: Tuple[str, Optional[int], str],
-        keywords,
+        keywords: Mapping[str, Any],
         outcome: "Literal['passed', 'failed', 'skipped']",
         longrepr: Union[
             None, ExceptionInfo[BaseException], Tuple[str, int, str], str, TerminalRepr
@@ -245,6 +262,8 @@ class TestReport(BaseReport):
         when: "Literal['setup', 'call', 'teardown']",
         sections: Iterable[Tuple[str, str]] = (),
         duration: float = 0,
+        start: float = 0,
+        stop: float = 0,
         user_properties: Optional[Iterable[Tuple[str, object]]] = None,
         **extra,
     ) -> None:
@@ -254,11 +273,13 @@ class TestReport(BaseReport):
         #: A (filesystempath, lineno, domaininfo) tuple indicating the
         #: actual location of a test item - it might be different from the
         #: collected one e.g. if a method is inherited from a different module.
+        #: The filesystempath may be relative to ``config.rootdir``.
+        #: The line number is 0-based.
         self.location: Tuple[str, Optional[int], str] = location
 
         #: A name -> value dictionary containing all keywords and
         #: markers associated with a test invocation.
-        self.keywords = keywords
+        self.keywords: Mapping[str, Any] = keywords
 
         #: Test outcome, always one of "passed", "failed", "skipped".
         self.outcome = outcome
@@ -273,14 +294,19 @@ class TestReport(BaseReport):
         #: defined properties of the test.
         self.user_properties = list(user_properties or [])
 
-        #: List of pairs ``(str, str)`` of extra information which needs to
-        #: marshallable. Used by pytest to add captured text
-        #: from ``stdout`` and ``stderr``, but may be used by other plugins
-        #: to add arbitrary information to reports.
+        #: Tuples of str ``(heading, content)`` with extra information
+        #: for the test report. Used by pytest to add text captured
+        #: from ``stdout``, ``stderr``, and intercepted logging events. May
+        #: be used by other plugins to add arbitrary information to reports.
         self.sections = list(sections)
 
         #: Time it took to run just the test.
-        self.duration = duration
+        self.duration: float = duration
+
+        #: The system time when the call started, in seconds since the epoch.
+        self.start: float = start
+        #: The system time when the call ended, in seconds since the epoch.
+        self.stop: float = stop
 
         self.__dict__.update(extra)
 
@@ -291,11 +317,17 @@ class TestReport(BaseReport):
 
     @classmethod
     def from_item_and_call(cls, item: Item, call: "CallInfo[None]") -> "TestReport":
-        """Create and fill a TestReport with standard item and call info."""
+        """Create and fill a TestReport with standard item and call info.
+
+        :param item: The item.
+        :param call: The call info.
+        """
         when = call.when
         # Remove "collect" from the Literal type -- only for collection calls.
         assert when != "collect"
         duration = call.duration
+        start = call.start
+        stop = call.stop
         keywords = {x: 1 for x in item.keywords}
         excinfo = call.excinfo
         sections = []
@@ -307,7 +339,7 @@ class TestReport(BaseReport):
                 Tuple[str, int, str],
                 str,
                 TerminalRepr,
-            ] = (None)
+            ] = None
         else:
             if not isinstance(excinfo, ExceptionInfo):
                 outcome = "failed"
@@ -315,7 +347,15 @@ class TestReport(BaseReport):
             elif isinstance(excinfo.value, skip.Exception):
                 outcome = "skipped"
                 r = excinfo._getreprcrash()
-                longrepr = (str(r.path), r.lineno, r.message)
+                assert (
+                    r is not None
+                ), "There should always be a traceback entry for skipping a test."
+                if excinfo.value._use_item_location:
+                    path, line = item.reportinfo()[:2]
+                    assert line is not None
+                    longrepr = os.fspath(path), line + 1, r.message
+                else:
+                    longrepr = (str(r.path), r.lineno, r.message)
             else:
                 outcome = "failed"
                 if call.when == "call":
@@ -335,21 +375,28 @@ class TestReport(BaseReport):
             when,
             sections,
             duration,
+            start,
+            stop,
             user_properties=item.user_properties,
         )
 
 
 @final
 class CollectReport(BaseReport):
-    """Collection report object."""
+    """Collection report object.
+
+    Reports can contain arbitrary extra attributes.
+    """
 
     when = "collect"
 
     def __init__(
         self,
         nodeid: str,
-        outcome: "Literal['passed', 'skipped', 'failed']",
-        longrepr,
+        outcome: "Literal['passed', 'failed', 'skipped']",
+        longrepr: Union[
+            None, ExceptionInfo[BaseException], Tuple[str, int, str], str, TerminalRepr
+        ],
         result: Optional[List[Union[Item, Collector]]],
         sections: Iterable[Tuple[str, str]] = (),
         **extra,
@@ -366,17 +413,18 @@ class CollectReport(BaseReport):
         #: The collected items and collection nodes.
         self.result = result or []
 
-        #: List of pairs ``(str, str)`` of extra information which needs to
-        #: marshallable.
-        # Used by pytest to add captured text : from ``stdout`` and ``stderr``,
-        # but may be used by other plugins : to add arbitrary information to
-        # reports.
+        #: Tuples of str ``(heading, content)`` with extra information
+        #: for the test report. Used by pytest to add text captured
+        #: from ``stdout``, ``stderr``, and intercepted logging events. May
+        #: be used by other plugins to add arbitrary information to reports.
         self.sections = list(sections)
 
         self.__dict__.update(extra)
 
     @property
-    def location(self):
+    def location(  # type:ignore[override]
+        self,
+    ) -> Optional[Tuple[str, Optional[int], str]]:
         return (self.fspath, None, self.fspath)
 
     def __repr__(self) -> str:
@@ -428,15 +476,15 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
     def serialize_repr_entry(
         entry: Union[ReprEntry, ReprEntryNative]
     ) -> Dict[str, Any]:
-        data = attr.asdict(entry)
+        data = dataclasses.asdict(entry)
         for key, value in data.items():
             if hasattr(value, "__dict__"):
-                data[key] = attr.asdict(value)
+                data[key] = dataclasses.asdict(value)
         entry_data = {"type": type(entry).__name__, "data": data}
         return entry_data
 
     def serialize_repr_traceback(reprtraceback: ReprTraceback) -> Dict[str, Any]:
-        result = attr.asdict(reprtraceback)
+        result = dataclasses.asdict(reprtraceback)
         result["reprentries"] = [
             serialize_repr_entry(x) for x in reprtraceback.reprentries
         ]
@@ -446,7 +494,7 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
         reprcrash: Optional[ReprFileLocation],
     ) -> Optional[Dict[str, Any]]:
         if reprcrash is not None:
-            return attr.asdict(reprcrash)
+            return dataclasses.asdict(reprcrash)
         else:
             return None
 
@@ -484,8 +532,8 @@ def _report_to_json(report: BaseReport) -> Dict[str, Any]:
     else:
         d["longrepr"] = report.longrepr
     for name in d:
-        if isinstance(d[name], (py.path.local, Path)):
-            d[name] = str(d[name])
+        if isinstance(d[name], os.PathLike):
+            d[name] = os.fspath(d[name])
         elif name == "result":
             d[name] = None  # for now
     return d
@@ -542,7 +590,6 @@ def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]:
         and "reprcrash" in reportdict["longrepr"]
         and "reprtraceback" in reportdict["longrepr"]
     ):
-
         reprtraceback = deserialize_repr_traceback(
             reportdict["longrepr"]["reprtraceback"]
         )
@@ -563,7 +610,10 @@ def _report_kwargs_from_json(reportdict: Dict[str, Any]) -> Dict[str, Any]:
                 ExceptionChainRepr, ReprExceptionInfo
             ] = ExceptionChainRepr(chain)
         else:
-            exception_info = ReprExceptionInfo(reprtraceback, reprcrash)
+            exception_info = ReprExceptionInfo(
+                reprtraceback=reprtraceback,
+                reprcrash=reprcrash,
+            )
 
         for section in reportdict["longrepr"]["sections"]:
             exception_info.addsection(*section)
index 794690ddb0b17b33d14c802e813d1a6df5666d75..f861c05a4516207d4a0d807e4cce8cd557c72ab0 100644 (file)
@@ -1,5 +1,6 @@
 """Basic collect and runtest protocol implementations."""
 import bdb
+import dataclasses
 import os
 import sys
 from typing import Callable
@@ -14,8 +15,6 @@ from typing import TYPE_CHECKING
 from typing import TypeVar
 from typing import Union
 
-import attr
-
 from .reports import BaseReport
 from .reports import CollectErrorRepr
 from .reports import CollectReport
@@ -26,13 +25,18 @@ from _pytest._code.code import ExceptionInfo
 from _pytest._code.code import TerminalRepr
 from _pytest.compat import final
 from _pytest.config.argparsing import Parser
+from _pytest.deprecated import check_ispytest
 from _pytest.nodes import Collector
 from _pytest.nodes import Item
 from _pytest.nodes import Node
 from _pytest.outcomes import Exit
+from _pytest.outcomes import OutcomeException
 from _pytest.outcomes import Skipped
 from _pytest.outcomes import TEST_OUTCOME
 
+if sys.version_info[:2] < (3, 11):
+    from exceptiongroup import BaseExceptionGroup
+
 if TYPE_CHECKING:
     from typing_extensions import Literal
 
@@ -44,14 +48,14 @@ if TYPE_CHECKING:
 
 
 def pytest_addoption(parser: Parser) -> None:
-    group = parser.getgroup("terminal reporting", "reporting", after="general")
+    group = parser.getgroup("terminal reporting", "Reporting", after="general")
     group.addoption(
         "--durations",
         action="store",
         type=int,
         default=None,
         metavar="N",
-        help="show N slowest setup/test durations (N=0 for all).",
+        help="Show N slowest setup/test durations (N=0 for all)",
     )
     group.addoption(
         "--durations-min",
@@ -59,7 +63,8 @@ def pytest_addoption(parser: Parser) -> None:
         type=float,
         default=0.005,
         metavar="N",
-        help="Minimal duration in seconds for inclusion in slowest list. Default 0.005",
+        help="Minimal duration in seconds for inclusion in slowest list. "
+        "Default: 0.005.",
     )
 
 
@@ -100,7 +105,7 @@ def pytest_sessionstart(session: "Session") -> None:
 
 
 def pytest_sessionfinish(session: "Session") -> None:
-    session._setupstate.teardown_all()
+    session._setupstate.teardown_exact(None)
 
 
 def pytest_runtest_protocol(item: Item, nextitem: Optional[Item]) -> bool:
@@ -116,6 +121,8 @@ def runtestprotocol(
 ) -> List[TestReport]:
     hasrequest = hasattr(item, "_request")
     if hasrequest and not item._request:  # type: ignore[attr-defined]
+        # This only happens if the item is re-run, as is done by
+        # pytest-rerunfailures.
         item._initrequest()  # type: ignore[attr-defined]
     rep = call_and_report(item, "setup", log)
     reports = [rep]
@@ -147,7 +154,7 @@ def show_test_item(item: Item) -> None:
 
 def pytest_runtest_setup(item: Item) -> None:
     _update_current_test_var(item, "setup")
-    item.session._setupstate.prepare(item)
+    item.session._setupstate.setup(item)
 
 
 def pytest_runtest_call(item: Item) -> None:
@@ -172,7 +179,7 @@ def pytest_runtest_call(item: Item) -> None:
 
 def pytest_runtest_teardown(item: Item, nextitem: Optional[Item]) -> None:
     _update_current_test_var(item, "teardown")
-    item.session._setupstate.teardown_exact(item, nextitem)
+    item.session._setupstate.teardown_exact(nextitem)
     _update_current_test_var(item, None)
 
 
@@ -260,34 +267,47 @@ TResult = TypeVar("TResult", covariant=True)
 
 
 @final
-@attr.s(repr=False)
+@dataclasses.dataclass
 class CallInfo(Generic[TResult]):
-    """Result/Exception info a function invocation.
-
-    :param T result:
-        The return value of the call, if it didn't raise. Can only be
-        accessed if excinfo is None.
-    :param Optional[ExceptionInfo] excinfo:
-        The captured exception of the call, if it raised.
-    :param float start:
-        The system time when the call started, in seconds since the epoch.
-    :param float stop:
-        The system time when the call ended, in seconds since the epoch.
-    :param float duration:
-        The call duration, in seconds.
-    :param str when:
-        The context of invocation: "setup", "call", "teardown", ...
-    """
-
-    _result = attr.ib(type="Optional[TResult]")
-    excinfo = attr.ib(type=Optional[ExceptionInfo[BaseException]])
-    start = attr.ib(type=float)
-    stop = attr.ib(type=float)
-    duration = attr.ib(type=float)
-    when = attr.ib(type="Literal['collect', 'setup', 'call', 'teardown']")
+    """Result/Exception info of a function invocation."""
+
+    _result: Optional[TResult]
+    #: The captured exception of the call, if it raised.
+    excinfo: Optional[ExceptionInfo[BaseException]]
+    #: The system time when the call started, in seconds since the epoch.
+    start: float
+    #: The system time when the call ended, in seconds since the epoch.
+    stop: float
+    #: The call duration, in seconds.
+    duration: float
+    #: The context of invocation: "collect", "setup", "call" or "teardown".
+    when: "Literal['collect', 'setup', 'call', 'teardown']"
+
+    def __init__(
+        self,
+        result: Optional[TResult],
+        excinfo: Optional[ExceptionInfo[BaseException]],
+        start: float,
+        stop: float,
+        duration: float,
+        when: "Literal['collect', 'setup', 'call', 'teardown']",
+        *,
+        _ispytest: bool = False,
+    ) -> None:
+        check_ispytest(_ispytest)
+        self._result = result
+        self.excinfo = excinfo
+        self.start = start
+        self.stop = stop
+        self.duration = duration
+        self.when = when
 
     @property
     def result(self) -> TResult:
+        """The return value of the call, if it didn't raise.
+
+        Can only be accessed if excinfo is None.
+        """
         if self.excinfo is not None:
             raise AttributeError(f"{self!r} has no valid result")
         # The cast is safe because an exception wasn't raised, hence
@@ -304,6 +324,16 @@ class CallInfo(Generic[TResult]):
             Union[Type[BaseException], Tuple[Type[BaseException], ...]]
         ] = None,
     ) -> "CallInfo[TResult]":
+        """Call func, wrapping the result in a CallInfo.
+
+        :param func:
+            The function to call. Called without arguments.
+        :param when:
+            The phase in which the function is called.
+        :param reraise:
+            Exception or exceptions that shall propagate if raised by the
+            function, instead of being wrapped in the CallInfo.
+        """
         excinfo = None
         start = timing.time()
         precise_start = timing.perf_counter()
@@ -325,6 +355,7 @@ class CallInfo(Generic[TResult]):
             when=when,
             result=result,
             excinfo=excinfo,
+            _ispytest=True,
         )
 
     def __repr__(self) -> str:
@@ -369,87 +400,145 @@ def pytest_make_collect_report(collector: Collector) -> CollectReport:
 
 
 class SetupState:
-    """Shared state for setting up/tearing down test items or collectors."""
+    """Shared state for setting up/tearing down test items or collectors
+    in a session.
 
-    def __init__(self):
-        self.stack: List[Node] = []
-        self._finalizers: Dict[Node, List[Callable[[], object]]] = {}
+    Suppose we have a collection tree as follows:
 
-    def addfinalizer(self, finalizer: Callable[[], object], colitem) -> None:
-        """Attach a finalizer to the given colitem."""
-        assert colitem and not isinstance(colitem, tuple)
-        assert callable(finalizer)
-        # assert colitem in self.stack  # some unit tests don't setup stack :/
-        self._finalizers.setdefault(colitem, []).append(finalizer)
-
-    def _pop_and_teardown(self):
-        colitem = self.stack.pop()
-        self._teardown_with_finalization(colitem)
-
-    def _callfinalizers(self, colitem) -> None:
-        finalizers = self._finalizers.pop(colitem, None)
-        exc = None
-        while finalizers:
-            fin = finalizers.pop()
-            try:
-                fin()
-            except TEST_OUTCOME as e:
-                # XXX Only first exception will be seen by user,
-                #     ideally all should be reported.
-                if exc is None:
-                    exc = e
-        if exc:
-            raise exc
-
-    def _teardown_with_finalization(self, colitem) -> None:
-        self._callfinalizers(colitem)
-        colitem.teardown()
-        for colitem in self._finalizers:
-            assert colitem in self.stack
-
-    def teardown_all(self) -> None:
-        while self.stack:
-            self._pop_and_teardown()
-        for key in list(self._finalizers):
-            self._teardown_with_finalization(key)
-        assert not self._finalizers
+    <Session session>
+        <Module mod1>
+            <Function item1>
+        <Module mod2>
+            <Function item2>
 
-    def teardown_exact(self, item, nextitem) -> None:
-        needed_collectors = nextitem and nextitem.listchain() or []
-        self._teardown_towards(needed_collectors)
+    The SetupState maintains a stack. The stack starts out empty:
 
-    def _teardown_towards(self, needed_collectors) -> None:
-        exc = None
-        while self.stack:
-            if self.stack == needed_collectors[: len(self.stack)]:
-                break
-            try:
-                self._pop_and_teardown()
-            except TEST_OUTCOME as e:
-                # XXX Only first exception will be seen by user,
-                #     ideally all should be reported.
-                if exc is None:
-                    exc = e
-        if exc:
-            raise exc
-
-    def prepare(self, colitem) -> None:
-        """Setup objects along the collector chain to the test-method."""
-
-        # Check if the last collection node has raised an error.
-        for col in self.stack:
-            if hasattr(col, "_prepare_exc"):
-                exc = col._prepare_exc  # type: ignore[attr-defined]
+        []
+
+    During the setup phase of item1, setup(item1) is called. What it does
+    is:
+
+        push session to stack, run session.setup()
+        push mod1 to stack, run mod1.setup()
+        push item1 to stack, run item1.setup()
+
+    The stack is:
+
+        [session, mod1, item1]
+
+    While the stack is in this shape, it is allowed to add finalizers to
+    each of session, mod1, item1 using addfinalizer().
+
+    During the teardown phase of item1, teardown_exact(item2) is called,
+    where item2 is the next item to item1. What it does is:
+
+        pop item1 from stack, run its teardowns
+        pop mod1 from stack, run its teardowns
+
+    mod1 was popped because it ended its purpose with item1. The stack is:
+
+        [session]
+
+    During the setup phase of item2, setup(item2) is called. What it does
+    is:
+
+        push mod2 to stack, run mod2.setup()
+        push item2 to stack, run item2.setup()
+
+    Stack:
+
+        [session, mod2, item2]
+
+    During the teardown phase of item2, teardown_exact(None) is called,
+    because item2 is the last item. What it does is:
+
+        pop item2 from stack, run its teardowns
+        pop mod2 from stack, run its teardowns
+        pop session from stack, run its teardowns
+
+    Stack:
+
+        []
+
+    The end!
+    """
+
+    def __init__(self) -> None:
+        # The stack is in the dict insertion order.
+        self.stack: Dict[
+            Node,
+            Tuple[
+                # Node's finalizers.
+                List[Callable[[], object]],
+                # Node's exception, if its setup raised.
+                Optional[Union[OutcomeException, Exception]],
+            ],
+        ] = {}
+
+    def setup(self, item: Item) -> None:
+        """Setup objects along the collector chain to the item."""
+        needed_collectors = item.listchain()
+
+        # If a collector fails its setup, fail its entire subtree of items.
+        # The setup is not retried for each item - the same exception is used.
+        for col, (finalizers, exc) in self.stack.items():
+            assert col in needed_collectors, "previous item was not torn down properly"
+            if exc:
                 raise exc
 
-        needed_collectors = colitem.listchain()
         for col in needed_collectors[len(self.stack) :]:
-            self.stack.append(col)
+            assert col not in self.stack
+            # Push onto the stack.
+            self.stack[col] = ([col.teardown], None)
             try:
                 col.setup()
-            except TEST_OUTCOME as e:
-                col._prepare_exc = e  # type: ignore[attr-defined]
-                raise e
+            except TEST_OUTCOME as exc:
+                self.stack[col] = (self.stack[col][0], exc)
+                raise exc
+
+    def addfinalizer(self, finalizer: Callable[[], object], node: Node) -> None:
+        """Attach a finalizer to the given node.
+
+        The node must be currently active in the stack.
+        """
+        assert node and not isinstance(node, tuple)
+        assert callable(finalizer)
+        assert node in self.stack, (node, self.stack)
+        self.stack[node][0].append(finalizer)
+
+    def teardown_exact(self, nextitem: Optional[Item]) -> None:
+        """Teardown the current stack up until reaching nodes that nextitem
+        also descends from.
+
+        When nextitem is None (meaning we're at the last item), the entire
+        stack is torn down.
+        """
+        needed_collectors = nextitem and nextitem.listchain() or []
+        exceptions: List[BaseException] = []
+        while self.stack:
+            if list(self.stack.keys()) == needed_collectors[: len(self.stack)]:
+                break
+            node, (finalizers, _) = self.stack.popitem()
+            these_exceptions = []
+            while finalizers:
+                fin = finalizers.pop()
+                try:
+                    fin()
+                except TEST_OUTCOME as e:
+                    these_exceptions.append(e)
+
+            if len(these_exceptions) == 1:
+                exceptions.extend(these_exceptions)
+            elif these_exceptions:
+                msg = f"errors while tearing down {node!r}"
+                exceptions.append(BaseExceptionGroup(msg, these_exceptions[::-1]))
+
+        if len(exceptions) == 1:
+            raise exceptions[0]
+        elif exceptions:
+            raise BaseExceptionGroup("errors during test teardown", exceptions[::-1])
+        if nextitem is None:
+            assert not self.stack
 
 
 def collect_one_node(collector: Collector) -> CollectReport:
diff --git a/src/_pytest/scope.py b/src/_pytest/scope.py
new file mode 100644 (file)
index 0000000..7a746fb
--- /dev/null
@@ -0,0 +1,91 @@
+"""
+Scope definition and related utilities.
+
+Those are defined here, instead of in the 'fixtures' module because
+their use is spread across many other pytest modules, and centralizing it in 'fixtures'
+would cause circular references.
+
+Also this makes the module light to import, as it should.
+"""
+from enum import Enum
+from functools import total_ordering
+from typing import Optional
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+    from typing_extensions import Literal
+
+    _ScopeName = Literal["session", "package", "module", "class", "function"]
+
+
+@total_ordering
+class Scope(Enum):
+    """
+    Represents one of the possible fixture scopes in pytest.
+
+    Scopes are ordered from lower to higher, that is:
+
+              ->>> higher ->>>
+
+    Function < Class < Module < Package < Session
+
+              <<<- lower  <<<-
+    """
+
+    # Scopes need to be listed from lower to higher.
+    Function: "_ScopeName" = "function"
+    Class: "_ScopeName" = "class"
+    Module: "_ScopeName" = "module"
+    Package: "_ScopeName" = "package"
+    Session: "_ScopeName" = "session"
+
+    def next_lower(self) -> "Scope":
+        """Return the next lower scope."""
+        index = _SCOPE_INDICES[self]
+        if index == 0:
+            raise ValueError(f"{self} is the lower-most scope")
+        return _ALL_SCOPES[index - 1]
+
+    def next_higher(self) -> "Scope":
+        """Return the next higher scope."""
+        index = _SCOPE_INDICES[self]
+        if index == len(_SCOPE_INDICES) - 1:
+            raise ValueError(f"{self} is the upper-most scope")
+        return _ALL_SCOPES[index + 1]
+
+    def __lt__(self, other: "Scope") -> bool:
+        self_index = _SCOPE_INDICES[self]
+        other_index = _SCOPE_INDICES[other]
+        return self_index < other_index
+
+    @classmethod
+    def from_user(
+        cls, scope_name: "_ScopeName", descr: str, where: Optional[str] = None
+    ) -> "Scope":
+        """
+        Given a scope name from the user, return the equivalent Scope enum. Should be used
+        whenever we want to convert a user provided scope name to its enum object.
+
+        If the scope name is invalid, construct a user friendly message and call pytest.fail.
+        """
+        from _pytest.outcomes import fail
+
+        try:
+            # Holding this reference is necessary for mypy at the moment.
+            scope = Scope(scope_name)
+        except ValueError:
+            fail(
+                "{} {}got an unexpected scope value '{}'".format(
+                    descr, f"from {where} " if where else "", scope_name
+                ),
+                pytrace=False,
+            )
+        return scope
+
+
+_ALL_SCOPES = list(Scope)
+_SCOPE_INDICES = {scope: index for index, scope in enumerate(_ALL_SCOPES)}
+
+
+# Ordered list of scopes which can contain many tests (in practice all except Function).
+HIGH_SCOPES = [x for x in Scope if x is not Scope.Function]
index 44a1094c0d24faa3c0573ee24e1fd604e49266bc..583590d6b705e2aad11a8084d7efc9b39548cbcd 100644 (file)
@@ -9,6 +9,7 @@ from _pytest.config import ExitCode
 from _pytest.config.argparsing import Parser
 from _pytest.fixtures import FixtureDef
 from _pytest.fixtures import SubRequest
+from _pytest.scope import Scope
 
 
 def pytest_addoption(parser: Parser) -> None:
@@ -17,13 +18,13 @@ def pytest_addoption(parser: Parser) -> None:
         "--setuponly",
         "--setup-only",
         action="store_true",
-        help="only setup fixtures, do not execute tests.",
+        help="Only setup fixtures, do not execute tests",
     )
     group.addoption(
         "--setupshow",
         "--setup-show",
         action="store_true",
-        help="show setup of fixtures while executing tests.",
+        help="Show setup of fixtures while executing tests",
     )
 
 
@@ -64,7 +65,9 @@ def _show_fixture_action(fixturedef: FixtureDef[object], msg: str) -> None:
 
     tw = config.get_terminal_writer()
     tw.line()
-    tw.write(" " * 2 * fixturedef.scopenum)
+    # Use smaller indentation the higher the scope: Session = 0, Package = 1, etc.
+    scope_indent = list(reversed(Scope)).index(fixturedef._scope)
+    tw.write(" " * 2 * scope_indent)
     tw.write(
         "{step} {scope} {fixture}".format(
             step=msg.ljust(8),  # align the output to TEARDOWN
@@ -79,7 +82,7 @@ def _show_fixture_action(fixturedef: FixtureDef[object], msg: str) -> None:
             tw.write(" (fixtures used: {})".format(", ".join(deps)))
 
     if hasattr(fixturedef, "cached_param"):
-        tw.write("[{}]".format(saferepr(fixturedef.cached_param, maxsize=42)))  # type: ignore[attr-defined]
+        tw.write(f"[{saferepr(fixturedef.cached_param, maxsize=42)}]")  # type: ignore[attr-defined]
 
     tw.flush()
 
index 9ba81ccaf0a4f28be0da63bd5881f9cff14a4f1e..1a4ebdd99caeec368d100e383fe68a93771e8901 100644 (file)
@@ -15,8 +15,8 @@ def pytest_addoption(parser: Parser) -> None:
         "--setupplan",
         "--setup-plan",
         action="store_true",
-        help="show what fixtures and tests would be executed but "
-        "don't execute anything.",
+        help="Show what fixtures and tests would be executed but "
+        "don't execute anything",
     )
 
 
index 9aacfecee7a6cb01a944c87d2f35de6d14a52ba1..26ce73758a06cd8ef237c845cb032f098d1c2ee5 100644 (file)
@@ -1,4 +1,5 @@
 """Support for skip/xfail functions and markers."""
+import dataclasses
 import os
 import platform
 import sys
@@ -9,8 +10,6 @@ from typing import Optional
 from typing import Tuple
 from typing import Type
 
-import attr
-
 from _pytest.config import Config
 from _pytest.config import hookimpl
 from _pytest.config.argparsing import Parser
@@ -21,7 +20,7 @@ from _pytest.outcomes import skip
 from _pytest.outcomes import xfail
 from _pytest.reports import BaseReport
 from _pytest.runner import CallInfo
-from _pytest.store import StoreKey
+from _pytest.stash import StashKey
 
 
 def pytest_addoption(parser: Parser) -> None:
@@ -31,12 +30,12 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         dest="runxfail",
         default=False,
-        help="report the results of xfail tests as if they were not marked",
+        help="Report the results of xfail tests as if they were not marked",
     )
 
     parser.addini(
         "xfail_strict",
-        "default for the strict parameter of xfail "
+        "Default for the strict parameter of xfail "
         "markers when not given explicitly (default: False)",
         default=False,
         type="bool",
@@ -49,7 +48,7 @@ def pytest_configure(config: Config) -> None:
         import pytest
 
         old = pytest.xfail
-        config._cleanup.append(lambda: setattr(pytest, "xfail", old))
+        config.add_cleanup(lambda: setattr(pytest, "xfail", old))
 
         def nop(*args, **kwargs):
             pass
@@ -68,7 +67,7 @@ def pytest_configure(config: Config) -> None:
         "skipif(condition, ..., *, reason=...): "
         "skip the given test function if any of the conditions evaluate to True. "
         "Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. "
-        "See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipif",
+        "See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif",
     )
     config.addinivalue_line(
         "markers",
@@ -78,7 +77,7 @@ def pytest_configure(config: Config) -> None:
         "and run=False if you don't even want to execute the test function. "
         "If only specific exception(s) are expected, you can list them in "
         "raises, and if the test fails in other ways, it will be reported as "
-        "a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail",
+        "a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail",
     )
 
 
@@ -157,11 +156,11 @@ def evaluate_condition(item: Item, mark: Mark, condition: object) -> Tuple[bool,
     return result, reason
 
 
-@attr.s(slots=True, frozen=True)
+@dataclasses.dataclass(frozen=True)
 class Skip:
     """The result of evaluate_skip_marks()."""
 
-    reason = attr.ib(type=str)
+    reason: str = "unconditional skip"
 
 
 def evaluate_skip_marks(item: Item) -> Optional[Skip]:
@@ -184,25 +183,24 @@ def evaluate_skip_marks(item: Item) -> Optional[Skip]:
                 return Skip(reason)
 
     for mark in item.iter_markers(name="skip"):
-        if "reason" in mark.kwargs:
-            reason = mark.kwargs["reason"]
-        elif mark.args:
-            reason = mark.args[0]
-        else:
-            reason = "unconditional skip"
-        return Skip(reason)
+        try:
+            return Skip(*mark.args, **mark.kwargs)
+        except TypeError as e:
+            raise TypeError(str(e) + " - maybe you meant pytest.mark.skipif?") from None
 
     return None
 
 
-@attr.s(slots=True, frozen=True)
+@dataclasses.dataclass(frozen=True)
 class Xfail:
     """The result of evaluate_xfail_marks()."""
 
-    reason = attr.ib(type=str)
-    run = attr.ib(type=bool)
-    strict = attr.ib(type=bool)
-    raises = attr.ib(type=Optional[Tuple[Type[BaseException], ...]])
+    __slots__ = ("reason", "run", "strict", "raises")
+
+    reason: str
+    run: bool
+    strict: bool
+    raises: Optional[Tuple[Type[BaseException], ...]]
 
 
 def evaluate_xfail_marks(item: Item) -> Optional[Xfail]:
@@ -230,30 +228,26 @@ def evaluate_xfail_marks(item: Item) -> Optional[Xfail]:
     return None
 
 
-# Whether skipped due to skip or skipif marks.
-skipped_by_mark_key = StoreKey[bool]()
 # Saves the xfail mark evaluation. Can be refreshed during call if None.
-xfailed_key = StoreKey[Optional[Xfail]]()
-unexpectedsuccess_key = StoreKey[str]()
+xfailed_key = StashKey[Optional[Xfail]]()
 
 
 @hookimpl(tryfirst=True)
 def pytest_runtest_setup(item: Item) -> None:
     skipped = evaluate_skip_marks(item)
-    item._store[skipped_by_mark_key] = skipped is not None
     if skipped:
-        skip(skipped.reason)
+        raise skip.Exception(skipped.reason, _use_item_location=True)
 
-    item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item)
+    item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item)
     if xfailed and not item.config.option.runxfail and not xfailed.run:
         xfail("[NOTRUN] " + xfailed.reason)
 
 
 @hookimpl(hookwrapper=True)
 def pytest_runtest_call(item: Item) -> Generator[None, None, None]:
-    xfailed = item._store.get(xfailed_key, None)
+    xfailed = item.stash.get(xfailed_key, None)
     if xfailed is None:
-        item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item)
+        item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item)
 
     if xfailed and not item.config.option.runxfail and not xfailed.run:
         xfail("[NOTRUN] " + xfailed.reason)
@@ -261,25 +255,17 @@ def pytest_runtest_call(item: Item) -> Generator[None, None, None]:
     yield
 
     # The test run may have added an xfail mark dynamically.
-    xfailed = item._store.get(xfailed_key, None)
+    xfailed = item.stash.get(xfailed_key, None)
     if xfailed is None:
-        item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item)
+        item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item)
 
 
 @hookimpl(hookwrapper=True)
 def pytest_runtest_makereport(item: Item, call: CallInfo[None]):
     outcome = yield
     rep = outcome.get_result()
-    xfailed = item._store.get(xfailed_key, None)
-    # unittest special case, see setting of unexpectedsuccess_key
-    if unexpectedsuccess_key in item._store and rep.when == "call":
-        reason = item._store[unexpectedsuccess_key]
-        if reason:
-            rep.longrepr = f"Unexpected success: {reason}"
-        else:
-            rep.longrepr = "Unexpected success"
-        rep.outcome = "failed"
-    elif item.config.option.runxfail:
+    xfailed = item.stash.get(xfailed_key, None)
+    if item.config.option.runxfail:
         pass  # don't interfere
     elif call.excinfo and isinstance(call.excinfo.value, xfail.Exception):
         assert call.excinfo.value.msg is not None
@@ -301,19 +287,6 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]):
                 rep.outcome = "passed"
                 rep.wasxfail = xfailed.reason
 
-    if (
-        item._store.get(skipped_by_mark_key, True)
-        and rep.skipped
-        and type(rep.longrepr) is tuple
-    ):
-        # Skipped by mark.skipif; change the location of the failure
-        # to point to the item definition, otherwise it will display
-        # the location of where the skip exception was raised within pytest.
-        _, _, reason = rep.longrepr
-        filename, line = item.reportinfo()[:2]
-        assert line is not None
-        rep.longrepr = str(filename), line + 1, reason
-
 
 def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str]]:
     if hasattr(report, "wasxfail"):
diff --git a/src/_pytest/stash.py b/src/_pytest/stash.py
new file mode 100644 (file)
index 0000000..e61d75b
--- /dev/null
@@ -0,0 +1,112 @@
+from typing import Any
+from typing import cast
+from typing import Dict
+from typing import Generic
+from typing import TypeVar
+from typing import Union
+
+
+__all__ = ["Stash", "StashKey"]
+
+
+T = TypeVar("T")
+D = TypeVar("D")
+
+
+class StashKey(Generic[T]):
+    """``StashKey`` is an object used as a key to a :class:`Stash`.
+
+    A ``StashKey`` is associated with the type ``T`` of the value of the key.
+
+    A ``StashKey`` is unique and cannot conflict with another key.
+    """
+
+    __slots__ = ()
+
+
+class Stash:
+    r"""``Stash`` is a type-safe heterogeneous mutable mapping that
+    allows keys and value types to be defined separately from
+    where it (the ``Stash``) is created.
+
+    Usually you will be given an object which has a ``Stash``, for example
+    :class:`~pytest.Config` or a :class:`~_pytest.nodes.Node`:
+
+    .. code-block:: python
+
+        stash: Stash = some_object.stash
+
+    If a module or plugin wants to store data in this ``Stash``, it creates
+    :class:`StashKey`\s for its keys (at the module level):
+
+    .. code-block:: python
+
+        # At the top-level of the module
+        some_str_key = StashKey[str]()
+        some_bool_key = StashKey[bool]()
+
+    To store information:
+
+    .. code-block:: python
+
+        # Value type must match the key.
+        stash[some_str_key] = "value"
+        stash[some_bool_key] = True
+
+    To retrieve the information:
+
+    .. code-block:: python
+
+        # The static type of some_str is str.
+        some_str = stash[some_str_key]
+        # The static type of some_bool is bool.
+        some_bool = stash[some_bool_key]
+    """
+
+    __slots__ = ("_storage",)
+
+    def __init__(self) -> None:
+        self._storage: Dict[StashKey[Any], object] = {}
+
+    def __setitem__(self, key: StashKey[T], value: T) -> None:
+        """Set a value for key."""
+        self._storage[key] = value
+
+    def __getitem__(self, key: StashKey[T]) -> T:
+        """Get the value for key.
+
+        Raises ``KeyError`` if the key wasn't set before.
+        """
+        return cast(T, self._storage[key])
+
+    def get(self, key: StashKey[T], default: D) -> Union[T, D]:
+        """Get the value for key, or return default if the key wasn't set
+        before."""
+        try:
+            return self[key]
+        except KeyError:
+            return default
+
+    def setdefault(self, key: StashKey[T], default: T) -> T:
+        """Return the value of key if already set, otherwise set the value
+        of key to default and return default."""
+        try:
+            return self[key]
+        except KeyError:
+            self[key] = default
+            return default
+
+    def __delitem__(self, key: StashKey[T]) -> None:
+        """Delete the value for key.
+
+        Raises ``KeyError`` if the key wasn't set before.
+        """
+        del self._storage[key]
+
+    def __contains__(self, key: StashKey[T]) -> bool:
+        """Return whether key was set."""
+        return key in self._storage
+
+    def __len__(self) -> int:
+        """Return how many items exist in the stash."""
+        return len(self._storage)
index 197577c790f1fcf1bde012f8ddcbe75e6ab372b3..74ad9dbd4dd192a0718327cf14f0b4b3014633fc 100644 (file)
@@ -23,7 +23,7 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         default=False,
         dest="stepwise",
-        help="exit on test failure and continue from last failing test next time",
+        help="Exit on test failure and continue from last failing test next time",
     )
     group.addoption(
         "--sw-skip",
@@ -31,13 +31,16 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         default=False,
         dest="stepwise_skip",
-        help="ignore the first failing test but stop on the next failing test",
+        help="Ignore the first failing test but stop on the next failing test. "
+        "Implicitly enables --stepwise.",
     )
 
 
 @pytest.hookimpl
 def pytest_configure(config: Config) -> None:
-    # We should always have a cache as cache provider plugin uses tryfirst=True
+    if config.option.stepwise_skip:
+        # allow --stepwise-skip to work on it's own merits.
+        config.option.stepwise = True
     if config.getoption("stepwise"):
         config.pluginmanager.register(StepwisePlugin(config), "stepwiseplugin")
 
@@ -45,6 +48,10 @@ def pytest_configure(config: Config) -> None:
 def pytest_sessionfinish(session: Session) -> None:
     if not session.config.getoption("stepwise"):
         assert session.config.cache is not None
+        if hasattr(session.config, "workerinput"):
+            # Do not update cache if this process is a xdist worker to prevent
+            # race conditions (#10641).
+            return
         # Clear the list of failing tests if the plugin is not active.
         session.config.cache.set(STEPWISE_CACHE_DIR, [])
 
@@ -116,4 +123,8 @@ class StepwisePlugin:
         return None
 
     def pytest_sessionfinish(self) -> None:
+        if hasattr(self.config, "workerinput"):
+            # Do not update cache if this process is a xdist worker to prevent
+            # race conditions (#10641).
+            return
         self.cache.set(STEPWISE_CACHE_DIR, self.lastfailed)
diff --git a/src/_pytest/store.py b/src/_pytest/store.py
deleted file mode 100644 (file)
index e5008cf..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-from typing import Any
-from typing import cast
-from typing import Dict
-from typing import Generic
-from typing import TypeVar
-from typing import Union
-
-
-__all__ = ["Store", "StoreKey"]
-
-
-T = TypeVar("T")
-D = TypeVar("D")
-
-
-class StoreKey(Generic[T]):
-    """StoreKey is an object used as a key to a Store.
-
-    A StoreKey is associated with the type T of the value of the key.
-
-    A StoreKey is unique and cannot conflict with another key.
-    """
-
-    __slots__ = ()
-
-
-class Store:
-    """Store is a type-safe heterogenous mutable mapping that
-    allows keys and value types to be defined separately from
-    where it (the Store) is created.
-
-    Usually you will be given an object which has a ``Store``:
-
-    .. code-block:: python
-
-        store: Store = some_object.store
-
-    If a module wants to store data in this Store, it creates StoreKeys
-    for its keys (at the module level):
-
-    .. code-block:: python
-
-        some_str_key = StoreKey[str]()
-        some_bool_key = StoreKey[bool]()
-
-    To store information:
-
-    .. code-block:: python
-
-        # Value type must match the key.
-        store[some_str_key] = "value"
-        store[some_bool_key] = True
-
-    To retrieve the information:
-
-    .. code-block:: python
-
-        # The static type of some_str is str.
-        some_str = store[some_str_key]
-        # The static type of some_bool is bool.
-        some_bool = store[some_bool_key]
-
-    Why use this?
-    -------------
-
-    Problem: module Internal defines an object. Module External, which
-    module Internal doesn't know about, receives the object and wants to
-    attach information to it, to be retrieved later given the object.
-
-    Bad solution 1: Module External assigns private attributes directly on
-    the object. This doesn't work well because the type checker doesn't
-    know about these attributes and it complains about undefined attributes.
-
-    Bad solution 2: module Internal adds a ``Dict[str, Any]`` attribute to
-    the object. Module External stores its data in private keys of this dict.
-    This doesn't work well because retrieved values are untyped.
-
-    Good solution: module Internal adds a ``Store`` to the object. Module
-    External mints StoreKeys for its own keys. Module External stores and
-    retrieves its data using these keys.
-    """
-
-    __slots__ = ("_store",)
-
-    def __init__(self) -> None:
-        self._store: Dict[StoreKey[Any], object] = {}
-
-    def __setitem__(self, key: StoreKey[T], value: T) -> None:
-        """Set a value for key."""
-        self._store[key] = value
-
-    def __getitem__(self, key: StoreKey[T]) -> T:
-        """Get the value for key.
-
-        Raises ``KeyError`` if the key wasn't set before.
-        """
-        return cast(T, self._store[key])
-
-    def get(self, key: StoreKey[T], default: D) -> Union[T, D]:
-        """Get the value for key, or return default if the key wasn't set
-        before."""
-        try:
-            return self[key]
-        except KeyError:
-            return default
-
-    def setdefault(self, key: StoreKey[T], default: T) -> T:
-        """Return the value of key if already set, otherwise set the value
-        of key to default and return default."""
-        try:
-            return self[key]
-        except KeyError:
-            self[key] = default
-            return default
-
-    def __delitem__(self, key: StoreKey[T]) -> None:
-        """Delete the value for key.
-
-        Raises ``KeyError`` if the key wasn't set before.
-        """
-        del self._store[key]
-
-    def __contains__(self, key: StoreKey[T]) -> bool:
-        """Return whether key was set."""
-        return key in self._store
index fbfb09aecfb0869ff6f423cd2f4df8ec2c47d97d..b0cdb58ce00ff833bc049b11db56b1cb48e56178 100644 (file)
@@ -3,10 +3,12 @@
 This is a good source for looking at the various reporting hooks.
 """
 import argparse
+import dataclasses
 import datetime
 import inspect
 import platform
 import sys
+import textwrap
 import warnings
 from collections import Counter
 from functools import partial
@@ -14,10 +16,12 @@ from pathlib import Path
 from typing import Any
 from typing import Callable
 from typing import cast
+from typing import ClassVar
 from typing import Dict
 from typing import Generator
 from typing import List
 from typing import Mapping
+from typing import NamedTuple
 from typing import Optional
 from typing import Sequence
 from typing import Set
@@ -26,16 +30,16 @@ from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import Union
 
-import attr
 import pluggy
-import py
 
 import _pytest._version
 from _pytest import nodes
 from _pytest import timing
 from _pytest._code import ExceptionInfo
 from _pytest._code.code import ExceptionRepr
+from _pytest._io import TerminalWriter
 from _pytest._io.wcwidth import wcswidth
+from _pytest.assertion.util import running_on_ci
 from _pytest.compat import final
 from _pytest.config import _PluggyPlugin
 from _pytest.config import Config
@@ -109,29 +113,49 @@ class MoreQuietAction(argparse.Action):
         namespace.quiet = getattr(namespace, "quiet", 0) + 1
 
 
+class TestShortLogReport(NamedTuple):
+    """Used to store the test status result category, shortletter and verbose word.
+    For example ``"rerun", "R", ("RERUN", {"yellow": True})``.
+
+    :ivar category:
+        The class of result, for example ``“passed”``, ``“skipped”``, ``“error”``, or the empty string.
+
+    :ivar letter:
+        The short letter shown as testing progresses, for example ``"."``, ``"s"``, ``"E"``, or the empty string.
+
+    :ivar word:
+        Verbose word is shown as testing progresses in verbose mode, for example ``"PASSED"``, ``"SKIPPED"``,
+        ``"ERROR"``, or the empty string.
+    """
+
+    category: str
+    letter: str
+    word: Union[str, Tuple[str, Mapping[str, bool]]]
+
+
 def pytest_addoption(parser: Parser) -> None:
-    group = parser.getgroup("terminal reporting", "reporting", after="general")
+    group = parser.getgroup("terminal reporting", "Reporting", after="general")
     group._addoption(
         "-v",
         "--verbose",
         action="count",
         default=0,
         dest="verbose",
-        help="increase verbosity.",
+        help="Increase verbosity",
     )
     group._addoption(
         "--no-header",
         action="store_true",
         default=False,
         dest="no_header",
-        help="disable header",
+        help="Disable header",
     )
     group._addoption(
         "--no-summary",
         action="store_true",
         default=False,
         dest="no_summary",
-        help="disable summary",
+        help="Disable summary",
     )
     group._addoption(
         "-q",
@@ -139,14 +163,14 @@ def pytest_addoption(parser: Parser) -> None:
         action=MoreQuietAction,
         default=0,
         dest="verbose",
-        help="decrease verbosity.",
+        help="Decrease verbosity",
     )
     group._addoption(
         "--verbosity",
         dest="verbose",
         type=int,
         default=0,
-        help="set verbosity. Default is 0.",
+        help="Set verbosity. Default: 0.",
     )
     group._addoption(
         "-r",
@@ -154,7 +178,7 @@ def pytest_addoption(parser: Parser) -> None:
         dest="reportchars",
         default=_REPORTCHARS_DEFAULT,
         metavar="chars",
-        help="show extra test summary info as specified by chars: (f)ailed, "
+        help="Show extra test summary info as specified by chars: (f)ailed, "
         "(E)rror, (s)kipped, (x)failed, (X)passed, "
         "(p)assed, (P)assed with output, (a)ll except passed (p/P), or (A)ll. "
         "(w)arnings are enabled by default (see --disable-warnings), "
@@ -166,7 +190,7 @@ def pytest_addoption(parser: Parser) -> None:
         default=False,
         dest="disable_warnings",
         action="store_true",
-        help="disable warnings summary",
+        help="Disable warnings summary",
     )
     group._addoption(
         "-l",
@@ -174,7 +198,13 @@ def pytest_addoption(parser: Parser) -> None:
         action="store_true",
         dest="showlocals",
         default=False,
-        help="show locals in tracebacks (disabled by default).",
+        help="Show locals in tracebacks (disabled by default)",
+    )
+    group._addoption(
+        "--no-showlocals",
+        action="store_false",
+        dest="showlocals",
+        help="Hide locals in tracebacks (negate --showlocals passed through addopts)",
     )
     group._addoption(
         "--tb",
@@ -183,7 +213,7 @@ def pytest_addoption(parser: Parser) -> None:
         dest="tbstyle",
         default="auto",
         choices=["auto", "long", "short", "no", "line", "native"],
-        help="traceback print mode (auto/long/short/line/native/no).",
+        help="Traceback print mode (auto/long/short/line/native/no)",
     )
     group._addoption(
         "--show-capture",
@@ -192,14 +222,14 @@ def pytest_addoption(parser: Parser) -> None:
         choices=["no", "stdout", "stderr", "log", "all"],
         default="all",
         help="Controls how captured stdout/stderr/log is shown on failed tests. "
-        "Default is 'all'.",
+        "Default: all.",
     )
     group._addoption(
         "--fulltrace",
         "--full-trace",
         action="store_true",
         default=False,
-        help="don't cut any tracebacks (default is to cut).",
+        help="Don't cut any tracebacks (default is to cut)",
     )
     group._addoption(
         "--color",
@@ -208,18 +238,21 @@ def pytest_addoption(parser: Parser) -> None:
         dest="color",
         default="auto",
         choices=["yes", "no", "auto"],
-        help="color terminal output (yes/no/auto).",
+        help="Color terminal output (yes/no/auto)",
     )
     group._addoption(
         "--code-highlight",
         default="yes",
         choices=["yes", "no"],
-        help="Whether code should be highlighted (only if --color is also enabled)",
+        help="Whether code should be highlighted (only if --color is also enabled). "
+        "Default: yes.",
     )
 
     parser.addini(
         "console_output_style",
-        help='console output: "classic", or with additional progress information ("progress" (percentage) | "count").',
+        help='Console output: "classic", or with additional progress information '
+        '("progress" (percentage) | "count" | "progress-even-when-capture-no" (forces '
+        "progress even when capture=no)",
         default="progress",
     )
 
@@ -277,7 +310,7 @@ def pytest_report_teststatus(report: BaseReport) -> Tuple[str, str, str]:
     return outcome, letter, outcome.upper()
 
 
-@attr.s
+@dataclasses.dataclass
 class WarningReport:
     """Simple structure to hold warnings information captured by ``pytest_warning_recorded``.
 
@@ -285,30 +318,24 @@ class WarningReport:
         User friendly message about the warning.
     :ivar str|None nodeid:
         nodeid that generated the warning (see ``get_location``).
-    :ivar tuple|py.path.local fslocation:
+    :ivar tuple fslocation:
         File system location of the source of the warning (see ``get_location``).
     """
 
-    message = attr.ib(type=str)
-    nodeid = attr.ib(type=Optional[str], default=None)
-    fslocation = attr.ib(
-        type=Optional[Union[Tuple[str, int], py.path.local]], default=None
-    )
-    count_towards_summary = True
+    message: str
+    nodeid: Optional[str] = None
+    fslocation: Optional[Tuple[str, int]] = None
+
+    count_towards_summary: ClassVar = True
 
     def get_location(self, config: Config) -> Optional[str]:
         """Return the more user-friendly information about the location of a warning, or None."""
         if self.nodeid:
             return self.nodeid
         if self.fslocation:
-            if isinstance(self.fslocation, tuple) and len(self.fslocation) >= 2:
-                filename, linenum = self.fslocation[:2]
-                relpath = bestrelpath(
-                    config.invocation_params.dir, absolutepath(filename)
-                )
-                return f"{relpath}:{linenum}"
-            else:
-                return str(self.fslocation)
+            filename, linenum = self.fslocation
+            relpath = bestrelpath(config.invocation_params.dir, absolutepath(filename))
+            return f"{relpath}:{linenum}"
         return None
 
 
@@ -325,7 +352,6 @@ class TerminalReporter:
         self.stats: Dict[str, List[Any]] = {}
         self._main_color: Optional[str] = None
         self._known_types: Optional[List[str]] = None
-        self.startdir = config.invocation_dir
         self.startpath = config.invocation_params.dir
         if file is None:
             file = sys.stdout
@@ -343,14 +369,19 @@ class TerminalReporter:
 
     def _determine_show_progress_info(self) -> "Literal['progress', 'count', False]":
         """Return whether we should display progress information based on the current config."""
-        # do not show progress if we are not capturing output (#3038)
-        if self.config.getoption("capture", "no") == "no":
+        # do not show progress if we are not capturing output (#3038) unless explicitly
+        # overridden by progress-even-when-capture-no
+        if (
+            self.config.getoption("capture", "no") == "no"
+            and self.config.getini("console_output_style")
+            != "progress-even-when-capture-no"
+        ):
             return False
         # do not show progress if we are showing fixture setup/teardown
         if self.config.getoption("setupshow", False):
             return False
         cfg: str = self.config.getini("console_output_style")
-        if cfg == "progress":
+        if cfg == "progress" or cfg == "progress-even-when-capture-no":
             return "progress"
         elif cfg == "count":
             return "count"
@@ -417,6 +448,28 @@ class TerminalReporter:
             self._tw.line()
             self.currentfspath = None
 
+    def wrap_write(
+        self,
+        content: str,
+        *,
+        flush: bool = False,
+        margin: int = 8,
+        line_sep: str = "\n",
+        **markup: bool,
+    ) -> None:
+        """Wrap message with margin for progress info."""
+        width_of_current_line = self._tw.width_of_current_line
+        wrapped = line_sep.join(
+            textwrap.wrap(
+                " " * width_of_current_line + content,
+                width=self._screen_width - margin,
+                drop_whitespace=True,
+                replace_whitespace=False,
+            ),
+        )
+        wrapped = wrapped[width_of_current_line:]
+        self._tw.write(wrapped, flush=flush, **markup)
+
     def write(self, content: str, *, flush: bool = False, **markup: bool) -> None:
         self._tw.write(content, flush=flush, **markup)
 
@@ -475,7 +528,9 @@ class TerminalReporter:
         return True
 
     def pytest_warning_recorded(
-        self, warning_message: warnings.WarningMessage, nodeid: str,
+        self,
+        warning_message: warnings.WarningMessage,
+        nodeid: str,
     ) -> None:
         from _pytest.warnings import warning_record_to_str
 
@@ -514,10 +569,11 @@ class TerminalReporter:
     def pytest_runtest_logreport(self, report: TestReport) -> None:
         self._tests_ran = True
         rep = report
-        res: Tuple[
-            str, str, Union[str, Tuple[str, Mapping[str, bool]]]
-        ] = self.config.hook.pytest_report_teststatus(report=rep, config=self.config)
-        category, letter, word = res
+
+        res = TestShortLogReport(
+            *self.config.hook.pytest_report_teststatus(report=rep, config=self.config)
+        )
+        category, letter, word = res.category, res.letter, res.word
         if not isinstance(word, tuple):
             markup = None
         else:
@@ -547,15 +603,21 @@ class TerminalReporter:
             if not running_xdist:
                 self.write_ensure_prefix(line, word, **markup)
                 if rep.skipped or hasattr(report, "wasxfail"):
-                    available_width = (
-                        (self._tw.fullwidth - self._tw.width_of_current_line)
-                        - len(" [100%]")
-                        - 1
-                    )
                     reason = _get_raw_skip_reason(rep)
-                    reason_ = _format_trimmed(" ({})", reason, available_width)
-                    if reason and reason_ is not None:
-                        self._tw.write(reason_)
+                    if self.config.option.verbose < 2:
+                        available_width = (
+                            (self._tw.fullwidth - self._tw.width_of_current_line)
+                            - len(" [100%]")
+                            - 1
+                        )
+                        formatted_reason = _format_trimmed(
+                            " ({})", reason, available_width
+                        )
+                    else:
+                        formatted_reason = f" ({reason})"
+
+                    if reason and formatted_reason is not None:
+                        self.wrap_write(formatted_reason)
                 if self._show_progress_info:
                     self._write_progress_information_filling_space()
             else:
@@ -582,7 +644,7 @@ class TerminalReporter:
         if self.verbosity <= 0 and self._show_progress_info:
             if self._show_progress_info == "count":
                 num_tests = self._session.testscollected
-                progress_length = len(" [{}/{}]".format(str(num_tests), str(num_tests)))
+                progress_length = len(f" [{num_tests}/{num_tests}]")
             else:
                 progress_length = len(" [100%]")
 
@@ -604,7 +666,7 @@ class TerminalReporter:
         if self._show_progress_info == "count":
             if collected:
                 progress = self._progress_nodeids_reported
-                counter_format = "{{:{}d}}".format(len(str(collected)))
+                counter_format = f"{{:{len(str(collected))}d}}"
                 format_string = f" [{counter_format}/{{}}]"
                 return format_string.format(len(progress), collected)
             return f" [ {collected} / {collected} ]"
@@ -662,11 +724,8 @@ class TerminalReporter:
         errors = len(self.stats.get("error", []))
         skipped = len(self.stats.get("skipped", []))
         deselected = len(self.stats.get("deselected", []))
-        selected = self._numcollected - errors - skipped - deselected
-        if final:
-            line = "collected "
-        else:
-            line = "collecting "
+        selected = self._numcollected - deselected
+        line = "collected " if final else "collecting "
         line += (
             str(self._numcollected) + " item" + ("" if self._numcollected == 1 else "s")
         )
@@ -676,7 +735,7 @@ class TerminalReporter:
             line += " / %d deselected" % deselected
         if skipped:
             line += " / %d skipped" % skipped
-        if self._numcollected > selected > 0:
+        if self._numcollected > selected:
             line += " / %d selected" % selected
         if self.isatty:
             self.rewrite(line, bold=True, erase=True)
@@ -698,9 +757,9 @@ class TerminalReporter:
             pypy_version_info = getattr(sys, "pypy_version_info", None)
             if pypy_version_info:
                 verinfo = ".".join(map(str, pypy_version_info[:3]))
-                msg += "[pypy-{}-{}]".format(verinfo, pypy_version_info[3])
-            msg += ", pytest-{}, py-{}, pluggy-{}".format(
-                _pytest._version.version, py.__version__, pluggy.__version__
+                msg += f"[pypy-{verinfo}-{pypy_version_info[3]}]"
+            msg += ", pytest-{}, pluggy-{}".format(
+                _pytest._version.version, pluggy.__version__
             )
             if (
                 self.verbosity > 0
@@ -710,7 +769,7 @@ class TerminalReporter:
                 msg += " -- " + str(sys.executable)
             self.write_line(msg)
             lines = self.config.hook.pytest_report_header(
-                config=self.config, startdir=self.startdir
+                config=self.config, start_path=self.startpath
             )
             self._write_report_lines_from_hooks(lines)
 
@@ -725,16 +784,14 @@ class TerminalReporter:
                     self.write_line(line)
 
     def pytest_report_header(self, config: Config) -> List[str]:
-        line = "rootdir: %s" % config.rootpath
+        result = [f"rootdir: {config.rootpath}"]
 
         if config.inipath:
-            line += ", configfile: " + bestrelpath(config.rootpath, config.inipath)
+            result.append("configfile: " + bestrelpath(config.rootpath, config.inipath))
 
-        testpaths: List[str] = config.getini("testpaths")
-        if config.invocation_params.dir == config.rootpath and config.args == testpaths:
-            line += ", testpaths: {}".format(", ".join(testpaths))
-
-        result = [line]
+        if config.args_source == Config.ArgsSource.TESTPATHS:
+            testpaths: List[str] = config.getini("testpaths")
+            result.append("testpaths: {}".format(", ".join(testpaths)))
 
         plugininfo = config.pluginmanager.list_plugin_distinfo()
         if plugininfo:
@@ -745,7 +802,9 @@ class TerminalReporter:
         self.report_collect(True)
 
         lines = self.config.hook.pytest_report_collectionfinish(
-            config=self.config, startdir=self.startdir, items=session.items
+            config=self.config,
+            start_path=self.startpath,
+            items=session.items,
         )
         self._write_report_lines_from_hooks(lines)
 
@@ -762,9 +821,6 @@ class TerminalReporter:
                     rep.toterminal(self._tw)
 
     def _printcollecteditems(self, items: Sequence[Item]) -> None:
-        # To print out items and their parent collectors
-        # we take care to leave out Instances aka ()
-        # because later versions are going to get rid of them anyway.
         if self.config.option.verbose < 0:
             if self.config.option.verbose < -1:
                 counts = Counter(item.nodeid.split("::", 1)[0] for item in items)
@@ -784,8 +840,6 @@ class TerminalReporter:
                 stack.pop()
             for col in needed_collectors[len(stack) :]:
                 stack.append(col)
-                if col.name == "()":  # Skip Instances.
-                    continue
                 indent = (len(stack) - 1) * "  "
                 self._tw.line(f"{indent}{col}")
                 if self.config.option.verbose >= 1:
@@ -856,8 +910,10 @@ class TerminalReporter:
                     yellow=True,
                 )
 
-    def _locationline(self, nodeid, fspath, lineno, domain):
-        def mkrel(nodeid):
+    def _locationline(
+        self, nodeid: str, fspath: str, lineno: Optional[int], domain: str
+    ) -> str:
+        def mkrel(nodeid: str) -> str:
             line = self.config.cwd_relative_nodeid(nodeid)
             if domain and line.endswith(domain):
                 line = line[: -len(domain)]
@@ -867,13 +923,12 @@ class TerminalReporter:
             return line
 
         # collect_fspath comes from testid which has a "/"-normalized path.
-
         if fspath:
             res = mkrel(nodeid)
             if self.verbosity >= 2 and nodeid.split("::")[0] != fspath.replace(
                 "\\", nodes.SEP
             ):
-                res += " <- " + bestrelpath(self.startpath, fspath)
+                res += " <- " + bestrelpath(self.startpath, Path(fspath))
         else:
             res = "[location]"
         return res + " "
@@ -897,11 +952,7 @@ class TerminalReporter:
     # Summaries for sessionfinish.
     #
     def getreports(self, name: str):
-        values = []
-        for x in self.stats.get(name, []):
-            if not hasattr(x, "_pdbshown"):
-                values.append(x)
-        return values
+        return [x for x in self.stats.get(name, ()) if not hasattr(x, "_pdbshown")]
 
     def summary_warnings(self) -> None:
         if self.hasopt("w"):
@@ -953,7 +1004,9 @@ class TerminalReporter:
                     message = message.rstrip()
                 self._tw.line(message)
                 self._tw.line()
-            self._tw.line("-- Docs: https://docs.pytest.org/en/stable/warnings.html")
+            self._tw.line(
+                "-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html"
+            )
 
     def summary_passes(self) -> None:
         if self.config.option.tbstyle != "no":
@@ -1058,7 +1111,7 @@ class TerminalReporter:
         msg = ", ".join(line_parts)
 
         main_markup = {main_color: True}
-        duration = " in {}".format(format_session_duration(session_duration))
+        duration = f" in {format_session_duration(session_duration)}"
         duration_with_markup = self._tw.markup(duration, **main_markup)
         if display_sep:
             fullwidth += len(duration_with_markup) - len(duration)
@@ -1080,33 +1133,43 @@ class TerminalReporter:
         if not self.reportchars:
             return
 
-        def show_simple(stat, lines: List[str]) -> None:
+        def show_simple(lines: List[str], *, stat: str) -> None:
             failed = self.stats.get(stat, [])
             if not failed:
                 return
-            termwidth = self._tw.fullwidth
             config = self.config
             for rep in failed:
-                line = _get_line_with_reprcrash_message(config, rep, termwidth)
+                color = _color_for_type.get(stat, _color_for_type_default)
+                line = _get_line_with_reprcrash_message(
+                    config, rep, self._tw, {color: True}
+                )
                 lines.append(line)
 
         def show_xfailed(lines: List[str]) -> None:
             xfailed = self.stats.get("xfailed", [])
             for rep in xfailed:
                 verbose_word = rep._get_verbose_word(self.config)
-                pos = _get_pos(self.config, rep)
-                lines.append(f"{verbose_word} {pos}")
+                markup_word = self._tw.markup(
+                    verbose_word, **{_color_for_type["warnings"]: True}
+                )
+                nodeid = _get_node_id_with_markup(self._tw, self.config, rep)
+                line = f"{markup_word} {nodeid}"
                 reason = rep.wasxfail
                 if reason:
-                    lines.append("  " + str(reason))
+                    line += " - " + str(reason)
+
+                lines.append(line)
 
         def show_xpassed(lines: List[str]) -> None:
             xpassed = self.stats.get("xpassed", [])
             for rep in xpassed:
                 verbose_word = rep._get_verbose_word(self.config)
-                pos = _get_pos(self.config, rep)
+                markup_word = self._tw.markup(
+                    verbose_word, **{_color_for_type["warnings"]: True}
+                )
+                nodeid = _get_node_id_with_markup(self._tw, self.config, rep)
                 reason = rep.wasxfail
-                lines.append(f"{verbose_word} {pos} {reason}")
+                lines.append(f"{markup_word} {nodeid} {reason}")
 
         def show_skipped(lines: List[str]) -> None:
             skipped: List[CollectReport] = self.stats.get("skipped", [])
@@ -1114,24 +1177,27 @@ class TerminalReporter:
             if not fskips:
                 return
             verbose_word = skipped[0]._get_verbose_word(self.config)
+            markup_word = self._tw.markup(
+                verbose_word, **{_color_for_type["warnings"]: True}
+            )
+            prefix = "Skipped: "
             for num, fspath, lineno, reason in fskips:
-                if reason.startswith("Skipped: "):
-                    reason = reason[9:]
+                if reason.startswith(prefix):
+                    reason = reason[len(prefix) :]
                 if lineno is not None:
                     lines.append(
-                        "%s [%d] %s:%d: %s"
-                        % (verbose_word, num, fspath, lineno, reason)
+                        "%s [%d] %s:%d: %s" % (markup_word, num, fspath, lineno, reason)
                     )
                 else:
-                    lines.append("%s [%d] %s: %s" % (verbose_word, num, fspath, reason))
+                    lines.append("%s [%d] %s: %s" % (markup_word, num, fspath, reason))
 
         REPORTCHAR_ACTIONS: Mapping[str, Callable[[List[str]], None]] = {
             "x": show_xfailed,
             "X": show_xpassed,
-            "f": partial(show_simple, "failed"),
+            "f": partial(show_simple, stat="failed"),
             "s": show_skipped,
-            "p": partial(show_simple, "passed"),
-            "E": partial(show_simple, "error"),
+            "p": partial(show_simple, stat="passed"),
+            "E": partial(show_simple, stat="error"),
         }
 
         lines: List[str] = []
@@ -1141,7 +1207,7 @@ class TerminalReporter:
                 action(lines)
 
         if lines:
-            self.write_sep("=", "short test summary info")
+            self.write_sep("=", "short test summary info", cyan=True, bold=True)
             for line in lines:
                 self.write_line(line)
 
@@ -1255,9 +1321,14 @@ class TerminalReporter:
         return parts, main_color
 
 
-def _get_pos(config: Config, rep: BaseReport):
+def _get_node_id_with_markup(tw: TerminalWriter, config: Config, rep: BaseReport):
     nodeid = config.cwd_relative_nodeid(rep.nodeid)
-    return nodeid
+    path, *parts = nodeid.split("::")
+    if parts:
+        parts_markup = tw.markup("::".join(parts), bold=True)
+        return path + "::" + parts_markup
+    else:
+        return path
 
 
 def _format_trimmed(format: str, msg: str, available_width: int) -> Optional[str]:
@@ -1286,13 +1357,14 @@ def _format_trimmed(format: str, msg: str, available_width: int) -> Optional[str
 
 
 def _get_line_with_reprcrash_message(
-    config: Config, rep: BaseReport, termwidth: int
+    config: Config, rep: BaseReport, tw: TerminalWriter, word_markup: Dict[str, bool]
 ) -> str:
     """Get summary line for a report, trying to add reprcrash message."""
     verbose_word = rep._get_verbose_word(config)
-    pos = _get_pos(config, rep)
+    word = tw.markup(verbose_word, **word_markup)
+    node = _get_node_id_with_markup(tw, config, rep)
 
-    line = f"{verbose_word} {pos}"
+    line = f"{word} {node}"
     line_width = wcswidth(line)
 
     try:
@@ -1301,8 +1373,11 @@ def _get_line_with_reprcrash_message(
     except AttributeError:
         pass
     else:
-        available_width = termwidth - line_width
-        msg = _format_trimmed(" - {}", msg, available_width)
+        if not running_on_ci():
+            available_width = tw.fullwidth - line_width
+            msg = _format_trimmed(" - {}", msg, available_width)
+        else:
+            msg = f" - {msg}"
         if msg is not None:
             line += msg
 
@@ -1310,7 +1385,8 @@ def _get_line_with_reprcrash_message(
 
 
 def _folded_skips(
-    startpath: Path, skipped: Sequence[CollectReport],
+    startpath: Path,
+    skipped: Sequence[CollectReport],
 ) -> List[Tuple[int, str, Optional[int], str]]:
     d: Dict[Tuple[str, Optional[int], str], List[CollectReport]] = {}
     for event in skipped:
index 1c1f62fdb73c99a5423f88341ac3d13a3e0b7917..43341e739a0e40cffe3b490dff8e7f20485eb28e 100644 (file)
@@ -34,11 +34,10 @@ class catch_threading_exception:
     """
 
     def __init__(self) -> None:
-        # See https://github.com/python/typeshed/issues/4767 regarding the underscore.
-        self.args: Optional["threading._ExceptHookArgs"] = None
-        self._old_hook: Optional[Callable[["threading._ExceptHookArgs"], Any]] = None
+        self.args: Optional["threading.ExceptHookArgs"] = None
+        self._old_hook: Optional[Callable[["threading.ExceptHookArgs"], Any]] = None
 
-    def _hook(self, args: "threading._ExceptHookArgs") -> None:
+    def _hook(self, args: "threading.ExceptHookArgs") -> None:
         self.args = args
 
     def __enter__(self) -> "catch_threading_exception":
@@ -62,14 +61,13 @@ def thread_exception_runtest_hook() -> Generator[None, None, None]:
     with catch_threading_exception() as cm:
         yield
         if cm.args:
-            if cm.args.thread is not None:
-                thread_name = cm.args.thread.name
-            else:
-                thread_name = "<unknown>"
+            thread_name = "<unknown>" if cm.args.thread is None else cm.args.thread.name
             msg = f"Exception in thread {thread_name}\n\n"
             msg += "".join(
                 traceback.format_exception(
-                    cm.args.exc_type, cm.args.exc_value, cm.args.exc_traceback,
+                    cm.args.exc_type,
+                    cm.args.exc_value,
+                    cm.args.exc_traceback,
                 )
             )
             warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
index 08c445e2bf8fc5e67b353fe236574c52294e8af2..3cc2bace55bb4730ca8c8f274616a00cbfffacc5 100644 (file)
@@ -1,40 +1,66 @@
 """Support for providing temporary directories to test functions."""
+import dataclasses
 import os
 import re
 import tempfile
 from pathlib import Path
+from shutil import rmtree
+from typing import Any
+from typing import Dict
+from typing import Generator
 from typing import Optional
+from typing import TYPE_CHECKING
+from typing import Union
 
-import attr
-import py
+from _pytest.nodes import Item
+from _pytest.reports import CollectReport
+from _pytest.stash import StashKey
+
+if TYPE_CHECKING:
+    from typing_extensions import Literal
+
+    RetentionType = Literal["all", "failed", "none"]
+
+
+from _pytest.config.argparsing import Parser
 
-from .pathlib import ensure_reset_dir
 from .pathlib import LOCK_TIMEOUT
 from .pathlib import make_numbered_dir
 from .pathlib import make_numbered_dir_with_cleanup
-from _pytest.compat import final
+from .pathlib import rm_rf
+from .pathlib import cleanup_dead_symlinks
+from _pytest.compat import final, get_user_id
 from _pytest.config import Config
+from _pytest.config import ExitCode
+from _pytest.config import hookimpl
 from _pytest.deprecated import check_ispytest
 from _pytest.fixtures import fixture
 from _pytest.fixtures import FixtureRequest
 from _pytest.monkeypatch import MonkeyPatch
 
+tmppath_result_key = StashKey[Dict[str, bool]]()
+
 
 @final
-@attr.s(init=False)
+@dataclasses.dataclass
 class TempPathFactory:
     """Factory for temporary directories under the common base temp directory.
 
     The base directory can be configured using the ``--basetemp`` option.
     """
 
-    _given_basetemp = attr.ib(type=Optional[Path])
-    _trace = attr.ib()
-    _basetemp = attr.ib(type=Optional[Path])
+    _given_basetemp: Optional[Path]
+    # pluggy TagTracerSub, not currently exposed, so Any.
+    _trace: Any
+    _basetemp: Optional[Path]
+    _retention_count: int
+    _retention_policy: "RetentionType"
 
     def __init__(
         self,
         given_basetemp: Optional[Path],
+        retention_count: int,
+        retention_policy: "RetentionType",
         trace,
         basetemp: Optional[Path] = None,
         *,
@@ -49,20 +75,39 @@ class TempPathFactory:
             # Path.absolute() exists, but it is not public (see https://bugs.python.org/issue25012).
             self._given_basetemp = Path(os.path.abspath(str(given_basetemp)))
         self._trace = trace
+        self._retention_count = retention_count
+        self._retention_policy = retention_policy
         self._basetemp = basetemp
 
     @classmethod
     def from_config(
-        cls, config: Config, *, _ispytest: bool = False,
+        cls,
+        config: Config,
+        *,
+        _ispytest: bool = False,
     ) -> "TempPathFactory":
         """Create a factory according to pytest configuration.
 
         :meta private:
         """
         check_ispytest(_ispytest)
+        count = int(config.getini("tmp_path_retention_count"))
+        if count < 0:
+            raise ValueError(
+                f"tmp_path_retention_count must be >= 0. Current input: {count}."
+            )
+
+        policy = config.getini("tmp_path_retention_policy")
+        if policy not in ("all", "failed", "none"):
+            raise ValueError(
+                f"tmp_path_retention_policy must be either all, failed, none. Current input: {policy}."
+            )
+
         return cls(
             given_basetemp=config.option.basetemp,
             trace=config.trace.get("tmpdir"),
+            retention_count=count,
+            retention_policy=policy,
             _ispytest=True,
         )
 
@@ -90,20 +135,26 @@ class TempPathFactory:
         basename = self._ensure_relative_to_basetemp(basename)
         if not numbered:
             p = self.getbasetemp().joinpath(basename)
-            p.mkdir()
+            p.mkdir(mode=0o700)
         else:
-            p = make_numbered_dir(root=self.getbasetemp(), prefix=basename)
+            p = make_numbered_dir(root=self.getbasetemp(), prefix=basename, mode=0o700)
             self._trace("mktemp", p)
         return p
 
     def getbasetemp(self) -> Path:
-        """Return base temporary directory."""
+        """Return the base temporary directory, creating it if needed.
+
+        :returns:
+            The base temporary directory.
+        """
         if self._basetemp is not None:
             return self._basetemp
 
         if self._given_basetemp is not None:
             basetemp = self._given_basetemp
-            ensure_reset_dir(basetemp)
+            if basetemp.exists():
+                rm_rf(basetemp)
+            basetemp.mkdir(mode=0o700)
             basetemp = basetemp.resolve()
         else:
             from_env = os.environ.get("PYTEST_DEBUG_TEMPROOT")
@@ -112,75 +163,87 @@ class TempPathFactory:
             # use a sub-directory in the temproot to speed-up
             # make_numbered_dir() call
             rootdir = temproot.joinpath(f"pytest-of-{user}")
-            rootdir.mkdir(exist_ok=True)
+            try:
+                rootdir.mkdir(mode=0o700, exist_ok=True)
+            except OSError:
+                # getuser() likely returned illegal characters for the platform, use unknown back off mechanism
+                rootdir = temproot.joinpath("pytest-of-unknown")
+                rootdir.mkdir(mode=0o700, exist_ok=True)
+            # Because we use exist_ok=True with a predictable name, make sure
+            # we are the owners, to prevent any funny business (on unix, where
+            # temproot is usually shared).
+            # Also, to keep things private, fixup any world-readable temp
+            # rootdir's permissions. Historically 0o755 was used, so we can't
+            # just error out on this, at least for a while.
+            uid = get_user_id()
+            if uid is not None:
+                rootdir_stat = rootdir.stat()
+                if rootdir_stat.st_uid != uid:
+                    raise OSError(
+                        f"The temporary directory {rootdir} is not owned by the current user. "
+                        "Fix this and try again."
+                    )
+                if (rootdir_stat.st_mode & 0o077) != 0:
+                    os.chmod(rootdir, rootdir_stat.st_mode & ~0o077)
+            keep = self._retention_count
+            if self._retention_policy == "none":
+                keep = 0
             basetemp = make_numbered_dir_with_cleanup(
-                prefix="pytest-", root=rootdir, keep=3, lock_timeout=LOCK_TIMEOUT
+                prefix="pytest-",
+                root=rootdir,
+                keep=keep,
+                lock_timeout=LOCK_TIMEOUT,
+                mode=0o700,
             )
         assert basetemp is not None, basetemp
-        self._basetemp = t = basetemp
-        self._trace("new basetemp", t)
-        return t
-
-
-@final
-@attr.s(init=False)
-class TempdirFactory:
-    """Backward comptibility wrapper that implements :class:``py.path.local``
-    for :class:``TempPathFactory``."""
-
-    _tmppath_factory = attr.ib(type=TempPathFactory)
-
-    def __init__(
-        self, tmppath_factory: TempPathFactory, *, _ispytest: bool = False
-    ) -> None:
-        check_ispytest(_ispytest)
-        self._tmppath_factory = tmppath_factory
-
-    def mktemp(self, basename: str, numbered: bool = True) -> py.path.local:
-        """Same as :meth:`TempPathFactory.mktemp`, but returns a ``py.path.local`` object."""
-        return py.path.local(self._tmppath_factory.mktemp(basename, numbered).resolve())
-
-    def getbasetemp(self) -> py.path.local:
-        """Backward compat wrapper for ``_tmppath_factory.getbasetemp``."""
-        return py.path.local(self._tmppath_factory.getbasetemp().resolve())
+        self._basetemp = basetemp
+        self._trace("new basetemp", basetemp)
+        return basetemp
 
 
 def get_user() -> Optional[str]:
     """Return the current user name, or None if getuser() does not work
     in the current environment (see #1010)."""
-    import getpass
-
     try:
+        # In some exotic environments, getpass may not be importable.
+        import getpass
+
         return getpass.getuser()
     except (ImportError, KeyError):
         return None
 
 
 def pytest_configure(config: Config) -> None:
-    """Create a TempdirFactory and attach it to the config object.
+    """Create a TempPathFactory and attach it to the config object.
 
     This is to comply with existing plugins which expect the handler to be
     available at pytest_configure time, but ideally should be moved entirely
-    to the tmpdir_factory session fixture.
+    to the tmp_path_factory session fixture.
     """
     mp = MonkeyPatch()
-    tmppath_handler = TempPathFactory.from_config(config, _ispytest=True)
-    t = TempdirFactory(tmppath_handler, _ispytest=True)
-    config._cleanup.append(mp.undo)
-    mp.setattr(config, "_tmp_path_factory", tmppath_handler, raising=False)
-    mp.setattr(config, "_tmpdirhandler", t, raising=False)
+    config.add_cleanup(mp.undo)
+    _tmp_path_factory = TempPathFactory.from_config(config, _ispytest=True)
+    mp.setattr(config, "_tmp_path_factory", _tmp_path_factory, raising=False)
 
 
-@fixture(scope="session")
-def tmpdir_factory(request: FixtureRequest) -> TempdirFactory:
-    """Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session."""
-    # Set dynamically by pytest_configure() above.
-    return request.config._tmpdirhandler  # type: ignore
+def pytest_addoption(parser: Parser) -> None:
+    parser.addini(
+        "tmp_path_retention_count",
+        help="How many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`.",
+        default=3,
+    )
+
+    parser.addini(
+        "tmp_path_retention_policy",
+        help="Controls which directories created by the `tmp_path` fixture are kept around, based on test outcome. "
+        "(all/failed/none)",
+        default="all",
+    )
 
 
 @fixture(scope="session")
 def tmp_path_factory(request: FixtureRequest) -> TempPathFactory:
-    """Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session."""
+    """Return a :class:`pytest.TempPathFactory` instance for the test session."""
     # Set dynamically by pytest_configure() above.
     return request.config._tmp_path_factory  # type: ignore
 
@@ -194,35 +257,68 @@ def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path:
 
 
 @fixture
-def tmpdir(tmp_path: Path) -> py.path.local:
+def tmp_path(
+    request: FixtureRequest, tmp_path_factory: TempPathFactory
+) -> Generator[Path, None, None]:
     """Return a temporary directory path object which is unique to each test
     function invocation, created as a sub directory of the base temporary
     directory.
 
     By default, a new base temporary directory is created each test session,
-    and old bases are removed after 3 sessions, to aid in debugging. If
-    ``--basetemp`` is used then it is cleared each session. See :ref:`base
+    and old bases are removed after 3 sessions, to aid in debugging.
+    This behavior can be configured with :confval:`tmp_path_retention_count` and
+    :confval:`tmp_path_retention_policy`.
+    If ``--basetemp`` is used then it is cleared each session. See :ref:`base
     temporary directory`.
 
-    The returned object is a `py.path.local`_ path object.
-
-    .. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
+    The returned object is a :class:`pathlib.Path` object.
     """
-    return py.path.local(tmp_path)
 
+    path = _mk_tmp(request, tmp_path_factory)
+    yield path
 
-@fixture
-def tmp_path(request: FixtureRequest, tmp_path_factory: TempPathFactory) -> Path:
-    """Return a temporary directory path object which is unique to each test
-    function invocation, created as a sub directory of the base temporary
-    directory.
+    # Remove the tmpdir if the policy is "failed" and the test passed.
+    tmp_path_factory: TempPathFactory = request.session.config._tmp_path_factory  # type: ignore
+    policy = tmp_path_factory._retention_policy
+    result_dict = request.node.stash[tmppath_result_key]
 
-    By default, a new base temporary directory is created each test session,
-    and old bases are removed after 3 sessions, to aid in debugging. If
-    ``--basetemp`` is used then it is cleared each session. See :ref:`base
-    temporary directory`.
+    if policy == "failed" and result_dict.get("call", True):
+        # We do a "best effort" to remove files, but it might not be possible due to some leaked resource,
+        # permissions, etc, in which case we ignore it.
+        rmtree(path, ignore_errors=True)
 
-    The returned object is a :class:`pathlib.Path` object.
-    """
+    del request.node.stash[tmppath_result_key]
 
-    return _mk_tmp(request, tmp_path_factory)
+
+def pytest_sessionfinish(session, exitstatus: Union[int, ExitCode]):
+    """After each session, remove base directory if all the tests passed,
+    the policy is "failed", and the basetemp is not specified by a user.
+    """
+    tmp_path_factory: TempPathFactory = session.config._tmp_path_factory
+    basetemp = tmp_path_factory._basetemp
+    if basetemp is None:
+        return
+
+    policy = tmp_path_factory._retention_policy
+    if (
+        exitstatus == 0
+        and policy == "failed"
+        and tmp_path_factory._given_basetemp is None
+    ):
+        if basetemp.is_dir():
+            # We do a "best effort" to remove files, but it might not be possible due to some leaked resource,
+            # permissions, etc, in which case we ignore it.
+            rmtree(basetemp, ignore_errors=True)
+
+    # Remove dead symlinks.
+    if basetemp.is_dir():
+        cleanup_dead_symlinks(basetemp)
+
+
+@hookimpl(tryfirst=True, hookwrapper=True)
+def pytest_runtest_makereport(item: Item, call):
+    outcome = yield
+    result: CollectReport = outcome.get_result()
+
+    empty: Dict[str, bool] = {}
+    item.stash.setdefault(tmppath_result_key, empty)[result.when] = result.passed
index 55f15efe4b7c5361401ab644eb9e66ac8c81f988..d42a12a3a9ea21afb57360eb3475be20c94360b9 100644 (file)
@@ -27,15 +27,13 @@ from _pytest.outcomes import skip
 from _pytest.outcomes import xfail
 from _pytest.python import Class
 from _pytest.python import Function
-from _pytest.python import PyCollector
+from _pytest.python import Module
 from _pytest.runner import CallInfo
-from _pytest.skipping import skipped_by_mark_key
-from _pytest.skipping import unexpectedsuccess_key
+from _pytest.scope import Scope
 
 if TYPE_CHECKING:
     import unittest
-
-    from _pytest.fixtures import _Scope
+    import twisted.trial.unittest
 
     _SysExcInfoType = Union[
         Tuple[Type[BaseException], BaseException, types.TracebackType],
@@ -44,7 +42,7 @@ if TYPE_CHECKING:
 
 
 def pytest_pycollect_makeitem(
-    collector: PyCollector, name: str, obj: object
+    collector: Union[Module, Class], name: str, obj: object
 ) -> Optional["UnitTestCase"]:
     # Has unittest been imported and is obj a subclass of its TestCase?
     try:
@@ -103,7 +101,7 @@ class UnitTestCase(Class):
             "setUpClass",
             "tearDownClass",
             "doClassCleanups",
-            scope="class",
+            scope=Scope.Class,
             pass_self=False,
         )
         if class_fixture:
@@ -114,7 +112,7 @@ class UnitTestCase(Class):
             "setup_method",
             "teardown_method",
             None,
-            scope="function",
+            scope=Scope.Function,
             pass_self=True,
         )
         if method_fixture:
@@ -126,7 +124,7 @@ def _make_xunit_fixture(
     setup_name: str,
     teardown_name: str,
     cleanup_name: Optional[str],
-    scope: "_Scope",
+    scope: Scope,
     pass_self: bool,
 ):
     setup = getattr(obj, setup_name, None)
@@ -142,15 +140,15 @@ def _make_xunit_fixture(
             pass
 
     @pytest.fixture(
-        scope=scope,
+        scope=scope.value,
         autouse=True,
         # Use a unique name to speed up lookup.
-        name=f"unittest_{setup_name}_fixture_{obj.__qualname__}",
+        name=f"_unittest_{setup_name}_fixture_{obj.__qualname__}",
     )
     def fixture(self, request: FixtureRequest) -> Generator[None, None, None]:
         if _is_skipped(self):
             reason = self.__unittest_skip_why__
-            pytest.skip(reason)
+            raise pytest.skip.Exception(reason, _use_item_location=True)
         if setup is not None:
             try:
                 if pass_self:
@@ -187,6 +185,15 @@ class TestCaseFunction(Function):
     _excinfo: Optional[List[_pytest._code.ExceptionInfo[BaseException]]] = None
     _testcase: Optional["unittest.TestCase"] = None
 
+    def _getobj(self):
+        assert self.parent is not None
+        # Unlike a regular Function in a Class, where `item.obj` returns
+        # a *bound* method (attached to an instance), TestCaseFunction's
+        # `obj` returns an *unbound* method (not attached to an instance).
+        # This inconsistency is probably not desirable, but needs some
+        # consideration before changing.
+        return getattr(self.parent.obj, self.originalname)  # type: ignore[attr-defined]
+
     def setup(self) -> None:
         # A bound method to be called during teardown() if set (see 'runtest()').
         self._explicit_tearDown: Optional[Callable[[], None]] = None
@@ -210,7 +217,7 @@ class TestCaseFunction(Function):
         # Unwrap potential exception info (see twisted trial support below).
         rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo)
         try:
-            excinfo = _pytest._code.ExceptionInfo(rawexcinfo)  # type: ignore[arg-type]
+            excinfo = _pytest._code.ExceptionInfo[BaseException].from_exc_info(rawexcinfo)  # type: ignore[arg-type]
             # Invoke the attributes to trigger storing the traceback
             # trial causes some issue there.
             excinfo.value
@@ -256,9 +263,8 @@ class TestCaseFunction(Function):
 
     def addSkip(self, testcase: "unittest.TestCase", reason: str) -> None:
         try:
-            skip(reason)
+            raise pytest.skip.Exception(reason, _use_item_location=True)
         except skip.Exception:
-            self._store[skipped_by_mark_key] = True
             self._addexcinfo(sys.exc_info())
 
     def addExpectedFailure(
@@ -273,9 +279,18 @@ class TestCaseFunction(Function):
             self._addexcinfo(sys.exc_info())
 
     def addUnexpectedSuccess(
-        self, testcase: "unittest.TestCase", reason: str = ""
+        self,
+        testcase: "unittest.TestCase",
+        reason: Optional["twisted.trial.unittest.Todo"] = None,
     ) -> None:
-        self._store[unexpectedsuccess_key] = reason
+        msg = "Unexpected success"
+        if reason:
+            msg += f": {reason.reason}"
+        # Preserve unittest behaviour - fail the test. Explicitly not an XPASS.
+        try:
+            fail(msg, pytrace=False)
+        except fail.Exception:
+            self._addexcinfo(sys.exc_info())
 
     def addSuccess(self, testcase: "unittest.TestCase") -> None:
         pass
@@ -283,14 +298,8 @@ class TestCaseFunction(Function):
     def stopTest(self, testcase: "unittest.TestCase") -> None:
         pass
 
-    def _expecting_failure(self, test_method) -> bool:
-        """Return True if the given unittest method (or the entire class) is marked
-        with @expectedFailure."""
-        expecting_failure_method = getattr(
-            test_method, "__unittest_expecting_failure__", False
-        )
-        expecting_failure_class = getattr(self, "__unittest_expecting_failure__", False)
-        return bool(expecting_failure_class or expecting_failure_method)
+    def addDuration(self, testcase: "unittest.TestCase", elapsed: float) -> None:
+        pass
 
     def runtest(self) -> None:
         from _pytest.debugging import maybe_wrap_pytest_function_for_tracing
@@ -310,7 +319,10 @@ class TestCaseFunction(Function):
             # Arguably we could always postpone tearDown(), but this changes the moment where the
             # TestCase instance interacts with the results object, so better to only do it
             # when absolutely needed.
-            if self.config.getoption("usepdb") and not _is_skipped(self.obj):
+            # We need to consider if the test itself is skipped, or the whole class.
+            assert isinstance(self.parent, UnitTestCase)
+            skipped = _is_skipped(self.obj) or _is_skipped(self.parent.obj)
+            if self.config.getoption("usepdb") and not skipped:
                 self._explicit_tearDown = self._testcase.tearDown
                 setattr(self._testcase, "tearDown", lambda *args: None)
 
@@ -322,15 +334,16 @@ class TestCaseFunction(Function):
             finally:
                 delattr(self._testcase, self.name)
 
-    def _prunetraceback(
+    def _traceback_filter(
         self, excinfo: _pytest._code.ExceptionInfo[BaseException]
-    ) -> None:
-        Function._prunetraceback(self, excinfo)
-        traceback = excinfo.traceback.filter(
-            lambda x: not x.frame.f_globals.get("__unittest")
+    ) -> _pytest._code.Traceback:
+        traceback = super()._traceback_filter(excinfo)
+        ntraceback = traceback.filter(
+            lambda x: not x.frame.f_globals.get("__unittest"),
         )
-        if traceback:
-            excinfo.traceback = traceback
+        if not ntraceback:
+            ntraceback = traceback
+        return ntraceback
 
 
 @hookimpl(tryfirst=True)
@@ -343,6 +356,10 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None:
             except AttributeError:
                 pass
 
+    # Convert unittest.SkipTest to pytest.skip.
+    # This is actually only needed for nose, which reuses unittest.SkipTest for
+    # its own nose.SkipTest. For unittest TestCases, SkipTest is already
+    # handled internally, and doesn't reach here.
     unittest = sys.modules.get("unittest")
     if (
         unittest
@@ -350,7 +367,6 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None:
         and isinstance(call.excinfo.value, unittest.SkipTest)  # type: ignore[attr-defined]
     ):
         excinfo = call.excinfo
-        # Let's substitute the excinfo with a pytest.skip one.
         call2 = CallInfo[None].from_call(
             lambda: pytest.skip(str(excinfo.value)), call.when
         )
index 2eadd9fe4dbbd3172ab3409ef809d705da071f51..bd5f418734308f33849445f5b9535e147aa3fdfb 100644 (file)
@@ -1,10 +1,12 @@
+import dataclasses
+import inspect
+import warnings
+from types import FunctionType
 from typing import Any
 from typing import Generic
 from typing import Type
 from typing import TypeVar
 
-import attr
-
 from _pytest.compat import final
 
 
@@ -42,13 +44,24 @@ class PytestCollectionWarning(PytestWarning):
     __module__ = "pytest"
 
 
-@final
 class PytestDeprecationWarning(PytestWarning, DeprecationWarning):
     """Warning class for features that will be removed in a future version."""
 
     __module__ = "pytest"
 
 
+class PytestRemovedIn8Warning(PytestDeprecationWarning):
+    """Warning class for features that will be removed in pytest 8."""
+
+    __module__ = "pytest"
+
+
+class PytestReturnNotNoneWarning(PytestRemovedIn8Warning):
+    """Warning emitted when a test function is returning value other than None."""
+
+    __module__ = "pytest"
+
+
 @final
 class PytestExperimentalApiWarning(PytestWarning, FutureWarning):
     """Warning category used to denote experiments in pytest.
@@ -69,7 +82,7 @@ class PytestExperimentalApiWarning(PytestWarning, FutureWarning):
 
 
 @final
-class PytestUnhandledCoroutineWarning(PytestWarning):
+class PytestUnhandledCoroutineWarning(PytestReturnNotNoneWarning):
     """Warning emitted for an unhandled coroutine.
 
     A coroutine was encountered when collecting test functions, but was not
@@ -116,7 +129,7 @@ _W = TypeVar("_W", bound=PytestWarning)
 
 
 @final
-@attr.s
+@dataclasses.dataclass
 class UnformattedWarning(Generic[_W]):
     """A warning meant to be formatted during runtime.
 
@@ -124,9 +137,34 @@ class UnformattedWarning(Generic[_W]):
     as opposed to a direct message.
     """
 
-    category = attr.ib(type=Type["_W"])
-    template = attr.ib(type=str)
+    category: Type["_W"]
+    template: str
 
     def format(self, **kwargs: Any) -> _W:
         """Return an instance of the warning category, formatted with given kwargs."""
         return self.category(self.template.format(**kwargs))
+
+
+def warn_explicit_for(method: FunctionType, message: PytestWarning) -> None:
+    """
+    Issue the warning :param:`message` for the definition of the given :param:`method`
+
+    this helps to log warnings for functions defined prior to finding an issue with them
+    (like hook wrappers being marked in a legacy mechanism)
+    """
+    lineno = method.__code__.co_firstlineno
+    filename = inspect.getfile(method)
+    module = method.__module__
+    mod_globals = method.__globals__
+    try:
+        warnings.warn_explicit(
+            message,
+            type(message),
+            filename=filename,
+            module=module,
+            registry=mod_globals.setdefault("__warningregistry__", {}),
+            lineno=lineno,
+        )
+    except Warning as w:
+        # If warnings are errors (e.g. -Werror), location information gets lost, so we add it to the message.
+        raise type(w)(f"{w}\n at {filename}:{lineno}") from None
index 35eed96df58712fd2f74e895e9372efb2417d99c..4aaa94452931791f4d1693959c3d3be31f7b9a27 100644 (file)
@@ -21,7 +21,7 @@ def pytest_configure(config: Config) -> None:
     config.addinivalue_line(
         "markers",
         "filterwarnings(warning): add a warning filter to the given test. "
-        "see https://docs.pytest.org/en/stable/warnings.html#pytest-mark-filterwarnings ",
+        "see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings ",
     )
 
 
@@ -61,14 +61,6 @@ def catch_warnings_for_item(
         yield
 
         for warning_message in log:
-            ihook.pytest_warning_captured.call_historic(
-                kwargs=dict(
-                    warning_message=warning_message,
-                    when=when,
-                    item=item,
-                    location=None,
-                )
-            )
             ihook.pytest_warning_recorded.call_historic(
                 kwargs=dict(
                     warning_message=warning_message,
@@ -89,6 +81,23 @@ def warning_record_to_str(warning_message: warnings.WarningMessage) -> str:
         warning_message.lineno,
         warning_message.line,
     )
+    if warning_message.source is not None:
+        try:
+            import tracemalloc
+        except ImportError:
+            pass
+        else:
+            tb = tracemalloc.get_object_traceback(warning_message.source)
+            if tb is not None:
+                formatted_tb = "\n".join(tb.format())
+                # Use a leading new line to better separate the (large) output
+                # from the traceback to the previous warning text.
+                msg += f"\nObject allocated at:\n{formatted_tb}"
+            else:
+                # No need for a leading new line.
+                url = "https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings"
+                msg += "Enable tracemalloc to get traceback where the object was allocated.\n"
+                msg += f"See {url} for more info."
     return msg
 
 
diff --git a/src/py.py b/src/py.py
new file mode 100644 (file)
index 0000000..7813c9b
--- /dev/null
+++ b/src/py.py
@@ -0,0 +1,10 @@
+# shim for pylib going away
+# if pylib is installed this file will get skipped
+# (`py/__init__.py` has higher precedence)
+import sys
+
+import _pytest._py.error as error
+import _pytest._py.path as path
+
+sys.modules["py.error"] = error
+sys.modules["py.path"] = path
diff --git a/src/pytest.egg-info/PKG-INFO b/src/pytest.egg-info/PKG-INFO
new file mode 100644 (file)
index 0000000..386915f
--- /dev/null
@@ -0,0 +1,222 @@
+Metadata-Version: 2.1
+Name: pytest
+Version: 7.4.3
+Summary: pytest: simple powerful testing with Python
+Home-page: https://docs.pytest.org/en/latest/
+Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
+License: MIT
+Project-URL: Changelog, https://docs.pytest.org/en/stable/changelog.html
+Project-URL: Twitter, https://twitter.com/pytestdotorg
+Project-URL: Source, https://github.com/pytest-dev/pytest
+Project-URL: Tracker, https://github.com/pytest-dev/pytest/issues
+Keywords: test,unittest
+Platform: unix
+Platform: linux
+Platform: osx
+Platform: cygwin
+Platform: win32
+Classifier: Development Status :: 6 - Mature
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: POSIX
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3 :: Only
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
+Classifier: Programming Language :: Python :: 3.11
+Classifier: Programming Language :: Python :: 3.12
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Testing
+Classifier: Topic :: Utilities
+Requires-Python: >=3.7
+Description-Content-Type: text/x-rst
+License-File: LICENSE
+Requires-Dist: iniconfig
+Requires-Dist: packaging
+Requires-Dist: pluggy<2.0,>=0.12
+Requires-Dist: colorama; sys_platform == "win32"
+Requires-Dist: exceptiongroup>=1.0.0rc8; python_version < "3.11"
+Requires-Dist: importlib-metadata>=0.12; python_version < "3.8"
+Requires-Dist: tomli>=1.0.0; python_version < "3.11"
+Provides-Extra: testing
+Requires-Dist: argcomplete; extra == "testing"
+Requires-Dist: attrs>=19.2.0; extra == "testing"
+Requires-Dist: hypothesis>=3.56; extra == "testing"
+Requires-Dist: mock; extra == "testing"
+Requires-Dist: nose; extra == "testing"
+Requires-Dist: pygments>=2.7.2; extra == "testing"
+Requires-Dist: requests; extra == "testing"
+Requires-Dist: setuptools; extra == "testing"
+Requires-Dist: xmlschema; extra == "testing"
+
+.. image:: https://github.com/pytest-dev/pytest/raw/main/doc/en/img/pytest_logo_curves.svg
+   :target: https://docs.pytest.org/en/stable/
+   :align: center
+   :height: 200
+   :alt: pytest
+
+
+------
+
+.. image:: https://img.shields.io/pypi/v/pytest.svg
+    :target: https://pypi.org/project/pytest/
+
+.. image:: https://img.shields.io/conda/vn/conda-forge/pytest.svg
+    :target: https://anaconda.org/conda-forge/pytest
+
+.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
+    :target: https://pypi.org/project/pytest/
+
+.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/main/graph/badge.svg
+    :target: https://codecov.io/gh/pytest-dev/pytest
+    :alt: Code coverage Status
+
+.. image:: https://github.com/pytest-dev/pytest/workflows/test/badge.svg
+    :target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Atest
+
+.. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
+   :target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
+   :alt: pre-commit.ci status
+
+.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
+    :target: https://github.com/psf/black
+
+.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
+    :target: https://www.codetriage.com/pytest-dev/pytest
+
+.. image:: https://readthedocs.org/projects/pytest/badge/?version=latest
+    :target: https://pytest.readthedocs.io/en/latest/?badge=latest
+    :alt: Documentation Status
+
+.. image:: https://img.shields.io/badge/Discord-pytest--dev-blue
+    :target: https://discord.com/invite/pytest-dev
+    :alt: Discord
+
+.. image:: https://img.shields.io/badge/Libera%20chat-%23pytest-orange
+    :target: https://web.libera.chat/#pytest
+    :alt: Libera chat
+
+
+The ``pytest`` framework makes it easy to write small tests, yet
+scales to support complex functional testing for applications and libraries.
+
+An example of a simple test:
+
+.. code-block:: python
+
+    # content of test_sample.py
+    def inc(x):
+        return x + 1
+
+
+    def test_answer():
+        assert inc(3) == 5
+
+
+To execute it::
+
+    $ pytest
+    ============================= test session starts =============================
+    collected 1 items
+
+    test_sample.py F
+
+    ================================== FAILURES ===================================
+    _________________________________ test_answer _________________________________
+
+        def test_answer():
+    >       assert inc(3) == 5
+    E       assert 4 == 5
+    E        +  where 4 = inc(3)
+
+    test_sample.py:5: AssertionError
+    ========================== 1 failed in 0.04 seconds ===========================
+
+
+Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <https://docs.pytest.org/en/stable/getting-started.html#our-first-test-run>`_ for more examples.
+
+
+Features
+--------
+
+- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/how-to/assert.html>`_ (no need to remember ``self.assert*`` names)
+
+- `Auto-discovery
+  <https://docs.pytest.org/en/stable/explanation/goodpractices.html#python-test-discovery>`_
+  of test modules and functions
+
+- `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
+  managing small or parametrized long-lived test resources
+
+- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
+  `nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
+
+- Python 3.7+ or PyPy3
+
+- Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
+
+
+Documentation
+-------------
+
+For full documentation, including installation, tutorials and PDF documents, please see https://docs.pytest.org/en/stable/.
+
+
+Bugs/Requests
+-------------
+
+Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issues>`_ to submit bugs or request features.
+
+
+Changelog
+---------
+
+Consult the `Changelog <https://docs.pytest.org/en/stable/changelog.html>`__ page for fixes and enhancements of each version.
+
+
+Support pytest
+--------------
+
+`Open Collective`_ is an online funding platform for open and transparent communities.
+It provides tools to raise money and share your finances in full transparency.
+
+It is the platform of choice for individuals and companies that want to make one-time or
+monthly donations directly to the project.
+
+See more details in the `pytest collective`_.
+
+.. _Open Collective: https://opencollective.com
+.. _pytest collective: https://opencollective.com/pytest
+
+
+pytest for enterprise
+---------------------
+
+Available as part of the Tidelift Subscription.
+
+The maintainers of pytest and thousands of other packages are working with Tidelift to deliver commercial support and
+maintenance for the open source dependencies you use to build your applications.
+Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
+
+`Learn more. <https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`_
+
+Security
+^^^^^^^^
+
+pytest has never been associated with a security vulnerability, but in any case, to report a
+security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
+Tidelift will coordinate the fix and disclosure.
+
+
+License
+-------
+
+Copyright Holger Krekel and others, 2004.
+
+Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
+
+.. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE
diff --git a/src/pytest.egg-info/SOURCES.txt b/src/pytest.egg-info/SOURCES.txt
new file mode 100644 (file)
index 0000000..2951567
--- /dev/null
@@ -0,0 +1,579 @@
+.coveragerc
+.gitattributes
+.gitblameignore
+.gitignore
+.pre-commit-config.yaml
+.readthedocs.yml
+AUTHORS
+CHANGELOG.rst
+CITATION
+CODE_OF_CONDUCT.md
+CONTRIBUTING.rst
+LICENSE
+OPENCOLLECTIVE.rst
+README.rst
+RELEASING.rst
+TIDELIFT.rst
+codecov.yml
+pyproject.toml
+setup.cfg
+setup.py
+tox.ini
+.github/FUNDING.yml
+.github/PULL_REQUEST_TEMPLATE.md
+.github/config.yml
+.github/dependabot.yml
+.github/labels.toml
+.github/ISSUE_TEMPLATE/1_bug_report.md
+.github/ISSUE_TEMPLATE/2_feature_request.md
+.github/ISSUE_TEMPLATE/config.yml
+.github/workflows/backport.yml
+.github/workflows/deploy.yml
+.github/workflows/prepare-release-pr.yml
+.github/workflows/stale.yml
+.github/workflows/test.yml
+.github/workflows/update-plugin-list.yml
+bench/bench.py
+bench/bench_argcomplete.py
+bench/empty.py
+bench/manyparam.py
+bench/skip.py
+bench/unit_test.py
+bench/xunit.py
+changelog/README.rst
+changelog/_template.rst
+doc/en/Makefile
+doc/en/adopt.rst
+doc/en/backwards-compatibility.rst
+doc/en/builtin.rst
+doc/en/changelog.rst
+doc/en/conf.py
+doc/en/conftest.py
+doc/en/contact.rst
+doc/en/contents.rst
+doc/en/contributing.rst
+doc/en/deprecations.rst
+doc/en/development_guide.rst
+doc/en/funcarg_compare.rst
+doc/en/funcargs.rst
+doc/en/getting-started.rst
+doc/en/historical-notes.rst
+doc/en/history.rst
+doc/en/index.rst
+doc/en/license.rst
+doc/en/naming20.rst
+doc/en/pytest.ini
+doc/en/recwarn.rst
+doc/en/requirements.txt
+doc/en/sponsor.rst
+doc/en/talks.rst
+doc/en/tidelift.rst
+doc/en/yieldfixture.rst
+doc/en/_templates/globaltoc.html
+doc/en/_templates/layout.html
+doc/en/_templates/links.html
+doc/en/_templates/relations.html
+doc/en/_templates/sidebarintro.html
+doc/en/_templates/slim_searchbox.html
+doc/en/announce/index.rst
+doc/en/announce/release-2.0.0.rst
+doc/en/announce/release-2.0.1.rst
+doc/en/announce/release-2.0.2.rst
+doc/en/announce/release-2.0.3.rst
+doc/en/announce/release-2.1.0.rst
+doc/en/announce/release-2.1.1.rst
+doc/en/announce/release-2.1.2.rst
+doc/en/announce/release-2.1.3.rst
+doc/en/announce/release-2.2.0.rst
+doc/en/announce/release-2.2.1.rst
+doc/en/announce/release-2.2.2.rst
+doc/en/announce/release-2.2.4.rst
+doc/en/announce/release-2.3.0.rst
+doc/en/announce/release-2.3.1.rst
+doc/en/announce/release-2.3.2.rst
+doc/en/announce/release-2.3.3.rst
+doc/en/announce/release-2.3.4.rst
+doc/en/announce/release-2.3.5.rst
+doc/en/announce/release-2.4.0.rst
+doc/en/announce/release-2.4.1.rst
+doc/en/announce/release-2.4.2.rst
+doc/en/announce/release-2.5.0.rst
+doc/en/announce/release-2.5.1.rst
+doc/en/announce/release-2.5.2.rst
+doc/en/announce/release-2.6.0.rst
+doc/en/announce/release-2.6.1.rst
+doc/en/announce/release-2.6.2.rst
+doc/en/announce/release-2.6.3.rst
+doc/en/announce/release-2.7.0.rst
+doc/en/announce/release-2.7.1.rst
+doc/en/announce/release-2.7.2.rst
+doc/en/announce/release-2.8.2.rst
+doc/en/announce/release-2.8.3.rst
+doc/en/announce/release-2.8.4.rst
+doc/en/announce/release-2.8.5.rst
+doc/en/announce/release-2.8.6.rst
+doc/en/announce/release-2.8.7.rst
+doc/en/announce/release-2.9.0.rst
+doc/en/announce/release-2.9.1.rst
+doc/en/announce/release-2.9.2.rst
+doc/en/announce/release-3.0.0.rst
+doc/en/announce/release-3.0.1.rst
+doc/en/announce/release-3.0.2.rst
+doc/en/announce/release-3.0.3.rst
+doc/en/announce/release-3.0.4.rst
+doc/en/announce/release-3.0.5.rst
+doc/en/announce/release-3.0.6.rst
+doc/en/announce/release-3.0.7.rst
+doc/en/announce/release-3.1.0.rst
+doc/en/announce/release-3.1.1.rst
+doc/en/announce/release-3.1.2.rst
+doc/en/announce/release-3.1.3.rst
+doc/en/announce/release-3.10.0.rst
+doc/en/announce/release-3.10.1.rst
+doc/en/announce/release-3.2.0.rst
+doc/en/announce/release-3.2.1.rst
+doc/en/announce/release-3.2.2.rst
+doc/en/announce/release-3.2.3.rst
+doc/en/announce/release-3.2.4.rst
+doc/en/announce/release-3.2.5.rst
+doc/en/announce/release-3.3.0.rst
+doc/en/announce/release-3.3.1.rst
+doc/en/announce/release-3.3.2.rst
+doc/en/announce/release-3.4.0.rst
+doc/en/announce/release-3.4.1.rst
+doc/en/announce/release-3.4.2.rst
+doc/en/announce/release-3.5.0.rst
+doc/en/announce/release-3.5.1.rst
+doc/en/announce/release-3.6.0.rst
+doc/en/announce/release-3.6.1.rst
+doc/en/announce/release-3.6.2.rst
+doc/en/announce/release-3.6.3.rst
+doc/en/announce/release-3.6.4.rst
+doc/en/announce/release-3.7.0.rst
+doc/en/announce/release-3.7.1.rst
+doc/en/announce/release-3.7.2.rst
+doc/en/announce/release-3.7.3.rst
+doc/en/announce/release-3.7.4.rst
+doc/en/announce/release-3.8.0.rst
+doc/en/announce/release-3.8.1.rst
+doc/en/announce/release-3.8.2.rst
+doc/en/announce/release-3.9.0.rst
+doc/en/announce/release-3.9.1.rst
+doc/en/announce/release-3.9.2.rst
+doc/en/announce/release-3.9.3.rst
+doc/en/announce/release-4.0.0.rst
+doc/en/announce/release-4.0.1.rst
+doc/en/announce/release-4.0.2.rst
+doc/en/announce/release-4.1.0.rst
+doc/en/announce/release-4.1.1.rst
+doc/en/announce/release-4.2.0.rst
+doc/en/announce/release-4.2.1.rst
+doc/en/announce/release-4.3.0.rst
+doc/en/announce/release-4.3.1.rst
+doc/en/announce/release-4.4.0.rst
+doc/en/announce/release-4.4.1.rst
+doc/en/announce/release-4.4.2.rst
+doc/en/announce/release-4.5.0.rst
+doc/en/announce/release-4.6.0.rst
+doc/en/announce/release-4.6.1.rst
+doc/en/announce/release-4.6.2.rst
+doc/en/announce/release-4.6.3.rst
+doc/en/announce/release-4.6.4.rst
+doc/en/announce/release-4.6.5.rst
+doc/en/announce/release-4.6.6.rst
+doc/en/announce/release-4.6.7.rst
+doc/en/announce/release-4.6.8.rst
+doc/en/announce/release-4.6.9.rst
+doc/en/announce/release-5.0.0.rst
+doc/en/announce/release-5.0.1.rst
+doc/en/announce/release-5.1.0.rst
+doc/en/announce/release-5.1.1.rst
+doc/en/announce/release-5.1.2.rst
+doc/en/announce/release-5.1.3.rst
+doc/en/announce/release-5.2.0.rst
+doc/en/announce/release-5.2.1.rst
+doc/en/announce/release-5.2.2.rst
+doc/en/announce/release-5.2.3.rst
+doc/en/announce/release-5.2.4.rst
+doc/en/announce/release-5.3.0.rst
+doc/en/announce/release-5.3.1.rst
+doc/en/announce/release-5.3.2.rst
+doc/en/announce/release-5.3.3.rst
+doc/en/announce/release-5.3.4.rst
+doc/en/announce/release-5.3.5.rst
+doc/en/announce/release-5.4.0.rst
+doc/en/announce/release-5.4.1.rst
+doc/en/announce/release-5.4.2.rst
+doc/en/announce/release-5.4.3.rst
+doc/en/announce/release-6.0.0.rst
+doc/en/announce/release-6.0.0rc1.rst
+doc/en/announce/release-6.0.1.rst
+doc/en/announce/release-6.0.2.rst
+doc/en/announce/release-6.1.0.rst
+doc/en/announce/release-6.1.1.rst
+doc/en/announce/release-6.1.2.rst
+doc/en/announce/release-6.2.0.rst
+doc/en/announce/release-6.2.1.rst
+doc/en/announce/release-6.2.2.rst
+doc/en/announce/release-6.2.3.rst
+doc/en/announce/release-6.2.4.rst
+doc/en/announce/release-6.2.5.rst
+doc/en/announce/release-7.0.0.rst
+doc/en/announce/release-7.0.0rc1.rst
+doc/en/announce/release-7.0.1.rst
+doc/en/announce/release-7.1.0.rst
+doc/en/announce/release-7.1.1.rst
+doc/en/announce/release-7.1.2.rst
+doc/en/announce/release-7.1.3.rst
+doc/en/announce/release-7.2.0.rst
+doc/en/announce/release-7.2.1.rst
+doc/en/announce/release-7.2.2.rst
+doc/en/announce/release-7.3.0.rst
+doc/en/announce/release-7.3.1.rst
+doc/en/announce/release-7.3.2.rst
+doc/en/announce/release-7.4.0.rst
+doc/en/announce/release-7.4.1.rst
+doc/en/announce/release-7.4.2.rst
+doc/en/announce/release-7.4.3.rst
+doc/en/announce/sprint2016.rst
+doc/en/example/attic.rst
+doc/en/example/conftest.py
+doc/en/example/index.rst
+doc/en/example/markers.rst
+doc/en/example/multipython.py
+doc/en/example/nonpython.rst
+doc/en/example/parametrize.rst
+doc/en/example/pythoncollection.py
+doc/en/example/pythoncollection.rst
+doc/en/example/reportingdemo.rst
+doc/en/example/simple.rst
+doc/en/example/special.rst
+doc/en/example/xfail_demo.py
+doc/en/example/assertion/failure_demo.py
+doc/en/example/assertion/test_failures.py
+doc/en/example/assertion/test_setup_flow_example.py
+doc/en/example/assertion/global_testmodule_config/conftest.py
+doc/en/example/assertion/global_testmodule_config/test_hello_world.py
+doc/en/example/fixtures/fixture_availability.svg
+doc/en/example/fixtures/fixture_availability_plugins.svg
+doc/en/example/fixtures/test_fixtures_order_autouse.py
+doc/en/example/fixtures/test_fixtures_order_autouse.svg
+doc/en/example/fixtures/test_fixtures_order_autouse_flat.svg
+doc/en/example/fixtures/test_fixtures_order_autouse_multiple_scopes.py
+doc/en/example/fixtures/test_fixtures_order_autouse_multiple_scopes.svg
+doc/en/example/fixtures/test_fixtures_order_autouse_temp_effects.py
+doc/en/example/fixtures/test_fixtures_order_autouse_temp_effects.svg
+doc/en/example/fixtures/test_fixtures_order_dependencies.py
+doc/en/example/fixtures/test_fixtures_order_dependencies.svg
+doc/en/example/fixtures/test_fixtures_order_dependencies_flat.svg
+doc/en/example/fixtures/test_fixtures_order_dependencies_unclear.svg
+doc/en/example/fixtures/test_fixtures_order_scope.py
+doc/en/example/fixtures/test_fixtures_order_scope.svg
+doc/en/example/fixtures/test_fixtures_request_different_scope.py
+doc/en/example/fixtures/test_fixtures_request_different_scope.svg
+doc/en/example/nonpython/__init__.py
+doc/en/example/nonpython/conftest.py
+doc/en/example/nonpython/test_simple.yaml
+doc/en/explanation/anatomy.rst
+doc/en/explanation/fixtures.rst
+doc/en/explanation/flaky.rst
+doc/en/explanation/goodpractices.rst
+doc/en/explanation/index.rst
+doc/en/explanation/pythonpath.rst
+doc/en/how-to/assert.rst
+doc/en/how-to/bash-completion.rst
+doc/en/how-to/cache.rst
+doc/en/how-to/capture-stdout-stderr.rst
+doc/en/how-to/capture-warnings.rst
+doc/en/how-to/doctest.rst
+doc/en/how-to/existingtestsuite.rst
+doc/en/how-to/failures.rst
+doc/en/how-to/fixtures.rst
+doc/en/how-to/index.rst
+doc/en/how-to/logging.rst
+doc/en/how-to/mark.rst
+doc/en/how-to/monkeypatch.rst
+doc/en/how-to/nose.rst
+doc/en/how-to/output.rst
+doc/en/how-to/parametrize.rst
+doc/en/how-to/plugins.rst
+doc/en/how-to/skipping.rst
+doc/en/how-to/tmp_path.rst
+doc/en/how-to/unittest.rst
+doc/en/how-to/usage.rst
+doc/en/how-to/writing_hook_functions.rst
+doc/en/how-to/writing_plugins.rst
+doc/en/how-to/xunit_setup.rst
+doc/en/img/cramer2.png
+doc/en/img/favicon.png
+doc/en/img/freiburg2.jpg
+doc/en/img/gaynor3.png
+doc/en/img/keleshev.png
+doc/en/img/pullrequest.png
+doc/en/img/pylib.png
+doc/en/img/pytest1.png
+doc/en/img/pytest_logo_curves.svg
+doc/en/img/theuni.png
+doc/en/proposals/parametrize_with_fixtures.rst
+doc/en/reference/customize.rst
+doc/en/reference/exit-codes.rst
+doc/en/reference/fixtures.rst
+doc/en/reference/index.rst
+doc/en/reference/plugin_list.rst
+doc/en/reference/reference.rst
+extra/get_issues.py
+scripts/prepare-release-pr.py
+scripts/publish-gh-release-notes.py
+scripts/release.major.rst
+scripts/release.minor.rst
+scripts/release.patch.rst
+scripts/release.pre.rst
+scripts/release.py
+scripts/towncrier-draft-to-file.py
+scripts/update-plugin-list.py
+src/py.py
+src/_pytest/__init__.py
+src/_pytest/_argcomplete.py
+src/_pytest/_version.py
+src/_pytest/cacheprovider.py
+src/_pytest/capture.py
+src/_pytest/compat.py
+src/_pytest/debugging.py
+src/_pytest/deprecated.py
+src/_pytest/doctest.py
+src/_pytest/faulthandler.py
+src/_pytest/fixtures.py
+src/_pytest/freeze_support.py
+src/_pytest/helpconfig.py
+src/_pytest/hookspec.py
+src/_pytest/junitxml.py
+src/_pytest/legacypath.py
+src/_pytest/logging.py
+src/_pytest/main.py
+src/_pytest/monkeypatch.py
+src/_pytest/nodes.py
+src/_pytest/nose.py
+src/_pytest/outcomes.py
+src/_pytest/pastebin.py
+src/_pytest/pathlib.py
+src/_pytest/py.typed
+src/_pytest/pytester.py
+src/_pytest/pytester_assertions.py
+src/_pytest/python.py
+src/_pytest/python_api.py
+src/_pytest/python_path.py
+src/_pytest/recwarn.py
+src/_pytest/reports.py
+src/_pytest/runner.py
+src/_pytest/scope.py
+src/_pytest/setuponly.py
+src/_pytest/setupplan.py
+src/_pytest/skipping.py
+src/_pytest/stash.py
+src/_pytest/stepwise.py
+src/_pytest/terminal.py
+src/_pytest/threadexception.py
+src/_pytest/timing.py
+src/_pytest/tmpdir.py
+src/_pytest/unittest.py
+src/_pytest/unraisableexception.py
+src/_pytest/warning_types.py
+src/_pytest/warnings.py
+src/_pytest/_code/__init__.py
+src/_pytest/_code/code.py
+src/_pytest/_code/source.py
+src/_pytest/_io/__init__.py
+src/_pytest/_io/saferepr.py
+src/_pytest/_io/terminalwriter.py
+src/_pytest/_io/wcwidth.py
+src/_pytest/_py/__init__.py
+src/_pytest/_py/error.py
+src/_pytest/_py/path.py
+src/_pytest/assertion/__init__.py
+src/_pytest/assertion/rewrite.py
+src/_pytest/assertion/truncate.py
+src/_pytest/assertion/util.py
+src/_pytest/config/__init__.py
+src/_pytest/config/argparsing.py
+src/_pytest/config/compat.py
+src/_pytest/config/exceptions.py
+src/_pytest/config/findpaths.py
+src/_pytest/mark/__init__.py
+src/_pytest/mark/expression.py
+src/_pytest/mark/structures.py
+src/pytest/__init__.py
+src/pytest/__main__.py
+src/pytest/py.typed
+src/pytest.egg-info/PKG-INFO
+src/pytest.egg-info/SOURCES.txt
+src/pytest.egg-info/dependency_links.txt
+src/pytest.egg-info/entry_points.txt
+src/pytest.egg-info/not-zip-safe
+src/pytest.egg-info/requires.txt
+src/pytest.egg-info/top_level.txt
+testing/acceptance_test.py
+testing/conftest.py
+testing/deprecated_test.py
+testing/test_argcomplete.py
+testing/test_assertion.py
+testing/test_assertrewrite.py
+testing/test_cacheprovider.py
+testing/test_capture.py
+testing/test_collection.py
+testing/test_compat.py
+testing/test_config.py
+testing/test_conftest.py
+testing/test_debugging.py
+testing/test_doctest.py
+testing/test_entry_points.py
+testing/test_error_diffs.py
+testing/test_faulthandler.py
+testing/test_findpaths.py
+testing/test_helpconfig.py
+testing/test_junitxml.py
+testing/test_legacypath.py
+testing/test_link_resolve.py
+testing/test_main.py
+testing/test_mark.py
+testing/test_mark_expression.py
+testing/test_meta.py
+testing/test_monkeypatch.py
+testing/test_nodes.py
+testing/test_nose.py
+testing/test_parseopt.py
+testing/test_pastebin.py
+testing/test_pathlib.py
+testing/test_pluginmanager.py
+testing/test_pytester.py
+testing/test_python_path.py
+testing/test_recwarn.py
+testing/test_reports.py
+testing/test_runner.py
+testing/test_runner_xunit.py
+testing/test_scope.py
+testing/test_session.py
+testing/test_setuponly.py
+testing/test_setupplan.py
+testing/test_skipping.py
+testing/test_stash.py
+testing/test_stepwise.py
+testing/test_terminal.py
+testing/test_threadexception.py
+testing/test_tmpdir.py
+testing/test_unittest.py
+testing/test_unraisableexception.py
+testing/test_warning_types.py
+testing/test_warnings.py
+testing/typing_checks.py
+testing/_py/test_local.py
+testing/code/test_code.py
+testing/code/test_excinfo.py
+testing/code/test_source.py
+testing/example_scripts/README.rst
+testing/example_scripts/__init__.py
+testing/example_scripts/issue_519.py
+testing/example_scripts/junit-10.xsd
+testing/example_scripts/pytest.ini
+testing/example_scripts/acceptance/fixture_mock_integration.py
+testing/example_scripts/collect/collect_init_tests/pytest.ini
+testing/example_scripts/collect/collect_init_tests/tests/__init__.py
+testing/example_scripts/collect/collect_init_tests/tests/test_foo.py
+testing/example_scripts/collect/package_infinite_recursion/__init__.pyi
+testing/example_scripts/collect/package_infinite_recursion/conftest.py
+testing/example_scripts/collect/package_infinite_recursion/tests/__init__.py
+testing/example_scripts/collect/package_infinite_recursion/tests/test_basic.py
+testing/example_scripts/collect/package_init_given_as_arg/pkg/__init__.py
+testing/example_scripts/collect/package_init_given_as_arg/pkg/test_foo.py
+testing/example_scripts/config/collect_pytest_prefix/__init__.pyi
+testing/example_scripts/config/collect_pytest_prefix/conftest.py
+testing/example_scripts/config/collect_pytest_prefix/test_foo.py
+testing/example_scripts/conftest_usageerror/__init__.pyi
+testing/example_scripts/conftest_usageerror/conftest.py
+testing/example_scripts/dataclasses/test_compare_dataclasses.py
+testing/example_scripts/dataclasses/test_compare_dataclasses_field_comparison_off.py
+testing/example_scripts/dataclasses/test_compare_dataclasses_verbose.py
+testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py
+testing/example_scripts/dataclasses/test_compare_initvar.py
+testing/example_scripts/dataclasses/test_compare_recursive_dataclasses.py
+testing/example_scripts/dataclasses/test_compare_two_different_dataclasses.py
+testing/example_scripts/doctest/main_py/__main__.py
+testing/example_scripts/doctest/main_py/test_normal_module.py
+testing/example_scripts/fixtures/test_fixture_named_request.py
+testing/example_scripts/fixtures/test_getfixturevalue_dynamic.py
+testing/example_scripts/fixtures/custom_item/__init__.pyi
+testing/example_scripts/fixtures/custom_item/conftest.py
+testing/example_scripts/fixtures/custom_item/foo/__init__.py
+testing/example_scripts/fixtures/custom_item/foo/test_foo.py
+testing/example_scripts/fixtures/fill_fixtures/test_detect_recursive_dependency_error.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_module_class.py
+testing/example_scripts/fixtures/fill_fixtures/test_funcarg_basic.py
+testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_classlevel.py
+testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookup_modulelevel.py
+testing/example_scripts/fixtures/fill_fixtures/test_funcarg_lookupfails.py
+testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/__init__.py
+testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/conftest.py
+testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub1/test_in_sub1.py
+testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/__init__.py
+testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/conftest.py
+testing/example_scripts/fixtures/fill_fixtures/test_conftest_funcargs_only_available_in_subdir/sub2/test_in_sub2.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/__init__.pyi
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/conftest.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/__init__.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/conftest.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_conftest/pkg/test_spam.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/__init__.pyi
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/conftest.py
+testing/example_scripts/fixtures/fill_fixtures/test_extend_fixture_conftest_module/test_extend_fixture_conftest_module.py
+testing/example_scripts/issue88_initial_file_multinodes/__init__.pyi
+testing/example_scripts/issue88_initial_file_multinodes/conftest.py
+testing/example_scripts/issue88_initial_file_multinodes/test_hello.py
+testing/example_scripts/marks/marks_considered_keywords/__init__.pyi
+testing/example_scripts/marks/marks_considered_keywords/conftest.py
+testing/example_scripts/marks/marks_considered_keywords/test_marks_as_keywords.py
+testing/example_scripts/perf_examples/collect_stats/.gitignore
+testing/example_scripts/perf_examples/collect_stats/generate_folders.py
+testing/example_scripts/perf_examples/collect_stats/template_test.py
+testing/example_scripts/tmpdir/tmp_path_fixture.py
+testing/example_scripts/unittest/test_parametrized_fixture_error_message.py
+testing/example_scripts/unittest/test_setup_skip.py
+testing/example_scripts/unittest/test_setup_skip_class.py
+testing/example_scripts/unittest/test_setup_skip_module.py
+testing/example_scripts/unittest/test_unittest_asyncio.py
+testing/example_scripts/unittest/test_unittest_asynctest.py
+testing/example_scripts/unittest/test_unittest_plain_async.py
+testing/example_scripts/warnings/test_group_warnings_by_message.py
+testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_1.py
+testing/example_scripts/warnings/test_group_warnings_by_message_summary/test_2.py
+testing/examples/test_issue519.py
+testing/freeze/.gitignore
+testing/freeze/create_executable.py
+testing/freeze/runtests_script.py
+testing/freeze/tox_run.py
+testing/freeze/tests/test_doctest.txt
+testing/freeze/tests/test_trivial.py
+testing/io/test_saferepr.py
+testing/io/test_terminalwriter.py
+testing/io/test_wcwidth.py
+testing/logging/test_fixture.py
+testing/logging/test_formatter.py
+testing/logging/test_reporting.py
+testing/plugins_integration/.gitignore
+testing/plugins_integration/README.rst
+testing/plugins_integration/bdd_wallet.feature
+testing/plugins_integration/bdd_wallet.py
+testing/plugins_integration/django_settings.py
+testing/plugins_integration/pytest.ini
+testing/plugins_integration/pytest_anyio_integration.py
+testing/plugins_integration/pytest_asyncio_integration.py
+testing/plugins_integration/pytest_mock_integration.py
+testing/plugins_integration/pytest_trio_integration.py
+testing/plugins_integration/pytest_twisted_integration.py
+testing/plugins_integration/requirements.txt
+testing/plugins_integration/simple_integration.py
+testing/python/approx.py
+testing/python/collect.py
+testing/python/fixtures.py
+testing/python/integration.py
+testing/python/metafunc.py
+testing/python/raises.py
+testing/python/show_fixtures_per_test.py
\ No newline at end of file
diff --git a/src/pytest.egg-info/dependency_links.txt b/src/pytest.egg-info/dependency_links.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/src/pytest.egg-info/entry_points.txt b/src/pytest.egg-info/entry_points.txt
new file mode 100644 (file)
index 0000000..192205d
--- /dev/null
@@ -0,0 +1,3 @@
+[console_scripts]
+py.test = pytest:console_main
+pytest = pytest:console_main
diff --git a/src/pytest.egg-info/not-zip-safe b/src/pytest.egg-info/not-zip-safe
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/src/pytest.egg-info/requires.txt b/src/pytest.egg-info/requires.txt
new file mode 100644 (file)
index 0000000..56a7194
--- /dev/null
@@ -0,0 +1,24 @@
+iniconfig
+packaging
+pluggy<2.0,>=0.12
+
+[:python_version < "3.11"]
+exceptiongroup>=1.0.0rc8
+tomli>=1.0.0
+
+[:python_version < "3.8"]
+importlib-metadata>=0.12
+
+[:sys_platform == "win32"]
+colorama
+
+[testing]
+argcomplete
+attrs>=19.2.0
+hypothesis>=3.56
+mock
+nose
+pygments>=2.7.2
+requests
+setuptools
+xmlschema
diff --git a/src/pytest.egg-info/top_level.txt b/src/pytest.egg-info/top_level.txt
new file mode 100644 (file)
index 0000000..3084ae5
--- /dev/null
@@ -0,0 +1,3 @@
+_pytest
+py
+pytest
index 70177f95040ca4d3bc0441b3b34e1ea2fbafd433..9c1d5d204d8783f3ffd05cbcabafba412ab87f94 100644 (file)
@@ -1,27 +1,37 @@
 # PYTHON_ARGCOMPLETE_OK
 """pytest: unit and functional testing with Python."""
-from . import collect
 from _pytest import __version__
+from _pytest import version_tuple
+from _pytest._code import ExceptionInfo
 from _pytest.assertion import register_assert_rewrite
 from _pytest.cacheprovider import Cache
 from _pytest.capture import CaptureFixture
 from _pytest.config import cmdline
+from _pytest.config import Config
 from _pytest.config import console_main
 from _pytest.config import ExitCode
 from _pytest.config import hookimpl
 from _pytest.config import hookspec
 from _pytest.config import main
+from _pytest.config import PytestPluginManager
 from _pytest.config import UsageError
+from _pytest.config.argparsing import OptionGroup
+from _pytest.config.argparsing import Parser
 from _pytest.debugging import pytestPDB as __pytestPDB
-from _pytest.fixtures import _fillfuncargs
+from _pytest.doctest import DoctestItem
 from _pytest.fixtures import fixture
 from _pytest.fixtures import FixtureLookupError
 from _pytest.fixtures import FixtureRequest
 from _pytest.fixtures import yield_fixture
 from _pytest.freeze_support import freeze_includes
+from _pytest.legacypath import TempdirFactory
+from _pytest.legacypath import Testdir
 from _pytest.logging import LogCaptureFixture
 from _pytest.main import Session
+from _pytest.mark import Mark
 from _pytest.mark import MARK_GEN as mark
+from _pytest.mark import MarkDecorator
+from _pytest.mark import MarkGenerator
 from _pytest.mark import param
 from _pytest.monkeypatch import MonkeyPatch
 from _pytest.nodes import Collector
@@ -32,11 +42,14 @@ from _pytest.outcomes import fail
 from _pytest.outcomes import importorskip
 from _pytest.outcomes import skip
 from _pytest.outcomes import xfail
+from _pytest.pytester import HookRecorder
+from _pytest.pytester import LineMatcher
 from _pytest.pytester import Pytester
-from _pytest.pytester import Testdir
+from _pytest.pytester import RecordedHookCall
+from _pytest.pytester import RunResult
 from _pytest.python import Class
 from _pytest.python import Function
-from _pytest.python import Instance
+from _pytest.python import Metafunc
 from _pytest.python import Module
 from _pytest.python import Package
 from _pytest.python_api import approx
@@ -44,7 +57,12 @@ from _pytest.python_api import raises
 from _pytest.recwarn import deprecated_call
 from _pytest.recwarn import WarningsRecorder
 from _pytest.recwarn import warns
-from _pytest.tmpdir import TempdirFactory
+from _pytest.reports import CollectReport
+from _pytest.reports import TestReport
+from _pytest.runner import CallInfo
+from _pytest.stash import Stash
+from _pytest.stash import StashKey
+from _pytest.terminal import TestShortLogReport
 from _pytest.tmpdir import TempPathFactory
 from _pytest.warning_types import PytestAssertRewriteWarning
 from _pytest.warning_types import PytestCacheWarning
@@ -52,6 +70,8 @@ from _pytest.warning_types import PytestCollectionWarning
 from _pytest.warning_types import PytestConfigWarning
 from _pytest.warning_types import PytestDeprecationWarning
 from _pytest.warning_types import PytestExperimentalApiWarning
+from _pytest.warning_types import PytestRemovedIn8Warning
+from _pytest.warning_types import PytestReturnNotNoneWarning
 from _pytest.warning_types import PytestUnhandledCoroutineWarning
 from _pytest.warning_types import PytestUnhandledThreadExceptionWarning
 from _pytest.warning_types import PytestUnknownMarkWarning
@@ -60,19 +80,23 @@ from _pytest.warning_types import PytestWarning
 
 set_trace = __pytestPDB.set_trace
 
+
 __all__ = [
     "__version__",
-    "_fillfuncargs",
     "approx",
     "Cache",
+    "CallInfo",
     "CaptureFixture",
     "Class",
     "cmdline",
-    "collect",
     "Collector",
+    "CollectReport",
+    "Config",
     "console_main",
     "deprecated_call",
+    "DoctestItem",
     "exit",
+    "ExceptionInfo",
     "ExitCode",
     "fail",
     "File",
@@ -82,40 +106,66 @@ __all__ = [
     "freeze_includes",
     "Function",
     "hookimpl",
+    "HookRecorder",
     "hookspec",
     "importorskip",
-    "Instance",
     "Item",
+    "LineMatcher",
     "LogCaptureFixture",
     "main",
     "mark",
+    "Mark",
+    "MarkDecorator",
+    "MarkGenerator",
+    "Metafunc",
     "Module",
     "MonkeyPatch",
+    "OptionGroup",
     "Package",
     "param",
+    "Parser",
     "PytestAssertRewriteWarning",
     "PytestCacheWarning",
     "PytestCollectionWarning",
     "PytestConfigWarning",
     "PytestDeprecationWarning",
     "PytestExperimentalApiWarning",
+    "PytestRemovedIn8Warning",
+    "PytestReturnNotNoneWarning",
     "Pytester",
+    "PytestPluginManager",
     "PytestUnhandledCoroutineWarning",
     "PytestUnhandledThreadExceptionWarning",
     "PytestUnknownMarkWarning",
     "PytestUnraisableExceptionWarning",
     "PytestWarning",
     "raises",
+    "RecordedHookCall",
     "register_assert_rewrite",
+    "RunResult",
     "Session",
     "set_trace",
     "skip",
+    "Stash",
+    "StashKey",
+    "version_tuple",
+    "TempdirFactory",
     "TempPathFactory",
     "Testdir",
-    "TempdirFactory",
+    "TestReport",
+    "TestShortLogReport",
     "UsageError",
     "WarningsRecorder",
     "warns",
     "xfail",
     "yield_fixture",
 ]
+
+
+def __getattr__(name: str) -> object:
+    if name == "Instance":
+        # The import emits a deprecation warning.
+        from _pytest.python import Instance
+
+        return Instance
+    raise AttributeError(f"module {__name__} has no attribute {name}")
diff --git a/src/pytest/collect.py b/src/pytest/collect.py
deleted file mode 100644 (file)
index 2edf447..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-import sys
-import warnings
-from types import ModuleType
-from typing import Any
-from typing import List
-
-import pytest
-from _pytest.deprecated import PYTEST_COLLECT_MODULE
-
-COLLECT_FAKEMODULE_ATTRIBUTES = [
-    "Collector",
-    "Module",
-    "Function",
-    "Instance",
-    "Session",
-    "Item",
-    "Class",
-    "File",
-    "_fillfuncargs",
-]
-
-
-class FakeCollectModule(ModuleType):
-    def __init__(self) -> None:
-        super().__init__("pytest.collect")
-        self.__all__ = list(COLLECT_FAKEMODULE_ATTRIBUTES)
-        self.__pytest = pytest
-
-    def __dir__(self) -> List[str]:
-        return dir(super()) + self.__all__
-
-    def __getattr__(self, name: str) -> Any:
-        if name not in self.__all__:
-            raise AttributeError(name)
-        warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2)
-        return getattr(pytest, name)
-
-
-sys.modules["pytest.collect"] = FakeCollectModule()
diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py
new file mode 100644 (file)
index 0000000..348682b
--- /dev/null
@@ -0,0 +1,1576 @@
+import contextlib
+import multiprocessing
+import os
+import sys
+import time
+import warnings
+from unittest import mock
+
+import pytest
+from py import error
+from py.path import local
+
+
+@contextlib.contextmanager
+def ignore_encoding_warning():
+    with warnings.catch_warnings():
+        with contextlib.suppress(NameError):  # new in 3.10
+            warnings.simplefilter("ignore", EncodingWarning)
+        yield
+
+
+class CommonFSTests:
+    def test_constructor_equality(self, path1):
+        p = path1.__class__(path1)
+        assert p == path1
+
+    def test_eq_nonstring(self, path1):
+        p1 = path1.join("sampledir")
+        p2 = path1.join("sampledir")
+        assert p1 == p2
+
+    def test_new_identical(self, path1):
+        assert path1 == path1.new()
+
+    def test_join(self, path1):
+        p = path1.join("sampledir")
+        strp = str(p)
+        assert strp.endswith("sampledir")
+        assert strp.startswith(str(path1))
+
+    def test_join_normalized(self, path1):
+        newpath = path1.join(path1.sep + "sampledir")
+        strp = str(newpath)
+        assert strp.endswith("sampledir")
+        assert strp.startswith(str(path1))
+        newpath = path1.join((path1.sep * 2) + "sampledir")
+        strp = str(newpath)
+        assert strp.endswith("sampledir")
+        assert strp.startswith(str(path1))
+
+    def test_join_noargs(self, path1):
+        newpath = path1.join()
+        assert path1 == newpath
+
+    def test_add_something(self, path1):
+        p = path1.join("sample")
+        p = p + "dir"
+        assert p.check()
+        assert p.exists()
+        assert p.isdir()
+        assert not p.isfile()
+
+    def test_parts(self, path1):
+        newpath = path1.join("sampledir", "otherfile")
+        par = newpath.parts()[-3:]
+        assert par == [path1, path1.join("sampledir"), newpath]
+
+        revpar = newpath.parts(reverse=True)[:3]
+        assert revpar == [newpath, path1.join("sampledir"), path1]
+
+    def test_common(self, path1):
+        other = path1.join("sampledir")
+        x = other.common(path1)
+        assert x == path1
+
+    # def test_parents_nonexisting_file(self, path1):
+    #    newpath = path1 / 'dirnoexist' / 'nonexisting file'
+    #    par = list(newpath.parents())
+    #    assert par[:2] == [path1 / 'dirnoexist', path1]
+
+    def test_basename_checks(self, path1):
+        newpath = path1.join("sampledir")
+        assert newpath.check(basename="sampledir")
+        assert newpath.check(notbasename="xyz")
+        assert newpath.basename == "sampledir"
+
+    def test_basename(self, path1):
+        newpath = path1.join("sampledir")
+        assert newpath.check(basename="sampledir")
+        assert newpath.basename, "sampledir"
+
+    def test_dirname(self, path1):
+        newpath = path1.join("sampledir")
+        assert newpath.dirname == str(path1)
+
+    def test_dirpath(self, path1):
+        newpath = path1.join("sampledir")
+        assert newpath.dirpath() == path1
+
+    def test_dirpath_with_args(self, path1):
+        newpath = path1.join("sampledir")
+        assert newpath.dirpath("x") == path1.join("x")
+
+    def test_newbasename(self, path1):
+        newpath = path1.join("samplefile")
+        newbase = newpath.new(basename="samplefile2")
+        assert newbase.basename == "samplefile2"
+        assert newbase.dirpath() == newpath.dirpath()
+
+    def test_not_exists(self, path1):
+        assert not path1.join("does_not_exist").check()
+        assert path1.join("does_not_exist").check(exists=0)
+
+    def test_exists(self, path1):
+        assert path1.join("samplefile").check()
+        assert path1.join("samplefile").check(exists=1)
+        assert path1.join("samplefile").exists()
+        assert path1.join("samplefile").isfile()
+        assert not path1.join("samplefile").isdir()
+
+    def test_dir(self, path1):
+        # print repr(path1.join("sampledir"))
+        assert path1.join("sampledir").check(dir=1)
+        assert path1.join("samplefile").check(notdir=1)
+        assert not path1.join("samplefile").check(dir=1)
+        assert path1.join("samplefile").exists()
+        assert not path1.join("samplefile").isdir()
+        assert path1.join("samplefile").isfile()
+
+    def test_fnmatch_file(self, path1):
+        assert path1.join("samplefile").check(fnmatch="s*e")
+        assert path1.join("samplefile").fnmatch("s*e")
+        assert not path1.join("samplefile").fnmatch("s*x")
+        assert not path1.join("samplefile").check(fnmatch="s*x")
+
+    # def test_fnmatch_dir(self, path1):
+
+    #    pattern = path1.sep.join(['s*file'])
+    #    sfile = path1.join("samplefile")
+    #    assert sfile.check(fnmatch=pattern)
+
+    def test_relto(self, path1):
+        p = path1.join("sampledir", "otherfile")
+        assert p.relto(path1) == p.sep.join(["sampledir", "otherfile"])
+        assert p.check(relto=path1)
+        assert path1.check(notrelto=p)
+        assert not path1.check(relto=p)
+
+    def test_bestrelpath(self, path1):
+        curdir = path1
+        sep = curdir.sep
+        s = curdir.bestrelpath(curdir)
+        assert s == "."
+        s = curdir.bestrelpath(curdir.join("hello", "world"))
+        assert s == "hello" + sep + "world"
+
+        s = curdir.bestrelpath(curdir.dirpath().join("sister"))
+        assert s == ".." + sep + "sister"
+        assert curdir.bestrelpath(curdir.dirpath()) == ".."
+
+        assert curdir.bestrelpath("hello") == "hello"
+
+    def test_relto_not_relative(self, path1):
+        l1 = path1.join("bcde")
+        l2 = path1.join("b")
+        assert not l1.relto(l2)
+        assert not l2.relto(l1)
+
+    def test_listdir(self, path1):
+        p = path1.listdir()
+        assert path1.join("sampledir") in p
+        assert path1.join("samplefile") in p
+        with pytest.raises(error.ENOTDIR):
+            path1.join("samplefile").listdir()
+
+    def test_listdir_fnmatchstring(self, path1):
+        p = path1.listdir("s*dir")
+        assert len(p)
+        assert p[0], path1.join("sampledir")
+
+    def test_listdir_filter(self, path1):
+        p = path1.listdir(lambda x: x.check(dir=1))
+        assert path1.join("sampledir") in p
+        assert not path1.join("samplefile") in p
+
+    def test_listdir_sorted(self, path1):
+        p = path1.listdir(lambda x: x.check(basestarts="sample"), sort=True)
+        assert path1.join("sampledir") == p[0]
+        assert path1.join("samplefile") == p[1]
+        assert path1.join("samplepickle") == p[2]
+
+    def test_visit_nofilter(self, path1):
+        lst = []
+        for i in path1.visit():
+            lst.append(i.relto(path1))
+        assert "sampledir" in lst
+        assert path1.sep.join(["sampledir", "otherfile"]) in lst
+
+    def test_visit_norecurse(self, path1):
+        lst = []
+        for i in path1.visit(None, lambda x: x.basename != "sampledir"):
+            lst.append(i.relto(path1))
+        assert "sampledir" in lst
+        assert not path1.sep.join(["sampledir", "otherfile"]) in lst
+
+    @pytest.mark.parametrize(
+        "fil",
+        ["*dir", "*dir", pytest.mark.skip("sys.version_info <" " (3,6)")(b"*dir")],
+    )
+    def test_visit_filterfunc_is_string(self, path1, fil):
+        lst = []
+        for i in path1.visit(fil):
+            lst.append(i.relto(path1))
+        assert len(lst), 2
+        assert "sampledir" in lst
+        assert "otherdir" in lst
+
+    def test_visit_ignore(self, path1):
+        p = path1.join("nonexisting")
+        assert list(p.visit(ignore=error.ENOENT)) == []
+
+    def test_visit_endswith(self, path1):
+        p = []
+        for i in path1.visit(lambda x: x.check(endswith="file")):
+            p.append(i.relto(path1))
+        assert path1.sep.join(["sampledir", "otherfile"]) in p
+        assert "samplefile" in p
+
+    def test_cmp(self, path1):
+        path1 = path1.join("samplefile")
+        path2 = path1.join("samplefile2")
+        assert (path1 < path2) == ("samplefile" < "samplefile2")
+        assert not (path1 < path1)
+
+    def test_simple_read(self, path1):
+        with ignore_encoding_warning():
+            x = path1.join("samplefile").read("r")
+        assert x == "samplefile\n"
+
+    def test_join_div_operator(self, path1):
+        newpath = path1 / "/sampledir" / "/test//"
+        newpath2 = path1.join("sampledir", "test")
+        assert newpath == newpath2
+
+    def test_ext(self, path1):
+        newpath = path1.join("sampledir.ext")
+        assert newpath.ext == ".ext"
+        newpath = path1.join("sampledir")
+        assert not newpath.ext
+
+    def test_purebasename(self, path1):
+        newpath = path1.join("samplefile.py")
+        assert newpath.purebasename == "samplefile"
+
+    def test_multiple_parts(self, path1):
+        newpath = path1.join("samplefile.py")
+        dirname, purebasename, basename, ext = newpath._getbyspec(
+            "dirname,purebasename,basename,ext"
+        )
+        assert str(path1).endswith(dirname)  # be careful with win32 'drive'
+        assert purebasename == "samplefile"
+        assert basename == "samplefile.py"
+        assert ext == ".py"
+
+    def test_dotted_name_ext(self, path1):
+        newpath = path1.join("a.b.c")
+        ext = newpath.ext
+        assert ext == ".c"
+        assert newpath.ext == ".c"
+
+    def test_newext(self, path1):
+        newpath = path1.join("samplefile.py")
+        newext = newpath.new(ext=".txt")
+        assert newext.basename == "samplefile.txt"
+        assert newext.purebasename == "samplefile"
+
+    def test_readlines(self, path1):
+        fn = path1.join("samplefile")
+        with ignore_encoding_warning():
+            contents = fn.readlines()
+        assert contents == ["samplefile\n"]
+
+    def test_readlines_nocr(self, path1):
+        fn = path1.join("samplefile")
+        with ignore_encoding_warning():
+            contents = fn.readlines(cr=0)
+        assert contents == ["samplefile", ""]
+
+    def test_file(self, path1):
+        assert path1.join("samplefile").check(file=1)
+
+    def test_not_file(self, path1):
+        assert not path1.join("sampledir").check(file=1)
+        assert path1.join("sampledir").check(file=0)
+
+    def test_non_existent(self, path1):
+        assert path1.join("sampledir.nothere").check(dir=0)
+        assert path1.join("sampledir.nothere").check(file=0)
+        assert path1.join("sampledir.nothere").check(notfile=1)
+        assert path1.join("sampledir.nothere").check(notdir=1)
+        assert path1.join("sampledir.nothere").check(notexists=1)
+        assert not path1.join("sampledir.nothere").check(notfile=0)
+
+    #    pattern = path1.sep.join(['s*file'])
+    #    sfile = path1.join("samplefile")
+    #    assert sfile.check(fnmatch=pattern)
+
+    def test_size(self, path1):
+        url = path1.join("samplefile")
+        assert url.size() > len("samplefile")
+
+    def test_mtime(self, path1):
+        url = path1.join("samplefile")
+        assert url.mtime() > 0
+
+    def test_relto_wrong_type(self, path1):
+        with pytest.raises(TypeError):
+            path1.relto(42)
+
+    def test_load(self, path1):
+        p = path1.join("samplepickle")
+        obj = p.load()
+        assert type(obj) is dict
+        assert obj.get("answer", None) == 42
+
+    def test_visit_filesonly(self, path1):
+        p = []
+        for i in path1.visit(lambda x: x.check(file=1)):
+            p.append(i.relto(path1))
+        assert "sampledir" not in p
+        assert path1.sep.join(["sampledir", "otherfile"]) in p
+
+    def test_visit_nodotfiles(self, path1):
+        p = []
+        for i in path1.visit(lambda x: x.check(dotfile=0)):
+            p.append(i.relto(path1))
+        assert "sampledir" in p
+        assert path1.sep.join(["sampledir", "otherfile"]) in p
+        assert ".dotfile" not in p
+
+    def test_visit_breadthfirst(self, path1):
+        lst = []
+        for i in path1.visit(bf=True):
+            lst.append(i.relto(path1))
+        for i, p in enumerate(lst):
+            if path1.sep in p:
+                for j in range(i, len(lst)):
+                    assert path1.sep in lst[j]
+                break
+        else:
+            pytest.fail("huh")
+
+    def test_visit_sort(self, path1):
+        lst = []
+        for i in path1.visit(bf=True, sort=True):
+            lst.append(i.relto(path1))
+        for i, p in enumerate(lst):
+            if path1.sep in p:
+                break
+        assert lst[:i] == sorted(lst[:i])
+        assert lst[i:] == sorted(lst[i:])
+
+    def test_endswith(self, path1):
+        def chk(p):
+            return p.check(endswith="pickle")
+
+        assert not chk(path1)
+        assert not chk(path1.join("samplefile"))
+        assert chk(path1.join("somepickle"))
+
+    def test_copy_file(self, path1):
+        otherdir = path1.join("otherdir")
+        initpy = otherdir.join("__init__.py")
+        copied = otherdir.join("copied")
+        initpy.copy(copied)
+        try:
+            assert copied.check()
+            s1 = initpy.read_text(encoding="utf-8")
+            s2 = copied.read_text(encoding="utf-8")
+            assert s1 == s2
+        finally:
+            if copied.check():
+                copied.remove()
+
+    def test_copy_dir(self, path1):
+        otherdir = path1.join("otherdir")
+        copied = path1.join("newdir")
+        try:
+            otherdir.copy(copied)
+            assert copied.check(dir=1)
+            assert copied.join("__init__.py").check(file=1)
+            s1 = otherdir.join("__init__.py").read_text(encoding="utf-8")
+            s2 = copied.join("__init__.py").read_text(encoding="utf-8")
+            assert s1 == s2
+        finally:
+            if copied.check(dir=1):
+                copied.remove(rec=1)
+
+    def test_remove_file(self, path1):
+        d = path1.ensure("todeleted")
+        assert d.check()
+        d.remove()
+        assert not d.check()
+
+    def test_remove_dir_recursive_by_default(self, path1):
+        d = path1.ensure("to", "be", "deleted")
+        assert d.check()
+        p = path1.join("to")
+        p.remove()
+        assert not p.check()
+
+    def test_ensure_dir(self, path1):
+        b = path1.ensure_dir("001", "002")
+        assert b.basename == "002"
+        assert b.isdir()
+
+    def test_mkdir_and_remove(self, path1):
+        tmpdir = path1
+        with pytest.raises(error.EEXIST):
+            tmpdir.mkdir("sampledir")
+        new = tmpdir.join("mktest1")
+        new.mkdir()
+        assert new.check(dir=1)
+        new.remove()
+
+        new = tmpdir.mkdir("mktest")
+        assert new.check(dir=1)
+        new.remove()
+        assert tmpdir.join("mktest") == new
+
+    def test_move_file(self, path1):
+        p = path1.join("samplefile")
+        newp = p.dirpath("moved_samplefile")
+        p.move(newp)
+        try:
+            assert newp.check(file=1)
+            assert not p.check()
+        finally:
+            dp = newp.dirpath()
+            if hasattr(dp, "revert"):
+                dp.revert()
+            else:
+                newp.move(p)
+                assert p.check()
+
+    def test_move_dir(self, path1):
+        source = path1.join("sampledir")
+        dest = path1.join("moveddir")
+        source.move(dest)
+        assert dest.check(dir=1)
+        assert dest.join("otherfile").check(file=1)
+        assert not source.join("sampledir").check()
+
+    def test_fspath_protocol_match_strpath(self, path1):
+        assert path1.__fspath__() == path1.strpath
+
+    def test_fspath_func_match_strpath(self, path1):
+        from os import fspath
+
+        assert fspath(path1) == path1.strpath
+
+    @pytest.mark.skip("sys.version_info < (3,6)")
+    def test_fspath_open(self, path1):
+        f = path1.join("opentestfile")
+        open(f)
+
+    @pytest.mark.skip("sys.version_info < (3,6)")
+    def test_fspath_fsencode(self, path1):
+        from os import fsencode
+
+        assert fsencode(path1) == fsencode(path1.strpath)
+
+
+def setuptestfs(path):
+    if path.join("samplefile").check():
+        return
+    # print "setting up test fs for", repr(path)
+    samplefile = path.ensure("samplefile")
+    samplefile.write_text("samplefile\n", encoding="utf-8")
+
+    execfile = path.ensure("execfile")
+    execfile.write_text("x=42", encoding="utf-8")
+
+    execfilepy = path.ensure("execfile.py")
+    execfilepy.write_text("x=42", encoding="utf-8")
+
+    d = {1: 2, "hello": "world", "answer": 42}
+    path.ensure("samplepickle").dump(d)
+
+    sampledir = path.ensure("sampledir", dir=1)
+    sampledir.ensure("otherfile")
+
+    otherdir = path.ensure("otherdir", dir=1)
+    otherdir.ensure("__init__.py")
+
+    module_a = otherdir.ensure("a.py")
+    module_a.write_text("from .b import stuff as result\n", encoding="utf-8")
+    module_b = otherdir.ensure("b.py")
+    module_b.write_text('stuff="got it"\n', encoding="utf-8")
+    module_c = otherdir.ensure("c.py")
+    module_c.write_text(
+        """import py;
+import otherdir.a
+value = otherdir.a.result
+""",
+        encoding="utf-8",
+    )
+    module_d = otherdir.ensure("d.py")
+    module_d.write_text(
+        """import py;
+from otherdir import a
+value2 = a.result
+""",
+        encoding="utf-8",
+    )
+
+
+win32only = pytest.mark.skipif(
+    "not (sys.platform == 'win32' or getattr(os, '_name', None) == 'nt')"
+)
+skiponwin32 = pytest.mark.skipif(
+    "sys.platform == 'win32' or getattr(os, '_name', None) == 'nt'"
+)
+
+ATIME_RESOLUTION = 0.01
+
+
+@pytest.fixture(scope="session")
+def path1(tmpdir_factory):
+    path = tmpdir_factory.mktemp("path")
+    setuptestfs(path)
+    yield path
+    assert path.join("samplefile").check()
+
+
+@pytest.fixture
+def fake_fspath_obj(request):
+    class FakeFSPathClass:
+        def __init__(self, path):
+            self._path = path
+
+        def __fspath__(self):
+            return self._path
+
+    return FakeFSPathClass(os.path.join("this", "is", "a", "fake", "path"))
+
+
+def batch_make_numbered_dirs(rootdir, repeats):
+    for i in range(repeats):
+        dir_ = local.make_numbered_dir(prefix="repro-", rootdir=rootdir)
+        file_ = dir_.join("foo")
+        file_.write_text("%s" % i, encoding="utf-8")
+        actual = int(file_.read_text(encoding="utf-8"))
+        assert (
+            actual == i
+        ), f"int(file_.read_text(encoding='utf-8')) is {actual} instead of {i}"
+        dir_.join(".lock").remove(ignore_errors=True)
+    return True
+
+
+class TestLocalPath(CommonFSTests):
+    def test_join_normpath(self, tmpdir):
+        assert tmpdir.join(".") == tmpdir
+        p = tmpdir.join("../%s" % tmpdir.basename)
+        assert p == tmpdir
+        p = tmpdir.join("..//%s/" % tmpdir.basename)
+        assert p == tmpdir
+
+    @skiponwin32
+    def test_dirpath_abs_no_abs(self, tmpdir):
+        p = tmpdir.join("foo")
+        assert p.dirpath("/bar") == tmpdir.join("bar")
+        assert tmpdir.dirpath("/bar", abs=True) == local("/bar")
+
+    def test_gethash(self, tmpdir):
+        from hashlib import md5
+        from hashlib import sha1 as sha
+
+        fn = tmpdir.join("testhashfile")
+        data = b"hello"
+        fn.write(data, mode="wb")
+        assert fn.computehash("md5") == md5(data).hexdigest()
+        assert fn.computehash("sha1") == sha(data).hexdigest()
+        with pytest.raises(ValueError):
+            fn.computehash("asdasd")
+
+    def test_remove_removes_readonly_file(self, tmpdir):
+        readonly_file = tmpdir.join("readonly").ensure()
+        readonly_file.chmod(0)
+        readonly_file.remove()
+        assert not readonly_file.check(exists=1)
+
+    def test_remove_removes_readonly_dir(self, tmpdir):
+        readonly_dir = tmpdir.join("readonlydir").ensure(dir=1)
+        readonly_dir.chmod(int("500", 8))
+        readonly_dir.remove()
+        assert not readonly_dir.check(exists=1)
+
+    def test_remove_removes_dir_and_readonly_file(self, tmpdir):
+        readonly_dir = tmpdir.join("readonlydir").ensure(dir=1)
+        readonly_file = readonly_dir.join("readonlyfile").ensure()
+        readonly_file.chmod(0)
+        readonly_dir.remove()
+        assert not readonly_dir.check(exists=1)
+
+    def test_remove_routes_ignore_errors(self, tmpdir, monkeypatch):
+        lst = []
+        monkeypatch.setattr("shutil.rmtree", lambda *args, **kwargs: lst.append(kwargs))
+        tmpdir.remove()
+        assert not lst[0]["ignore_errors"]
+        for val in (True, False):
+            lst[:] = []
+            tmpdir.remove(ignore_errors=val)
+            assert lst[0]["ignore_errors"] == val
+
+    def test_initialize_curdir(self):
+        assert str(local()) == os.getcwd()
+
+    @skiponwin32
+    def test_chdir_gone(self, path1):
+        p = path1.ensure("dir_to_be_removed", dir=1)
+        p.chdir()
+        p.remove()
+        pytest.raises(error.ENOENT, local)
+        assert path1.chdir() is None
+        assert os.getcwd() == str(path1)
+
+        with pytest.raises(error.ENOENT):
+            with p.as_cwd():
+                raise NotImplementedError
+
+    @skiponwin32
+    def test_chdir_gone_in_as_cwd(self, path1):
+        p = path1.ensure("dir_to_be_removed", dir=1)
+        p.chdir()
+        p.remove()
+
+        with path1.as_cwd() as old:
+            assert old is None
+
+    def test_as_cwd(self, path1):
+        dir = path1.ensure("subdir", dir=1)
+        old = local()
+        with dir.as_cwd() as x:
+            assert x == old
+            assert local() == dir
+        assert os.getcwd() == str(old)
+
+    def test_as_cwd_exception(self, path1):
+        old = local()
+        dir = path1.ensure("subdir", dir=1)
+        with pytest.raises(ValueError):
+            with dir.as_cwd():
+                raise ValueError()
+        assert old == local()
+
+    def test_initialize_reldir(self, path1):
+        with path1.as_cwd():
+            p = local("samplefile")
+            assert p.check()
+
+    def test_tilde_expansion(self, monkeypatch, tmpdir):
+        monkeypatch.setenv("HOME", str(tmpdir))
+        p = local("~", expanduser=True)
+        assert p == os.path.expanduser("~")
+
+    @pytest.mark.skipif(
+        not sys.platform.startswith("win32"), reason="case insensitive only on windows"
+    )
+    def test_eq_hash_are_case_insensitive_on_windows(self):
+        a = local("/some/path")
+        b = local("/some/PATH")
+        assert a == b
+        assert hash(a) == hash(b)
+        assert a in {b}
+        assert a in {b: "b"}
+
+    def test_eq_with_strings(self, path1):
+        path1 = path1.join("sampledir")
+        path2 = str(path1)
+        assert path1 == path2
+        assert path2 == path1
+        path3 = path1.join("samplefile")
+        assert path3 != path2
+        assert path2 != path3
+
+    def test_eq_with_none(self, path1):
+        assert path1 != None  # noqa: E711
+
+    def test_eq_non_ascii_unicode(self, path1):
+        path2 = path1.join("temp")
+        path3 = path1.join("ação")
+        path4 = path1.join("ディレクトリ")
+
+        assert path2 != path3
+        assert path2 != path4
+        assert path4 != path3
+
+    def test_gt_with_strings(self, path1):
+        path2 = path1.join("sampledir")
+        path3 = str(path1.join("ttt"))
+        assert path3 > path2
+        assert path2 < path3
+        assert path2 < "ttt"
+        assert "ttt" > path2
+        path4 = path1.join("aaa")
+        lst = [path2, path4, path3]
+        assert sorted(lst) == [path4, path2, path3]
+
+    def test_open_and_ensure(self, path1):
+        p = path1.join("sub1", "sub2", "file")
+        with p.open("w", ensure=1, encoding="utf-8") as f:
+            f.write("hello")
+        assert p.read_text(encoding="utf-8") == "hello"
+
+    def test_write_and_ensure(self, path1):
+        p = path1.join("sub1", "sub2", "file")
+        p.write_text("hello", ensure=1, encoding="utf-8")
+        assert p.read_text(encoding="utf-8") == "hello"
+
+    @pytest.mark.parametrize("bin", (False, True))
+    def test_dump(self, tmpdir, bin):
+        path = tmpdir.join("dumpfile%s" % int(bin))
+        try:
+            d = {"answer": 42}
+            path.dump(d, bin=bin)
+            f = path.open("rb+")
+            import pickle
+
+            dnew = pickle.load(f)
+            assert d == dnew
+        finally:
+            f.close()
+
+    def test_setmtime(self):
+        import tempfile
+        import time
+
+        try:
+            fd, name = tempfile.mkstemp()
+            os.close(fd)
+        except AttributeError:
+            name = tempfile.mktemp()
+            open(name, "w").close()
+        try:
+            mtime = int(time.time()) - 100
+            path = local(name)
+            assert path.mtime() != mtime
+            path.setmtime(mtime)
+            assert path.mtime() == mtime
+            path.setmtime()
+            assert path.mtime() != mtime
+        finally:
+            os.remove(name)
+
+    def test_normpath(self, path1):
+        new1 = path1.join("/otherdir")
+        new2 = path1.join("otherdir")
+        assert str(new1) == str(new2)
+
+    def test_mkdtemp_creation(self):
+        d = local.mkdtemp()
+        try:
+            assert d.check(dir=1)
+        finally:
+            d.remove(rec=1)
+
+    def test_tmproot(self):
+        d = local.mkdtemp()
+        tmproot = local.get_temproot()
+        try:
+            assert d.check(dir=1)
+            assert d.dirpath() == tmproot
+        finally:
+            d.remove(rec=1)
+
+    def test_chdir(self, tmpdir):
+        old = local()
+        try:
+            res = tmpdir.chdir()
+            assert str(res) == str(old)
+            assert os.getcwd() == str(tmpdir)
+        finally:
+            old.chdir()
+
+    def test_ensure_filepath_withdir(self, tmpdir):
+        newfile = tmpdir.join("test1", "test")
+        newfile.ensure()
+        assert newfile.check(file=1)
+        newfile.write_text("42", encoding="utf-8")
+        newfile.ensure()
+        s = newfile.read_text(encoding="utf-8")
+        assert s == "42"
+
+    def test_ensure_filepath_withoutdir(self, tmpdir):
+        newfile = tmpdir.join("test1file")
+        t = newfile.ensure()
+        assert t == newfile
+        assert newfile.check(file=1)
+
+    def test_ensure_dirpath(self, tmpdir):
+        newfile = tmpdir.join("test1", "testfile")
+        t = newfile.ensure(dir=1)
+        assert t == newfile
+        assert newfile.check(dir=1)
+
+    def test_ensure_non_ascii_unicode(self, tmpdir):
+        newfile = tmpdir.join("ação", "ディレクトリ")
+        t = newfile.ensure(dir=1)
+        assert t == newfile
+        assert newfile.check(dir=1)
+
+    @pytest.mark.xfail(run=False, reason="unreliable est for long filenames")
+    def test_long_filenames(self, tmpdir):
+        if sys.platform == "win32":
+            pytest.skip("win32: work around needed for path length limit")
+        # see http://codespeak.net/pipermail/py-dev/2008q2/000922.html
+
+        # testing paths > 260 chars (which is Windows' limitation, but
+        # depending on how the paths are used), but > 4096 (which is the
+        # Linux' limitation) - the behaviour of paths with names > 4096 chars
+        # is undetermined
+        newfilename = "/test" * 60  # type:ignore[unreachable]
+        l1 = tmpdir.join(newfilename)
+        l1.ensure(file=True)
+        l1.write_text("foo", encoding="utf-8")
+        l2 = tmpdir.join(newfilename)
+        assert l2.read_text(encoding="utf-8") == "foo"
+
+    def test_visit_depth_first(self, tmpdir):
+        tmpdir.ensure("a", "1")
+        tmpdir.ensure("b", "2")
+        p3 = tmpdir.ensure("breadth")
+        lst = list(tmpdir.visit(lambda x: x.check(file=1)))
+        assert len(lst) == 3
+        # check that breadth comes last
+        assert lst[2] == p3
+
+    def test_visit_rec_fnmatch(self, tmpdir):
+        p1 = tmpdir.ensure("a", "123")
+        tmpdir.ensure(".b", "345")
+        lst = list(tmpdir.visit("???", rec="[!.]*"))
+        assert len(lst) == 1
+        # check that breadth comes last
+        assert lst[0] == p1
+
+    def test_fnmatch_file_abspath(self, tmpdir):
+        b = tmpdir.join("a", "b")
+        assert b.fnmatch(os.sep.join("ab"))
+        pattern = os.sep.join([str(tmpdir), "*", "b"])
+        assert b.fnmatch(pattern)
+
+    def test_sysfind(self):
+        name = sys.platform == "win32" and "cmd" or "test"
+        x = local.sysfind(name)
+        assert x.check(file=1)
+        assert local.sysfind("jaksdkasldqwe") is None
+        assert local.sysfind(name, paths=[]) is None
+        x2 = local.sysfind(name, paths=[x.dirpath()])
+        assert x2 == x
+
+    def test_fspath_protocol_other_class(self, fake_fspath_obj):
+        # py.path is always absolute
+        py_path = local(fake_fspath_obj)
+        str_path = fake_fspath_obj.__fspath__()
+        assert py_path.check(endswith=str_path)
+        assert py_path.join(fake_fspath_obj).strpath == os.path.join(
+            py_path.strpath, str_path
+        )
+
+    def test_make_numbered_dir_multiprocess_safe(self, tmpdir):
+        # https://github.com/pytest-dev/py/issues/30
+        with multiprocessing.Pool() as pool:
+            results = [
+                pool.apply_async(batch_make_numbered_dirs, [tmpdir, 100])
+                for _ in range(20)
+            ]
+            for r in results:
+                assert r.get()
+
+
+class TestExecutionOnWindows:
+    pytestmark = win32only
+
+    def test_sysfind_bat_exe_before(self, tmpdir, monkeypatch):
+        monkeypatch.setenv("PATH", str(tmpdir), prepend=os.pathsep)
+        tmpdir.ensure("hello")
+        h = tmpdir.ensure("hello.bat")
+        x = local.sysfind("hello")
+        assert x == h
+
+
+class TestExecution:
+    pytestmark = skiponwin32
+
+    def test_sysfind_no_permisson_ignored(self, monkeypatch, tmpdir):
+        noperm = tmpdir.ensure("noperm", dir=True)
+        monkeypatch.setenv("PATH", str(noperm), prepend=":")
+        noperm.chmod(0)
+        try:
+            assert local.sysfind("jaksdkasldqwe") is None
+        finally:
+            noperm.chmod(0o644)
+
+    def test_sysfind_absolute(self):
+        x = local.sysfind("test")
+        assert x.check(file=1)
+        y = local.sysfind(str(x))
+        assert y.check(file=1)
+        assert y == x
+
+    def test_sysfind_multiple(self, tmpdir, monkeypatch):
+        monkeypatch.setenv(
+            "PATH", "{}:{}".format(tmpdir.ensure("a"), tmpdir.join("b")), prepend=":"
+        )
+        tmpdir.ensure("b", "a")
+        x = local.sysfind("a", checker=lambda x: x.dirpath().basename == "b")
+        assert x.basename == "a"
+        assert x.dirpath().basename == "b"
+        assert local.sysfind("a", checker=lambda x: None) is None
+
+    def test_sysexec(self):
+        x = local.sysfind("ls")
+        out = x.sysexec("-a")
+        for x in local().listdir():
+            assert out.find(x.basename) != -1
+
+    def test_sysexec_failing(self):
+        try:
+            from py._process.cmdexec import ExecutionFailed  # py library
+        except ImportError:
+            ExecutionFailed = RuntimeError  # py vendored
+        x = local.sysfind("false")
+        with pytest.raises(ExecutionFailed):
+            x.sysexec("aksjdkasjd")
+
+    def test_make_numbered_dir(self, tmpdir):
+        tmpdir.ensure("base.not_an_int", dir=1)
+        for i in range(10):
+            numdir = local.make_numbered_dir(
+                prefix="base.", rootdir=tmpdir, keep=2, lock_timeout=0
+            )
+            assert numdir.check()
+            assert numdir.basename == "base.%d" % i
+            if i >= 1:
+                assert numdir.new(ext=str(i - 1)).check()
+            if i >= 2:
+                assert numdir.new(ext=str(i - 2)).check()
+            if i >= 3:
+                assert not numdir.new(ext=str(i - 3)).check()
+
+    def test_make_numbered_dir_case(self, tmpdir):
+        """make_numbered_dir does not make assumptions on the underlying
+        filesystem based on the platform and will assume it _could_ be case
+        insensitive.
+
+        See issues:
+        - https://github.com/pytest-dev/pytest/issues/708
+        - https://github.com/pytest-dev/pytest/issues/3451
+        """
+        d1 = local.make_numbered_dir(
+            prefix="CAse.",
+            rootdir=tmpdir,
+            keep=2,
+            lock_timeout=0,
+        )
+        d2 = local.make_numbered_dir(
+            prefix="caSE.",
+            rootdir=tmpdir,
+            keep=2,
+            lock_timeout=0,
+        )
+        assert str(d1).lower() != str(d2).lower()
+        assert str(d2).endswith(".1")
+
+    def test_make_numbered_dir_NotImplemented_Error(self, tmpdir, monkeypatch):
+        def notimpl(x, y):
+            raise NotImplementedError(42)
+
+        monkeypatch.setattr(os, "symlink", notimpl)
+        x = tmpdir.make_numbered_dir(rootdir=tmpdir, lock_timeout=0)
+        assert x.relto(tmpdir)
+        assert x.check()
+
+    def test_locked_make_numbered_dir(self, tmpdir):
+        for i in range(10):
+            numdir = local.make_numbered_dir(prefix="base2.", rootdir=tmpdir, keep=2)
+            assert numdir.check()
+            assert numdir.basename == "base2.%d" % i
+            for j in range(i):
+                assert numdir.new(ext=str(j)).check()
+
+    def test_error_preservation(self, path1):
+        pytest.raises(EnvironmentError, path1.join("qwoeqiwe").mtime)
+        pytest.raises(EnvironmentError, path1.join("qwoeqiwe").read)
+
+    # def test_parentdirmatch(self):
+    #    local.parentdirmatch('std', startmodule=__name__)
+    #
+
+
+class TestImport:
+    @pytest.fixture(autouse=True)
+    def preserve_sys(self):
+        with mock.patch.dict(sys.modules):
+            with mock.patch.object(sys, "path", list(sys.path)):
+                yield
+
+    def test_pyimport(self, path1):
+        obj = path1.join("execfile.py").pyimport()
+        assert obj.x == 42
+        assert obj.__name__ == "execfile"
+
+    def test_pyimport_renamed_dir_creates_mismatch(self, tmpdir, monkeypatch):
+        p = tmpdir.ensure("a", "test_x123.py")
+        p.pyimport()
+        tmpdir.join("a").move(tmpdir.join("b"))
+        with pytest.raises(tmpdir.ImportMismatchError):
+            tmpdir.join("b", "test_x123.py").pyimport()
+
+        # Errors can be ignored.
+        monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "1")
+        tmpdir.join("b", "test_x123.py").pyimport()
+
+        # PY_IGNORE_IMPORTMISMATCH=0 does not ignore error.
+        monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "0")
+        with pytest.raises(tmpdir.ImportMismatchError):
+            tmpdir.join("b", "test_x123.py").pyimport()
+
+    def test_pyimport_messy_name(self, tmpdir):
+        # http://bitbucket.org/hpk42/py-trunk/issue/129
+        path = tmpdir.ensure("foo__init__.py")
+        path.pyimport()
+
+    def test_pyimport_dir(self, tmpdir):
+        p = tmpdir.join("hello_123")
+        p_init = p.ensure("__init__.py")
+        m = p.pyimport()
+        assert m.__name__ == "hello_123"
+        m = p_init.pyimport()
+        assert m.__name__ == "hello_123"
+
+    def test_pyimport_execfile_different_name(self, path1):
+        obj = path1.join("execfile.py").pyimport(modname="0x.y.z")
+        assert obj.x == 42
+        assert obj.__name__ == "0x.y.z"
+
+    def test_pyimport_a(self, path1):
+        otherdir = path1.join("otherdir")
+        mod = otherdir.join("a.py").pyimport()
+        assert mod.result == "got it"
+        assert mod.__name__ == "otherdir.a"
+
+    def test_pyimport_b(self, path1):
+        otherdir = path1.join("otherdir")
+        mod = otherdir.join("b.py").pyimport()
+        assert mod.stuff == "got it"
+        assert mod.__name__ == "otherdir.b"
+
+    def test_pyimport_c(self, path1):
+        otherdir = path1.join("otherdir")
+        mod = otherdir.join("c.py").pyimport()
+        assert mod.value == "got it"
+
+    def test_pyimport_d(self, path1):
+        otherdir = path1.join("otherdir")
+        mod = otherdir.join("d.py").pyimport()
+        assert mod.value2 == "got it"
+
+    def test_pyimport_and_import(self, tmpdir):
+        tmpdir.ensure("xxxpackage", "__init__.py")
+        mod1path = tmpdir.ensure("xxxpackage", "module1.py")
+        mod1 = mod1path.pyimport()
+        assert mod1.__name__ == "xxxpackage.module1"
+        from xxxpackage import module1
+
+        assert module1 is mod1
+
+    def test_pyimport_check_filepath_consistency(self, monkeypatch, tmpdir):
+        name = "pointsback123"
+        ModuleType = type(os)
+        p = tmpdir.ensure(name + ".py")
+        for ending in (".pyc", "$py.class", ".pyo"):
+            mod = ModuleType(name)
+            pseudopath = tmpdir.ensure(name + ending)
+            mod.__file__ = str(pseudopath)
+            monkeypatch.setitem(sys.modules, name, mod)
+            newmod = p.pyimport()
+            assert mod == newmod
+        monkeypatch.undo()
+        mod = ModuleType(name)
+        pseudopath = tmpdir.ensure(name + "123.py")
+        mod.__file__ = str(pseudopath)
+        monkeypatch.setitem(sys.modules, name, mod)
+        excinfo = pytest.raises(pseudopath.ImportMismatchError, p.pyimport)
+        modname, modfile, orig = excinfo.value.args
+        assert modname == name
+        assert modfile == pseudopath
+        assert orig == p
+        assert issubclass(pseudopath.ImportMismatchError, ImportError)
+
+    def test_issue131_pyimport_on__init__(self, tmpdir):
+        # __init__.py files may be namespace packages, and thus the
+        # __file__ of an imported module may not be ourselves
+        # see issue
+        p1 = tmpdir.ensure("proja", "__init__.py")
+        p2 = tmpdir.ensure("sub", "proja", "__init__.py")
+        m1 = p1.pyimport()
+        m2 = p2.pyimport()
+        assert m1 == m2
+
+    def test_ensuresyspath_append(self, tmpdir):
+        root1 = tmpdir.mkdir("root1")
+        file1 = root1.ensure("x123.py")
+        assert str(root1) not in sys.path
+        file1.pyimport(ensuresyspath="append")
+        assert str(root1) == sys.path[-1]
+        assert str(root1) not in sys.path[:-1]
+
+
+class TestImportlibImport:
+    OPTS = {"ensuresyspath": "importlib"}
+
+    def test_pyimport(self, path1):
+        obj = path1.join("execfile.py").pyimport(**self.OPTS)
+        assert obj.x == 42
+        assert obj.__name__ == "execfile"
+
+    def test_pyimport_dir_fails(self, tmpdir):
+        p = tmpdir.join("hello_123")
+        p.ensure("__init__.py")
+        with pytest.raises(ImportError):
+            p.pyimport(**self.OPTS)
+
+    def test_pyimport_execfile_different_name(self, path1):
+        obj = path1.join("execfile.py").pyimport(modname="0x.y.z", **self.OPTS)
+        assert obj.x == 42
+        assert obj.__name__ == "0x.y.z"
+
+    def test_pyimport_relative_import_fails(self, path1):
+        otherdir = path1.join("otherdir")
+        with pytest.raises(ImportError):
+            otherdir.join("a.py").pyimport(**self.OPTS)
+
+    def test_pyimport_doesnt_use_sys_modules(self, tmpdir):
+        p = tmpdir.ensure("file738jsk.py")
+        mod = p.pyimport(**self.OPTS)
+        assert mod.__name__ == "file738jsk"
+        assert "file738jsk" not in sys.modules
+
+
+def test_pypkgdir(tmpdir):
+    pkg = tmpdir.ensure("pkg1", dir=1)
+    pkg.ensure("__init__.py")
+    pkg.ensure("subdir/__init__.py")
+    assert pkg.pypkgpath() == pkg
+    assert pkg.join("subdir", "__init__.py").pypkgpath() == pkg
+
+
+def test_pypkgdir_unimportable(tmpdir):
+    pkg = tmpdir.ensure("pkg1-1", dir=1)  # unimportable
+    pkg.ensure("__init__.py")
+    subdir = pkg.ensure("subdir/__init__.py").dirpath()
+    assert subdir.pypkgpath() == subdir
+    assert subdir.ensure("xyz.py").pypkgpath() == subdir
+    assert not pkg.pypkgpath()
+
+
+def test_isimportable():
+    try:
+        from py.path import isimportable  # py vendored version
+    except ImportError:
+        from py._path.local import isimportable  # py library
+
+    assert not isimportable("")
+    assert isimportable("x")
+    assert isimportable("x1")
+    assert isimportable("x_1")
+    assert isimportable("_")
+    assert isimportable("_1")
+    assert not isimportable("x-1")
+    assert not isimportable("x:1")
+
+
+def test_homedir_from_HOME(monkeypatch):
+    path = os.getcwd()
+    monkeypatch.setenv("HOME", path)
+    assert local._gethomedir() == local(path)
+
+
+def test_homedir_not_exists(monkeypatch):
+    monkeypatch.delenv("HOME", raising=False)
+    monkeypatch.delenv("HOMEDRIVE", raising=False)
+    homedir = local._gethomedir()
+    assert homedir is None
+
+
+def test_samefile(tmpdir):
+    assert tmpdir.samefile(tmpdir)
+    p = tmpdir.ensure("hello")
+    assert p.samefile(p)
+    with p.dirpath().as_cwd():
+        assert p.samefile(p.basename)
+    if sys.platform == "win32":
+        p1 = p.__class__(str(p).lower())
+        p2 = p.__class__(str(p).upper())
+        assert p1.samefile(p2)
+
+
+@pytest.mark.skipif(not hasattr(os, "symlink"), reason="os.symlink not available")
+def test_samefile_symlink(tmpdir):
+    p1 = tmpdir.ensure("foo.txt")
+    p2 = tmpdir.join("linked.txt")
+    try:
+        os.symlink(str(p1), str(p2))
+    except (OSError, NotImplementedError) as e:
+        # on Windows this might fail if the user doesn't have special symlink permissions
+        # pypy3 on Windows doesn't implement os.symlink and raises NotImplementedError
+        pytest.skip(str(e.args[0]))
+
+    assert p1.samefile(p2)
+
+
+def test_listdir_single_arg(tmpdir):
+    tmpdir.ensure("hello")
+    assert tmpdir.listdir("hello")[0].basename == "hello"
+
+
+def test_mkdtemp_rootdir(tmpdir):
+    dtmp = local.mkdtemp(rootdir=tmpdir)
+    assert tmpdir.listdir() == [dtmp]
+
+
+class TestWINLocalPath:
+    pytestmark = win32only
+
+    def test_owner_group_not_implemented(self, path1):
+        with pytest.raises(NotImplementedError):
+            path1.stat().owner
+        with pytest.raises(NotImplementedError):
+            path1.stat().group
+
+    def test_chmod_simple_int(self, path1):
+        mode = path1.stat().mode
+        # Ensure that we actually change the mode to something different.
+        path1.chmod(mode == 0 and 1 or 0)
+        try:
+            print(path1.stat().mode)
+            print(mode)
+            assert path1.stat().mode != mode
+        finally:
+            path1.chmod(mode)
+            assert path1.stat().mode == mode
+
+    def test_path_comparison_lowercase_mixed(self, path1):
+        t1 = path1.join("a_path")
+        t2 = path1.join("A_path")
+        assert t1 == t1
+        assert t1 == t2
+
+    def test_relto_with_mixed_case(self, path1):
+        t1 = path1.join("a_path", "fiLe")
+        t2 = path1.join("A_path")
+        assert t1.relto(t2) == "fiLe"
+
+    def test_allow_unix_style_paths(self, path1):
+        t1 = path1.join("a_path")
+        assert t1 == str(path1) + "\\a_path"
+        t1 = path1.join("a_path/")
+        assert t1 == str(path1) + "\\a_path"
+        t1 = path1.join("dir/a_path")
+        assert t1 == str(path1) + "\\dir\\a_path"
+
+    def test_sysfind_in_currentdir(self, path1):
+        cmd = local.sysfind("cmd")
+        root = cmd.new(dirname="", basename="")  # c:\ in most installations
+        with root.as_cwd():
+            x = local.sysfind(cmd.relto(root))
+            assert x.check(file=1)
+
+    def test_fnmatch_file_abspath_posix_pattern_on_win32(self, tmpdir):
+        # path-matching patterns might contain a posix path separator '/'
+        # Test that we can match that pattern on windows.
+        import posixpath
+
+        b = tmpdir.join("a", "b")
+        assert b.fnmatch(posixpath.sep.join("ab"))
+        pattern = posixpath.sep.join([str(tmpdir), "*", "b"])
+        assert b.fnmatch(pattern)
+
+
+class TestPOSIXLocalPath:
+    pytestmark = skiponwin32
+
+    def test_hardlink(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        filepath = tmpdir.join("file")
+        filepath.write_text("Hello", encoding="utf-8")
+        nlink = filepath.stat().nlink
+        linkpath.mklinkto(filepath)
+        assert filepath.stat().nlink == nlink + 1
+
+    def test_symlink_are_identical(self, tmpdir):
+        filepath = tmpdir.join("file")
+        filepath.write_text("Hello", encoding="utf-8")
+        linkpath = tmpdir.join("test")
+        linkpath.mksymlinkto(filepath)
+        assert linkpath.readlink() == str(filepath)
+
+    def test_symlink_isfile(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        filepath = tmpdir.join("file")
+        filepath.write_text("", encoding="utf-8")
+        linkpath.mksymlinkto(filepath)
+        assert linkpath.check(file=1)
+        assert not linkpath.check(link=0, file=1)
+        assert linkpath.islink()
+
+    def test_symlink_relative(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        filepath = tmpdir.join("file")
+        filepath.write_text("Hello", encoding="utf-8")
+        linkpath.mksymlinkto(filepath, absolute=False)
+        assert linkpath.readlink() == "file"
+        assert filepath.read_text(encoding="utf-8") == linkpath.read_text(
+            encoding="utf-8"
+        )
+
+    def test_symlink_not_existing(self, tmpdir):
+        linkpath = tmpdir.join("testnotexisting")
+        assert not linkpath.check(link=1)
+        assert linkpath.check(link=0)
+
+    def test_relto_with_root(self, path1, tmpdir):
+        y = path1.join("x").relto(local("/"))
+        assert y[0] == str(path1)[1]
+
+    def test_visit_recursive_symlink(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        linkpath.mksymlinkto(tmpdir)
+        visitor = tmpdir.visit(None, lambda x: x.check(link=0))
+        assert list(visitor) == [linkpath]
+
+    def test_symlink_isdir(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        linkpath.mksymlinkto(tmpdir)
+        assert linkpath.check(dir=1)
+        assert not linkpath.check(link=0, dir=1)
+
+    def test_symlink_remove(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        linkpath.mksymlinkto(linkpath)  # point to itself
+        assert linkpath.check(link=1)
+        linkpath.remove()
+        assert not linkpath.check()
+
+    def test_realpath_file(self, tmpdir):
+        linkpath = tmpdir.join("test")
+        filepath = tmpdir.join("file")
+        filepath.write_text("", encoding="utf-8")
+        linkpath.mksymlinkto(filepath)
+        realpath = linkpath.realpath()
+        assert realpath.basename == "file"
+
+    def test_owner(self, path1, tmpdir):
+        from pwd import getpwuid  # type:ignore[attr-defined]
+        from grp import getgrgid  # type:ignore[attr-defined]
+
+        stat = path1.stat()
+        assert stat.path == path1
+
+        uid = stat.uid
+        gid = stat.gid
+        owner = getpwuid(uid)[0]
+        group = getgrgid(gid)[0]
+
+        assert uid == stat.uid
+        assert owner == stat.owner
+        assert gid == stat.gid
+        assert group == stat.group
+
+    def test_stat_helpers(self, tmpdir, monkeypatch):
+        path1 = tmpdir.ensure("file")
+        stat1 = path1.stat()
+        stat2 = tmpdir.stat()
+        assert stat1.isfile()
+        assert stat2.isdir()
+        assert not stat1.islink()
+        assert not stat2.islink()
+
+    def test_stat_non_raising(self, tmpdir):
+        path1 = tmpdir.join("file")
+        pytest.raises(error.ENOENT, lambda: path1.stat())
+        res = path1.stat(raising=False)
+        assert res is None
+
+    def test_atime(self, tmpdir):
+        import time
+
+        path = tmpdir.ensure("samplefile")
+        now = time.time()
+        atime1 = path.atime()
+        # we could wait here but timer resolution is very
+        # system dependent
+        path.read_binary()
+        time.sleep(ATIME_RESOLUTION)
+        atime2 = path.atime()
+        time.sleep(ATIME_RESOLUTION)
+        duration = time.time() - now
+        assert (atime2 - atime1) <= duration
+
+    def test_commondir(self, path1):
+        # XXX This is here in local until we find a way to implement this
+        #     using the subversion command line api.
+        p1 = path1.join("something")
+        p2 = path1.join("otherthing")
+        assert p1.common(p2) == path1
+        assert p2.common(p1) == path1
+
+    def test_commondir_nocommon(self, path1):
+        # XXX This is here in local until we find a way to implement this
+        #     using the subversion command line api.
+        p1 = path1.join("something")
+        p2 = local(path1.sep + "blabla")
+        assert p1.common(p2) == "/"
+
+    def test_join_to_root(self, path1):
+        root = path1.parts()[0]
+        assert len(str(root)) == 1
+        assert str(root.join("a")) == "/a"
+
+    def test_join_root_to_root_with_no_abs(self, path1):
+        nroot = path1.join("/")
+        assert str(path1) == str(nroot)
+        assert path1 == nroot
+
+    def test_chmod_simple_int(self, path1):
+        mode = path1.stat().mode
+        path1.chmod(int(mode / 2))
+        try:
+            assert path1.stat().mode != mode
+        finally:
+            path1.chmod(mode)
+            assert path1.stat().mode == mode
+
+    def test_chmod_rec_int(self, path1):
+        # XXX fragile test
+        def recfilter(x):
+            return x.check(dotfile=0, link=0)
+
+        oldmodes = {}
+        for x in path1.visit(rec=recfilter):
+            oldmodes[x] = x.stat().mode
+        path1.chmod(int("772", 8), rec=recfilter)
+        try:
+            for x in path1.visit(rec=recfilter):
+                assert x.stat().mode & int("777", 8) == int("772", 8)
+        finally:
+            for x, y in oldmodes.items():
+                x.chmod(y)
+
+    def test_copy_archiving(self, tmpdir):
+        unicode_fn = "something-\342\200\223.txt"
+        f = tmpdir.ensure("a", unicode_fn)
+        a = f.dirpath()
+        oldmode = f.stat().mode
+        newmode = oldmode ^ 1
+        f.chmod(newmode)
+        b = tmpdir.join("b")
+        a.copy(b, mode=True)
+        assert b.join(f.basename).stat().mode == newmode
+
+    def test_copy_stat_file(self, tmpdir):
+        src = tmpdir.ensure("src")
+        dst = tmpdir.join("dst")
+        # a small delay before the copy
+        time.sleep(ATIME_RESOLUTION)
+        src.copy(dst, stat=True)
+        oldstat = src.stat()
+        newstat = dst.stat()
+        assert oldstat.mode == newstat.mode
+        assert (dst.atime() - src.atime()) < ATIME_RESOLUTION
+        assert (dst.mtime() - src.mtime()) < ATIME_RESOLUTION
+
+    def test_copy_stat_dir(self, tmpdir):
+        test_files = ["a", "b", "c"]
+        src = tmpdir.join("src")
+        for f in test_files:
+            src.join(f).write_text(f, ensure=True, encoding="utf-8")
+        dst = tmpdir.join("dst")
+        # a small delay before the copy
+        time.sleep(ATIME_RESOLUTION)
+        src.copy(dst, stat=True)
+        for f in test_files:
+            oldstat = src.join(f).stat()
+            newstat = dst.join(f).stat()
+            assert (newstat.atime - oldstat.atime) < ATIME_RESOLUTION
+            assert (newstat.mtime - oldstat.mtime) < ATIME_RESOLUTION
+            assert oldstat.mode == newstat.mode
+
+    def test_chown_identity(self, path1):
+        owner = path1.stat().owner
+        group = path1.stat().group
+        path1.chown(owner, group)
+
+    def test_chown_dangling_link(self, path1):
+        owner = path1.stat().owner
+        group = path1.stat().group
+        x = path1.join("hello")
+        x.mksymlinkto("qlwkejqwlek")
+        try:
+            path1.chown(owner, group, rec=1)
+        finally:
+            x.remove(rec=0)
+
+    def test_chown_identity_rec_mayfail(self, path1):
+        owner = path1.stat().owner
+        group = path1.stat().group
+        path1.chown(owner, group)
+
+
+class TestUnicodePy2Py3:
+    def test_join_ensure(self, tmpdir, monkeypatch):
+        if sys.version_info >= (3, 0) and "LANG" not in os.environ:
+            pytest.skip("cannot run test without locale")
+        x = local(tmpdir.strpath)
+        part = "hällo"
+        y = x.ensure(part)
+        assert x.join(part) == y
+
+    def test_listdir(self, tmpdir):
+        if sys.version_info >= (3, 0) and "LANG" not in os.environ:
+            pytest.skip("cannot run test without locale")
+        x = local(tmpdir.strpath)
+        part = "hällo"
+        y = x.ensure(part)
+        assert x.listdir(part)[0] == y
+
+    @pytest.mark.xfail(reason="changing read/write might break existing usages")
+    def test_read_write(self, tmpdir):
+        x = tmpdir.join("hello")
+        part = "hällo"
+        with ignore_encoding_warning():
+            x.write(part)
+            assert x.read() == part
+            x.write(part.encode(sys.getdefaultencoding()))
+            assert x.read() == part.encode(sys.getdefaultencoding())
+
+
+class TestBinaryAndTextMethods:
+    def test_read_binwrite(self, tmpdir):
+        x = tmpdir.join("hello")
+        part = "hällo"
+        part_utf8 = part.encode("utf8")
+        x.write_binary(part_utf8)
+        assert x.read_binary() == part_utf8
+        s = x.read_text(encoding="utf8")
+        assert s == part
+        assert isinstance(s, str)
+
+    def test_read_textwrite(self, tmpdir):
+        x = tmpdir.join("hello")
+        part = "hällo"
+        part_utf8 = part.encode("utf8")
+        x.write_text(part, encoding="utf8")
+        assert x.read_binary() == part_utf8
+        assert x.read_text(encoding="utf8") == part
+
+    def test_default_encoding(self, tmpdir):
+        x = tmpdir.join("hello")
+        # Can't use UTF8 as the default encoding (ASCII) doesn't support it
+        part = "hello"
+        x.write_text(part, "ascii")
+        s = x.read_text("ascii")
+        assert s == part
+        assert type(s) == type(part)
index b7ec18a9cb60fdf1cf253b7163d97dafd633f36d..ed750a97071ef961b728be1e3f72a5310e3990b8 100644 (file)
@@ -1,10 +1,8 @@
+import dataclasses
 import os
 import sys
 import types
 
-import attr
-import py
-
 import pytest
 from _pytest.compat import importlib_metadata
 from _pytest.config import ExitCode
@@ -116,11 +114,11 @@ class TestGeneralUsage:
 
         loaded = []
 
-        @attr.s
+        @dataclasses.dataclass
         class DummyEntryPoint:
-            name = attr.ib()
-            module = attr.ib()
-            group = "pytest11"
+            name: str
+            module: str
+            group: str = "pytest11"
 
             def load(self):
                 __import__(self.module)
@@ -133,10 +131,10 @@ class TestGeneralUsage:
             DummyEntryPoint("mycov", "mycov_module"),
         ]
 
-        @attr.s
+        @dataclasses.dataclass
         class DummyDist:
-            entry_points = attr.ib()
-            files = ()
+            entry_points: object
+            files: object = ()
 
         def my_dists():
             return (DummyDist(entry_points),)
@@ -187,8 +185,7 @@ class TestGeneralUsage:
         assert result.ret == ExitCode.USAGE_ERROR
         result.stderr.fnmatch_lines(
             [
-                f"ERROR: not found: {p2}",
-                "(no name {!r} in any of [[][]])".format(str(p2)),
+                f"ERROR: found no collectors for {p2}",
                 "",
             ]
         )
@@ -270,7 +267,7 @@ class TestGeneralUsage:
     def test_issue109_sibling_conftests_not_loaded(self, pytester: Pytester) -> None:
         sub1 = pytester.mkdir("sub1")
         sub2 = pytester.mkdir("sub2")
-        sub1.joinpath("conftest.py").write_text("assert 0")
+        sub1.joinpath("conftest.py").write_text("assert 0", encoding="utf-8")
         result = pytester.runpytest(sub2)
         assert result.ret == ExitCode.NO_TESTS_COLLECTED
         sub2.joinpath("__init__.py").touch()
@@ -304,9 +301,9 @@ class TestGeneralUsage:
             class MyCollector(pytest.File):
                 def collect(self):
                     return [MyItem.from_parent(name="xyz", parent=self)]
-            def pytest_collect_file(path, parent):
-                if path.basename.startswith("conftest"):
-                    return MyCollector.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.name.startswith("conftest"):
+                    return MyCollector.from_parent(path=file_path, parent=parent)
         """
         )
         result = pytester.runpytest(c.name + "::" + "xyz")
@@ -470,7 +467,7 @@ class TestGeneralUsage:
         assert "invalid" in str(excinfo.value)
 
         p = pytester.path.joinpath("test_test_plugins_given_as_strings.py")
-        p.write_text("def test_foo(): pass")
+        p.write_text("def test_foo(): pass", encoding="utf-8")
         mod = types.ModuleType("myplugin")
         monkeypatch.setitem(sys.modules, "myplugin", mod)
         assert pytest.main(args=[str(pytester.path)], plugins=["myplugin"]) == 0
@@ -515,28 +512,10 @@ class TestInvocationVariants:
         assert result.ret == 0
 
     def test_pydoc(self, pytester: Pytester) -> None:
-        for name in ("py.test", "pytest"):
-            result = pytester.runpython_c(f"import {name};help({name})")
-            assert result.ret == 0
-            s = result.stdout.str()
-            assert "MarkGenerator" in s
-
-    def test_import_star_py_dot_test(self, pytester: Pytester) -> None:
-        p = pytester.makepyfile(
-            """
-            from py.test import *
-            #collect
-            #cmdline
-            #Item
-            # assert collect.Item is Item
-            # assert collect.Collector is Collector
-            main
-            skip
-            xfail
-        """
-        )
-        result = pytester.runpython(p)
+        result = pytester.runpython_c("import pytest;help(pytest)")
         assert result.ret == 0
+        s = result.stdout.str()
+        assert "MarkGenerator" in s
 
     def test_import_star_pytest(self, pytester: Pytester) -> None:
         p = pytester.makepyfile(
@@ -585,10 +564,6 @@ class TestInvocationVariants:
         assert res.ret == 0
         res.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_equivalence_pytest_pydottest(self) -> None:
-        # Type ignored because `py.test` is not and will not be typed.
-        assert pytest.main == py.test.cmdline.main  # type: ignore[attr-defined]
-
     def test_invoke_with_invalid_type(self) -> None:
         with pytest.raises(
             TypeError, match="expected to be a list of strings, got: '-h'"
@@ -612,7 +587,7 @@ class TestInvocationVariants:
     def test_pyargs_importerror(self, pytester: Pytester, monkeypatch) -> None:
         monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", False)
         path = pytester.mkpydir("tpkg")
-        path.joinpath("test_hello.py").write_text("raise ImportError")
+        path.joinpath("test_hello.py").write_text("raise ImportError", encoding="utf-8")
 
         result = pytester.runpytest("--pyargs", "tpkg.test_hello", syspathinsert=True)
         assert result.ret != 0
@@ -622,10 +597,10 @@ class TestInvocationVariants:
     def test_pyargs_only_imported_once(self, pytester: Pytester) -> None:
         pkg = pytester.mkpydir("foo")
         pkg.joinpath("test_foo.py").write_text(
-            "print('hello from test_foo')\ndef test(): pass"
+            "print('hello from test_foo')\ndef test(): pass", encoding="utf-8"
         )
         pkg.joinpath("conftest.py").write_text(
-            "def pytest_configure(config): print('configuring')"
+            "def pytest_configure(config): print('configuring')", encoding="utf-8"
         )
 
         result = pytester.runpytest(
@@ -638,7 +613,7 @@ class TestInvocationVariants:
 
     def test_pyargs_filename_looks_like_module(self, pytester: Pytester) -> None:
         pytester.path.joinpath("conftest.py").touch()
-        pytester.path.joinpath("t.py").write_text("def test(): pass")
+        pytester.path.joinpath("t.py").write_text("def test(): pass", encoding="utf-8")
         result = pytester.runpytest("--pyargs", "t.py")
         assert result.ret == ExitCode.OK
 
@@ -647,8 +622,12 @@ class TestInvocationVariants:
 
         monkeypatch.delenv("PYTHONDONTWRITEBYTECODE", False)
         path = pytester.mkpydir("tpkg")
-        path.joinpath("test_hello.py").write_text("def test_hello(): pass")
-        path.joinpath("test_world.py").write_text("def test_world(): pass")
+        path.joinpath("test_hello.py").write_text(
+            "def test_hello(): pass", encoding="utf-8"
+        )
+        path.joinpath("test_world.py").write_text(
+            "def test_world(): pass", encoding="utf-8"
+        )
         result = pytester.runpytest("--pyargs", "tpkg")
         assert result.ret == 0
         result.stdout.fnmatch_lines(["*2 passed*"])
@@ -687,13 +666,15 @@ class TestInvocationVariants:
             ns = d.joinpath("ns_pkg")
             ns.mkdir()
             ns.joinpath("__init__.py").write_text(
-                "__import__('pkg_resources').declare_namespace(__name__)"
+                "__import__('pkg_resources').declare_namespace(__name__)",
+                encoding="utf-8",
             )
             lib = ns.joinpath(dirname)
             lib.mkdir()
             lib.joinpath("__init__.py").touch()
             lib.joinpath(f"test_{dirname}.py").write_text(
-                f"def test_{dirname}(): pass\ndef test_other():pass"
+                f"def test_{dirname}(): pass\ndef test_other():pass",
+                encoding="utf-8",
             )
 
         # The structure of the test directory is now:
@@ -718,7 +699,18 @@ class TestInvocationVariants:
 
         # mixed module and filenames:
         monkeypatch.chdir("world")
-        result = pytester.runpytest("--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world")
+
+        # pgk_resources.declare_namespace has been deprecated in favor of implicit namespace packages.
+        # pgk_resources has been deprecated entirely.
+        # While we could change the test to use implicit namespace packages, seems better
+        # to still ensure the old declaration via declare_namespace still works.
+        ignore_w = (
+            r"-Wignore:Deprecated call to `pkg_resources.declare_namespace",
+            r"-Wignore:pkg_resources is deprecated",
+        )
+        result = pytester.runpytest(
+            "--pyargs", "-v", "ns_pkg.hello", "ns_pkg/world", *ignore_w
+        )
         assert result.ret == 0
         result.stdout.fnmatch_lines(
             [
@@ -768,10 +760,10 @@ class TestInvocationVariants:
         lib.mkdir()
         lib.joinpath("__init__.py").touch()
         lib.joinpath("test_bar.py").write_text(
-            "def test_bar(): pass\ndef test_other(a_fixture):pass"
+            "def test_bar(): pass\ndef test_other(a_fixture):pass", encoding="utf-8"
         )
         lib.joinpath("conftest.py").write_text(
-            "import pytest\n@pytest.fixture\ndef a_fixture():pass"
+            "import pytest\n@pytest.fixture\ndef a_fixture():pass", encoding="utf-8"
         )
 
         d_local = pytester.mkdir("symlink_root")
@@ -896,7 +888,6 @@ class TestDurations:
         )
 
     def test_calls_show_2(self, pytester: Pytester, mock_timing) -> None:
-
         pytester.makepyfile(self.source)
         result = pytester.runpytest_inprocess("--durations=2")
         assert result.ret == 0
@@ -1061,14 +1052,14 @@ def test_fixture_values_leak(pytester: Pytester) -> None:
     """
     pytester.makepyfile(
         """
-        import attr
+        import dataclasses
         import gc
         import pytest
         import weakref
 
-        @attr.s
-        class SomeObj(object):
-            name = attr.ib()
+        @dataclasses.dataclass
+        class SomeObj:
+            name: str
 
         fix_of_test1_ref = None
         session_ref = None
@@ -1173,7 +1164,7 @@ def test_usage_error_code(pytester: Pytester) -> None:
     assert result.ret == ExitCode.USAGE_ERROR
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnhandledCoroutineWarning")
 def test_warn_on_async_function(pytester: Pytester) -> None:
     # In the below we .close() the coroutine only to avoid
     # "RuntimeWarning: coroutine 'test_2' was never awaited"
@@ -1206,7 +1197,7 @@ def test_warn_on_async_function(pytester: Pytester) -> None:
     )
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnhandledCoroutineWarning")
 def test_warn_on_async_gen_function(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_async="""
@@ -1261,8 +1252,6 @@ def test_pdb_can_be_rewritten(pytester: Pytester) -> None:
             "    def check():",
             ">       assert 1 == 2",
             "E       assert 1 == 2",
-            "E         +1",
-            "E         -2",
             "",
             "pdb.py:2: AssertionError",
             "*= 1 failed in *",
@@ -1293,8 +1282,7 @@ def test_tee_stdio_captures_and_live_prints(pytester: Pytester) -> None:
     result.stderr.fnmatch_lines(["*@this is stderr@*"])
 
     # now ensure the output is in the junitxml
-    with open(pytester.path.joinpath("output.xml")) as f:
-        fullXml = f.read()
+    fullXml = pytester.path.joinpath("output.xml").read_text(encoding="utf-8")
     assert "@this is stdout@\n" in fullXml
     assert "@this is stderr@\n" in fullXml
 
@@ -1304,7 +1292,7 @@ def test_tee_stdio_captures_and_live_prints(pytester: Pytester) -> None:
     reason="Windows raises `OSError: [Errno 22] Invalid argument` instead",
 )
 def test_no_brokenpipeerror_message(pytester: Pytester) -> None:
-    """Ensure that the broken pipe error message is supressed.
+    """Ensure that the broken pipe error message is suppressed.
 
     In some Python versions, it reaches sys.unraisablehook, in others
     a BrokenPipeError exception is propagated, but either way it prints
@@ -1318,3 +1306,49 @@ def test_no_brokenpipeerror_message(pytester: Pytester) -> None:
 
     # Cleanup.
     popen.stderr.close()
+
+
+def test_function_return_non_none_warning(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        def test_stuff():
+            return "something"
+    """
+    )
+    res = pytester.runpytest()
+    res.stdout.fnmatch_lines(["*Did you mean to use `assert` instead of `return`?*"])
+
+
+def test_doctest_and_normal_imports_with_importlib(pytester: Pytester) -> None:
+    """
+    Regression test for #10811: previously import_path with ImportMode.importlib would
+    not return a module if already in sys.modules, resulting in modules being imported
+    multiple times, which causes problems with modules that have import side effects.
+    """
+    # Uses the exact reproducer form #10811, given it is very minimal
+    # and illustrates the problem well.
+    pytester.makepyfile(
+        **{
+            "pmxbot/commands.py": "from . import logging",
+            "pmxbot/logging.py": "",
+            "tests/__init__.py": "",
+            "tests/test_commands.py": """
+                import importlib
+                from pmxbot import logging
+
+                class TestCommands:
+                    def test_boo(self):
+                        assert importlib.import_module('pmxbot.logging') is logging
+                """,
+        }
+    )
+    pytester.makeini(
+        """
+        [pytest]
+        addopts=
+            --doctest-modules
+            --import-mode importlib
+        """
+    )
+    result = pytester.runpytest_subprocess()
+    result.stdout.fnmatch_lines("*1 passed*")
index 5b9e3eda5296437cf617ca62bf9c4c54d637f76b..e5c030c4d66f825b0317dd00b1874a3dad7cd15c 100644 (file)
@@ -1,25 +1,28 @@
 import importlib
 import io
 import operator
-import os
 import queue
 import sys
 import textwrap
+from pathlib import Path
 from typing import Any
 from typing import Dict
 from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import Union
 
-import py
-
-import _pytest
+import _pytest._code
 import pytest
 from _pytest._code.code import ExceptionChainRepr
 from _pytest._code.code import ExceptionInfo
 from _pytest._code.code import FormattedExcinfo
 from _pytest._io import TerminalWriter
+from _pytest.monkeypatch import MonkeyPatch
+from _pytest.pathlib import bestrelpath
+from _pytest.pathlib import import_path
 from _pytest.pytester import LineMatcher
+from _pytest.pytester import Pytester
+
 
 if TYPE_CHECKING:
     from _pytest._code.code import _TracebackStyle
@@ -50,6 +53,20 @@ def test_excinfo_from_exc_info_simple() -> None:
     assert info.type == ValueError
 
 
+def test_excinfo_from_exception_simple() -> None:
+    try:
+        raise ValueError
+    except ValueError as e:
+        assert e.__traceback__ is not None
+        info = _pytest._code.ExceptionInfo.from_exception(e)
+    assert info.type == ValueError
+
+
+def test_excinfo_from_exception_missing_traceback_assertion() -> None:
+    with pytest.raises(AssertionError, match=r"must have.*__traceback__"):
+        _pytest._code.ExceptionInfo.from_exception(ValueError())
+
+
 def test_excinfo_getstatement():
     def g():
         raise ValueError
@@ -146,29 +163,30 @@ class TestTraceback_f_g_h:
             "    except somenoname:  # type: ignore[name-defined] # noqa: F821",
         ]
 
-    def test_traceback_cut(self):
+    def test_traceback_cut(self) -> None:
         co = _pytest._code.Code.from_function(f)
         path, firstlineno = co.path, co.firstlineno
+        assert isinstance(path, Path)
         traceback = self.excinfo.traceback
         newtraceback = traceback.cut(path=path, firstlineno=firstlineno)
         assert len(newtraceback) == 1
         newtraceback = traceback.cut(path=path, lineno=firstlineno + 2)
         assert len(newtraceback) == 1
 
-    def test_traceback_cut_excludepath(self, testdir):
-        p = testdir.makepyfile("def f(): raise ValueError")
+    def test_traceback_cut_excludepath(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile("def f(): raise ValueError")
         with pytest.raises(ValueError) as excinfo:
-            p.pyimport().f()
-        basedir = py.path.local(pytest.__file__).dirpath()
+            import_path(p, root=pytester.path).f()  # type: ignore[attr-defined]
+        basedir = Path(pytest.__file__).parent
         newtraceback = excinfo.traceback.cut(excludepath=basedir)
         for x in newtraceback:
-            if hasattr(x, "path"):
-                assert not py.path.local(x.path).relto(basedir)
+            assert isinstance(x.path, Path)
+            assert basedir not in x.path.parents
         assert newtraceback[-1].frame.code.path == p
 
     def test_traceback_filter(self):
         traceback = self.excinfo.traceback
-        ntraceback = traceback.filter()
+        ntraceback = traceback.filter(self.excinfo)
         assert len(ntraceback) == len(traceback) - 1
 
     @pytest.mark.parametrize(
@@ -199,7 +217,7 @@ class TestTraceback_f_g_h:
 
         excinfo = pytest.raises(ValueError, h)
         traceback = excinfo.traceback
-        ntraceback = traceback.filter()
+        ntraceback = traceback.filter(excinfo)
         print(f"old: {traceback!r}")
         print(f"new: {ntraceback!r}")
 
@@ -272,7 +290,7 @@ class TestTraceback_f_g_h:
         excinfo = pytest.raises(ValueError, fail)
         assert excinfo.traceback.recursionindex() is None
 
-    def test_traceback_getcrashentry(self):
+    def test_getreprcrash(self):
         def i():
             __tracebackhide__ = True
             raise ValueError
@@ -288,14 +306,13 @@ class TestTraceback_f_g_h:
             g()
 
         excinfo = pytest.raises(ValueError, f)
-        tb = excinfo.traceback
-        entry = tb.getcrashentry()
+        reprcrash = excinfo._getreprcrash()
+        assert reprcrash is not None
         co = _pytest._code.Code.from_function(h)
-        assert entry.frame.code.path == co.path
-        assert entry.lineno == co.firstlineno + 1
-        assert entry.frame.code.name == "h"
+        assert reprcrash.path == str(co.path)
+        assert reprcrash.lineno == co.firstlineno + 1 + 1
 
-    def test_traceback_getcrashentry_empty(self):
+    def test_getreprcrash_empty(self):
         def g():
             __tracebackhide__ = True
             raise ValueError
@@ -305,12 +322,7 @@ class TestTraceback_f_g_h:
             g()
 
         excinfo = pytest.raises(ValueError, f)
-        tb = excinfo.traceback
-        entry = tb.getcrashentry()
-        co = _pytest._code.Code.from_function(g)
-        assert entry.frame.code.path == co.path
-        assert entry.lineno == co.firstlineno + 2
-        assert entry.frame.code.name == "g"
+        assert excinfo._getreprcrash() is None
 
 
 def test_excinfo_exconly():
@@ -360,19 +372,19 @@ def test_excinfo_no_sourcecode():
     assert s == "  File '<string>':1 in <module>\n  ???\n"
 
 
-def test_excinfo_no_python_sourcecode(tmpdir):
+def test_excinfo_no_python_sourcecode(tmp_path: Path) -> None:
     # XXX: simplified locally testable version
-    tmpdir.join("test.txt").write("{{ h()}}:")
+    tmp_path.joinpath("test.txt").write_text("{{ h()}}:", encoding="utf-8")
 
     jinja2 = pytest.importorskip("jinja2")
-    loader = jinja2.FileSystemLoader(str(tmpdir))
+    loader = jinja2.FileSystemLoader(str(tmp_path))
     env = jinja2.Environment(loader=loader)
     template = env.get_template("test.txt")
     excinfo = pytest.raises(ValueError, template.render, h=h)
     for item in excinfo.traceback:
         print(item)  # XXX: for some reason jinja.Template.render is printed in full
         item.source  # shouldn't fail
-        if isinstance(item.path, py.path.local) and item.path.basename == "test.txt":
+        if isinstance(item.path, Path) and item.path.name == "test.txt":
             assert str(item.source) == "{{ h()}}:"
 
 
@@ -388,16 +400,16 @@ def test_entrysource_Queue_example():
     assert s.startswith("def get")
 
 
-def test_codepath_Queue_example():
+def test_codepath_Queue_example() -> None:
     try:
         queue.Queue().get(timeout=0.001)
     except queue.Empty:
         excinfo = _pytest._code.ExceptionInfo.from_current()
     entry = excinfo.traceback[-1]
     path = entry.path
-    assert isinstance(path, py.path.local)
-    assert path.basename.lower() == "queue.py"
-    assert path.check()
+    assert isinstance(path, Path)
+    assert path.name.lower() == "queue.py"
+    assert path.exists()
 
 
 def test_match_succeeds():
@@ -406,8 +418,8 @@ def test_match_succeeds():
     excinfo.match(r".*zero.*")
 
 
-def test_match_raises_error(testdir):
-    testdir.makepyfile(
+def test_match_raises_error(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
         def test_division_zero():
@@ -416,31 +428,32 @@ def test_match_raises_error(testdir):
             excinfo.match(r'[123]+')
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest("--tb=short")
     assert result.ret != 0
 
-    exc_msg = "Regex pattern '[[]123[]]+' does not match 'division by zero'."
-    result.stdout.fnmatch_lines([f"E * AssertionError: {exc_msg}"])
+    match = [
+        r"E .* AssertionError: Regex pattern did not match.",
+        r"E .* Regex: '\[123\]\+'",
+        r"E .* Input: 'division by zero'",
+    ]
+    result.stdout.re_match_lines(match)
     result.stdout.no_fnmatch_line("*__tracebackhide__ = True*")
 
-    result = testdir.runpytest("--fulltrace")
+    result = pytester.runpytest("--fulltrace")
     assert result.ret != 0
-    result.stdout.fnmatch_lines(
-        ["*__tracebackhide__ = True*", f"E * AssertionError: {exc_msg}"]
-    )
+    result.stdout.re_match_lines([r".*__tracebackhide__ = True.*", *match])
 
 
 class TestFormattedExcinfo:
     @pytest.fixture
-    def importasmod(self, request, _sys_snapshot):
+    def importasmod(self, tmp_path: Path, _sys_snapshot):
         def importasmod(source):
             source = textwrap.dedent(source)
-            tmpdir = request.getfixturevalue("tmpdir")
-            modpath = tmpdir.join("mod.py")
-            tmpdir.ensure("__init__.py")
-            modpath.write(source)
+            modpath = tmp_path.joinpath("mod.py")
+            tmp_path.joinpath("__init__.py").touch()
+            modpath.write_text(source, encoding="utf-8")
             importlib.invalidate_caches()
-            return modpath.pyimport()
+            return import_path(modpath, root=tmp_path)
 
         return importasmod
 
@@ -452,12 +465,30 @@ class TestFormattedExcinfo:
                 pass
             """
         ).strip()
-        pr.flow_marker = "|"
+        pr.flow_marker = "|"  # type: ignore[misc]
         lines = pr.get_source(source, 0)
         assert len(lines) == 2
         assert lines[0] == "|   def f(x):"
         assert lines[1] == "        pass"
 
+    def test_repr_source_out_of_bounds(self):
+        pr = FormattedExcinfo()
+        source = _pytest._code.Source(
+            """\
+            def f(x):
+                pass
+            """
+        ).strip()
+        pr.flow_marker = "|"  # type: ignore[misc]
+
+        lines = pr.get_source(source, 100)
+        assert len(lines) == 1
+        assert lines[0] == "|   ???"
+
+        lines = pr.get_source(source, -100)
+        assert len(lines) == 1
+        assert lines[0] == "|   ???"
+
     def test_repr_source_excinfo(self) -> None:
         """Check if indentation is right."""
         try:
@@ -593,7 +624,7 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.func1)
-        excinfo.traceback = excinfo.traceback.filter()
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
         p = FormattedExcinfo()
         reprtb = p.repr_traceback_entry(excinfo.traceback[-1])
 
@@ -626,7 +657,7 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.func1, "m" * 90, 5, 13, "z" * 120)
-        excinfo.traceback = excinfo.traceback.filter()
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
         entry = excinfo.traceback[-1]
         p = FormattedExcinfo(funcargs=True)
         reprfuncargs = p.repr_args(entry)
@@ -653,7 +684,7 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.func1, "a", "b", c="d")
-        excinfo.traceback = excinfo.traceback.filter()
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
         entry = excinfo.traceback[-1]
         p = FormattedExcinfo(funcargs=True)
         reprfuncargs = p.repr_args(entry)
@@ -682,7 +713,7 @@ raise ValueError()
         p = FormattedExcinfo(style="short")
         reprtb = p.repr_traceback_entry(excinfo.traceback[-2])
         lines = reprtb.lines
-        basename = py.path.local(mod.__file__).basename
+        basename = Path(mod.__file__).name
         assert lines[0] == "    func1()"
         assert reprtb.reprfileloc is not None
         assert basename in str(reprtb.reprfileloc.path)
@@ -802,21 +833,21 @@ raise ValueError()
 
         raised = 0
 
-        orig_getcwd = os.getcwd
+        orig_path_cwd = Path.cwd
 
         def raiseos():
             nonlocal raised
             upframe = sys._getframe().f_back
             assert upframe is not None
-            if upframe.f_code.co_name == "checked_call":
+            if upframe.f_code.co_name == "_makepath":
                 # Only raise with expected calls, but not via e.g. inspect for
                 # py38-windows.
                 raised += 1
                 raise OSError(2, "custom_oserror")
-            return orig_getcwd()
+            return orig_path_cwd()
 
-        monkeypatch.setattr(os, "getcwd", raiseos)
-        assert p._makepath(__file__) == __file__
+        monkeypatch.setattr(Path, "cwd", raiseos)
+        assert p._makepath(Path(__file__)) == __file__
         assert raised == 1
         repr_tb = p.repr_traceback(excinfo)
 
@@ -927,7 +958,7 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.f)
-        excinfo.traceback = excinfo.traceback.filter()
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
         repr = excinfo.getrepr()
         repr.toterminal(tw_mock)
         assert tw_mock.lines[0] == ""
@@ -948,7 +979,9 @@ raise ValueError()
         assert line.endswith("mod.py")
         assert tw_mock.lines[12] == ":3: ValueError"
 
-    def test_toterminal_long_missing_source(self, importasmod, tmpdir, tw_mock):
+    def test_toterminal_long_missing_source(
+        self, importasmod, tmp_path: Path, tw_mock
+    ) -> None:
         mod = importasmod(
             """
             def g(x):
@@ -958,8 +991,8 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.f)
-        tmpdir.join("mod.py").remove()
-        excinfo.traceback = excinfo.traceback.filter()
+        tmp_path.joinpath("mod.py").unlink()
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
         repr = excinfo.getrepr()
         repr.toterminal(tw_mock)
         assert tw_mock.lines[0] == ""
@@ -978,7 +1011,9 @@ raise ValueError()
         assert line.endswith("mod.py")
         assert tw_mock.lines[10] == ":3: ValueError"
 
-    def test_toterminal_long_incomplete_source(self, importasmod, tmpdir, tw_mock):
+    def test_toterminal_long_incomplete_source(
+        self, importasmod, tmp_path: Path, tw_mock
+    ) -> None:
         mod = importasmod(
             """
             def g(x):
@@ -988,8 +1023,8 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.f)
-        tmpdir.join("mod.py").write("asdf")
-        excinfo.traceback = excinfo.traceback.filter()
+        tmp_path.joinpath("mod.py").write_text("asdf", encoding="utf-8")
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
         repr = excinfo.getrepr()
         repr.toterminal(tw_mock)
         assert tw_mock.lines[0] == ""
@@ -1008,7 +1043,9 @@ raise ValueError()
         assert line.endswith("mod.py")
         assert tw_mock.lines[10] == ":3: ValueError"
 
-    def test_toterminal_long_filenames(self, importasmod, tw_mock):
+    def test_toterminal_long_filenames(
+        self, importasmod, tw_mock, monkeypatch: MonkeyPatch
+    ) -> None:
         mod = importasmod(
             """
             def f():
@@ -1016,25 +1053,22 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.f)
-        path = py.path.local(mod.__file__)
-        old = path.dirpath().chdir()
-        try:
-            repr = excinfo.getrepr(abspath=False)
-            repr.toterminal(tw_mock)
-            x = py.path.local().bestrelpath(path)
-            if len(x) < len(str(path)):
-                msg = tw_mock.get_write_msg(-2)
-                assert msg == "mod.py"
-                assert tw_mock.lines[-1] == ":3: ValueError"
-
-            repr = excinfo.getrepr(abspath=True)
-            repr.toterminal(tw_mock)
+        path = Path(mod.__file__)
+        monkeypatch.chdir(path.parent)
+        repr = excinfo.getrepr(abspath=False)
+        repr.toterminal(tw_mock)
+        x = bestrelpath(Path.cwd(), path)
+        if len(x) < len(str(path)):
             msg = tw_mock.get_write_msg(-2)
-            assert msg == path
-            line = tw_mock.lines[-1]
-            assert line == ":3: ValueError"
-        finally:
-            old.chdir()
+            assert msg == "mod.py"
+            assert tw_mock.lines[-1] == ":3: ValueError"
+
+        repr = excinfo.getrepr(abspath=True)
+        repr.toterminal(tw_mock)
+        msg = tw_mock.get_write_msg(-2)
+        assert msg == str(path)
+        line = tw_mock.lines[-1]
+        assert line == ":3: ValueError"
 
     @pytest.mark.parametrize(
         "reproptions",
@@ -1087,9 +1121,11 @@ raise ValueError()
         """
         )
         excinfo = pytest.raises(ValueError, mod.f)
-        excinfo.traceback = excinfo.traceback.filter()
-        excinfo.traceback[1].set_repr_style("short")
-        excinfo.traceback[2].set_repr_style("short")
+        excinfo.traceback = excinfo.traceback.filter(excinfo)
+        excinfo.traceback = _pytest._code.Traceback(
+            entry if i not in (1, 2) else entry.with_repr_style("short")
+            for i, entry in enumerate(excinfo.traceback)
+        )
         r = excinfo.getrepr(style="long")
         r.toterminal(tw_mock)
         for line in tw_mock.lines:
@@ -1355,7 +1391,7 @@ raise ValueError()
         with pytest.raises(TypeError) as excinfo:
             mod.f()
         # previously crashed with `AttributeError: list has no attribute get`
-        excinfo.traceback.filter()
+        excinfo.traceback.filter(excinfo)
 
 
 @pytest.mark.parametrize("style", ["short", "long"])
@@ -1374,16 +1410,41 @@ def test_repr_traceback_with_unicode(style, encoding):
     assert repr_traceback is not None
 
 
-def test_cwd_deleted(testdir):
-    testdir.makepyfile(
+def test_cwd_deleted(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
-        def test(tmpdir):
-            tmpdir.chdir()
-            tmpdir.remove()
+        import os
+
+        def test(tmp_path):
+            os.chdir(tmp_path)
+            tmp_path.unlink()
             assert False
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
+    result.stdout.fnmatch_lines(["* 1 failed in *"])
+    result.stdout.no_fnmatch_line("*INTERNALERROR*")
+    result.stderr.no_fnmatch_line("*INTERNALERROR*")
+
+
+def test_regression_nagative_line_index(pytester: Pytester) -> None:
+    """
+    With Python 3.10 alphas, there was an INTERNALERROR reported in
+    https://github.com/pytest-dev/pytest/pull/8227
+    This test ensures it does not regress.
+    """
+    pytester.makepyfile(
+        """
+        import ast
+        import pytest
+
+
+        def test_literal_eval():
+            with pytest.raises(ValueError, match="^$"):
+                ast.literal_eval("pytest")
+    """
+    )
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["* 1 failed in *"])
     result.stdout.no_fnmatch_line("*INTERNALERROR*")
     result.stderr.no_fnmatch_line("*INTERNALERROR*")
@@ -1437,3 +1498,153 @@ def test_no_recursion_index_on_recursion_error():
     with pytest.raises(RuntimeError) as excinfo:
         RecursionDepthError().trigger
     assert "maximum recursion" in str(excinfo.getrepr())
+
+
+def _exceptiongroup_common(
+    pytester: Pytester,
+    outer_chain: str,
+    inner_chain: str,
+    native: bool,
+) -> None:
+    pre_raise = "exceptiongroup." if not native else ""
+    pre_catch = pre_raise if sys.version_info < (3, 11) else ""
+    filestr = f"""
+    {"import exceptiongroup" if not native else ""}
+    import pytest
+
+    def f(): raise ValueError("From f()")
+    def g(): raise BaseException("From g()")
+
+    def inner(inner_chain):
+        excs = []
+        for callback in [f, g]:
+            try:
+                callback()
+            except BaseException as err:
+                excs.append(err)
+        if excs:
+            if inner_chain == "none":
+                raise {pre_raise}BaseExceptionGroup("Oops", excs)
+            try:
+                raise SyntaxError()
+            except SyntaxError as e:
+                if inner_chain == "from":
+                    raise {pre_raise}BaseExceptionGroup("Oops", excs) from e
+                else:
+                    raise {pre_raise}BaseExceptionGroup("Oops", excs)
+
+    def outer(outer_chain, inner_chain):
+        try:
+            inner(inner_chain)
+        except {pre_catch}BaseExceptionGroup as e:
+            if outer_chain == "none":
+                raise
+            if outer_chain == "from":
+                raise IndexError() from e
+            else:
+                raise IndexError()
+
+
+    def test():
+        outer("{outer_chain}", "{inner_chain}")
+    """
+    pytester.makepyfile(test_excgroup=filestr)
+    result = pytester.runpytest()
+    match_lines = []
+    if inner_chain in ("another", "from"):
+        match_lines.append(r"SyntaxError: <no detail available>")
+
+    match_lines += [
+        r"  + Exception Group Traceback (most recent call last):",
+        rf"  \| {pre_catch}BaseExceptionGroup: Oops \(2 sub-exceptions\)",
+        r"    \| ValueError: From f\(\)",
+        r"    \| BaseException: From g\(\)",
+        r"=* short test summary info =*",
+    ]
+    if outer_chain in ("another", "from"):
+        match_lines.append(r"FAILED test_excgroup.py::test - IndexError")
+    else:
+        match_lines.append(
+            rf"FAILED test_excgroup.py::test - {pre_catch}BaseExceptionGroup: Oops \(2.*"
+        )
+    result.stdout.re_match_lines(match_lines)
+
+
+@pytest.mark.skipif(
+    sys.version_info < (3, 11), reason="Native ExceptionGroup not implemented"
+)
+@pytest.mark.parametrize("outer_chain", ["none", "from", "another"])
+@pytest.mark.parametrize("inner_chain", ["none", "from", "another"])
+def test_native_exceptiongroup(pytester: Pytester, outer_chain, inner_chain) -> None:
+    _exceptiongroup_common(pytester, outer_chain, inner_chain, native=True)
+
+
+@pytest.mark.parametrize("outer_chain", ["none", "from", "another"])
+@pytest.mark.parametrize("inner_chain", ["none", "from", "another"])
+def test_exceptiongroup(pytester: Pytester, outer_chain, inner_chain) -> None:
+    # with py>=3.11 does not depend on exceptiongroup, though there is a toxenv for it
+    pytest.importorskip("exceptiongroup")
+    _exceptiongroup_common(pytester, outer_chain, inner_chain, native=False)
+
+
+@pytest.mark.parametrize("tbstyle", ("long", "short", "auto", "line", "native"))
+def test_all_entries_hidden(pytester: Pytester, tbstyle: str) -> None:
+    """Regression test for #10903."""
+    pytester.makepyfile(
+        """
+        def test():
+            __tracebackhide__ = True
+            1 / 0
+    """
+    )
+    result = pytester.runpytest("--tb", tbstyle)
+    assert result.ret == 1
+    if tbstyle != "line":
+        result.stdout.fnmatch_lines(["*ZeroDivisionError: division by zero"])
+    if tbstyle not in ("line", "native"):
+        result.stdout.fnmatch_lines(["All traceback entries are hidden.*"])
+
+
+def test_hidden_entries_of_chained_exceptions_are_not_shown(pytester: Pytester) -> None:
+    """Hidden entries of chained exceptions are not shown (#1904)."""
+    p = pytester.makepyfile(
+        """
+        def g1():
+            __tracebackhide__ = True
+            str.does_not_exist
+
+        def f3():
+            __tracebackhide__ = True
+            1 / 0
+
+        def f2():
+            try:
+                f3()
+            except Exception:
+                g1()
+
+        def f1():
+            __tracebackhide__ = True
+            f2()
+
+        def test():
+            f1()
+        """
+    )
+    result = pytester.runpytest(str(p), "--tb=short")
+    assert result.ret == 1
+    result.stdout.fnmatch_lines(
+        [
+            "*.py:11: in f2",
+            "    f3()",
+            "E   ZeroDivisionError: division by zero",
+            "",
+            "During handling of the above exception, another exception occurred:",
+            "*.py:20: in test",
+            "    f1()",
+            "*.py:13: in f2",
+            "    g1()",
+            "E   AttributeError:*'does_not_exist'",
+        ],
+        consecutive=True,
+    )
index 04d0ea9323d60119e4646cb6d2f18625f444fd02..dc35c9496ab660da0be4e1d6e8e801613bbf40de 100644 (file)
@@ -1,23 +1,20 @@
 # flake8: noqa
 # disable flake check on this file because some constructs are strange
 # or redundant on purpose and can't be disable on a line-by-line basis
-import ast
 import inspect
 import linecache
 import sys
 import textwrap
-from types import CodeType
+from pathlib import Path
 from typing import Any
 from typing import Dict
-from typing import Optional
-
-import py.path
 
 import pytest
 from _pytest._code import Code
 from _pytest._code import Frame
 from _pytest._code import getfslineno
 from _pytest._code import Source
+from _pytest.pathlib import import_path
 
 
 def test_source_str_function() -> None:
@@ -286,7 +283,7 @@ def test_deindent() -> None:
     assert lines == ["def f():", "    def g():", "        pass"]
 
 
-def test_source_of_class_at_eof_without_newline(tmpdir, _sys_snapshot) -> None:
+def test_source_of_class_at_eof_without_newline(_sys_snapshot, tmp_path: Path) -> None:
     # this test fails because the implicit inspect.getsource(A) below
     # does not return the "x = 1" last line.
     source = Source(
@@ -296,9 +293,10 @@ def test_source_of_class_at_eof_without_newline(tmpdir, _sys_snapshot) -> None:
                 x = 1
     """
     )
-    path = tmpdir.join("a.py")
-    path.write(source)
-    s2 = Source(tmpdir.join("a.py").pyimport().A)
+    path = tmp_path.joinpath("a.py")
+    path.write_text(str(source), encoding="utf-8")
+    mod: Any = import_path(path, root=tmp_path)
+    s2 = Source(mod.A)
     assert str(source).strip() == str(s2).strip()
 
 
@@ -331,8 +329,7 @@ def test_findsource(monkeypatch) -> None:
     lines = ["if 1:\n", "    def x():\n", "          pass\n"]
     co = compile("".join(lines), filename, "exec")
 
-    # Type ignored because linecache.cache is private.
-    monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename))  # type: ignore[attr-defined]
+    monkeypatch.setitem(linecache.cache, filename, (1, None, lines, filename))
 
     src, lineno = findsource(co)
     assert src is not None
@@ -352,8 +349,8 @@ def test_getfslineno() -> None:
 
     fspath, lineno = getfslineno(f)
 
-    assert isinstance(fspath, py.path.local)
-    assert fspath.basename == "test_source.py"
+    assert isinstance(fspath, Path)
+    assert fspath.name == "test_source.py"
     assert lineno == f.__code__.co_firstlineno - 1  # see findsource
 
     class A:
@@ -362,8 +359,8 @@ def test_getfslineno() -> None:
     fspath, lineno = getfslineno(A)
 
     _, A_lineno = inspect.findsource(A)
-    assert isinstance(fspath, py.path.local)
-    assert fspath.basename == "test_source.py"
+    assert isinstance(fspath, Path)
+    assert fspath.name == "test_source.py"
     assert lineno == A_lineno
 
     assert getfslineno(3) == ("", -1)
@@ -483,7 +480,7 @@ def test_source_with_decorator() -> None:
 
     src = inspect.getsource(deco_fixture)
     assert src == "    @pytest.fixture\n    def deco_fixture():\n        assert False\n"
-    # currenly Source does not unwrap decorators, testing the
+    # currently Source does not unwrap decorators, testing the
     # existing behavior here for explicitness, but perhaps we should revisit/change this
     # in the future
     assert str(Source(deco_fixture)).startswith("@functools.wraps(function)")
@@ -617,6 +614,19 @@ def something():
     assert str(source) == "def func(): raise ValueError(42)"
 
 
+def test_decorator() -> None:
+    s = """\
+def foo(f):
+    pass
+
+@foo
+def bar():
+    pass
+    """
+    source = getstatement(3, s)
+    assert "@foo" in str(source)
+
+
 def XXX_test_expression_multiline() -> None:
     source = """\
 something
index 2dc20bcb2fdd7b63ff21ffdb0a987c0766c350d0..2a3ce5203d9c18bf5a0a0dada38a42f371dc33c7 100644 (file)
@@ -1,3 +1,4 @@
+import dataclasses
 import re
 import sys
 from typing import List
@@ -20,6 +21,15 @@ if sys.gettrace():
             sys.settrace(orig_trace)
 
 
+@pytest.fixture(autouse=True)
+def set_column_width(monkeypatch: pytest.MonkeyPatch) -> None:
+    """
+    Force terminal width to 80: some tests check the formatting of --help, which is sensible
+    to terminal width.
+    """
+    monkeypatch.setenv("COLUMNS", "80")
+
+
 @pytest.hookimpl(hookwrapper=True, tryfirst=True)
 def pytest_collection_modifyitems(items):
     """Prefer faster tests.
@@ -104,7 +114,7 @@ def tw_mock():
 
 
 @pytest.fixture
-def dummy_yaml_custom_test(pytester: Pytester):
+def dummy_yaml_custom_test(pytester: Pytester) -> None:
     """Writes a conftest file that collects and executes a dummy yaml test.
 
     Taken from the docs, but stripped down to the bare minimum, useful for
@@ -114,13 +124,13 @@ def dummy_yaml_custom_test(pytester: Pytester):
         """
         import pytest
 
-        def pytest_collect_file(parent, path):
-            if path.ext == ".yaml" and path.basename.startswith("test"):
-                return YamlFile.from_parent(fspath=path, parent=parent)
+        def pytest_collect_file(parent, file_path):
+            if file_path.suffix == ".yaml" and file_path.name.startswith("test"):
+                return YamlFile.from_parent(path=file_path, parent=parent)
 
         class YamlFile(pytest.File):
             def collect(self):
-                yield YamlItem.from_parent(name=self.fspath.basename, parent=self)
+                yield YamlItem.from_parent(name=self.path.name, parent=self)
 
         class YamlItem(pytest.Item):
             def runtest(self):
@@ -157,6 +167,7 @@ def color_mapping():
             "number": "\x1b[94m",
             "str": "\x1b[33m",
             "print": "\x1b[96m",
+            "endline": "\x1b[90m\x1b[39;49;00m",
         }
         RE_COLORS = {k: re.escape(v) for k, v in COLORS.items()}
 
@@ -191,20 +202,18 @@ def mock_timing(monkeypatch: MonkeyPatch):
     Time is static, and only advances through `sleep` calls, thus tests might sleep over large
     numbers and obtain accurate time() calls at the end, making tests reliable and instant.
     """
-    import attr
 
-    @attr.s
+    @dataclasses.dataclass
     class MockTiming:
+        _current_time: float = 1590150050.0
 
-        _current_time = attr.ib(default=1590150050.0)
-
-        def sleep(self, seconds):
+        def sleep(self, seconds: float) -> None:
             self._current_time += seconds
 
-        def time(self):
+        def time(self) -> float:
             return self._current_time
 
-        def patch(self):
+        def patch(self) -> None:
             from _pytest import timing
 
             monkeypatch.setattr(timing, "sleep", self.sleep)
index d213414ee456a9d3bd1d0afeeab16f3108c07f23..3ceed7f5a2c18aabc25f0ec87c486e42c294001b 100644 (file)
@@ -1,80 +1,75 @@
 import re
+import sys
 import warnings
-from unittest import mock
+from pathlib import Path
 
 import pytest
 from _pytest import deprecated
+from _pytest.compat import legacy_path
 from _pytest.pytester import Pytester
-from _pytest.pytester import Testdir
-
-
-@pytest.mark.parametrize("attribute", pytest.collect.__all__)  # type: ignore
-# false positive due to dynamic attribute
-def test_pytest_collect_module_deprecated(attribute):
-    with pytest.warns(DeprecationWarning, match=attribute):
-        getattr(pytest.collect, attribute)
+from pytest import PytestDeprecationWarning
 
 
 @pytest.mark.parametrize("plugin", sorted(deprecated.DEPRECATED_EXTERNAL_PLUGINS))
 @pytest.mark.filterwarnings("default")
-def test_external_plugins_integrated(testdir, plugin):
-    testdir.syspathinsert()
-    testdir.makepyfile(**{plugin: ""})
+def test_external_plugins_integrated(pytester: Pytester, plugin) -> None:
+    pytester.syspathinsert()
+    pytester.makepyfile(**{plugin: ""})
 
     with pytest.warns(pytest.PytestConfigWarning):
-        testdir.parseconfig("-p", plugin)
+        pytester.parseconfig("-p", plugin)
 
 
-def test_fillfuncargs_is_deprecated() -> None:
-    with pytest.warns(
-        pytest.PytestDeprecationWarning,
-        match=re.escape(
-            "pytest._fillfuncargs() is deprecated, use "
-            "function._request._fillfixtures() instead if you cannot avoid reaching into internals."
-        ),
-    ):
-        pytest._fillfuncargs(mock.Mock())
+def test_hookspec_via_function_attributes_are_deprecated():
+    from _pytest.config import PytestPluginManager
+
+    pm = PytestPluginManager()
 
+    class DeprecatedHookMarkerSpec:
+        def pytest_bad_hook(self):
+            pass
 
-def test_fillfixtures_is_deprecated() -> None:
-    import _pytest.fixtures
+        pytest_bad_hook.historic = False  # type: ignore[attr-defined]
 
     with pytest.warns(
-        pytest.PytestDeprecationWarning,
-        match=re.escape(
-            "_pytest.fixtures.fillfixtures() is deprecated, use "
-            "function._request._fillfixtures() instead if you cannot avoid reaching into internals."
-        ),
-    ):
-        _pytest.fixtures.fillfixtures(mock.Mock())
+        PytestDeprecationWarning,
+        match=r"Please use the pytest\.hookspec\(historic=False\) decorator",
+    ) as recorder:
+        pm.add_hookspecs(DeprecatedHookMarkerSpec)
+    (record,) = recorder
+    assert (
+        record.lineno
+        == DeprecatedHookMarkerSpec.pytest_bad_hook.__code__.co_firstlineno
+    )
+    assert record.filename == __file__
 
 
-def test_minus_k_dash_is_deprecated(testdir) -> None:
-    threepass = testdir.makepyfile(
-        test_threepass="""
-        def test_one(): assert 1
-        def test_two(): assert 1
-        def test_three(): assert 1
-    """
-    )
-    result = testdir.runpytest("-k=-test_two", threepass)
-    result.stdout.fnmatch_lines(["*The `-k '-expr'` syntax*deprecated*"])
+def test_hookimpl_via_function_attributes_are_deprecated():
+    from _pytest.config import PytestPluginManager
+
+    pm = PytestPluginManager()
+
+    class DeprecatedMarkImplPlugin:
+        def pytest_runtest_call(self):
+            pass
 
+        pytest_runtest_call.tryfirst = True  # type: ignore[attr-defined]
 
-def test_minus_k_colon_is_deprecated(testdir) -> None:
-    threepass = testdir.makepyfile(
-        test_threepass="""
-        def test_one(): assert 1
-        def test_two(): assert 1
-        def test_three(): assert 1
-    """
+    with pytest.warns(
+        PytestDeprecationWarning,
+        match=r"Please use the pytest.hookimpl\(tryfirst=True\)",
+    ) as recorder:
+        pm.register(DeprecatedMarkImplPlugin())
+    (record,) = recorder
+    assert (
+        record.lineno
+        == DeprecatedMarkImplPlugin.pytest_runtest_call.__code__.co_firstlineno
     )
-    result = testdir.runpytest("-k", "test_two:", threepass)
-    result.stdout.fnmatch_lines(["*The `-k 'expr:'` syntax*deprecated*"])
+    assert record.filename == __file__
 
 
-def test_fscollector_gethookproxy_isinitpath(testdir: Testdir) -> None:
-    module = testdir.getmodulecol(
+def test_fscollector_gethookproxy_isinitpath(pytester: Pytester) -> None:
+    module = pytester.getmodulecol(
         """
         def test_foo(): pass
         """,
@@ -85,16 +80,16 @@ def test_fscollector_gethookproxy_isinitpath(testdir: Testdir) -> None:
     assert isinstance(package, pytest.Package)
 
     with pytest.warns(pytest.PytestDeprecationWarning, match="gethookproxy"):
-        package.gethookproxy(testdir.tmpdir)
+        package.gethookproxy(pytester.path)
 
     with pytest.warns(pytest.PytestDeprecationWarning, match="isinitpath"):
-        package.isinitpath(testdir.tmpdir)
+        package.isinitpath(pytester.path)
 
     # The methods on Session are *not* deprecated.
     session = module.session
     with warnings.catch_warnings(record=True) as rec:
-        session.gethookproxy(testdir.tmpdir)
-        session.isinitpath(testdir.tmpdir)
+        session.gethookproxy(pytester.path)
+        session.isinitpath(pytester.path)
     assert len(rec) == 0
 
 
@@ -112,7 +107,7 @@ def test_strict_option_is_deprecated(pytester: Pytester) -> None:
     result.stdout.fnmatch_lines(
         [
             "'unknown' not found in `markers` configuration option",
-            "*PytestDeprecationWarning: The --strict option is deprecated, use --strict-markers instead.",
+            "*PytestRemovedIn8Warning: The --strict option is deprecated, use --strict-markers instead.",
         ]
     )
 
@@ -137,3 +132,209 @@ def test_private_is_deprecated() -> None:
 
     # Doesn't warn.
     PrivateInit(10, _ispytest=True)
+
+
+@pytest.mark.parametrize("hooktype", ["hook", "ihook"])
+def test_hookproxy_warnings_for_pathlib(tmp_path, hooktype, request):
+    path = legacy_path(tmp_path)
+
+    PATH_WARN_MATCH = r".*path: py\.path\.local\) argument is deprecated, please use \(collection_path: pathlib\.Path.*"
+    if hooktype == "ihook":
+        hooks = request.node.ihook
+    else:
+        hooks = request.config.hook
+
+    with pytest.warns(PytestDeprecationWarning, match=PATH_WARN_MATCH) as r:
+        l1 = sys._getframe().f_lineno
+        hooks.pytest_ignore_collect(
+            config=request.config, path=path, collection_path=tmp_path
+        )
+        l2 = sys._getframe().f_lineno
+
+    (record,) = r
+    assert record.filename == __file__
+    assert l1 < record.lineno < l2
+
+    hooks.pytest_ignore_collect(config=request.config, collection_path=tmp_path)
+
+    # Passing entirely *different* paths is an outright error.
+    with pytest.raises(ValueError, match=r"path.*fspath.*need to be equal"):
+        with pytest.warns(PytestDeprecationWarning, match=PATH_WARN_MATCH) as r:
+            hooks.pytest_ignore_collect(
+                config=request.config, path=path, collection_path=Path("/bla/bla")
+            )
+
+
+def test_warns_none_is_deprecated():
+    with pytest.warns(
+        PytestDeprecationWarning,
+        match=re.escape(
+            "Passing None has been deprecated.\n"
+            "See https://docs.pytest.org/en/latest/how-to/capture-warnings.html"
+            "#additional-use-cases-of-warnings-in-tests"
+            " for alternatives in common use cases."
+        ),
+    ):
+        with pytest.warns(None):  # type: ignore[call-overload]
+            pass
+
+
+class TestSkipMsgArgumentDeprecated:
+    def test_skip_with_msg_is_deprecated(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
+            """
+            import pytest
+
+            def test_skipping_msg():
+                pytest.skip(msg="skippedmsg")
+            """
+        )
+        result = pytester.runpytest(p)
+        result.stdout.fnmatch_lines(
+            [
+                "*PytestRemovedIn8Warning: pytest.skip(msg=...) is now deprecated, "
+                "use pytest.skip(reason=...) instead",
+                '*pytest.skip(msg="skippedmsg")*',
+            ]
+        )
+        result.assert_outcomes(skipped=1, warnings=1)
+
+    def test_fail_with_msg_is_deprecated(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
+            """
+            import pytest
+
+            def test_failing_msg():
+                pytest.fail(msg="failedmsg")
+            """
+        )
+        result = pytester.runpytest(p)
+        result.stdout.fnmatch_lines(
+            [
+                "*PytestRemovedIn8Warning: pytest.fail(msg=...) is now deprecated, "
+                "use pytest.fail(reason=...) instead",
+                '*pytest.fail(msg="failedmsg")',
+            ]
+        )
+        result.assert_outcomes(failed=1, warnings=1)
+
+    def test_exit_with_msg_is_deprecated(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
+            """
+            import pytest
+
+            def test_exit_msg():
+                pytest.exit(msg="exitmsg")
+            """
+        )
+        result = pytester.runpytest(p)
+        result.stdout.fnmatch_lines(
+            [
+                "*PytestRemovedIn8Warning: pytest.exit(msg=...) is now deprecated, "
+                "use pytest.exit(reason=...) instead",
+            ]
+        )
+        result.assert_outcomes(warnings=1)
+
+
+def test_deprecation_of_cmdline_preparse(pytester: Pytester) -> None:
+    pytester.makeconftest(
+        """
+        def pytest_cmdline_preparse(config, args):
+            ...
+
+        """
+    )
+    result = pytester.runpytest()
+    result.stdout.fnmatch_lines(
+        [
+            "*PytestRemovedIn8Warning: The pytest_cmdline_preparse hook is deprecated*",
+            "*Please use pytest_load_initial_conftests hook instead.*",
+        ]
+    )
+
+
+def test_node_ctor_fspath_argument_is_deprecated(pytester: Pytester) -> None:
+    mod = pytester.getmodulecol("")
+
+    with pytest.warns(
+        pytest.PytestDeprecationWarning,
+        match=re.escape("The (fspath: py.path.local) argument to File is deprecated."),
+    ):
+        pytest.File.from_parent(
+            parent=mod.parent,
+            fspath=legacy_path("bla"),
+        )
+
+
+def test_importing_instance_is_deprecated(pytester: Pytester) -> None:
+    with pytest.warns(
+        pytest.PytestDeprecationWarning,
+        match=re.escape("The pytest.Instance collector type is deprecated"),
+    ):
+        pytest.Instance
+
+    with pytest.warns(
+        pytest.PytestDeprecationWarning,
+        match=re.escape("The pytest.Instance collector type is deprecated"),
+    ):
+        from _pytest.python import Instance  # noqa: F401
+
+
+@pytest.mark.filterwarnings("default")
+def test_nose_deprecated_with_setup(pytester: Pytester) -> None:
+    pytest.importorskip("nose")
+    pytester.makepyfile(
+        """
+        from nose.tools import with_setup
+
+        def setup_fn_no_op():
+            ...
+
+        def teardown_fn_no_op():
+            ...
+
+        @with_setup(setup_fn_no_op, teardown_fn_no_op)
+        def test_omits_warnings():
+            ...
+        """
+    )
+    output = pytester.runpytest()
+    message = [
+        "*PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.",
+        "*test_nose_deprecated_with_setup.py::test_omits_warnings is using nose method: `setup_fn_no_op` (setup)",
+        "*PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.",
+        "*test_nose_deprecated_with_setup.py::test_omits_warnings is using nose method: `teardown_fn_no_op` (teardown)",
+    ]
+    output.stdout.fnmatch_lines(message)
+    output.assert_outcomes(passed=1)
+
+
+@pytest.mark.filterwarnings("default")
+def test_nose_deprecated_setup_teardown(pytester: Pytester) -> None:
+    pytest.importorskip("nose")
+    pytester.makepyfile(
+        """
+        class Test:
+
+            def setup(self):
+                ...
+
+            def teardown(self):
+                ...
+
+            def test(self):
+                ...
+        """
+    )
+    output = pytester.runpytest()
+    message = [
+        "*PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.",
+        "*test_nose_deprecated_setup_teardown.py::Test::test is using nose-specific method: `setup(self)`",
+        "*To remove this warning, rename it to `setup_method(self)`",
+        "*PytestRemovedIn8Warning: Support for nose tests is deprecated and will be removed in a future release.",
+        "*test_nose_deprecated_setup_teardown.py::Test::test is using nose-specific method: `teardown(self)`",
+        "*To remove this warning, rename it to `teardown_method(self)`",
+    ]
+    output.stdout.fnmatch_lines(message)
+    output.assert_outcomes(passed=1)
diff --git a/testing/example_scripts/__init__.py b/testing/example_scripts/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 9629fa646af6af1d38f1dbd9c90ee3d4c316e763..973ccc0c030032465d1d959627830a37ff0b944e 100644 (file)
@@ -1,2 +1,2 @@
-def pytest_ignore_collect(path):
+def pytest_ignore_collect(collection_path):
     return False
diff --git a/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py b/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py
new file mode 100644 (file)
index 0000000..e026fe3
--- /dev/null
@@ -0,0 +1,17 @@
+from dataclasses import dataclass
+from dataclasses import field
+
+
+def test_dataclasses() -> None:
+    @dataclass
+    class SimpleDataObject:
+        field_a: int = field()
+        field_b: str = field()
+
+        def __eq__(self, __o: object) -> bool:
+            return super().__eq__(__o)
+
+    left = SimpleDataObject(1, "b")
+    right = SimpleDataObject(1, "c")
+
+    assert left == right
diff --git a/testing/example_scripts/dataclasses/test_compare_initvar.py b/testing/example_scripts/dataclasses/test_compare_initvar.py
new file mode 100644 (file)
index 0000000..d859634
--- /dev/null
@@ -0,0 +1,12 @@
+from dataclasses import dataclass
+from dataclasses import InitVar
+
+
+@dataclass
+class Foo:
+    init_only: InitVar[int]
+    real_attr: int
+
+
+def test_demonstrate():
+    assert Foo(1, 2) == Foo(1, 3)
index 167140e16a6637b0f72b02bd7771548b72cf74dd..0945790f004201a514da57a064ef69c2b45de86d 100644 (file)
@@ -29,10 +29,16 @@ class C3:
 
 def test_recursive_dataclasses():
     left = C3(
-        S(10, "ten"), C2(C(S(1, "one"), S(2, "two")), S(2, "three")), "equal", "left",
+        S(10, "ten"),
+        C2(C(S(1, "one"), S(2, "two")), S(2, "three")),
+        "equal",
+        "left",
     )
     right = C3(
-        S(20, "xxx"), C2(C(S(1, "one"), S(2, "yyy")), S(3, "three")), "equal", "right",
+        S(20, "xxx"),
+        C2(C(S(1, "one"), S(2, "yyy")), S(3, "three")),
+        "equal",
+        "right",
     )
 
     assert left == right
diff --git a/testing/example_scripts/doctest/main_py/__main__.py b/testing/example_scripts/doctest/main_py/__main__.py
new file mode 100644 (file)
index 0000000..e471d06
--- /dev/null
@@ -0,0 +1,2 @@
+def test_this_is_ignored():
+    assert True
diff --git a/testing/example_scripts/doctest/main_py/test_normal_module.py b/testing/example_scripts/doctest/main_py/test_normal_module.py
new file mode 100644 (file)
index 0000000..700cc97
--- /dev/null
@@ -0,0 +1,6 @@
+def test_doc():
+    """
+    >>> 10 > 5
+    True
+    """
+    assert False
index 161934b58f7c1472bf59a0ac5c87867facc9a02e..a7a5e9db80a34a63bea27558cd4e89d94250893c 100644 (file)
@@ -11,5 +11,5 @@ class CustomFile(pytest.File):
         yield CustomItem.from_parent(name="foo", parent=self)
 
 
-def pytest_collect_file(path, parent):
-    return CustomFile.from_parent(fspath=path, parent=parent)
+def pytest_collect_file(file_path, parent):
+    return CustomFile.from_parent(path=file_path, parent=parent)
index a053a638a9f7e6e829634e1a1971f9da703d243b..cb8f5d671ea8599f258a6029fa466af869954948 100644 (file)
@@ -6,8 +6,8 @@ class MyFile(pytest.File):
         return [MyItem.from_parent(name="hello", parent=self)]
 
 
-def pytest_collect_file(path, parent):
-    return MyFile.from_parent(fspath=path, parent=parent)
+def pytest_collect_file(file_path, parent):
+    return MyFile.from_parent(path=file_path, parent=parent)
 
 
 class MyItem(pytest.Item):
index 3928294886f36733ec28fe7eb96bf7bf7f2ab8ba..e44367fca04687d38b1ae0f601b706ab7490ed9c 100644 (file)
@@ -20,12 +20,12 @@ def checked_order():
     yield order
     pprint.pprint(order)
     assert order == [
-        ("testing/example_scripts/issue_519.py", "fix1", "arg1v1"),
+        ("issue_519.py", "fix1", "arg1v1"),
         ("test_one[arg1v1-arg2v1]", "fix2", "arg2v1"),
         ("test_two[arg1v1-arg2v1]", "fix2", "arg2v1"),
         ("test_one[arg1v1-arg2v2]", "fix2", "arg2v2"),
         ("test_two[arg1v1-arg2v2]", "fix2", "arg2v2"),
-        ("testing/example_scripts/issue_519.py", "fix1", "arg1v2"),
+        ("issue_519.py", "fix1", "arg1v2"),
         ("test_one[arg1v2-arg2v1]", "fix2", "arg2v1"),
         ("test_two[arg1v2-arg2v1]", "fix2", "arg2v1"),
         ("test_one[arg1v2-arg2v2]", "fix2", "arg2v2"),
diff --git a/testing/example_scripts/tmpdir/tmp_path_fixture.py b/testing/example_scripts/tmpdir/tmp_path_fixture.py
new file mode 100644 (file)
index 0000000..8675eb2
--- /dev/null
@@ -0,0 +1,7 @@
+import pytest
+
+
+@pytest.mark.parametrize("a", [r"qwe/\abc"])
+def test_fixture(tmp_path, a):
+    assert tmp_path.is_dir()
+    assert list(tmp_path.iterdir()) == []
diff --git a/testing/example_scripts/tmpdir/tmpdir_fixture.py b/testing/example_scripts/tmpdir/tmpdir_fixture.py
deleted file mode 100644 (file)
index f4ad074..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-import pytest
-
-
-@pytest.mark.parametrize("a", [r"qwe/\abc"])
-def test_fixture(tmpdir, a):
-    tmpdir.check(dir=1)
-    assert tmpdir.listdir() == []
index bbc752de5c14a2f2092629a740bbc62c0a385175..1cd2168604c495539376fc2f2031d97c7e729543 100644 (file)
@@ -1,5 +1,5 @@
 from typing import List
-from unittest import IsolatedAsyncioTestCase  # type: ignore
+from unittest import IsolatedAsyncioTestCase
 
 
 teardowns: List[None] = []
index e83f18fdc93a3efa7e4761d92d44674b91c6c500..7b9c109889ed7c557518b53af26435da5c05afeb 100644 (file)
@@ -1,3 +1,7 @@
-def test_510(testdir):
-    testdir.copy_example("issue_519.py")
-    testdir.runpytest("issue_519.py")
+from _pytest.pytester import Pytester
+
+
+def test_519(pytester: Pytester) -> None:
+    pytester.copy_example("issue_519.py")
+    res = pytester.runpytest("issue_519.py")
+    res.assert_outcomes(passed=8)
index 7a97cf424c578cc8a5c925ae33ad2eddec0a6b10..24746bc22355f4b1a3cc9ced1f6382f1799258a9 100644 (file)
@@ -1,6 +1,8 @@
 import pytest
 from _pytest._io.saferepr import _pformat_dispatch
+from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
 from _pytest._io.saferepr import saferepr
+from _pytest._io.saferepr import saferepr_unlimited
 
 
 def test_simple_repr():
@@ -15,6 +17,13 @@ def test_maxsize():
     assert s == expected
 
 
+def test_no_maxsize():
+    text = "x" * DEFAULT_REPR_MAX_SIZE * 10
+    s = saferepr(text, maxsize=None)
+    expected = repr(text)
+    assert s == expected
+
+
 def test_maxsize_error_on_instance():
     class A:
         def __repr__(self):
@@ -171,3 +180,23 @@ def test_broken_getattribute():
     assert saferepr(SomeClass()).startswith(
         "<[RuntimeError() raised in repr()] SomeClass object at 0x"
     )
+
+
+def test_saferepr_unlimited():
+    dict5 = {f"v{i}": i for i in range(5)}
+    assert saferepr_unlimited(dict5) == "{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4}"
+
+    dict_long = {f"v{i}": i for i in range(1_000)}
+    r = saferepr_unlimited(dict_long)
+    assert "..." not in r
+    assert "\n" not in r
+
+
+def test_saferepr_unlimited_exc():
+    class A:
+        def __repr__(self):
+            raise ValueError(42)
+
+    assert saferepr_unlimited(A()).startswith(
+        "<[ValueError(42) raised in repr()] A object at 0x"
+    )
index db0ccf06a4042dffbd1ede67736a2e0f7a45622e..b5a04a99f183e9622ab9c1a1f3f2c123caeaecad 100644 (file)
@@ -3,6 +3,7 @@ import os
 import re
 import shutil
 import sys
+from pathlib import Path
 from typing import Generator
 from unittest import mock
 
@@ -55,7 +56,7 @@ def test_terminalwriter_not_unicode() -> None:
     file = io.TextIOWrapper(buffer, encoding="cp1252")
     tw = terminalwriter.TerminalWriter(file)
     tw.write("hello 🌀 wôrld אבג", flush=True)
-    assert buffer.getvalue() == br"hello \U0001f300 w\xf4rld \u05d0\u05d1\u05d2"
+    assert buffer.getvalue() == rb"hello \U0001f300 w\xf4rld \u05d0\u05d1\u05d2"
 
 
 win32 = int(sys.platform == "win32")
@@ -64,10 +65,10 @@ win32 = int(sys.platform == "win32")
 class TestTerminalWriter:
     @pytest.fixture(params=["path", "stringio"])
     def tw(
-        self, request, tmpdir
+        self, request, tmp_path: Path
     ) -> Generator[terminalwriter.TerminalWriter, None, None]:
         if request.param == "path":
-            p = tmpdir.join("tmpfile")
+            p = tmp_path.joinpath("tmpfile")
             f = open(str(p), "w+", encoding="utf8")
             tw = terminalwriter.TerminalWriter(f)
 
@@ -253,17 +254,26 @@ class TestTerminalWriterLineWidth:
         pytest.param(
             True,
             True,
-            "{kw}assert{hl-reset} {number}0{hl-reset}\n",
+            "{kw}assert{hl-reset} {number}0{hl-reset}{endline}\n",
             id="with markup and code_highlight",
         ),
         pytest.param(
-            True, False, "assert 0\n", id="with markup but no code_highlight",
+            True,
+            False,
+            "assert 0\n",
+            id="with markup but no code_highlight",
         ),
         pytest.param(
-            False, True, "assert 0\n", id="without markup but with code_highlight",
+            False,
+            True,
+            "assert 0\n",
+            id="without markup but with code_highlight",
         ),
         pytest.param(
-            False, False, "assert 0\n", id="neither markup nor code_highlight",
+            False,
+            False,
+            "assert 0\n",
+            id="neither markup nor code_highlight",
         ),
     ],
 )
index ffd51bcad7a089955253b7e628d3ebda8147366d..753cf5fcd032b894d764ca02bb7f597df16f1b94 100644 (file)
@@ -1,19 +1,35 @@
+# mypy: disable-error-code="attr-defined"
+# mypy: disallow-untyped-defs
 import logging
+from typing import Iterator
 
 import pytest
 from _pytest.logging import caplog_records_key
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
 
 logger = logging.getLogger(__name__)
 sublogger = logging.getLogger(__name__ + ".baz")
 
 
-def test_fixture_help(testdir):
-    result = testdir.runpytest("--fixtures")
+@pytest.fixture(autouse=True)
+def cleanup_disabled_logging() -> Iterator[None]:
+    """Simple fixture that ensures that a test doesn't disable logging.
+
+    This is necessary because ``logging.disable()`` is global, so a test disabling logging
+    and not cleaning up after will break every test that runs after it.
+
+    This behavior was moved to a fixture so that logging will be un-disabled even if the test fails an assertion.
+    """
+    yield
+    logging.disable(logging.NOTSET)
+
+
+def test_fixture_help(pytester: Pytester) -> None:
+    result = pytester.runpytest("--fixtures")
     result.stdout.fnmatch_lines(["*caplog*"])
 
 
-def test_change_level(caplog):
+def test_change_level(caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.INFO)
     logger.debug("handler DEBUG level")
     logger.info("handler INFO level")
@@ -28,12 +44,29 @@ def test_change_level(caplog):
     assert "CRITICAL" in caplog.text
 
 
-def test_change_level_undo(testdir: Testdir) -> None:
+def test_change_level_logging_disabled(caplog: pytest.LogCaptureFixture) -> None:
+    logging.disable(logging.CRITICAL)
+    assert logging.root.manager.disable == logging.CRITICAL
+    caplog.set_level(logging.WARNING)
+    logger.info("handler INFO level")
+    logger.warning("handler WARNING level")
+
+    caplog.set_level(logging.CRITICAL, logger=sublogger.name)
+    sublogger.warning("logger SUB_WARNING level")
+    sublogger.critical("logger SUB_CRITICAL level")
+
+    assert "INFO" not in caplog.text
+    assert "WARNING" in caplog.text
+    assert "SUB_WARNING" not in caplog.text
+    assert "SUB_CRITICAL" in caplog.text
+
+
+def test_change_level_undo(pytester: Pytester) -> None:
     """Ensure that 'set_level' is undone after the end of the test.
 
-    Tests the logging output themselves (affacted both by logger and handler levels).
+    Tests the logging output themselves (affected both by logger and handler levels).
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -49,17 +82,46 @@ def test_change_level_undo(testdir: Testdir) -> None:
             assert 0
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*log from test1*", "*2 failed in *"])
     result.stdout.no_fnmatch_line("*log from test2*")
 
 
-def test_change_level_undos_handler_level(testdir: Testdir) -> None:
+def test_change_disabled_level_undo(pytester: Pytester) -> None:
+    """Ensure that '_force_enable_logging' in 'set_level' is undone after the end of the test.
+
+    Tests the logging output themselves (affected by disabled logging level).
+    """
+    pytester.makepyfile(
+        """
+        import logging
+
+        def test1(caplog):
+            logging.disable(logging.CRITICAL)
+            caplog.set_level(logging.INFO)
+            # using + operator here so fnmatch_lines doesn't match the code in the traceback
+            logging.info('log from ' + 'test1')
+            assert 0
+
+        def test2(caplog):
+            # using + operator here so fnmatch_lines doesn't match the code in the traceback
+            # use logging.warning because we need a level that will show up if logging.disabled
+            # isn't reset to ``CRITICAL`` after test1.
+            logging.warning('log from ' + 'test2')
+            assert 0
+    """
+    )
+    result = pytester.runpytest()
+    result.stdout.fnmatch_lines(["*log from test1*", "*2 failed in *"])
+    result.stdout.no_fnmatch_line("*log from test2*")
+
+
+def test_change_level_undos_handler_level(pytester: Pytester) -> None:
     """Ensure that 'set_level' is undone after the end of the test (handler).
 
     Issue #7569. Tests the handler level specifically.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -78,11 +140,11 @@ def test_change_level_undos_handler_level(testdir: Testdir) -> None:
             assert caplog.handler.level == 43
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(passed=3)
 
 
-def test_with_statement(caplog):
+def test_with_statement(caplog: pytest.LogCaptureFixture) -> None:
     with caplog.at_level(logging.INFO):
         logger.debug("handler DEBUG level")
         logger.info("handler INFO level")
@@ -97,7 +159,66 @@ def test_with_statement(caplog):
     assert "CRITICAL" in caplog.text
 
 
-def test_log_access(caplog):
+def test_with_statement_logging_disabled(caplog: pytest.LogCaptureFixture) -> None:
+    logging.disable(logging.CRITICAL)
+    assert logging.root.manager.disable == logging.CRITICAL
+    with caplog.at_level(logging.WARNING):
+        logger.debug("handler DEBUG level")
+        logger.info("handler INFO level")
+        logger.warning("handler WARNING level")
+        logger.error("handler ERROR level")
+        logger.critical("handler CRITICAL level")
+
+        assert logging.root.manager.disable == logging.INFO
+
+        with caplog.at_level(logging.CRITICAL, logger=sublogger.name):
+            sublogger.warning("logger SUB_WARNING level")
+            sublogger.critical("logger SUB_CRITICAL level")
+
+    assert "DEBUG" not in caplog.text
+    assert "INFO" not in caplog.text
+    assert "WARNING" in caplog.text
+    assert "ERROR" in caplog.text
+    assert " CRITICAL" in caplog.text
+    assert "SUB_WARNING" not in caplog.text
+    assert "SUB_CRITICAL" in caplog.text
+    assert logging.root.manager.disable == logging.CRITICAL
+
+
+@pytest.mark.parametrize(
+    "level_str,expected_disable_level",
+    [
+        ("CRITICAL", logging.ERROR),
+        ("ERROR", logging.WARNING),
+        ("WARNING", logging.INFO),
+        ("INFO", logging.DEBUG),
+        ("DEBUG", logging.NOTSET),
+        ("NOTSET", logging.NOTSET),
+        ("NOTVALIDLEVEL", logging.NOTSET),
+    ],
+)
+def test_force_enable_logging_level_string(
+    caplog: pytest.LogCaptureFixture, level_str: str, expected_disable_level: int
+) -> None:
+    """Test _force_enable_logging using a level string.
+
+    ``expected_disable_level`` is one level below ``level_str`` because the disabled log level
+    always needs to be *at least* one level lower than the level that caplog is trying to capture.
+    """
+    test_logger = logging.getLogger("test_str_level_force_enable")
+    # Emulate a testing environment where all logging is disabled.
+    logging.disable(logging.CRITICAL)
+    # Make sure all logging is disabled.
+    assert not test_logger.isEnabledFor(logging.CRITICAL)
+    # Un-disable logging for `level_str`.
+    caplog._force_enable_logging(level_str, test_logger)
+    # Make sure that the disabled level is now one below the requested logging level.
+    # We don't use `isEnabledFor` here because that also checks the level set by
+    # `logging.setLevel()` which is irrelevant to `logging.disable()`.
+    assert test_logger.manager.disable == expected_disable_level
+
+
+def test_log_access(caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.INFO)
     logger.info("boo %s", "arg")
     assert caplog.records[0].levelname == "INFO"
@@ -105,7 +226,7 @@ def test_log_access(caplog):
     assert "boo arg" in caplog.text
 
 
-def test_messages(caplog):
+def test_messages(caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.INFO)
     logger.info("boo %s", "arg")
     logger.info("bar %s\nbaz %s", "arg1", "arg2")
@@ -126,14 +247,14 @@ def test_messages(caplog):
     assert "Exception" not in caplog.messages[-1]
 
 
-def test_record_tuples(caplog):
+def test_record_tuples(caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.INFO)
     logger.info("boo %s", "arg")
 
     assert caplog.record_tuples == [(__name__, logging.INFO, "boo arg")]
 
 
-def test_unicode(caplog):
+def test_unicode(caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.INFO)
     logger.info("bū")
     assert caplog.records[0].levelname == "INFO"
@@ -141,7 +262,7 @@ def test_unicode(caplog):
     assert "bū" in caplog.text
 
 
-def test_clear(caplog):
+def test_clear(caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.INFO)
     logger.info("bū")
     assert len(caplog.records)
@@ -152,7 +273,9 @@ def test_clear(caplog):
 
 
 @pytest.fixture
-def logging_during_setup_and_teardown(caplog):
+def logging_during_setup_and_teardown(
+    caplog: pytest.LogCaptureFixture,
+) -> Iterator[None]:
     caplog.set_level("INFO")
     logger.info("a_setup_log")
     yield
@@ -160,7 +283,9 @@ def logging_during_setup_and_teardown(caplog):
     assert [x.message for x in caplog.get_records("teardown")] == ["a_teardown_log"]
 
 
-def test_caplog_captures_for_all_stages(caplog, logging_during_setup_and_teardown):
+def test_caplog_captures_for_all_stages(
+    caplog: pytest.LogCaptureFixture, logging_during_setup_and_teardown: None
+) -> None:
     assert not caplog.records
     assert not caplog.get_records("call")
     logger.info("a_call_log")
@@ -169,11 +294,35 @@ def test_caplog_captures_for_all_stages(caplog, logging_during_setup_and_teardow
     assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
 
     # This reaches into private API, don't use this type of thing in real tests!
-    assert set(caplog._item._store[caplog_records_key]) == {"setup", "call"}
+    caplog_records = caplog._item.stash[caplog_records_key]
+    assert set(caplog_records) == {"setup", "call"}
+
+
+def test_clear_for_call_stage(
+    caplog: pytest.LogCaptureFixture, logging_during_setup_and_teardown: None
+) -> None:
+    logger.info("a_call_log")
+    assert [x.message for x in caplog.get_records("call")] == ["a_call_log"]
+    assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
+    caplog_records = caplog._item.stash[caplog_records_key]
+    assert set(caplog_records) == {"setup", "call"}
+
+    caplog.clear()
+
+    assert caplog.get_records("call") == []
+    assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
+    caplog_records = caplog._item.stash[caplog_records_key]
+    assert set(caplog_records) == {"setup", "call"}
+
+    logging.info("a_call_log_after_clear")
+    assert [x.message for x in caplog.get_records("call")] == ["a_call_log_after_clear"]
+    assert [x.message for x in caplog.get_records("setup")] == ["a_setup_log"]
+    caplog_records = caplog._item.stash[caplog_records_key]
+    assert set(caplog_records) == {"setup", "call"}
 
 
-def test_ini_controls_global_log_level(testdir):
-    testdir.makepyfile(
+def test_ini_controls_global_log_level(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -187,20 +336,20 @@ def test_ini_controls_global_log_level(testdir):
             assert 'ERROR' in caplog.text
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_level=ERROR
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     # make sure that that we get a '0' exit code for the testsuite
     assert result.ret == 0
 
 
-def test_caplog_can_override_global_log_level(testdir):
-    testdir.makepyfile(
+def test_caplog_can_override_global_log_level(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -227,19 +376,19 @@ def test_caplog_can_override_global_log_level(testdir):
             assert "message won't be shown" not in caplog.text
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_level=WARNING
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 0
 
 
-def test_caplog_captures_despite_exception(testdir):
-    testdir.makepyfile(
+def test_caplog_captures_despite_exception(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -255,26 +404,28 @@ def test_caplog_captures_despite_exception(testdir):
                 raise Exception()
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_level=WARNING
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*ERROR message will be shown*"])
     result.stdout.no_fnmatch_line("*DEBUG message won't be shown*")
     assert result.ret == 1
 
 
-def test_log_report_captures_according_to_config_option_upon_failure(testdir):
+def test_log_report_captures_according_to_config_option_upon_failure(
+    pytester: Pytester,
+) -> None:
     """Test that upon failure:
     (1) `caplog` succeeded to capture the DEBUG message and assert on it => No `Exception` is raised.
     (2) The `DEBUG` message does NOT appear in the `Captured log call` report.
     (3) The stdout, `INFO`, and `WARNING` messages DO appear in the test reports due to `--log-level=INFO`.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -299,7 +450,7 @@ def test_log_report_captures_according_to_config_option_upon_failure(testdir):
     """
     )
 
-    result = testdir.runpytest("--log-level=INFO")
+    result = pytester.runpytest("--log-level=INFO")
     result.stdout.no_fnmatch_line("*Exception: caplog failed to capture DEBUG*")
     result.stdout.no_fnmatch_line("*DEBUG log message*")
     result.stdout.fnmatch_lines(
index 335166caa2fb8bf7ef55ff8016ed6d28cfe4b088..37971293726fce9bfdca075bd7f70e53ec907074 100644 (file)
@@ -18,9 +18,32 @@ def test_coloredlogformatter() -> None:
         exc_info=None,
     )
 
-    class ColorConfig:
-        class option:
-            pass
+    tw = TerminalWriter()
+    tw.hasmarkup = True
+    formatter = ColoredLevelFormatter(tw, logfmt)
+    output = formatter.format(record)
+    assert output == (
+        "dummypath                   10 \x1b[32mINFO    \x1b[0m Test Message"
+    )
+
+    tw.hasmarkup = False
+    formatter = ColoredLevelFormatter(tw, logfmt)
+    output = formatter.format(record)
+    assert output == ("dummypath                   10 INFO     Test Message")
+
+
+def test_coloredlogformatter_with_width_precision() -> None:
+    logfmt = "%(filename)-25s %(lineno)4d %(levelname)-8.8s %(message)s"
+
+    record = logging.LogRecord(
+        name="dummy",
+        level=logging.INFO,
+        pathname="dummypath",
+        lineno=10,
+        msg="Test Message",
+        args=(),
+        exc_info=None,
+    )
 
     tw = TerminalWriter()
     tw.hasmarkup = True
index fc9f1082346d15aecf11df85ebeab3889cced768..0c8e3fd08a9ec613b1fea419ebd1ce200d360d37 100644 (file)
@@ -6,12 +6,13 @@ from typing import cast
 import pytest
 from _pytest.capture import CaptureManager
 from _pytest.config import ExitCode
-from _pytest.pytester import Testdir
+from _pytest.fixtures import FixtureRequest
+from _pytest.pytester import Pytester
 from _pytest.terminal import TerminalReporter
 
 
-def test_nothing_logged(testdir):
-    testdir.makepyfile(
+def test_nothing_logged(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import sys
 
@@ -21,7 +22,7 @@ def test_nothing_logged(testdir):
             assert False
         """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 1
     result.stdout.fnmatch_lines(["*- Captured stdout call -*", "text going to stdout"])
     result.stdout.fnmatch_lines(["*- Captured stderr call -*", "text going to stderr"])
@@ -29,8 +30,8 @@ def test_nothing_logged(testdir):
         result.stdout.fnmatch_lines(["*- Captured *log call -*"])
 
 
-def test_messages_logged(testdir):
-    testdir.makepyfile(
+def test_messages_logged(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import sys
         import logging
@@ -44,15 +45,15 @@ def test_messages_logged(testdir):
             assert False
         """
     )
-    result = testdir.runpytest("--log-level=INFO")
+    result = pytester.runpytest("--log-level=INFO")
     assert result.ret == 1
     result.stdout.fnmatch_lines(["*- Captured *log call -*", "*text going to logger*"])
     result.stdout.fnmatch_lines(["*- Captured stdout call -*", "text going to stdout"])
     result.stdout.fnmatch_lines(["*- Captured stderr call -*", "text going to stderr"])
 
 
-def test_root_logger_affected(testdir):
-    testdir.makepyfile(
+def test_root_logger_affected(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import logging
         logger = logging.getLogger()
@@ -65,8 +66,8 @@ def test_root_logger_affected(testdir):
             assert 0
     """
     )
-    log_file = testdir.tmpdir.join("pytest.log").strpath
-    result = testdir.runpytest("--log-level=ERROR", "--log-file=pytest.log")
+    log_file = str(pytester.path.joinpath("pytest.log"))
+    result = pytester.runpytest("--log-level=ERROR", "--log-file=pytest.log")
     assert result.ret == 1
 
     # The capture log calls in the stdout section only contain the
@@ -80,15 +81,15 @@ def test_root_logger_affected(testdir):
     # not the info one, because the default level of the root logger is
     # WARNING.
     assert os.path.isfile(log_file)
-    with open(log_file) as rfh:
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert "info text going to logger" not in contents
         assert "warning text going to logger" in contents
         assert "error text going to logger" in contents
 
 
-def test_log_cli_level_log_level_interaction(testdir):
-    testdir.makepyfile(
+def test_log_cli_level_log_level_interaction(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import logging
         logger = logging.getLogger()
@@ -102,7 +103,7 @@ def test_log_cli_level_log_level_interaction(testdir):
     """
     )
 
-    result = testdir.runpytest("--log-cli-level=INFO", "--log-level=ERROR")
+    result = pytester.runpytest("--log-cli-level=INFO", "--log-level=ERROR")
     assert result.ret == 1
 
     result.stdout.fnmatch_lines(
@@ -117,8 +118,8 @@ def test_log_cli_level_log_level_interaction(testdir):
     result.stdout.no_re_match_line("DEBUG")
 
 
-def test_setup_logging(testdir):
-    testdir.makepyfile(
+def test_setup_logging(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import logging
 
@@ -132,7 +133,7 @@ def test_setup_logging(testdir):
             assert False
     """
     )
-    result = testdir.runpytest("--log-level=INFO")
+    result = pytester.runpytest("--log-level=INFO")
     assert result.ret == 1
     result.stdout.fnmatch_lines(
         [
@@ -144,8 +145,8 @@ def test_setup_logging(testdir):
     )
 
 
-def test_teardown_logging(testdir):
-    testdir.makepyfile(
+def test_teardown_logging(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import logging
 
@@ -159,7 +160,7 @@ def test_teardown_logging(testdir):
             assert False
         """
     )
-    result = testdir.runpytest("--log-level=INFO")
+    result = pytester.runpytest("--log-level=INFO")
     assert result.ret == 1
     result.stdout.fnmatch_lines(
         [
@@ -172,9 +173,9 @@ def test_teardown_logging(testdir):
 
 
 @pytest.mark.parametrize("enabled", [True, False])
-def test_log_cli_enabled_disabled(testdir, enabled):
+def test_log_cli_enabled_disabled(pytester: Pytester, enabled: bool) -> None:
     msg = "critical message logged by test"
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
         def test_log_cli():
@@ -184,13 +185,13 @@ def test_log_cli_enabled_disabled(testdir, enabled):
         )
     )
     if enabled:
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             log_cli=true
         """
         )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     if enabled:
         result.stdout.fnmatch_lines(
             [
@@ -204,9 +205,9 @@ def test_log_cli_enabled_disabled(testdir, enabled):
         assert msg not in result.stdout.str()
 
 
-def test_log_cli_default_level(testdir):
+def test_log_cli_default_level(pytester: Pytester) -> None:
     # Default log file level
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -217,14 +218,14 @@ def test_log_cli_default_level(testdir):
             logging.getLogger('catchlog').warning("WARNING message will be shown")
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(
@@ -234,14 +235,16 @@ def test_log_cli_default_level(testdir):
         ]
     )
     result.stdout.no_fnmatch_line("*INFO message won't be shown*")
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
 
 
-def test_log_cli_default_level_multiple_tests(testdir, request):
+def test_log_cli_default_level_multiple_tests(
+    pytester: Pytester, request: FixtureRequest
+) -> None:
     """Ensure we reset the first newline added by the live logger between tests"""
     filename = request.node.name + ".py"
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -252,14 +255,14 @@ def test_log_cli_default_level_multiple_tests(testdir, request):
             logging.warning("log message from test_log_2")
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             f"{filename}::test_log_1 ",
@@ -273,11 +276,13 @@ def test_log_cli_default_level_multiple_tests(testdir, request):
     )
 
 
-def test_log_cli_default_level_sections(testdir, request):
+def test_log_cli_default_level_sections(
+    pytester: Pytester, request: FixtureRequest
+) -> None:
     """Check that with live logging enable we are printing the correct headers during
     start/setup/call/teardown/finish."""
     filename = request.node.name + ".py"
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import pytest
         import logging
@@ -290,7 +295,7 @@ def test_log_cli_default_level_sections(testdir, request):
     """
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -308,14 +313,14 @@ def test_log_cli_default_level_sections(testdir, request):
             logging.warning("log message from test_log_2")
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             f"{filename}::test_log_1 ",
@@ -347,11 +352,13 @@ def test_log_cli_default_level_sections(testdir, request):
     )
 
 
-def test_live_logs_unknown_sections(testdir, request):
+def test_live_logs_unknown_sections(
+    pytester: Pytester, request: FixtureRequest
+) -> None:
     """Check that with live logging enable we are printing the correct headers during
     start/setup/call/teardown/finish."""
     filename = request.node.name + ".py"
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import pytest
         import logging
@@ -367,7 +374,7 @@ def test_live_logs_unknown_sections(testdir, request):
     """
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -383,14 +390,14 @@ def test_live_logs_unknown_sections(testdir, request):
 
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*WARNING*Unknown Section*",
@@ -409,11 +416,13 @@ def test_live_logs_unknown_sections(testdir, request):
     )
 
 
-def test_sections_single_new_line_after_test_outcome(testdir, request):
+def test_sections_single_new_line_after_test_outcome(
+    pytester: Pytester, request: FixtureRequest
+) -> None:
     """Check that only a single new line is written between log messages during
     teardown/finish."""
     filename = request.node.name + ".py"
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import pytest
         import logging
@@ -427,7 +436,7 @@ def test_sections_single_new_line_after_test_outcome(testdir, request):
     """
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -443,14 +452,14 @@ def test_sections_single_new_line_after_test_outcome(testdir, request):
             logging.warning("log message from test_log_1")
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             f"{filename}::test_log_1 ",
@@ -487,9 +496,9 @@ def test_sections_single_new_line_after_test_outcome(testdir, request):
     )
 
 
-def test_log_cli_level(testdir):
+def test_log_cli_level(pytester: Pytester) -> None:
     # Default log file level
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -501,14 +510,14 @@ def test_log_cli_level(testdir):
             print('PASSED')
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
     """
     )
 
-    result = testdir.runpytest("-s", "--log-cli-level=INFO")
+    result = pytester.runpytest("-s", "--log-cli-level=INFO")
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(
@@ -519,10 +528,10 @@ def test_log_cli_level(testdir):
     )
     result.stdout.no_fnmatch_line("*This log message won't be shown*")
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
 
-    result = testdir.runpytest("-s", "--log-level=INFO")
+    result = pytester.runpytest("-s", "--log-level=INFO")
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(
@@ -533,19 +542,19 @@ def test_log_cli_level(testdir):
     )
     result.stdout.no_fnmatch_line("*This log message won't be shown*")
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
 
 
-def test_log_cli_ini_level(testdir):
-    testdir.makeini(
+def test_log_cli_ini_level(pytester: Pytester) -> None:
+    pytester.makeini(
         """
         [pytest]
         log_cli=true
         log_cli_level = INFO
         """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -558,7 +567,7 @@ def test_log_cli_ini_level(testdir):
     """
     )
 
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(
@@ -569,7 +578,7 @@ def test_log_cli_ini_level(testdir):
     )
     result.stdout.no_fnmatch_line("*This log message won't be shown*")
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
 
 
@@ -577,11 +586,11 @@ def test_log_cli_ini_level(testdir):
     "cli_args",
     ["", "--log-level=WARNING", "--log-file-level=WARNING", "--log-cli-level=WARNING"],
 )
-def test_log_cli_auto_enable(testdir, cli_args):
+def test_log_cli_auto_enable(pytester: Pytester, cli_args: str) -> None:
     """Check that live logs are enabled if --log-level or --log-cli-level is passed on the CLI.
     It should not be auto enabled if the same configs are set on the INI file.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -591,7 +600,7 @@ def test_log_cli_auto_enable(testdir, cli_args):
 
     """
     )
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_level=INFO
@@ -599,7 +608,7 @@ def test_log_cli_auto_enable(testdir, cli_args):
     """
     )
 
-    result = testdir.runpytest(cli_args)
+    result = pytester.runpytest(cli_args)
     stdout = result.stdout.str()
     if cli_args == "--log-cli-level=WARNING":
         result.stdout.fnmatch_lines(
@@ -620,9 +629,9 @@ def test_log_cli_auto_enable(testdir, cli_args):
         assert "WARNING" not in stdout
 
 
-def test_log_file_cli(testdir):
+def test_log_file_cli(pytester: Pytester) -> None:
     # Default log file level
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -635,27 +644,27 @@ def test_log_file_cli(testdir):
     """
     )
 
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    result = testdir.runpytest(
+    result = pytester.runpytest(
         "-s", f"--log-file={log_file}", "--log-file-level=WARNING"
     )
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(["test_log_file_cli.py PASSED"])
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
     assert os.path.isfile(log_file)
-    with open(log_file) as rfh:
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert "This log message will be shown" in contents
         assert "This log message won't be shown" not in contents
 
 
-def test_log_file_cli_level(testdir):
+def test_log_file_cli_level(pytester: Pytester) -> None:
     # Default log file level
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -668,38 +677,38 @@ def test_log_file_cli_level(testdir):
     """
     )
 
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    result = testdir.runpytest("-s", f"--log-file={log_file}", "--log-file-level=INFO")
+    result = pytester.runpytest("-s", f"--log-file={log_file}", "--log-file-level=INFO")
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(["test_log_file_cli_level.py PASSED"])
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
     assert os.path.isfile(log_file)
-    with open(log_file) as rfh:
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert "This log message will be shown" in contents
         assert "This log message won't be shown" not in contents
 
 
-def test_log_level_not_changed_by_default(testdir):
-    testdir.makepyfile(
+def test_log_level_not_changed_by_default(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import logging
         def test_log_file():
             assert logging.getLogger().level == logging.WARNING
     """
     )
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
     result.stdout.fnmatch_lines(["* 1 passed in *"])
 
 
-def test_log_file_ini(testdir):
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+def test_log_file_ini(pytester: Pytester) -> None:
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file={}
@@ -708,7 +717,7 @@ def test_log_file_ini(testdir):
             log_file
         )
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -721,24 +730,24 @@ def test_log_file_ini(testdir):
     """
     )
 
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(["test_log_file_ini.py PASSED"])
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
     assert os.path.isfile(log_file)
-    with open(log_file) as rfh:
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert "This log message will be shown" in contents
         assert "This log message won't be shown" not in contents
 
 
-def test_log_file_ini_level(testdir):
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+def test_log_file_ini_level(pytester: Pytester) -> None:
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file={}
@@ -747,7 +756,7 @@ def test_log_file_ini_level(testdir):
             log_file
         )
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -760,24 +769,24 @@ def test_log_file_ini_level(testdir):
     """
     )
 
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
 
     # fnmatch_lines does an assertion internally
     result.stdout.fnmatch_lines(["test_log_file_ini_level.py PASSED"])
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
     assert os.path.isfile(log_file)
-    with open(log_file) as rfh:
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert "This log message will be shown" in contents
         assert "This log message won't be shown" not in contents
 
 
-def test_log_file_unicode(testdir):
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+def test_log_file_unicode(pytester: Pytester) -> None:
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file={}
@@ -786,7 +795,7 @@ def test_log_file_unicode(testdir):
             log_file
         )
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """\
         import logging
 
@@ -797,9 +806,9 @@ def test_log_file_unicode(testdir):
         """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
 
-    # make sure that that we get a '0' exit code for the testsuite
+    # make sure that we get a '0' exit code for the testsuite
     assert result.ret == 0
     assert os.path.isfile(log_file)
     with open(log_file, encoding="utf-8") as rfh:
@@ -810,11 +819,13 @@ def test_log_file_unicode(testdir):
 
 
 @pytest.mark.parametrize("has_capture_manager", [True, False])
-def test_live_logging_suspends_capture(has_capture_manager: bool, request) -> None:
+def test_live_logging_suspends_capture(
+    has_capture_manager: bool, request: FixtureRequest
+) -> None:
     """Test that capture manager is suspended when we emitting messages for live logging.
 
     This tests the implementation calls instead of behavior because it is difficult/impossible to do it using
-    ``testdir`` facilities because they do their own capturing.
+    ``pytester`` facilities because they do their own capturing.
 
     We parametrize the test to also make sure _LiveLoggingStreamHandler works correctly if no capture manager plugin
     is installed.
@@ -856,8 +867,8 @@ def test_live_logging_suspends_capture(has_capture_manager: bool, request) -> No
     assert cast(io.StringIO, out_file).getvalue() == "\nsome message\n"
 
 
-def test_collection_live_logging(testdir):
-    testdir.makepyfile(
+def test_collection_live_logging(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import logging
 
@@ -865,22 +876,22 @@ def test_collection_live_logging(testdir):
     """
     )
 
-    result = testdir.runpytest("--log-cli-level=INFO")
+    result = pytester.runpytest("--log-cli-level=INFO")
     result.stdout.fnmatch_lines(
         ["*--- live log collection ---*", "*Normal message*", "collected 0 items"]
     )
 
 
 @pytest.mark.parametrize("verbose", ["", "-q", "-qq"])
-def test_collection_collect_only_live_logging(testdir, verbose):
-    testdir.makepyfile(
+def test_collection_collect_only_live_logging(pytester: Pytester, verbose: str) -> None:
+    pytester.makepyfile(
         """
         def test_simple():
             pass
     """
     )
 
-    result = testdir.runpytest("--collect-only", "--log-cli-level=INFO", verbose)
+    result = pytester.runpytest("--collect-only", "--log-cli-level=INFO", verbose)
 
     expected_lines = []
 
@@ -907,10 +918,10 @@ def test_collection_collect_only_live_logging(testdir, verbose):
     result.stdout.fnmatch_lines(expected_lines)
 
 
-def test_collection_logging_to_file(testdir):
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+def test_collection_logging_to_file(pytester: Pytester) -> None:
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file={}
@@ -920,7 +931,7 @@ def test_collection_logging_to_file(testdir):
         )
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -932,7 +943,7 @@ def test_collection_logging_to_file(testdir):
     """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
 
     result.stdout.no_fnmatch_line("*--- live log collection ---*")
 
@@ -945,10 +956,10 @@ def test_collection_logging_to_file(testdir):
         assert "info message in test_simple" in contents
 
 
-def test_log_in_hooks(testdir):
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+def test_log_in_hooks(pytester: Pytester) -> None:
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file={}
@@ -958,7 +969,7 @@ def test_log_in_hooks(testdir):
             log_file
         )
     )
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import logging
 
@@ -972,19 +983,19 @@ def test_log_in_hooks(testdir):
             logging.info('sessionfinish')
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*sessionstart*", "*runtestloop*", "*sessionfinish*"])
-    with open(log_file) as rfh:
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert "sessionstart" in contents
         assert "runtestloop" in contents
         assert "sessionfinish" in contents
 
 
-def test_log_in_runtest_logreport(testdir):
-    log_file = testdir.tmpdir.join("pytest.log").strpath
+def test_log_in_runtest_logreport(pytester: Pytester) -> None:
+    log_file = str(pytester.path.joinpath("pytest.log"))
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file={}
@@ -994,7 +1005,7 @@ def test_log_in_runtest_logreport(testdir):
             log_file
         )
     )
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import logging
         logger = logging.getLogger(__name__)
@@ -1003,29 +1014,29 @@ def test_log_in_runtest_logreport(testdir):
             logger.info("logreport")
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
             def test_first():
                 assert True
         """
     )
-    testdir.runpytest()
-    with open(log_file) as rfh:
+    pytester.runpytest()
+    with open(log_file, encoding="utf-8") as rfh:
         contents = rfh.read()
         assert contents.count("logreport") == 3
 
 
-def test_log_set_path(testdir):
-    report_dir_base = testdir.tmpdir.strpath
+def test_log_set_path(pytester: Pytester) -> None:
+    report_dir_base = str(pytester.path)
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         log_file_level = DEBUG
         log_cli=true
         """
     )
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
             import os
             import pytest
@@ -1040,7 +1051,7 @@ def test_log_set_path(testdir):
             repr(report_dir_base)
         )
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
             import logging
             logger = logging.getLogger("testcase-logger")
@@ -1053,20 +1064,20 @@ def test_log_set_path(testdir):
                 assert True
         """
     )
-    testdir.runpytest()
-    with open(os.path.join(report_dir_base, "test_first")) as rfh:
+    pytester.runpytest()
+    with open(os.path.join(report_dir_base, "test_first"), encoding="utf-8") as rfh:
         content = rfh.read()
         assert "message from test 1" in content
 
-    with open(os.path.join(report_dir_base, "test_second")) as rfh:
+    with open(os.path.join(report_dir_base, "test_second"), encoding="utf-8") as rfh:
         content = rfh.read()
         assert "message from test 2" in content
 
 
-def test_colored_captured_log(testdir):
+def test_colored_captured_log(pytester: Pytester) -> None:
     """Test that the level names of captured log messages of a failing test
     are colored."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -1077,7 +1088,7 @@ def test_colored_captured_log(testdir):
             assert False
         """
     )
-    result = testdir.runpytest("--log-level=INFO", "--color=yes")
+    result = pytester.runpytest("--log-level=INFO", "--color=yes")
     assert result.ret == 1
     result.stdout.fnmatch_lines(
         [
@@ -1087,9 +1098,9 @@ def test_colored_captured_log(testdir):
     )
 
 
-def test_colored_ansi_esc_caplogtext(testdir):
+def test_colored_ansi_esc_caplogtext(pytester: Pytester) -> None:
     """Make sure that caplog.text does not contain ANSI escape sequences."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -1100,11 +1111,11 @@ def test_colored_ansi_esc_caplogtext(testdir):
             assert '\x1b' not in caplog.text
         """
     )
-    result = testdir.runpytest("--log-level=INFO", "--color=yes")
+    result = pytester.runpytest("--log-level=INFO", "--color=yes")
     assert result.ret == 0
 
 
-def test_logging_emit_error(testdir: Testdir) -> None:
+def test_logging_emit_error(pytester: Pytester) -> None:
     """An exception raised during emit() should fail the test.
 
     The default behavior of logging is to print "Logging error"
@@ -1112,7 +1123,7 @@ def test_logging_emit_error(testdir: Testdir) -> None:
 
     pytest overrides this behavior to propagate the exception.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -1120,7 +1131,7 @@ def test_logging_emit_error(testdir: Testdir) -> None:
             logging.warning('oops', 'first', 2)
         """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(failed=1)
     result.stdout.fnmatch_lines(
         [
@@ -1130,10 +1141,10 @@ def test_logging_emit_error(testdir: Testdir) -> None:
     )
 
 
-def test_logging_emit_error_supressed(testdir: Testdir) -> None:
+def test_logging_emit_error_supressed(pytester: Pytester) -> None:
     """If logging is configured to silently ignore errors, pytest
     doesn't propagate errors either."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import logging
 
@@ -1142,13 +1153,181 @@ def test_logging_emit_error_supressed(testdir: Testdir) -> None:
             logging.warning('oops', 'first', 2)
         """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(passed=1)
 
 
-def test_log_file_cli_subdirectories_are_successfully_created(testdir):
-    path = testdir.makepyfile(""" def test_logger(): pass """)
+def test_log_file_cli_subdirectories_are_successfully_created(
+    pytester: Pytester,
+) -> None:
+    path = pytester.makepyfile(""" def test_logger(): pass """)
     expected = os.path.join(os.path.dirname(str(path)), "foo", "bar")
-    result = testdir.runpytest("--log-file=foo/bar/logf.log")
+    result = pytester.runpytest("--log-file=foo/bar/logf.log")
     assert "logf.log" in os.listdir(expected)
     assert result.ret == ExitCode.OK
+
+
+def test_disable_loggers(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        import logging
+        import os
+        disabled_log = logging.getLogger('disabled')
+        test_log = logging.getLogger('test')
+        def test_logger_propagation(caplog):
+            with caplog.at_level(logging.DEBUG):
+                disabled_log.warning("no log; no stderr")
+                test_log.debug("Visible text!")
+                assert caplog.record_tuples == [('test', 10, 'Visible text!')]
+         """
+    )
+    result = pytester.runpytest("--log-disable=disabled", "-s")
+    assert result.ret == ExitCode.OK
+    assert not result.stderr.lines
+
+
+def test_disable_loggers_does_not_propagate(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+    import logging
+    import os
+
+    parent_logger = logging.getLogger("parent")
+    child_logger = parent_logger.getChild("child")
+
+    def test_logger_propagation_to_parent(caplog):
+            with caplog.at_level(logging.DEBUG):
+                parent_logger.warning("some parent logger message")
+                child_logger.warning("some child logger message")
+                assert len(caplog.record_tuples) == 1
+                assert caplog.record_tuples[0][0] == "parent"
+                assert caplog.record_tuples[0][2] == "some parent logger message"
+    """
+    )
+
+    result = pytester.runpytest("--log-disable=parent.child", "-s")
+    assert result.ret == ExitCode.OK
+    assert not result.stderr.lines
+
+
+def test_log_disabling_works_with_log_cli(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+    import logging
+    disabled_log = logging.getLogger('disabled')
+    test_log = logging.getLogger('test')
+
+    def test_log_cli_works(caplog):
+        test_log.info("Visible text!")
+        disabled_log.warning("This string will be suppressed.")
+    """
+    )
+    result = pytester.runpytest(
+        "--log-cli-level=DEBUG",
+        "--log-disable=disabled",
+    )
+    assert result.ret == ExitCode.OK
+    result.stdout.fnmatch_lines(
+        "INFO     test:test_log_disabling_works_with_log_cli.py:6 Visible text!"
+    )
+    result.stdout.no_fnmatch_line(
+        "WARNING  disabled:test_log_disabling_works_with_log_cli.py:7 This string will be suppressed."
+    )
+    assert not result.stderr.lines
+
+
+def test_without_date_format_log(pytester: Pytester) -> None:
+    """Check that date is not printed by default."""
+    pytester.makepyfile(
+        """
+        import logging
+
+        logger = logging.getLogger(__name__)
+
+        def test_foo():
+            logger.warning('text')
+            assert False
+        """
+    )
+    result = pytester.runpytest()
+    assert result.ret == 1
+    result.stdout.fnmatch_lines(
+        ["WARNING  test_without_date_format_log:test_without_date_format_log.py:6 text"]
+    )
+
+
+def test_date_format_log(pytester: Pytester) -> None:
+    """Check that log_date_format affects output."""
+    pytester.makepyfile(
+        """
+        import logging
+
+        logger = logging.getLogger(__name__)
+
+        def test_foo():
+            logger.warning('text')
+            assert False
+        """
+    )
+    pytester.makeini(
+        """
+        [pytest]
+        log_format=%(asctime)s; %(levelname)s; %(message)s
+        log_date_format=%Y-%m-%d %H:%M:%S
+    """
+    )
+    result = pytester.runpytest()
+    assert result.ret == 1
+    result.stdout.re_match_lines([r"^[0-9-]{10} [0-9:]{8}; WARNING; text"])
+
+
+def test_date_format_percentf_log(pytester: Pytester) -> None:
+    """Make sure that microseconds are printed in log."""
+    pytester.makepyfile(
+        """
+        import logging
+
+        logger = logging.getLogger(__name__)
+
+        def test_foo():
+            logger.warning('text')
+            assert False
+        """
+    )
+    pytester.makeini(
+        """
+        [pytest]
+        log_format=%(asctime)s; %(levelname)s; %(message)s
+        log_date_format=%Y-%m-%d %H:%M:%S.%f
+    """
+    )
+    result = pytester.runpytest()
+    assert result.ret == 1
+    result.stdout.re_match_lines([r"^[0-9-]{10} [0-9:]{8}.[0-9]{6}; WARNING; text"])
+
+
+def test_date_format_percentf_tz_log(pytester: Pytester) -> None:
+    """Make sure that timezone and microseconds are properly formatted together."""
+    pytester.makepyfile(
+        """
+        import logging
+
+        logger = logging.getLogger(__name__)
+
+        def test_foo():
+            logger.warning('text')
+            assert False
+        """
+    )
+    pytester.makeini(
+        """
+        [pytest]
+        log_format=%(asctime)s; %(levelname)s; %(message)s
+        log_date_format=%Y-%m-%d %H:%M:%S.%f%z
+    """
+    )
+    result = pytester.runpytest()
+    assert result.ret == 1
+    result.stdout.re_match_lines(
+        [r"^[0-9-]{10} [0-9:]{8}.[0-9]{6}[+-][0-9\.]+; WARNING; text"]
+    )
index f6c77b0dee56cda7412a039dbeda43b496909c93..3bacdef62ab9426a9338c2c07688d073ec8931ca 100644 (file)
@@ -1,4 +1,6 @@
 [pytest]
 addopts = --strict-markers
+asyncio_mode = strict
 filterwarnings =
     error::pytest.PytestWarning
+    ignore:.*.fspath is deprecated and will be replaced by .*.path.*:pytest.PytestDeprecationWarning
index d0ee9b571e22c8d2398ae0491e12479812f60539..d56720c02820dad8a3c68d57529e03e355646401 100644 (file)
@@ -1,15 +1,15 @@
-anyio[curio,trio]==2.0.2
-django==3.1.4
-pytest-asyncio==0.14.0
-pytest-bdd==4.0.1
-pytest-cov==2.10.1
-pytest-django==4.1.0
-pytest-flakes==4.0.3
-pytest-html==3.1.0
-pytest-mock==3.3.1
-pytest-rerunfailures==9.1.1
-pytest-sugar==0.9.4
+anyio[curio,trio]==3.7.0
+django==4.2.2
+pytest-asyncio==0.21.0
+pytest-bdd==6.1.1
+pytest-cov==4.1.0
+pytest-django==4.5.2
+pytest-flakes==4.0.5
+pytest-html==3.2.0
+pytest-mock==3.11.1
+pytest-rerunfailures==11.1.2
+pytest-sugar==0.9.7
 pytest-trio==0.7.0
-pytest-twisted==1.13.2
-twisted==20.3.0
-pytest-xvfb==2.0.0
+pytest-twisted==1.14.0
+twisted==22.8.0
+pytest-xvfb==3.0.0
index e76d6b774d6fff7f1c7b950da7f89d98cd9d6cac..6ad411a3e071c325f733ff2d99234dd695eb1603 100644 (file)
@@ -1,13 +1,15 @@
 import operator
-import sys
+from contextlib import contextmanager
 from decimal import Decimal
 from fractions import Fraction
+from math import sqrt
 from operator import eq
 from operator import ne
 from typing import Optional
 
 import pytest
 from _pytest.pytester import Pytester
+from _pytest.python_api import _recursive_sequence_map
 from pytest import approx
 
 inf, nan = float("inf"), float("nan")
@@ -43,7 +45,267 @@ def mocked_doctest_runner(monkeypatch):
     return MyDocTestRunner()
 
 
+@contextmanager
+def temporary_verbosity(config, verbosity=0):
+    original_verbosity = config.getoption("verbose")
+    config.option.verbose = verbosity
+    try:
+        yield
+    finally:
+        config.option.verbose = original_verbosity
+
+
+@pytest.fixture
+def assert_approx_raises_regex(pytestconfig):
+    def do_assert(lhs, rhs, expected_message, verbosity_level=0):
+        import re
+
+        with temporary_verbosity(pytestconfig, verbosity_level):
+            with pytest.raises(AssertionError) as e:
+                assert lhs == approx(rhs)
+
+        nl = "\n"
+        obtained_message = str(e.value).splitlines()[1:]
+        assert len(obtained_message) == len(expected_message), (
+            "Regex message length doesn't match obtained.\n"
+            "Obtained:\n"
+            f"{nl.join(obtained_message)}\n\n"
+            "Expected regex:\n"
+            f"{nl.join(expected_message)}\n\n"
+        )
+
+        for i, (obtained_line, expected_line) in enumerate(
+            zip(obtained_message, expected_message)
+        ):
+            regex = re.compile(expected_line)
+            assert regex.match(obtained_line) is not None, (
+                "Unexpected error message:\n"
+                f"{nl.join(obtained_message)}\n\n"
+                "Did not match regex:\n"
+                f"{nl.join(expected_message)}\n\n"
+                f"With verbosity level = {verbosity_level}, on line {i}"
+            )
+
+    return do_assert
+
+
+SOME_FLOAT = r"[+-]?([0-9]*[.])?[0-9]+\s*"
+SOME_INT = r"[0-9]+\s*"
+
+
 class TestApprox:
+    def test_error_messages_native_dtypes(self, assert_approx_raises_regex):
+        assert_approx_raises_regex(
+            2.0,
+            1.0,
+            [
+                "  comparison failed",
+                f"  Obtained: {SOME_FLOAT}",
+                f"  Expected: {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        assert_approx_raises_regex(
+            {"a": 1.0, "b": 1000.0, "c": 1000000.0},
+            {
+                "a": 2.0,
+                "b": 1000.0,
+                "c": 3000000.0,
+            },
+            [
+                r"  comparison failed. Mismatched elements: 2 / 3:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index \| Obtained\s+\| Expected           ",
+                rf"  a     \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+                rf"  c     \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        assert_approx_raises_regex(
+            {"a": 1.0, "b": None, "c": None},
+            {
+                "a": None,
+                "b": 1000.0,
+                "c": None,
+            },
+            [
+                r"  comparison failed. Mismatched elements: 2 / 3:",
+                r"  Max absolute difference: -inf",
+                r"  Max relative difference: -inf",
+                r"  Index \| Obtained\s+\| Expected\s+",
+                rf"  a     \| {SOME_FLOAT} \| None",
+                rf"  b     \| None\s+\| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        assert_approx_raises_regex(
+            [1.0, 2.0, 3.0, 4.0],
+            [1.0, 3.0, 3.0, 5.0],
+            [
+                r"  comparison failed. Mismatched elements: 2 / 4:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index \| Obtained\s+\| Expected   ",
+                rf"  1     \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+                rf"  3     \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        assert_approx_raises_regex(
+            (1, 2.2, 4),
+            (1, 3.2, 4),
+            [
+                r"  comparison failed. Mismatched elements: 1 / 3:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index \| Obtained\s+\| Expected   ",
+                rf"  1     \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        # Specific test for comparison with 0.0 (relative diff will be 'inf')
+        assert_approx_raises_regex(
+            [0.0],
+            [1.0],
+            [
+                r"  comparison failed. Mismatched elements: 1 / 1:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                r"  Max relative difference: inf",
+                r"  Index \| Obtained\s+\| Expected   ",
+                rf"\s*0\s*\| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+    def test_error_messages_numpy_dtypes(self, assert_approx_raises_regex):
+        np = pytest.importorskip("numpy")
+
+        a = np.linspace(0, 100, 20)
+        b = np.linspace(0, 100, 20)
+        a[10] += 0.5
+        assert_approx_raises_regex(
+            a,
+            b,
+            [
+                r"  comparison failed. Mismatched elements: 1 / 20:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index \| Obtained\s+\| Expected",
+                rf"  \(10,\) \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        assert_approx_raises_regex(
+            np.array(
+                [
+                    [[1.1987311, 12412342.3], [3.214143244, 1423412423415.677]],
+                    [[1, 2], [3, 219371297321973]],
+                ]
+            ),
+            np.array(
+                [
+                    [[1.12313, 12412342.3], [3.214143244, 534523542345.677]],
+                    [[1, 2], [3, 7]],
+                ]
+            ),
+            [
+                r"  comparison failed. Mismatched elements: 3 / 8:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index\s+\| Obtained\s+\| Expected\s+",
+                rf"  \(0, 0, 0\) \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+                rf"  \(0, 1, 1\) \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+                rf"  \(1, 1, 1\) \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+        # Specific test for comparison with 0.0 (relative diff will be 'inf')
+        assert_approx_raises_regex(
+            np.array([0.0]),
+            np.array([1.0]),
+            [
+                r"  comparison failed. Mismatched elements: 1 / 1:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                r"  Max relative difference: inf",
+                r"  Index \| Obtained\s+\| Expected   ",
+                rf"\s*\(0,\)\s*\| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
+    def test_error_messages_invalid_args(self, assert_approx_raises_regex):
+        np = pytest.importorskip("numpy")
+        with pytest.raises(AssertionError) as e:
+            assert np.array([[1.2, 3.4], [4.0, 5.0]]) == pytest.approx(
+                np.array([[4.0], [5.0]])
+            )
+        message = "\n".join(str(e.value).split("\n")[1:])
+        assert message == "\n".join(
+            [
+                "  Impossible to compare arrays with different shapes.",
+                "  Shapes: (2, 1) and (2, 2)",
+            ]
+        )
+
+        with pytest.raises(AssertionError) as e:
+            assert [1.0, 2.0, 3.0] == pytest.approx([4.0, 5.0])
+        message = "\n".join(str(e.value).split("\n")[1:])
+        assert message == "\n".join(
+            [
+                "  Impossible to compare lists with different sizes.",
+                "  Lengths: 2 and 3",
+            ]
+        )
+
+    def test_error_messages_with_different_verbosity(self, assert_approx_raises_regex):
+        np = pytest.importorskip("numpy")
+        for v in [0, 1, 2]:
+            # Verbosity level doesn't affect the error message for scalars
+            assert_approx_raises_regex(
+                2.0,
+                1.0,
+                [
+                    "  comparison failed",
+                    f"  Obtained: {SOME_FLOAT}",
+                    f"  Expected: {SOME_FLOAT} ± {SOME_FLOAT}",
+                ],
+                verbosity_level=v,
+            )
+
+        a = np.linspace(1, 101, 20)
+        b = np.linspace(2, 102, 20)
+        assert_approx_raises_regex(
+            a,
+            b,
+            [
+                r"  comparison failed. Mismatched elements: 20 / 20:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index \| Obtained\s+\| Expected",
+                rf"  \(0,\)\s+\| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+                rf"  \(1,\)\s+\| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+                rf"  \(2,\)\s+\| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}...",
+                "",
+                rf"\s*...Full output truncated \({SOME_INT} lines hidden\), use '-vv' to show",
+            ],
+            verbosity_level=0,
+        )
+
+        assert_approx_raises_regex(
+            a,
+            b,
+            [
+                r"  comparison failed. Mismatched elements: 20 / 20:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                rf"  Max relative difference: {SOME_FLOAT}",
+                r"  Index \| Obtained\s+\| Expected",
+            ]
+            + [
+                rf"  \({i},\)\s+\| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}"
+                for i in range(20)
+            ],
+            verbosity_level=2,
+        )
+
     def test_repr_string(self):
         assert repr(approx(1.0)) == "1.0 ± 1.0e-06"
         assert repr(approx([1.0, 2.0])) == "approx([1.0 ± 1.0e-06, 2.0 ± 2.0e-06])"
@@ -89,6 +351,12 @@ class TestApprox:
         np_array = np.array(value)
         assert repr(approx(np_array)) == expected_repr_string
 
+    def test_bool(self):
+        with pytest.raises(AssertionError) as err:
+            assert approx(1)
+
+        assert err.match(r"approx\(\) is not supported in a boolean context")
+
     def test_operator_overloading(self):
         assert 1 == approx(1, rel=1e-6, abs=1e-12)
         assert not (1 != approx(1, rel=1e-6, abs=1e-12))
@@ -141,6 +409,13 @@ class TestApprox:
         with pytest.raises(ValueError):
             1.1 == approx(1, rel, abs)
 
+    def test_negative_tolerance_message(self):
+        # Error message for negative tolerance should include the value.
+        with pytest.raises(ValueError, match="-3"):
+            0 == approx(1, abs=-3)
+        with pytest.raises(ValueError, match="-3"):
+            0 == approx(1, rel=-3)
+
     def test_inf_tolerance(self):
         # Everything should be equal if the tolerance is infinite.
         large_diffs = [(1, 1000), (1e-50, 1e50), (-1.0, -1e300), (0.0, 10)]
@@ -313,6 +588,12 @@ class TestApprox:
         assert approx(expected, rel=5e-7, abs=0) == actual
         assert approx(expected, rel=5e-8, abs=0) != actual
 
+    def test_list_decimal(self):
+        actual = [Decimal("1.000001"), Decimal("2.000001")]
+        expected = [Decimal("1"), Decimal("2")]
+
+        assert actual == approx(expected)
+
     def test_list_wrong_len(self):
         assert [1, 2] != approx([1])
         assert [1, 2] != approx([1, 2, 3])
@@ -346,6 +627,14 @@ class TestApprox:
         assert approx(expected, rel=5e-7, abs=0) == actual
         assert approx(expected, rel=5e-8, abs=0) != actual
 
+    def test_dict_decimal(self):
+        actual = {"a": Decimal("1.000001"), "b": Decimal("2.000001")}
+        # Dictionaries became ordered in python3.6, so switch up the order here
+        # to make sure it doesn't matter.
+        expected = {"b": Decimal("2"), "a": Decimal("1")}
+
+        assert actual == approx(expected)
+
     def test_dict_wrong_len(self):
         assert {"a": 1, "b": 2} != approx({"a": 1})
         assert {"a": 1, "b": 2} != approx({"a": 1, "c": 2})
@@ -358,6 +647,19 @@ class TestApprox:
     def test_dict_vs_other(self):
         assert 1 != approx({"a": 0})
 
+    def test_dict_for_div_by_zero(self, assert_approx_raises_regex):
+        assert_approx_raises_regex(
+            {"foo": 42.0},
+            {"foo": 0.0},
+            [
+                r"  comparison failed. Mismatched elements: 1 / 1:",
+                rf"  Max absolute difference: {SOME_FLOAT}",
+                r"  Max relative difference: inf",
+                r"  Index \| Obtained\s+\| Expected   ",
+                rf"  foo   | {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}",
+            ],
+        )
+
     def test_numpy_array(self):
         np = pytest.importorskip("numpy")
 
@@ -514,7 +816,8 @@ class TestApprox:
     )
     def test_expected_value_type_error(self, x, name):
         with pytest.raises(
-            TypeError, match=fr"pytest.approx\(\) does not support nested {name}:",
+            TypeError,
+            match=rf"pytest.approx\(\) does not support nested {name}:",
         ):
             approx(x)
 
@@ -552,7 +855,6 @@ class TestApprox:
         assert 1.0 != approx([None])
         assert None != approx([1.0])  # noqa: E711
 
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="requires ordered dicts")
     def test_nonnumeric_dict_repr(self):
         """Dicts with non-numerics and infinites have no tolerances"""
         x1 = {"foo": 1.0000005, "bar": None, "foobar": inf}
@@ -602,13 +904,49 @@ class TestApprox:
         assert approx(expected, rel=5e-7, abs=0) == actual
         assert approx(expected, rel=5e-8, abs=0) != actual
 
-    def test_generic_sized_iterable_object(self):
-        class MySizedIterable:
-            def __iter__(self):
-                return iter([1, 2, 3, 4])
+    def test_generic_ordered_sequence(self):
+        class MySequence:
+            def __getitem__(self, i):
+                return [1, 2, 3, 4][i]
 
             def __len__(self):
                 return 4
 
-        expected = MySizedIterable()
-        assert [1, 2, 3, 4] == approx(expected)
+        expected = MySequence()
+        assert [1, 2, 3, 4] == approx(expected, abs=1e-4)
+
+        expected_repr = "approx([1 ± 1.0e-06, 2 ± 2.0e-06, 3 ± 3.0e-06, 4 ± 4.0e-06])"
+        assert repr(approx(expected)) == expected_repr
+
+    def test_allow_ordered_sequences_only(self) -> None:
+        """pytest.approx() should raise an error on unordered sequences (#9692)."""
+        with pytest.raises(TypeError, match="only supports ordered sequences"):
+            assert {1, 2, 3} == approx({1, 2, 3})
+
+
+class TestRecursiveSequenceMap:
+    def test_map_over_scalar(self):
+        assert _recursive_sequence_map(sqrt, 16) == 4
+
+    def test_map_over_empty_list(self):
+        assert _recursive_sequence_map(sqrt, []) == []
+
+    def test_map_over_list(self):
+        assert _recursive_sequence_map(sqrt, [4, 16, 25, 676]) == [2, 4, 5, 26]
+
+    def test_map_over_tuple(self):
+        assert _recursive_sequence_map(sqrt, (4, 16, 25, 676)) == (2, 4, 5, 26)
+
+    def test_map_over_nested_lists(self):
+        assert _recursive_sequence_map(sqrt, [4, [25, 64], [[49]]]) == [
+            2,
+            [5, 8],
+            [[7]],
+        ]
+
+    def test_map_over_mixed_sequence(self):
+        assert _recursive_sequence_map(sqrt, [4, (25, 64), [(49)]]) == [
+            2,
+            (5, 8),
+            [(7)],
+        ]
index 4d5f4c6895f347722b99d58330ab7113802f7b42..9bf6e00d1f01438c14ff5eb88c677fd97f40d2c7 100644 (file)
@@ -1,3 +1,4 @@
+import os
 import sys
 import textwrap
 from typing import Any
@@ -6,42 +7,51 @@ from typing import Dict
 import _pytest._code
 import pytest
 from _pytest.config import ExitCode
+from _pytest.main import Session
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.nodes import Collector
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
+from _pytest.python import Class
+from _pytest.python import Function
 
 
 class TestModule:
-    def test_failing_import(self, testdir):
-        modcol = testdir.getmodulecol("import alksdjalskdjalkjals")
+    def test_failing_import(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol("import alksdjalskdjalkjals")
         pytest.raises(Collector.CollectError, modcol.collect)
 
-    def test_import_duplicate(self, testdir):
-        a = testdir.mkdir("a")
-        b = testdir.mkdir("b")
-        p = a.ensure("test_whatever.py")
-        p.pyimport()
-        del sys.modules["test_whatever"]
-        b.ensure("test_whatever.py")
-        result = testdir.runpytest()
+    def test_import_duplicate(self, pytester: Pytester) -> None:
+        a = pytester.mkdir("a")
+        b = pytester.mkdir("b")
+        p1 = a.joinpath("test_whatever.py")
+        p1.touch()
+        p2 = b.joinpath("test_whatever.py")
+        p2.touch()
+        # ensure we don't have it imported already
+        sys.modules.pop(p1.stem, None)
+
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "*import*mismatch*",
                 "*imported*test_whatever*",
-                "*%s*" % a.join("test_whatever.py"),
+                "*%s*" % p1,
                 "*not the same*",
-                "*%s*" % b.join("test_whatever.py"),
+                "*%s*" % p2,
                 "*HINT*",
             ]
         )
 
-    def test_import_prepend_append(self, testdir, monkeypatch):
-        root1 = testdir.mkdir("root1")
-        root2 = testdir.mkdir("root2")
-        root1.ensure("x456.py")
-        root2.ensure("x456.py")
-        p = root2.join("test_x456.py")
+    def test_import_prepend_append(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
+        root1 = pytester.mkdir("root1")
+        root2 = pytester.mkdir("root2")
+        root1.joinpath("x456.py").touch()
+        root2.joinpath("x456.py").touch()
+        p = root2.joinpath("test_x456.py")
         monkeypatch.syspath_prepend(str(root1))
-        p.write(
+        p.write_text(
             textwrap.dedent(
                 """\
                 import x456
@@ -50,27 +60,29 @@ class TestModule:
                 """.format(
                     str(root2)
                 )
-            )
+            ),
+            encoding="utf-8",
         )
-        with root2.as_cwd():
-            reprec = testdir.inline_run("--import-mode=append")
+        with monkeypatch.context() as mp:
+            mp.chdir(root2)
+            reprec = pytester.inline_run("--import-mode=append")
             reprec.assertoutcome(passed=0, failed=1)
-            reprec = testdir.inline_run()
+            reprec = pytester.inline_run()
             reprec.assertoutcome(passed=1)
 
-    def test_syntax_error_in_module(self, testdir):
-        modcol = testdir.getmodulecol("this is a syntax error")
+    def test_syntax_error_in_module(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol("this is a syntax error")
         pytest.raises(modcol.CollectError, modcol.collect)
         pytest.raises(modcol.CollectError, modcol.collect)
 
-    def test_module_considers_pluginmanager_at_import(self, testdir):
-        modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',")
+    def test_module_considers_pluginmanager_at_import(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol("pytest_plugins='xasdlkj',")
         pytest.raises(ImportError, lambda: modcol.obj)
 
-    def test_invalid_test_module_name(self, testdir):
-        a = testdir.mkdir("a")
-        a.ensure("test_one.part1.py")
-        result = testdir.runpytest()
+    def test_invalid_test_module_name(self, pytester: Pytester) -> None:
+        a = pytester.mkdir("a")
+        a.joinpath("test_one.part1.py").touch()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "ImportError while importing test module*test_one.part1*",
@@ -79,24 +91,26 @@ class TestModule:
         )
 
     @pytest.mark.parametrize("verbose", [0, 1, 2])
-    def test_show_traceback_import_error(self, testdir, verbose):
+    def test_show_traceback_import_error(
+        self, pytester: Pytester, verbose: int
+    ) -> None:
         """Import errors when collecting modules should display the traceback (#1976).
 
         With low verbosity we omit pytest and internal modules, otherwise show all traceback entries.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             foo_traceback_import_error="""
                from bar_traceback_import_error import NOT_AVAILABLE
            """,
             bar_traceback_import_error="",
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
                import foo_traceback_import_error
         """
         )
         args = ("-v",) * verbose
-        result = testdir.runpytest(*args)
+        result = pytester.runpytest(*args)
         result.stdout.fnmatch_lines(
             [
                 "ImportError while importing test module*",
@@ -113,12 +127,12 @@ class TestModule:
         else:
             assert "_pytest" not in stdout
 
-    def test_show_traceback_import_error_unicode(self, testdir):
+    def test_show_traceback_import_error_unicode(self, pytester: Pytester) -> None:
         """Check test modules collected which raise ImportError with unicode messages
         are handled properly (#2336).
         """
-        testdir.makepyfile("raise ImportError('Something bad happened ☺')")
-        result = testdir.runpytest()
+        pytester.makepyfile("raise ImportError('Something bad happened ☺')")
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "ImportError while importing test module*",
@@ -130,15 +144,15 @@ class TestModule:
 
 
 class TestClass:
-    def test_class_with_init_warning(self, testdir):
-        testdir.makepyfile(
+    def test_class_with_init_warning(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             class TestClass1(object):
                 def __init__(self):
                     pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "*cannot collect test class 'TestClass1' because it has "
@@ -146,15 +160,15 @@ class TestClass:
             ]
         )
 
-    def test_class_with_new_warning(self, testdir):
-        testdir.makepyfile(
+    def test_class_with_new_warning(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             class TestClass1(object):
                 def __new__(self):
                     pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "*cannot collect test class 'TestClass1' because it has "
@@ -162,19 +176,19 @@ class TestClass:
             ]
         )
 
-    def test_class_subclassobject(self, testdir):
-        testdir.getmodulecol(
+    def test_class_subclassobject(self, pytester: Pytester) -> None:
+        pytester.getmodulecol(
             """
             class test(object):
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*collected 0*"])
 
-    def test_static_method(self, testdir):
+    def test_static_method(self, pytester: Pytester) -> None:
         """Support for collecting staticmethod tests (#2528, #2699)"""
-        testdir.getmodulecol(
+        pytester.getmodulecol(
             """
             import pytest
             class Test(object):
@@ -191,11 +205,11 @@ class TestClass:
                     assert fix == 1
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*collected 2 items*", "*2 passed in*"])
 
-    def test_setup_teardown_class_as_classmethod(self, testdir):
-        testdir.makepyfile(
+    def test_setup_teardown_class_as_classmethod(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_mod1="""
             class TestClassMethod(object):
                 @classmethod
@@ -208,11 +222,11 @@ class TestClass:
                     pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_issue1035_obj_has_getattr(self, testdir):
-        modcol = testdir.getmodulecol(
+    def test_issue1035_obj_has_getattr(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             class Chameleon(object):
                 def __getattr__(self, name):
@@ -223,22 +237,22 @@ class TestClass:
         colitems = modcol.collect()
         assert len(colitems) == 0
 
-    def test_issue1579_namedtuple(self, testdir):
-        testdir.makepyfile(
+    def test_issue1579_namedtuple(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import collections
 
             TestCase = collections.namedtuple('TestCase', ['a'])
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             "*cannot collect test class 'TestCase' "
             "because it has a __new__ constructor*"
         )
 
-    def test_issue2234_property(self, testdir):
-        testdir.makepyfile(
+    def test_issue2234_property(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             class TestCase(object):
                 @property
@@ -246,29 +260,29 @@ class TestClass:
                     raise NotImplementedError()
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
 
 class TestFunction:
-    def test_getmodulecollector(self, testdir):
-        item = testdir.getitem("def test_func(): pass")
+    def test_getmodulecollector(self, pytester: Pytester) -> None:
+        item = pytester.getitem("def test_func(): pass")
         modcol = item.getparent(pytest.Module)
         assert isinstance(modcol, pytest.Module)
         assert hasattr(modcol.obj, "test_func")
 
     @pytest.mark.filterwarnings("default")
-    def test_function_as_object_instance_ignored(self, testdir):
-        testdir.makepyfile(
+    def test_function_as_object_instance_ignored(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             class A(object):
-                def __call__(self, tmpdir):
+                def __call__(self, tmp_path):
                     0/0
 
             test_a = A()
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "collected 0 items",
@@ -278,37 +292,37 @@ class TestFunction:
         )
 
     @staticmethod
-    def make_function(testdir, **kwargs):
+    def make_function(pytester: Pytester, **kwargs: Any) -> Any:
         from _pytest.fixtures import FixtureManager
 
-        config = testdir.parseconfigure()
-        session = testdir.Session.from_config(config)
+        config = pytester.parseconfigure()
+        session = Session.from_config(config)
         session._fixturemanager = FixtureManager(session)
 
         return pytest.Function.from_parent(parent=session, **kwargs)
 
-    def test_function_equality(self, testdir):
+    def test_function_equality(self, pytester: Pytester) -> None:
         def func1():
             pass
 
         def func2():
             pass
 
-        f1 = self.make_function(testdir, name="name", callobj=func1)
+        f1 = self.make_function(pytester, name="name", callobj=func1)
         assert f1 == f1
         f2 = self.make_function(
-            testdir, name="name", callobj=func2, originalname="foobar"
+            pytester, name="name", callobj=func2, originalname="foobar"
         )
         assert f1 != f2
 
-    def test_repr_produces_actual_test_id(self, testdir):
+    def test_repr_produces_actual_test_id(self, pytester: Pytester) -> None:
         f = self.make_function(
-            testdir, name=r"test[\xe5]", callobj=self.test_repr_produces_actual_test_id
+            pytester, name=r"test[\xe5]", callobj=self.test_repr_produces_actual_test_id
         )
         assert repr(f) == r"<Function test[\xe5]>"
 
-    def test_issue197_parametrize_emptyset(self, testdir):
-        testdir.makepyfile(
+    def test_issue197_parametrize_emptyset(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.parametrize('arg', [])
@@ -316,11 +330,11 @@ class TestFunction:
                 pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(skipped=1)
 
-    def test_single_tuple_unwraps_values(self, testdir):
-        testdir.makepyfile(
+    def test_single_tuple_unwraps_values(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.parametrize(('arg',), [(1,)])
@@ -328,11 +342,11 @@ class TestFunction:
                 assert arg == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_issue213_parametrize_value_no_equal(self, testdir):
-        testdir.makepyfile(
+    def test_issue213_parametrize_value_no_equal(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             class A(object):
@@ -343,12 +357,12 @@ class TestFunction:
                 assert arg.__class__.__name__ == "A"
         """
         )
-        reprec = testdir.inline_run("--fulltrace")
+        reprec = pytester.inline_run("--fulltrace")
         reprec.assertoutcome(passed=1)
 
-    def test_parametrize_with_non_hashable_values(self, testdir):
+    def test_parametrize_with_non_hashable_values(self, pytester: Pytester) -> None:
         """Test parametrization with non-hashable values."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             archival_mapping = {
                 '1.0': {'tag': '1.0'},
@@ -363,12 +377,14 @@ class TestFunction:
                 assert value == archival_mapping[key]
         """
         )
-        rec = testdir.inline_run()
+        rec = pytester.inline_run()
         rec.assertoutcome(passed=2)
 
-    def test_parametrize_with_non_hashable_values_indirect(self, testdir):
+    def test_parametrize_with_non_hashable_values_indirect(
+        self, pytester: Pytester
+    ) -> None:
         """Test parametrization with non-hashable values with indirect parametrization."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             archival_mapping = {
                 '1.0': {'tag': '1.0'},
@@ -392,12 +408,12 @@ class TestFunction:
                 assert value == archival_mapping[key]
         """
         )
-        rec = testdir.inline_run()
+        rec = pytester.inline_run()
         rec.assertoutcome(passed=2)
 
-    def test_parametrize_overrides_fixture(self, testdir):
+    def test_parametrize_overrides_fixture(self, pytester: Pytester) -> None:
         """Test parametrization when parameter overrides existing fixture with same name."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -421,12 +437,14 @@ class TestFunction:
                 assert value == 'overridden'
         """
         )
-        rec = testdir.inline_run()
+        rec = pytester.inline_run()
         rec.assertoutcome(passed=3)
 
-    def test_parametrize_overrides_parametrized_fixture(self, testdir):
+    def test_parametrize_overrides_parametrized_fixture(
+        self, pytester: Pytester
+    ) -> None:
         """Test parametrization when parameter overrides existing parametrized fixture with same name."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -440,12 +458,14 @@ class TestFunction:
                 assert value == 'overridden'
         """
         )
-        rec = testdir.inline_run()
+        rec = pytester.inline_run()
         rec.assertoutcome(passed=1)
 
-    def test_parametrize_overrides_indirect_dependency_fixture(self, testdir):
+    def test_parametrize_overrides_indirect_dependency_fixture(
+        self, pytester: Pytester
+    ) -> None:
         """Test parametrization when parameter overrides a fixture that a test indirectly depends on"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -471,11 +491,11 @@ class TestFunction:
                assert not fix3_instantiated
         """
         )
-        rec = testdir.inline_run()
+        rec = pytester.inline_run()
         rec.assertoutcome(passed=1)
 
-    def test_parametrize_with_mark(self, testdir):
-        items = testdir.getitems(
+    def test_parametrize_with_mark(self, pytester: Pytester) -> None:
+        items = pytester.getitems(
             """
             import pytest
             @pytest.mark.foo
@@ -495,8 +515,8 @@ class TestFunction:
         )
         assert "foo" in keywords[1] and "bar" in keywords[1] and "baz" in keywords[1]
 
-    def test_parametrize_with_empty_string_arguments(self, testdir):
-        items = testdir.getitems(
+    def test_parametrize_with_empty_string_arguments(self, pytester: Pytester) -> None:
+        items = pytester.getitems(
             """\
             import pytest
 
@@ -508,8 +528,8 @@ class TestFunction:
         names = {item.name for item in items}
         assert names == {"test[-]", "test[ -]", "test[- ]", "test[ - ]"}
 
-    def test_function_equality_with_callspec(self, testdir):
-        items = testdir.getitems(
+    def test_function_equality_with_callspec(self, pytester: Pytester) -> None:
+        items = pytester.getitems(
             """
             import pytest
             @pytest.mark.parametrize('arg', [1,2])
@@ -520,8 +540,8 @@ class TestFunction:
         assert items[0] != items[1]
         assert not (items[0] == items[1])
 
-    def test_pyfunc_call(self, testdir):
-        item = testdir.getitem("def test_func(): raise ValueError")
+    def test_pyfunc_call(self, pytester: Pytester) -> None:
+        item = pytester.getitem("def test_func(): raise ValueError")
         config = item.config
 
         class MyPlugin1:
@@ -537,8 +557,8 @@ class TestFunction:
         config.hook.pytest_runtest_setup(item=item)
         config.hook.pytest_pyfunc_call(pyfuncitem=item)
 
-    def test_multiple_parametrize(self, testdir):
-        modcol = testdir.getmodulecol(
+    def test_multiple_parametrize(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             import pytest
             @pytest.mark.parametrize('x', [0, 1])
@@ -553,8 +573,8 @@ class TestFunction:
         assert colitems[2].name == "test1[3-0]"
         assert colitems[3].name == "test1[3-1]"
 
-    def test_issue751_multiple_parametrize_with_ids(self, testdir):
-        modcol = testdir.getmodulecol(
+    def test_issue751_multiple_parametrize_with_ids(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             import pytest
             @pytest.mark.parametrize('x', [0], ids=['c'])
@@ -566,14 +586,14 @@ class TestFunction:
                     pass
         """
         )
-        colitems = modcol.collect()[0].collect()[0].collect()
+        colitems = modcol.collect()[0].collect()
         assert colitems[0].name == "test1[a-c]"
         assert colitems[1].name == "test1[b-c]"
         assert colitems[2].name == "test2[a-c]"
         assert colitems[3].name == "test2[b-c]"
 
-    def test_parametrize_skipif(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_skipif(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -584,11 +604,11 @@ class TestFunction:
                 assert x < 2
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed, 1 skipped in *"])
 
-    def test_parametrize_skip(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_skip(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -599,11 +619,11 @@ class TestFunction:
                 assert x < 2
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed, 1 skipped in *"])
 
-    def test_parametrize_skipif_no_skip(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_skipif_no_skip(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -614,11 +634,11 @@ class TestFunction:
                 assert x < 2
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 1 failed, 2 passed in *"])
 
-    def test_parametrize_xfail(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_xfail(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -629,11 +649,11 @@ class TestFunction:
                 assert x < 2
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed, 1 xfailed in *"])
 
-    def test_parametrize_passed(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_passed(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -644,11 +664,11 @@ class TestFunction:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed, 1 xpassed in *"])
 
-    def test_parametrize_xfail_passed(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_xfail_passed(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -659,11 +679,11 @@ class TestFunction:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 3 passed in *"])
 
-    def test_function_originalname(self, testdir: Testdir) -> None:
-        items = testdir.getitems(
+    def test_function_originalname(self, pytester: Pytester) -> None:
+        items = pytester.getitems(
             """
             import pytest
 
@@ -685,14 +705,14 @@ class TestFunction:
             "test_no_param",
         ]
 
-    def test_function_with_square_brackets(self, testdir: Testdir) -> None:
+    def test_function_with_square_brackets(self, pytester: Pytester) -> None:
         """Check that functions with square brackets don't cause trouble."""
-        p1 = testdir.makepyfile(
+        p1 = pytester.makepyfile(
             """
             locals()["test_foo[name]"] = lambda: None
             """
         )
-        result = testdir.runpytest("-v", str(p1))
+        result = pytester.runpytest("-v", str(p1))
         result.stdout.fnmatch_lines(
             [
                 "test_function_with_square_brackets.py::test_foo[[]name[]] PASSED *",
@@ -702,23 +722,23 @@ class TestFunction:
 
 
 class TestSorting:
-    def test_check_equality(self, testdir) -> None:
-        modcol = testdir.getmodulecol(
+    def test_check_equality(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             def test_pass(): pass
             def test_fail(): assert 0
         """
         )
-        fn1 = testdir.collect_by_name(modcol, "test_pass")
+        fn1 = pytester.collect_by_name(modcol, "test_pass")
         assert isinstance(fn1, pytest.Function)
-        fn2 = testdir.collect_by_name(modcol, "test_pass")
+        fn2 = pytester.collect_by_name(modcol, "test_pass")
         assert isinstance(fn2, pytest.Function)
 
         assert fn1 == fn2
         assert fn1 != modcol
         assert hash(fn1) == hash(fn2)
 
-        fn3 = testdir.collect_by_name(modcol, "test_fail")
+        fn3 = pytester.collect_by_name(modcol, "test_fail")
         assert isinstance(fn3, pytest.Function)
         assert not (fn1 == fn3)
         assert fn1 != fn3
@@ -730,8 +750,8 @@ class TestSorting:
             assert [1, 2, 3] != fn  # type: ignore[comparison-overlap]
             assert modcol != fn
 
-    def test_allow_sane_sorting_for_decorators(self, testdir):
-        modcol = testdir.getmodulecol(
+    def test_allow_sane_sorting_for_decorators(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             def dec(f):
                 g = lambda: f(2)
@@ -752,27 +772,58 @@ class TestSorting:
         assert len(colitems) == 2
         assert [item.name for item in colitems] == ["test_b", "test_a"]
 
+    def test_ordered_by_definition_order(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """\
+            class Test1:
+                def test_foo(): pass
+                def test_bar(): pass
+            class Test2:
+                def test_foo(): pass
+                test_bar = Test1.test_bar
+            class Test3(Test2):
+                def test_baz(): pass
+            """
+        )
+        result = pytester.runpytest("--collect-only")
+        result.stdout.fnmatch_lines(
+            [
+                "*Class Test1*",
+                "*Function test_foo*",
+                "*Function test_bar*",
+                "*Class Test2*",
+                # previously the order was flipped due to Test1.test_bar reference
+                "*Function test_foo*",
+                "*Function test_bar*",
+                "*Class Test3*",
+                "*Function test_foo*",
+                "*Function test_bar*",
+                "*Function test_baz*",
+            ]
+        )
+
 
 class TestConftestCustomization:
-    def test_pytest_pycollect_module(self, testdir):
-        testdir.makeconftest(
+    def test_pytest_pycollect_module(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             class MyModule(pytest.Module):
                 pass
-            def pytest_pycollect_makemodule(path, parent):
-                if path.basename == "test_xyz.py":
-                    return MyModule.from_parent(fspath=path, parent=parent)
+            def pytest_pycollect_makemodule(module_path, parent):
+                if module_path.name == "test_xyz.py":
+                    return MyModule.from_parent(path=module_path, parent=parent)
         """
         )
-        testdir.makepyfile("def test_some(): pass")
-        testdir.makepyfile(test_xyz="def test_func(): pass")
-        result = testdir.runpytest("--collect-only")
+        pytester.makepyfile("def test_some(): pass")
+        pytester.makepyfile(test_xyz="def test_func(): pass")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*<Module*test_pytest*", "*<MyModule*xyz*"])
 
-    def test_customized_pymakemodule_issue205_subdir(self, testdir):
-        b = testdir.mkdir("a").mkdir("b")
-        b.join("conftest.py").write(
+    def test_customized_pymakemodule_issue205_subdir(self, pytester: Pytester) -> None:
+        b = pytester.path.joinpath("a", "b")
+        b.mkdir(parents=True)
+        b.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -782,22 +833,25 @@ class TestConftestCustomization:
                     mod = outcome.get_result()
                     mod.obj.hello = "world"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        b.join("test_module.py").write(
+        b.joinpath("test_module.py").write_text(
             textwrap.dedent(
                 """\
                 def test_hello():
                     assert hello == "world"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_customized_pymakeitem(self, testdir):
-        b = testdir.mkdir("a").mkdir("b")
-        b.join("conftest.py").write(
+    def test_customized_pymakeitem(self, pytester: Pytester) -> None:
+        b = pytester.path.joinpath("a", "b")
+        b.mkdir(parents=True)
+        b.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -810,9 +864,10 @@ class TestConftestCustomization:
                             for func in result:
                                 func._some123 = "world"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        b.join("test_module.py").write(
+        b.joinpath("test_module.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -823,13 +878,14 @@ class TestConftestCustomization:
                 def test_hello(obj):
                     assert obj == "world"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_pytest_pycollect_makeitem(self, testdir):
-        testdir.makeconftest(
+    def test_pytest_pycollect_makeitem(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             class MyFunction(pytest.Function):
@@ -839,44 +895,48 @@ class TestConftestCustomization:
                     return MyFunction.from_parent(name=name, parent=collector)
         """
         )
-        testdir.makepyfile("def some(): pass")
-        result = testdir.runpytest("--collect-only")
+        pytester.makepyfile("def some(): pass")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*MyFunction*some*"])
 
-    def test_issue2369_collect_module_fileext(self, testdir):
+    def test_issue2369_collect_module_fileext(self, pytester: Pytester) -> None:
         """Ensure we can collect files with weird file extensions as Python
         modules (#2369)"""
-        # We'll implement a little finder and loader to import files containing
+        # Implement a little meta path finder to import files containing
         # Python source code whose file extension is ".narf".
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
-            import sys, os, imp
+            import sys
+            import os.path
+            from importlib.util import spec_from_loader
+            from importlib.machinery import SourceFileLoader
             from _pytest.python import Module
 
-            class Loader(object):
-                def load_module(self, name):
-                    return imp.load_source(name, name + ".narf")
-            class Finder(object):
-                def find_module(self, name, path=None):
-                    if os.path.exists(name + ".narf"):
-                        return Loader()
-            sys.meta_path.append(Finder())
-
-            def pytest_collect_file(path, parent):
-                if path.ext == ".narf":
-                    return Module.from_parent(fspath=path, parent=parent)"""
+            class MetaPathFinder:
+                def find_spec(self, fullname, path, target=None):
+                    if os.path.exists(fullname + ".narf"):
+                        return spec_from_loader(
+                            fullname,
+                            SourceFileLoader(fullname, fullname + ".narf"),
+                        )
+            sys.meta_path.append(MetaPathFinder())
+
+            def pytest_collect_file(file_path, parent):
+                if file_path.suffix == ".narf":
+                    return Module.from_parent(path=file_path, parent=parent)
+            """
         )
-        testdir.makefile(
+        pytester.makefile(
             ".narf",
             """\
             def test_something():
                 assert 1 + 1 == 2""",
         )
         # Use runpytest_subprocess, since we're futzing with sys.meta_path.
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_early_ignored_attributes(self, testdir: Testdir) -> None:
+    def test_early_ignored_attributes(self, pytester: Pytester) -> None:
         """Builtin attributes should be ignored early on, even if
         configuration would otherwise allow them.
 
@@ -884,14 +944,14 @@ class TestConftestCustomization:
         although it tests PytestCollectionWarning is not raised, while
         it would have been raised otherwise.
         """
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             python_classes=*
             python_functions=*
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             class TestEmpty:
                 pass
@@ -900,48 +960,50 @@ class TestConftestCustomization:
                 pass
         """
         )
-        items, rec = testdir.inline_genitems()
+        items, rec = pytester.inline_genitems()
         assert rec.ret == 0
         assert len(items) == 1
 
 
-def test_setup_only_available_in_subdir(testdir):
-    sub1 = testdir.mkpydir("sub1")
-    sub2 = testdir.mkpydir("sub2")
-    sub1.join("conftest.py").write(
+def test_setup_only_available_in_subdir(pytester: Pytester) -> None:
+    sub1 = pytester.mkpydir("sub1")
+    sub2 = pytester.mkpydir("sub2")
+    sub1.joinpath("conftest.py").write_text(
         textwrap.dedent(
             """\
             import pytest
             def pytest_runtest_setup(item):
-                assert item.fspath.purebasename == "test_in_sub1"
+                assert item.path.stem == "test_in_sub1"
             def pytest_runtest_call(item):
-                assert item.fspath.purebasename == "test_in_sub1"
+                assert item.path.stem == "test_in_sub1"
             def pytest_runtest_teardown(item):
-                assert item.fspath.purebasename == "test_in_sub1"
+                assert item.path.stem == "test_in_sub1"
             """
-        )
+        ),
+        encoding="utf-8",
     )
-    sub2.join("conftest.py").write(
+    sub2.joinpath("conftest.py").write_text(
         textwrap.dedent(
             """\
             import pytest
             def pytest_runtest_setup(item):
-                assert item.fspath.purebasename == "test_in_sub2"
+                assert item.path.stem == "test_in_sub2"
             def pytest_runtest_call(item):
-                assert item.fspath.purebasename == "test_in_sub2"
+                assert item.path.stem == "test_in_sub2"
             def pytest_runtest_teardown(item):
-                assert item.fspath.purebasename == "test_in_sub2"
+                assert item.path.stem == "test_in_sub2"
             """
-        )
+        ),
+        encoding="utf-8",
     )
-    sub1.join("test_in_sub1.py").write("def test_1(): pass")
-    sub2.join("test_in_sub2.py").write("def test_2(): pass")
-    result = testdir.runpytest("-v", "-s")
+    sub1.joinpath("test_in_sub1.py").write_text("def test_1(): pass", encoding="utf-8")
+    sub2.joinpath("test_in_sub2.py").write_text("def test_2(): pass", encoding="utf-8")
+    result = pytester.runpytest("-v", "-s")
     result.assert_outcomes(passed=2)
 
 
-def test_modulecol_roundtrip(testdir):
-    modcol = testdir.getmodulecol("pass", withinit=False)
+def test_modulecol_roundtrip(pytester: Pytester) -> None:
+    modcol = pytester.getmodulecol("pass", withinit=False)
     trail = modcol.nodeid
     newcol = modcol.session.perform_collect([trail], genitems=0)[0]
     assert modcol.name == newcol.name
@@ -952,12 +1014,12 @@ class TestTracebackCutting:
         with pytest.raises(pytest.skip.Exception) as excinfo:
             pytest.skip("xxx")
         assert excinfo.traceback[-1].frame.code.name == "skip"
-        assert excinfo.traceback[-1].ishidden()
+        assert excinfo.traceback[-1].ishidden(excinfo)
         assert excinfo.traceback[-2].frame.code.name == "test_skip_simple"
-        assert not excinfo.traceback[-2].ishidden()
+        assert not excinfo.traceback[-2].ishidden(excinfo)
 
-    def test_traceback_argsetup(self, testdir):
-        testdir.makeconftest(
+    def test_traceback_argsetup(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
 
@@ -966,8 +1028,8 @@ class TestTracebackCutting:
                 raise ValueError("xyz")
         """
         )
-        p = testdir.makepyfile("def test(hello): pass")
-        result = testdir.runpytest(p)
+        p = pytester.makepyfile("def test(hello): pass")
+        result = pytester.runpytest(p)
         assert result.ret != 0
         out = result.stdout.str()
         assert "xyz" in out
@@ -975,14 +1037,14 @@ class TestTracebackCutting:
         numentries = out.count("_ _ _")  # separator for traceback entries
         assert numentries == 0
 
-        result = testdir.runpytest("--fulltrace", p)
+        result = pytester.runpytest("--fulltrace", p)
         out = result.stdout.str()
         assert "conftest.py:5: ValueError" in out
         numentries = out.count("_ _ _ _")  # separator for traceback entries
         assert numentries > 3
 
-    def test_traceback_error_during_import(self, testdir):
-        testdir.makepyfile(
+    def test_traceback_error_during_import(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             x = 1
             x = 2
@@ -990,21 +1052,23 @@ class TestTracebackCutting:
             asd
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret != 0
         out = result.stdout.str()
         assert "x = 1" not in out
         assert "x = 2" not in out
         result.stdout.fnmatch_lines([" *asd*", "E*NameError*"])
-        result = testdir.runpytest("--fulltrace")
+        result = pytester.runpytest("--fulltrace")
         out = result.stdout.str()
         assert "x = 1" in out
         assert "x = 2" in out
         result.stdout.fnmatch_lines([">*asd*", "E*NameError*"])
 
-    def test_traceback_filter_error_during_fixture_collection(self, testdir):
+    def test_traceback_filter_error_during_fixture_collection(
+        self, pytester: Pytester
+    ) -> None:
         """Integration test for issue #995."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1022,7 +1086,7 @@ class TestTracebackCutting:
                pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret != 0
         out = result.stdout.str()
         assert "INTERNALERROR>" not in out
@@ -1039,6 +1103,7 @@ class TestTracebackCutting:
         """
         from _pytest._code import filter_traceback
 
+        tb = None
         try:
             ns: Dict[str, Any] = {}
             exec("def foo(): raise ValueError", ns)
@@ -1051,7 +1116,7 @@ class TestTracebackCutting:
         assert isinstance(traceback[-1].path, str)
         assert not filter_traceback(traceback[-1])
 
-    def test_filter_traceback_path_no_longer_valid(self, testdir) -> None:
+    def test_filter_traceback_path_no_longer_valid(self, pytester: Pytester) -> None:
         """Test that filter_traceback() works with the fact that
         _pytest._code.code.Code.path attribute might return an str object.
 
@@ -1060,13 +1125,14 @@ class TestTracebackCutting:
         """
         from _pytest._code import filter_traceback
 
-        testdir.syspathinsert()
-        testdir.makepyfile(
+        pytester.syspathinsert()
+        pytester.makepyfile(
             filter_traceback_entry_as_str="""
             def foo():
                 raise ValueError
         """
         )
+        tb = None
         try:
             import filter_traceback_entry_as_str
 
@@ -1075,15 +1141,15 @@ class TestTracebackCutting:
             _, _, tb = sys.exc_info()
 
         assert tb is not None
-        testdir.tmpdir.join("filter_traceback_entry_as_str.py").remove()
+        pytester.path.joinpath("filter_traceback_entry_as_str.py").unlink()
         traceback = _pytest._code.Traceback(tb)
         assert isinstance(traceback[-1].path, str)
         assert filter_traceback(traceback[-1])
 
 
 class TestReportInfo:
-    def test_itemreport_reportinfo(self, testdir):
-        testdir.makeconftest(
+    def test_itemreport_reportinfo(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             class MyFunction(pytest.Function):
@@ -1094,54 +1160,64 @@ class TestReportInfo:
                     return MyFunction.from_parent(name=name, parent=collector)
         """
         )
-        item = testdir.getitem("def test_func(): pass")
+        item = pytester.getitem("def test_func(): pass")
         item.config.pluginmanager.getplugin("runner")
         assert item.location == ("ABCDE", 42, "custom")
 
-    def test_func_reportinfo(self, testdir):
-        item = testdir.getitem("def test_func(): pass")
-        fspath, lineno, modpath = item.reportinfo()
-        assert fspath == item.fspath
+    def test_func_reportinfo(self, pytester: Pytester) -> None:
+        item = pytester.getitem("def test_func(): pass")
+        path, lineno, modpath = item.reportinfo()
+        assert os.fspath(path) == str(item.path)
         assert lineno == 0
         assert modpath == "test_func"
 
-    def test_class_reportinfo(self, testdir):
-        modcol = testdir.getmodulecol(
+    def test_class_reportinfo(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             # lineno 0
             class TestClass(object):
                 def test_hello(self): pass
         """
         )
-        classcol = testdir.collect_by_name(modcol, "TestClass")
-        fspath, lineno, msg = classcol.reportinfo()
-        assert fspath == modcol.fspath
+        classcol = pytester.collect_by_name(modcol, "TestClass")
+        assert isinstance(classcol, Class)
+        path, lineno, msg = classcol.reportinfo()
+        assert os.fspath(path) == str(modcol.path)
         assert lineno == 1
         assert msg == "TestClass"
 
     @pytest.mark.filterwarnings(
         "ignore:usage of Generator.Function is deprecated, please use pytest.Function instead"
     )
-    def test_reportinfo_with_nasty_getattr(self, testdir):
+    def test_reportinfo_with_nasty_getattr(self, pytester: Pytester) -> None:
         # https://github.com/pytest-dev/pytest/issues/1204
-        modcol = testdir.getmodulecol(
+        modcol = pytester.getmodulecol(
             """
             # lineno 0
-            class TestClass(object):
+            class TestClass:
                 def __getattr__(self, name):
                     return "this is not an int"
 
-                def test_foo(self):
+                def __class_getattr__(cls, name):
+                    return "this is not an int"
+
+                def intest_foo(self):
+                    pass
+
+                def test_bar(self):
                     pass
         """
         )
-        classcol = testdir.collect_by_name(modcol, "TestClass")
-        instance = classcol.collect()[0]
-        fspath, lineno, msg = instance.reportinfo()
+        classcol = pytester.collect_by_name(modcol, "TestClass")
+        assert isinstance(classcol, Class)
+        path, lineno, msg = classcol.reportinfo()
+        func = list(classcol.collect())[0]
+        assert isinstance(func, Function)
+        path, lineno, msg = func.reportinfo()
 
 
-def test_customized_python_discovery(testdir):
-    testdir.makeini(
+def test_customized_python_discovery(pytester: Pytester) -> None:
+    pytester.makeini(
         """
         [pytest]
         python_files=check_*.py
@@ -1149,7 +1225,7 @@ def test_customized_python_discovery(testdir):
         python_functions=check
     """
     )
-    p = testdir.makepyfile(
+    p = pytester.makepyfile(
         """
         def check_simple():
             pass
@@ -1158,41 +1234,41 @@ def test_customized_python_discovery(testdir):
                 pass
     """
     )
-    p2 = p.new(basename=p.basename.replace("test", "check"))
-    p.move(p2)
-    result = testdir.runpytest("--collect-only", "-s")
+    p2 = p.with_name(p.name.replace("test", "check"))
+    p.rename(p2)
+    result = pytester.runpytest("--collect-only", "-s")
     result.stdout.fnmatch_lines(
         ["*check_customized*", "*check_simple*", "*CheckMyApp*", "*check_meth*"]
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 0
     result.stdout.fnmatch_lines(["*2 passed*"])
 
 
-def test_customized_python_discovery_functions(testdir):
-    testdir.makeini(
+def test_customized_python_discovery_functions(pytester: Pytester) -> None:
+    pytester.makeini(
         """
         [pytest]
         python_functions=_test
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         def _test_underscore():
             pass
     """
     )
-    result = testdir.runpytest("--collect-only", "-s")
+    result = pytester.runpytest("--collect-only", "-s")
     result.stdout.fnmatch_lines(["*_test_underscore*"])
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 0
     result.stdout.fnmatch_lines(["*1 passed*"])
 
 
-def test_unorderable_types(testdir):
-    testdir.makepyfile(
+def test_unorderable_types(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         class TestJoinEmpty(object):
             pass
@@ -1205,19 +1281,19 @@ def test_unorderable_types(testdir):
         TestFoo = make_test()
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.no_fnmatch_line("*TypeError*")
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
 
-@pytest.mark.filterwarnings("default")
-def test_dont_collect_non_function_callable(testdir):
+@pytest.mark.filterwarnings("default::pytest.PytestCollectionWarning")
+def test_dont_collect_non_function_callable(pytester: Pytester) -> None:
     """Test for issue https://github.com/pytest-dev/pytest/issues/331
 
     In this case an INTERNALERROR occurred trying to report the failure of
     a test like this one because pytest failed to get the source lines.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         class Oh(object):
             def __call__(self):
@@ -1229,7 +1305,7 @@ def test_dont_collect_non_function_callable(testdir):
             pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*collected 1 item*",
@@ -1239,21 +1315,21 @@ def test_dont_collect_non_function_callable(testdir):
     )
 
 
-def test_class_injection_does_not_break_collection(testdir):
+def test_class_injection_does_not_break_collection(pytester: Pytester) -> None:
     """Tests whether injection during collection time will terminate testing.
 
     In this case the error should not occur if the TestClass itself
     is modified during collection time, and the original method list
     is still used for collection.
     """
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         from test_inject import TestClass
         def pytest_generate_tests(metafunc):
             TestClass.changed_var = {}
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         test_inject='''
          class TestClass(object):
             def test_injection(self):
@@ -1261,7 +1337,7 @@ def test_class_injection_does_not_break_collection(testdir):
                 pass
     '''
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert (
         "RuntimeError: dictionary changed size during iteration"
         not in result.stdout.str()
@@ -1269,16 +1345,16 @@ def test_class_injection_does_not_break_collection(testdir):
     result.stdout.fnmatch_lines(["*1 passed*"])
 
 
-def test_syntax_error_with_non_ascii_chars(testdir):
+def test_syntax_error_with_non_ascii_chars(pytester: Pytester) -> None:
     """Fix decoding issue while formatting SyntaxErrors during collection (#578)."""
-    testdir.makepyfile("☃")
-    result = testdir.runpytest()
+    pytester.makepyfile("☃")
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*ERROR collecting*", "*SyntaxError*", "*1 error in*"])
 
 
-def test_collect_error_with_fulltrace(testdir):
-    testdir.makepyfile("assert 0")
-    result = testdir.runpytest("--fulltrace")
+def test_collect_error_with_fulltrace(pytester: Pytester) -> None:
+    pytester.makepyfile("assert 0")
+    result = pytester.runpytest("--fulltrace")
     result.stdout.fnmatch_lines(
         [
             "collected 0 items / 1 error",
@@ -1295,60 +1371,62 @@ def test_collect_error_with_fulltrace(testdir):
     )
 
 
-def test_skip_duplicates_by_default(testdir):
+def test_skip_duplicates_by_default(pytester: Pytester) -> None:
     """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
 
     Ignore duplicate directories.
     """
-    a = testdir.mkdir("a")
-    fh = a.join("test_a.py")
-    fh.write(
+    a = pytester.mkdir("a")
+    fh = a.joinpath("test_a.py")
+    fh.write_text(
         textwrap.dedent(
             """\
             import pytest
             def test_real():
                 pass
             """
-        )
+        ),
+        encoding="utf-8",
     )
-    result = testdir.runpytest(a.strpath, a.strpath)
+    result = pytester.runpytest(str(a), str(a))
     result.stdout.fnmatch_lines(["*collected 1 item*"])
 
 
-def test_keep_duplicates(testdir):
+def test_keep_duplicates(pytester: Pytester) -> None:
     """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
 
     Use --keep-duplicates to collect tests from duplicate directories.
     """
-    a = testdir.mkdir("a")
-    fh = a.join("test_a.py")
-    fh.write(
+    a = pytester.mkdir("a")
+    fh = a.joinpath("test_a.py")
+    fh.write_text(
         textwrap.dedent(
             """\
             import pytest
             def test_real():
                 pass
             """
-        )
+        ),
+        encoding="utf-8",
     )
-    result = testdir.runpytest("--keep-duplicates", a.strpath, a.strpath)
+    result = pytester.runpytest("--keep-duplicates", str(a), str(a))
     result.stdout.fnmatch_lines(["*collected 2 item*"])
 
 
-def test_package_collection_infinite_recursion(testdir):
-    testdir.copy_example("collect/package_infinite_recursion")
-    result = testdir.runpytest()
+def test_package_collection_infinite_recursion(pytester: Pytester) -> None:
+    pytester.copy_example("collect/package_infinite_recursion")
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*1 passed*"])
 
 
-def test_package_collection_init_given_as_argument(testdir):
+def test_package_collection_init_given_as_argument(pytester: Pytester) -> None:
     """Regression test for #3749"""
-    p = testdir.copy_example("collect/package_init_given_as_arg")
-    result = testdir.runpytest(p / "pkg" / "__init__.py")
+    p = pytester.copy_example("collect/package_init_given_as_arg")
+    result = pytester.runpytest(p / "pkg" / "__init__.py")
     result.stdout.fnmatch_lines(["*1 passed*"])
 
 
-def test_package_with_modules(testdir):
+def test_package_with_modules(pytester: Pytester) -> None:
     """
     .
     └── root
@@ -1363,32 +1441,39 @@ def test_package_with_modules(testdir):
                 └── test_in_sub2.py
 
     """
-    root = testdir.mkpydir("root")
-    sub1 = root.mkdir("sub1")
-    sub1.ensure("__init__.py")
-    sub1_test = sub1.mkdir("sub1_1")
-    sub1_test.ensure("__init__.py")
-    sub2 = root.mkdir("sub2")
-    sub2_test = sub2.mkdir("sub2")
-
-    sub1_test.join("test_in_sub1.py").write("def test_1(): pass")
-    sub2_test.join("test_in_sub2.py").write("def test_2(): pass")
+    root = pytester.mkpydir("root")
+    sub1 = root.joinpath("sub1")
+    sub1_test = sub1.joinpath("sub1_1")
+    sub1_test.mkdir(parents=True)
+    for d in (sub1, sub1_test):
+        d.joinpath("__init__.py").touch()
+
+    sub2 = root.joinpath("sub2")
+    sub2_test = sub2.joinpath("test")
+    sub2_test.mkdir(parents=True)
+
+    sub1_test.joinpath("test_in_sub1.py").write_text(
+        "def test_1(): pass", encoding="utf-8"
+    )
+    sub2_test.joinpath("test_in_sub2.py").write_text(
+        "def test_2(): pass", encoding="utf-8"
+    )
 
     # Execute from .
-    result = testdir.runpytest("-v", "-s")
+    result = pytester.runpytest("-v", "-s")
     result.assert_outcomes(passed=2)
 
     # Execute from . with one argument "root"
-    result = testdir.runpytest("-v", "-s", "root")
+    result = pytester.runpytest("-v", "-s", "root")
     result.assert_outcomes(passed=2)
 
     # Chdir into package's root and execute with no args
-    root.chdir()
-    result = testdir.runpytest("-v", "-s")
+    os.chdir(root)
+    result = pytester.runpytest("-v", "-s")
     result.assert_outcomes(passed=2)
 
 
-def test_package_ordering(testdir):
+def test_package_ordering(pytester: Pytester) -> None:
     """
     .
     └── root
@@ -1402,22 +1487,26 @@ def test_package_ordering(testdir):
                 └── test_sub2.py
 
     """
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         python_files=*.py
     """
     )
-    root = testdir.mkpydir("root")
-    sub1 = root.mkdir("sub1")
-    sub1.ensure("__init__.py")
-    sub2 = root.mkdir("sub2")
-    sub2_test = sub2.mkdir("sub2")
-
-    root.join("Test_root.py").write("def test_1(): pass")
-    sub1.join("Test_sub1.py").write("def test_2(): pass")
-    sub2_test.join("test_sub2.py").write("def test_3(): pass")
+    root = pytester.mkpydir("root")
+    sub1 = root.joinpath("sub1")
+    sub1.mkdir()
+    sub1.joinpath("__init__.py").touch()
+    sub2 = root.joinpath("sub2")
+    sub2_test = sub2.joinpath("test")
+    sub2_test.mkdir(parents=True)
+
+    root.joinpath("Test_root.py").write_text("def test_1(): pass", encoding="utf-8")
+    sub1.joinpath("Test_sub1.py").write_text("def test_2(): pass", encoding="utf-8")
+    sub2_test.joinpath("test_sub2.py").write_text(
+        "def test_3(): pass", encoding="utf-8"
+    )
 
     # Execute from .
-    result = testdir.runpytest("-v", "-s")
+    result = pytester.runpytest("-v", "-s")
     result.assert_outcomes(passed=3)
index 94547dd245c3abd6a7464518a4af4d8cea1eab7c..e62db8c2653376c0619d521f475a82ad7bc45e4e 100644 (file)
@@ -1,3 +1,4 @@
+import os
 import sys
 import textwrap
 from pathlib import Path
@@ -7,8 +8,10 @@ from _pytest import fixtures
 from _pytest.compat import getfuncargnames
 from _pytest.config import ExitCode
 from _pytest.fixtures import FixtureRequest
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pytester import get_public_names
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
+from _pytest.python import Function
 
 
 def test_getfuncargnames_functions():
@@ -56,6 +59,20 @@ def test_getfuncargnames_staticmethod():
     assert getfuncargnames(A.static, cls=A) == ("arg1", "arg2")
 
 
+def test_getfuncargnames_staticmethod_inherited() -> None:
+    """Test getfuncargnames for inherited staticmethods (#8061)"""
+
+    class A:
+        @staticmethod
+        def static(arg1, arg2, x=1):
+            raise NotImplementedError()
+
+    class B(A):
+        pass
+
+    assert getfuncargnames(B.static, cls=B) == ("arg1", "arg2")
+
+
 def test_getfuncargnames_partial():
     """Check getfuncargnames for methods defined with functools.partial (#5701)"""
     import functools
@@ -86,13 +103,9 @@ def test_getfuncargnames_staticmethod_partial():
 
 @pytest.mark.pytester_example_path("fixtures/fill_fixtures")
 class TestFillFixtures:
-    def test_fillfuncargs_exposed(self):
-        # used by oejskit, kept for compatibility
-        assert pytest._fillfuncargs == fixtures._fillfuncargs
-
-    def test_funcarg_lookupfails(self, testdir):
-        testdir.copy_example()
-        result = testdir.runpytest()  # "--collect-only")
+    def test_funcarg_lookupfails(self, pytester: Pytester) -> None:
+        pytester.copy_example()
+        result = pytester.runpytest()  # "--collect-only")
         assert result.ret != 0
         result.stdout.fnmatch_lines(
             """
@@ -102,60 +115,64 @@ class TestFillFixtures:
             """
         )
 
-    def test_detect_recursive_dependency_error(self, testdir):
-        testdir.copy_example()
-        result = testdir.runpytest()
+    def test_detect_recursive_dependency_error(self, pytester: Pytester) -> None:
+        pytester.copy_example()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             ["*recursive dependency involving fixture 'fix1' detected*"]
         )
 
-    def test_funcarg_basic(self, testdir):
-        testdir.copy_example()
-        item = testdir.getitem(Path("test_funcarg_basic.py"))
-        item._request._fillfixtures()
+    def test_funcarg_basic(self, pytester: Pytester) -> None:
+        pytester.copy_example()
+        item = pytester.getitem(Path("test_funcarg_basic.py"))
+        assert isinstance(item, Function)
+        # Execute's item's setup, which fills fixtures.
+        item.session._setupstate.setup(item)
         del item.funcargs["request"]
         assert len(get_public_names(item.funcargs)) == 2
         assert item.funcargs["some"] == "test_func"
         assert item.funcargs["other"] == 42
 
-    def test_funcarg_lookup_modulelevel(self, testdir):
-        testdir.copy_example()
-        reprec = testdir.inline_run()
+    def test_funcarg_lookup_modulelevel(self, pytester: Pytester) -> None:
+        pytester.copy_example()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_funcarg_lookup_classlevel(self, testdir):
-        p = testdir.copy_example()
-        result = testdir.runpytest(p)
+    def test_funcarg_lookup_classlevel(self, pytester: Pytester) -> None:
+        p = pytester.copy_example()
+        result = pytester.runpytest(p)
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_conftest_funcargs_only_available_in_subdir(self, testdir):
-        testdir.copy_example()
-        result = testdir.runpytest("-v")
+    def test_conftest_funcargs_only_available_in_subdir(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.copy_example()
+        result = pytester.runpytest("-v")
         result.assert_outcomes(passed=2)
 
-    def test_extend_fixture_module_class(self, testdir):
-        testfile = testdir.copy_example()
-        result = testdir.runpytest()
+    def test_extend_fixture_module_class(self, pytester: Pytester) -> None:
+        testfile = pytester.copy_example()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
-        result = testdir.runpytest(testfile)
+        result = pytester.runpytest(testfile)
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_extend_fixture_conftest_module(self, testdir):
-        p = testdir.copy_example()
-        result = testdir.runpytest()
+    def test_extend_fixture_conftest_module(self, pytester: Pytester) -> None:
+        p = pytester.copy_example()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
-        result = testdir.runpytest(str(next(Path(str(p)).rglob("test_*.py"))))
+        result = pytester.runpytest(str(next(Path(str(p)).rglob("test_*.py"))))
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_extend_fixture_conftest_conftest(self, testdir):
-        p = testdir.copy_example()
-        result = testdir.runpytest()
+    def test_extend_fixture_conftest_conftest(self, pytester: Pytester) -> None:
+        p = pytester.copy_example()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
-        result = testdir.runpytest(str(next(Path(str(p)).rglob("test_*.py"))))
+        result = pytester.runpytest(str(next(Path(str(p)).rglob("test_*.py"))))
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_extend_fixture_conftest_plugin(self, testdir):
-        testdir.makepyfile(
+    def test_extend_fixture_conftest_plugin(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             testplugin="""
             import pytest
 
@@ -164,8 +181,8 @@ class TestFillFixtures:
                 return 7
         """
         )
-        testdir.syspathinsert()
-        testdir.makeconftest(
+        pytester.syspathinsert()
+        pytester.makeconftest(
             """
             import pytest
 
@@ -176,18 +193,18 @@ class TestFillFixtures:
                 return foo + 7
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_foo(foo):
                 assert foo == 14
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         assert result.ret == 0
 
-    def test_extend_fixture_plugin_plugin(self, testdir):
+    def test_extend_fixture_plugin_plugin(self, pytester: Pytester) -> None:
         # Two plugins should extend each order in loading order
-        testdir.makepyfile(
+        pytester.makepyfile(
             testplugin0="""
             import pytest
 
@@ -196,7 +213,7 @@ class TestFillFixtures:
                 return 7
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             testplugin1="""
             import pytest
 
@@ -205,8 +222,8 @@ class TestFillFixtures:
                 return foo + 7
         """
         )
-        testdir.syspathinsert()
-        testdir.makepyfile(
+        pytester.syspathinsert()
+        pytester.makepyfile(
             """
             pytest_plugins = ['testplugin0', 'testplugin1']
 
@@ -214,12 +231,14 @@ class TestFillFixtures:
                 assert foo == 14
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 0
 
-    def test_override_parametrized_fixture_conftest_module(self, testdir):
+    def test_override_parametrized_fixture_conftest_module(
+        self, pytester: Pytester
+    ) -> None:
         """Test override of the parametrized fixture with non-parametrized one on the test module level."""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -228,7 +247,7 @@ class TestFillFixtures:
                 return request.param
         """
         )
-        testfile = testdir.makepyfile(
+        testfile = pytester.makepyfile(
             """
             import pytest
 
@@ -240,14 +259,16 @@ class TestFillFixtures:
                 assert spam == 'spam'
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
-        result = testdir.runpytest(testfile)
+        result = pytester.runpytest(testfile)
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_override_parametrized_fixture_conftest_conftest(self, testdir):
+    def test_override_parametrized_fixture_conftest_conftest(
+        self, pytester: Pytester
+    ) -> None:
         """Test override of the parametrized fixture with non-parametrized one on the conftest level."""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -256,8 +277,8 @@ class TestFillFixtures:
                 return request.param
         """
         )
-        subdir = testdir.mkpydir("subdir")
-        subdir.join("conftest.py").write(
+        subdir = pytester.mkpydir("subdir")
+        subdir.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -266,25 +287,29 @@ class TestFillFixtures:
                 def spam():
                     return 'spam'
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        testfile = subdir.join("test_spam.py")
-        testfile.write(
+        testfile = subdir.joinpath("test_spam.py")
+        testfile.write_text(
             textwrap.dedent(
                 """\
                 def test_spam(spam):
                     assert spam == "spam"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
-        result = testdir.runpytest(testfile)
+        result = pytester.runpytest(testfile)
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_override_non_parametrized_fixture_conftest_module(self, testdir):
+    def test_override_non_parametrized_fixture_conftest_module(
+        self, pytester: Pytester
+    ) -> None:
         """Test override of the non-parametrized fixture with parametrized one on the test module level."""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -293,7 +318,7 @@ class TestFillFixtures:
                 return 'spam'
         """
         )
-        testfile = testdir.makepyfile(
+        testfile = pytester.makepyfile(
             """
             import pytest
 
@@ -308,14 +333,16 @@ class TestFillFixtures:
                 params['spam'] += 1
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*3 passed*"])
-        result = testdir.runpytest(testfile)
+        result = pytester.runpytest(testfile)
         result.stdout.fnmatch_lines(["*3 passed*"])
 
-    def test_override_non_parametrized_fixture_conftest_conftest(self, testdir):
+    def test_override_non_parametrized_fixture_conftest_conftest(
+        self, pytester: Pytester
+    ) -> None:
         """Test override of the non-parametrized fixture with parametrized one on the conftest level."""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -324,8 +351,8 @@ class TestFillFixtures:
                 return 'spam'
         """
         )
-        subdir = testdir.mkpydir("subdir")
-        subdir.join("conftest.py").write(
+        subdir = pytester.mkpydir("subdir")
+        subdir.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -334,10 +361,11 @@ class TestFillFixtures:
                 def spam(request):
                     return request.param
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        testfile = subdir.join("test_spam.py")
-        testfile.write(
+        testfile = subdir.joinpath("test_spam.py")
+        testfile.write_text(
             textwrap.dedent(
                 """\
                 params = {'spam': 1}
@@ -346,20 +374,21 @@ class TestFillFixtures:
                     assert spam == params['spam']
                     params['spam'] += 1
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*3 passed*"])
-        result = testdir.runpytest(testfile)
+        result = pytester.runpytest(testfile)
         result.stdout.fnmatch_lines(["*3 passed*"])
 
     def test_override_autouse_fixture_with_parametrized_fixture_conftest_conftest(
-        self, testdir
-    ):
+        self, pytester: Pytester
+    ) -> None:
         """Test override of the autouse fixture with parametrized one on the conftest level.
         This test covers the issue explained in issue 1601
         """
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -368,8 +397,8 @@ class TestFillFixtures:
                 return 'spam'
         """
         )
-        subdir = testdir.mkpydir("subdir")
-        subdir.join("conftest.py").write(
+        subdir = pytester.mkpydir("subdir")
+        subdir.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -378,10 +407,11 @@ class TestFillFixtures:
                 def spam(request):
                     return request.param
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        testfile = subdir.join("test_spam.py")
-        testfile.write(
+        testfile = subdir.joinpath("test_spam.py")
+        testfile.write_text(
             textwrap.dedent(
                 """\
                 params = {'spam': 1}
@@ -390,18 +420,21 @@ class TestFillFixtures:
                     assert spam == params['spam']
                     params['spam'] += 1
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*3 passed*"])
-        result = testdir.runpytest(testfile)
+        result = pytester.runpytest(testfile)
         result.stdout.fnmatch_lines(["*3 passed*"])
 
-    def test_override_fixture_reusing_super_fixture_parametrization(self, testdir):
+    def test_override_fixture_reusing_super_fixture_parametrization(
+        self, pytester: Pytester
+    ) -> None:
         """Override a fixture at a lower level, reusing the higher-level fixture that
         is parametrized (#1953).
         """
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -410,7 +443,7 @@ class TestFillFixtures:
                 return request.param
             """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -422,14 +455,16 @@ class TestFillFixtures:
                 assert foo in (2, 4)
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 passed*"])
 
-    def test_override_parametrize_fixture_and_indirect(self, testdir):
+    def test_override_parametrize_fixture_and_indirect(
+        self, pytester: Pytester
+    ) -> None:
         """Override a fixture at a lower level, reusing the higher-level fixture that
         is parametrized, while also using indirect parametrization.
         """
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -438,7 +473,7 @@ class TestFillFixtures:
                 return request.param
             """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -456,14 +491,14 @@ class TestFillFixtures:
                 assert foo in (2, 4)
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 passed*"])
 
     def test_override_top_level_fixture_reusing_super_fixture_parametrization(
-        self, testdir
-    ):
+        self, pytester: Pytester
+    ) -> None:
         """Same as the above test, but with another level of overwriting."""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -472,7 +507,7 @@ class TestFillFixtures:
                 return request.param
             """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -490,15 +525,17 @@ class TestFillFixtures:
                     assert foo in (2, 4)
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 passed*"])
 
-    def test_override_parametrized_fixture_with_new_parametrized_fixture(self, testdir):
+    def test_override_parametrized_fixture_with_new_parametrized_fixture(
+        self, pytester: Pytester
+    ) -> None:
         """Overriding a parametrized fixture, while also parametrizing the new fixture and
         simultaneously requesting the overwritten fixture as parameter, yields the same value
         as ``request.param``.
         """
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -507,7 +544,7 @@ class TestFillFixtures:
                 return request.param
             """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -520,13 +557,13 @@ class TestFillFixtures:
                 assert foo in (20, 40)
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 passed*"])
 
-    def test_autouse_fixture_plugin(self, testdir):
+    def test_autouse_fixture_plugin(self, pytester: Pytester) -> None:
         # A fixture from a plugin has no baseid set, which screwed up
         # the autouse fixture handling.
-        testdir.makepyfile(
+        pytester.makepyfile(
             testplugin="""
             import pytest
 
@@ -535,8 +572,8 @@ class TestFillFixtures:
                 request.function.foo = 7
         """
         )
-        testdir.syspathinsert()
-        testdir.makepyfile(
+        pytester.syspathinsert()
+        pytester.makepyfile(
             """
             pytest_plugins = 'testplugin'
 
@@ -544,11 +581,11 @@ class TestFillFixtures:
                 assert request.function.foo == 7
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 0
 
-    def test_funcarg_lookup_error(self, testdir):
-        testdir.makeconftest(
+    def test_funcarg_lookup_error(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
 
@@ -565,13 +602,13 @@ class TestFillFixtures:
             def d_fixture(): pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_lookup_error(unknown):
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "*ERROR at setup of test_lookup_error*",
@@ -585,9 +622,9 @@ class TestFillFixtures:
         )
         result.stdout.no_fnmatch_line("*INTERNAL*")
 
-    def test_fixture_excinfo_leak(self, testdir):
+    def test_fixture_excinfo_leak(self, pytester: Pytester) -> None:
         # on python2 sys.excinfo would leak into fixture executions
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import sys
             import traceback
@@ -606,13 +643,13 @@ class TestFillFixtures:
                 assert sys.exc_info() == (None, None, None)
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 0
 
 
 class TestRequestBasic:
-    def test_request_attributes(self, testdir):
-        item = testdir.getitem(
+    def test_request_attributes(self, pytester: Pytester) -> None:
+        item = pytester.getitem(
             """
             import pytest
 
@@ -621,6 +658,7 @@ class TestRequestBasic:
             def test_func(something): pass
         """
         )
+        assert isinstance(item, Function)
         req = fixtures.FixtureRequest(item, _ispytest=True)
         assert req.function == item.obj
         assert req.keywords == item.keywords
@@ -630,8 +668,8 @@ class TestRequestBasic:
         assert req.config == item.config
         assert repr(req).find(req.function.__name__) != -1
 
-    def test_request_attributes_method(self, testdir):
-        (item,) = testdir.getitems(
+    def test_request_attributes_method(self, pytester: Pytester) -> None:
+        (item,) = pytester.getitems(
             """
             import pytest
             class TestB(object):
@@ -643,12 +681,13 @@ class TestRequestBasic:
                     pass
         """
         )
+        assert isinstance(item, Function)
         req = item._request
         assert req.cls.__name__ == "TestB"
         assert req.instance.__class__ == req.cls
 
-    def test_request_contains_funcarg_arg2fixturedefs(self, testdir):
-        modcol = testdir.getmodulecol(
+    def test_request_contains_funcarg_arg2fixturedefs(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol(
             """
             import pytest
             @pytest.fixture
@@ -659,7 +698,7 @@ class TestRequestBasic:
                     pass
         """
         )
-        (item1,) = testdir.genitems([modcol])
+        (item1,) = pytester.genitems([modcol])
         assert item1.name == "test_method"
         arg2fixturedefs = fixtures.FixtureRequest(
             item1, _ispytest=True
@@ -671,14 +710,14 @@ class TestRequestBasic:
         hasattr(sys, "pypy_version_info"),
         reason="this method of test doesn't work on pypy",
     )
-    def test_request_garbage(self, testdir):
+    def test_request_garbage(self, pytester: Pytester) -> None:
         try:
             import xdist  # noqa
         except ImportError:
             pass
         else:
             pytest.xfail("this test is flaky when executed with xdist")
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import sys
             import pytest
@@ -704,11 +743,11 @@ class TestRequestBasic:
                 pass
         """
         )
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         result.stdout.fnmatch_lines(["* 1 passed in *"])
 
-    def test_getfixturevalue_recursive(self, testdir):
-        testdir.makeconftest(
+    def test_getfixturevalue_recursive(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
 
@@ -717,7 +756,7 @@ class TestRequestBasic:
                 return 1
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -728,10 +767,10 @@ class TestRequestBasic:
                 assert something == 2
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_getfixturevalue_teardown(self, testdir):
+    def test_getfixturevalue_teardown(self, pytester: Pytester) -> None:
         """
         Issue #1895
 
@@ -742,7 +781,7 @@ class TestRequestBasic:
         `inner` dependent on `resource` when it is used via `getfixturevalue`: `test_func`
         will then cause the `resource`'s finalizer to be called first because of this.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -766,24 +805,32 @@ class TestRequestBasic:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed in *"])
 
-    def test_getfixturevalue(self, testdir):
-        item = testdir.getitem(
+    def test_getfixturevalue(self, pytester: Pytester) -> None:
+        item = pytester.getitem(
             """
             import pytest
-            values = [2]
+
             @pytest.fixture
-            def something(request): return 1
+            def something(request):
+                return 1
+
+            values = [2]
             @pytest.fixture
             def other(request):
                 return values.pop()
+
             def test_func(something): pass
         """
         )
+        assert isinstance(item, Function)
         req = item._request
 
+        # Execute item's setup.
+        item.session._setupstate.setup(item)
+
         with pytest.raises(pytest.FixtureLookupError):
             req.getfixturevalue("notexists")
         val = req.getfixturevalue("something")
@@ -794,13 +841,12 @@ class TestRequestBasic:
         assert val2 == 2
         val2 = req.getfixturevalue("other")  # see about caching
         assert val2 == 2
-        item._request._fillfixtures()
         assert item.funcargs["something"] == 1
         assert len(get_public_names(item.funcargs)) == 2
         assert "request" in item.funcargs
 
-    def test_request_addfinalizer(self, testdir):
-        item = testdir.getitem(
+    def test_request_addfinalizer(self, pytester: Pytester) -> None:
+        item = pytester.getitem(
             """
             import pytest
             teardownlist = []
@@ -810,18 +856,21 @@ class TestRequestBasic:
             def test_func(something): pass
         """
         )
-        item.session._setupstate.prepare(item)
+        assert isinstance(item, Function)
+        item.session._setupstate.setup(item)
         item._request._fillfixtures()
         # successively check finalization calls
-        teardownlist = item.getparent(pytest.Module).obj.teardownlist
+        parent = item.getparent(pytest.Module)
+        assert parent is not None
+        teardownlist = parent.obj.teardownlist
         ss = item.session._setupstate
         assert not teardownlist
-        ss.teardown_exact(item, None)
+        ss.teardown_exact(None)
         print(ss.stack)
         assert teardownlist == [1]
 
-    def test_request_addfinalizer_failing_setup(self, testdir):
-        testdir.makepyfile(
+    def test_request_addfinalizer_failing_setup(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = [1]
@@ -835,11 +884,13 @@ class TestRequestBasic:
                 assert not values
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(failed=1, passed=1)
 
-    def test_request_addfinalizer_failing_setup_module(self, testdir):
-        testdir.makepyfile(
+    def test_request_addfinalizer_failing_setup_module(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = [1, 2]
@@ -852,12 +903,14 @@ class TestRequestBasic:
                 pass
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         mod = reprec.getcalls("pytest_runtest_setup")[0].item.module
         assert not mod.values
 
-    def test_request_addfinalizer_partial_setup_failure(self, testdir):
-        p = testdir.makepyfile(
+    def test_request_addfinalizer_partial_setup_failure(
+        self, pytester: Pytester
+    ) -> None:
+        p = pytester.makepyfile(
             """
             import pytest
             values = []
@@ -870,17 +923,19 @@ class TestRequestBasic:
                 assert len(values) == 1
         """
         )
-        result = testdir.runpytest(p)
+        result = pytester.runpytest(p)
         result.stdout.fnmatch_lines(
             ["*1 error*"]  # XXX the whole module collection fails
         )
 
-    def test_request_subrequest_addfinalizer_exceptions(self, testdir):
+    def test_request_subrequest_addfinalizer_exceptions(
+        self, pytester: Pytester
+    ) -> None:
         """
         Ensure exceptions raised during teardown by a finalizer are suppressed
         until all finalizers are called, re-raising the first exception (#2440)
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -904,19 +959,19 @@ class TestRequestBasic:
                 assert values == [3, 2, 1]
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             ["*Exception: Error in excepts fixture", "* 2 passed, 1 error in *"]
         )
 
-    def test_request_getmodulepath(self, testdir):
-        modcol = testdir.getmodulecol("def test_somefunc(): pass")
-        (item,) = testdir.genitems([modcol])
+    def test_request_getmodulepath(self, pytester: Pytester) -> None:
+        modcol = pytester.getmodulecol("def test_somefunc(): pass")
+        (item,) = pytester.genitems([modcol])
         req = fixtures.FixtureRequest(item, _ispytest=True)
-        assert req.fspath == modcol.fspath
+        assert req.path == modcol.path
 
-    def test_request_fixturenames(self, testdir):
-        testdir.makepyfile(
+    def test_request_fixturenames(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             from _pytest.pytester import get_public_names
@@ -927,25 +982,25 @@ class TestRequestBasic:
             def farg(arg1):
                 pass
             @pytest.fixture(autouse=True)
-            def sarg(tmpdir):
+            def sarg(tmp_path):
                 pass
             def test_function(request, farg):
                 assert set(get_public_names(request.fixturenames)) == \
-                       set(["tmpdir", "sarg", "arg1", "request", "farg",
+                       set(["sarg", "arg1", "request", "farg",
                             "tmp_path", "tmp_path_factory"])
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_request_fixturenames_dynamic_fixture(self, testdir):
+    def test_request_fixturenames_dynamic_fixture(self, pytester: Pytester) -> None:
         """Regression test for #3057"""
-        testdir.copy_example("fixtures/test_getfixturevalue_dynamic.py")
-        result = testdir.runpytest()
+        pytester.copy_example("fixtures/test_getfixturevalue_dynamic.py")
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_setupdecorator_and_xunit(self, testdir):
-        testdir.makepyfile(
+    def test_setupdecorator_and_xunit(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -973,13 +1028,14 @@ class TestRequestBasic:
                              "function", "method", "function"]
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=3)
 
-    def test_fixtures_sub_subdir_normalize_sep(self, testdir):
+    def test_fixtures_sub_subdir_normalize_sep(self, pytester: Pytester) -> None:
         # this tests that normalization of nodeids takes place
-        b = testdir.mkdir("tests").mkdir("unit")
-        b.join("conftest.py").write(
+        b = pytester.path.joinpath("tests", "unit")
+        b.mkdir(parents=True)
+        b.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -987,11 +1043,12 @@ class TestRequestBasic:
                 def arg1():
                     pass
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        p = b.join("test_module.py")
-        p.write("def test_func(arg1): pass")
-        result = testdir.runpytest(p, "--fixtures")
+        p = b.joinpath("test_module.py")
+        p.write_text("def test_func(arg1): pass", encoding="utf-8")
+        result = pytester.runpytest(p, "--fixtures")
         assert result.ret == 0
         result.stdout.fnmatch_lines(
             """
@@ -1000,13 +1057,13 @@ class TestRequestBasic:
         """
         )
 
-    def test_show_fixtures_color_yes(self, testdir):
-        testdir.makepyfile("def test_this(): assert 1")
-        result = testdir.runpytest("--color=yes", "--fixtures")
-        assert "\x1b[32mtmpdir" in result.stdout.str()
+    def test_show_fixtures_color_yes(self, pytester: Pytester) -> None:
+        pytester.makepyfile("def test_this(): assert 1")
+        result = pytester.runpytest("--color=yes", "--fixtures")
+        assert "\x1b[32mtmp_path" in result.stdout.str()
 
-    def test_newstyle_with_request(self, testdir):
-        testdir.makepyfile(
+    def test_newstyle_with_request(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture()
@@ -1016,11 +1073,11 @@ class TestRequestBasic:
                 pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_setupcontext_no_param(self, testdir):
-        testdir.makepyfile(
+    def test_setupcontext_no_param(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(params=[1,2])
@@ -1034,13 +1091,27 @@ class TestRequestBasic:
                 assert arg in (1,2)
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
 
+class TestRequestSessionScoped:
+    @pytest.fixture(scope="session")
+    def session_request(self, request):
+        return request
+
+    @pytest.mark.parametrize("name", ["path", "module"])
+    def test_session_scoped_unavailable_attributes(self, session_request, name):
+        with pytest.raises(
+            AttributeError,
+            match=f"{name} not available in session-scoped context",
+        ):
+            getattr(session_request, name)
+
+
 class TestRequestMarking:
-    def test_applymarker(self, testdir):
-        item1, item2 = testdir.getitems(
+    def test_applymarker(self, pytester: Pytester) -> None:
+        item1, item2 = pytester.getitems(
             """
             import pytest
 
@@ -1064,8 +1135,8 @@ class TestRequestMarking:
         with pytest.raises(ValueError):
             req1.applymarker(42)  # type: ignore[arg-type]
 
-    def test_accesskeywords(self, testdir):
-        testdir.makepyfile(
+    def test_accesskeywords(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture()
@@ -1077,11 +1148,11 @@ class TestRequestMarking:
                 assert "abc" not in keywords
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_accessmarker_dynamic(self, testdir):
-        testdir.makeconftest(
+    def test_accessmarker_dynamic(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             @pytest.fixture()
@@ -1093,7 +1164,7 @@ class TestRequestMarking:
                 request.applymarker(pytest.mark.XYZ("hello"))
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             def test_fun1(keywords):
@@ -1104,13 +1175,13 @@ class TestRequestMarking:
                 assert "abc" not in keywords
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
 
 class TestFixtureUsages:
-    def test_noargfixturedec(self, testdir):
-        testdir.makepyfile(
+    def test_noargfixturedec(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture
@@ -1121,11 +1192,11 @@ class TestFixtureUsages:
                 assert arg1 == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_receives_funcargs(self, testdir):
-        testdir.makepyfile(
+    def test_receives_funcargs(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture()
@@ -1143,11 +1214,11 @@ class TestFixtureUsages:
                 assert arg2 == 2
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_receives_funcargs_scope_mismatch(self, testdir):
-        testdir.makepyfile(
+    def test_receives_funcargs_scope_mismatch(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="function")
@@ -1162,7 +1233,7 @@ class TestFixtureUsages:
                 assert arg2 == 2
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "*ScopeMismatch*involved factories*",
@@ -1172,8 +1243,10 @@ class TestFixtureUsages:
             ]
         )
 
-    def test_receives_funcargs_scope_mismatch_issue660(self, testdir):
-        testdir.makepyfile(
+    def test_receives_funcargs_scope_mismatch_issue660(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="function")
@@ -1188,13 +1261,13 @@ class TestFixtureUsages:
                 assert arg2 == 2
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             ["*ScopeMismatch*involved factories*", "* def arg2*", "*1 error*"]
         )
 
-    def test_invalid_scope(self, testdir):
-        testdir.makepyfile(
+    def test_invalid_scope(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="functions")
@@ -1205,14 +1278,14 @@ class TestFixtureUsages:
                 pass
         """
         )
-        result = testdir.runpytest_inprocess()
+        result = pytester.runpytest_inprocess()
         result.stdout.fnmatch_lines(
             "*Fixture 'badscope' from test_invalid_scope.py got an unexpected scope value 'functions'"
         )
 
     @pytest.mark.parametrize("scope", ["function", "session"])
-    def test_parameters_without_eq_semantics(self, scope, testdir):
-        testdir.makepyfile(
+    def test_parameters_without_eq_semantics(self, scope, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             class NoEq1:  # fails on `a == b` statement
                 def __eq__(self, _):
@@ -1239,11 +1312,11 @@ class TestFixtureUsages:
                 scope=scope
             )
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*4 passed*"])
 
-    def test_funcarg_parametrized_and_used_twice(self, testdir):
-        testdir.makepyfile(
+    def test_funcarg_parametrized_and_used_twice(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -1261,11 +1334,13 @@ class TestFixtureUsages:
                 assert len(values) == arg1
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 passed*"])
 
-    def test_factory_uses_unknown_funcarg_as_dependency_error(self, testdir):
-        testdir.makepyfile(
+    def test_factory_uses_unknown_funcarg_as_dependency_error(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1281,7 +1356,7 @@ class TestFixtureUsages:
                 pass
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             """
             *pytest.fixture()*
@@ -1292,8 +1367,8 @@ class TestFixtureUsages:
         """
         )
 
-    def test_factory_setup_as_classes_fails(self, testdir):
-        testdir.makepyfile(
+    def test_factory_setup_as_classes_fails(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             class arg1(object):
@@ -1303,12 +1378,12 @@ class TestFixtureUsages:
 
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         values = reprec.getfailedcollections()
         assert len(values) == 1
 
-    def test_usefixtures_marker(self, testdir):
-        testdir.makepyfile(
+    def test_usefixtures_marker(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1329,17 +1404,17 @@ class TestFixtureUsages:
             pytest.mark.usefixtures("myfix")(TestClass)
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_usefixtures_ini(self, testdir):
-        testdir.makeini(
+    def test_usefixtures_ini(self, pytester: Pytester) -> None:
+        pytester.makeini(
             """
             [pytest]
             usefixtures = myfix
         """
         )
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -1349,7 +1424,7 @@ class TestFixtureUsages:
 
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             class TestClass(object):
                 def test_one(self):
@@ -1358,19 +1433,19 @@ class TestFixtureUsages:
                     assert self.hello == "world"
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_usefixtures_seen_in_showmarkers(self, testdir):
-        result = testdir.runpytest("--markers")
+    def test_usefixtures_seen_in_showmarkers(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("--markers")
         result.stdout.fnmatch_lines(
             """
             *usefixtures(fixturename1*mark tests*fixtures*
         """
         )
 
-    def test_request_instance_issue203(self, testdir):
-        testdir.makepyfile(
+    def test_request_instance_issue203(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1383,11 +1458,11 @@ class TestFixtureUsages:
                     assert self.arg1 == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_fixture_parametrized_with_iterator(self, testdir):
-        testdir.makepyfile(
+    def test_fixture_parametrized_with_iterator(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1410,14 +1485,14 @@ class TestFixtureUsages:
                 values.append(arg2*10)
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=4)
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         assert values == [1, 2, 10, 20]
 
-    def test_setup_functions_as_fixtures(self, testdir):
+    def test_setup_functions_as_fixtures(self, pytester: Pytester) -> None:
         """Ensure setup_* methods obey fixture scope rules (#517, #3094)."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1451,15 +1526,14 @@ class TestFixtureUsages:
                     pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed in *"])
 
 
 class TestFixtureManagerParseFactories:
     @pytest.fixture
-    def testdir(self, request):
-        testdir = request.getfixturevalue("testdir")
-        testdir.makeconftest(
+    def pytester(self, pytester: Pytester) -> Pytester:
+        pytester.makeconftest(
             """
             import pytest
 
@@ -1476,10 +1550,10 @@ class TestFixtureManagerParseFactories:
                 return request._pyfuncitem
         """
         )
-        return testdir
+        return pytester
 
-    def test_parsefactories_evil_objects_issue214(self, testdir):
-        testdir.makepyfile(
+    def test_parsefactories_evil_objects_issue214(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             class A(object):
                 def __call__(self):
@@ -1491,11 +1565,11 @@ class TestFixtureManagerParseFactories:
                 pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1, failed=0)
 
-    def test_parsefactories_conftest(self, testdir):
-        testdir.makepyfile(
+    def test_parsefactories_conftest(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             def test_hello(item, fm):
                 for name in ("fm", "hello", "item"):
@@ -1505,11 +1579,13 @@ class TestFixtureManagerParseFactories:
                     assert fac.func.__name__ == name
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=1)
 
-    def test_parsefactories_conftest_and_module_and_class(self, testdir):
-        testdir.makepyfile(
+    def test_parsefactories_conftest_and_module_and_class(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """\
             import pytest
 
@@ -1530,15 +1606,17 @@ class TestFixtureManagerParseFactories:
                     assert faclist[2].func(item._request) == "class"
             """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=1)
 
-    def test_parsefactories_relative_node_ids(self, testdir):
+    def test_parsefactories_relative_node_ids(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
         # example mostly taken from:
         # https://mail.python.org/pipermail/pytest-dev/2014-September/002617.html
-        runner = testdir.mkdir("runner")
-        package = testdir.mkdir("package")
-        package.join("conftest.py").write(
+        runner = pytester.mkdir("runner")
+        package = pytester.mkdir("package")
+        package.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
             import pytest
@@ -1546,19 +1624,22 @@ class TestFixtureManagerParseFactories:
             def one():
                 return 1
             """
-            )
+            ),
+            encoding="utf-8",
         )
-        package.join("test_x.py").write(
+        package.joinpath("test_x.py").write_text(
             textwrap.dedent(
                 """\
                 def test_x(one):
                     assert one == 1
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        sub = package.mkdir("sub")
-        sub.join("__init__.py").ensure()
-        sub.join("conftest.py").write(
+        sub = package.joinpath("sub")
+        sub.mkdir()
+        sub.joinpath("__init__.py").touch()
+        sub.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -1566,30 +1647,33 @@ class TestFixtureManagerParseFactories:
                 def one():
                     return 2
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        sub.join("test_y.py").write(
+        sub.joinpath("test_y.py").write_text(
             textwrap.dedent(
                 """\
                 def test_x(one):
                     assert one == 2
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
-        with runner.as_cwd():
-            reprec = testdir.inline_run("..")
+        with monkeypatch.context() as mp:
+            mp.chdir(runner)
+            reprec = pytester.inline_run("..")
             reprec.assertoutcome(passed=2)
 
-    def test_package_xunit_fixture(self, testdir):
-        testdir.makepyfile(
+    def test_package_xunit_fixture(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             __init__="""\
             values = []
         """
         )
-        package = testdir.mkdir("package")
-        package.join("__init__.py").write(
+        package = pytester.mkdir("package")
+        package.joinpath("__init__.py").write_text(
             textwrap.dedent(
                 """\
                 from .. import values
@@ -1598,19 +1682,21 @@ class TestFixtureManagerParseFactories:
                 def teardown_module():
                     values[:] = []
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        package.join("test_x.py").write(
+        package.joinpath("test_x.py").write_text(
             textwrap.dedent(
                 """\
                 from .. import values
                 def test_x():
                     assert values == ["package"]
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        package = testdir.mkdir("package2")
-        package.join("__init__.py").write(
+        package = pytester.mkdir("package2")
+        package.joinpath("__init__.py").write_text(
             textwrap.dedent(
                 """\
                 from .. import values
@@ -1619,30 +1705,32 @@ class TestFixtureManagerParseFactories:
                 def teardown_module():
                     values[:] = []
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        package.join("test_x.py").write(
+        package.joinpath("test_x.py").write_text(
             textwrap.dedent(
                 """\
                 from .. import values
                 def test_x():
                     assert values == ["package2"]
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_package_fixture_complex(self, testdir):
-        testdir.makepyfile(
+    def test_package_fixture_complex(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             __init__="""\
             values = []
         """
         )
-        testdir.syspathinsert(testdir.tmpdir.dirname)
-        package = testdir.mkdir("package")
-        package.join("__init__.py").write("")
-        package.join("conftest.py").write(
+        pytester.syspathinsert(pytester.path.name)
+        package = pytester.mkdir("package")
+        package.joinpath("__init__.py").write_text("", encoding="utf-8")
+        package.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -1658,9 +1746,10 @@ class TestFixtureManagerParseFactories:
                     yield values
                     values.pop()
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        package.join("test_x.py").write(
+        package.joinpath("test_x.py").write_text(
             textwrap.dedent(
                 """\
                 from .. import values
@@ -1669,29 +1758,30 @@ class TestFixtureManagerParseFactories:
                 def test_package(one):
                     assert values == ["package-auto", "package"]
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_collect_custom_items(self, testdir):
-        testdir.copy_example("fixtures/custom_item")
-        result = testdir.runpytest("foo")
+    def test_collect_custom_items(self, pytester: Pytester) -> None:
+        pytester.copy_example("fixtures/custom_item")
+        result = pytester.runpytest("foo")
         result.stdout.fnmatch_lines(["*passed*"])
 
 
 class TestAutouseDiscovery:
     @pytest.fixture
-    def testdir(self, testdir):
-        testdir.makeconftest(
+    def pytester(self, pytester: Pytester) -> Pytester:
+        pytester.makeconftest(
             """
             import pytest
             @pytest.fixture(autouse=True)
-            def perfunction(request, tmpdir):
+            def perfunction(request, tmp_path):
                 pass
 
             @pytest.fixture()
-            def arg1(tmpdir):
+            def arg1(tmp_path):
                 pass
             @pytest.fixture(autouse=True)
             def perfunction2(arg1):
@@ -1706,10 +1796,10 @@ class TestAutouseDiscovery:
                 return request._pyfuncitem
         """
         )
-        return testdir
+        return pytester
 
-    def test_parsefactories_conftest(self, testdir):
-        testdir.makepyfile(
+    def test_parsefactories_conftest(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             from _pytest.pytester import get_public_names
             def test_check_setup(item, fm):
@@ -1719,11 +1809,11 @@ class TestAutouseDiscovery:
                 assert "perfunction" in autousenames
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=1)
 
-    def test_two_classes_separated_autouse(self, testdir):
-        testdir.makepyfile(
+    def test_two_classes_separated_autouse(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             class TestA(object):
@@ -1742,11 +1832,11 @@ class TestAutouseDiscovery:
                     assert self.values == [1]
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_setup_at_classlevel(self, testdir):
-        testdir.makepyfile(
+    def test_setup_at_classlevel(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             class TestClass(object):
@@ -1759,12 +1849,12 @@ class TestAutouseDiscovery:
                     assert self.funcname == "test_method2"
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=2)
 
     @pytest.mark.xfail(reason="'enabled' feature not implemented")
-    def test_setup_enabled_functionnode(self, testdir):
-        testdir.makepyfile(
+    def test_setup_enabled_functionnode(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1787,13 +1877,13 @@ class TestAutouseDiscovery:
                 assert "db" in request.fixturenames
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=2)
 
-    def test_callables_nocode(self, testdir):
+    def test_callables_nocode(self, pytester: Pytester) -> None:
         """An imported mock.call would break setup/factory discovery due to
         it being callable and __code__ not being a code object."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
            class _call(tuple):
                def __call__(self, *k, **kw):
@@ -1804,13 +1894,13 @@ class TestAutouseDiscovery:
            call = _call()
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(failed=0, passed=0)
 
-    def test_autouse_in_conftests(self, testdir):
-        a = testdir.mkdir("a")
-        b = testdir.mkdir("a1")
-        conftest = testdir.makeconftest(
+    def test_autouse_in_conftests(self, pytester: Pytester) -> None:
+        a = pytester.mkdir("a")
+        b = pytester.mkdir("a1")
+        conftest = pytester.makeconftest(
             """
             import pytest
             @pytest.fixture(autouse=True)
@@ -1818,18 +1908,22 @@ class TestAutouseDiscovery:
                 xxx
         """
         )
-        conftest.move(a.join(conftest.basename))
-        a.join("test_something.py").write("def test_func(): pass")
-        b.join("test_otherthing.py").write("def test_func(): pass")
-        result = testdir.runpytest()
+        conftest.rename(a.joinpath(conftest.name))
+        a.joinpath("test_something.py").write_text(
+            "def test_func(): pass", encoding="utf-8"
+        )
+        b.joinpath("test_otherthing.py").write_text(
+            "def test_func(): pass", encoding="utf-8"
+        )
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             """
             *1 passed*1 error*
         """
         )
 
-    def test_autouse_in_module_and_two_classes(self, testdir):
-        testdir.makepyfile(
+    def test_autouse_in_module_and_two_classes(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -1850,14 +1944,14 @@ class TestAutouseDiscovery:
                     assert values == ["module", "module", "A", "module"], values
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=3)
 
 
 class TestAutouseManagement:
-    def test_autouse_conftest_mid_directory(self, testdir):
-        pkgdir = testdir.mkpydir("xyz123")
-        pkgdir.join("conftest.py").write(
+    def test_autouse_conftest_mid_directory(self, pytester: Pytester) -> None:
+        pkgdir = pytester.mkpydir("xyz123")
+        pkgdir.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -1866,23 +1960,28 @@ class TestAutouseManagement:
                     import sys
                     sys._myapp = "hello"
                 """
-            )
-        )
-        t = pkgdir.ensure("tests", "test_app.py")
-        t.write(
+            ),
+            encoding="utf-8",
+        )
+        sub = pkgdir.joinpath("tests")
+        sub.mkdir()
+        t = sub.joinpath("test_app.py")
+        t.touch()
+        t.write_text(
             textwrap.dedent(
                 """\
                 import sys
                 def test_app():
                     assert sys._myapp == "hello"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=1)
 
-    def test_funcarg_and_setup(self, testdir):
-        testdir.makepyfile(
+    def test_funcarg_and_setup(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -1905,11 +2004,11 @@ class TestAutouseManagement:
                 assert arg == 0
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_uses_parametrized_resource(self, testdir):
-        testdir.makepyfile(
+    def test_uses_parametrized_resource(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -1931,11 +2030,11 @@ class TestAutouseManagement:
 
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=2)
 
-    def test_session_parametrized_function(self, testdir):
-        testdir.makepyfile(
+    def test_session_parametrized_function(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1958,11 +2057,13 @@ class TestAutouseManagement:
                 assert values[:arg] == [1,2][:arg]
         """
         )
-        reprec = testdir.inline_run("-v", "-s")
+        reprec = pytester.inline_run("-v", "-s")
         reprec.assertoutcome(passed=4)
 
-    def test_class_function_parametrization_finalization(self, testdir):
-        p = testdir.makeconftest(
+    def test_class_function_parametrization_finalization(
+        self, pytester: Pytester
+    ) -> None:
+        p = pytester.makeconftest(
             """
             import pytest
             import pprint
@@ -1984,7 +2085,7 @@ class TestAutouseManagement:
                 request.addfinalizer(fin)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1996,17 +2097,16 @@ class TestAutouseManagement:
                     pass
         """
         )
-        confcut = f"--confcutdir={testdir.tmpdir}"
-        reprec = testdir.inline_run("-v", "-s", confcut)
+        reprec = pytester.inline_run("-v", "-s", "--confcutdir", pytester.path)
         reprec.assertoutcome(passed=8)
         config = reprec.getcalls("pytest_unconfigure")[0].config
-        values = config.pluginmanager._getconftestmodules(p, importmode="prepend")[
-            0
-        ].values
+        values = config.pluginmanager._getconftestmodules(
+            p, importmode="prepend", rootpath=pytester.path
+        )[0].values
         assert values == ["fin_a1", "fin_a2", "fin_b1", "fin_b2"] * 2
 
-    def test_scope_ordering(self, testdir):
-        testdir.makepyfile(
+    def test_scope_ordering(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2025,11 +2125,11 @@ class TestAutouseManagement:
                     assert values == [1,3,2]
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_parametrization_setup_teardown_ordering(self, testdir):
-        testdir.makepyfile(
+    def test_parametrization_setup_teardown_ordering(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2054,11 +2154,11 @@ class TestAutouseManagement:
                              "setup-2", "step1-2", "step2-2", "teardown-2",]
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=5)
 
-    def test_ordering_autouse_before_explicit(self, testdir):
-        testdir.makepyfile(
+    def test_ordering_autouse_before_explicit(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2073,14 +2173,16 @@ class TestAutouseManagement:
                 assert values == [1,2]
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
     @pytest.mark.parametrize("param1", ["", "params=[1]"], ids=["p00", "p01"])
     @pytest.mark.parametrize("param2", ["", "params=[1]"], ids=["p10", "p11"])
-    def test_ordering_dependencies_torndown_first(self, testdir, param1, param2):
+    def test_ordering_dependencies_torndown_first(
+        self, pytester: Pytester, param1, param2
+    ) -> None:
         """#226"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2100,13 +2202,13 @@ class TestAutouseManagement:
         """
             % locals()
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         reprec.assertoutcome(passed=2)
 
 
 class TestFixtureMarker:
-    def test_parametrize(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(params=["a", "b", "c"])
@@ -2119,11 +2221,11 @@ class TestFixtureMarker:
                 assert values == list("abc")
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=4)
 
-    def test_multiple_parametrization_issue_736(self, testdir):
-        testdir.makepyfile(
+    def test_multiple_parametrization_issue_736(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2137,19 +2239,21 @@ class TestFixtureMarker:
                 assert foobar in [4,5,6]
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=9)
 
     @pytest.mark.parametrize(
         "param_args",
         ["'fixt, val'", "'fixt,val'", "['fixt', 'val']", "('fixt', 'val')"],
     )
-    def test_override_parametrized_fixture_issue_979(self, testdir, param_args):
+    def test_override_parametrized_fixture_issue_979(
+        self, pytester: Pytester, param_args
+    ) -> None:
         """Make sure a parametrized argument can override a parametrized fixture.
 
         This was a regression introduced in the fix for #736.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2163,11 +2267,11 @@ class TestFixtureMarker:
         """
             % param_args
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_scope_session(self, testdir):
-        testdir.makepyfile(
+    def test_scope_session(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2187,11 +2291,11 @@ class TestFixtureMarker:
                     assert len(values) == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=3)
 
-    def test_scope_session_exc(self, testdir):
-        testdir.makepyfile(
+    def test_scope_session_exc(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2208,11 +2312,11 @@ class TestFixtureMarker:
                 assert values == [1]
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(skipped=2, passed=1)
 
-    def test_scope_session_exc_two_fix(self, testdir):
-        testdir.makepyfile(
+    def test_scope_session_exc_two_fix(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2234,11 +2338,11 @@ class TestFixtureMarker:
                 assert m == []
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(skipped=2, passed=1)
 
-    def test_scope_exc(self, testdir):
-        testdir.makepyfile(
+    def test_scope_exc(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_foo="""
                 def test_foo(fix):
                     pass
@@ -2263,11 +2367,11 @@ class TestFixtureMarker:
                     assert req_list == [1]
             """,
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(skipped=2, passed=1)
 
-    def test_scope_module_uses_session(self, testdir):
-        testdir.makepyfile(
+    def test_scope_module_uses_session(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2287,11 +2391,11 @@ class TestFixtureMarker:
                     assert len(values) == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=3)
 
-    def test_scope_module_and_finalizer(self, testdir):
-        testdir.makeconftest(
+    def test_scope_module_and_finalizer(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             finalized_list = []
@@ -2309,7 +2413,7 @@ class TestFixtureMarker:
                 return len(finalized_list)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_mod1="""
                 def test_1(arg, created, finalized):
                     assert created == 1
@@ -2327,11 +2431,11 @@ class TestFixtureMarker:
                     assert finalized == 2
             """,
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=4)
 
-    def test_scope_mismatch_various(self, testdir):
-        testdir.makeconftest(
+    def test_scope_mismatch_various(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             finalized = []
@@ -2341,7 +2445,7 @@ class TestFixtureMarker:
                 pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_mod1="""
                 import pytest
                 @pytest.fixture(scope="session")
@@ -2351,14 +2455,14 @@ class TestFixtureMarker:
                     pass
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret != 0
         result.stdout.fnmatch_lines(
             ["*ScopeMismatch*You tried*function*session*request*"]
         )
 
-    def test_dynamic_scope(self, testdir):
-        testdir.makeconftest(
+    def test_dynamic_scope(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
 
@@ -2381,7 +2485,7 @@ class TestFixtureMarker:
         """
         )
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_first(dynamic_fixture):
                 assert dynamic_fixture == 1
@@ -2393,14 +2497,14 @@ class TestFixtureMarker:
         """
         )
 
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-        reprec = testdir.inline_run("--extend-scope")
+        reprec = pytester.inline_run("--extend-scope")
         reprec.assertoutcome(passed=1, failed=1)
 
-    def test_dynamic_scope_bad_return(self, testdir):
-        testdir.makepyfile(
+    def test_dynamic_scope_bad_return(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2413,14 +2517,14 @@ class TestFixtureMarker:
 
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             "Fixture 'fixture' from test_dynamic_scope_bad_return.py "
             "got an unexpected scope value 'wrong-scope'"
         )
 
-    def test_register_only_with_mark(self, testdir):
-        testdir.makeconftest(
+    def test_register_only_with_mark(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             @pytest.fixture()
@@ -2428,7 +2532,7 @@ class TestFixtureMarker:
                 return 1
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_mod1="""
                 import pytest
                 @pytest.fixture()
@@ -2438,11 +2542,11 @@ class TestFixtureMarker:
                     assert arg == 2
             """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_parametrize_and_scope(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_and_scope(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="module", params=["a", "b", "c"])
@@ -2453,7 +2557,7 @@ class TestFixtureMarker:
                 values.append(arg)
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=3)
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         assert len(values) == 3
@@ -2461,8 +2565,8 @@ class TestFixtureMarker:
         assert "b" in values
         assert "c" in values
 
-    def test_scope_mismatch(self, testdir):
-        testdir.makeconftest(
+    def test_scope_mismatch(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             @pytest.fixture(scope="function")
@@ -2470,7 +2574,7 @@ class TestFixtureMarker:
                 pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="session")
@@ -2480,11 +2584,11 @@ class TestFixtureMarker:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*ScopeMismatch*", "*1 error*"])
 
-    def test_parametrize_separated_order(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_separated_order(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2499,19 +2603,19 @@ class TestFixtureMarker:
                 values.append(arg)
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=4)
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         assert values == [1, 1, 2, 2]
 
-    def test_module_parametrized_ordering(self, testdir):
-        testdir.makeini(
+    def test_module_parametrized_ordering(self, pytester: Pytester) -> None:
+        pytester.makeini(
             """
             [pytest]
             console_output_style=classic
         """
         )
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -2523,7 +2627,7 @@ class TestFixtureMarker:
                 pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_mod1="""
             def test_func(sarg):
                 pass
@@ -2541,7 +2645,7 @@ class TestFixtureMarker:
                 pass
         """,
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             """
             test_mod1.py::test_func[s1] PASSED
@@ -2563,14 +2667,14 @@ class TestFixtureMarker:
         """
         )
 
-    def test_dynamic_parametrized_ordering(self, testdir):
-        testdir.makeini(
+    def test_dynamic_parametrized_ordering(self, pytester: Pytester) -> None:
+        pytester.makeini(
             """
             [pytest]
             console_output_style=classic
         """
         )
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -2590,7 +2694,7 @@ class TestFixtureMarker:
                 pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test(reprovision):
                 pass
@@ -2598,7 +2702,7 @@ class TestFixtureMarker:
                 pass
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             """
             test_dynamic_parametrized_ordering.py::test[flavor1-vxlan] PASSED
@@ -2612,14 +2716,14 @@ class TestFixtureMarker:
         """
         )
 
-    def test_class_ordering(self, testdir):
-        testdir.makeini(
+    def test_class_ordering(self, pytester: Pytester) -> None:
+        pytester.makeini(
             """
             [pytest]
             console_output_style=classic
         """
         )
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -2640,7 +2744,7 @@ class TestFixtureMarker:
                 request.addfinalizer(fin)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2654,7 +2758,7 @@ class TestFixtureMarker:
                     pass
         """
         )
-        result = testdir.runpytest("-vs")
+        result = pytester.runpytest("-vs")
         result.stdout.re_match_lines(
             r"""
             test_class_ordering.py::TestClass2::test_1\[a-1\] PASSED
@@ -2672,8 +2776,10 @@ class TestFixtureMarker:
         """
         )
 
-    def test_parametrize_separated_order_higher_scope_first(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_separated_order_higher_scope_first(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2702,7 +2808,7 @@ class TestFixtureMarker:
                 values.append("test4")
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=12)
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         expected = [
@@ -2748,8 +2854,8 @@ class TestFixtureMarker:
         pprint.pprint(list(zip(values, expected)))
         assert values == expected
 
-    def test_parametrized_fixture_teardown_order(self, testdir):
-        testdir.makepyfile(
+    def test_parametrized_fixture_teardown_order(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(params=[1,2], scope="class")
@@ -2781,7 +2887,7 @@ class TestFixtureMarker:
                 assert not values
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             """
             *3 passed*
@@ -2789,8 +2895,8 @@ class TestFixtureMarker:
         )
         result.stdout.no_fnmatch_line("*error*")
 
-    def test_fixture_finalizer(self, testdir):
-        testdir.makeconftest(
+    def test_fixture_finalizer(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
             import sys
@@ -2799,13 +2905,13 @@ class TestFixtureMarker:
             def browser(request):
 
                 def finalize():
-                    sys.stdout.write('Finalized')
+                    sys.stdout.write_text('Finalized', encoding='utf-8')
                 request.addfinalizer(finalize)
                 return {}
         """
         )
-        b = testdir.mkdir("subdir")
-        b.join("test_overridden_fixture_finalizer.py").write(
+        b = pytester.mkdir("subdir")
+        b.joinpath("test_overridden_fixture_finalizer.py").write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -2817,14 +2923,15 @@ class TestFixtureMarker:
                 def test_browser(browser):
                     assert browser['visited'] is True
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.runpytest("-s")
+        reprec = pytester.runpytest("-s")
         for test in ["test_browser"]:
             reprec.stdout.fnmatch_lines(["*Finalized*"])
 
-    def test_class_scope_with_normal_tests(self, testdir):
-        testpath = testdir.makepyfile(
+    def test_class_scope_with_normal_tests(self, pytester: Pytester) -> None:
+        testpath = pytester.makepyfile(
             """
             import pytest
 
@@ -2847,12 +2954,12 @@ class TestFixtureMarker:
                 def test_c(self, a):
                     assert a == 3"""
         )
-        reprec = testdir.inline_run(testpath)
+        reprec = pytester.inline_run(testpath)
         for test in ["test_a", "test_b", "test_c"]:
             assert reprec.matchreport(test).passed
 
-    def test_request_is_clean(self, testdir):
-        testdir.makepyfile(
+    def test_request_is_clean(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2863,12 +2970,12 @@ class TestFixtureMarker:
                 pass
         """
         )
-        reprec = testdir.inline_run("-s")
+        reprec = pytester.inline_run("-s")
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         assert values == [1, 2]
 
-    def test_parametrize_separated_lifecycle(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_separated_lifecycle(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2884,7 +2991,7 @@ class TestFixtureMarker:
                 values.append(arg)
         """
         )
-        reprec = testdir.inline_run("-vs")
+        reprec = pytester.inline_run("-vs")
         reprec.assertoutcome(passed=4)
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         import pprint
@@ -2896,8 +3003,10 @@ class TestFixtureMarker:
         assert values[3] == values[4] == 2
         assert values[5] == "fin2"
 
-    def test_parametrize_function_scoped_finalizers_called(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_function_scoped_finalizers_called(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -2917,13 +3026,15 @@ class TestFixtureMarker:
                 assert values == [1, "fin1", 2, "fin2", 1, "fin1", 2, "fin2"]
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=5)
 
     @pytest.mark.parametrize("scope", ["session", "function", "module"])
-    def test_finalizer_order_on_parametrization(self, scope, testdir):
+    def test_finalizer_order_on_parametrization(
+        self, scope, pytester: Pytester
+    ) -> None:
         """#246"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2954,12 +3065,12 @@ class TestFixtureMarker:
         """
             % {"scope": scope}
         )
-        reprec = testdir.inline_run("-lvs")
+        reprec = pytester.inline_run("-lvs")
         reprec.assertoutcome(passed=3)
 
-    def test_class_scope_parametrization_ordering(self, testdir):
+    def test_class_scope_parametrization_ordering(self, pytester: Pytester) -> None:
         """#396"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -2980,7 +3091,7 @@ class TestFixtureMarker:
                     values.append("test_population")
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=6)
         values = reprec.getcalls("pytest_runtest_call")[0].item.module.values
         assert values == [
@@ -2996,8 +3107,8 @@ class TestFixtureMarker:
             "fin Doe",
         ]
 
-    def test_parametrize_setup_function(self, testdir):
-        testdir.makepyfile(
+    def test_parametrize_setup_function(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3026,11 +3137,13 @@ class TestFixtureMarker:
 
         """
         )
-        reprec = testdir.inline_run("-v")
+        reprec = pytester.inline_run("-v")
         reprec.assertoutcome(passed=6)
 
-    def test_fixture_marked_function_not_collected_as_test(self, testdir):
-        testdir.makepyfile(
+    def test_fixture_marked_function_not_collected_as_test(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture
@@ -3041,11 +3154,11 @@ class TestFixtureMarker:
                 assert test_app == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_params_and_ids(self, testdir):
-        testdir.makepyfile(
+    def test_params_and_ids(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3058,11 +3171,11 @@ class TestFixtureMarker:
                 assert 1
         """
         )
-        res = testdir.runpytest("-v")
+        res = pytester.runpytest("-v")
         res.stdout.fnmatch_lines(["*test_foo*alpha*", "*test_foo*beta*"])
 
-    def test_params_and_ids_yieldfixture(self, testdir):
-        testdir.makepyfile(
+    def test_params_and_ids_yieldfixture(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3074,12 +3187,14 @@ class TestFixtureMarker:
                 assert 1
         """
         )
-        res = testdir.runpytest("-v")
+        res = pytester.runpytest("-v")
         res.stdout.fnmatch_lines(["*test_foo*alpha*", "*test_foo*beta*"])
 
-    def test_deterministic_fixture_collection(self, testdir, monkeypatch):
+    def test_deterministic_fixture_collection(
+        self, pytester: Pytester, monkeypatch
+    ) -> None:
         """#920"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3104,36 +3219,36 @@ class TestFixtureMarker:
             """
         )
         monkeypatch.setenv("PYTHONHASHSEED", "1")
-        out1 = testdir.runpytest_subprocess("-v")
+        out1 = pytester.runpytest_subprocess("-v")
         monkeypatch.setenv("PYTHONHASHSEED", "2")
-        out2 = testdir.runpytest_subprocess("-v")
-        out1 = [
+        out2 = pytester.runpytest_subprocess("-v")
+        output1 = [
             line
             for line in out1.outlines
             if line.startswith("test_deterministic_fixture_collection.py::test_foo")
         ]
-        out2 = [
+        output2 = [
             line
             for line in out2.outlines
             if line.startswith("test_deterministic_fixture_collection.py::test_foo")
         ]
-        assert len(out1) == 12
-        assert out1 == out2
+        assert len(output1) == 12
+        assert output1 == output2
 
 
 class TestRequestScopeAccess:
     pytestmark = pytest.mark.parametrize(
         ("scope", "ok", "error"),
         [
-            ["session", "", "fspath class function module"],
-            ["module", "module fspath", "cls function"],
-            ["class", "module fspath cls", "function"],
-            ["function", "module fspath cls function", ""],
+            ["session", "", "path class function module"],
+            ["module", "module path", "cls function"],
+            ["class", "module path cls", "function"],
+            ["function", "module path cls function", ""],
         ],
     )
 
-    def test_setup(self, testdir, scope, ok, error):
-        testdir.makepyfile(
+    def test_setup(self, pytester: Pytester, scope, ok, error) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope=%r, autouse=True)
@@ -3150,11 +3265,11 @@ class TestRequestScopeAccess:
         """
             % (scope, ok.split(), error.split())
         )
-        reprec = testdir.inline_run("-l")
+        reprec = pytester.inline_run("-l")
         reprec.assertoutcome(passed=1)
 
-    def test_funcarg(self, testdir, scope, ok, error):
-        testdir.makepyfile(
+    def test_funcarg(self, pytester: Pytester, scope, ok, error) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope=%r)
@@ -3171,13 +3286,13 @@ class TestRequestScopeAccess:
         """
             % (scope, ok.split(), error.split())
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
 
 class TestErrors:
-    def test_subfactory_missing_funcarg(self, testdir):
-        testdir.makepyfile(
+    def test_subfactory_missing_funcarg(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture()
@@ -3187,14 +3302,14 @@ class TestErrors:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret != 0
         result.stdout.fnmatch_lines(
             ["*def gen(qwe123):*", "*fixture*qwe123*not found*", "*1 error*"]
         )
 
-    def test_issue498_fixture_finalizer_failing(self, testdir):
-        testdir.makepyfile(
+    def test_issue498_fixture_finalizer_failing(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture
@@ -3213,7 +3328,7 @@ class TestErrors:
                 assert values[0] != values[1]
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             """
             *ERROR*teardown*test_1*
@@ -3224,8 +3339,8 @@ class TestErrors:
         """
         )
 
-    def test_setupfunc_missing_funcarg(self, testdir):
-        testdir.makepyfile(
+    def test_setupfunc_missing_funcarg(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(autouse=True)
@@ -3235,7 +3350,7 @@ class TestErrors:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret != 0
         result.stdout.fnmatch_lines(
             ["*def gen(qwe123):*", "*fixture*qwe123*not found*", "*1 error*"]
@@ -3243,34 +3358,38 @@ class TestErrors:
 
 
 class TestShowFixtures:
-    def test_funcarg_compat(self, testdir):
-        config = testdir.parseconfigure("--funcargs")
+    def test_funcarg_compat(self, pytester: Pytester) -> None:
+        config = pytester.parseconfigure("--funcargs")
         assert config.option.showfixtures
 
-    def test_show_fixtures(self, testdir):
-        result = testdir.runpytest("--fixtures")
+    def test_show_help(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("--fixtures", "--help")
+        assert not result.ret
+
+    def test_show_fixtures(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("--fixtures")
         result.stdout.fnmatch_lines(
             [
-                "tmpdir_factory [[]session scope[]]",
+                "tmp_path_factory [[]session scope[]] -- .../_pytest/tmpdir.py:*",
                 "*for the test session*",
-                "tmpdir",
+                "tmp_path -- .../_pytest/tmpdir.py:*",
                 "*temporary directory*",
             ]
         )
 
-    def test_show_fixtures_verbose(self, testdir):
-        result = testdir.runpytest("--fixtures", "-v")
+    def test_show_fixtures_verbose(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("--fixtures", "-v")
         result.stdout.fnmatch_lines(
             [
-                "tmpdir_factory [[]session scope[]] -- *tmpdir.py*",
+                "tmp_path_factory [[]session scope[]] -- .../_pytest/tmpdir.py:*",
                 "*for the test session*",
-                "tmpdir -- *tmpdir.py*",
+                "tmp_path -- .../_pytest/tmpdir.py:*",
                 "*temporary directory*",
             ]
         )
 
-    def test_show_fixtures_testmodule(self, testdir):
-        p = testdir.makepyfile(
+    def test_show_fixtures_testmodule(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             '''
             import pytest
             @pytest.fixture
@@ -3281,20 +3400,20 @@ class TestShowFixtures:
                 """  hello world """
         '''
         )
-        result = testdir.runpytest("--fixtures", p)
+        result = pytester.runpytest("--fixtures", p)
         result.stdout.fnmatch_lines(
             """
-            *tmpdir
+            *tmp_path -- *
             *fixtures defined from*
-            *arg1*
+            *arg1 -- test_show_fixtures_testmodule.py:6*
             *hello world*
         """
         )
         result.stdout.no_fnmatch_line("*arg0*")
 
     @pytest.mark.parametrize("testmod", [True, False])
-    def test_show_fixtures_conftest(self, testdir, testmod):
-        testdir.makeconftest(
+    def test_show_fixtures_conftest(self, pytester: Pytester, testmod) -> None:
+        pytester.makeconftest(
             '''
             import pytest
             @pytest.fixture
@@ -3303,24 +3422,24 @@ class TestShowFixtures:
         '''
         )
         if testmod:
-            testdir.makepyfile(
+            pytester.makepyfile(
                 """
                 def test_hello():
                     pass
             """
             )
-        result = testdir.runpytest("--fixtures")
+        result = pytester.runpytest("--fixtures")
         result.stdout.fnmatch_lines(
             """
-            *tmpdir*
+            *tmp_path*
             *fixtures defined from*conftest*
             *arg1*
             *hello world*
         """
         )
 
-    def test_show_fixtures_trimmed_doc(self, testdir):
-        p = testdir.makepyfile(
+    def test_show_fixtures_trimmed_doc(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             textwrap.dedent(
                 '''\
                 import pytest
@@ -3341,23 +3460,23 @@ class TestShowFixtures:
                 '''
             )
         )
-        result = testdir.runpytest("--fixtures", p)
+        result = pytester.runpytest("--fixtures", p)
         result.stdout.fnmatch_lines(
             textwrap.dedent(
                 """\
                 * fixtures defined from test_show_fixtures_trimmed_doc *
-                arg2
+                arg2 -- test_show_fixtures_trimmed_doc.py:10
                     line1
                     line2
-                arg1
+                arg1 -- test_show_fixtures_trimmed_doc.py:3
                     line1
                     line2
                 """
             )
         )
 
-    def test_show_fixtures_indented_doc(self, testdir):
-        p = testdir.makepyfile(
+    def test_show_fixtures_indented_doc(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             textwrap.dedent(
                 '''\
                 import pytest
@@ -3370,20 +3489,22 @@ class TestShowFixtures:
                 '''
             )
         )
-        result = testdir.runpytest("--fixtures", p)
+        result = pytester.runpytest("--fixtures", p)
         result.stdout.fnmatch_lines(
             textwrap.dedent(
                 """\
                 * fixtures defined from test_show_fixtures_indented_doc *
-                fixture1
+                fixture1 -- test_show_fixtures_indented_doc.py:3
                     line1
                         indented line
                 """
             )
         )
 
-    def test_show_fixtures_indented_doc_first_line_unindented(self, testdir):
-        p = testdir.makepyfile(
+    def test_show_fixtures_indented_doc_first_line_unindented(
+        self, pytester: Pytester
+    ) -> None:
+        p = pytester.makepyfile(
             textwrap.dedent(
                 '''\
                 import pytest
@@ -3396,12 +3517,12 @@ class TestShowFixtures:
                 '''
             )
         )
-        result = testdir.runpytest("--fixtures", p)
+        result = pytester.runpytest("--fixtures", p)
         result.stdout.fnmatch_lines(
             textwrap.dedent(
                 """\
                 * fixtures defined from test_show_fixtures_indented_doc_first_line_unindented *
-                fixture1
+                fixture1 -- test_show_fixtures_indented_doc_first_line_unindented.py:3
                     line1
                     line2
                         indented line
@@ -3409,8 +3530,8 @@ class TestShowFixtures:
             )
         )
 
-    def test_show_fixtures_indented_in_class(self, testdir):
-        p = testdir.makepyfile(
+    def test_show_fixtures_indented_in_class(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             textwrap.dedent(
                 '''\
                 import pytest
@@ -3424,12 +3545,12 @@ class TestShowFixtures:
                 '''
             )
         )
-        result = testdir.runpytest("--fixtures", p)
+        result = pytester.runpytest("--fixtures", p)
         result.stdout.fnmatch_lines(
             textwrap.dedent(
                 """\
                 * fixtures defined from test_show_fixtures_indented_in_class *
-                fixture1
+                fixture1 -- test_show_fixtures_indented_in_class.py:4
                     line1
                     line2
                         indented line
@@ -3437,9 +3558,9 @@ class TestShowFixtures:
             )
         )
 
-    def test_show_fixtures_different_files(self, testdir):
+    def test_show_fixtures_different_files(self, pytester: Pytester) -> None:
         """`--fixtures` only shows fixtures from first file (#833)."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_a='''
             import pytest
 
@@ -3452,7 +3573,7 @@ class TestShowFixtures:
                 pass
         '''
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_b='''
             import pytest
 
@@ -3465,21 +3586,21 @@ class TestShowFixtures:
                 pass
         '''
         )
-        result = testdir.runpytest("--fixtures")
+        result = pytester.runpytest("--fixtures")
         result.stdout.fnmatch_lines(
             """
             * fixtures defined from test_a *
-            fix_a
+            fix_a -- test_a.py:4
                 Fixture A
 
             * fixtures defined from test_b *
-            fix_b
+            fix_b -- test_b.py:4
                 Fixture B
         """
         )
 
-    def test_show_fixtures_with_same_name(self, testdir):
-        testdir.makeconftest(
+    def test_show_fixtures_with_same_name(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             '''
             import pytest
             @pytest.fixture
@@ -3488,13 +3609,13 @@ class TestShowFixtures:
                 return "Hello World"
         '''
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_foo(arg1):
                 assert arg1 == "Hello World"
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             '''
             import pytest
             @pytest.fixture
@@ -3505,15 +3626,15 @@ class TestShowFixtures:
                 assert arg1 == "Hi"
         '''
         )
-        result = testdir.runpytest("--fixtures")
+        result = pytester.runpytest("--fixtures")
         result.stdout.fnmatch_lines(
             """
             * fixtures defined from conftest *
-            arg1
+            arg1 -- conftest.py:3
                 Hello World in conftest.py
 
             * fixtures defined from test_show_fixtures_with_same_name *
-            arg1
+            arg1 -- test_show_fixtures_with_same_name.py:3
                 Hi from test module
         """
         )
@@ -3529,8 +3650,8 @@ class TestShowFixtures:
 
 
 class TestContextManagerFixtureFuncs:
-    def test_simple(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_simple(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture
@@ -3545,7 +3666,7 @@ class TestContextManagerFixtureFuncs:
                 assert 0
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(
             """
             *setup*
@@ -3557,8 +3678,8 @@ class TestContextManagerFixtureFuncs:
         """
         )
 
-    def test_scoped(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_scoped(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="module")
@@ -3572,7 +3693,7 @@ class TestContextManagerFixtureFuncs:
                 print("test2", arg1)
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(
             """
             *setup*
@@ -3582,8 +3703,8 @@ class TestContextManagerFixtureFuncs:
         """
         )
 
-    def test_setup_exception(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_setup_exception(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="module")
@@ -3594,7 +3715,7 @@ class TestContextManagerFixtureFuncs:
                 pass
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(
             """
             *pytest.fail*setup*
@@ -3602,8 +3723,8 @@ class TestContextManagerFixtureFuncs:
         """
         )
 
-    def test_teardown_exception(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_teardown_exception(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="module")
@@ -3614,7 +3735,7 @@ class TestContextManagerFixtureFuncs:
                 pass
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(
             """
             *pytest.fail*teardown*
@@ -3622,8 +3743,8 @@ class TestContextManagerFixtureFuncs:
         """
         )
 
-    def test_yields_more_than_one(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_yields_more_than_one(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope="module")
@@ -3634,7 +3755,7 @@ class TestContextManagerFixtureFuncs:
                 pass
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(
             """
             *fixture function*
@@ -3642,8 +3763,8 @@ class TestContextManagerFixtureFuncs:
         """
         )
 
-    def test_custom_name(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_custom_name(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(name='meow')
@@ -3653,13 +3774,13 @@ class TestContextManagerFixtureFuncs:
                 print(meow)
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(["*mew*"])
 
 
 class TestParameterizedSubRequest:
-    def test_call_from_fixture(self, testdir):
-        testdir.makepyfile(
+    def test_call_from_fixture(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_call_from_fixture="""
             import pytest
 
@@ -3675,7 +3796,7 @@ class TestParameterizedSubRequest:
                 pass
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "The requested fixture has no parameter defined for test:",
@@ -3688,8 +3809,8 @@ class TestParameterizedSubRequest:
             ]
         )
 
-    def test_call_from_test(self, testdir):
-        testdir.makepyfile(
+    def test_call_from_test(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_call_from_test="""
             import pytest
 
@@ -3701,7 +3822,7 @@ class TestParameterizedSubRequest:
                 request.getfixturevalue('fix_with_param')
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "The requested fixture has no parameter defined for test:",
@@ -3714,8 +3835,8 @@ class TestParameterizedSubRequest:
             ]
         )
 
-    def test_external_fixture(self, testdir):
-        testdir.makeconftest(
+    def test_external_fixture(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import pytest
 
@@ -3725,13 +3846,13 @@ class TestParameterizedSubRequest:
             """
         )
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_external_fixture="""
             def test_foo(request):
                 request.getfixturevalue('fix_with_param')
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "The requested fixture has no parameter defined for test:",
@@ -3745,11 +3866,11 @@ class TestParameterizedSubRequest:
             ]
         )
 
-    def test_non_relative_path(self, testdir):
-        tests_dir = testdir.mkdir("tests")
-        fixdir = testdir.mkdir("fixtures")
-        fixfile = fixdir.join("fix.py")
-        fixfile.write(
+    def test_non_relative_path(self, pytester: Pytester) -> None:
+        tests_dir = pytester.mkdir("tests")
+        fixdir = pytester.mkdir("fixtures")
+        fixfile = fixdir.joinpath("fix.py")
+        fixfile.write_text(
             textwrap.dedent(
                 """\
                 import pytest
@@ -3758,11 +3879,12 @@ class TestParameterizedSubRequest:
                 def fix_with_param(request):
                     return request.param
                 """
-            )
+            ),
+            encoding="utf-8",
         )
 
-        testfile = tests_dir.join("test_foos.py")
-        testfile.write(
+        testfile = tests_dir.joinpath("test_foos.py")
+        testfile.write_text(
             textwrap.dedent(
                 """\
                 from fix import fix_with_param
@@ -3770,12 +3892,13 @@ class TestParameterizedSubRequest:
                 def test_foo(request):
                     request.getfixturevalue('fix_with_param')
                 """
-            )
+            ),
+            encoding="utf-8",
         )
 
-        tests_dir.chdir()
-        testdir.syspathinsert(fixdir)
-        result = testdir.runpytest()
+        os.chdir(tests_dir)
+        pytester.syspathinsert(fixdir)
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "The requested fixture has no parameter defined for test:",
@@ -3790,9 +3913,9 @@ class TestParameterizedSubRequest:
         )
 
         # With non-overlapping rootdir, passing tests_dir.
-        rootdir = testdir.mkdir("rootdir")
-        rootdir.chdir()
-        result = testdir.runpytest("--rootdir", rootdir, tests_dir)
+        rootdir = pytester.mkdir("rootdir")
+        os.chdir(rootdir)
+        result = pytester.runpytest("--rootdir", rootdir, tests_dir)
         result.stdout.fnmatch_lines(
             [
                 "The requested fixture has no parameter defined for test:",
@@ -3807,8 +3930,8 @@ class TestParameterizedSubRequest:
         )
 
 
-def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
-    testdir.makeconftest(
+def test_pytest_fixture_setup_and_post_finalizer_hook(pytester: Pytester) -> None:
+    pytester.makeconftest(
         """
         def pytest_fixture_setup(fixturedef, request):
             print('ROOT setup hook called for {0} from {1}'.format(fixturedef.argname, request.node.name))
@@ -3816,7 +3939,7 @@ def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
             print('ROOT finalizer hook called for {0} from {1}'.format(fixturedef.argname, request.node.name))
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         **{
             "tests/conftest.py": """
             def pytest_fixture_setup(fixturedef, request):
@@ -3837,7 +3960,7 @@ def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
         """,
         }
     )
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
     assert result.ret == 0
     result.stdout.fnmatch_lines(
         [
@@ -3854,10 +3977,12 @@ class TestScopeOrdering:
     """Class of tests that ensure fixtures are ordered based on their scopes (#2405)"""
 
     @pytest.mark.parametrize("variant", ["mark", "autouse"])
-    def test_func_closure_module_auto(self, testdir, variant, monkeypatch):
+    def test_func_closure_module_auto(
+        self, pytester: Pytester, variant, monkeypatch
+    ) -> None:
         """Semantically identical to the example posted in #2405 when ``use_mark=True``"""
         monkeypatch.setenv("FIXTURE_ACTIVATION_VARIANT", variant)
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import warnings
             import os
@@ -3883,16 +4008,18 @@ class TestScopeOrdering:
                 pass
         """
         )
-        items, _ = testdir.inline_genitems()
+        items, _ = pytester.inline_genitems()
         request = FixtureRequest(items[0], _ispytest=True)
         assert request.fixturenames == "m1 f1".split()
 
-    def test_func_closure_with_native_fixtures(self, testdir, monkeypatch) -> None:
+    def test_func_closure_with_native_fixtures(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
         """Sanity check that verifies the order returned by the closures and the actual fixture execution order:
         The execution order may differ because of fixture inter-dependencies.
         """
         monkeypatch.setattr(pytest, "FIXTURE_ORDER", [], raising=False)
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3911,15 +4038,15 @@ class TestScopeOrdering:
                 FIXTURE_ORDER.append('m1')
 
             @pytest.fixture(scope='session')
-            def my_tmpdir_factory():
-                FIXTURE_ORDER.append('my_tmpdir_factory')
+            def my_tmp_path_factory():
+                FIXTURE_ORDER.append('my_tmp_path_factory')
 
             @pytest.fixture
-            def my_tmpdir(my_tmpdir_factory):
-                FIXTURE_ORDER.append('my_tmpdir')
+            def my_tmp_path(my_tmp_path_factory):
+                FIXTURE_ORDER.append('my_tmp_path')
 
             @pytest.fixture
-            def f1(my_tmpdir):
+            def f1(my_tmp_path):
                 FIXTURE_ORDER.append('f1')
 
             @pytest.fixture
@@ -3929,19 +4056,20 @@ class TestScopeOrdering:
             def test_foo(f1, p1, m1, f2, s1): pass
         """
         )
-        items, _ = testdir.inline_genitems()
+        items, _ = pytester.inline_genitems()
         request = FixtureRequest(items[0], _ispytest=True)
         # order of fixtures based on their scope and position in the parameter list
         assert (
-            request.fixturenames == "s1 my_tmpdir_factory p1 m1 f1 f2 my_tmpdir".split()
+            request.fixturenames
+            == "s1 my_tmp_path_factory p1 m1 f1 f2 my_tmp_path".split()
         )
-        testdir.runpytest()
-        # actual fixture execution differs: dependent fixtures must be created first ("my_tmpdir")
+        pytester.runpytest()
+        # actual fixture execution differs: dependent fixtures must be created first ("my_tmp_path")
         FIXTURE_ORDER = pytest.FIXTURE_ORDER  # type: ignore[attr-defined]
-        assert FIXTURE_ORDER == "s1 my_tmpdir_factory p1 m1 my_tmpdir f1 f2".split()
+        assert FIXTURE_ORDER == "s1 my_tmp_path_factory p1 m1 my_tmp_path f1 f2".split()
 
-    def test_func_closure_module(self, testdir):
-        testdir.makepyfile(
+    def test_func_closure_module(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3955,15 +4083,15 @@ class TestScopeOrdering:
                 pass
         """
         )
-        items, _ = testdir.inline_genitems()
+        items, _ = pytester.inline_genitems()
         request = FixtureRequest(items[0], _ispytest=True)
         assert request.fixturenames == "m1 f1".split()
 
-    def test_func_closure_scopes_reordered(self, testdir):
+    def test_func_closure_scopes_reordered(self, pytester: Pytester) -> None:
         """Test ensures that fixtures are ordered by scope regardless of the order of the parameters, although
         fixtures of same scope keep the declared order
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -3988,13 +4116,15 @@ class TestScopeOrdering:
                     pass
         """
         )
-        items, _ = testdir.inline_genitems()
+        items, _ = pytester.inline_genitems()
         request = FixtureRequest(items[0], _ispytest=True)
         assert request.fixturenames == "s1 m1 c1 f2 f1".split()
 
-    def test_func_closure_same_scope_closer_root_first(self, testdir):
+    def test_func_closure_same_scope_closer_root_first(
+        self, pytester: Pytester
+    ) -> None:
         """Auto-use fixtures of same scope are ordered by closer-to-root first"""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -4002,7 +4132,7 @@ class TestScopeOrdering:
             def m_conf(): pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             **{
                 "sub/conftest.py": """
                 import pytest
@@ -4028,13 +4158,13 @@ class TestScopeOrdering:
         """,
             }
         )
-        items, _ = testdir.inline_genitems()
+        items, _ = pytester.inline_genitems()
         request = FixtureRequest(items[0], _ispytest=True)
         assert request.fixturenames == "p_sub m_conf m_sub m_test f1".split()
 
-    def test_func_closure_all_scopes_complex(self, testdir):
+    def test_func_closure_all_scopes_complex(self, pytester: Pytester) -> None:
         """Complex test involving all scopes and mixing autouse with normal fixtures"""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -4045,8 +4175,8 @@ class TestScopeOrdering:
             def p1(): pass
         """
         )
-        testdir.makepyfile(**{"__init__.py": ""})
-        testdir.makepyfile(
+        pytester.makepyfile(**{"__init__.py": ""})
+        pytester.makepyfile(
             """
             import pytest
 
@@ -4072,11 +4202,11 @@ class TestScopeOrdering:
                     pass
         """
         )
-        items, _ = testdir.inline_genitems()
+        items, _ = pytester.inline_genitems()
         request = FixtureRequest(items[0], _ispytest=True)
         assert request.fixturenames == "s1 p1 m1 m2 c1 f2 f1".split()
 
-    def test_multiple_packages(self, testdir):
+    def test_multiple_packages(self, pytester: Pytester) -> None:
         """Complex test involving multiple package fixtures. Make sure teardowns
         are executed in order.
         .
@@ -4091,11 +4221,12 @@ class TestScopeOrdering:
                 ├── conftest.py
                 └── test_2.py
         """
-        root = testdir.mkdir("root")
-        root.join("__init__.py").write("values = []")
-        sub1 = root.mkdir("sub1")
-        sub1.ensure("__init__.py")
-        sub1.join("conftest.py").write(
+        root = pytester.mkdir("root")
+        root.joinpath("__init__.py").write_text("values = []", encoding="utf-8")
+        sub1 = root.joinpath("sub1")
+        sub1.mkdir()
+        sub1.joinpath("__init__.py").touch()
+        sub1.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
             import pytest
@@ -4106,20 +4237,23 @@ class TestScopeOrdering:
                 yield values
                 assert values.pop() == "pre-sub1"
         """
-            )
+            ),
+            encoding="utf-8",
         )
-        sub1.join("test_1.py").write(
+        sub1.joinpath("test_1.py").write_text(
             textwrap.dedent(
                 """\
             from .. import values
             def test_1(fix):
                 assert values == ["pre-sub1"]
         """
-            )
+            ),
+            encoding="utf-8",
         )
-        sub2 = root.mkdir("sub2")
-        sub2.ensure("__init__.py")
-        sub2.join("conftest.py").write(
+        sub2 = root.joinpath("sub2")
+        sub2.mkdir()
+        sub2.joinpath("__init__.py").touch()
+        sub2.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
             import pytest
@@ -4130,25 +4264,27 @@ class TestScopeOrdering:
                 yield values
                 assert values.pop() == "pre-sub2"
         """
-            )
+            ),
+            encoding="utf-8",
         )
-        sub2.join("test_2.py").write(
+        sub2.joinpath("test_2.py").write_text(
             textwrap.dedent(
                 """\
             from .. import values
             def test_2(fix):
                 assert values == ["pre-sub2"]
         """
-            )
+            ),
+            encoding="utf-8",
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_class_fixture_self_instance(self, testdir):
+    def test_class_fixture_self_instance(self, pytester: Pytester) -> None:
         """Check that plugin classes which implement fixtures receive the plugin instance
         as self (see #2270).
         """
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import pytest
 
@@ -4166,14 +4302,14 @@ class TestScopeOrdering:
         """
         )
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             class TestClass(object):
                 def test_1(self, myfix):
                     assert myfix == 1
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
 
@@ -4188,9 +4324,9 @@ def test_call_fixture_function_error():
         assert fix() == 1
 
 
-def test_fixture_param_shadowing(testdir):
+def test_fixture_param_shadowing(pytester: Pytester) -> None:
     """Parametrized arguments would be shadowed if a fixture with the same name also exists (#5036)"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
 
@@ -4223,7 +4359,7 @@ def test_fixture_param_shadowing(testdir):
     """
     )
     # Only one test should have run
-    result = testdir.runpytest("-v")
+    result = pytester.runpytest("-v")
     result.assert_outcomes(passed=4)
     result.stdout.fnmatch_lines(["*::test_direct[[]1[]]*"])
     result.stdout.fnmatch_lines(["*::test_normal_fixture[[]a[]]*"])
@@ -4231,9 +4367,9 @@ def test_fixture_param_shadowing(testdir):
     result.stdout.fnmatch_lines(["*::test_indirect[[]1[]]*"])
 
 
-def test_fixture_named_request(testdir):
-    testdir.copy_example("fixtures/test_fixture_named_request.py")
-    result = testdir.runpytest()
+def test_fixture_named_request(pytester: Pytester) -> None:
+    pytester.copy_example("fixtures/test_fixture_named_request.py")
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*'request' is a reserved word for fixtures, use another name:",
@@ -4242,9 +4378,9 @@ def test_fixture_named_request(testdir):
     )
 
 
-def test_indirect_fixture_does_not_break_scope(testdir):
+def test_indirect_fixture_does_not_break_scope(pytester: Pytester) -> None:
     """Ensure that fixture scope is respected when using indirect fixtures (#570)"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         instantiated  = []
@@ -4289,14 +4425,14 @@ def test_indirect_fixture_does_not_break_scope(testdir):
             ]
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(passed=7)
 
 
-def test_fixture_parametrization_nparray(testdir):
+def test_fixture_parametrization_nparray(pytester: Pytester) -> None:
     pytest.importorskip("numpy")
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         from numpy import linspace
         from pytest import fixture
@@ -4309,18 +4445,18 @@ def test_fixture_parametrization_nparray(testdir):
             assert value == value
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(passed=10)
 
 
-def test_fixture_arg_ordering(testdir):
+def test_fixture_arg_ordering(pytester: Pytester) -> None:
     """
     This test describes how fixtures in the same scope but without explicit dependencies
     between them are created. While users should make dependencies explicit, often
     they rely on this order, so this test exists to catch regressions in this regard.
     See #6540 and #6492.
     """
-    p1 = testdir.makepyfile(
+    p1 = pytester.makepyfile(
         """
         import pytest
 
@@ -4344,12 +4480,12 @@ def test_fixture_arg_ordering(testdir):
             assert suffixes == ["fix_1", "fix_2", "fix_3", "fix_4", "fix_5"]
         """
     )
-    result = testdir.runpytest("-vv", str(p1))
+    result = pytester.runpytest("-vv", str(p1))
     assert result.ret == 0
 
 
-def test_yield_fixture_with_no_value(testdir):
-    testdir.makepyfile(
+def test_yield_fixture_with_no_value(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
         @pytest.fixture(name='custom')
@@ -4362,7 +4498,7 @@ def test_yield_fixture_with_no_value(testdir):
         """
     )
     expected = "E               ValueError: custom did not yield a value"
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(errors=1)
     result.stdout.fnmatch_lines([expected])
     assert result.ret == ExitCode.TESTS_FAILED
index f006e5ed4eee4e807d91655907cdd194cc275182..054c14a39e4396631ba2c789b9f88b5183e46dea 100644 (file)
@@ -1,77 +1,8 @@
-from typing import Any
-
 import pytest
-from _pytest import runner
 from _pytest._code import getfslineno
-
-
-class TestOEJSKITSpecials:
-    def test_funcarg_non_pycollectobj(
-        self, testdir, recwarn
-    ) -> None:  # rough jstests usage
-        testdir.makeconftest(
-            """
-            import pytest
-            def pytest_pycollect_makeitem(collector, name, obj):
-                if name == "MyClass":
-                    return MyCollector.from_parent(collector, name=name)
-            class MyCollector(pytest.Collector):
-                def reportinfo(self):
-                    return self.fspath, 3, "xyz"
-        """
-        )
-        modcol = testdir.getmodulecol(
-            """
-            import pytest
-            @pytest.fixture
-            def arg1(request):
-                return 42
-            class MyClass(object):
-                pass
-        """
-        )
-        # this hook finds funcarg factories
-        rep = runner.collect_one_node(collector=modcol)
-        # TODO: Don't treat as Any.
-        clscol: Any = rep.result[0]
-        clscol.obj = lambda arg1: None
-        clscol.funcargs = {}
-        pytest._fillfuncargs(clscol)
-        assert clscol.funcargs["arg1"] == 42
-
-    def test_autouse_fixture(self, testdir, recwarn) -> None:  # rough jstests usage
-        testdir.makeconftest(
-            """
-            import pytest
-            def pytest_pycollect_makeitem(collector, name, obj):
-                if name == "MyClass":
-                    return MyCollector.from_parent(collector, name=name)
-            class MyCollector(pytest.Collector):
-                def reportinfo(self):
-                    return self.fspath, 3, "xyz"
-        """
-        )
-        modcol = testdir.getmodulecol(
-            """
-            import pytest
-            @pytest.fixture(autouse=True)
-            def hello():
-                pass
-            @pytest.fixture
-            def arg1(request):
-                return 42
-            class MyClass(object):
-                pass
-        """
-        )
-        # this hook finds funcarg factories
-        rep = runner.collect_one_node(modcol)
-        # TODO: Don't treat as Any.
-        clscol: Any = rep.result[0]
-        clscol.obj = lambda: None
-        clscol.funcargs = {}
-        pytest._fillfuncargs(clscol)
-        assert not clscol.funcargs
+from _pytest.fixtures import getfixturemarker
+from _pytest.pytester import Pytester
+from _pytest.python import Function
 
 
 def test_wrapped_getfslineno() -> None:
@@ -125,8 +56,8 @@ class TestMockDecoration:
         values = getfuncargnames(f)
         assert values == ("y", "z")
 
-    def test_unittest_mock(self, testdir):
-        testdir.makepyfile(
+    def test_unittest_mock(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import unittest.mock
             class T(unittest.TestCase):
@@ -137,11 +68,11 @@ class TestMockDecoration:
                     abspath.assert_any_call("hello")
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_unittest_mock_and_fixture(self, testdir):
-        testdir.makepyfile(
+    def test_unittest_mock_and_fixture(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import os.path
             import unittest.mock
@@ -158,12 +89,12 @@ class TestMockDecoration:
                 os.path.abspath("hello")
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_unittest_mock_and_pypi_mock(self, testdir):
+    def test_unittest_mock_and_pypi_mock(self, pytester: Pytester) -> None:
         pytest.importorskip("mock", "1.0.1")
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import mock
             import unittest.mock
@@ -181,15 +112,15 @@ class TestMockDecoration:
                     abspath.assert_any_call("hello")
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_mock_sentinel_check_against_numpy_like(self, testdir):
+    def test_mock_sentinel_check_against_numpy_like(self, pytester: Pytester) -> None:
         """Ensure our function that detects mock arguments compares against sentinels using
         identity to circumvent objects which can't be compared with equality against others
         in a truth context, like with numpy arrays (#5606).
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             dummy="""
             class NumpyLike:
                 def __init__(self, value):
@@ -199,7 +130,7 @@ class TestMockDecoration:
             FOO = NumpyLike(10)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             from unittest.mock import patch
             import dummy
@@ -209,12 +140,12 @@ class TestMockDecoration:
                     assert dummy.FOO.value == 50
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
-    def test_mock(self, testdir):
+    def test_mock(self, pytester: Pytester) -> None:
         pytest.importorskip("mock", "1.0.1")
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import os
             import unittest
@@ -230,14 +161,14 @@ class TestMockDecoration:
             @mock.patch("os.path.abspath")
             @mock.patch("os.path.normpath")
             @mock.patch("os.path.basename", new=mock_basename)
-            def test_someting(normpath, abspath, tmpdir):
+            def test_someting(normpath, abspath, tmp_path):
                 abspath.return_value = "this"
                 os.path.normpath(os.path.abspath("hello"))
                 normpath.assert_any_call("this")
                 assert os.path.basename("123") == "mock_basename"
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
         calls = reprec.getcalls("pytest_runtest_logreport")
         funcnames = [
@@ -245,9 +176,9 @@ class TestMockDecoration:
         ]
         assert funcnames == ["T.test_hello", "test_someting"]
 
-    def test_mock_sorting(self, testdir):
+    def test_mock_sorting(self, pytester: Pytester) -> None:
         pytest.importorskip("mock", "1.0.1")
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import os
             import mock
@@ -263,15 +194,15 @@ class TestMockDecoration:
                 pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         calls = reprec.getreports("pytest_runtest_logreport")
         calls = [x for x in calls if x.when == "call"]
         names = [x.nodeid.split("::")[-1] for x in calls]
         assert names == ["test_one", "test_two", "test_three"]
 
-    def test_mock_double_patch_issue473(self, testdir):
+    def test_mock_double_patch_issue473(self, pytester: Pytester) -> None:
         pytest.importorskip("mock", "1.0.1")
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             from mock import patch
             from pytest import mark
@@ -284,13 +215,13 @@ class TestMockDecoration:
                     pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=1)
 
 
 class TestReRunTests:
-    def test_rerun(self, testdir):
-        testdir.makeconftest(
+    def test_rerun(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             from _pytest.runner import runtestprotocol
             def pytest_runtest_protocol(item, nextitem):
@@ -298,7 +229,7 @@ class TestReRunTests:
                 runtestprotocol(item, log=True, nextitem=nextitem)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             count = 0
@@ -314,7 +245,7 @@ class TestReRunTests:
                 pass
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         result.stdout.fnmatch_lines(
             """
             *fix count 0*
@@ -331,26 +262,27 @@ class TestReRunTests:
 def test_pytestconfig_is_session_scoped() -> None:
     from _pytest.fixtures import pytestconfig
 
-    marker = pytestconfig._pytestfixturefunction  # type: ignore
+    marker = getfixturemarker(pytestconfig)
+    assert marker is not None
     assert marker.scope == "session"
 
 
 class TestNoselikeTestAttribute:
-    def test_module_with_global_test(self, testdir):
-        testdir.makepyfile(
+    def test_module_with_global_test(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             __test__ = False
             def test_hello():
                 pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         assert not reprec.getfailedcollections()
         calls = reprec.getreports("pytest_runtest_logreport")
         assert not calls
 
-    def test_class_and_method(self, testdir):
-        testdir.makepyfile(
+    def test_class_and_method(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             __test__ = True
             def test_func():
@@ -363,13 +295,13 @@ class TestNoselikeTestAttribute:
                     pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         assert not reprec.getfailedcollections()
         calls = reprec.getreports("pytest_runtest_logreport")
         assert not calls
 
-    def test_unittest_class(self, testdir):
-        testdir.makepyfile(
+    def test_unittest_class(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import unittest
             class TC(unittest.TestCase):
@@ -381,20 +313,20 @@ class TestNoselikeTestAttribute:
                     pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         assert not reprec.getfailedcollections()
         call = reprec.getcalls("pytest_collection_modifyitems")[0]
         assert len(call.items) == 1
         assert call.items[0].cls.__name__ == "TC"
 
-    def test_class_with_nasty_getattr(self, testdir):
+    def test_class_with_nasty_getattr(self, pytester: Pytester) -> None:
         """Make sure we handle classes with a custom nasty __getattr__ right.
 
         With a custom __getattr__ which e.g. returns a function (like with a
         RPC wrapper), we shouldn't assume this meant "__test__ = True".
         """
         # https://github.com/pytest-dev/pytest/issues/1204
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             class MetaModel(type):
 
@@ -413,7 +345,7 @@ class TestNoselikeTestAttribute:
                     pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         assert not reprec.getfailedcollections()
         call = reprec.getcalls("pytest_collection_modifyitems")[0]
         assert not call.items
@@ -422,8 +354,8 @@ class TestNoselikeTestAttribute:
 class TestParameterize:
     """#351"""
 
-    def test_idfn_marker(self, testdir):
-        testdir.makepyfile(
+    def test_idfn_marker(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -440,11 +372,11 @@ class TestParameterize:
                 pass
         """
         )
-        res = testdir.runpytest("--collect-only")
+        res = pytester.runpytest("--collect-only")
         res.stdout.fnmatch_lines(["*spam-2*", "*ham-2*"])
 
-    def test_idfn_fixture(self, testdir):
-        testdir.makepyfile(
+    def test_idfn_fixture(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -468,5 +400,30 @@ class TestParameterize:
                 pass
         """
         )
-        res = testdir.runpytest("--collect-only")
+        res = pytester.runpytest("--collect-only")
         res.stdout.fnmatch_lines(["*spam-2*", "*ham-2*"])
+
+
+def test_function_instance(pytester: Pytester) -> None:
+    items = pytester.getitems(
+        """
+        def test_func(): pass
+        class TestIt:
+            def test_method(self): pass
+            @classmethod
+            def test_class(cls): pass
+            @staticmethod
+            def test_static(): pass
+        """
+    )
+    assert len(items) == 4
+    assert isinstance(items[0], Function)
+    assert items[0].name == "test_func"
+    assert items[0].instance is None
+    assert isinstance(items[1], Function)
+    assert items[1].name == "test_method"
+    assert items[1].instance is not None
+    assert items[1].instance.__class__.__name__ == "TestIt"
+    assert isinstance(items[3], Function)
+    assert items[3].name == "test_static"
+    assert items[3].instance is None
index 676f1d988bc26a91d88042a6e971715a9d48ed42..a9e9b526934cc930a997a0f2cee788bb332a0693 100644 (file)
@@ -1,3 +1,4 @@
+import dataclasses
 import itertools
 import re
 import sys
@@ -12,7 +13,6 @@ from typing import Sequence
 from typing import Tuple
 from typing import Union
 
-import attr
 import hypothesis
 from hypothesis import strategies
 
@@ -23,9 +23,9 @@ from _pytest.compat import _format_args
 from _pytest.compat import getfuncargnames
 from _pytest.compat import NOTSET
 from _pytest.outcomes import fail
-from _pytest.pytester import Testdir
-from _pytest.python import _idval
-from _pytest.python import idmaker
+from _pytest.pytester import Pytester
+from _pytest.python import IdMaker
+from _pytest.scope import Scope
 
 
 class TestMetafunc:
@@ -39,15 +39,15 @@ class TestMetafunc:
             def __init__(self, names):
                 self.names_closure = names
 
-        @attr.s
+        @dataclasses.dataclass
         class DefinitionMock(python.FunctionDefinition):
-            obj = attr.ib()
-            _nodeid = attr.ib()
+            _nodeid: str
+            obj: object
 
         names = getfuncargnames(func)
         fixtureinfo: Any = FuncFixtureInfoMock(names)
-        definition: Any = DefinitionMock._create(func, "mock::nodeid")
-        return python.Metafunc(definition, fixtureinfo, config)
+        definition: Any = DefinitionMock._create(obj=func, _nodeid="mock::nodeid")
+        return python.Metafunc(definition, fixtureinfo, config, _ispytest=True)
 
     def test_no_funcargs(self) -> None:
         def function():
@@ -106,8 +106,8 @@ class TestMetafunc:
         with pytest.raises(
             fail.Exception,
             match=(
-                r"In func: ids must be list of string/float/int/bool, found:"
-                r" Exc\(from_gen\) \(type: <class .*Exc'>\) at index 2"
+                r"In func: ids contains unsupported value Exc\(from_gen\) \(type: <class .*Exc'>\) at index 2. "
+                r"Supported types are: .*"
             ),
         ):
             metafunc.parametrize("x", [1, 2, 3], ids=gen())  # type: ignore[arg-type]
@@ -123,7 +123,7 @@ class TestMetafunc:
         ):
             metafunc.parametrize("x", [1], scope="doggy")  # type: ignore[arg-type]
 
-    def test_parametrize_request_name(self, testdir: Testdir) -> None:
+    def test_parametrize_request_name(self, pytester: Pytester) -> None:
         """Show proper error  when 'request' is used as a parameter name in parametrize (#6183)"""
 
         def func(request):
@@ -140,18 +140,18 @@ class TestMetafunc:
         """Unit test for _find_parametrized_scope (#3941)."""
         from _pytest.python import _find_parametrized_scope
 
-        @attr.s
+        @dataclasses.dataclass
         class DummyFixtureDef:
-            scope = attr.ib()
+            _scope: Scope
 
         fixtures_defs = cast(
             Dict[str, Sequence[fixtures.FixtureDef[object]]],
             dict(
-                session_fix=[DummyFixtureDef("session")],
-                package_fix=[DummyFixtureDef("package")],
-                module_fix=[DummyFixtureDef("module")],
-                class_fix=[DummyFixtureDef("class")],
-                func_fix=[DummyFixtureDef("function")],
+                session_fix=[DummyFixtureDef(Scope.Session)],
+                package_fix=[DummyFixtureDef(Scope.Package)],
+                module_fix=[DummyFixtureDef(Scope.Module)],
+                class_fix=[DummyFixtureDef(Scope.Class)],
+                func_fix=[DummyFixtureDef(Scope.Function)],
             ),
         )
 
@@ -160,29 +160,33 @@ class TestMetafunc:
         def find_scope(argnames, indirect):
             return _find_parametrized_scope(argnames, fixtures_defs, indirect=indirect)
 
-        assert find_scope(["func_fix"], indirect=True) == "function"
-        assert find_scope(["class_fix"], indirect=True) == "class"
-        assert find_scope(["module_fix"], indirect=True) == "module"
-        assert find_scope(["package_fix"], indirect=True) == "package"
-        assert find_scope(["session_fix"], indirect=True) == "session"
+        assert find_scope(["func_fix"], indirect=True) == Scope.Function
+        assert find_scope(["class_fix"], indirect=True) == Scope.Class
+        assert find_scope(["module_fix"], indirect=True) == Scope.Module
+        assert find_scope(["package_fix"], indirect=True) == Scope.Package
+        assert find_scope(["session_fix"], indirect=True) == Scope.Session
 
-        assert find_scope(["class_fix", "func_fix"], indirect=True) == "function"
-        assert find_scope(["func_fix", "session_fix"], indirect=True) == "function"
-        assert find_scope(["session_fix", "class_fix"], indirect=True) == "class"
-        assert find_scope(["package_fix", "session_fix"], indirect=True) == "package"
-        assert find_scope(["module_fix", "session_fix"], indirect=True) == "module"
+        assert find_scope(["class_fix", "func_fix"], indirect=True) == Scope.Function
+        assert find_scope(["func_fix", "session_fix"], indirect=True) == Scope.Function
+        assert find_scope(["session_fix", "class_fix"], indirect=True) == Scope.Class
+        assert (
+            find_scope(["package_fix", "session_fix"], indirect=True) == Scope.Package
+        )
+        assert find_scope(["module_fix", "session_fix"], indirect=True) == Scope.Module
 
         # when indirect is False or is not for all scopes, always use function
-        assert find_scope(["session_fix", "module_fix"], indirect=False) == "function"
+        assert (
+            find_scope(["session_fix", "module_fix"], indirect=False) == Scope.Function
+        )
         assert (
             find_scope(["session_fix", "module_fix"], indirect=["module_fix"])
-            == "function"
+            == Scope.Function
         )
         assert (
             find_scope(
                 ["session_fix", "module_fix"], indirect=["session_fix", "module_fix"]
             )
-            == "module"
+            == Scope.Module
         )
 
     def test_parametrize_and_id(self) -> None:
@@ -281,7 +285,7 @@ class TestMetafunc:
         deadline=400.0
     )  # very close to std deadline and CI boxes are not reliable in CPU power
     def test_idval_hypothesis(self, value) -> None:
-        escaped = _idval(value, "a", 6, None, nodeid=None, config=None)
+        escaped = IdMaker([], [], None, None, None, None, None)._idval(value, "a", 6)
         assert isinstance(escaped, str)
         escaped.encode("ascii")
 
@@ -303,7 +307,10 @@ class TestMetafunc:
             ),
         ]
         for val, expected in values:
-            assert _idval(val, "a", 6, None, nodeid=None, config=None) == expected
+            assert (
+                IdMaker([], [], None, None, None, None, None)._idval(val, "a", 6)
+                == expected
+            )
 
     def test_unicode_idval_with_config(self) -> None:
         """Unit test for expected behavior to obtain ids with
@@ -331,7 +338,7 @@ class TestMetafunc:
             ("ação", MockConfig({option: False}), "a\\xe7\\xe3o"),
         ]
         for val, config, expected in values:
-            actual = _idval(val, "a", 6, None, nodeid=None, config=config)
+            actual = IdMaker([], [], None, None, config, None, None)._idval(val, "a", 6)
             assert actual == expected
 
     def test_bytes_idval(self) -> None:
@@ -344,7 +351,10 @@ class TestMetafunc:
             ("αρά".encode(), r"\xce\xb1\xcf\x81\xce\xac"),
         ]
         for val, expected in values:
-            assert _idval(val, "a", 6, idfn=None, nodeid=None, config=None) == expected
+            assert (
+                IdMaker([], [], None, None, None, None, None)._idval(val, "a", 6)
+                == expected
+            )
 
     def test_class_or_function_idval(self) -> None:
         """Unit test for the expected behavior to obtain ids for parametrized
@@ -358,7 +368,10 @@ class TestMetafunc:
 
         values = [(TestClass, "TestClass"), (test_function, "test_function")]
         for val, expected in values:
-            assert _idval(val, "a", 6, None, nodeid=None, config=None) == expected
+            assert (
+                IdMaker([], [], None, None, None, None, None)._idval(val, "a", 6)
+                == expected
+            )
 
     def test_notset_idval(self) -> None:
         """Test that a NOTSET value (used by an empty parameterset) generates
@@ -366,29 +379,47 @@ class TestMetafunc:
 
         Regression test for #7686.
         """
-        assert _idval(NOTSET, "a", 0, None, nodeid=None, config=None) == "a0"
+        assert (
+            IdMaker([], [], None, None, None, None, None)._idval(NOTSET, "a", 0) == "a0"
+        )
 
     def test_idmaker_autoname(self) -> None:
         """#250"""
-        result = idmaker(
-            ("a", "b"), [pytest.param("string", 1.0), pytest.param("st-ring", 2.0)]
-        )
+        result = IdMaker(
+            ("a", "b"),
+            [pytest.param("string", 1.0), pytest.param("st-ring", 2.0)],
+            None,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["string-1.0", "st-ring-2.0"]
 
-        result = idmaker(
-            ("a", "b"), [pytest.param(object(), 1.0), pytest.param(object(), object())]
-        )
+        result = IdMaker(
+            ("a", "b"),
+            [pytest.param(object(), 1.0), pytest.param(object(), object())],
+            None,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["a0-1.0", "a1-b1"]
         # unicode mixing, issue250
-        result = idmaker(("a", "b"), [pytest.param({}, b"\xc3\xb4")])
+        result = IdMaker(
+            ("a", "b"), [pytest.param({}, b"\xc3\xb4")], None, None, None, None, None
+        ).make_unique_parameterset_ids()
         assert result == ["a0-\\xc3\\xb4"]
 
     def test_idmaker_with_bytes_regex(self) -> None:
-        result = idmaker(("a"), [pytest.param(re.compile(b"foo"), 1.0)])
+        result = IdMaker(
+            ("a"), [pytest.param(re.compile(b"foo"), 1.0)], None, None, None, None, None
+        ).make_unique_parameterset_ids()
         assert result == ["foo"]
 
     def test_idmaker_native_strings(self) -> None:
-        result = idmaker(
+        result = IdMaker(
             ("a", "b"),
             [
                 pytest.param(1.0, -1.1),
@@ -403,8 +434,14 @@ class TestMetafunc:
                 pytest.param(tuple("eight"), (8, -8, 8)),
                 pytest.param(b"\xc3\xb4", b"name"),
                 pytest.param(b"\xc3\xb4", "other"),
+                pytest.param(1.0j, -2.0j),
             ],
-        )
+            None,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == [
             "1.0--1.1",
             "2--202",
@@ -418,10 +455,11 @@ class TestMetafunc:
             "a9-b9",
             "\\xc3\\xb4-name",
             "\\xc3\\xb4-other",
+            "1j-(-0-2j)",
         ]
 
     def test_idmaker_non_printable_characters(self) -> None:
-        result = idmaker(
+        result = IdMaker(
             ("s", "n"),
             [
                 pytest.param("\x00", 1),
@@ -431,23 +469,35 @@ class TestMetafunc:
                 pytest.param("\t", 5),
                 pytest.param(b"\t", 6),
             ],
-        )
+            None,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["\\x00-1", "\\x05-2", "\\x00-3", "\\x05-4", "\\t-5", "\\t-6"]
 
     def test_idmaker_manual_ids_must_be_printable(self) -> None:
-        result = idmaker(
+        result = IdMaker(
             ("s",),
             [
                 pytest.param("x00", id="hello \x00"),
                 pytest.param("x05", id="hello \x05"),
             ],
-        )
+            None,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["hello \\x00", "hello \\x05"]
 
     def test_idmaker_enum(self) -> None:
         enum = pytest.importorskip("enum")
         e = enum.Enum("Foo", "one, two")
-        result = idmaker(("a", "b"), [pytest.param(e.one, e.two)])
+        result = IdMaker(
+            ("a", "b"), [pytest.param(e.one, e.two)], None, None, None, None, None
+        ).make_unique_parameterset_ids()
         assert result == ["Foo.one-Foo.two"]
 
     def test_idmaker_idfn(self) -> None:
@@ -458,15 +508,19 @@ class TestMetafunc:
                 return repr(val)
             return None
 
-        result = idmaker(
+        result = IdMaker(
             ("a", "b"),
             [
                 pytest.param(10.0, IndexError()),
                 pytest.param(20, KeyError()),
                 pytest.param("three", [1, 2, 3]),
             ],
-            idfn=ids,
-        )
+            ids,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["10.0-IndexError()", "20-KeyError()", "three-b2"]
 
     def test_idmaker_idfn_unique_names(self) -> None:
@@ -475,15 +529,19 @@ class TestMetafunc:
         def ids(val: object) -> str:
             return "a"
 
-        result = idmaker(
+        result = IdMaker(
             ("a", "b"),
             [
                 pytest.param(10.0, IndexError()),
                 pytest.param(20, KeyError()),
                 pytest.param("three", [1, 2, 3]),
             ],
-            idfn=ids,
-        )
+            ids,
+            None,
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["a-a0", "a-a1", "a-a2"]
 
     def test_idmaker_with_idfn_and_config(self) -> None:
@@ -513,9 +571,15 @@ class TestMetafunc:
             (MockConfig({option: False}), "a\\xe7\\xe3o"),
         ]
         for config, expected in values:
-            result = idmaker(
-                ("a",), [pytest.param("string")], idfn=lambda _: "ação", config=config,
-            )
+            result = IdMaker(
+                ("a",),
+                [pytest.param("string")],
+                lambda _: "ação",
+                None,
+                config,
+                None,
+                None,
+            ).make_unique_parameterset_ids()
             assert result == [expected]
 
     def test_idmaker_with_ids_and_config(self) -> None:
@@ -545,17 +609,17 @@ class TestMetafunc:
             (MockConfig({option: False}), "a\\xe7\\xe3o"),
         ]
         for config, expected in values:
-            result = idmaker(
-                ("a",), [pytest.param("string")], ids=["ação"], config=config,
-            )
+            result = IdMaker(
+                ("a",), [pytest.param("string")], None, ["ação"], config, None, None
+            ).make_unique_parameterset_ids()
             assert result == [expected]
 
-    def test_parametrize_ids_exception(self, testdir: Testdir) -> None:
+    def test_parametrize_ids_exception(self, pytester: Pytester) -> None:
         """
-        :param testdir: the instance of Testdir class, a temporary
+        :param pytester: the instance of Pytester class, a temporary
         test directory.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
                 import pytest
 
@@ -567,7 +631,7 @@ class TestMetafunc:
                     pass
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
                 "*Exception: bad ids",
@@ -575,8 +639,8 @@ class TestMetafunc:
             ]
         )
 
-    def test_parametrize_ids_returns_non_string(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_ids_returns_non_string(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """\
             import pytest
 
@@ -592,7 +656,7 @@ class TestMetafunc:
                 assert arg
             """
         )
-        result = testdir.runpytest("-vv", "-s")
+        result = pytester.runpytest("-vv", "-s")
         result.stdout.fnmatch_lines(
             [
                 "test_parametrize_ids_returns_non_string.py::test[arg0] PASSED",
@@ -604,23 +668,39 @@ class TestMetafunc:
         )
 
     def test_idmaker_with_ids(self) -> None:
-        result = idmaker(
-            ("a", "b"), [pytest.param(1, 2), pytest.param(3, 4)], ids=["a", None]
-        )
+        result = IdMaker(
+            ("a", "b"),
+            [pytest.param(1, 2), pytest.param(3, 4)],
+            None,
+            ["a", None],
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["a", "3-4"]
 
     def test_idmaker_with_paramset_id(self) -> None:
-        result = idmaker(
+        result = IdMaker(
             ("a", "b"),
             [pytest.param(1, 2, id="me"), pytest.param(3, 4, id="you")],
-            ids=["a", None],
-        )
+            None,
+            ["a", None],
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["me", "you"]
 
     def test_idmaker_with_ids_unique_names(self) -> None:
-        result = idmaker(
-            ("a"), map(pytest.param, [1, 2, 3, 4, 5]), ids=["a", "a", "b", "c", "b"]
-        )
+        result = IdMaker(
+            ("a"),
+            list(map(pytest.param, [1, 2, 3, 4, 5])),
+            None,
+            ["a", "a", "b", "c", "b"],
+            None,
+            None,
+            None,
+        ).make_unique_parameterset_ids()
         assert result == ["a0", "a1", "b0", "c", "b1"]
 
     def test_parametrize_indirect(self) -> None:
@@ -682,18 +762,17 @@ class TestMetafunc:
         ):
             metafunc.parametrize("x, y", [("a", "b")], indirect={})  # type: ignore[arg-type]
 
-    def test_parametrize_indirect_list_functional(self, testdir: Testdir) -> None:
+    def test_parametrize_indirect_list_functional(self, pytester: Pytester) -> None:
         """
         #714
         Test parametrization with 'indirect' parameter applied on
-        particular arguments. As y is is direct, its value should
-        be used directly rather than being passed to the fixture
-        y.
+        particular arguments. As y is direct, its value should
+        be used directly rather than being passed to the fixture y.
 
-        :param testdir: the instance of Testdir class, a temporary
+        :param pytester: the instance of Pytester class, a temporary
         test directory.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope='function')
@@ -708,7 +787,7 @@ class TestMetafunc:
                 assert len(y) == 1
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(["*test_simple*a-b*", "*1 passed*"])
 
     def test_parametrize_indirect_list_error(self) -> None:
@@ -722,7 +801,7 @@ class TestMetafunc:
             metafunc.parametrize("x, y", [("a", "b")], indirect=["x", "z"])
 
     def test_parametrize_uses_no_fixture_error_indirect_false(
-        self, testdir: Testdir
+        self, pytester: Pytester
     ) -> None:
         """The 'uses no fixture' error tells the user at collection time
         that the parametrize data they've set up doesn't correspond to the
@@ -731,7 +810,7 @@ class TestMetafunc:
 
         #714
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -740,14 +819,14 @@ class TestMetafunc:
                 assert len(x) == 3
         """
         )
-        result = testdir.runpytest("--collect-only")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*uses no argument 'y'*"])
 
     def test_parametrize_uses_no_fixture_error_indirect_true(
-        self, testdir: Testdir
+        self, pytester: Pytester
     ) -> None:
         """#714"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope='function')
@@ -762,14 +841,14 @@ class TestMetafunc:
                 assert len(x) == 3
         """
         )
-        result = testdir.runpytest("--collect-only")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*uses no fixture 'y'*"])
 
     def test_parametrize_indirect_uses_no_fixture_error_indirect_string(
-        self, testdir: Testdir
+        self, pytester: Pytester
     ) -> None:
         """#714"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope='function')
@@ -781,14 +860,14 @@ class TestMetafunc:
                 assert len(x) == 3
         """
         )
-        result = testdir.runpytest("--collect-only")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*uses no fixture 'y'*"])
 
     def test_parametrize_indirect_uses_no_fixture_error_indirect_list(
-        self, testdir: Testdir
+        self, pytester: Pytester
     ) -> None:
         """#714"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope='function')
@@ -800,12 +879,14 @@ class TestMetafunc:
                 assert len(x) == 3
         """
         )
-        result = testdir.runpytest("--collect-only")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*uses no fixture 'y'*"])
 
-    def test_parametrize_argument_not_in_indirect_list(self, testdir: Testdir) -> None:
+    def test_parametrize_argument_not_in_indirect_list(
+        self, pytester: Pytester
+    ) -> None:
         """#714"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture(scope='function')
@@ -817,13 +898,13 @@ class TestMetafunc:
                 assert len(x) == 3
         """
         )
-        result = testdir.runpytest("--collect-only")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(["*uses no argument 'y'*"])
 
     def test_parametrize_gives_indicative_error_on_function_with_default_argument(
-        self, testdir
+        self, pytester: Pytester
     ) -> None:
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -832,13 +913,13 @@ class TestMetafunc:
                 assert len(x) == 1
         """
         )
-        result = testdir.runpytest("--collect-only")
+        result = pytester.runpytest("--collect-only")
         result.stdout.fnmatch_lines(
             ["*already takes an argument 'y' with a default value"]
         )
 
-    def test_parametrize_functional(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_functional(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def pytest_generate_tests(metafunc):
@@ -853,7 +934,7 @@ class TestMetafunc:
                 assert y == 2
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             ["*test_simple*1-2*", "*test_simple*2-2*", "*2 passed*"]
         )
@@ -884,8 +965,8 @@ class TestMetafunc:
         assert metafunc._calls[1].funcargs == dict(x=3, y=4)
         assert metafunc._calls[1].id == "3-4"
 
-    def test_parametrize_multiple_times(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_multiple_times(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             pytestmark = pytest.mark.parametrize("x", [1,2])
@@ -897,12 +978,12 @@ class TestMetafunc:
                     assert 0, x
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 1
         result.assert_outcomes(failed=6)
 
-    def test_parametrize_CSV(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_CSV(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.parametrize("x, y,", [(1,2), (2,3)])
@@ -910,11 +991,11 @@ class TestMetafunc:
                 assert x+1 == y
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
-    def test_parametrize_class_scenarios(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_class_scenarios(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
         # same as doc/en/example/parametrize scenario example
         def pytest_generate_tests(metafunc):
@@ -941,7 +1022,7 @@ class TestMetafunc:
                   pass
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         assert result.ret == 0
         result.stdout.fnmatch_lines(
             """
@@ -978,8 +1059,8 @@ class TestMetafunc:
 
 
 class TestMetafuncFunctional:
-    def test_attributes(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_attributes(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             # assumes that generate/provide runs in the same process
             import sys, pytest
@@ -1005,11 +1086,11 @@ class TestMetafuncFunctional:
                     assert metafunc.cls == TestClass
         """
         )
-        result = testdir.runpytest(p, "-v")
+        result = pytester.runpytest(p, "-v")
         result.assert_outcomes(passed=2)
 
-    def test_two_functions(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_two_functions(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 metafunc.parametrize('arg1', [10, 20], ids=['0', '1'])
@@ -1021,7 +1102,7 @@ class TestMetafuncFunctional:
                 assert arg1 in (10, 20)
         """
         )
-        result = testdir.runpytest("-v", p)
+        result = pytester.runpytest("-v", p)
         result.stdout.fnmatch_lines(
             [
                 "*test_func1*0*PASS*",
@@ -1032,8 +1113,8 @@ class TestMetafuncFunctional:
             ]
         )
 
-    def test_noself_in_method(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_noself_in_method(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 assert 'xyz' not in metafunc.fixturenames
@@ -1043,11 +1124,11 @@ class TestMetafuncFunctional:
                     pass
         """
         )
-        result = testdir.runpytest(p)
+        result = pytester.runpytest(p)
         result.assert_outcomes(passed=1)
 
-    def test_generate_tests_in_class(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_generate_tests_in_class(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             class TestClass(object):
                 def pytest_generate_tests(self, metafunc):
@@ -1057,11 +1138,11 @@ class TestMetafuncFunctional:
                     assert hello == "world"
         """
         )
-        result = testdir.runpytest("-v", p)
+        result = pytester.runpytest("-v", p)
         result.stdout.fnmatch_lines(["*test_myfunc*hello*PASS*", "*1 passed*"])
 
-    def test_two_functions_not_same_instance(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_two_functions_not_same_instance(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 metafunc.parametrize('arg1', [10, 20], ids=["0", "1"])
@@ -1072,13 +1153,13 @@ class TestMetafuncFunctional:
                     self.x = 1
         """
         )
-        result = testdir.runpytest("-v", p)
+        result = pytester.runpytest("-v", p)
         result.stdout.fnmatch_lines(
             ["*test_func*0*PASS*", "*test_func*1*PASS*", "*2 pass*"]
         )
 
-    def test_issue28_setup_method_in_generate_tests(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_issue28_setup_method_in_generate_tests(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 metafunc.parametrize('arg1', [1])
@@ -1090,11 +1171,11 @@ class TestMetafuncFunctional:
                     self.val = 1
             """
         )
-        result = testdir.runpytest(p)
+        result = pytester.runpytest(p)
         result.assert_outcomes(passed=1)
 
-    def test_parametrize_functional2(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_functional2(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 metafunc.parametrize("arg1", [1,2])
@@ -1103,13 +1184,13 @@ class TestMetafuncFunctional:
                 assert 0, (arg1, arg2)
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             ["*(1, 4)*", "*(1, 5)*", "*(2, 4)*", "*(2, 5)*", "*4 failed*"]
         )
 
-    def test_parametrize_and_inner_getfixturevalue(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_parametrize_and_inner_getfixturevalue(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 metafunc.parametrize("arg1", [1], indirect=True)
@@ -1129,11 +1210,11 @@ class TestMetafuncFunctional:
                 assert arg1 == 11
         """
         )
-        result = testdir.runpytest("-v", p)
+        result = pytester.runpytest("-v", p)
         result.stdout.fnmatch_lines(["*test_func1*1*PASS*", "*1 passed*"])
 
-    def test_parametrize_on_setup_arg(self, testdir: Testdir) -> None:
-        p = testdir.makepyfile(
+    def test_parametrize_on_setup_arg(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             def pytest_generate_tests(metafunc):
                 assert "arg1" in metafunc.fixturenames
@@ -1152,17 +1233,17 @@ class TestMetafuncFunctional:
                 assert arg2 == 10
         """
         )
-        result = testdir.runpytest("-v", p)
+        result = pytester.runpytest("-v", p)
         result.stdout.fnmatch_lines(["*test_func*1*PASS*", "*1 passed*"])
 
-    def test_parametrize_with_ids(self, testdir: Testdir) -> None:
-        testdir.makeini(
+    def test_parametrize_with_ids(self, pytester: Pytester) -> None:
+        pytester.makeini(
             """
             [pytest]
             console_output_style=classic
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             def pytest_generate_tests(metafunc):
@@ -1173,14 +1254,14 @@ class TestMetafuncFunctional:
                 assert a == b
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         assert result.ret == 1
         result.stdout.fnmatch_lines_random(
             ["*test_function*basic*PASSED", "*test_function*advanced*FAILED"]
         )
 
-    def test_parametrize_without_ids(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_without_ids(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def pytest_generate_tests(metafunc):
@@ -1191,7 +1272,7 @@ class TestMetafuncFunctional:
                 assert 1
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             """
             *test_function*1-b0*
@@ -1199,8 +1280,8 @@ class TestMetafuncFunctional:
         """
         )
 
-    def test_parametrize_with_None_in_ids(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_with_None_in_ids(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def pytest_generate_tests(metafunc):
@@ -1211,7 +1292,7 @@ class TestMetafuncFunctional:
                 assert a == b
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         assert result.ret == 1
         result.stdout.fnmatch_lines_random(
             [
@@ -1221,9 +1302,9 @@ class TestMetafuncFunctional:
             ]
         )
 
-    def test_fixture_parametrized_empty_ids(self, testdir: Testdir) -> None:
+    def test_fixture_parametrized_empty_ids(self, pytester: Pytester) -> None:
         """Fixtures parametrized with empty ids cause an internal error (#1849)."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1235,12 +1316,12 @@ class TestMetafuncFunctional:
                  pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 1 skipped *"])
 
-    def test_parametrized_empty_ids(self, testdir: Testdir) -> None:
+    def test_parametrized_empty_ids(self, pytester: Pytester) -> None:
         """Tests parametrized with empty ids cause an internal error (#1849)."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1249,32 +1330,32 @@ class TestMetafuncFunctional:
                  pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 1 skipped *"])
 
-    def test_parametrized_ids_invalid_type(self, testdir: Testdir) -> None:
+    def test_parametrized_ids_invalid_type(self, pytester: Pytester) -> None:
         """Test error with non-strings/non-ints, without generator (#1857)."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
-            @pytest.mark.parametrize("x, expected", [(1, 2), (3, 4), (5, 6)], ids=(None, 2, type))
+            @pytest.mark.parametrize("x, expected", [(1, 2), (3, 4), (5, 6)], ids=(None, 2, OSError()))
             def test_ids_numbers(x,expected):
                 assert x * 2 == expected
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
-                "In test_ids_numbers: ids must be list of string/float/int/bool,"
-                " found: <class 'type'> (type: <class 'type'>) at index 2"
+                "In test_ids_numbers: ids contains unsupported value OSError() (type: <class 'OSError'>) at index 2. "
+                "Supported types are: str, bytes, int, float, complex, bool, enum, regex or anything with a __name__."
             ]
         )
 
     def test_parametrize_with_identical_ids_get_unique_names(
-        self, testdir: Testdir
+        self, pytester: Pytester
     ) -> None:
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             def pytest_generate_tests(metafunc):
@@ -1285,7 +1366,7 @@ class TestMetafuncFunctional:
                 assert a == b
         """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         assert result.ret == 1
         result.stdout.fnmatch_lines_random(
             ["*test_function*a0*PASSED*", "*test_function*a1*FAILED*"]
@@ -1293,9 +1374,9 @@ class TestMetafuncFunctional:
 
     @pytest.mark.parametrize(("scope", "length"), [("module", 2), ("function", 4)])
     def test_parametrize_scope_overrides(
-        self, testdir: Testdir, scope: str, length: int
+        self, pytester: Pytester, scope: str, length: int
     ) -> None:
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             values = []
@@ -1316,11 +1397,11 @@ class TestMetafuncFunctional:
         """
             % (scope, length)
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=5)
 
-    def test_parametrize_issue323(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_issue323(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1334,11 +1415,11 @@ class TestMetafuncFunctional:
                 pass
         """
         )
-        reprec = testdir.inline_run("--collect-only")
+        reprec = pytester.inline_run("--collect-only")
         assert not reprec.getcalls("pytest_internalerror")
 
-    def test_usefixtures_seen_in_generate_tests(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_usefixtures_seen_in_generate_tests(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def pytest_generate_tests(metafunc):
@@ -1350,35 +1431,41 @@ class TestMetafuncFunctional:
                 pass
         """
         )
-        reprec = testdir.runpytest()
+        reprec = pytester.runpytest()
         reprec.assert_outcomes(passed=1)
 
-    def test_generate_tests_only_done_in_subdir(self, testdir: Testdir) -> None:
-        sub1 = testdir.mkpydir("sub1")
-        sub2 = testdir.mkpydir("sub2")
-        sub1.join("conftest.py").write(
+    def test_generate_tests_only_done_in_subdir(self, pytester: Pytester) -> None:
+        sub1 = pytester.mkpydir("sub1")
+        sub2 = pytester.mkpydir("sub2")
+        sub1.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 def pytest_generate_tests(metafunc):
                     assert metafunc.function.__name__ == "test_1"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        sub2.join("conftest.py").write(
+        sub2.joinpath("conftest.py").write_text(
             textwrap.dedent(
                 """\
                 def pytest_generate_tests(metafunc):
                     assert metafunc.function.__name__ == "test_2"
                 """
-            )
+            ),
+            encoding="utf-8",
+        )
+        sub1.joinpath("test_in_sub1.py").write_text(
+            "def test_1(): pass", encoding="utf-8"
         )
-        sub1.join("test_in_sub1.py").write("def test_1(): pass")
-        sub2.join("test_in_sub2.py").write("def test_2(): pass")
-        result = testdir.runpytest("--keep-duplicates", "-v", "-s", sub1, sub2, sub1)
+        sub2.joinpath("test_in_sub2.py").write_text(
+            "def test_2(): pass", encoding="utf-8"
+        )
+        result = pytester.runpytest("--keep-duplicates", "-v", "-s", sub1, sub2, sub1)
         result.assert_outcomes(passed=3)
 
-    def test_generate_same_function_names_issue403(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_generate_same_function_names_issue403(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1392,12 +1479,12 @@ class TestMetafuncFunctional:
             test_y = make_tests()
         """
         )
-        reprec = testdir.runpytest()
+        reprec = pytester.runpytest()
         reprec.assert_outcomes(passed=4)
 
-    def test_parametrize_misspelling(self, testdir: Testdir) -> None:
+    def test_parametrize_misspelling(self, pytester: Pytester) -> None:
         """#463"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1406,7 +1493,7 @@ class TestMetafuncFunctional:
                 pass
         """
         )
-        result = testdir.runpytest("--collectonly")
+        result = pytester.runpytest("--collectonly")
         result.stdout.fnmatch_lines(
             [
                 "collected 0 items / 1 error",
@@ -1426,8 +1513,8 @@ class TestMetafuncFunctionalAuto:
     """Tests related to automatically find out the correct scope for
     parametrized tests (#1832)."""
 
-    def test_parametrize_auto_scope(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_auto_scope(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1445,11 +1532,11 @@ class TestMetafuncFunctionalAuto:
 
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 3 passed *"])
 
-    def test_parametrize_auto_scope_indirect(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_auto_scope_indirect(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1468,11 +1555,11 @@ class TestMetafuncFunctionalAuto:
                 assert echo in (1, 2, 3)
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 3 passed *"])
 
-    def test_parametrize_auto_scope_override_fixture(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_auto_scope_override_fixture(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1485,11 +1572,11 @@ class TestMetafuncFunctionalAuto:
                 assert animal in ('dog', 'cat')
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 2 passed *"])
 
-    def test_parametrize_all_indirects(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_all_indirects(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1512,11 +1599,11 @@ class TestMetafuncFunctionalAuto:
                 assert echo in (1, 2, 3)
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["* 3 passed *"])
 
     def test_parametrize_some_arguments_auto_scope(
-        self, testdir: Testdir, monkeypatch
+        self, pytester: Pytester, monkeypatch
     ) -> None:
         """Integration test for (#3941)"""
         class_fix_setup: List[object] = []
@@ -1524,7 +1611,7 @@ class TestMetafuncFunctionalAuto:
         func_fix_setup: List[object] = []
         monkeypatch.setattr(sys, "func_fix_setup", func_fix_setup, raising=False)
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             import sys
@@ -1545,13 +1632,13 @@ class TestMetafuncFunctionalAuto:
                     pass
             """
         )
-        result = testdir.runpytest_inprocess()
+        result = pytester.runpytest_inprocess()
         result.stdout.fnmatch_lines(["* 4 passed in *"])
         assert func_fix_setup == [True] * 4
         assert class_fix_setup == [10, 20]
 
-    def test_parametrize_issue634(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_issue634(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1579,7 +1666,7 @@ class TestMetafuncFunctionalAuto:
                 metafunc.parametrize('foo', params, indirect=True)
         """
         )
-        result = testdir.runpytest("-s")
+        result = pytester.runpytest("-s")
         output = result.stdout.str()
         assert output.count("preparing foo-2") == 1
         assert output.count("preparing foo-3") == 1
@@ -1588,7 +1675,7 @@ class TestMetafuncFunctionalAuto:
 class TestMarkersWithParametrization:
     """#308"""
 
-    def test_simple_mark(self, testdir: Testdir) -> None:
+    def test_simple_mark(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1601,7 +1688,7 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        items = testdir.getitems(s)
+        items = pytester.getitems(s)
         assert len(items) == 3
         for item in items:
             assert "foo" in item.keywords
@@ -1609,7 +1696,7 @@ class TestMarkersWithParametrization:
         assert "bar" in items[1].keywords
         assert "bar" not in items[2].keywords
 
-    def test_select_based_on_mark(self, testdir: Testdir) -> None:
+    def test_select_based_on_mark(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1621,14 +1708,14 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        testdir.makepyfile(s)
-        rec = testdir.inline_run("-m", "foo")
+        pytester.makepyfile(s)
+        rec = pytester.inline_run("-m", "foo")
         passed, skipped, fail = rec.listoutcomes()
         assert len(passed) == 1
         assert len(skipped) == 0
         assert len(fail) == 0
 
-    def test_simple_xfail(self, testdir: Testdir) -> None:
+    def test_simple_xfail(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1640,12 +1727,12 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         # xfail is skip??
         reprec.assertoutcome(passed=2, skipped=1)
 
-    def test_simple_xfail_single_argname(self, testdir: Testdir) -> None:
+    def test_simple_xfail_single_argname(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1657,11 +1744,11 @@ class TestMarkersWithParametrization:
             def test_isEven(n):
                 assert n % 2 == 0
         """
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2, skipped=1)
 
-    def test_xfail_with_arg(self, testdir: Testdir) -> None:
+    def test_xfail_with_arg(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1673,11 +1760,11 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2, skipped=1)
 
-    def test_xfail_with_kwarg(self, testdir: Testdir) -> None:
+    def test_xfail_with_kwarg(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1689,11 +1776,11 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2, skipped=1)
 
-    def test_xfail_with_arg_and_kwarg(self, testdir: Testdir) -> None:
+    def test_xfail_with_arg_and_kwarg(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1705,12 +1792,12 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2, skipped=1)
 
     @pytest.mark.parametrize("strict", [True, False])
-    def test_xfail_passing_is_xpass(self, testdir: Testdir, strict: bool) -> None:
+    def test_xfail_passing_is_xpass(self, pytester: Pytester, strict: bool) -> None:
         s = """
             import pytest
 
@@ -1726,12 +1813,12 @@ class TestMarkersWithParametrization:
         """.format(
             strict=strict
         )
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         passed, failed = (2, 1) if strict else (3, 0)
         reprec.assertoutcome(passed=passed, failed=failed)
 
-    def test_parametrize_called_in_generate_tests(self, testdir: Testdir) -> None:
+    def test_parametrize_called_in_generate_tests(self, pytester: Pytester) -> None:
         s = """
             import pytest
 
@@ -1750,13 +1837,15 @@ class TestMarkersWithParametrization:
             def test_increment(n, expected):
                 assert n + 1 == expected
         """
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2, skipped=2)
 
-    def test_parametrize_ID_generation_string_int_works(self, testdir: Testdir) -> None:
+    def test_parametrize_ID_generation_string_int_works(
+        self, pytester: Pytester
+    ) -> None:
         """#290"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1769,11 +1858,11 @@ class TestMarkersWithParametrization:
                 return
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reprec.assertoutcome(passed=2)
 
     @pytest.mark.parametrize("strict", [True, False])
-    def test_parametrize_marked_value(self, testdir: Testdir, strict: bool) -> None:
+    def test_parametrize_marked_value(self, pytester: Pytester, strict: bool) -> None:
         s = """
             import pytest
 
@@ -1792,19 +1881,19 @@ class TestMarkersWithParametrization:
         """.format(
             strict=strict
         )
-        testdir.makepyfile(s)
-        reprec = testdir.inline_run()
+        pytester.makepyfile(s)
+        reprec = pytester.inline_run()
         passed, failed = (0, 2) if strict else (2, 0)
         reprec.assertoutcome(passed=passed, failed=failed)
 
-    def test_pytest_make_parametrize_id(self, testdir: Testdir) -> None:
-        testdir.makeconftest(
+    def test_pytest_make_parametrize_id(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             def pytest_make_parametrize_id(config, val):
                 return str(val * 2)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
                 import pytest
 
@@ -1813,17 +1902,17 @@ class TestMarkersWithParametrization:
                     pass
                 """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(["*test_func*0*PASS*", "*test_func*2*PASS*"])
 
-    def test_pytest_make_parametrize_id_with_argname(self, testdir: Testdir) -> None:
-        testdir.makeconftest(
+    def test_pytest_make_parametrize_id_with_argname(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             def pytest_make_parametrize_id(config, val, argname):
                 return str(val * 2 if argname == 'x' else val * 10)
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
                 import pytest
 
@@ -1836,13 +1925,13 @@ class TestMarkersWithParametrization:
                     pass
                 """
         )
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             ["*test_func_a*0*PASS*", "*test_func_a*2*PASS*", "*test_func_b*10*PASS*"]
         )
 
-    def test_parametrize_positional_args(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_positional_args(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -1851,11 +1940,11 @@ class TestMarkersWithParametrization:
                 pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.assert_outcomes(passed=1)
 
-    def test_parametrize_iterator(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_parametrize_iterator(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import itertools
             import pytest
@@ -1877,7 +1966,7 @@ class TestMarkersWithParametrization:
                 pass
         """
         )
-        result = testdir.runpytest("-vv", "-s")
+        result = pytester.runpytest("-vv", "-s")
         result.stdout.fnmatch_lines(
             [
                 "test_parametrize_iterator.py::test1[param0] PASSED",
index 80634eebfbffb22e6ddad15dbd5247735ca3dd30..3dcec31eb1fa5521ef2caf24c50820f40ccfdd54 100644 (file)
@@ -3,6 +3,7 @@ import sys
 
 import pytest
 from _pytest.outcomes import Failed
+from _pytest.pytester import Pytester
 
 
 class TestRaises:
@@ -18,6 +19,16 @@ class TestRaises:
         excinfo = pytest.raises(ValueError, int, "hello")
         assert "invalid literal" in str(excinfo.value)
 
+    def test_raises_does_not_allow_none(self):
+        with pytest.raises(ValueError, match="Expected an exception type or"):
+            # We're testing that this invalid usage gives a helpful error,
+            # so we can ignore Mypy telling us that None is invalid.
+            pytest.raises(expected_exception=None)  # type: ignore
+
+    def test_raises_does_not_allow_empty_tuple(self):
+        with pytest.raises(ValueError, match="Expected an exception type or"):
+            pytest.raises(expected_exception=())
+
     def test_raises_callable_no_exception(self) -> None:
         class A:
             def __call__(self):
@@ -50,8 +61,8 @@ class TestRaises:
             pprint.pprint(excinfo)
             raise E()
 
-    def test_raises_as_contextmanager(self, testdir):
-        testdir.makepyfile(
+    def test_raises_as_contextmanager(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             import _pytest._code
@@ -75,19 +86,15 @@ class TestRaises:
                            1/0
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*3 passed*"])
 
-    def test_does_not_raise(self, testdir):
-        testdir.makepyfile(
+    def test_does_not_raise(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
-            from contextlib import contextmanager
+            from contextlib import nullcontext as does_not_raise
             import pytest
 
-            @contextmanager
-            def does_not_raise():
-                yield
-
             @pytest.mark.parametrize('example_input,expectation', [
                 (3, does_not_raise()),
                 (2, does_not_raise()),
@@ -100,19 +107,15 @@ class TestRaises:
                     assert (6 / example_input) is not None
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*4 passed*"])
 
-    def test_does_not_raise_does_raise(self, testdir):
-        testdir.makepyfile(
+    def test_does_not_raise_does_raise(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
-            from contextlib import contextmanager
+            from contextlib import nullcontext as does_not_raise
             import pytest
 
-            @contextmanager
-            def does_not_raise():
-                yield
-
             @pytest.mark.parametrize('example_input,expectation', [
                 (0, does_not_raise()),
                 (1, pytest.raises(ZeroDivisionError)),
@@ -123,7 +126,7 @@ class TestRaises:
                     assert (6 / example_input) is not None
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 failed*"])
 
     def test_noclass(self) -> None:
@@ -143,7 +146,7 @@ class TestRaises:
         try:
             pytest.raises(ValueError, int, "0")
         except pytest.fail.Exception as e:
-            assert e.msg == "DID NOT RAISE {}".format(repr(ValueError))
+            assert e.msg == f"DID NOT RAISE {repr(ValueError)}"
         else:
             assert False, "Expected pytest.raises.Exception"
 
@@ -151,7 +154,7 @@ class TestRaises:
             with pytest.raises(ValueError):
                 pass
         except pytest.fail.Exception as e:
-            assert e.msg == "DID NOT RAISE {}".format(repr(ValueError))
+            assert e.msg == f"DID NOT RAISE {repr(ValueError)}"
         else:
             assert False, "Expected pytest.raises.Exception"
 
@@ -190,10 +193,12 @@ class TestRaises:
             int("asdf")
 
         msg = "with base 16"
-        expr = "Regex pattern {!r} does not match \"invalid literal for int() with base 10: 'asdf'\".".format(
-            msg
+        expr = (
+            "Regex pattern did not match.\n"
+            f" Regex: {msg!r}\n"
+            " Input: \"invalid literal for int() with base 10: 'asdf'\""
         )
-        with pytest.raises(AssertionError, match=re.escape(expr)):
+        with pytest.raises(AssertionError, match="(?m)" + re.escape(expr)):
             with pytest.raises(ValueError, match=msg):
                 int("asdf", base=10)
 
@@ -216,7 +221,7 @@ class TestRaises:
             with pytest.raises(AssertionError, match="'foo"):
                 raise AssertionError("'bar")
         (msg,) = excinfo.value.args
-        assert msg == 'Regex pattern "\'foo" does not match "\'bar".'
+        assert msg == '''Regex pattern did not match.\n Regex: "'foo"\n Input: "'bar"'''
 
     def test_match_failure_exact_string_message(self):
         message = "Oh here is a message with (42) numbers in parameters"
@@ -225,9 +230,10 @@ class TestRaises:
                 raise AssertionError(message)
         (msg,) = excinfo.value.args
         assert msg == (
-            "Regex pattern 'Oh here is a message with (42) numbers in "
-            "parameters' does not match 'Oh here is a message with (42) "
-            "numbers in parameters'. Did you mean to `re.escape()` the regex?"
+            "Regex pattern did not match.\n"
+            " Regex: 'Oh here is a message with (42) numbers in parameters'\n"
+            " Input: 'Oh here is a message with (42) numbers in parameters'\n"
+            " Did you mean to `re.escape()` the regex?"
         )
 
     def test_raises_match_wrong_type(self):
index ef841819d09cde34e6c541439397afced7f4229b..f756dca41c72bb8dc4ed9edccf254680ef8ee21d 100644 (file)
@@ -1,11 +1,14 @@
-def test_no_items_should_not_show_output(testdir):
-    result = testdir.runpytest("--fixtures-per-test")
+from _pytest.pytester import Pytester
+
+
+def test_no_items_should_not_show_output(pytester: Pytester) -> None:
+    result = pytester.runpytest("--fixtures-per-test")
     result.stdout.no_fnmatch_line("*fixtures used by*")
     assert result.ret == 0
 
 
-def test_fixtures_in_module(testdir):
-    p = testdir.makepyfile(
+def test_fixtures_in_module(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
         '''
         import pytest
         @pytest.fixture
@@ -19,22 +22,22 @@ def test_fixtures_in_module(testdir):
     '''
     )
 
-    result = testdir.runpytest("--fixtures-per-test", p)
+    result = pytester.runpytest("--fixtures-per-test", p)
     assert result.ret == 0
 
     result.stdout.fnmatch_lines(
         [
             "*fixtures used by test_arg1*",
             "*(test_fixtures_in_module.py:9)*",
-            "arg1",
+            "arg1 -- test_fixtures_in_module.py:6",
             "    arg1 docstring",
         ]
     )
     result.stdout.no_fnmatch_line("*_arg0*")
 
 
-def test_fixtures_in_conftest(testdir):
-    testdir.makeconftest(
+def test_fixtures_in_conftest(pytester: Pytester) -> None:
+    pytester.makeconftest(
         '''
         import pytest
         @pytest.fixture
@@ -50,7 +53,7 @@ def test_fixtures_in_conftest(testdir):
             """
     '''
     )
-    p = testdir.makepyfile(
+    p = pytester.makepyfile(
         """
         def test_arg2(arg2):
             pass
@@ -58,30 +61,29 @@ def test_fixtures_in_conftest(testdir):
             pass
     """
     )
-    result = testdir.runpytest("--fixtures-per-test", p)
+    result = pytester.runpytest("--fixtures-per-test", p)
     assert result.ret == 0
 
     result.stdout.fnmatch_lines(
         [
             "*fixtures used by test_arg2*",
             "*(test_fixtures_in_conftest.py:2)*",
-            "arg2",
+            "arg2 -- conftest.py:6",
             "    arg2 docstring",
             "*fixtures used by test_arg3*",
             "*(test_fixtures_in_conftest.py:4)*",
-            "arg1",
+            "arg1 -- conftest.py:3",
             "    arg1 docstring",
-            "arg2",
+            "arg2 -- conftest.py:6",
             "    arg2 docstring",
-            "arg3",
+            "arg3 -- conftest.py:9",
             "    arg3",
-            "    docstring",
         ]
     )
 
 
-def test_should_show_fixtures_used_by_test(testdir):
-    testdir.makeconftest(
+def test_should_show_fixtures_used_by_test(pytester: Pytester) -> None:
+    pytester.makeconftest(
         '''
         import pytest
         @pytest.fixture
@@ -92,7 +94,7 @@ def test_should_show_fixtures_used_by_test(testdir):
             """arg2 from conftest"""
     '''
     )
-    p = testdir.makepyfile(
+    p = pytester.makepyfile(
         '''
         import pytest
         @pytest.fixture
@@ -102,23 +104,23 @@ def test_should_show_fixtures_used_by_test(testdir):
             pass
     '''
     )
-    result = testdir.runpytest("--fixtures-per-test", p)
+    result = pytester.runpytest("--fixtures-per-test", p)
     assert result.ret == 0
 
     result.stdout.fnmatch_lines(
         [
             "*fixtures used by test_args*",
             "*(test_should_show_fixtures_used_by_test.py:6)*",
-            "arg1",
+            "arg1 -- test_should_show_fixtures_used_by_test.py:3",
             "    arg1 from testmodule",
-            "arg2",
+            "arg2 -- conftest.py:6",
             "    arg2 from conftest",
         ]
     )
 
 
-def test_verbose_include_private_fixtures_and_loc(testdir):
-    testdir.makeconftest(
+def test_verbose_include_private_fixtures_and_loc(pytester: Pytester) -> None:
+    pytester.makeconftest(
         '''
         import pytest
         @pytest.fixture
@@ -129,7 +131,7 @@ def test_verbose_include_private_fixtures_and_loc(testdir):
             """arg2 from conftest"""
     '''
     )
-    p = testdir.makepyfile(
+    p = pytester.makepyfile(
         '''
         import pytest
         @pytest.fixture
@@ -139,7 +141,7 @@ def test_verbose_include_private_fixtures_and_loc(testdir):
             pass
     '''
     )
-    result = testdir.runpytest("--fixtures-per-test", "-v", p)
+    result = pytester.runpytest("--fixtures-per-test", "-v", p)
     assert result.ret == 0
 
     result.stdout.fnmatch_lines(
@@ -156,8 +158,8 @@ def test_verbose_include_private_fixtures_and_loc(testdir):
     )
 
 
-def test_doctest_items(testdir):
-    testdir.makepyfile(
+def test_doctest_items(pytester: Pytester) -> None:
+    pytester.makepyfile(
         '''
         def foo():
             """
@@ -166,15 +168,87 @@ def test_doctest_items(testdir):
             """
     '''
     )
-    testdir.maketxtfile(
+    pytester.maketxtfile(
         """
         >>> 1 + 1
         2
     """
     )
-    result = testdir.runpytest(
+    result = pytester.runpytest(
         "--fixtures-per-test", "--doctest-modules", "--doctest-glob=*.txt", "-v"
     )
     assert result.ret == 0
 
     result.stdout.fnmatch_lines(["*collected 2 items*"])
+
+
+def test_multiline_docstring_in_module(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        '''
+        import pytest
+        @pytest.fixture
+        def arg1():
+            """Docstring content that spans across multiple lines,
+            through second line,
+            and through third line.
+
+            Docstring content that extends into a second paragraph.
+
+            Docstring content that extends into a third paragraph.
+            """
+        def test_arg1(arg1):
+            pass
+    '''
+    )
+
+    result = pytester.runpytest("--fixtures-per-test", p)
+    assert result.ret == 0
+
+    result.stdout.fnmatch_lines(
+        [
+            "*fixtures used by test_arg1*",
+            "*(test_multiline_docstring_in_module.py:13)*",
+            "arg1 -- test_multiline_docstring_in_module.py:3",
+            "    Docstring content that spans across multiple lines,",
+            "    through second line,",
+            "    and through third line.",
+        ]
+    )
+
+
+def test_verbose_include_multiline_docstring(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        '''
+        import pytest
+        @pytest.fixture
+        def arg1():
+            """Docstring content that spans across multiple lines,
+            through second line,
+            and through third line.
+
+            Docstring content that extends into a second paragraph.
+
+            Docstring content that extends into a third paragraph.
+            """
+        def test_arg1(arg1):
+            pass
+    '''
+    )
+
+    result = pytester.runpytest("--fixtures-per-test", "-v", p)
+    assert result.ret == 0
+
+    result.stdout.fnmatch_lines(
+        [
+            "*fixtures used by test_arg1*",
+            "*(test_verbose_include_multiline_docstring.py:13)*",
+            "arg1 -- test_verbose_include_multiline_docstring.py:3",
+            "    Docstring content that spans across multiple lines,",
+            "    through second line,",
+            "    and through third line.",
+            "    ",
+            "    Docstring content that extends into a second paragraph.",
+            "    ",
+            "    Docstring content that extends into a third paragraph.",
+        ]
+    )
index a3224be512656807d939dca2e80197dc5e015ed6..8c10e230b0c8a233f580617fee286b4f676a7b6c 100644 (file)
@@ -1,7 +1,9 @@
 import subprocess
 import sys
+from pathlib import Path
 
 import pytest
+from _pytest.monkeypatch import MonkeyPatch
 
 # Test for _argcomplete but not specific for any application.
 
@@ -65,19 +67,22 @@ class FilesCompleter:
 
 class TestArgComplete:
     @pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
-    def test_compare_with_compgen(self, tmpdir):
+    def test_compare_with_compgen(
+        self, tmp_path: Path, monkeypatch: MonkeyPatch
+    ) -> None:
         from _pytest._argcomplete import FastFilesCompleter
 
         ffc = FastFilesCompleter()
         fc = FilesCompleter()
 
-        with tmpdir.as_cwd():
-            assert equal_with_bash("", ffc, fc, out=sys.stdout)
+        monkeypatch.chdir(tmp_path)
 
-            tmpdir.ensure("data")
+        assert equal_with_bash("", ffc, fc, out=sys.stdout)
 
-            for x in ["d", "data", "doesnotexist", ""]:
-                assert equal_with_bash(x, ffc, fc, out=sys.stdout)
+        tmp_path.cwd().joinpath("data").touch()
+
+        for x in ["d", "data", "doesnotexist", ""]:
+            assert equal_with_bash(x, ffc, fc, out=sys.stdout)
 
     @pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
     def test_remove_dir_prefix(self):
index 289fe5b083f6445e86e818a75ffa827ab3425241..7119b3b5aa6c60b4a8b7683dc1009c28545b0b5a 100644 (file)
@@ -13,6 +13,7 @@ import pytest
 from _pytest import outcomes
 from _pytest.assertion import truncate
 from _pytest.assertion import util
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pytester import Pytester
 
 
@@ -82,7 +83,7 @@ class TestImportHookInstallation:
                 "E       assert {'failed': 1,... 'skipped': 0} == {'failed': 0,... 'skipped': 0}",
                 "E         Omitting 1 identical items, use -vv to show",
                 "E         Differing items:",
-                "E         Use -v to get the full diff",
+                "E         Use -v to get more diff",
             ]
         )
         # XXX: unstable output.
@@ -375,7 +376,7 @@ class TestAssert_reprcompare:
         assert diff == [
             "b'spam' == b'eggs'",
             "At index 0 diff: b's' != b'e'",
-            "Use -v to get the full diff",
+            "Use -v to get more diff",
         ]
 
     def test_bytes_diff_verbose(self) -> None:
@@ -443,11 +444,38 @@ class TestAssert_reprcompare:
         """
         expl = callequal(left, right, verbose=0)
         assert expl is not None
-        assert expl[-1] == "Use -v to get the full diff"
+        assert expl[-1] == "Use -v to get more diff"
         verbose_expl = callequal(left, right, verbose=1)
         assert verbose_expl is not None
         assert "\n".join(verbose_expl).endswith(textwrap.dedent(expected).strip())
 
+    def test_iterable_quiet(self) -> None:
+        expl = callequal([1, 2], [10, 2], verbose=-1)
+        assert expl == [
+            "[1, 2] == [10, 2]",
+            "At index 0 diff: 1 != 10",
+            "Use -v to get more diff",
+        ]
+
+    def test_iterable_full_diff_ci(
+        self, monkeypatch: MonkeyPatch, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            r"""
+            def test_full_diff():
+                left = [0, 1]
+                right = [0, 2]
+                assert left == right
+        """
+        )
+        monkeypatch.setenv("CI", "true")
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines(["E         Full diff:"])
+
+        monkeypatch.delenv("CI", raising=False)
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines(["E         Use -v to get more diff"])
+
     def test_list_different_lengths(self) -> None:
         expl = callequal([0, 1], [0, 1, 2])
         assert expl is not None
@@ -679,32 +707,6 @@ class TestAssert_reprcompare:
         assert expl is not None
         assert len(expl) > 1
 
-    def test_repr_verbose(self) -> None:
-        class Nums:
-            def __init__(self, nums):
-                self.nums = nums
-
-            def __repr__(self):
-                return str(self.nums)
-
-        list_x = list(range(5000))
-        list_y = list(range(5000))
-        list_y[len(list_y) // 2] = 3
-        nums_x = Nums(list_x)
-        nums_y = Nums(list_y)
-
-        assert callequal(nums_x, nums_y) is None
-
-        expl = callequal(nums_x, nums_y, verbose=1)
-        assert expl is not None
-        assert "+" + repr(nums_x) in expl
-        assert "-" + repr(nums_y) in expl
-
-        expl = callequal(nums_x, nums_y, verbose=2)
-        assert expl is not None
-        assert "+" + repr(nums_x) in expl
-        assert "-" + repr(nums_y) in expl
-
     def test_list_bad_repr(self) -> None:
         class A:
             def __repr__(self):
@@ -774,9 +776,26 @@ class TestAssert_reprcompare:
         msg = "\n".join(expl)
         assert msg
 
+    def test_nfc_nfd_same_string(self) -> None:
+        # issue 3426
+        left = "hyv\xe4"
+        right = "hyva\u0308"
+        expl = callequal(left, right)
+        assert expl == [
+            r"'hyv\xe4' == 'hyva\u0308'",
+            f"- {str(right)}",
+            f"+ {str(left)}",
+        ]
+
+        expl = callequal(left, right, verbose=2)
+        assert expl == [
+            r"'hyv\xe4' == 'hyva\u0308'",
+            f"- {str(right)}",
+            f"+ {str(left)}",
+        ]
+
 
 class TestAssert_reprcompare_dataclass:
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
     def test_dataclasses(self, pytester: Pytester) -> None:
         p = pytester.copy_example("dataclasses/test_compare_dataclasses.py")
         result = pytester.runpytest(p)
@@ -788,14 +807,13 @@ class TestAssert_reprcompare_dataclass:
                 "E         ['field_b']",
                 "E         ",
                 "E         Drill down into differing attribute field_b:",
-                "E           field_b: 'b' != 'c'...",
-                "E         ",
-                "E         ...Full output truncated (3 lines hidden), use '-vv' to show",
+                "E           field_b: 'b' != 'c'",
+                "E           - c",
+                "E           + b",
             ],
             consecutive=True,
         )
 
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
     def test_recursive_dataclasses(self, pytester: Pytester) -> None:
         p = pytester.copy_example("dataclasses/test_compare_recursive_dataclasses.py")
         result = pytester.runpytest(p)
@@ -809,12 +827,11 @@ class TestAssert_reprcompare_dataclass:
                 "E         Drill down into differing attribute g:",
                 "E           g: S(a=10, b='ten') != S(a=20, b='xxx')...",
                 "E         ",
-                "E         ...Full output truncated (52 lines hidden), use '-vv' to show",
+                "E         ...Full output truncated (51 lines hidden), use '-vv' to show",
             ],
             consecutive=True,
         )
 
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
     def test_recursive_dataclasses_verbose(self, pytester: Pytester) -> None:
         p = pytester.copy_example("dataclasses/test_compare_recursive_dataclasses.py")
         result = pytester.runpytest(p, "-vv")
@@ -834,8 +851,6 @@ class TestAssert_reprcompare_dataclass:
                 "E           ",
                 "E           Drill down into differing attribute a:",
                 "E             a: 10 != 20",
-                "E             +10",
-                "E             -20",
                 "E           ",
                 "E           Drill down into differing attribute b:",
                 "E             b: 'ten' != 'xxx'",
@@ -847,7 +862,6 @@ class TestAssert_reprcompare_dataclass:
             consecutive=True,
         )
 
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
     def test_dataclasses_verbose(self, pytester: Pytester) -> None:
         p = pytester.copy_example("dataclasses/test_compare_dataclasses_verbose.py")
         result = pytester.runpytest(p, "-vv")
@@ -861,7 +875,6 @@ class TestAssert_reprcompare_dataclass:
             ]
         )
 
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
     def test_dataclasses_with_attribute_comparison_off(
         self, pytester: Pytester
     ) -> None:
@@ -871,7 +884,6 @@ class TestAssert_reprcompare_dataclass:
         result = pytester.runpytest(p, "-vv")
         result.assert_outcomes(failed=0, passed=1)
 
-    @pytest.mark.skipif(sys.version_info < (3, 7), reason="Dataclasses in Python3.7+")
     def test_comparing_two_different_data_classes(self, pytester: Pytester) -> None:
         p = pytester.copy_example(
             "dataclasses/test_compare_two_different_dataclasses.py"
@@ -879,6 +891,22 @@ class TestAssert_reprcompare_dataclass:
         result = pytester.runpytest(p, "-vv")
         result.assert_outcomes(failed=0, passed=1)
 
+    def test_data_classes_with_custom_eq(self, pytester: Pytester) -> None:
+        p = pytester.copy_example(
+            "dataclasses/test_compare_dataclasses_with_custom_eq.py"
+        )
+        # issue 9362
+        result = pytester.runpytest(p, "-vv")
+        result.assert_outcomes(failed=1, passed=0)
+        result.stdout.no_re_match_line(".*Differing attributes.*")
+
+    def test_data_classes_with_initvar(self, pytester: Pytester) -> None:
+        p = pytester.copy_example("dataclasses/test_compare_initvar.py")
+        # issue 9820
+        result = pytester.runpytest(p, "-vv")
+        result.assert_outcomes(failed=1, passed=0)
+        result.stdout.no_re_match_line(".*AttributeError.*")
+
 
 class TestAssert_reprcompare_attrsclass:
     def test_attrs(self) -> None:
@@ -962,7 +990,6 @@ class TestAssert_reprcompare_attrsclass:
         right = SimpleDataObject(1, "b")
 
         lines = callequal(left, right, verbose=2)
-        print(lines)
         assert lines is not None
         assert lines[2].startswith("Matching attributes:")
         assert "Omitting" not in lines[1]
@@ -987,6 +1014,36 @@ class TestAssert_reprcompare_attrsclass:
         lines = callequal(left, right)
         assert lines is None
 
+    def test_attrs_with_auto_detect_and_custom_eq(self) -> None:
+        @attr.s(
+            auto_detect=True
+        )  # attr.s doesn’t ignore a custom eq if auto_detect=True
+        class SimpleDataObject:
+            field_a = attr.ib()
+
+            def __eq__(self, other):  # pragma: no cover
+                return super().__eq__(other)
+
+        left = SimpleDataObject(1)
+        right = SimpleDataObject(2)
+        # issue 9362
+        lines = callequal(left, right, verbose=2)
+        assert lines is None
+
+    def test_attrs_with_custom_eq(self) -> None:
+        @attr.define(slots=False)
+        class SimpleDataObject:
+            field_a = attr.ib()
+
+            def __eq__(self, other):  # pragma: no cover
+                return super().__eq__(other)
+
+        left = SimpleDataObject(1)
+        right = SimpleDataObject(2)
+        # issue 9362
+        lines = callequal(left, right, verbose=2)
+        assert lines is None
+
 
 class TestAssert_reprcompare_namedtuple:
     def test_namedtuple(self) -> None:
@@ -1007,7 +1064,7 @@ class TestAssert_reprcompare_namedtuple:
             "  b: 'b' != 'c'",
             "  - c",
             "  + b",
-            "Use -v to get the full diff",
+            "Use -v to get more diff",
         ]
 
     def test_comparing_two_different_namedtuple(self) -> None:
@@ -1022,7 +1079,7 @@ class TestAssert_reprcompare_namedtuple:
         assert lines == [
             "NT1(a=1, b='b') == NT2(a=2, b='b')",
             "At index 0 diff: 1 != 2",
-            "Use -v to get the full diff",
+            "Use -v to get more diff",
         ]
 
 
@@ -1131,30 +1188,55 @@ class TestTruncateExplanation:
     def test_truncates_at_8_lines_when_given_list_of_empty_strings(self) -> None:
         expl = ["" for x in range(50)]
         result = truncate._truncate_explanation(expl, max_lines=8, max_chars=100)
+        assert len(result) != len(expl)
         assert result != expl
         assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG
         assert "Full output truncated" in result[-1]
-        assert "43 lines hidden" in result[-1]
+        assert "42 lines hidden" in result[-1]
         last_line_before_trunc_msg = result[-self.LINES_IN_TRUNCATION_MSG - 1]
         assert last_line_before_trunc_msg.endswith("...")
 
     def test_truncates_at_8_lines_when_first_8_lines_are_LT_max_chars(self) -> None:
-        expl = ["a" for x in range(100)]
+        total_lines = 100
+        expl = ["a" for x in range(total_lines)]
         result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80)
         assert result != expl
         assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG
         assert "Full output truncated" in result[-1]
-        assert "93 lines hidden" in result[-1]
+        assert f"{total_lines - 8} lines hidden" in result[-1]
         last_line_before_trunc_msg = result[-self.LINES_IN_TRUNCATION_MSG - 1]
         assert last_line_before_trunc_msg.endswith("...")
 
+    def test_truncates_at_8_lines_when_there_is_one_line_to_remove(self) -> None:
+        """The number of line in the result is 9, the same number as if we truncated."""
+        expl = ["a" for x in range(9)]
+        result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80)
+        assert result == expl
+        assert "truncated" not in result[-1]
+
+    def test_truncates_edgecase_when_truncation_message_makes_the_result_longer_for_chars(
+        self,
+    ) -> None:
+        line = "a" * 10
+        expl = [line, line]
+        result = truncate._truncate_explanation(expl, max_lines=10, max_chars=10)
+        assert result == [line, line]
+
+    def test_truncates_edgecase_when_truncation_message_makes_the_result_longer_for_lines(
+        self,
+    ) -> None:
+        line = "a" * 10
+        expl = [line, line]
+        result = truncate._truncate_explanation(expl, max_lines=1, max_chars=100)
+        assert result == [line, line]
+
     def test_truncates_at_8_lines_when_first_8_lines_are_EQ_max_chars(self) -> None:
-        expl = ["a" * 80 for x in range(16)]
+        expl = [chr(97 + x) * 80 for x in range(16)]
         result = truncate._truncate_explanation(expl, max_lines=8, max_chars=8 * 80)
         assert result != expl
-        assert len(result) == 8 + self.LINES_IN_TRUNCATION_MSG
+        assert len(result) == 16 - 8 + self.LINES_IN_TRUNCATION_MSG
         assert "Full output truncated" in result[-1]
-        assert "9 lines hidden" in result[-1]
+        assert "8 lines hidden" in result[-1]
         last_line_before_trunc_msg = result[-self.LINES_IN_TRUNCATION_MSG - 1]
         assert last_line_before_trunc_msg.endswith("...")
 
@@ -1183,7 +1265,7 @@ class TestTruncateExplanation:
 
         line_count = 7
         line_len = 100
-        expected_truncated_lines = 2
+        expected_truncated_lines = 1
         pytester.makepyfile(
             r"""
             def test_many_lines():
@@ -1204,7 +1286,7 @@ class TestTruncateExplanation:
                 "*+ 1*",
                 "*+ 3*",
                 "*+ 5*",
-                "*truncated (%d lines hidden)*use*-vv*" % expected_truncated_lines,
+                "*truncated (%d line hidden)*use*-vv*" % expected_truncated_lines,
             ]
         )
 
@@ -1310,14 +1392,14 @@ def test_sequence_comparison_uses_repr(pytester: Pytester) -> None:
 def test_assertrepr_loaded_per_dir(pytester: Pytester) -> None:
     pytester.makepyfile(test_base=["def test_base(): assert 1 == 2"])
     a = pytester.mkdir("a")
-    a.joinpath("test_a.py").write_text("def test_a(): assert 1 == 2")
+    a.joinpath("test_a.py").write_text("def test_a(): assert 1 == 2", encoding="utf-8")
     a.joinpath("conftest.py").write_text(
-        'def pytest_assertrepr_compare(): return ["summary a"]'
+        'def pytest_assertrepr_compare(): return ["summary a"]', encoding="utf-8"
     )
     b = pytester.mkdir("b")
-    b.joinpath("test_b.py").write_text("def test_b(): assert 1 == 2")
+    b.joinpath("test_b.py").write_text("def test_b(): assert 1 == 2", encoding="utf-8")
     b.joinpath("conftest.py").write_text(
-        'def pytest_assertrepr_compare(): return ["summary b"]'
+        'def pytest_assertrepr_compare(): return ["summary b"]', encoding="utf-8"
     )
 
     result = pytester.runpytest()
@@ -1596,7 +1678,7 @@ def test_raise_unprintable_assertion_error(pytester: Pytester) -> None:
     )
 
 
-def test_raise_assertion_error_raisin_repr(pytester: Pytester) -> None:
+def test_raise_assertion_error_raising_repr(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
         class RaisingRepr(object):
@@ -1607,9 +1689,7 @@ def test_raise_assertion_error_raisin_repr(pytester: Pytester) -> None:
     """
     )
     result = pytester.runpytest()
-    result.stdout.fnmatch_lines(
-        ["E       AssertionError: <unprintable AssertionError object>"]
-    )
+    result.stdout.fnmatch_lines(["E       AssertionError: <exception str() failed>"])
 
 
 def test_issue_1944(pytester: Pytester) -> None:
@@ -1657,3 +1737,18 @@ def test_assertion_location_with_coverage(pytester: Pytester) -> None:
             "*= 1 failed in*",
         ]
     )
+
+
+def test_reprcompare_verbose_long() -> None:
+    a = {f"v{i}": i for i in range(11)}
+    b = a.copy()
+    b["v2"] += 10
+    lines = callop("==", a, b, verbose=2)
+    assert lines is not None
+    assert lines[0] == (
+        "{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4, 'v5': 5, "
+        "'v6': 6, 'v7': 7, 'v8': 8, 'v9': 9, 'v10': 10}"
+        " == "
+        "{'v0': 0, 'v1': 1, 'v2': 12, 'v3': 3, 'v4': 4, 'v5': 5, "
+        "'v6': 6, 'v7': 7, 'v8': 8, 'v9': 9, 'v10': 10}"
+    )
index 84d5276e729e65c8d214a446f48d1b7afdd50935..fbf2854953ff2b68dae24896af5b678ae8343c3e 100644 (file)
@@ -11,23 +11,27 @@ import textwrap
 import zipfile
 from functools import partial
 from pathlib import Path
+from typing import cast
 from typing import Dict
+from typing import Generator
 from typing import List
 from typing import Mapping
 from typing import Optional
 from typing import Set
-
-import py
+from unittest import mock
 
 import _pytest._code
 import pytest
+from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE
 from _pytest.assertion import util
 from _pytest.assertion.rewrite import _get_assertion_exprs
+from _pytest.assertion.rewrite import _get_maxsize_for_saferepr
 from _pytest.assertion.rewrite import AssertionRewritingHook
 from _pytest.assertion.rewrite import get_cache_dir
 from _pytest.assertion.rewrite import PYC_TAIL
 from _pytest.assertion.rewrite import PYTEST_TAG
 from _pytest.assertion.rewrite import rewrite_asserts
+from _pytest.config import Config
 from _pytest.config import ExitCode
 from _pytest.pathlib import make_numbered_dir
 from _pytest.pytester import Pytester
@@ -109,6 +113,28 @@ class TestAssertionRewrite:
             assert imp.col_offset == 0
         assert isinstance(m.body[3], ast.Expr)
 
+    def test_location_is_set(self) -> None:
+        s = textwrap.dedent(
+            """
+
+        assert False, (
+
+            "Ouch"
+          )
+
+        """
+        )
+        m = rewrite(s)
+        for node in m.body:
+            if isinstance(node, ast.Import):
+                continue
+            for n in [node, *ast.iter_child_nodes(node)]:
+                assert n.lineno == 3
+                assert n.col_offset == 0
+                if sys.version_info >= (3, 8):
+                    assert n.end_lineno == 6
+                    assert n.end_col_offset == 3
+
     def test_dont_rewrite(self) -> None:
         s = """'PYTEST_DONT_REWRITE'\nassert 14"""
         m = rewrite(s)
@@ -134,7 +160,8 @@ class TestAssertionRewrite:
             "def special_asserter():\n"
             "    def special_assert(x, y):\n"
             "        assert x == y\n"
-            "    return special_assert\n"
+            "    return special_assert\n",
+            encoding="utf-8",
         )
         pytester.makeconftest('pytest_plugins = ["plugin"]')
         pytester.makepyfile("def test(special_asserter): special_asserter(1, 2)\n")
@@ -147,7 +174,9 @@ class TestAssertionRewrite:
         pytester.makepyfile(test_y="x = 1")
         xdir = pytester.mkdir("x")
         pytester.mkpydir(str(xdir.joinpath("test_Y")))
-        xdir.joinpath("test_Y").joinpath("__init__.py").write_text("x = 2")
+        xdir.joinpath("test_Y").joinpath("__init__.py").write_text(
+            "x = 2", encoding="utf-8"
+        )
         pytester.makepyfile(
             "import test_y\n"
             "import test_Y\n"
@@ -178,16 +207,8 @@ class TestAssertionRewrite:
         def f4() -> None:
             assert sys == 42  # type: ignore[comparison-overlap]
 
-        verbose = request.config.getoption("verbose")
         msg = getmsg(f4, {"sys": sys})
-        if verbose > 0:
-            assert msg == (
-                "assert <module 'sys' (built-in)> == 42\n"
-                "  +<module 'sys' (built-in)>\n"
-                "  -42"
-            )
-        else:
-            assert msg == "assert sys == 42"
+        assert msg == "assert sys == 42"
 
         def f5() -> None:
             assert cls == 42  # type: ignore[name-defined]  # noqa: F821
@@ -198,20 +219,7 @@ class TestAssertionRewrite:
         msg = getmsg(f5, {"cls": X})
         assert msg is not None
         lines = msg.splitlines()
-        if verbose > 1:
-            assert lines == [
-                f"assert {X!r} == 42",
-                f"  +{X!r}",
-                "  -42",
-            ]
-        elif verbose > 0:
-            assert lines == [
-                "assert <class 'test_...e.<locals>.X'> == 42",
-                f"  +{X!r}",
-                "  -42",
-            ]
-        else:
-            assert lines == ["assert cls == 42"]
+        assert lines == ["assert cls == 42"]
 
     def test_assertrepr_compare_same_width(self, request) -> None:
         """Should use same width/truncation with same initial width."""
@@ -253,14 +261,11 @@ class TestAssertionRewrite:
         msg = getmsg(f, {"cls": Y})
         assert msg is not None
         lines = msg.splitlines()
-        if request.config.getoption("verbose") > 0:
-            assert lines == ["assert 3 == 2", "  +3", "  -2"]
-        else:
-            assert lines == [
-                "assert 3 == 2",
-                " +  where 3 = Y.foo",
-                " +    where Y = cls()",
-            ]
+        assert lines == [
+            "assert 3 == 2",
+            " +  where 3 = Y.foo",
+            " +    where Y = cls()",
+        ]
 
     def test_assert_already_has_message(self) -> None:
         def f():
@@ -383,7 +388,7 @@ class TestAssertionRewrite:
         )
 
         def f7() -> None:
-            assert False or x()  # type: ignore[unreachable]
+            assert False or x()
 
         assert (
             getmsg(f7, {"x": x})
@@ -473,7 +478,7 @@ class TestAssertionRewrite:
         assert getmsg(f1) == "assert ((3 % 2) and False)"
 
         def f2() -> None:
-            assert False or 4 % 2  # type: ignore[unreachable]
+            assert False or 4 % 2
 
         assert getmsg(f2) == "assert (False or (4 % 2))"
 
@@ -637,10 +642,7 @@ class TestAssertionRewrite:
             assert len(values) == 11
 
         msg = getmsg(f)
-        if request.config.getoption("verbose") > 0:
-            assert msg == "assert 10 == 11\n  +10\n  -11"
-        else:
-            assert msg == "assert 10 == 11\n +  where 10 = len([0, 1, 2, 3, 4, 5, ...])"
+        assert msg == "assert 10 == 11\n +  where 10 = len([0, 1, 2, 3, 4, 5, ...])"
 
     def test_custom_reprcompare(self, monkeypatch) -> None:
         def my_reprcompare1(op, left, right) -> str:
@@ -706,10 +708,7 @@ class TestAssertionRewrite:
         msg = getmsg(f)
         assert msg is not None
         lines = util._format_lines([msg])
-        if request.config.getoption("verbose") > 0:
-            assert lines == ["assert 0 == 1\n  +0\n  -1"]
-        else:
-            assert lines == ["assert 0 == 1\n +  where 1 = \\n{ \\n~ \\n}.a"]
+        assert lines == ["assert 0 == 1\n +  where 1 = \\n{ \\n~ \\n}.a"]
 
     def test_custom_repr_non_ascii(self) -> None:
         def f() -> None:
@@ -730,7 +729,7 @@ class TestAssertionRewrite:
 
 class TestRewriteOnImport:
     def test_pycache_is_a_file(self, pytester: Pytester) -> None:
-        pytester.path.joinpath("__pycache__").write_text("Hello")
+        pytester.path.joinpath("__pycache__").write_text("Hello", encoding="utf-8")
         pytester.makepyfile(
             """
             def test_rewritten():
@@ -771,6 +770,35 @@ class TestRewriteOnImport:
         )
         assert pytester.runpytest().ret == ExitCode.NO_TESTS_COLLECTED
 
+    @pytest.mark.skipif(
+        sys.version_info < (3, 9),
+        reason="importlib.resources.files was introduced in 3.9",
+    )
+    def test_load_resource_via_files_with_rewrite(self, pytester: Pytester) -> None:
+        example = pytester.path.joinpath("demo") / "example"
+        init = pytester.path.joinpath("demo") / "__init__.py"
+        pytester.makepyfile(
+            **{
+                "demo/__init__.py": """
+                from importlib.resources import files
+
+                def load():
+                    return files(__name__)
+                """,
+                "test_load": f"""
+                pytest_plugins = ["demo"]
+
+                def test_load():
+                    from demo import load
+                    found = {{str(i) for i in load().iterdir() if i.name != "__pycache__"}}
+                    assert found == {{{str(example)!r}, {str(init)!r}}}
+                """,
+            }
+        )
+        example.mkdir()
+
+        assert pytester.runpytest("-vv").ret == ExitCode.OK
+
     def test_readonly(self, pytester: Pytester) -> None:
         sub = pytester.mkdir("testing")
         sub.joinpath("test_readonly.py").write_bytes(
@@ -878,7 +906,8 @@ def test_rewritten():
         pkg.joinpath("test_blah.py").write_text(
             """
 def test_rewritten():
-    assert "@py_builtins" in globals()"""
+    assert "@py_builtins" in globals()""",
+            encoding="utf-8",
         )
         assert pytester.runpytest().ret == 0
 
@@ -984,7 +1013,7 @@ class TestAssertionRewriteHookDetails:
         )
         assert pytester.runpytest().ret == 0
 
-    def test_write_pyc(self, pytester: Pytester, tmp_path, monkeypatch) -> None:
+    def test_write_pyc(self, pytester: Pytester, tmp_path) -> None:
         from _pytest.assertion.rewrite import _write_pyc
         from _pytest.assertion import AssertionState
 
@@ -996,27 +1025,8 @@ class TestAssertionRewriteHookDetails:
         co = compile("1", "f.py", "single")
         assert _write_pyc(state, co, os.stat(source_path), pycpath)
 
-        if sys.platform == "win32":
-            from contextlib import contextmanager
-
-            @contextmanager
-            def atomic_write_failed(fn, mode="r", overwrite=False):
-                e = OSError()
-                e.errno = 10
-                raise e
-                yield  # type:ignore[unreachable]
-
-            monkeypatch.setattr(
-                _pytest.assertion.rewrite, "atomic_write", atomic_write_failed
-            )
-        else:
-
-            def raise_oserror(*args):
-                raise OSError()
-
-            monkeypatch.setattr("os.rename", raise_oserror)
-
-        assert not _write_pyc(state, co, os.stat(source_path), pycpath)
+        with mock.patch.object(os, "replace", side_effect=OSError):
+            assert not _write_pyc(state, co, os.stat(source_path), pycpath)
 
     def test_resources_provider_for_loader(self, pytester: Pytester) -> None:
         """
@@ -1060,7 +1070,7 @@ class TestAssertionRewriteHookDetails:
         source = tmp_path / "source.py"
         pyc = Path(str(source) + "c")
 
-        source.write_text("def test(): pass")
+        source.write_text("def test(): pass", encoding="utf-8")
         py_compile.compile(str(source), str(pyc))
 
         contents = pyc.read_bytes()
@@ -1070,9 +1080,28 @@ class TestAssertionRewriteHookDetails:
 
         assert _read_pyc(source, pyc) is None  # no error
 
-    @pytest.mark.skipif(
-        sys.version_info < (3, 7), reason="Only the Python 3.7 format for simplicity"
-    )
+    def test_read_pyc_success(self, tmp_path: Path, pytester: Pytester) -> None:
+        """
+        Ensure that the _rewrite_test() -> _write_pyc() produces a pyc file
+        that can be properly read with _read_pyc()
+        """
+        from _pytest.assertion import AssertionState
+        from _pytest.assertion.rewrite import _read_pyc
+        from _pytest.assertion.rewrite import _rewrite_test
+        from _pytest.assertion.rewrite import _write_pyc
+
+        config = pytester.parseconfig()
+        state = AssertionState(config, "rewrite")
+
+        fn = tmp_path / "source.py"
+        pyc = Path(str(fn) + "c")
+
+        fn.write_text("def test(): assert True", encoding="utf-8")
+
+        source_stat, co = _rewrite_test(fn, config)
+        _write_pyc(state, co, source_stat, pyc)
+        assert _read_pyc(fn, pyc, state.trace) is not None
+
     def test_read_pyc_more_invalid(self, tmp_path: Path) -> None:
         from _pytest.assertion.rewrite import _read_pyc
 
@@ -1132,7 +1161,7 @@ class TestAssertionRewriteHookDetails:
                 return False
 
             def rewrite_self():
-                with open(__file__, 'w') as self:
+                with open(__file__, 'w', encoding='utf-8') as self:
                     self.write('def reloaded(): return True')
             """,
             test_fun="""
@@ -1162,9 +1191,10 @@ class TestAssertionRewriteHookDetails:
                         data = pkgutil.get_data('foo.test_foo', 'data.txt')
                         assert data == b'Hey'
                 """
-            )
+            ),
+            encoding="utf-8",
         )
-        path.joinpath("data.txt").write_text("Hey")
+        path.joinpath("data.txt").write_text("Hey", encoding="utf-8")
         result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 passed*"])
 
@@ -1241,7 +1271,290 @@ class TestIssue2121:
 
 
 @pytest.mark.skipif(
-    sys.maxsize <= (2 ** 31 - 1), reason="Causes OverflowError on 32bit systems"
+    sys.version_info < (3, 8), reason="walrus operator not available in py<38"
+)
+class TestIssue10743:
+    def test_assertion_walrus_operator(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            def my_func(before, after):
+                return before == after
+
+            def change_value(value):
+                return value.lower()
+
+            def test_walrus_conversion():
+                a = "Hello"
+                assert not my_func(a, a := change_value(a))
+                assert a == "hello"
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_dont_rewrite(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            'PYTEST_DONT_REWRITE'
+            def my_func(before, after):
+                return before == after
+
+            def change_value(value):
+                return value.lower()
+
+            def test_walrus_conversion_dont_rewrite():
+                a = "Hello"
+                assert not my_func(a, a := change_value(a))
+                assert a == "hello"
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_inline_walrus_operator(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            def my_func(before, after):
+                return before == after
+
+            def test_walrus_conversion_inline():
+                a = "Hello"
+                assert not my_func(a, a := a.lower())
+                assert a == "hello"
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_inline_walrus_operator_reverse(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            def my_func(before, after):
+                return before == after
+
+            def test_walrus_conversion_reverse():
+                a = "Hello"
+                assert my_func(a := a.lower(), a)
+                assert a == 'hello'
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_no_variable_name_conflict(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_conversion_no_conflict():
+                a = "Hello"
+                assert a == (b := a.lower())
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 1
+        result.stdout.fnmatch_lines(["*AssertionError: assert 'Hello' == 'hello'"])
+
+    def test_assertion_walrus_operator_true_assertion_and_changes_variable_value(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_conversion_succeed():
+                a = "Hello"
+                assert a != (a := a.lower())
+                assert a == 'hello'
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_fail_assertion(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_conversion_fails():
+                a = "Hello"
+                assert a == (a := a.lower())
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 1
+        result.stdout.fnmatch_lines(["*AssertionError: assert 'Hello' == 'hello'"])
+
+    def test_assertion_walrus_operator_boolean_composite(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_operator_change_boolean_value():
+                a = True
+                assert a and True and ((a := False) is False) and (a is False) and ((a := None) is None)
+                assert a is None
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_compare_boolean_fails(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_operator_change_boolean_value():
+                a = True
+                assert not (a and ((a := False) is False))
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 1
+        result.stdout.fnmatch_lines(["*assert not (True and False is False)"])
+
+    def test_assertion_walrus_operator_boolean_none_fails(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_operator_change_boolean_value():
+                a = True
+                assert not (a and ((a := None) is None))
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 1
+        result.stdout.fnmatch_lines(["*assert not (True and None is None)"])
+
+    def test_assertion_walrus_operator_value_changes_cleared_after_each_test(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_walrus_operator_change_value():
+                a = True
+                assert (a := None) is None
+
+            def test_walrus_operator_not_override_value():
+                a = True
+                assert a is True
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+
+@pytest.mark.skipif(
+    sys.version_info < (3, 8), reason="walrus operator not available in py<38"
+)
+class TestIssue11028:
+    def test_assertion_walrus_operator_in_operand(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            def test_in_string():
+              assert (obj := "foo") in obj
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_in_operand_json_dumps(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            import json
+
+            def test_json_encoder():
+                assert (obj := "foo") in json.dumps(obj)
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_equals_operand_function(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def f(a):
+                return a
+
+            def test_call_other_function_arg():
+              assert (obj := "foo") == f(obj)
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_equals_operand_function_keyword_arg(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def f(a='test'):
+                return a
+
+            def test_call_other_function_k_arg():
+              assert (obj := "foo") == f(a=obj)
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_equals_operand_function_arg_as_function(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def f(a='test'):
+                return a
+
+            def test_function_of_function():
+              assert (obj := "foo") == f(f(obj))
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+    def test_assertion_walrus_operator_gt_operand_function(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def add_one(a):
+                return a + 1
+
+            def test_gt():
+              assert (obj := 4) > add_one(obj)
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 1
+        result.stdout.fnmatch_lines(["*assert 4 > 5", "*where 5 = add_one(4)"])
+
+
+class TestIssue11239:
+    @pytest.mark.skipif(sys.version_info[:2] <= (3, 7), reason="Only Python 3.8+")
+    def test_assertion_walrus_different_test_cases(self, pytester: Pytester) -> None:
+        """Regression for (#11239)
+
+        Walrus operator rewriting would leak to separate test cases if they used the same variables.
+        """
+        pytester.makepyfile(
+            """
+            def test_1():
+                state = {"x": 2}.get("x")
+                assert state is not None
+
+            def test_2():
+                db = {"x": 2}
+                assert (state := db.get("x")) is not None
+        """
+        )
+        result = pytester.runpytest()
+        assert result.ret == 0
+
+
+@pytest.mark.skipif(
+    sys.maxsize <= (2**31 - 1), reason="Causes OverflowError on 32bit systems"
 )
 @pytest.mark.parametrize("offset", [-1, +1])
 def test_source_mtime_long_long(pytester: Pytester, offset) -> None:
@@ -1260,7 +1573,7 @@ def test_source_mtime_long_long(pytester: Pytester, offset) -> None:
     # use unsigned long timestamp which overflows signed long,
     # which was the cause of the bug
     # +1 offset also tests masking of 0xFFFFFFFF
-    timestamp = 2 ** 32 + offset
+    timestamp = 2**32 + offset
     os.utime(str(p), (timestamp, timestamp))
     result = pytester.runpytest()
     assert result.ret == 0
@@ -1304,14 +1617,14 @@ class TestEarlyRewriteBailout:
     @pytest.fixture
     def hook(
         self, pytestconfig, monkeypatch, pytester: Pytester
-    ) -> AssertionRewritingHook:
+    ) -> Generator[AssertionRewritingHook, None, None]:
         """Returns a patched AssertionRewritingHook instance so we can configure its initial paths and track
         if PathFinder.find_spec has been called.
         """
         import importlib.machinery
 
         self.find_spec_calls: List[str] = []
-        self.initial_paths: Set[py.path.local] = set()
+        self.initial_paths: Set[Path] = set()
 
         class StubSession:
             _initialpaths = self.initial_paths
@@ -1325,11 +1638,11 @@ class TestEarlyRewriteBailout:
 
         hook = AssertionRewritingHook(pytestconfig)
         # use default patterns, otherwise we inherit pytest's testing config
-        hook.fnpats[:] = ["test_*.py", "*_test.py"]
-        monkeypatch.setattr(hook, "_find_spec", spy_find_spec)
-        hook.set_session(StubSession())  # type: ignore[arg-type]
-        pytester.syspathinsert()
-        return hook
+        with mock.patch.object(hook, "fnpats", ["test_*.py", "*_test.py"]):
+            monkeypatch.setattr(hook, "_find_spec", spy_find_spec)
+            hook.set_session(StubSession())  # type: ignore[arg-type]
+            pytester.syspathinsert()
+            yield hook
 
     def test_basic(self, pytester: Pytester, hook: AssertionRewritingHook) -> None:
         """
@@ -1346,7 +1659,7 @@ class TestEarlyRewriteBailout:
         pytester.makepyfile(test_foo="def test_foo(): pass")
         pytester.makepyfile(bar="def bar(): pass")
         foobar_path = pytester.makepyfile(foobar="def foobar(): pass")
-        self.initial_paths.add(py.path.local(foobar_path))
+        self.initial_paths.add(foobar_path)
 
         # conftest files should always be rewritten
         assert hook.find_spec("conftest") is not None
@@ -1379,13 +1692,16 @@ class TestEarlyRewriteBailout:
             }
         )
         pytester.syspathinsert("tests")
-        hook.fnpats[:] = ["tests/**.py"]
-        assert hook.find_spec("file") is not None
-        assert self.find_spec_calls == ["file"]
+        with mock.patch.object(hook, "fnpats", ["tests/**.py"]):
+            assert hook.find_spec("file") is not None
+            assert self.find_spec_calls == ["file"]
 
     @pytest.mark.skipif(
         sys.platform.startswith("win32"), reason="cannot remove cwd on Windows"
     )
+    @pytest.mark.skipif(
+        sys.platform.startswith("sunos5"), reason="cannot remove cwd on Solaris"
+    )
     def test_cwd_changed(self, pytester: Pytester, monkeypatch) -> None:
         # Setup conditions for py's fspath trying to import pathlib on py34
         # always (previously triggered via xdist only).
@@ -1397,12 +1713,10 @@ class TestEarlyRewriteBailout:
             **{
                 "test_setup_nonexisting_cwd.py": """\
                     import os
-                    import shutil
                     import tempfile
 
-                    d = tempfile.mkdtemp()
-                    os.chdir(d)
-                    shutil.rmtree(d)
+                    with tempfile.TemporaryDirectory() as d:
+                        os.chdir(d)
                 """,
                 "test_test.py": """\
                     def test():
@@ -1627,7 +1941,7 @@ def test_try_makedirs(monkeypatch, tmp_path: Path) -> None:
 
     # monkeypatch to simulate all error situations
     def fake_mkdir(p, exist_ok=False, *, exc):
-        assert isinstance(p, str)
+        assert isinstance(p, Path)
         raise exc
 
     monkeypatch.setattr(os, "makedirs", partial(fake_mkdir, exc=FileNotFoundError()))
@@ -1675,6 +1989,10 @@ class TestPyCacheDir:
     @pytest.mark.skipif(
         sys.version_info < (3, 8), reason="pycache_prefix not available in py<38"
     )
+    @pytest.mark.skipif(
+        sys.version_info[:2] == (3, 9) and sys.platform.startswith("win"),
+        reason="#9298",
+    )
     def test_sys_pycache_prefix_integration(
         self, tmp_path, monkeypatch, pytester: Pytester
     ) -> None:
@@ -1710,3 +2028,52 @@ class TestPyCacheDir:
             cache_tag=sys.implementation.cache_tag
         )
         assert bar_init_pyc.is_file()
+
+
+class TestReprSizeVerbosity:
+    """
+    Check that verbosity also controls the string length threshold to shorten it using
+    ellipsis.
+    """
+
+    @pytest.mark.parametrize(
+        "verbose, expected_size",
+        [
+            (0, DEFAULT_REPR_MAX_SIZE),
+            (1, DEFAULT_REPR_MAX_SIZE * 10),
+            (2, None),
+            (3, None),
+        ],
+    )
+    def test_get_maxsize_for_saferepr(self, verbose: int, expected_size) -> None:
+        class FakeConfig:
+            def getoption(self, name: str) -> int:
+                assert name == "verbose"
+                return verbose
+
+        config = FakeConfig()
+        assert _get_maxsize_for_saferepr(cast(Config, config)) == expected_size
+
+    def create_test_file(self, pytester: Pytester, size: int) -> None:
+        pytester.makepyfile(
+            f"""
+            def test_very_long_string():
+                text = "x" * {size}
+                assert "hello world" in text
+            """
+        )
+
+    def test_default_verbosity(self, pytester: Pytester) -> None:
+        self.create_test_file(pytester, DEFAULT_REPR_MAX_SIZE)
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines(["*xxx...xxx*"])
+
+    def test_increased_verbosity(self, pytester: Pytester) -> None:
+        self.create_test_file(pytester, DEFAULT_REPR_MAX_SIZE)
+        result = pytester.runpytest("-v")
+        result.stdout.no_fnmatch_line("*xxx...xxx*")
+
+    def test_max_increased_verbosity(self, pytester: Pytester) -> None:
+        self.create_test_file(pytester, DEFAULT_REPR_MAX_SIZE * 10)
+        result = pytester.runpytest("-vv")
+        result.stdout.no_fnmatch_line("*xxx...xxx*")
index ccc7304b02a8d43d41dff49dc9151cf94b9823ea..e2e195ca7f5f57f20c034398699abc9dfb8603d7 100644 (file)
@@ -1,31 +1,33 @@
 import os
 import shutil
-import stat
-import sys
-
-import py
+from pathlib import Path
+from typing import Generator
+from typing import List
 
 import pytest
 from _pytest.config import ExitCode
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pytester import Pytester
-from _pytest.pytester import Testdir
+from _pytest.tmpdir import TempPathFactory
 
 pytest_plugins = ("pytester",)
 
 
 class TestNewAPI:
-    def test_config_cache_makedir(self, testdir):
-        testdir.makeini("[pytest]")
-        config = testdir.parseconfigure()
+    def test_config_cache_mkdir(self, pytester: Pytester) -> None:
+        pytester.makeini("[pytest]")
+        config = pytester.parseconfigure()
+        assert config.cache is not None
         with pytest.raises(ValueError):
-            config.cache.makedir("key/name")
+            config.cache.mkdir("key/name")
 
-        p = config.cache.makedir("name")
-        assert p.check()
+        p = config.cache.mkdir("name")
+        assert p.is_dir()
 
-    def test_config_cache_dataerror(self, testdir):
-        testdir.makeini("[pytest]")
-        config = testdir.parseconfigure()
+    def test_config_cache_dataerror(self, pytester: Pytester) -> None:
+        pytester.makeini("[pytest]")
+        config = pytester.parseconfigure()
+        assert config.cache is not None
         cache = config.cache
         pytest.raises(TypeError, lambda: cache.set("key/name", cache))
         config.cache.set("key/name", 0)
@@ -34,75 +36,85 @@ class TestNewAPI:
         assert val == -2
 
     @pytest.mark.filterwarnings("ignore:could not create cache path")
-    def test_cache_writefail_cachfile_silent(self, testdir):
-        testdir.makeini("[pytest]")
-        testdir.tmpdir.join(".pytest_cache").write("gone wrong")
-        config = testdir.parseconfigure()
+    def test_cache_writefail_cachfile_silent(self, pytester: Pytester) -> None:
+        pytester.makeini("[pytest]")
+        pytester.path.joinpath(".pytest_cache").write_text(
+            "gone wrong", encoding="utf-8"
+        )
+        config = pytester.parseconfigure()
         cache = config.cache
+        assert cache is not None
         cache.set("test/broken", [])
 
-    @pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows")
+    @pytest.fixture
+    def unwritable_cache_dir(self, pytester: Pytester) -> Generator[Path, None, None]:
+        cache_dir = pytester.path.joinpath(".pytest_cache")
+        cache_dir.mkdir()
+        mode = cache_dir.stat().st_mode
+        cache_dir.chmod(0)
+        if os.access(cache_dir, os.W_OK):
+            pytest.skip("Failed to make cache dir unwritable")
+
+        yield cache_dir
+        cache_dir.chmod(mode)
+
     @pytest.mark.filterwarnings(
         "ignore:could not create cache path:pytest.PytestWarning"
     )
-    def test_cache_writefail_permissions(self, testdir):
-        testdir.makeini("[pytest]")
-        cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))
-        mode = os.stat(cache_dir)[stat.ST_MODE]
-        testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
-        try:
-            config = testdir.parseconfigure()
-            cache = config.cache
-            cache.set("test/broken", [])
-        finally:
-            testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
-
-    @pytest.mark.skipif(sys.platform.startswith("win"), reason="no chmod on windows")
+    def test_cache_writefail_permissions(
+        self, unwritable_cache_dir: Path, pytester: Pytester
+    ) -> None:
+        pytester.makeini("[pytest]")
+        config = pytester.parseconfigure()
+        cache = config.cache
+        assert cache is not None
+        cache.set("test/broken", [])
+
     @pytest.mark.filterwarnings("default")
-    def test_cache_failure_warns(self, testdir, monkeypatch):
+    def test_cache_failure_warns(
+        self,
+        pytester: Pytester,
+        monkeypatch: MonkeyPatch,
+        unwritable_cache_dir: Path,
+    ) -> None:
         monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1")
-        cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))
-        mode = os.stat(cache_dir)[stat.ST_MODE]
-        testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
-        try:
-            testdir.makepyfile("def test_error(): raise Exception")
-            result = testdir.runpytest()
-            assert result.ret == 1
-            # warnings from nodeids, lastfailed, and stepwise
-            result.stdout.fnmatch_lines(
-                [
-                    # Validate location/stacklevel of warning from cacheprovider.
-                    "*= warnings summary =*",
-                    "*/cacheprovider.py:*",
-                    "  */cacheprovider.py:*: PytestCacheWarning: could not create cache path "
-                    "{}/v/cache/nodeids".format(cache_dir),
-                    '    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))',
-                    "*1 failed, 3 warnings in*",
-                ]
-            )
-        finally:
-            testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
 
-    def test_config_cache(self, testdir):
-        testdir.makeconftest(
+        pytester.makepyfile("def test_error(): raise Exception")
+        result = pytester.runpytest()
+        assert result.ret == 1
+        # warnings from nodeids, lastfailed, and stepwise
+        result.stdout.fnmatch_lines(
+            [
+                # Validate location/stacklevel of warning from cacheprovider.
+                "*= warnings summary =*",
+                "*/cacheprovider.py:*",
+                "  */cacheprovider.py:*: PytestCacheWarning: could not create cache path "
+                f"{unwritable_cache_dir}/v/cache/nodeids: *",
+                '    config.cache.set("cache/nodeids", sorted(self.cached_nodeids))',
+                "*1 failed, 3 warnings in*",
+            ]
+        )
+
+    def test_config_cache(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             def pytest_configure(config):
                 # see that we get cache information early on
                 assert hasattr(config, "cache")
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_session(pytestconfig):
                 assert hasattr(pytestconfig, "cache")
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 0
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_cachefuncarg(self, testdir):
-        testdir.makepyfile(
+    def test_cachefuncarg(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def test_cachefuncarg(cache):
@@ -114,13 +126,13 @@ class TestNewAPI:
                 assert val == [1]
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 0
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_custom_rel_cache_dir(self, testdir):
+    def test_custom_rel_cache_dir(self, pytester: Pytester) -> None:
         rel_cache_dir = os.path.join("custom_cache_dir", "subdir")
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             cache_dir = {cache_dir}
@@ -128,14 +140,16 @@ class TestNewAPI:
                 cache_dir=rel_cache_dir
             )
         )
-        testdir.makepyfile(test_errored="def test_error():\n    assert False")
-        testdir.runpytest()
-        assert testdir.tmpdir.join(rel_cache_dir).isdir()
+        pytester.makepyfile(test_errored="def test_error():\n    assert False")
+        pytester.runpytest()
+        assert pytester.path.joinpath(rel_cache_dir).is_dir()
 
-    def test_custom_abs_cache_dir(self, testdir, tmpdir_factory):
-        tmp = str(tmpdir_factory.mktemp("tmp"))
-        abs_cache_dir = os.path.join(tmp, "custom_cache_dir")
-        testdir.makeini(
+    def test_custom_abs_cache_dir(
+        self, pytester: Pytester, tmp_path_factory: TempPathFactory
+    ) -> None:
+        tmp = tmp_path_factory.mktemp("tmp")
+        abs_cache_dir = tmp / "custom_cache_dir"
+        pytester.makeini(
             """
             [pytest]
             cache_dir = {cache_dir}
@@ -143,13 +157,15 @@ class TestNewAPI:
                 cache_dir=abs_cache_dir
             )
         )
-        testdir.makepyfile(test_errored="def test_error():\n    assert False")
-        testdir.runpytest()
-        assert py.path.local(abs_cache_dir).isdir()
+        pytester.makepyfile(test_errored="def test_error():\n    assert False")
+        pytester.runpytest()
+        assert abs_cache_dir.is_dir()
 
-    def test_custom_cache_dir_with_env_var(self, testdir, monkeypatch):
+    def test_custom_cache_dir_with_env_var(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
         monkeypatch.setenv("env_var", "custom_cache_dir")
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             cache_dir = {cache_dir}
@@ -157,31 +173,33 @@ class TestNewAPI:
                 cache_dir="$env_var"
             )
         )
-        testdir.makepyfile(test_errored="def test_error():\n    assert False")
-        testdir.runpytest()
-        assert testdir.tmpdir.join("custom_cache_dir").isdir()
+        pytester.makepyfile(test_errored="def test_error():\n    assert False")
+        pytester.runpytest()
+        assert pytester.path.joinpath("custom_cache_dir").is_dir()
 
 
 @pytest.mark.parametrize("env", ((), ("TOX_ENV_DIR", "/tox_env_dir")))
-def test_cache_reportheader(env, testdir, monkeypatch):
-    testdir.makepyfile("""def test_foo(): pass""")
+def test_cache_reportheader(env, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
+    pytester.makepyfile("""def test_foo(): pass""")
     if env:
         monkeypatch.setenv(*env)
         expected = os.path.join(env[1], ".pytest_cache")
     else:
         monkeypatch.delenv("TOX_ENV_DIR", raising=False)
         expected = ".pytest_cache"
-    result = testdir.runpytest("-v")
+    result = pytester.runpytest("-v")
     result.stdout.fnmatch_lines(["cachedir: %s" % expected])
 
 
-def test_cache_reportheader_external_abspath(testdir, tmpdir_factory):
-    external_cache = tmpdir_factory.mktemp(
+def test_cache_reportheader_external_abspath(
+    pytester: Pytester, tmp_path_factory: TempPathFactory
+) -> None:
+    external_cache = tmp_path_factory.mktemp(
         "test_cache_reportheader_external_abspath_abs"
     )
 
-    testdir.makepyfile("def test_hello(): pass")
-    testdir.makeini(
+    pytester.makepyfile("def test_hello(): pass")
+    pytester.makeini(
         """
     [pytest]
     cache_dir = {abscache}
@@ -189,29 +207,29 @@ def test_cache_reportheader_external_abspath(testdir, tmpdir_factory):
             abscache=external_cache
         )
     )
-    result = testdir.runpytest("-v")
+    result = pytester.runpytest("-v")
     result.stdout.fnmatch_lines([f"cachedir: {external_cache}"])
 
 
-def test_cache_show(testdir):
-    result = testdir.runpytest("--cache-show")
+def test_cache_show(pytester: Pytester) -> None:
+    result = pytester.runpytest("--cache-show")
     assert result.ret == 0
     result.stdout.fnmatch_lines(["*cache is empty*"])
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         def pytest_configure(config):
             config.cache.set("my/name", [1,2,3])
             config.cache.set("my/hello", "world")
             config.cache.set("other/some", {1:2})
-            dp = config.cache.makedir("mydb")
-            dp.ensure("hello")
-            dp.ensure("world")
+            dp = config.cache.mkdir("mydb")
+            dp.joinpath("hello").touch()
+            dp.joinpath("world").touch()
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 5  # no tests executed
 
-    result = testdir.runpytest("--cache-show")
+    result = pytester.runpytest("--cache-show")
     result.stdout.fnmatch_lines(
         [
             "*cachedir:*",
@@ -228,7 +246,7 @@ def test_cache_show(testdir):
     )
     assert result.ret == 0
 
-    result = testdir.runpytest("--cache-show", "*/hello")
+    result = pytester.runpytest("--cache-show", "*/hello")
     result.stdout.fnmatch_lines(
         [
             "*cachedir:*",
@@ -246,25 +264,27 @@ def test_cache_show(testdir):
 
 
 class TestLastFailed:
-    def test_lastfailed_usecase(self, testdir, monkeypatch):
+    def test_lastfailed_usecase(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
         monkeypatch.setattr("sys.dont_write_bytecode", True)
-        p = testdir.makepyfile(
+        p = pytester.makepyfile(
             """
             def test_1(): assert 0
             def test_2(): assert 0
             def test_3(): assert 1
             """
         )
-        result = testdir.runpytest(str(p))
+        result = pytester.runpytest(str(p))
         result.stdout.fnmatch_lines(["*2 failed*"])
-        p = testdir.makepyfile(
+        p = pytester.makepyfile(
             """
             def test_1(): assert 1
             def test_2(): assert 1
             def test_3(): assert 0
             """
         )
-        result = testdir.runpytest(str(p), "--lf")
+        result = pytester.runpytest(str(p), "--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 3 items / 1 deselected / 2 selected",
@@ -272,7 +292,7 @@ class TestLastFailed:
                 "*= 2 passed, 1 deselected in *",
             ]
         )
-        result = testdir.runpytest(str(p), "--lf")
+        result = pytester.runpytest(str(p), "--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 3 items",
@@ -280,27 +300,27 @@ class TestLastFailed:
                 "*1 failed*2 passed*",
             ]
         )
-        testdir.tmpdir.join(".pytest_cache").mkdir(".git")
-        result = testdir.runpytest(str(p), "--lf", "--cache-clear")
+        pytester.path.joinpath(".pytest_cache", ".git").mkdir(parents=True)
+        result = pytester.runpytest(str(p), "--lf", "--cache-clear")
         result.stdout.fnmatch_lines(["*1 failed*2 passed*"])
-        assert testdir.tmpdir.join(".pytest_cache", "README.md").isfile()
-        assert testdir.tmpdir.join(".pytest_cache", ".git").isdir()
+        assert pytester.path.joinpath(".pytest_cache", "README.md").is_file()
+        assert pytester.path.joinpath(".pytest_cache", ".git").is_dir()
 
         # Run this again to make sure clear-cache is robust
         if os.path.isdir(".pytest_cache"):
             shutil.rmtree(".pytest_cache")
-        result = testdir.runpytest("--lf", "--cache-clear")
+        result = pytester.runpytest("--lf", "--cache-clear")
         result.stdout.fnmatch_lines(["*1 failed*2 passed*"])
 
-    def test_failedfirst_order(self, testdir):
-        testdir.makepyfile(
+    def test_failedfirst_order(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_a="def test_always_passes(): pass",
             test_b="def test_always_fails(): assert 0",
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         # Test order will be collection order; alphabetical
         result.stdout.fnmatch_lines(["test_a.py*", "test_b.py*"])
-        result = testdir.runpytest("--ff")
+        result = pytester.runpytest("--ff")
         # Test order will be failing tests first
         result.stdout.fnmatch_lines(
             [
@@ -311,40 +331,42 @@ class TestLastFailed:
             ]
         )
 
-    def test_lastfailed_failedfirst_order(self, testdir):
-        testdir.makepyfile(
+    def test_lastfailed_failedfirst_order(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_a="def test_always_passes(): assert 1",
             test_b="def test_always_fails(): assert 0",
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         # Test order will be collection order; alphabetical
         result.stdout.fnmatch_lines(["test_a.py*", "test_b.py*"])
-        result = testdir.runpytest("--lf", "--ff")
+        result = pytester.runpytest("--lf", "--ff")
         # Test order will be failing tests first
         result.stdout.fnmatch_lines(["test_b.py*"])
         result.stdout.no_fnmatch_line("*test_a.py*")
 
-    def test_lastfailed_difference_invocations(self, testdir, monkeypatch):
+    def test_lastfailed_difference_invocations(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
         monkeypatch.setattr("sys.dont_write_bytecode", True)
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_a="""
                 def test_a1(): assert 0
                 def test_a2(): assert 1
             """,
             test_b="def test_b1(): assert 0",
         )
-        p = testdir.tmpdir.join("test_a.py")
-        p2 = testdir.tmpdir.join("test_b.py")
+        p = pytester.path.joinpath("test_a.py")
+        p2 = pytester.path.joinpath("test_b.py")
 
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 failed*"])
-        result = testdir.runpytest("--lf", p2)
+        result = pytester.runpytest("--lf", p2)
         result.stdout.fnmatch_lines(["*1 failed*"])
 
-        testdir.makepyfile(test_b="def test_b1(): assert 1")
-        result = testdir.runpytest("--lf", p2)
+        pytester.makepyfile(test_b="def test_b1(): assert 1")
+        result = pytester.runpytest("--lf", p2)
         result.stdout.fnmatch_lines(["*1 passed*"])
-        result = testdir.runpytest("--lf", p)
+        result = pytester.runpytest("--lf", p)
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items / 1 deselected / 1 selected",
@@ -353,21 +375,23 @@ class TestLastFailed:
             ]
         )
 
-    def test_lastfailed_usecase_splice(self, testdir, monkeypatch):
+    def test_lastfailed_usecase_splice(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
         monkeypatch.setattr("sys.dont_write_bytecode", True)
-        testdir.makepyfile(
+        pytester.makepyfile(
             "def test_1(): assert 0", test_something="def test_2(): assert 0"
         )
-        p2 = testdir.tmpdir.join("test_something.py")
-        result = testdir.runpytest()
+        p2 = pytester.path.joinpath("test_something.py")
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 failed*"])
-        result = testdir.runpytest("--lf", p2)
+        result = pytester.runpytest("--lf", p2)
         result.stdout.fnmatch_lines(["*1 failed*"])
-        result = testdir.runpytest("--lf")
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(["*2 failed*"])
 
-    def test_lastfailed_xpass(self, testdir):
-        testdir.inline_runsource(
+    def test_lastfailed_xpass(self, pytester: Pytester) -> None:
+        pytester.inline_runsource(
             """
             import pytest
             @pytest.mark.xfail
@@ -375,15 +399,16 @@ class TestLastFailed:
                 assert 1
         """
         )
-        config = testdir.parseconfigure()
+        config = pytester.parseconfigure()
+        assert config.cache is not None
         lastfailed = config.cache.get("cache/lastfailed", -1)
         assert lastfailed == -1
 
-    def test_non_serializable_parametrize(self, testdir):
+    def test_non_serializable_parametrize(self, pytester: Pytester) -> None:
         """Test that failed parametrized tests with unmarshable parameters
         don't break pytest-cache.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             r"""
             import pytest
 
@@ -394,26 +419,32 @@ class TestLastFailed:
                 assert False
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 failed in*"])
 
-    def test_terminal_report_lastfailed(self, testdir):
-        test_a = testdir.makepyfile(
+    @pytest.mark.parametrize("parent", ("session", "package"))
+    def test_terminal_report_lastfailed(self, pytester: Pytester, parent: str) -> None:
+        if parent == "package":
+            pytester.makepyfile(
+                __init__="",
+            )
+
+        test_a = pytester.makepyfile(
             test_a="""
             def test_a1(): pass
             def test_a2(): pass
         """
         )
-        test_b = testdir.makepyfile(
+        test_b = pytester.makepyfile(
             test_b="""
             def test_b1(): assert 0
             def test_b2(): assert 0
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 4 items", "*2 failed, 2 passed in*"])
 
-        result = testdir.runpytest("--lf")
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -422,7 +453,7 @@ class TestLastFailed:
             ]
         )
 
-        result = testdir.runpytest(test_a, "--lf")
+        result = pytester.runpytest(test_a, "--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -431,7 +462,7 @@ class TestLastFailed:
             ]
         )
 
-        result = testdir.runpytest(test_b, "--lf")
+        result = pytester.runpytest(test_b, "--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -440,7 +471,7 @@ class TestLastFailed:
             ]
         )
 
-        result = testdir.runpytest("test_b.py::test_b1", "--lf")
+        result = pytester.runpytest("test_b.py::test_b1", "--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 1 item",
@@ -449,17 +480,17 @@ class TestLastFailed:
             ]
         )
 
-    def test_terminal_report_failedfirst(self, testdir):
-        testdir.makepyfile(
+    def test_terminal_report_failedfirst(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             test_a="""
             def test_a1(): assert 0
             def test_a2(): pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 2 items", "*1 failed, 1 passed in*"])
 
-        result = testdir.runpytest("--ff")
+        result = pytester.runpytest("--ff")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -468,9 +499,10 @@ class TestLastFailed:
             ]
         )
 
-    def test_lastfailed_collectfailure(self, testdir, monkeypatch):
-
-        testdir.makepyfile(
+    def test_lastfailed_collectfailure(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
+        pytester.makepyfile(
             test_maybe="""
             import os
             env = os.environ
@@ -485,8 +517,9 @@ class TestLastFailed:
             monkeypatch.setenv("FAILIMPORT", str(fail_import))
             monkeypatch.setenv("FAILTEST", str(fail_run))
 
-            testdir.runpytest("-q")
-            config = testdir.parseconfigure()
+            pytester.runpytest("-q")
+            config = pytester.parseconfigure()
+            assert config.cache is not None
             lastfailed = config.cache.get("cache/lastfailed", -1)
             return lastfailed
 
@@ -499,8 +532,10 @@ class TestLastFailed:
         lastfailed = rlf(fail_import=0, fail_run=1)
         assert list(lastfailed) == ["test_maybe.py::test_hello"]
 
-    def test_lastfailed_failure_subset(self, testdir, monkeypatch):
-        testdir.makepyfile(
+    def test_lastfailed_failure_subset(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
+        pytester.makepyfile(
             test_maybe="""
             import os
             env = os.environ
@@ -511,7 +546,7 @@ class TestLastFailed:
         """
         )
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_maybe2="""
             import os
             env = os.environ
@@ -530,8 +565,9 @@ class TestLastFailed:
             monkeypatch.setenv("FAILIMPORT", str(fail_import))
             monkeypatch.setenv("FAILTEST", str(fail_run))
 
-            result = testdir.runpytest("-q", "--lf", *args)
-            config = testdir.parseconfigure()
+            result = pytester.runpytest("-q", "--lf", *args)
+            config = pytester.parseconfigure()
+            assert config.cache is not None
             lastfailed = config.cache.get("cache/lastfailed", -1)
             return result, lastfailed
 
@@ -552,61 +588,63 @@ class TestLastFailed:
         assert list(lastfailed) == ["test_maybe.py"]
         result.stdout.fnmatch_lines(["*2 passed*"])
 
-    def test_lastfailed_creates_cache_when_needed(self, testdir):
+    def test_lastfailed_creates_cache_when_needed(self, pytester: Pytester) -> None:
         # Issue #1342
-        testdir.makepyfile(test_empty="")
-        testdir.runpytest("-q", "--lf")
+        pytester.makepyfile(test_empty="")
+        pytester.runpytest("-q", "--lf")
         assert not os.path.exists(".pytest_cache/v/cache/lastfailed")
 
-        testdir.makepyfile(test_successful="def test_success():\n    assert True")
-        testdir.runpytest("-q", "--lf")
+        pytester.makepyfile(test_successful="def test_success():\n    assert True")
+        pytester.runpytest("-q", "--lf")
         assert not os.path.exists(".pytest_cache/v/cache/lastfailed")
 
-        testdir.makepyfile(test_errored="def test_error():\n    assert False")
-        testdir.runpytest("-q", "--lf")
+        pytester.makepyfile(test_errored="def test_error():\n    assert False")
+        pytester.runpytest("-q", "--lf")
         assert os.path.exists(".pytest_cache/v/cache/lastfailed")
 
-    def test_xfail_not_considered_failure(self, testdir):
-        testdir.makepyfile(
+    def test_xfail_not_considered_failure(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.xfail
             def test(): assert 0
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 xfailed*"])
-        assert self.get_cached_last_failed(testdir) == []
+        assert self.get_cached_last_failed(pytester) == []
 
-    def test_xfail_strict_considered_failure(self, testdir):
-        testdir.makepyfile(
+    def test_xfail_strict_considered_failure(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.xfail(strict=True)
             def test(): pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*1 failed*"])
-        assert self.get_cached_last_failed(testdir) == [
+        assert self.get_cached_last_failed(pytester) == [
             "test_xfail_strict_considered_failure.py::test"
         ]
 
     @pytest.mark.parametrize("mark", ["mark.xfail", "mark.skip"])
-    def test_failed_changed_to_xfail_or_skip(self, testdir, mark):
-        testdir.makepyfile(
+    def test_failed_changed_to_xfail_or_skip(
+        self, pytester: Pytester, mark: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def test(): assert 0
         """
         )
-        result = testdir.runpytest()
-        assert self.get_cached_last_failed(testdir) == [
+        result = pytester.runpytest()
+        assert self.get_cached_last_failed(pytester) == [
             "test_failed_changed_to_xfail_or_skip.py::test"
         ]
         assert result.ret == 1
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             @pytest.{mark}
@@ -615,66 +653,69 @@ class TestLastFailed:
                 mark=mark
             )
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         assert result.ret == 0
-        assert self.get_cached_last_failed(testdir) == []
+        assert self.get_cached_last_failed(pytester) == []
         assert result.ret == 0
 
     @pytest.mark.parametrize("quiet", [True, False])
     @pytest.mark.parametrize("opt", ["--ff", "--lf"])
-    def test_lf_and_ff_prints_no_needless_message(self, quiet, opt, testdir):
+    def test_lf_and_ff_prints_no_needless_message(
+        self, quiet: bool, opt: str, pytester: Pytester
+    ) -> None:
         # Issue 3853
-        testdir.makepyfile("def test(): assert 0")
+        pytester.makepyfile("def test(): assert 0")
         args = [opt]
         if quiet:
             args.append("-q")
-        result = testdir.runpytest(*args)
+        result = pytester.runpytest(*args)
         result.stdout.no_fnmatch_line("*run all*")
 
-        result = testdir.runpytest(*args)
+        result = pytester.runpytest(*args)
         if quiet:
             result.stdout.no_fnmatch_line("*run all*")
         else:
             assert "rerun previous" in result.stdout.str()
 
-    def get_cached_last_failed(self, testdir):
-        config = testdir.parseconfigure()
+    def get_cached_last_failed(self, pytester: Pytester) -> List[str]:
+        config = pytester.parseconfigure()
+        assert config.cache is not None
         return sorted(config.cache.get("cache/lastfailed", {}))
 
-    def test_cache_cumulative(self, testdir):
+    def test_cache_cumulative(self, pytester: Pytester) -> None:
         """Test workflow where user fixes errors gradually file by file using --lf."""
         # 1. initial run
-        test_bar = testdir.makepyfile(
+        test_bar = pytester.makepyfile(
             test_bar="""
             def test_bar_1(): pass
             def test_bar_2(): assert 0
         """
         )
-        test_foo = testdir.makepyfile(
+        test_foo = pytester.makepyfile(
             test_foo="""
             def test_foo_3(): pass
             def test_foo_4(): assert 0
         """
         )
-        testdir.runpytest()
-        assert self.get_cached_last_failed(testdir) == [
+        pytester.runpytest()
+        assert self.get_cached_last_failed(pytester) == [
             "test_bar.py::test_bar_2",
             "test_foo.py::test_foo_4",
         ]
 
         # 2. fix test_bar_2, run only test_bar.py
-        testdir.makepyfile(
+        pytester.makepyfile(
             test_bar="""
             def test_bar_1(): pass
             def test_bar_2(): pass
         """
         )
-        result = testdir.runpytest(test_bar)
+        result = pytester.runpytest(test_bar)
         result.stdout.fnmatch_lines(["*2 passed*"])
         # ensure cache does not forget that test_foo_4 failed once before
-        assert self.get_cached_last_failed(testdir) == ["test_foo.py::test_foo_4"]
+        assert self.get_cached_last_failed(pytester) == ["test_foo.py::test_foo_4"]
 
-        result = testdir.runpytest("--last-failed")
+        result = pytester.runpytest("--last-failed")
         result.stdout.fnmatch_lines(
             [
                 "collected 1 item",
@@ -682,16 +723,16 @@ class TestLastFailed:
                 "*= 1 failed in *",
             ]
         )
-        assert self.get_cached_last_failed(testdir) == ["test_foo.py::test_foo_4"]
+        assert self.get_cached_last_failed(pytester) == ["test_foo.py::test_foo_4"]
 
         # 3. fix test_foo_4, run only test_foo.py
-        test_foo = testdir.makepyfile(
+        test_foo = pytester.makepyfile(
             test_foo="""
             def test_foo_3(): pass
             def test_foo_4(): pass
         """
         )
-        result = testdir.runpytest(test_foo, "--last-failed")
+        result = pytester.runpytest(test_foo, "--last-failed")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items / 1 deselected / 1 selected",
@@ -699,29 +740,31 @@ class TestLastFailed:
                 "*= 1 passed, 1 deselected in *",
             ]
         )
-        assert self.get_cached_last_failed(testdir) == []
+        assert self.get_cached_last_failed(pytester) == []
 
-        result = testdir.runpytest("--last-failed")
+        result = pytester.runpytest("--last-failed")
         result.stdout.fnmatch_lines(["*4 passed*"])
-        assert self.get_cached_last_failed(testdir) == []
+        assert self.get_cached_last_failed(pytester) == []
 
-    def test_lastfailed_no_failures_behavior_all_passed(self, testdir):
-        testdir.makepyfile(
+    def test_lastfailed_no_failures_behavior_all_passed(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             def test_1(): pass
             def test_2(): pass
         """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["*2 passed*"])
-        result = testdir.runpytest("--lf")
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(["*2 passed*"])
-        result = testdir.runpytest("--lf", "--lfnf", "all")
+        result = pytester.runpytest("--lf", "--lfnf", "all")
         result.stdout.fnmatch_lines(["*2 passed*"])
 
         # Ensure the list passed to pytest_deselected is a copy,
         # and not a reference which is cleared right after.
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             deselected = []
 
@@ -734,10 +777,10 @@ class TestLastFailed:
         """
         )
 
-        result = testdir.runpytest("--lf", "--lfnf", "none")
+        result = pytester.runpytest("--lf", "--lfnf", "none")
         result.stdout.fnmatch_lines(
             [
-                "collected 2 items / 2 deselected",
+                "collected 2 items / 2 deselected / 0 selected",
                 "run-last-failure: no previously failed tests, deselecting all items.",
                 "deselected=2",
                 "* 2 deselected in *",
@@ -745,26 +788,28 @@ class TestLastFailed:
         )
         assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
-    def test_lastfailed_no_failures_behavior_empty_cache(self, testdir):
-        testdir.makepyfile(
+    def test_lastfailed_no_failures_behavior_empty_cache(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             """
             def test_1(): pass
             def test_2(): assert 0
         """
         )
-        result = testdir.runpytest("--lf", "--cache-clear")
+        result = pytester.runpytest("--lf", "--cache-clear")
         result.stdout.fnmatch_lines(["*1 failed*1 passed*"])
-        result = testdir.runpytest("--lf", "--cache-clear", "--lfnf", "all")
+        result = pytester.runpytest("--lf", "--cache-clear", "--lfnf", "all")
         result.stdout.fnmatch_lines(["*1 failed*1 passed*"])
-        result = testdir.runpytest("--lf", "--cache-clear", "--lfnf", "none")
+        result = pytester.runpytest("--lf", "--cache-clear", "--lfnf", "none")
         result.stdout.fnmatch_lines(["*2 desel*"])
 
-    def test_lastfailed_skip_collection(self, testdir):
+    def test_lastfailed_skip_collection(self, pytester: Pytester) -> None:
         """
         Test --lf behavior regarding skipping collection of files that are not marked as
         failed in the cache (#5172).
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             **{
                 "pkg1/test_1.py": """
                 import pytest
@@ -782,10 +827,10 @@ class TestLastFailed:
             }
         )
         # first run: collects 8 items (test_1: 3, test_2: 5)
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 8 items", "*2 failed*6 passed*"])
         # second run: collects only 5 items from test_2, because all tests from test_1 have passed
-        result = testdir.runpytest("--lf")
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -795,14 +840,14 @@ class TestLastFailed:
         )
 
         # add another file and check if message is correct when skipping more than 1 file
-        testdir.makepyfile(
+        pytester.makepyfile(
             **{
                 "pkg1/test_3.py": """
                 def test_3(): pass
             """
             }
         )
-        result = testdir.runpytest("--lf")
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -811,18 +856,47 @@ class TestLastFailed:
             ]
         )
 
-    def test_lastfailed_with_known_failures_not_being_selected(self, testdir):
-        testdir.makepyfile(
+    def test_lastfailed_skip_collection_with_nesting(self, pytester: Pytester) -> None:
+        """Check that file skipping works even when the file with failures is
+        nested at a different level of the collection tree."""
+        pytester.makepyfile(
+            **{
+                "test_1.py": """
+                    def test_1(): pass
+                """,
+                "pkg/__init__.py": "",
+                "pkg/test_2.py": """
+                    def test_2(): assert False
+                """,
+            }
+        )
+        # first run
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines(["collected 2 items", "*1 failed*1 passed*"])
+        # second run - test_1.py is skipped.
+        result = pytester.runpytest("--lf")
+        result.stdout.fnmatch_lines(
+            [
+                "collected 1 item",
+                "run-last-failure: rerun previous 1 failure (skipped 1 file)",
+                "*= 1 failed in *",
+            ]
+        )
+
+    def test_lastfailed_with_known_failures_not_being_selected(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             **{
                 "pkg1/test_1.py": """def test_1(): assert 0""",
                 "pkg1/test_2.py": """def test_2(): pass""",
             }
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 2 items", "* 1 failed, 1 passed in *"])
 
-        py.path.local("pkg1/test_1.py").remove()
-        result = testdir.runpytest("--lf")
+        Path("pkg1/test_1.py").unlink()
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 1 item",
@@ -832,8 +906,8 @@ class TestLastFailed:
         )
 
         # Recreate file with known failure.
-        testdir.makepyfile(**{"pkg1/test_1.py": """def test_1(): assert 0"""})
-        result = testdir.runpytest("--lf")
+        pytester.makepyfile(**{"pkg1/test_1.py": """def test_1(): assert 0"""})
+        result = pytester.runpytest("--lf")
         result.stdout.fnmatch_lines(
             [
                 "collected 1 item",
@@ -843,8 +917,8 @@ class TestLastFailed:
         )
 
         # Remove/rename test: collects the file again.
-        testdir.makepyfile(**{"pkg1/test_1.py": """def test_renamed(): assert 0"""})
-        result = testdir.runpytest("--lf", "-rf")
+        pytester.makepyfile(**{"pkg1/test_1.py": """def test_renamed(): assert 0"""})
+        result = pytester.runpytest("--lf", "-rf")
         result.stdout.fnmatch_lines(
             [
                 "collected 2 items",
@@ -856,7 +930,7 @@ class TestLastFailed:
             ]
         )
 
-        result = testdir.runpytest("--lf", "--co")
+        result = pytester.runpytest("--lf", "--co")
         result.stdout.fnmatch_lines(
             [
                 "collected 1 item",
@@ -867,13 +941,13 @@ class TestLastFailed:
             ]
         )
 
-    def test_lastfailed_args_with_deselected(self, testdir: Testdir) -> None:
+    def test_lastfailed_args_with_deselected(self, pytester: Pytester) -> None:
         """Test regression with --lf running into NoMatch error.
 
         This was caused by it not collecting (non-failed) nodes given as
         arguments.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             **{
                 "pkg1/test_1.py": """
                     def test_pass(): pass
@@ -881,11 +955,11 @@ class TestLastFailed:
                 """,
             }
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 2 items", "* 1 failed, 1 passed in *"])
         assert result.ret == 1
 
-        result = testdir.runpytest("pkg1/test_1.py::test_pass", "--lf", "--co")
+        result = pytester.runpytest("pkg1/test_1.py::test_pass", "--lf", "--co")
         assert result.ret == 0
         result.stdout.fnmatch_lines(
             [
@@ -898,7 +972,7 @@ class TestLastFailed:
             consecutive=True,
         )
 
-        result = testdir.runpytest(
+        result = pytester.runpytest(
             "pkg1/test_1.py::test_pass", "pkg1/test_1.py::test_fail", "--lf", "--co"
         )
         assert result.ret == 0
@@ -913,9 +987,9 @@ class TestLastFailed:
             ],
         )
 
-    def test_lastfailed_with_class_items(self, testdir: Testdir) -> None:
+    def test_lastfailed_with_class_items(self, pytester: Pytester) -> None:
         """Test regression with --lf deselecting whole classes."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             **{
                 "pkg1/test_1.py": """
                     class TestFoo:
@@ -926,11 +1000,11 @@ class TestLastFailed:
                 """,
             }
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 3 items", "* 2 failed, 1 passed in *"])
         assert result.ret == 1
 
-        result = testdir.runpytest("--lf", "--co")
+        result = pytester.runpytest("--lf", "--co")
         assert result.ret == 0
         result.stdout.fnmatch_lines(
             [
@@ -939,7 +1013,7 @@ class TestLastFailed:
                 "",
                 "<Module pkg1/test_1.py>",
                 "  <Class TestFoo>",
-                "      <Function test_fail>",
+                "    <Function test_fail>",
                 "  <Function test_other>",
                 "",
                 "*= 2/3 tests collected (1 deselected) in *",
@@ -947,8 +1021,8 @@ class TestLastFailed:
             consecutive=True,
         )
 
-    def test_lastfailed_with_all_filtered(self, testdir: Testdir) -> None:
-        testdir.makepyfile(
+    def test_lastfailed_with_all_filtered(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             **{
                 "pkg1/test_1.py": """
                     def test_fail(): assert 0
@@ -956,19 +1030,19 @@ class TestLastFailed:
                 """,
             }
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(["collected 2 items", "* 1 failed, 1 passed in *"])
         assert result.ret == 1
 
         # Remove known failure.
-        testdir.makepyfile(
+        pytester.makepyfile(
             **{
                 "pkg1/test_1.py": """
                     def test_pass(): pass
                 """,
             }
         )
-        result = testdir.runpytest("--lf", "--co")
+        result = pytester.runpytest("--lf", "--co")
         result.stdout.fnmatch_lines(
             [
                 "collected 1 item",
@@ -1013,10 +1087,32 @@ class TestLastFailed:
         result = pytester.runpytest("--lf")
         result.assert_outcomes(failed=3)
 
+    def test_non_python_file_skipped(
+        self,
+        pytester: Pytester,
+        dummy_yaml_custom_test: None,
+    ) -> None:
+        pytester.makepyfile(
+            **{
+                "test_bad.py": """def test_bad(): assert False""",
+            },
+        )
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines(["collected 2 items", "* 1 failed, 1 passed in *"])
+
+        result = pytester.runpytest("--lf")
+        result.stdout.fnmatch_lines(
+            [
+                "collected 1 item",
+                "run-last-failure: rerun previous 1 failure (skipped 1 file)",
+                "* 1 failed in *",
+            ]
+        )
+
 
 class TestNewFirst:
-    def test_newfirst_usecase(self, testdir):
-        testdir.makepyfile(
+    def test_newfirst_usecase(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             **{
                 "test_1/test_1.py": """
                 def test_1(): assert 1
@@ -1026,24 +1122,26 @@ class TestNewFirst:
             """,
             }
         )
-        testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
 
-        result = testdir.runpytest("-v")
+        p1 = pytester.path.joinpath("test_1/test_1.py")
+        os.utime(p1, ns=(p1.stat().st_atime_ns, int(1e9)))
+
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             ["*test_1/test_1.py::test_1 PASSED*", "*test_2/test_2.py::test_1 PASSED*"]
         )
 
-        result = testdir.runpytest("-v", "--nf")
+        result = pytester.runpytest("-v", "--nf")
         result.stdout.fnmatch_lines(
             ["*test_2/test_2.py::test_1 PASSED*", "*test_1/test_1.py::test_1 PASSED*"]
         )
 
-        testdir.tmpdir.join("test_1/test_1.py").write(
-            "def test_1(): assert 1\n" "def test_2(): assert 1\n"
+        p1.write_text(
+            "def test_1(): assert 1\n" "def test_2(): assert 1\n", encoding="utf-8"
         )
-        testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
+        os.utime(p1, ns=(p1.stat().st_atime_ns, int(1e9)))
 
-        result = testdir.runpytest("--nf", "--collect-only", "-q")
+        result = pytester.runpytest("--nf", "--collect-only", "-q")
         result.stdout.fnmatch_lines(
             [
                 "test_1/test_1.py::test_2",
@@ -1053,15 +1151,15 @@ class TestNewFirst:
         )
 
         # Newest first with (plugin) pytest_collection_modifyitems hook.
-        testdir.makepyfile(
+        pytester.makepyfile(
             myplugin="""
             def pytest_collection_modifyitems(items):
                 items[:] = sorted(items, key=lambda item: item.nodeid)
                 print("new_items:", [x.nodeid for x in items])
             """
         )
-        testdir.syspathinsert()
-        result = testdir.runpytest("--nf", "-p", "myplugin", "--collect-only", "-q")
+        pytester.syspathinsert()
+        result = pytester.runpytest("--nf", "-p", "myplugin", "--collect-only", "-q")
         result.stdout.fnmatch_lines(
             [
                 "new_items: *test_1.py*test_1.py*test_2.py*",
@@ -1071,8 +1169,8 @@ class TestNewFirst:
             ]
         )
 
-    def test_newfirst_parametrize(self, testdir):
-        testdir.makepyfile(
+    def test_newfirst_parametrize(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             **{
                 "test_1/test_1.py": """
                 import pytest
@@ -1087,9 +1185,10 @@ class TestNewFirst:
             }
         )
 
-        testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
+        p1 = pytester.path.joinpath("test_1/test_1.py")
+        os.utime(p1, ns=(p1.stat().st_atime_ns, int(1e9)))
 
-        result = testdir.runpytest("-v")
+        result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
             [
                 "*test_1/test_1.py::test_1[1*",
@@ -1099,7 +1198,7 @@ class TestNewFirst:
             ]
         )
 
-        result = testdir.runpytest("-v", "--nf")
+        result = pytester.runpytest("-v", "--nf")
         result.stdout.fnmatch_lines(
             [
                 "*test_2/test_2.py::test_1[1*",
@@ -1109,20 +1208,21 @@ class TestNewFirst:
             ]
         )
 
-        testdir.tmpdir.join("test_1/test_1.py").write(
+        p1.write_text(
             "import pytest\n"
             "@pytest.mark.parametrize('num', [1, 2, 3])\n"
-            "def test_1(num): assert num\n"
+            "def test_1(num): assert num\n",
+            encoding="utf-8",
         )
-        testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
+        os.utime(p1, ns=(p1.stat().st_atime_ns, int(1e9)))
 
         # Running only a subset does not forget about existing ones.
-        result = testdir.runpytest("-v", "--nf", "test_2/test_2.py")
+        result = pytester.runpytest("-v", "--nf", "test_2/test_2.py")
         result.stdout.fnmatch_lines(
             ["*test_2/test_2.py::test_1[1*", "*test_2/test_2.py::test_1[2*"]
         )
 
-        result = testdir.runpytest("-v", "--nf")
+        result = pytester.runpytest("-v", "--nf")
         result.stdout.fnmatch_lines(
             [
                 "*test_1/test_1.py::test_1[3*",
@@ -1135,27 +1235,28 @@ class TestNewFirst:
 
 
 class TestReadme:
-    def check_readme(self, testdir):
-        config = testdir.parseconfigure()
+    def check_readme(self, pytester: Pytester) -> bool:
+        config = pytester.parseconfigure()
+        assert config.cache is not None
         readme = config.cache._cachedir.joinpath("README.md")
         return readme.is_file()
 
-    def test_readme_passed(self, testdir):
-        testdir.makepyfile("def test_always_passes(): pass")
-        testdir.runpytest()
-        assert self.check_readme(testdir) is True
+    def test_readme_passed(self, pytester: Pytester) -> None:
+        pytester.makepyfile("def test_always_passes(): pass")
+        pytester.runpytest()
+        assert self.check_readme(pytester) is True
 
-    def test_readme_failed(self, testdir):
-        testdir.makepyfile("def test_always_fails(): assert 0")
-        testdir.runpytest()
-        assert self.check_readme(testdir) is True
+    def test_readme_failed(self, pytester: Pytester) -> None:
+        pytester.makepyfile("def test_always_fails(): assert 0")
+        pytester.runpytest()
+        assert self.check_readme(pytester) is True
 
 
-def test_gitignore(testdir):
+def test_gitignore(pytester: Pytester) -> None:
     """Ensure we automatically create .gitignore file in the pytest_cache directory (#3286)."""
     from _pytest.cacheprovider import Cache
 
-    config = testdir.parseconfig()
+    config = pytester.parseconfig()
     cache = Cache.for_config(config, _ispytest=True)
     cache.set("foo", "bar")
     msg = "# Created by pytest automatically.\n*\n"
@@ -1163,21 +1264,32 @@ def test_gitignore(testdir):
     assert gitignore_path.read_text(encoding="UTF-8") == msg
 
     # Does not overwrite existing/custom one.
-    gitignore_path.write_text("custom")
+    gitignore_path.write_text("custom", encoding="utf-8")
     cache.set("something", "else")
     assert gitignore_path.read_text(encoding="UTF-8") == "custom"
 
 
-def test_does_not_create_boilerplate_in_existing_dirs(testdir):
+def test_preserve_keys_order(pytester: Pytester) -> None:
+    """Ensure keys order is preserved when saving dicts (#9205)."""
+    from _pytest.cacheprovider import Cache
+
+    config = pytester.parseconfig()
+    cache = Cache.for_config(config, _ispytest=True)
+    cache.set("foo", {"z": 1, "b": 2, "a": 3, "d": 10})
+    read_back = cache.get("foo", None)
+    assert list(read_back.items()) == [("z", 1), ("b", 2), ("a", 3), ("d", 10)]
+
+
+def test_does_not_create_boilerplate_in_existing_dirs(pytester: Pytester) -> None:
     from _pytest.cacheprovider import Cache
 
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         cache_dir = .
         """
     )
-    config = testdir.parseconfig()
+    config = pytester.parseconfig()
     cache = Cache.for_config(config, _ispytest=True)
     cache.set("foo", "bar")
 
@@ -1186,13 +1298,18 @@ def test_does_not_create_boilerplate_in_existing_dirs(testdir):
     assert not os.path.exists("README.md")
 
 
-def test_cachedir_tag(testdir):
+def test_cachedir_tag(pytester: Pytester) -> None:
     """Ensure we automatically create CACHEDIR.TAG file in the pytest_cache directory (#4278)."""
     from _pytest.cacheprovider import Cache
     from _pytest.cacheprovider import CACHEDIR_TAG_CONTENT
 
-    config = testdir.parseconfig()
+    config = pytester.parseconfig()
     cache = Cache.for_config(config, _ispytest=True)
     cache.set("foo", "bar")
     cachedir_tag_path = cache._cachedir.joinpath("CACHEDIR.TAG")
     assert cachedir_tag_path.read_bytes() == CACHEDIR_TAG_CONTENT
+
+
+def test_clioption_with_cacheshow_and_help(pytester: Pytester) -> None:
+    result = pytester.runpytest("--cache-show", "--help")
+    assert result.ret == 0
index 3a5c617fe5a438fb4d63cc37968342d8a55b8533..b6ea8161356ea8d4b316e2908312835850ff0641 100644 (file)
@@ -750,9 +750,10 @@ def test_setup_failure_does_not_kill_capturing(pytester: Pytester) -> None:
             def pytest_runtest_setup(item):
                 raise ValueError(42)
             """
-        )
+        ),
+        encoding="utf-8",
     )
-    sub1.joinpath("test_mod.py").write_text("def test_func1(): pass")
+    sub1.joinpath("test_mod.py").write_text("def test_func1(): pass", encoding="utf-8")
     result = pytester.runpytest(pytester.path, "--traceconfig")
     result.stdout.fnmatch_lines(["*ValueError(42)*", "*1 error*"])
 
@@ -890,14 +891,26 @@ def test_dontreadfrominput() -> None:
     from _pytest.capture import DontReadFromInput
 
     f = DontReadFromInput()
-    assert f.buffer is f
+    assert f.buffer is f  # type: ignore[comparison-overlap]
     assert not f.isatty()
     pytest.raises(OSError, f.read)
     pytest.raises(OSError, f.readlines)
     iter_f = iter(f)
     pytest.raises(OSError, next, iter_f)
     pytest.raises(UnsupportedOperation, f.fileno)
+    pytest.raises(UnsupportedOperation, f.flush)
+    assert not f.readable()
+    pytest.raises(UnsupportedOperation, f.seek, 0)
+    assert not f.seekable()
+    pytest.raises(UnsupportedOperation, f.tell)
+    pytest.raises(UnsupportedOperation, f.truncate, 0)
+    pytest.raises(UnsupportedOperation, f.write, b"")
+    pytest.raises(UnsupportedOperation, f.writelines, [])
+    assert not f.writable()
+    assert isinstance(f.encoding, str)
     f.close()  # just for completeness
+    with f:
+        pass
 
 
 def test_captureresult() -> None:
@@ -1040,6 +1053,7 @@ class TestFDCapture:
                 )
             )
             # Should not crash with missing "_old".
+            assert isinstance(cap.syscapture, capture.SysCapture)
             assert repr(cap.syscapture) == (
                 "<SysCapture stdout _old=<UNSET> _state='done' tmpfile={!r}>".format(
                     cap.syscapture.tmpfile
@@ -1340,6 +1354,7 @@ def test_capsys_results_accessible_by_attribute(capsys: CaptureFixture[str]) ->
 
 def test_fdcapture_tmpfile_remains_the_same() -> None:
     cap = StdCaptureFD(out=False, err=True)
+    assert isinstance(cap.err, capture.FDCapture)
     try:
         cap.start_capturing()
         capfile = cap.err.tmpfile
@@ -1379,8 +1394,7 @@ def test_capturing_and_logging_fundamentals(pytester: Pytester, method: str) ->
     # here we check a fundamental feature
     p = pytester.makepyfile(
         """
-        import sys, os
-        import py, logging
+        import sys, os, logging
         from _pytest import capture
         cap = capture.MultiCapture(
             in_=None,
@@ -1431,21 +1445,22 @@ def test_error_attribute_issue555(pytester: Pytester) -> None:
 
 
 @pytest.mark.skipif(
-    not sys.platform.startswith("win"), reason="only on windows",
+    not sys.platform.startswith("win"),
+    reason="only on windows",
 )
-def test_py36_windowsconsoleio_workaround_non_standard_streams() -> None:
+def test_windowsconsoleio_workaround_non_standard_streams() -> None:
     """
-    Ensure _py36_windowsconsoleio_workaround function works with objects that
+    Ensure _windowsconsoleio_workaround function works with objects that
     do not implement the full ``io``-based stream protocol, for example execnet channels (#2666).
     """
-    from _pytest.capture import _py36_windowsconsoleio_workaround
+    from _pytest.capture import _windowsconsoleio_workaround
 
     class DummyStream:
         def write(self, s):
             pass
 
     stream = cast(TextIO, DummyStream())
-    _py36_windowsconsoleio_workaround(stream)
+    _windowsconsoleio_workaround(stream)
 
 
 def test_dontreadfrominput_has_encoding(pytester: Pytester) -> None:
@@ -1509,9 +1524,9 @@ def test_global_capture_with_live_logging(pytester: Pytester) -> None:
         def pytest_runtest_logreport(report):
             if "test_global" in report.nodeid:
                 if report.when == "teardown":
-                    with open("caplog", "w") as f:
+                    with open("caplog", "w", encoding="utf-8") as f:
                         f.write(report.caplog)
-                    with open("capstdout", "w") as f:
+                    with open("capstdout", "w", encoding="utf-8") as f:
                         f.write(report.capstdout)
         """
     )
@@ -1541,14 +1556,14 @@ def test_global_capture_with_live_logging(pytester: Pytester) -> None:
     result = pytester.runpytest_subprocess("--log-cli-level=INFO")
     assert result.ret == 0
 
-    with open("caplog") as f:
+    with open("caplog", encoding="utf-8") as f:
         caplog = f.read()
 
     assert "fix setup" in caplog
     assert "something in test" in caplog
     assert "fix teardown" in caplog
 
-    with open("capstdout") as f:
+    with open("capstdout", encoding="utf-8") as f:
         capstdout = f.read()
 
     assert "fix setup" in capstdout
index 1138c2bd6f5c9556d53f18d9c75ca53a7bd9e61e..8b0a1ab36508b48ccb7dd06c44251e6d8a64638e 100644 (file)
@@ -16,7 +16,6 @@ from _pytest.nodes import Item
 from _pytest.pathlib import symlink_or_skip
 from _pytest.pytester import HookRecorder
 from _pytest.pytester import Pytester
-from _pytest.pytester import Testdir
 
 
 def ensure_file(file_path: Path) -> Path:
@@ -65,7 +64,7 @@ class TestCollector:
 
         assert pytester.collect_by_name(modcol, "doesnotexist") is None
 
-    def test_getparent(self, pytester: Pytester) -> None:
+    def test_getparent_and_accessors(self, pytester: Pytester) -> None:
         modcol = pytester.getmodulecol(
             """
             class TestClass:
@@ -75,19 +74,24 @@ class TestCollector:
         )
         cls = pytester.collect_by_name(modcol, "TestClass")
         assert isinstance(cls, pytest.Class)
-        instance = pytester.collect_by_name(cls, "()")
-        assert isinstance(instance, pytest.Instance)
-        fn = pytester.collect_by_name(instance, "test_foo")
+        fn = pytester.collect_by_name(cls, "test_foo")
         assert isinstance(fn, pytest.Function)
 
-        module_parent = fn.getparent(pytest.Module)
-        assert module_parent is modcol
+        assert fn.getparent(pytest.Module) is modcol
+        assert modcol.module is not None
+        assert modcol.cls is None
+        assert modcol.instance is None
 
-        function_parent = fn.getparent(pytest.Function)
-        assert function_parent is fn
+        assert fn.getparent(pytest.Class) is cls
+        assert cls.module is not None
+        assert cls.cls is not None
+        assert cls.instance is None
 
-        class_parent = fn.getparent(pytest.Class)
-        assert class_parent is cls
+        assert fn.getparent(pytest.Function) is fn
+        assert fn.module is not None
+        assert fn.cls is not None
+        assert fn.instance is not None
+        assert fn.function is not None
 
     def test_getcustomfile_roundtrip(self, pytester: Pytester) -> None:
         hello = pytester.makefile(".xxx", hello="world")
@@ -96,9 +100,9 @@ class TestCollector:
             import pytest
             class CustomFile(pytest.File):
                 pass
-            def pytest_collect_file(path, parent):
-                if path.ext == ".xxx":
-                    return CustomFile.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.suffix == ".xxx":
+                    return CustomFile.from_parent(path=file_path, parent=parent)
         """
         )
         node = pytester.getpathnode(hello)
@@ -126,17 +130,17 @@ class TestCollector:
 
 class TestCollectFS:
     def test_ignored_certain_directories(self, pytester: Pytester) -> None:
-        tmpdir = pytester.path
-        ensure_file(tmpdir / "build" / "test_notfound.py")
-        ensure_file(tmpdir / "dist" / "test_notfound.py")
-        ensure_file(tmpdir / "_darcs" / "test_notfound.py")
-        ensure_file(tmpdir / "CVS" / "test_notfound.py")
-        ensure_file(tmpdir / "{arch}" / "test_notfound.py")
-        ensure_file(tmpdir / ".whatever" / "test_notfound.py")
-        ensure_file(tmpdir / ".bzr" / "test_notfound.py")
-        ensure_file(tmpdir / "normal" / "test_found.py")
-        for x in Path(str(tmpdir)).rglob("test_*.py"):
-            x.write_text("def test_hello(): pass", "utf-8")
+        tmp_path = pytester.path
+        ensure_file(tmp_path / "build" / "test_notfound.py")
+        ensure_file(tmp_path / "dist" / "test_notfound.py")
+        ensure_file(tmp_path / "_darcs" / "test_notfound.py")
+        ensure_file(tmp_path / "CVS" / "test_notfound.py")
+        ensure_file(tmp_path / "{arch}" / "test_notfound.py")
+        ensure_file(tmp_path / ".whatever" / "test_notfound.py")
+        ensure_file(tmp_path / ".bzr" / "test_notfound.py")
+        ensure_file(tmp_path / "normal" / "test_found.py")
+        for x in tmp_path.rglob("test_*.py"):
+            x.write_text("def test_hello(): pass", encoding="utf-8")
 
         result = pytester.runpytest("--collect-only")
         s = result.stdout.str()
@@ -158,7 +162,7 @@ class TestCollectFS:
         bindir = "Scripts" if sys.platform.startswith("win") else "bin"
         ensure_file(pytester.path / "virtual" / bindir / fname)
         testfile = ensure_file(pytester.path / "virtual" / "test_invenv.py")
-        testfile.write_text("def test_hello(): pass")
+        testfile.write_text("def test_hello(): pass", encoding="utf-8")
 
         # by default, ignore tests inside a virtualenv
         result = pytester.runpytest()
@@ -188,7 +192,7 @@ class TestCollectFS:
         # norecursedirs takes priority
         ensure_file(pytester.path / ".virtual" / bindir / fname)
         testfile = ensure_file(pytester.path / ".virtual" / "test_invenv.py")
-        testfile.write_text("def test_hello(): pass")
+        testfile.write_text("def test_hello(): pass", encoding="utf-8")
         result = pytester.runpytest("--collect-in-virtualenv")
         result.stdout.no_fnmatch_line("*test_invenv*")
         # ...unless the virtualenv is explicitly given on the CLI
@@ -206,14 +210,16 @@ class TestCollectFS:
             "Activate.ps1",
         ),
     )
-    def test__in_venv(self, testdir: Testdir, fname: str) -> None:
+    def test__in_venv(self, pytester: Pytester, fname: str) -> None:
         """Directly test the virtual env detection function"""
         bindir = "Scripts" if sys.platform.startswith("win") else "bin"
         # no bin/activate, not a virtualenv
-        base_path = testdir.tmpdir.mkdir("venv")
+        base_path = pytester.mkdir("venv")
         assert _in_venv(base_path) is False
         # with bin/activate, totally a virtualenv
-        base_path.ensure(bindir, fname)
+        bin_path = base_path.joinpath(bindir)
+        bin_path.mkdir()
+        bin_path.joinpath(fname).touch()
         assert _in_venv(base_path) is True
 
     def test_custom_norecursedirs(self, pytester: Pytester) -> None:
@@ -223,10 +229,16 @@ class TestCollectFS:
             norecursedirs = mydir xyz*
         """
         )
-        tmpdir = pytester.path
-        ensure_file(tmpdir / "mydir" / "test_hello.py").write_text("def test_1(): pass")
-        ensure_file(tmpdir / "xyz123" / "test_2.py").write_text("def test_2(): 0/0")
-        ensure_file(tmpdir / "xy" / "test_ok.py").write_text("def test_3(): pass")
+        tmp_path = pytester.path
+        ensure_file(tmp_path / "mydir" / "test_hello.py").write_text(
+            "def test_1(): pass", encoding="utf-8"
+        )
+        ensure_file(tmp_path / "xyz123" / "test_2.py").write_text(
+            "def test_2(): 0/0", encoding="utf-8"
+        )
+        ensure_file(tmp_path / "xy" / "test_ok.py").write_text(
+            "def test_3(): pass", encoding="utf-8"
+        )
         rec = pytester.inline_run()
         rec.assertoutcome(passed=1)
         rec = pytester.inline_run("xyz123/test_2.py")
@@ -236,47 +248,53 @@ class TestCollectFS:
         pytester.makeini(
             """
             [pytest]
-            testpaths = gui uts
+            testpaths = */tests
         """
         )
-        tmpdir = pytester.path
-        ensure_file(tmpdir / "env" / "test_1.py").write_text("def test_env(): pass")
-        ensure_file(tmpdir / "gui" / "test_2.py").write_text("def test_gui(): pass")
-        ensure_file(tmpdir / "uts" / "test_3.py").write_text("def test_uts(): pass")
+        tmp_path = pytester.path
+        ensure_file(tmp_path / "a" / "test_1.py").write_text(
+            "def test_a(): pass", encoding="utf-8"
+        )
+        ensure_file(tmp_path / "b" / "tests" / "test_2.py").write_text(
+            "def test_b(): pass", encoding="utf-8"
+        )
+        ensure_file(tmp_path / "c" / "tests" / "test_3.py").write_text(
+            "def test_c(): pass", encoding="utf-8"
+        )
 
         # executing from rootdir only tests from `testpaths` directories
         # are collected
         items, reprec = pytester.inline_genitems("-v")
-        assert [x.name for x in items] == ["test_gui", "test_uts"]
+        assert [x.name for x in items] == ["test_b", "test_c"]
 
         # check that explicitly passing directories in the command-line
         # collects the tests
-        for dirname in ("env", "gui", "uts"):
-            items, reprec = pytester.inline_genitems(tmpdir.joinpath(dirname))
+        for dirname in ("a", "b", "c"):
+            items, reprec = pytester.inline_genitems(tmp_path.joinpath(dirname))
             assert [x.name for x in items] == ["test_%s" % dirname]
 
         # changing cwd to each subdirectory and running pytest without
         # arguments collects the tests in that directory normally
-        for dirname in ("env", "gui", "uts"):
+        for dirname in ("a", "b", "c"):
             monkeypatch.chdir(pytester.path.joinpath(dirname))
             items, reprec = pytester.inline_genitems()
             assert [x.name for x in items] == ["test_%s" % dirname]
 
 
 class TestCollectPluginHookRelay:
-    def test_pytest_collect_file(self, testdir: Testdir) -> None:
+    def test_pytest_collect_file(self, pytester: Pytester) -> None:
         wascalled = []
 
         class Plugin:
-            def pytest_collect_file(self, path):
-                if not path.basename.startswith("."):
+            def pytest_collect_file(self, file_path: Path) -> None:
+                if not file_path.name.startswith("."):
                     # Ignore hidden files, e.g. .testmondata.
-                    wascalled.append(path)
+                    wascalled.append(file_path)
 
-        testdir.makefile(".abc", "xyz")
-        pytest.main(testdir.tmpdir, plugins=[Plugin()])
+        pytester.makefile(".abc", "xyz")
+        pytest.main(pytester.path, plugins=[Plugin()])
         assert len(wascalled) == 1
-        assert wascalled[0].ext == ".abc"
+        assert wascalled[0].suffix == ".abc"
 
 
 class TestPrunetraceback:
@@ -289,15 +307,15 @@ class TestPrunetraceback:
         pytester.makeconftest(
             """
             import pytest
-            def pytest_collect_file(path, parent):
-                return MyFile.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                return MyFile.from_parent(path=file_path, parent=parent)
             class MyError(Exception):
                 pass
             class MyFile(pytest.File):
                 def collect(self):
                     raise MyError()
                 def repr_failure(self, excinfo):
-                    if excinfo.errisinstance(MyError):
+                    if isinstance(excinfo.value, MyError):
                         return "hello world"
                     return pytest.File.repr_failure(self, excinfo)
         """
@@ -332,14 +350,13 @@ class TestCustomConftests:
     def test_ignore_collect_path(self, pytester: Pytester) -> None:
         pytester.makeconftest(
             """
-            def pytest_ignore_collect(path, config):
-                return path.basename.startswith("x") or \
-                       path.basename == "test_one.py"
+            def pytest_ignore_collect(collection_path, config):
+                return collection_path.name.startswith("x") or collection_path.name == "test_one.py"
         """
         )
         sub = pytester.mkdir("xy123")
-        ensure_file(sub / "test_hello.py").write_text("syntax error")
-        sub.joinpath("conftest.py").write_text("syntax error")
+        ensure_file(sub / "test_hello.py").write_text("syntax error", encoding="utf-8")
+        sub.joinpath("conftest.py").write_text("syntax error", encoding="utf-8")
         pytester.makepyfile("def test_hello(): pass")
         pytester.makepyfile(test_one="syntax error")
         result = pytester.runpytest("--fulltrace")
@@ -349,7 +366,7 @@ class TestCustomConftests:
     def test_ignore_collect_not_called_on_argument(self, pytester: Pytester) -> None:
         pytester.makeconftest(
             """
-            def pytest_ignore_collect(path, config):
+            def pytest_ignore_collect(collection_path, config):
                 return True
         """
         )
@@ -364,9 +381,19 @@ class TestCustomConftests:
     def test_collectignore_exclude_on_option(self, pytester: Pytester) -> None:
         pytester.makeconftest(
             """
-            collect_ignore = ['hello', 'test_world.py']
+            from pathlib import Path
+
+            class MyPathLike:
+                def __init__(self, path):
+                    self.path = path
+                def __fspath__(self):
+                    return "path"
+
+            collect_ignore = [MyPathLike('hello'), 'test_world.py', Path('bye')]
+
             def pytest_addoption(parser):
                 parser.addoption("--XX", action="store_true", default=False)
+
             def pytest_configure(config):
                 if config.getvalue("XX"):
                     collect_ignore[:] = []
@@ -407,9 +434,9 @@ class TestCustomConftests:
             import pytest
             class MyModule(pytest.Module):
                 pass
-            def pytest_collect_file(path, parent):
-                if path.ext == ".py":
-                    return MyModule.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.suffix == ".py":
+                    return MyModule.from_parent(path=file_path, parent=parent)
         """
         )
         pytester.mkdir("sub")
@@ -425,9 +452,9 @@ class TestCustomConftests:
             import pytest
             class MyModule1(pytest.Module):
                 pass
-            def pytest_collect_file(path, parent):
-                if path.ext == ".py":
-                    return MyModule1.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.suffix == ".py":
+                    return MyModule1.from_parent(path=file_path, parent=parent)
         """
         )
         conf1.replace(sub1.joinpath(conf1.name))
@@ -436,9 +463,9 @@ class TestCustomConftests:
             import pytest
             class MyModule2(pytest.Module):
                 pass
-            def pytest_collect_file(path, parent):
-                if path.ext == ".py":
-                    return MyModule2.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.suffix == ".py":
+                    return MyModule2.from_parent(path=file_path, parent=parent)
         """
         )
         conf2.replace(sub2.joinpath(conf2.name))
@@ -457,13 +484,13 @@ class TestSession:
         config = pytester.parseconfig(id)
         topdir = pytester.path
         rcol = Session.from_config(config)
-        assert topdir == rcol.fspath
+        assert topdir == rcol.path
         # rootid = rcol.nodeid
         # root2 = rcol.perform_collect([rcol.nodeid], genitems=False)[0]
         # assert root2 == rcol, rootid
         colitems = rcol.perform_collect([rcol.nodeid], genitems=False)
         assert len(colitems) == 1
-        assert colitems[0].fspath == p
+        assert colitems[0].path == p
 
     def get_reported_items(self, hookrec: HookRecorder) -> List[Item]:
         """Return pytest.Item instances reported by the pytest_collectreport hook"""
@@ -487,10 +514,10 @@ class TestSession:
         topdir = pytester.path  # noqa
         hookrec.assert_contains(
             [
-                ("pytest_collectstart", "collector.fspath == topdir"),
-                ("pytest_make_collect_report", "collector.fspath == topdir"),
-                ("pytest_collectstart", "collector.fspath == p"),
-                ("pytest_make_collect_report", "collector.fspath == p"),
+                ("pytest_collectstart", "collector.path == topdir"),
+                ("pytest_make_collect_report", "collector.path == topdir"),
+                ("pytest_collectstart", "collector.path == p"),
+                ("pytest_make_collect_report", "collector.path == p"),
                 ("pytest_pycollect_makeitem", "name == 'test_func'"),
                 ("pytest_collectreport", "report.result[0].name == 'test_func'"),
             ]
@@ -527,9 +554,9 @@ class TestSession:
             class SpecialFile(pytest.File):
                 def collect(self):
                     return [SpecialItem.from_parent(name="check", parent=self)]
-            def pytest_collect_file(path, parent):
-                if path.basename == %r:
-                    return SpecialFile.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.name == %r:
+                    return SpecialFile.from_parent(path=file_path, parent=parent)
         """
             % p.name
         )
@@ -540,7 +567,7 @@ class TestSession:
         assert len(items) == 2
         hookrec.assert_contains(
             [
-                ("pytest_collectstart", "collector.fspath == collector.session.fspath"),
+                ("pytest_collectstart", "collector.path == collector.session.path"),
                 (
                     "pytest_collectstart",
                     "collector.__class__.__name__ == 'SpecialFile'",
@@ -563,7 +590,7 @@ class TestSession:
         pprint.pprint(hookrec.calls)
         hookrec.assert_contains(
             [
-                ("pytest_collectstart", "collector.fspath == test_aaa"),
+                ("pytest_collectstart", "collector.path == test_aaa"),
                 ("pytest_pycollect_makeitem", "name == 'test_func'"),
                 ("pytest_collectreport", "report.nodeid.startswith('aaa/test_aaa.py')"),
             ]
@@ -585,10 +612,10 @@ class TestSession:
         pprint.pprint(hookrec.calls)
         hookrec.assert_contains(
             [
-                ("pytest_collectstart", "collector.fspath == test_aaa"),
+                ("pytest_collectstart", "collector.path == test_aaa"),
                 ("pytest_pycollect_makeitem", "name == 'test_func'"),
                 ("pytest_collectreport", "report.nodeid == 'aaa/test_aaa.py'"),
-                ("pytest_collectstart", "collector.fspath == test_bbb"),
+                ("pytest_collectstart", "collector.path == test_bbb"),
                 ("pytest_pycollect_makeitem", "name == 'test_func'"),
                 ("pytest_collectreport", "report.nodeid == 'bbb/test_bbb.py'"),
             ]
@@ -602,7 +629,7 @@ class TestSession:
         items2, hookrec = pytester.inline_genitems(item.nodeid)
         (item2,) = items2
         assert item2.name == item.name
-        assert item2.fspath == item.fspath
+        assert item2.path == item.path
 
     def test_find_byid_without_instance_parents(self, pytester: Pytester) -> None:
         p = pytester.makepyfile(
@@ -623,10 +650,9 @@ class TestSession:
 
 class Test_getinitialnodes:
     def test_global_file(self, pytester: Pytester) -> None:
-        tmpdir = pytester.path
-        x = ensure_file(tmpdir / "x.py")
-        with tmpdir.cwd():
-            config = pytester.parseconfigure(x)
+        tmp_path = pytester.path
+        x = ensure_file(tmp_path / "x.py")
+        config = pytester.parseconfigure(x)
         col = pytester.getnode(config, x)
         assert isinstance(col, pytest.Module)
         assert col.name == "x.py"
@@ -635,16 +661,17 @@ class Test_getinitialnodes:
         for parent in col.listchain():
             assert parent.config is config
 
-    def test_pkgfile(self, pytester: Pytester) -> None:
+    def test_pkgfile(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
         """Verify nesting when a module is within a package.
         The parent chain should match: Module<x.py> -> Package<subdir> -> Session.
             Session's parent should always be None.
         """
-        tmpdir = pytester.path
-        subdir = tmpdir.joinpath("subdir")
+        tmp_path = pytester.path
+        subdir = tmp_path.joinpath("subdir")
         x = ensure_file(subdir / "x.py")
         ensure_file(subdir / "__init__.py")
-        with subdir.cwd():
+        with monkeypatch.context() as mp:
+            mp.chdir(subdir)
             config = pytester.parseconfigure(x)
         col = pytester.getnode(config, x)
         assert col is not None
@@ -714,6 +741,20 @@ class Test_genitems:
         assert s.endswith("test_example_items1.testone")
         print(s)
 
+    def test_classmethod_is_discovered(self, pytester: Pytester) -> None:
+        """Test that classmethods are discovered"""
+        p = pytester.makepyfile(
+            """
+            class TestCase:
+                @classmethod
+                def test_classmethod(cls) -> None:
+                    pass
+            """
+        )
+        items, reprec = pytester.inline_genitems(p)
+        ids = [x.getmodpath() for x in items]  # type: ignore[attr-defined]
+        assert ids == ["TestCase.test_classmethod"]
+
     def test_class_and_functions_discovery_using_glob(self, pytester: Pytester) -> None:
         """Test that Python_classes and Python_functions config options work
         as prefixes and glob-like patterns (#600)."""
@@ -748,13 +789,13 @@ def test_matchnodes_two_collections_same_file(pytester: Pytester) -> None:
             config.pluginmanager.register(Plugin2())
 
         class Plugin2(object):
-            def pytest_collect_file(self, path, parent):
-                if path.ext == ".abc":
-                    return MyFile2.from_parent(fspath=path, parent=parent)
+            def pytest_collect_file(self, file_path, parent):
+                if file_path.suffix == ".abc":
+                    return MyFile2.from_parent(path=file_path, parent=parent)
 
-        def pytest_collect_file(path, parent):
-            if path.ext == ".abc":
-                return MyFile1.from_parent(fspath=path, parent=parent)
+        def pytest_collect_file(file_path, parent):
+            if file_path.suffix == ".abc":
+                return MyFile1.from_parent(path=file_path, parent=parent)
 
         class MyFile1(pytest.File):
             def collect(self):
@@ -781,7 +822,7 @@ def test_matchnodes_two_collections_same_file(pytester: Pytester) -> None:
     res.stdout.fnmatch_lines(["*1 passed*"])
 
 
-class TestNodekeywords:
+class TestNodeKeywords:
     def test_no_under(self, pytester: Pytester) -> None:
         modcol = pytester.getmodulecol(
             """
@@ -847,6 +888,54 @@ class TestNodekeywords:
             reprec = pytester.inline_run("-k " + expression)
             reprec.assertoutcome(passed=num_matching_tests, failed=0)
 
+    def test_duplicates_handled_correctly(self, pytester: Pytester) -> None:
+        item = pytester.getitem(
+            """
+            import pytest
+            pytestmark = pytest.mark.kw
+            class TestClass:
+                pytestmark = pytest.mark.kw
+                def test_method(self): pass
+                test_method.kw = 'method'
+        """,
+            "test_method",
+        )
+        assert item.parent is not None and item.parent.parent is not None
+        item.parent.parent.keywords["kw"] = "class"
+
+        assert item.keywords["kw"] == "method"
+        assert len(item.keywords) == len(set(item.keywords))
+
+    def test_unpacked_marks_added_to_keywords(self, pytester: Pytester) -> None:
+        item = pytester.getitem(
+            """
+            import pytest
+            pytestmark = pytest.mark.foo
+            class TestClass:
+                pytestmark = pytest.mark.bar
+                def test_method(self): pass
+                test_method.pytestmark = pytest.mark.baz
+        """,
+            "test_method",
+        )
+        assert isinstance(item, pytest.Function)
+        cls = item.getparent(pytest.Class)
+        assert cls is not None
+        mod = item.getparent(pytest.Module)
+        assert mod is not None
+
+        assert item.keywords["foo"] == pytest.mark.foo.mark
+        assert item.keywords["bar"] == pytest.mark.bar.mark
+        assert item.keywords["baz"] == pytest.mark.baz.mark
+
+        assert cls.keywords["foo"] == pytest.mark.foo.mark
+        assert cls.keywords["bar"] == pytest.mark.bar.mark
+        assert "baz" not in cls.keywords
+
+        assert mod.keywords["foo"] == pytest.mark.foo.mark
+        assert "bar" not in mod.keywords
+        assert "baz" not in mod.keywords
+
 
 COLLECTION_ERROR_PY_FILES = dict(
     test_01_failure="""
@@ -977,13 +1066,18 @@ def test_fixture_scope_sibling_conftests(pytester: Pytester) -> None:
             def fix():
                 return 1
             """
-        )
+        ),
+        encoding="utf-8",
+    )
+    foo_path.joinpath("test_foo.py").write_text(
+        "def test_foo(fix): assert fix == 1", encoding="utf-8"
     )
-    foo_path.joinpath("test_foo.py").write_text("def test_foo(fix): assert fix == 1")
 
     # Tests in `food/` should not see the conftest fixture from `foo/`
     food_path = pytester.mkpydir("food")
-    food_path.joinpath("test_food.py").write_text("def test_food(fix): assert fix == 1")
+    food_path.joinpath("test_food.py").write_text(
+        "def test_food(fix): assert fix == 1", encoding="utf-8"
+    )
 
     res = pytester.runpytest()
     assert res.ret == 1
@@ -1114,7 +1208,8 @@ def test_collect_with_chdir_during_import(pytester: Pytester) -> None:
             os.chdir(%r)
             """
             % (str(subdir),)
-        )
+        ),
+        encoding="utf-8",
     )
     pytester.makepyfile(
         """
@@ -1124,8 +1219,7 @@ def test_collect_with_chdir_during_import(pytester: Pytester) -> None:
         """
         % (str(subdir),)
     )
-    with pytester.path.cwd():
-        result = pytester.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*1 passed in*"])
     assert result.ret == 0
 
@@ -1136,8 +1230,7 @@ def test_collect_with_chdir_during_import(pytester: Pytester) -> None:
         testpaths = .
     """
     )
-    with pytester.path.cwd():
-        result = pytester.runpytest("--collect-only")
+    result = pytester.runpytest("--collect-only")
     result.stdout.fnmatch_lines(["collected 1 item"])
 
 
@@ -1146,8 +1239,12 @@ def test_collect_pyargs_with_testpaths(
 ) -> None:
     testmod = pytester.mkdir("testmod")
     # NOTE: __init__.py is not collected since it does not match python_files.
-    testmod.joinpath("__init__.py").write_text("def test_func(): pass")
-    testmod.joinpath("test_file.py").write_text("def test_func(): pass")
+    testmod.joinpath("__init__.py").write_text(
+        "def test_func(): pass", encoding="utf-8"
+    )
+    testmod.joinpath("test_file.py").write_text(
+        "def test_func(): pass", encoding="utf-8"
+    )
 
     root = pytester.mkdir("root")
     root.joinpath("pytest.ini").write_text(
@@ -1157,14 +1254,66 @@ def test_collect_pyargs_with_testpaths(
         addopts = --pyargs
         testpaths = testmod
     """
-        )
+        ),
+        encoding="utf-8",
     )
     monkeypatch.setenv("PYTHONPATH", str(pytester.path), prepend=os.pathsep)
-    with root.cwd():
+    with monkeypatch.context() as mp:
+        mp.chdir(root)
         result = pytester.runpytest_subprocess()
     result.stdout.fnmatch_lines(["*1 passed in*"])
 
 
+def test_initial_conftests_with_testpaths(pytester: Pytester) -> None:
+    """The testpaths ini option should load conftests in those paths as 'initial' (#10987)."""
+    p = pytester.mkdir("some_path")
+    p.joinpath("conftest.py").write_text(
+        textwrap.dedent(
+            """
+            def pytest_sessionstart(session):
+                raise Exception("pytest_sessionstart hook successfully run")
+            """
+        ),
+        encoding="utf-8",
+    )
+    pytester.makeini(
+        """
+        [pytest]
+        testpaths = some_path
+        """
+    )
+
+    # No command line args - falls back to testpaths.
+    result = pytester.runpytest()
+    assert result.ret == ExitCode.INTERNAL_ERROR
+    result.stdout.fnmatch_lines(
+        "INTERNALERROR* Exception: pytest_sessionstart hook successfully run"
+    )
+
+    # No fallback.
+    result = pytester.runpytest(".")
+    assert result.ret == ExitCode.NO_TESTS_COLLECTED
+
+
+def test_large_option_breaks_initial_conftests(pytester: Pytester) -> None:
+    """Long option values do not break initial conftests handling (#10169)."""
+    option_value = "x" * 1024 * 1000
+    pytester.makeconftest(
+        """
+        def pytest_addoption(parser):
+            parser.addoption("--xx", default=None)
+        """
+    )
+    pytester.makepyfile(
+        f"""
+        def test_foo(request):
+            assert request.config.getoption("xx") == {option_value!r}
+        """
+    )
+    result = pytester.runpytest(f"--xx={option_value}")
+    assert result.ret == 0
+
+
 def test_collect_symlink_file_arg(pytester: Pytester) -> None:
     """Collect a direct symlink works even if it does not match python_files (#4325)."""
     real = pytester.makepyfile(
@@ -1192,6 +1341,7 @@ def test_collect_symlink_out_of_tree(pytester: Pytester) -> None:
             assert request.node.nodeid == "test_real.py::test_nodeid"
         """
         ),
+        encoding="utf-8",
     )
 
     out_of_tree = pytester.mkdir("out_of_tree")
@@ -1212,7 +1362,7 @@ def test_collect_symlink_dir(pytester: Pytester) -> None:
     """A symlinked directory is collected."""
     dir = pytester.mkdir("dir")
     dir.joinpath("test_it.py").write_text("def test_it(): pass", "utf-8")
-    pytester.path.joinpath("symlink_dir").symlink_to(dir)
+    symlink_or_skip(pytester.path.joinpath("symlink_dir"), dir)
     result = pytester.runpytest()
     result.assert_outcomes(passed=2)
 
@@ -1220,12 +1370,16 @@ def test_collect_symlink_dir(pytester: Pytester) -> None:
 def test_collectignore_via_conftest(pytester: Pytester) -> None:
     """collect_ignore in parent conftest skips importing child (issue #4592)."""
     tests = pytester.mkpydir("tests")
-    tests.joinpath("conftest.py").write_text("collect_ignore = ['ignore_me']")
+    tests.joinpath("conftest.py").write_text(
+        "collect_ignore = ['ignore_me']", encoding="utf-8"
+    )
 
     ignore_me = tests.joinpath("ignore_me")
     ignore_me.mkdir()
     ignore_me.joinpath("__init__.py").touch()
-    ignore_me.joinpath("conftest.py").write_text("assert 0, 'should_not_be_called'")
+    ignore_me.joinpath("conftest.py").write_text(
+        "assert 0, 'should_not_be_called'", encoding="utf-8"
+    )
 
     result = pytester.runpytest()
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
@@ -1234,9 +1388,9 @@ def test_collectignore_via_conftest(pytester: Pytester) -> None:
 def test_collect_pkg_init_and_file_in_args(pytester: Pytester) -> None:
     subdir = pytester.mkdir("sub")
     init = subdir.joinpath("__init__.py")
-    init.write_text("def test_init(): pass")
+    init.write_text("def test_init(): pass", encoding="utf-8")
     p = subdir.joinpath("test_file.py")
-    p.write_text("def test_file(): pass")
+    p.write_text("def test_file(): pass", encoding="utf-8")
 
     # NOTE: without "-o python_files=*.py" this collects test_file.py twice.
     # This changed/broke with "Add package scoped fixtures #2283" (2b1410895)
@@ -1263,7 +1417,7 @@ def test_collect_pkg_init_and_file_in_args(pytester: Pytester) -> None:
 def test_collect_pkg_init_only(pytester: Pytester) -> None:
     subdir = pytester.mkdir("sub")
     init = subdir.joinpath("__init__.py")
-    init.write_text("def test_init(): pass")
+    init.write_text("def test_init(): pass", encoding="utf-8")
 
     result = pytester.runpytest(str(init))
     result.stdout.fnmatch_lines(["*no tests ran in*"])
@@ -1278,7 +1432,7 @@ def test_collect_sub_with_symlinks(use_pkg: bool, pytester: Pytester) -> None:
     sub = pytester.mkdir("sub")
     if use_pkg:
         sub.joinpath("__init__.py").touch()
-    sub.joinpath("test_file.py").write_text("def test_file(): pass")
+    sub.joinpath("test_file.py").write_text("def test_file(): pass", encoding="utf-8")
 
     # Create a broken symlink.
     symlink_or_skip("test_doesnotexist.py", sub.joinpath("test_broken.py"))
@@ -1316,7 +1470,7 @@ def test_collector_respects_tbstyle(pytester: Pytester) -> None:
 def test_does_not_eagerly_collect_packages(pytester: Pytester) -> None:
     pytester.makepyfile("def test(): pass")
     pydir = pytester.mkpydir("foopkg")
-    pydir.joinpath("__init__.py").write_text("assert False")
+    pydir.joinpath("__init__.py").write_text("assert False", encoding="utf-8")
     result = pytester.runpytest()
     assert result.ret == ExitCode.OK
 
@@ -1334,27 +1488,39 @@ def test_does_not_put_src_on_path(pytester: Pytester) -> None:
     assert result.ret == ExitCode.OK
 
 
-def test_fscollector_from_parent(testdir: Testdir, request: FixtureRequest) -> None:
+def test_fscollector_from_parent(pytester: Pytester, request: FixtureRequest) -> None:
     """Ensure File.from_parent can forward custom arguments to the constructor.
 
     Context: https://github.com/pytest-dev/pytest-cpp/pull/47
     """
 
     class MyCollector(pytest.File):
-        def __init__(self, fspath, parent, x):
-            super().__init__(fspath, parent)
+        def __init__(self, *k, x, **kw):
+            super().__init__(*k, **kw)
             self.x = x
 
-        @classmethod
-        def from_parent(cls, parent, *, fspath, x):
-            return super().from_parent(parent=parent, fspath=fspath, x=x)
-
     collector = MyCollector.from_parent(
-        parent=request.session, fspath=testdir.tmpdir / "foo", x=10
+        parent=request.session, path=pytester.path / "foo", x=10
     )
     assert collector.x == 10
 
 
+def test_class_from_parent(pytester: Pytester, request: FixtureRequest) -> None:
+    """Ensure Class.from_parent can forward custom arguments to the constructor."""
+
+    class MyCollector(pytest.Class):
+        def __init__(self, name, parent, x):
+            super().__init__(name, parent)
+            self.x = x
+
+        @classmethod
+        def from_parent(cls, parent, *, name, x):
+            return super().from_parent(parent=parent, name=name, x=x)
+
+    collector = MyCollector.from_parent(parent=request.session, name="foo", x=10)
+    assert collector.x == 10
+
+
 class TestImportModeImportlib:
     def test_collect_duplicate_names(self, pytester: Pytester) -> None:
         """--import-mode=importlib can import modules with same names that are not in packages."""
@@ -1431,6 +1597,35 @@ class TestImportModeImportlib:
             ]
         )
 
+    def test_using_python_path(self, pytester: Pytester) -> None:
+        """
+        Dummy modules created by insert_missing_modules should not get in
+        the way of modules that could be imported via python path (#9645).
+        """
+        pytester.makeini(
+            """
+            [pytest]
+            pythonpath = .
+            addopts = --import-mode importlib
+            """
+        )
+        pytester.makepyfile(
+            **{
+                "tests/__init__.py": "",
+                "tests/conftest.py": "",
+                "tests/subpath/__init__.py": "",
+                "tests/subpath/helper.py": "",
+                "tests/subpath/test_something.py": """
+                import tests.subpath.helper
+
+                def test_something():
+                    assert True
+                """,
+            }
+        )
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines("*1 passed in*")
+
 
 def test_does_not_crash_on_error_from_decorated_function(pytester: Pytester) -> None:
     """Regression test for an issue around bad exception formatting due to
index 9f48a31d6898e3c6eed8e8aaabd06190d15c452e..8a80fd625dcdee811334da25b15bb5dcb4fd7c31 100644 (file)
@@ -1,4 +1,5 @@
 import enum
+import sys
 from functools import partial
 from functools import wraps
 from typing import TYPE_CHECKING
@@ -91,6 +92,7 @@ def test_get_real_func_partial() -> None:
     assert get_real_func(partial(foo)) is foo
 
 
+@pytest.mark.skipif(sys.version_info >= (3, 11), reason="couroutine removed")
 def test_is_generator_asyncio(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
@@ -133,7 +135,7 @@ def test_is_generator_async_gen_syntax(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
         from _pytest.compat import is_generator
-        def test_is_generator_py36():
+        def test_is_generator():
             async def foo():
                 yield
                 await foo()
@@ -156,11 +158,11 @@ class ErrorsHelper:
 
     @property
     def raise_exception(self):
-        raise Exception("exception should be catched")
+        raise Exception("exception should be caught")
 
     @property
     def raise_fail_outcome(self):
-        pytest.fail("fail should be catched")
+        pytest.fail("fail should be caught")
 
 
 def test_helper_failures() -> None:
index b931797d4297e27c64bbe0383189fc75e5ff409c..3aec5d7631fce64a3036576e078f7d3296c11b31 100644 (file)
@@ -1,3 +1,4 @@
+import dataclasses
 import os
 import re
 import sys
@@ -10,9 +11,6 @@ from typing import Tuple
 from typing import Type
 from typing import Union
 
-import attr
-import py.path
-
 import _pytest._code
 import pytest
 from _pytest.compat import importlib_metadata
@@ -28,6 +26,7 @@ from _pytest.config.findpaths import determine_setup
 from _pytest.config.findpaths import get_common_ancestor
 from _pytest.config.findpaths import locate_config
 from _pytest.monkeypatch import MonkeyPatch
+from _pytest.pathlib import absolutepath
 from _pytest.pytester import Pytester
 
 
@@ -75,7 +74,7 @@ class TestParseIni:
             % p1.name,
         )
         result = pytester.runpytest()
-        result.stdout.fnmatch_lines(["*, configfile: setup.cfg, *", "* 1 passed in *"])
+        result.stdout.fnmatch_lines(["configfile: setup.cfg", "* 1 passed in *"])
         assert result.ret == 0
 
     def test_append_parse_args(
@@ -88,7 +87,8 @@ class TestParseIni:
                 [pytest]
                 addopts = --verbose
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         config = pytester.parseconfig(tmp_path)
         assert config.option.color == "no"
@@ -112,21 +112,27 @@ class TestParseIni:
 
     @pytest.mark.parametrize(
         "section, name",
-        [("tool:pytest", "setup.cfg"), ("pytest", "tox.ini"), ("pytest", "pytest.ini")],
+        [
+            ("tool:pytest", "setup.cfg"),
+            ("pytest", "tox.ini"),
+            ("pytest", "pytest.ini"),
+            ("pytest", ".pytest.ini"),
+        ],
     )
     def test_ini_names(self, pytester: Pytester, name, section) -> None:
         pytester.path.joinpath(name).write_text(
             textwrap.dedent(
                 """
             [{section}]
-            minversion = 1.0
+            minversion = 3.36
         """.format(
                     section=section
                 )
-            )
+            ),
+            encoding="utf-8",
         )
         config = pytester.parseconfig()
-        assert config.getini("minversion") == "1.0"
+        assert config.getini("minversion") == "3.36"
 
     def test_pyproject_toml(self, pytester: Pytester) -> None:
         pytester.makepyprojecttoml(
@@ -146,7 +152,8 @@ class TestParseIni:
             [pytest]
             minversion = 2.0
         """
-            )
+            ),
+            encoding="utf-8",
         )
         pytester.path.joinpath("pytest.ini").write_text(
             textwrap.dedent(
@@ -154,16 +161,46 @@ class TestParseIni:
             [pytest]
             minversion = 1.5
         """
-            )
+            ),
+            encoding="utf-8",
         )
         config = pytester.parseconfigure(sub)
         assert config.getini("minversion") == "2.0"
 
     def test_ini_parse_error(self, pytester: Pytester) -> None:
-        pytester.path.joinpath("pytest.ini").write_text("addopts = -x")
+        pytester.path.joinpath("pytest.ini").write_text(
+            "addopts = -x", encoding="utf-8"
+        )
         result = pytester.runpytest()
         assert result.ret != 0
-        result.stderr.fnmatch_lines(["ERROR: *pytest.ini:1: no section header defined"])
+        result.stderr.fnmatch_lines("ERROR: *pytest.ini:1: no section header defined")
+
+    def test_toml_parse_error(self, pytester: Pytester) -> None:
+        pytester.makepyprojecttoml(
+            """
+            \\"
+            """
+        )
+        result = pytester.runpytest()
+        assert result.ret != 0
+        result.stderr.fnmatch_lines("ERROR: *pyproject.toml: Invalid statement*")
+
+    def test_confcutdir_default_without_configfile(self, pytester: Pytester) -> None:
+        # If --confcutdir is not specified, and there is no configfile, default
+        # to the roothpath.
+        sub = pytester.mkdir("sub")
+        os.chdir(sub)
+        config = pytester.parseconfigure()
+        assert config.pluginmanager._confcutdir == sub
+
+    def test_confcutdir_default_with_configfile(self, pytester: Pytester) -> None:
+        # If --confcutdir is not specified, and there is a configfile, default
+        # to the configfile's directory.
+        pytester.makeini("[pytest]")
+        sub = pytester.mkdir("sub")
+        os.chdir(sub)
+        config = pytester.parseconfigure()
+        assert config.pluginmanager._confcutdir == pytester.path
 
     @pytest.mark.xfail(reason="probably not needed")
     def test_confcutdir(self, pytester: Pytester) -> None:
@@ -290,7 +327,7 @@ class TestParseIni:
         result = pytester.runpytest()
         result.stdout.no_fnmatch_line("*PytestConfigWarning*")
 
-    @pytest.mark.filterwarnings("default")
+    @pytest.mark.filterwarnings("default::pytest.PytestConfigWarning")
     def test_disable_warnings_plugin_disables_config_warnings(
         self, pytester: Pytester
     ) -> None:
@@ -309,13 +346,14 @@ class TestParseIni:
         result.stdout.no_fnmatch_line("*PytestConfigWarning*")
 
     @pytest.mark.parametrize(
-        "ini_file_text, exception_text",
+        "ini_file_text, plugin_version, exception_text",
         [
             pytest.param(
                 """
                 [pytest]
                 required_plugins = a z
                 """,
+                "1.5",
                 "Missing required plugins: a, z",
                 id="2-missing",
             ),
@@ -324,6 +362,7 @@ class TestParseIni:
                 [pytest]
                 required_plugins = a z myplugin
                 """,
+                "1.5",
                 "Missing required plugins: a, z",
                 id="2-missing-1-ok",
             ),
@@ -332,6 +371,7 @@ class TestParseIni:
                 [pytest]
                 required_plugins = myplugin
                 """,
+                "1.5",
                 None,
                 id="1-ok",
             ),
@@ -340,6 +380,7 @@ class TestParseIni:
                 [pytest]
                 required_plugins = myplugin==1.5
                 """,
+                "1.5",
                 None,
                 id="1-ok-pin-exact",
             ),
@@ -348,31 +389,44 @@ class TestParseIni:
                 [pytest]
                 required_plugins = myplugin>1.0,<2.0
                 """,
+                "1.5",
                 None,
                 id="1-ok-pin-loose",
             ),
             pytest.param(
                 """
                 [pytest]
-                required_plugins = pyplugin==1.6
+                required_plugins = myplugin
                 """,
-                "Missing required plugins: pyplugin==1.6",
+                "1.5a1",
+                None,
+                id="1-ok-prerelease",
+            ),
+            pytest.param(
+                """
+                [pytest]
+                required_plugins = myplugin==1.6
+                """,
+                "1.5",
+                "Missing required plugins: myplugin==1.6",
                 id="missing-version",
             ),
             pytest.param(
                 """
                 [pytest]
-                required_plugins = pyplugin==1.6 other==1.0
+                required_plugins = myplugin==1.6 other==1.0
                 """,
-                "Missing required plugins: other==1.0, pyplugin==1.6",
+                "1.5",
+                "Missing required plugins: myplugin==1.6, other==1.0",
                 id="missing-versions",
             ),
             pytest.param(
                 """
                 [some_other_header]
-                required_plugins = wont be triggered
+                required_plugins = won't be triggered
                 [pytest]
                 """,
+                "1.5",
                 None,
                 id="invalid-header",
             ),
@@ -383,6 +437,7 @@ class TestParseIni:
         pytester: Pytester,
         monkeypatch: MonkeyPatch,
         ini_file_text: str,
+        plugin_version: str,
         exception_text: str,
     ) -> None:
         """Check 'required_plugins' option with various settings.
@@ -390,11 +445,11 @@ class TestParseIni:
         This test installs a mock "myplugin-1.5" which is used in the parametrized test cases.
         """
 
-        @attr.s
+        @dataclasses.dataclass
         class DummyEntryPoint:
-            name = attr.ib()
-            module = attr.ib()
-            group = "pytest11"
+            name: str
+            module: str
+            group: str = "pytest11"
 
             def load(self):
                 __import__(self.module)
@@ -404,11 +459,11 @@ class TestParseIni:
             DummyEntryPoint("myplugin1", "myplugin1_module"),
         ]
 
-        @attr.s
+        @dataclasses.dataclass
         class DummyDist:
-            entry_points = attr.ib()
-            files = ()
-            version = "1.5"
+            entry_points: object
+            files: object = ()
+            version: str = plugin_version
 
             @property
             def metadata(self):
@@ -482,6 +537,8 @@ class TestConfigCmdlineParsing:
         )
         config = pytester.parseconfig("-c", "custom.ini")
         assert config.getini("custom") == "1"
+        config = pytester.parseconfig("--config-file", "custom.ini")
+        assert config.getini("custom") == "1"
 
         pytester.makefile(
             ".cfg",
@@ -492,6 +549,8 @@ class TestConfigCmdlineParsing:
         )
         config = pytester.parseconfig("-c", "custom_tool_pytest_section.cfg")
         assert config.getini("custom") == "1"
+        config = pytester.parseconfig("--config-file", "custom_tool_pytest_section.cfg")
+        assert config.getini("custom") == "1"
 
         pytester.makefile(
             ".toml",
@@ -504,6 +563,8 @@ class TestConfigCmdlineParsing:
         )
         config = pytester.parseconfig("-c", "custom.toml")
         assert config.getini("custom") == "1"
+        config = pytester.parseconfig("--config-file", "custom.toml")
+        assert config.getini("custom") == "1"
 
     def test_absolute_win32_path(self, pytester: Pytester) -> None:
         temp_ini_file = pytester.makefile(
@@ -518,6 +579,8 @@ class TestConfigCmdlineParsing:
         temp_ini_file_norm = normpath(str(temp_ini_file))
         ret = pytest.main(["-c", temp_ini_file_norm])
         assert ret == ExitCode.OK
+        ret = pytest.main(["--config-file", temp_ini_file_norm])
+        assert ret == ExitCode.OK
 
 
 class TestConfigAPI:
@@ -574,16 +637,22 @@ class TestConfigAPI:
             config.getvalue("x")
         assert config.getoption("x", 1) == 1
 
-    def test_getconftest_pathlist(self, pytester: Pytester, tmpdir) -> None:
-        somepath = tmpdir.join("x", "y", "z")
-        p = tmpdir.join("conftest.py")
-        p.write("pathlist = ['.', %r]" % str(somepath))
+    def test_getconftest_pathlist(self, pytester: Pytester, tmp_path: Path) -> None:
+        somepath = tmp_path.joinpath("x", "y", "z")
+        p = tmp_path.joinpath("conftest.py")
+        p.write_text(f"mylist = {['.', str(somepath)]}", encoding="utf-8")
         config = pytester.parseconfigure(p)
-        assert config._getconftest_pathlist("notexist", path=tmpdir) is None
-        pl = config._getconftest_pathlist("pathlist", path=tmpdir) or []
+        assert (
+            config._getconftest_pathlist("notexist", path=tmp_path, rootpath=tmp_path)
+            is None
+        )
+        pl = (
+            config._getconftest_pathlist("mylist", path=tmp_path, rootpath=tmp_path)
+            or []
+        )
         print(pl)
         assert len(pl) == 2
-        assert pl[0] == tmpdir
+        assert pl[0] == tmp_path
         assert pl[1] == somepath
 
     @pytest.mark.parametrize("maybe_type", ["not passed", "None", '"string"'])
@@ -610,41 +679,34 @@ class TestConfigAPI:
         assert val == "hello"
         pytest.raises(ValueError, config.getini, "other")
 
-    def make_conftest_for_pathlist(self, pytester: Pytester) -> None:
+    @pytest.mark.parametrize("config_type", ["ini", "pyproject"])
+    def test_addini_paths(self, pytester: Pytester, config_type: str) -> None:
         pytester.makeconftest(
             """
             def pytest_addoption(parser):
-                parser.addini("paths", "my new ini value", type="pathlist")
+                parser.addini("paths", "my new ini value", type="paths")
                 parser.addini("abc", "abc value")
         """
         )
-
-    def test_addini_pathlist_ini_files(self, pytester: Pytester) -> None:
-        self.make_conftest_for_pathlist(pytester)
-        p = pytester.makeini(
+        if config_type == "ini":
+            inipath = pytester.makeini(
+                """
+                [pytest]
+                paths=hello world/sub.py
             """
-            [pytest]
-            paths=hello world/sub.py
-        """
-        )
-        self.check_config_pathlist(pytester, p)
-
-    def test_addini_pathlist_pyproject_toml(self, pytester: Pytester) -> None:
-        self.make_conftest_for_pathlist(pytester)
-        p = pytester.makepyprojecttoml(
+            )
+        elif config_type == "pyproject":
+            inipath = pytester.makepyprojecttoml(
+                """
+                [tool.pytest.ini_options]
+                paths=["hello", "world/sub.py"]
             """
-            [tool.pytest.ini_options]
-            paths=["hello", "world/sub.py"]
-        """
-        )
-        self.check_config_pathlist(pytester, p)
-
-    def check_config_pathlist(self, pytester: Pytester, config_path: Path) -> None:
+            )
         config = pytester.parseconfig()
         values = config.getini("paths")
         assert len(values) == 2
-        assert values[0] == config_path.parent.joinpath("hello")
-        assert values[1] == config_path.parent.joinpath("world/sub.py")
+        assert values[0] == inipath.parent.joinpath("hello")
+        assert values[1] == inipath.parent.joinpath("world/sub.py")
         pytest.raises(ValueError, config.getini, "other")
 
     def make_conftest_for_args(self, pytester: Pytester) -> None:
@@ -790,7 +852,7 @@ class TestConfigAPI:
         with pytest.raises(pytest.UsageError, match=exp_match):
             pytester.parseconfig("--confcutdir", pytester.path.joinpath("file"))
         with pytest.raises(pytest.UsageError, match=exp_match):
-            pytester.parseconfig("--confcutdir", pytester.path.joinpath("inexistant"))
+            pytester.parseconfig("--confcutdir", pytester.path.joinpath("nonexistent"))
 
         p = pytester.mkdir("dir")
         config = pytester.parseconfig("--confcutdir", p)
@@ -810,6 +872,9 @@ class TestConfigAPI:
             (["src/bar/__init__.py"], ["bar"]),
             (["src/bar/__init__.py", "setup.py"], ["bar"]),
             (["source/python/bar/__init__.py", "setup.py"], ["bar"]),
+            # editable installation finder modules
+            (["__editable___xyz_finder.py"], []),
+            (["bar/__init__.py", "__editable___xyz_finder.py"], ["bar"]),
         ],
     )
     def test_iter_rewritable_modules(self, names, expected) -> None:
@@ -851,11 +916,12 @@ class TestConfigFromdictargs:
                 [pytest]
                 name = value
                 """
-            )
+            ),
+            encoding="utf-8",
         )
 
-        inifile = "../../foo/bar.ini"
-        option_dict = {"inifilename": inifile, "capture": "no"}
+        inifilename = "../../foo/bar.ini"
+        option_dict = {"inifilename": inifilename, "capture": "no"}
 
         cwd = tmp_path.joinpath("a/b")
         cwd.mkdir(parents=True)
@@ -868,19 +934,20 @@ class TestConfigFromdictargs:
                 name = wrong-value
                 should_not_be_set = true
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         with MonkeyPatch.context() as mp:
             mp.chdir(cwd)
             config = Config.fromdictargs(option_dict, ())
-            inipath = py.path.local(inifile)
+            inipath = absolutepath(inifilename)
 
         assert config.args == [str(cwd)]
-        assert config.option.inifilename == inifile
+        assert config.option.inifilename == inifilename
         assert config.option.capture == "no"
 
         # this indicates this is the file used for getting configuration values
-        assert config.inifile == inipath
+        assert config.inipath == inipath
         assert config.inicfg.get("name") == "value"
         assert config.inicfg.get("should_not_be_set") is None
 
@@ -1247,9 +1314,21 @@ def test_load_initial_conftest_last_ordering(_config_for_test):
     m = My()
     pm.register(m)
     hc = pm.hook.pytest_load_initial_conftests
-    values = hc._nonwrappers + hc._wrappers
-    expected = ["_pytest.config", m.__module__, "_pytest.capture", "_pytest.warnings"]
-    assert [x.function.__module__ for x in values] == expected
+    hookimpls = [
+        (
+            hookimpl.function.__module__,
+            "wrapper" if hookimpl.hookwrapper else "nonwrapper",
+        )
+        for hookimpl in hc.get_hookimpls()
+    ]
+    assert hookimpls == [
+        ("_pytest.config", "nonwrapper"),
+        (m.__module__, "nonwrapper"),
+        ("_pytest.legacypath", "nonwrapper"),
+        ("_pytest.python_path", "nonwrapper"),
+        ("_pytest.capture", "wrapper"),
+        ("_pytest.warnings", "wrapper"),
+    ]
 
 
 def test_get_plugin_specs_as_list() -> None:
@@ -1316,7 +1395,7 @@ class TestRootdir:
     )
     def test_with_ini(self, tmp_path: Path, name: str, contents: str) -> None:
         inipath = tmp_path / name
-        inipath.write_text(contents, "utf-8")
+        inipath.write_text(contents, encoding="utf-8")
 
         a = tmp_path / "a"
         a.mkdir()
@@ -1375,12 +1454,32 @@ class TestRootdir:
     ) -> None:
         p = tmp_path / name
         p.touch()
-        p.write_text(contents, "utf-8")
+        p.write_text(contents, encoding="utf-8")
         rootpath, inipath, ini_config = determine_setup(str(p), [str(tmp_path)])
         assert rootpath == tmp_path
         assert inipath == p
         assert ini_config == {"x": "10"}
 
+    def test_explicit_config_file_sets_rootdir(
+        self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
+    ) -> None:
+        tests_dir = tmp_path / "tests"
+        tests_dir.mkdir()
+
+        monkeypatch.chdir(tmp_path)
+
+        # No config file is explicitly given: rootdir is determined to be cwd.
+        rootpath, found_inipath, *_ = determine_setup(None, [str(tests_dir)])
+        assert rootpath == tmp_path
+        assert found_inipath is None
+
+        # Config file is explicitly given: rootdir is determined to be inifile's directory.
+        inipath = tmp_path / "pytest.ini"
+        inipath.touch()
+        rootpath, found_inipath, *_ = determine_setup(str(inipath), [str(tests_dir)])
+        assert rootpath == tmp_path
+        assert found_inipath == inipath
+
     def test_with_arg_outside_cwd_without_inifile(
         self, tmp_path: Path, monkeypatch: MonkeyPatch
     ) -> None:
@@ -1451,7 +1550,8 @@ class TestOverrideIniArgs:
             custom = 1.0""".format(
                     section=section
                 )
-            )
+            ),
+            encoding="utf-8",
         )
         pytester.makeconftest(
             """
@@ -1475,11 +1575,11 @@ class TestOverrideIniArgs:
         assert result.ret == 0
         result.stdout.fnmatch_lines(["custom_option:3.0"])
 
-    def test_override_ini_pathlist(self, pytester: Pytester) -> None:
+    def test_override_ini_paths(self, pytester: Pytester) -> None:
         pytester.makeconftest(
             """
             def pytest_addoption(parser):
-                parser.addini("paths", "my new ini value", type="pathlist")"""
+                parser.addini("paths", "my new ini value", type="paths")"""
         )
         pytester.makeini(
             """
@@ -1487,13 +1587,13 @@ class TestOverrideIniArgs:
             paths=blah.py"""
         )
         pytester.makepyfile(
-            """
-            import py.path
-            def test_pathlist(pytestconfig):
+            r"""
+            def test_overriden(pytestconfig):
                 config_paths = pytestconfig.getini("paths")
                 print(config_paths)
                 for cpf in config_paths:
-                    print('\\nuser_path:%s' % cpf.basename)"""
+                    print('\nuser_path:%s' % cpf.name)
+            """
         )
         result = pytester.runpytest(
             "--override-ini", "paths=foo/bar1.py foo/bar2.py", "-s"
@@ -1712,7 +1812,7 @@ def test_help_and_version_after_argument_error(pytester: Pytester) -> None:
     assert result.ret == ExitCode.USAGE_ERROR
 
     result = pytester.runpytest("--version")
-    result.stderr.fnmatch_lines([f"pytest {pytest.__version__}"])
+    result.stdout.fnmatch_lines([f"pytest {pytest.__version__}"])
     assert result.ret == ExitCode.USAGE_ERROR
 
 
@@ -1742,6 +1842,10 @@ def test_config_does_not_load_blocked_plugin_from_args(pytester: Pytester) -> No
     result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"])
     assert result.ret == ExitCode.USAGE_ERROR
 
+    result = pytester.runpytest(str(p), "-p no:capture", "-s")
+    result.stderr.fnmatch_lines(["*: error: unrecognized arguments: -s"])
+    assert result.ret == ExitCode.USAGE_ERROR
+
 
 def test_invocation_args(pytester: Pytester) -> None:
     """Ensure that Config.invocation_* arguments are correctly defined"""
@@ -1780,7 +1884,7 @@ def test_invocation_args(pytester: Pytester) -> None:
 )
 def test_config_blocked_default_plugins(pytester: Pytester, plugin: str) -> None:
     if plugin == "debugging":
-        # Fixed in xdist master (after 1.27.0).
+        # Fixed in xdist (after 1.27.0).
         # https://github.com/pytest-dev/pytest-xdist/pull/422
         try:
             import xdist  # noqa: F401
@@ -1796,8 +1900,7 @@ def test_config_blocked_default_plugins(pytester: Pytester, plugin: str) -> None
         assert result.ret == ExitCode.USAGE_ERROR
         result.stderr.fnmatch_lines(
             [
-                "ERROR: not found: */test_config_blocked_default_plugins.py",
-                "(no name '*/test_config_blocked_default_plugins.py' in any of [])",
+                "ERROR: found no collectors for */test_config_blocked_default_plugins.py",
             ]
         )
         return
@@ -1838,6 +1941,9 @@ class TestSetupCfg:
         with pytest.raises(pytest.fail.Exception):
             pytester.runpytest("-c", "custom.cfg")
 
+        with pytest.raises(pytest.fail.Exception):
+            pytester.runpytest("--config-file", "custom.cfg")
+
 
 class TestPytestPluginsVariable:
     def test_pytest_plugins_in_non_top_level_conftest_unsupported(
@@ -1935,10 +2041,10 @@ class TestPytestPluginsVariable:
         assert msg not in res.stdout.str()
 
 
-def test_conftest_import_error_repr(tmpdir: py.path.local) -> None:
+def test_conftest_import_error_repr(tmp_path: Path) -> None:
     """`ConftestImportFailure` should use a short error message and readable
     path to the failed conftest.py file."""
-    path = tmpdir.join("foo/conftest.py")
+    path = tmp_path.joinpath("foo/conftest.py")
     with pytest.raises(
         ConftestImportFailure,
         match=re.escape(f"RuntimeError: some error (from {path})"),
@@ -1992,9 +2098,75 @@ def test_parse_warning_filter(
     assert parse_warning_filter(arg, escape=escape) == expected
 
 
-@pytest.mark.parametrize("arg", [":" * 5, "::::-1", "::::not-a-number"])
+@pytest.mark.parametrize(
+    "arg",
+    [
+        # Too much parts.
+        ":" * 5,
+        # Invalid action.
+        "FOO::",
+        # ImportError when importing the warning class.
+        "::test_parse_warning_filter_failure.NonExistentClass::",
+        # Class is not a Warning subclass.
+        "::list::",
+        # Negative line number.
+        "::::-1",
+        # Not a line number.
+        "::::not-a-number",
+    ],
+)
 def test_parse_warning_filter_failure(arg: str) -> None:
-    import warnings
-
-    with pytest.raises(warnings._OptionError):
+    with pytest.raises(pytest.UsageError):
         parse_warning_filter(arg, escape=True)
+
+
+class TestDebugOptions:
+    def test_without_debug_does_not_write_log(self, pytester: Pytester) -> None:
+        result = pytester.runpytest()
+        result.stderr.no_fnmatch_line(
+            "*writing pytest debug information to*pytestdebug.log"
+        )
+        result.stderr.no_fnmatch_line(
+            "*wrote pytest debug information to*pytestdebug.log"
+        )
+        assert not [f.name for f in pytester.path.glob("**/*.log")]
+
+    def test_with_only_debug_writes_pytestdebug_log(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("--debug")
+        result.stderr.fnmatch_lines(
+            [
+                "*writing pytest debug information to*pytestdebug.log",
+                "*wrote pytest debug information to*pytestdebug.log",
+            ]
+        )
+        assert "pytestdebug.log" in [f.name for f in pytester.path.glob("**/*.log")]
+
+    def test_multiple_custom_debug_logs(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("--debug", "bar.log")
+        result.stderr.fnmatch_lines(
+            [
+                "*writing pytest debug information to*bar.log",
+                "*wrote pytest debug information to*bar.log",
+            ]
+        )
+        result = pytester.runpytest("--debug", "foo.log")
+        result.stderr.fnmatch_lines(
+            [
+                "*writing pytest debug information to*foo.log",
+                "*wrote pytest debug information to*foo.log",
+            ]
+        )
+
+        assert {"bar.log", "foo.log"} == {
+            f.name for f in pytester.path.glob("**/*.log")
+        }
+
+    def test_debug_help(self, pytester: Pytester) -> None:
+        result = pytester.runpytest("-h")
+        result.stdout.fnmatch_lines(
+            [
+                "*Store internal tracing debug information in this log*",
+                "*file. This file is opened with 'w' and truncated as a*",
+                "*Default: pytestdebug.log.",
+            ]
+        )
index 638321728d76b84d95b684cdbc09064152bc2857..4278315078f73a40748903c25e08f7a684b1482a 100644 (file)
@@ -1,13 +1,13 @@
-import argparse
 import os
 import textwrap
 from pathlib import Path
 from typing import cast
 from typing import Dict
+from typing import Generator
 from typing import List
 from typing import Optional
-
-import py
+from typing import Sequence
+from typing import Union
 
 import pytest
 from _pytest.config import ExitCode
@@ -15,7 +15,7 @@ from _pytest.config import PytestPluginManager
 from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pathlib import symlink_or_skip
 from _pytest.pytester import Pytester
-from _pytest.pytester import Testdir
+from _pytest.tmpdir import TempPathFactory
 
 
 def ConftestWithSetinitial(path) -> PytestPluginManager:
@@ -25,89 +25,127 @@ def ConftestWithSetinitial(path) -> PytestPluginManager:
 
 
 def conftest_setinitial(
-    conftest: PytestPluginManager, args, confcutdir: Optional[py.path.local] = None
+    conftest: PytestPluginManager,
+    args: Sequence[Union[str, Path]],
+    confcutdir: Optional[Path] = None,
 ) -> None:
-    class Namespace:
-        def __init__(self) -> None:
-            self.file_or_dir = args
-            self.confcutdir = str(confcutdir)
-            self.noconftest = False
-            self.pyargs = False
-            self.importmode = "prepend"
-
-    namespace = cast(argparse.Namespace, Namespace())
-    conftest._set_initial_conftests(namespace)
+    conftest._set_initial_conftests(
+        args=args,
+        pyargs=False,
+        noconftest=False,
+        rootpath=Path(args[0]),
+        confcutdir=confcutdir,
+        importmode="prepend",
+    )
 
 
 @pytest.mark.usefixtures("_sys_snapshot")
 class TestConftestValueAccessGlobal:
     @pytest.fixture(scope="module", params=["global", "inpackage"])
-    def basedir(self, request, tmpdir_factory):
-        tmpdir = tmpdir_factory.mktemp("basedir", numbered=True)
-        tmpdir.ensure("adir/conftest.py").write("a=1 ; Directory = 3")
-        tmpdir.ensure("adir/b/conftest.py").write("b=2 ; a = 1.5")
+    def basedir(
+        self, request, tmp_path_factory: TempPathFactory
+    ) -> Generator[Path, None, None]:
+        tmp_path = tmp_path_factory.mktemp("basedir", numbered=True)
+        tmp_path.joinpath("adir/b").mkdir(parents=True)
+        tmp_path.joinpath("adir/conftest.py").write_text(
+            "a=1 ; Directory = 3", encoding="utf-8"
+        )
+        tmp_path.joinpath("adir/b/conftest.py").write_text(
+            "b=2 ; a = 1.5", encoding="utf-8"
+        )
         if request.param == "inpackage":
-            tmpdir.ensure("adir/__init__.py")
-            tmpdir.ensure("adir/b/__init__.py")
+            tmp_path.joinpath("adir/__init__.py").touch()
+            tmp_path.joinpath("adir/b/__init__.py").touch()
 
-        yield tmpdir
+        yield tmp_path
 
-    def test_basic_init(self, basedir):
+    def test_basic_init(self, basedir: Path) -> None:
         conftest = PytestPluginManager()
-        p = basedir.join("adir")
-        assert conftest._rget_with_confmod("a", p, importmode="prepend")[1] == 1
+        p = basedir / "adir"
+        assert (
+            conftest._rget_with_confmod("a", p, importmode="prepend", rootpath=basedir)[
+                1
+            ]
+            == 1
+        )
 
-    def test_immediate_initialiation_and_incremental_are_the_same(self, basedir):
+    def test_immediate_initialiation_and_incremental_are_the_same(
+        self, basedir: Path
+    ) -> None:
         conftest = PytestPluginManager()
         assert not len(conftest._dirpath2confmods)
-        conftest._getconftestmodules(basedir, importmode="prepend")
+        conftest._getconftestmodules(
+            basedir, importmode="prepend", rootpath=Path(basedir)
+        )
         snap1 = len(conftest._dirpath2confmods)
         assert snap1 == 1
-        conftest._getconftestmodules(basedir.join("adir"), importmode="prepend")
+        conftest._getconftestmodules(
+            basedir / "adir", importmode="prepend", rootpath=basedir
+        )
         assert len(conftest._dirpath2confmods) == snap1 + 1
-        conftest._getconftestmodules(basedir.join("b"), importmode="prepend")
+        conftest._getconftestmodules(
+            basedir / "b", importmode="prepend", rootpath=basedir
+        )
         assert len(conftest._dirpath2confmods) == snap1 + 2
 
-    def test_value_access_not_existing(self, basedir):
+    def test_value_access_not_existing(self, basedir: Path) -> None:
         conftest = ConftestWithSetinitial(basedir)
         with pytest.raises(KeyError):
-            conftest._rget_with_confmod("a", basedir, importmode="prepend")
+            conftest._rget_with_confmod(
+                "a", basedir, importmode="prepend", rootpath=Path(basedir)
+            )
 
-    def test_value_access_by_path(self, basedir):
+    def test_value_access_by_path(self, basedir: Path) -> None:
         conftest = ConftestWithSetinitial(basedir)
-        adir = basedir.join("adir")
-        assert conftest._rget_with_confmod("a", adir, importmode="prepend")[1] == 1
+        adir = basedir / "adir"
         assert (
-            conftest._rget_with_confmod("a", adir.join("b"), importmode="prepend")[1]
+            conftest._rget_with_confmod(
+                "a", adir, importmode="prepend", rootpath=basedir
+            )[1]
+            == 1
+        )
+        assert (
+            conftest._rget_with_confmod(
+                "a", adir / "b", importmode="prepend", rootpath=basedir
+            )[1]
             == 1.5
         )
 
-    def test_value_access_with_confmod(self, basedir):
-        startdir = basedir.join("adir", "b")
-        startdir.ensure("xx", dir=True)
+    def test_value_access_with_confmod(self, basedir: Path) -> None:
+        startdir = basedir / "adir" / "b"
+        startdir.joinpath("xx").mkdir()
         conftest = ConftestWithSetinitial(startdir)
-        mod, value = conftest._rget_with_confmod("a", startdir, importmode="prepend")
+        mod, value = conftest._rget_with_confmod(
+            "a", startdir, importmode="prepend", rootpath=Path(basedir)
+        )
         assert value == 1.5
-        path = py.path.local(mod.__file__)
-        assert path.dirpath() == basedir.join("adir", "b")
-        assert path.purebasename.startswith("conftest")
+        assert mod.__file__ is not None
+        path = Path(mod.__file__)
+        assert path.parent == basedir / "adir" / "b"
+        assert path.stem == "conftest"
 
 
 def test_conftest_in_nonpkg_with_init(tmp_path: Path, _sys_snapshot) -> None:
     tmp_path.joinpath("adir-1.0/b").mkdir(parents=True)
-    tmp_path.joinpath("adir-1.0/conftest.py").write_text("a=1 ; Directory = 3")
-    tmp_path.joinpath("adir-1.0/b/conftest.py").write_text("b=2 ; a = 1.5")
+    tmp_path.joinpath("adir-1.0/conftest.py").write_text(
+        "a=1 ; Directory = 3", encoding="utf-8"
+    )
+    tmp_path.joinpath("adir-1.0/b/conftest.py").write_text(
+        "b=2 ; a = 1.5", encoding="utf-8"
+    )
     tmp_path.joinpath("adir-1.0/b/__init__.py").touch()
     tmp_path.joinpath("adir-1.0/__init__.py").touch()
     ConftestWithSetinitial(tmp_path.joinpath("adir-1.0", "b"))
 
 
-def test_doubledash_considered(testdir: Testdir) -> None:
-    conf = testdir.mkdir("--option")
-    conf.join("conftest.py").ensure()
+def test_doubledash_considered(pytester: Pytester) -> None:
+    conf = pytester.mkdir("--option")
+    conf.joinpath("conftest.py").touch()
     conftest = PytestPluginManager()
-    conftest_setinitial(conftest, [conf.basename, conf.basename])
-    values = conftest._getconftestmodules(py.path.local(conf), importmode="prepend")
+    conftest_setinitial(conftest, [conf.name, conf.name])
+    values = conftest._getconftestmodules(
+        conf, importmode="prepend", rootpath=pytester.path
+    )
     assert len(values) == 1
 
 
@@ -117,26 +155,28 @@ def test_issue151_load_all_conftests(pytester: Pytester) -> None:
         p = pytester.mkdir(name)
         p.joinpath("conftest.py").touch()
 
-    conftest = PytestPluginManager()
-    conftest_setinitial(conftest, names)
-    d = list(conftest._conftestpath2mod.values())
-    assert len(d) == len(names)
+    pm = PytestPluginManager()
+    conftest_setinitial(pm, names)
+    assert len(set(pm.get_plugins()) - {pm}) == len(names)
 
 
 def test_conftest_global_import(pytester: Pytester) -> None:
     pytester.makeconftest("x=3")
     p = pytester.makepyfile(
         """
-        import py, pytest
+        from pathlib import Path
+        import pytest
         from _pytest.config import PytestPluginManager
         conf = PytestPluginManager()
-        mod = conf._importconftest(py.path.local("conftest.py"), importmode="prepend")
+        mod = conf._importconftest(Path("conftest.py"), importmode="prepend", rootpath=Path.cwd())
         assert mod.x == 3
         import conftest
         assert conftest is mod, (conftest, mod)
-        subconf = py.path.local().ensure("sub", "conftest.py")
-        subconf.write("y=4")
-        mod2 = conf._importconftest(subconf, importmode="prepend")
+        sub = Path("sub")
+        sub.mkdir()
+        subconf = sub / "conftest.py"
+        subconf.write_text("y=4", encoding="utf-8")
+        mod2 = conf._importconftest(subconf, importmode="prepend", rootpath=Path.cwd())
         assert mod != mod2
         assert mod2.y == 4
         import conftest
@@ -147,34 +187,45 @@ def test_conftest_global_import(pytester: Pytester) -> None:
     assert res.ret == 0
 
 
-def test_conftestcutdir(testdir: Testdir) -> None:
-    conf = testdir.makeconftest("")
-    p = testdir.mkdir("x")
+def test_conftestcutdir(pytester: Pytester) -> None:
+    conf = pytester.makeconftest("")
+    p = pytester.mkdir("x")
     conftest = PytestPluginManager()
-    conftest_setinitial(conftest, [testdir.tmpdir], confcutdir=p)
-    values = conftest._getconftestmodules(p, importmode="prepend")
+    conftest_setinitial(conftest, [pytester.path], confcutdir=p)
+    values = conftest._getconftestmodules(
+        p, importmode="prepend", rootpath=pytester.path
+    )
     assert len(values) == 0
-    values = conftest._getconftestmodules(conf.dirpath(), importmode="prepend")
+    values = conftest._getconftestmodules(
+        conf.parent, importmode="prepend", rootpath=pytester.path
+    )
     assert len(values) == 0
-    assert Path(conf) not in conftest._conftestpath2mod
+    assert not conftest.has_plugin(str(conf))
     # but we can still import a conftest directly
-    conftest._importconftest(conf, importmode="prepend")
-    values = conftest._getconftestmodules(conf.dirpath(), importmode="prepend")
+    conftest._importconftest(conf, importmode="prepend", rootpath=pytester.path)
+    values = conftest._getconftestmodules(
+        conf.parent, importmode="prepend", rootpath=pytester.path
+    )
+    assert values[0].__file__ is not None
     assert values[0].__file__.startswith(str(conf))
     # and all sub paths get updated properly
-    values = conftest._getconftestmodules(p, importmode="prepend")
+    values = conftest._getconftestmodules(
+        p, importmode="prepend", rootpath=pytester.path
+    )
     assert len(values) == 1
+    assert values[0].__file__ is not None
     assert values[0].__file__.startswith(str(conf))
 
 
 def test_conftestcutdir_inplace_considered(pytester: Pytester) -> None:
     conf = pytester.makeconftest("")
     conftest = PytestPluginManager()
-    conftest_setinitial(conftest, [conf.parent], confcutdir=py.path.local(conf.parent))
+    conftest_setinitial(conftest, [conf.parent], confcutdir=conf.parent)
     values = conftest._getconftestmodules(
-        py.path.local(conf.parent), importmode="prepend"
+        conf.parent, importmode="prepend", rootpath=pytester.path
     )
     assert len(values) == 1
+    assert values[0].__file__ is not None
     assert values[0].__file__.startswith(str(conf))
 
 
@@ -183,15 +234,15 @@ def test_setinitial_conftest_subdirs(pytester: Pytester, name: str) -> None:
     sub = pytester.mkdir(name)
     subconftest = sub.joinpath("conftest.py")
     subconftest.touch()
-    conftest = PytestPluginManager()
-    conftest_setinitial(conftest, [sub.parent], confcutdir=py.path.local(pytester.path))
+    pm = PytestPluginManager()
+    conftest_setinitial(pm, [sub.parent], confcutdir=pytester.path)
     key = subconftest.resolve()
     if name not in ("whatever", ".dotdir"):
-        assert key in conftest._conftestpath2mod
-        assert len(conftest._conftestpath2mod) == 1
+        assert pm.has_plugin(str(key))
+        assert len(set(pm.get_plugins()) - {pm}) == 1
     else:
-        assert key not in conftest._conftestpath2mod
-        assert len(conftest._conftestpath2mod) == 0
+        assert not pm.has_plugin(str(key))
+        assert len(set(pm.get_plugins()) - {pm}) == 0
 
 
 def test_conftest_confcutdir(pytester: Pytester) -> None:
@@ -203,13 +254,45 @@ def test_conftest_confcutdir(pytester: Pytester) -> None:
             def pytest_addoption(parser):
                 parser.addoption("--xyz", action="store_true")
             """
-        )
+        ),
+        encoding="utf-8",
     )
     result = pytester.runpytest("-h", "--confcutdir=%s" % x, x)
     result.stdout.fnmatch_lines(["*--xyz*"])
     result.stdout.no_fnmatch_line("*warning: could not load initial*")
 
 
+def test_installed_conftest_is_picked_up(pytester: Pytester, tmp_path: Path) -> None:
+    """When using `--pyargs` to run tests in an installed packages (located e.g.
+    in a site-packages in the PYTHONPATH), conftest files in there are picked
+    up.
+
+    Regression test for #9767.
+    """
+    # pytester dir - the source tree.
+    # tmp_path - the simulated site-packages dir (not in source tree).
+
+    pytester.syspathinsert(tmp_path)
+    pytester.makepyprojecttoml("[tool.pytest.ini_options]")
+    tmp_path.joinpath("foo").mkdir()
+    tmp_path.joinpath("foo", "__init__.py").touch()
+    tmp_path.joinpath("foo", "conftest.py").write_text(
+        textwrap.dedent(
+            """\
+            import pytest
+            @pytest.fixture
+            def fix(): return None
+            """
+        ),
+        encoding="utf-8",
+    )
+    tmp_path.joinpath("foo", "test_it.py").write_text(
+        "def test_it(fix): pass", encoding="utf-8"
+    )
+    result = pytester.runpytest("--pyargs", "foo")
+    assert result.ret == 0
+
+
 def test_conftest_symlink(pytester: Pytester) -> None:
     """`conftest.py` discovery follows normal path resolution and does not resolve symlinks."""
     # Structure:
@@ -330,39 +413,39 @@ def test_conftest_existing_junitxml(pytester: Pytester) -> None:
             def pytest_addoption(parser):
                 parser.addoption("--xyz", action="store_true")
             """
-        )
+        ),
+        encoding="utf-8",
     )
     pytester.makefile(ext=".xml", junit="")  # Writes junit.xml
     result = pytester.runpytest("-h", "--junitxml", "junit.xml")
     result.stdout.fnmatch_lines(["*--xyz*"])
 
 
-def test_conftest_import_order(testdir: Testdir, monkeypatch: MonkeyPatch) -> None:
-    ct1 = testdir.makeconftest("")
-    sub = testdir.mkdir("sub")
-    ct2 = sub.join("conftest.py")
-    ct2.write("")
+def test_conftest_import_order(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
+    ct1 = pytester.makeconftest("")
+    sub = pytester.mkdir("sub")
+    ct2 = sub / "conftest.py"
+    ct2.write_text("", encoding="utf-8")
 
-    def impct(p, importmode):
+    def impct(p, importmode, root):
         return p
 
     conftest = PytestPluginManager()
-    conftest._confcutdir = testdir.tmpdir
+    conftest._confcutdir = pytester.path
     monkeypatch.setattr(conftest, "_importconftest", impct)
     mods = cast(
-        List[py.path.local],
-        conftest._getconftestmodules(py.path.local(sub), importmode="prepend"),
+        List[Path],
+        conftest._getconftestmodules(sub, importmode="prepend", rootpath=pytester.path),
     )
     expected = [ct1, ct2]
     assert mods == expected
 
 
 def test_fixture_dependency(pytester: Pytester) -> None:
-    ct1 = pytester.makeconftest("")
-    ct1 = pytester.makepyfile("__init__.py")
-    ct1.write_text("")
+    pytester.makeconftest("")
+    pytester.path.joinpath("__init__.py").touch()
     sub = pytester.mkdir("sub")
-    sub.joinpath("__init__.py").write_text("")
+    sub.joinpath("__init__.py").touch()
     sub.joinpath("conftest.py").write_text(
         textwrap.dedent(
             """\
@@ -380,11 +463,12 @@ def test_fixture_dependency(pytester: Pytester) -> None:
             def bar(foo):
                 return 'bar'
             """
-        )
+        ),
+        encoding="utf-8",
     )
     subsub = sub.joinpath("subsub")
     subsub.mkdir()
-    subsub.joinpath("__init__.py").write_text("")
+    subsub.joinpath("__init__.py").touch()
     subsub.joinpath("test_bar.py").write_text(
         textwrap.dedent(
             """\
@@ -397,7 +481,8 @@ def test_fixture_dependency(pytester: Pytester) -> None:
             def test_event_fixture(bar):
                 assert bar == 'sub bar'
             """
-        )
+        ),
+        encoding="utf-8",
     )
     result = pytester.runpytest("sub")
     result.stdout.fnmatch_lines(["*1 passed*"])
@@ -411,10 +496,11 @@ def test_conftest_found_with_double_dash(pytester: Pytester) -> None:
             def pytest_addoption(parser):
                 parser.addoption("--hello-world", action="store_true")
             """
-        )
+        ),
+        encoding="utf-8",
     )
     p = sub.joinpath("test_hello.py")
-    p.write_text("def test_hello(): pass")
+    p.write_text("def test_hello(): pass", encoding="utf-8")
     result = pytester.runpytest(str(p) + "::test_hello", "-h")
     result.stdout.fnmatch_lines(
         """
@@ -438,7 +524,8 @@ class TestConftestVisibility:
                 def fxtr():
                     return "from-package"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         package.joinpath("test_pkgroot.py").write_text(
             textwrap.dedent(
@@ -446,7 +533,8 @@ class TestConftestVisibility:
                 def test_pkgroot(fxtr):
                     assert fxtr == "from-package"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
 
         swc = package.joinpath("swc")
@@ -460,7 +548,8 @@ class TestConftestVisibility:
                 def fxtr():
                     return "from-swc"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         swc.joinpath("test_with_conftest.py").write_text(
             textwrap.dedent(
@@ -468,7 +557,8 @@ class TestConftestVisibility:
                 def test_with_conftest(fxtr):
                     assert fxtr == "from-swc"
                 """
-            )
+            ),
+            encoding="utf-8",
         )
 
         snc = package.joinpath("snc")
@@ -481,10 +571,11 @@ class TestConftestVisibility:
                     assert fxtr == "from-package"   # No local conftest.py, so should
                                                     # use value from parent dir's
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         print("created directory structure:")
-        for x in pytester.path.rglob(""):
+        for x in pytester.path.glob("**/"):
             print("   " + str(x.relative_to(pytester.path)))
 
         return {"runner": runner, "package": package, "swc": swc, "snc": snc}
@@ -522,10 +613,16 @@ class TestConftestVisibility:
         """#616"""
         dirs = self._setup_tree(pytester)
         print("pytest run in cwd: %s" % (dirs[chdir].relative_to(pytester.path)))
-        print("pytestarg        : %s" % (testarg))
-        print("expected pass    : %s" % (expect_ntests_passed))
+        print("pytestarg        : %s" % testarg)
+        print("expected pass    : %s" % expect_ntests_passed)
         os.chdir(dirs[chdir])
-        reprec = pytester.inline_run(testarg, "-q", "--traceconfig")
+        reprec = pytester.inline_run(
+            testarg,
+            "-q",
+            "--traceconfig",
+            "--confcutdir",
+            pytester.path,
+        )
         reprec.assertoutcome(passed=expect_ntests_passed)
 
 
@@ -541,7 +638,7 @@ def test_search_conftest_up_to_inifile(
     root = pytester.path
     src = root.joinpath("src")
     src.mkdir()
-    src.joinpath("pytest.ini").write_text("[pytest]")
+    src.joinpath("pytest.ini").write_text("[pytest]", encoding="utf-8")
     src.joinpath("conftest.py").write_text(
         textwrap.dedent(
             """\
@@ -549,7 +646,8 @@ def test_search_conftest_up_to_inifile(
             @pytest.fixture
             def fix1(): pass
             """
-        )
+        ),
+        encoding="utf-8",
     )
     src.joinpath("test_foo.py").write_text(
         textwrap.dedent(
@@ -559,7 +657,8 @@ def test_search_conftest_up_to_inifile(
             def test_2(out_of_reach):
                 pass
             """
-        )
+        ),
+        encoding="utf-8",
     )
     root.joinpath("conftest.py").write_text(
         textwrap.dedent(
@@ -568,7 +667,8 @@ def test_search_conftest_up_to_inifile(
             @pytest.fixture
             def out_of_reach(): pass
             """
-        )
+        ),
+        encoding="utf-8",
     )
 
     args = [str(src)]
@@ -629,7 +729,7 @@ def test_hook_proxy(pytester: Pytester) -> None:
             "root/demo-0/test_foo1.py": "def test1(): pass",
             "root/demo-a/test_foo2.py": "def test1(): pass",
             "root/demo-a/conftest.py": """\
-            def pytest_ignore_collect(path, config):
+            def pytest_ignore_collect(collection_path, config):
                 return True
             """,
             "root/demo-b/test_foo3.py": "def test1(): pass",
@@ -651,7 +751,8 @@ def test_required_option_help(pytester: Pytester) -> None:
             def pytest_addoption(parser):
                 parser.addoption("--xyz", action="store_true", required=True)
             """
-        )
+        ),
+        encoding="utf-8",
     )
     result = pytester.runpytest("-h", x)
     result.stdout.no_fnmatch_line("*argument --xyz is required*")
index ed96f7ec78175a3d8032d096ca08c226ec4ff654..eecc1e39fd3d7190d6d99c1fb331ca767f2cce13 100644 (file)
@@ -8,14 +8,6 @@ from _pytest.debugging import _validate_usepdb_cls
 from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pytester import Pytester
 
-try:
-    # Type ignored for Python <= 3.6.
-    breakpoint  # type: ignore
-except NameError:
-    SUPPORTS_BREAKPOINT_BUILTIN = False
-else:
-    SUPPORTS_BREAKPOINT_BUILTIN = True
-
 
 _ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "")
 
@@ -24,13 +16,22 @@ _ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "")
 def pdb_env(request):
     if "pytester" in request.fixturenames:
         # Disable pdb++ with inner tests.
-        pytester = request.getfixturevalue("testdir")
-        pytester.monkeypatch.setenv("PDBPP_HIJACK_PDB", "0")
+        pytester = request.getfixturevalue("pytester")
+        pytester._monkeypatch.setenv("PDBPP_HIJACK_PDB", "0")
 
 
-def runpdb_and_get_report(pytester: Pytester, source: str):
+def runpdb(pytester: Pytester, source: str):
     p = pytester.makepyfile(source)
-    result = pytester.runpytest_inprocess("--pdb", p)
+    return pytester.runpytest_inprocess("--pdb", p)
+
+
+def runpdb_and_get_stdout(pytester: Pytester, source: str):
+    result = runpdb(pytester, source)
+    return result.stdout.str()
+
+
+def runpdb_and_get_report(pytester: Pytester, source: str):
+    result = runpdb(pytester, source)
     reports = result.reprec.getreports("pytest_runtest_logreport")  # type: ignore[attr-defined]
     assert len(reports) == 3, reports  # setup/call/teardown
     return reports[1]
@@ -132,6 +133,16 @@ class TestPDB:
         assert rep.skipped
         assert len(pdblist) == 0
 
+    def test_pdb_on_top_level_raise_skiptest(self, pytester, pdblist) -> None:
+        stdout = runpdb_and_get_stdout(
+            pytester,
+            """
+            import unittest
+            raise unittest.SkipTest("This is a common way to skip an entire file.")
+        """,
+        )
+        assert "entering PDB" not in stdout, stdout
+
     def test_pdb_on_BdbQuit(self, pytester, pdblist) -> None:
         rep = runpdb_and_get_report(
             pytester,
@@ -252,7 +263,7 @@ class TestPDB:
             """
             def test_1():
                 import logging
-                logging.warn("get " + "rekt")
+                logging.warning("get " + "rekt")
                 assert False
         """
         )
@@ -271,7 +282,7 @@ class TestPDB:
             """
             def test_1():
                 import logging
-                logging.warn("get " + "rekt")
+                logging.warning("get " + "rekt")
                 assert False
         """
         )
@@ -361,6 +372,7 @@ class TestPDB:
         result = pytester.runpytest_subprocess("--pdb", ".")
         result.stdout.fnmatch_lines(["-> import unknown"])
 
+    @pytest.mark.xfail(reason="#10042")
     def test_pdb_interaction_capturing_simple(self, pytester: Pytester) -> None:
         p1 = pytester.makepyfile(
             """
@@ -529,6 +541,7 @@ class TestPDB:
         assert "BdbQuit" not in rest
         assert "UNEXPECTED EXCEPTION" not in rest
 
+    @pytest.mark.xfail(reason="#10042")
     def test_pdb_interaction_capturing_twice(self, pytester: Pytester) -> None:
         p1 = pytester.makepyfile(
             """
@@ -564,6 +577,7 @@ class TestPDB:
         assert "1 failed" in rest
         self.flush(child)
 
+    @pytest.mark.xfail(reason="#10042")
     def test_pdb_with_injected_do_debug(self, pytester: Pytester) -> None:
         """Simulates pdbpp, which injects Pdb into do_debug, and uses
         self.__class__ in do_continue.
@@ -877,7 +891,9 @@ class TestPDB:
         assert custom_pdb_calls == []
 
     def test_pdb_custom_cls_with_set_trace(
-        self, pytester: Pytester, monkeypatch: MonkeyPatch,
+        self,
+        pytester: Pytester,
+        monkeypatch: MonkeyPatch,
     ) -> None:
         pytester.makepyfile(
             custom_pdb="""
@@ -909,14 +925,6 @@ class TestPDB:
 
 
 class TestDebuggingBreakpoints:
-    def test_supports_breakpoint_module_global(self) -> None:
-        """Test that supports breakpoint global marks on Python 3.7+."""
-        if sys.version_info >= (3, 7):
-            assert SUPPORTS_BREAKPOINT_BUILTIN is True
-
-    @pytest.mark.skipif(
-        not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin"
-    )
     @pytest.mark.parametrize("arg", ["--pdb", ""])
     def test_sys_breakpointhook_configure_and_unconfigure(
         self, pytester: Pytester, arg: str
@@ -932,7 +940,7 @@ class TestDebuggingBreakpoints:
             from _pytest.debugging import pytestPDB
 
             def pytest_configure(config):
-                config._cleanup.append(check_restored)
+                config.add_cleanup(check_restored)
 
             def check_restored():
                 assert sys.breakpointhook == sys.__breakpointhook__
@@ -950,9 +958,6 @@ class TestDebuggingBreakpoints:
         result = pytester.runpytest_subprocess(*args)
         result.stdout.fnmatch_lines(["*1 passed in *"])
 
-    @pytest.mark.skipif(
-        not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin"
-    )
     def test_pdb_custom_cls(self, pytester: Pytester, custom_debugger_hook) -> None:
         p1 = pytester.makepyfile(
             """
@@ -967,9 +972,6 @@ class TestDebuggingBreakpoints:
         assert custom_debugger_hook == ["init", "set_trace"]
 
     @pytest.mark.parametrize("arg", ["--pdb", ""])
-    @pytest.mark.skipif(
-        not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin"
-    )
     def test_environ_custom_class(
         self, pytester: Pytester, custom_debugger_hook, arg: str
     ) -> None:
@@ -981,7 +983,7 @@ class TestDebuggingBreakpoints:
             os.environ['PYTHONBREAKPOINT'] = '_pytest._CustomDebugger.set_trace'
 
             def pytest_configure(config):
-                config._cleanup.append(check_restored)
+                config.add_cleanup(check_restored)
 
             def check_restored():
                 assert sys.breakpointhook == sys.__breakpointhook__
@@ -1000,9 +1002,6 @@ class TestDebuggingBreakpoints:
         result = pytester.runpytest_subprocess(*args)
         result.stdout.fnmatch_lines(["*1 passed in *"])
 
-    @pytest.mark.skipif(
-        not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin"
-    )
     @pytest.mark.skipif(
         not _ENVIRON_PYTHONBREAKPOINT == "",
         reason="Requires breakpoint() default value",
@@ -1023,9 +1022,7 @@ class TestDebuggingBreakpoints:
         assert "reading from stdin while output" not in rest
         TestPDB.flush(child)
 
-    @pytest.mark.skipif(
-        not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin"
-    )
+    @pytest.mark.xfail(reason="#10042")
     def test_pdb_not_altered(self, pytester: Pytester) -> None:
         p1 = pytester.makepyfile(
             """
@@ -1185,6 +1182,7 @@ def test_quit_with_swallowed_SystemExit(pytester: Pytester) -> None:
 
 
 @pytest.mark.parametrize("fixture", ("capfd", "capsys"))
+@pytest.mark.xfail(reason="#10042")
 def test_pdb_suspends_fixture_capturing(pytester: Pytester, fixture: str) -> None:
     """Using "-s" with pytest should suspend/resume fixture capturing."""
     p1 = pytester.makepyfile(
index 6e3880330a96392db6ae138f62cf8555d98bdce0..665bdb73b5d9da6295eee3bbf5e7f20ee0f31b1e 100644 (file)
@@ -1,12 +1,13 @@
 import inspect
+import sys
 import textwrap
+from pathlib import Path
 from typing import Callable
 from typing import Optional
 
-import py
-
 import pytest
 from _pytest.doctest import _get_checker
+from _pytest.doctest import _is_main_py
 from _pytest.doctest import _is_mocked
 from _pytest.doctest import _is_setup_py
 from _pytest.doctest import _patch_unwrap_mock_aware
@@ -70,7 +71,9 @@ class TestDoctests:
 
     @pytest.mark.parametrize("filename", ["__init__", "whatever"])
     def test_collect_module_two_doctest_no_modulelevel(
-        self, pytester: Pytester, filename: str,
+        self,
+        pytester: Pytester,
+        filename: str,
     ) -> None:
         path = pytester.makepyfile(
             **{
@@ -78,7 +81,7 @@ class TestDoctests:
             '# Empty'
             def my_func():
                 ">>> magic = 42 "
-            def unuseful():
+            def useless():
                 '''
                 # This is a function
                 # >>> # it doesn't have any doctest
@@ -110,6 +113,28 @@ class TestDoctests:
         reprec = pytester.inline_run(p)
         reprec.assertoutcome(failed=1)
 
+    def test_importmode(self, pytester: Pytester):
+        p = pytester.makepyfile(
+            **{
+                "namespacepkg/innerpkg/__init__.py": "",
+                "namespacepkg/innerpkg/a.py": """
+                  def some_func():
+                    return 42
+                """,
+                "namespacepkg/innerpkg/b.py": """
+                  from namespacepkg.innerpkg.a import some_func
+                  def my_func():
+                    '''
+                    >>> my_func()
+                    42
+                    '''
+                    return some_func()
+                """,
+            }
+        )
+        reprec = pytester.inline_run(p, "--doctest-modules", "--import-mode=importlib")
+        reprec.assertoutcome(passed=1)
+
     def test_new_pattern(self, pytester: Pytester):
         p = pytester.maketxtfile(
             xdoc="""
@@ -198,6 +223,11 @@ class TestDoctests:
                 "Traceback (most recent call last):",
                 '  File "*/doctest.py", line *, in __run',
                 "    *",
+                *(
+                    (" *^^^^*",)
+                    if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
+                    else ()
+                ),
                 '  File "<doctest test_doctest_unexpected_exception.txt[1]>", line 1, in <module>',
                 "ZeroDivisionError: division by zero",
                 "*/test_doctest_unexpected_exception.txt:2: UnexpectedException",
@@ -327,7 +357,8 @@ class TestDoctests:
                         >>> 1/0
                         '''
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         result = pytester.runpytest("--doctest-modules")
         result.stdout.fnmatch_lines(
@@ -418,7 +449,8 @@ class TestDoctests:
                 """\
                 import asdalsdkjaslkdjasd
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         pytester.maketxtfile(
             """
@@ -450,6 +482,27 @@ class TestDoctests:
         reprec = pytester.inline_run(p, "--doctest-modules")
         reprec.assertoutcome(failed=1)
 
+    @pytest.mark.skipif(
+        sys.version_info[:2] <= (3, 7), reason="Only Python 3.7 or less"
+    )
+    def test_doctest_cached_property(self, pytester: Pytester):
+        p = pytester.makepyfile(
+            """
+            import functools
+
+            class Foo:
+                @functools.cached_property
+                def foo(self):
+                    '''
+                    >>> assert False, "Tacos!"
+                    '''
+                    ...
+        """
+        )
+        result = pytester.runpytest(p, "--doctest-modules")
+        result.assert_outcomes(failed=1)
+        assert "Tacos!" in result.stdout.str()
+
     def test_doctestmodule_external_and_issue116(self, pytester: Pytester):
         p = pytester.mkpydir("hello")
         p.joinpath("__init__.py").write_text(
@@ -462,7 +515,8 @@ class TestDoctests:
                         2
                     '''
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         result = pytester.runpytest(p, "--doctest-modules")
         result.stdout.fnmatch_lines(
@@ -562,7 +616,7 @@ class TestDoctests:
                 >>> magic - 42
                 0
                 '''
-            def unuseful():
+            def useless():
                 pass
             def another():
                 '''
@@ -729,12 +783,11 @@ class TestDoctests:
             test_unicode_doctest="""
             .. doctest::
 
-                >>> print(
-                ...    "Hi\\n\\nByé")
+                >>> print("Hi\\n\\nByé")
                 Hi
                 ...
                 Byé
-                >>> 1/0  # Byé
+                >>> 1 / 0  # Byé
                 1
         """
         )
@@ -800,17 +853,23 @@ class TestDoctests:
         """
         p = pytester.makepyfile(
             setup="""
-            from setuptools import setup, find_packages
-            setup(name='sample',
-                  version='0.0',
-                  description='description',
-                  packages=find_packages()
-            )
+            if __name__ == '__main__':
+                from setuptools import setup, find_packages
+                setup(name='sample',
+                      version='0.0',
+                      description='description',
+                      packages=find_packages()
+                )
         """
         )
         result = pytester.runpytest(p, "--doctest-modules")
         result.stdout.fnmatch_lines(["*collected 0 items*"])
 
+    def test_main_py_does_not_cause_import_errors(self, pytester: Pytester):
+        p = pytester.copy_example("doctest/main_py")
+        result = pytester.runpytest(p, "--doctest-modules")
+        result.stdout.fnmatch_lines(["*collected 2 items*", "*1 failed, 1 passed*"])
+
     def test_invalid_setup_py(self, pytester: Pytester):
         """
         Test to make sure that pytest reads setup.py files that are not used
@@ -1164,9 +1223,43 @@ class TestDoctestSkips:
             ["*4: UnexpectedException*", "*5: DocTestFailure*", "*8: DocTestFailure*"]
         )
 
+    def test_skipping_wrapped_test(self, pytester):
+        """
+        Issue 8796: INTERNALERROR raised when skipping a decorated DocTest
+        through pytest_collection_modifyitems.
+        """
+        pytester.makeconftest(
+            """
+            import pytest
+            from _pytest.doctest import DoctestItem
 
-class TestDoctestAutoUseFixtures:
+            def pytest_collection_modifyitems(config, items):
+                skip_marker = pytest.mark.skip()
+
+                for item in items:
+                    if isinstance(item, DoctestItem):
+                        item.add_marker(skip_marker)
+            """
+        )
+
+        pytester.makepyfile(
+            """
+            from contextlib import contextmanager
+
+            @contextmanager
+            def my_config_context():
+                '''
+                >>> import os
+                '''
+            """
+        )
+
+        result = pytester.runpytest("--doctest-modules")
+        assert "INTERNALERROR" not in result.stdout.str()
+        result.assert_outcomes(skipped=1)
 
+
+class TestDoctestAutoUseFixtures:
     SCOPES = ["module", "session", "class", "function"]
 
     def test_doctest_module_session_fixture(self, pytester: Pytester):
@@ -1309,7 +1402,6 @@ class TestDoctestAutoUseFixtures:
 
 
 class TestDoctestNamespaceFixture:
-
     SCOPES = ["module", "session", "class", "function"]
 
     @pytest.mark.parametrize("scope", SCOPES)
@@ -1496,25 +1588,35 @@ def test_warning_on_unwrap_of_broken_object(
     assert inspect.unwrap.__module__ == "inspect"
 
 
-def test_is_setup_py_not_named_setup_py(tmp_path):
+def test_is_setup_py_not_named_setup_py(tmp_path: Path) -> None:
     not_setup_py = tmp_path.joinpath("not_setup.py")
-    not_setup_py.write_text('from setuptools import setup; setup(name="foo")')
-    assert not _is_setup_py(py.path.local(str(not_setup_py)))
+    not_setup_py.write_text(
+        'from setuptools import setup; setup(name="foo")', encoding="utf-8"
+    )
+    assert not _is_setup_py(not_setup_py)
 
 
 @pytest.mark.parametrize("mod", ("setuptools", "distutils.core"))
-def test_is_setup_py_is_a_setup_py(tmpdir, mod):
-    setup_py = tmpdir.join("setup.py")
-    setup_py.write(f'from {mod} import setup; setup(name="foo")')
+def test_is_setup_py_is_a_setup_py(tmp_path: Path, mod: str) -> None:
+    setup_py = tmp_path.joinpath("setup.py")
+    setup_py.write_text(f'from {mod} import setup; setup(name="foo")', "utf-8")
     assert _is_setup_py(setup_py)
 
 
 @pytest.mark.parametrize("mod", ("setuptools", "distutils.core"))
-def test_is_setup_py_different_encoding(tmp_path, mod):
+def test_is_setup_py_different_encoding(tmp_path: Path, mod: str) -> None:
     setup_py = tmp_path.joinpath("setup.py")
     contents = (
         "# -*- coding: cp1252 -*-\n"
         'from {} import setup; setup(name="foo", description="€")\n'.format(mod)
     )
     setup_py.write_bytes(contents.encode("cp1252"))
-    assert _is_setup_py(py.path.local(str(setup_py)))
+    assert _is_setup_py(setup_py)
+
+
+@pytest.mark.parametrize(
+    "name, expected", [("__main__.py", True), ("__init__.py", False)]
+)
+def test_is_main_py(tmp_path: Path, name: str, expected: bool) -> None:
+    dunder_main = tmp_path.joinpath(name)
+    assert _is_main_py(dunder_main) == expected
index 1668e929ab413642e1bb0148b971f4a6cc5f364f..eb7812108725eb087b5a072b71ff516004c0d841 100644 (file)
@@ -4,8 +4,6 @@ Tests and examples for correct "+/-" usage in error diffs.
 See https://github.com/pytest-dev/pytest/issues/3333 for details.
 
 """
-import sys
-
 import pytest
 from _pytest.pytester import Pytester
 
@@ -210,68 +208,61 @@ TESTCASES = [
         """,
         id='Test "not in" string',
     ),
-]
-if sys.version_info[:2] >= (3, 7):
-    TESTCASES.extend(
-        [
-            pytest.param(
-                """
-                from dataclasses import dataclass
+    pytest.param(
+        """
+        from dataclasses import dataclass
 
-                @dataclass
-                class A:
-                    a: int
-                    b: str
+        @dataclass
+        class A:
+            a: int
+            b: str
 
-                def test_this():
-                    result =   A(1, 'spam')
-                    expected = A(2, 'spam')
-                    assert result == expected
-                """,
-                """
-                >       assert result == expected
-                E       AssertionError: assert A(a=1, b='spam') == A(a=2, b='spam')
-                E         Matching attributes:
-                E         ['b']
-                E         Differing attributes:
-                E         ['a']
-                E         Drill down into differing attribute a:
-                E           a: 1 != 2
-                E           +1
-                E           -2
-                """,
-                id="Compare data classes",
-            ),
-            pytest.param(
-                """
-                import attr
+        def test_this():
+            result =   A(1, 'spam')
+            expected = A(2, 'spam')
+            assert result == expected
+        """,
+        """
+        >       assert result == expected
+        E       AssertionError: assert A(a=1, b='spam') == A(a=2, b='spam')
+        E         Matching attributes:
+        E         ['b']
+        E         Differing attributes:
+        E         ['a']
+        E         Drill down into differing attribute a:
+        E           a: 1 != 2
+        """,
+        id="Compare data classes",
+    ),
+    pytest.param(
+        """
+        import attr
 
-                @attr.s(auto_attribs=True)
-                class A:
-                    a: int
-                    b: str
+        @attr.s(auto_attribs=True)
+        class A:
+            a: int
+            b: str
 
-                def test_this():
-                    result =   A(1, 'spam')
-                    expected = A(1, 'eggs')
-                    assert result == expected
-                """,
-                """
-                >       assert result == expected
-                E       AssertionError: assert A(a=1, b='spam') == A(a=1, b='eggs')
-                E         Matching attributes:
-                E         ['a']
-                E         Differing attributes:
-                E         ['b']
-                E         Drill down into differing attribute b:
-                E           b: 'spam' != 'eggs'
-                E           - eggs
-                E           + spam
-                """,
-                id="Compare attrs classes",
-            ),
-        ]
-    )
+        def test_this():
+            result =   A(1, 'spam')
+            expected = A(1, 'eggs')
+            assert result == expected
+        """,
+        """
+        >       assert result == expected
+        E       AssertionError: assert A(a=1, b='spam') == A(a=1, b='eggs')
+        E         Matching attributes:
+        E         ['a']
+        E         Differing attributes:
+        E         ['b']
+        E         Drill down into differing attribute b:
+        E           b: 'spam' != 'eggs'
+        E           - eggs
+        E           + spam
+        """,
+        id="Compare attrs classes",
+    ),
+]
 
 
 @pytest.mark.parametrize("code, expected", TESTCASES)
index 370084c125f08f850f7901250bd7e589103524a8..5b7911f21f833e74356357e9d23a9599483f914b 100644 (file)
@@ -19,22 +19,41 @@ def test_enabled(pytester: Pytester) -> None:
     assert result.ret != 0
 
 
-def test_crash_near_exit(pytester: Pytester) -> None:
-    """Test that fault handler displays crashes that happen even after
-    pytest is exiting (for example, when the interpreter is shutting down)."""
+def setup_crashing_test(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
-    import faulthandler
-    import atexit
-    def test_ok():
-        atexit.register(faulthandler._sigabrt)
-    """
+        import faulthandler
+        import atexit
+        def test_ok():
+            atexit.register(faulthandler._sigabrt)
+        """
     )
-    result = pytester.runpytest_subprocess()
+
+
+def test_crash_during_shutdown_captured(pytester: Pytester) -> None:
+    """
+    Re-enable faulthandler if pytest encountered it enabled during configure.
+    We should be able to then see crashes during interpreter shutdown.
+    """
+    setup_crashing_test(pytester)
+    args = (sys.executable, "-Xfaulthandler", "-mpytest")
+    result = pytester.run(*args)
     result.stderr.fnmatch_lines(["*Fatal Python error*"])
     assert result.ret != 0
 
 
+def test_crash_during_shutdown_not_captured(pytester: Pytester) -> None:
+    """
+    Check that pytest leaves faulthandler disabled if it was not enabled during configure.
+    This prevents us from seeing crashes during interpreter shutdown (see #8260).
+    """
+    setup_crashing_test(pytester)
+    args = (sys.executable, "-mpytest")
+    result = pytester.run(*args)
+    result.stderr.no_fnmatch_line("*Fatal Python error*")
+    assert result.ret != 0
+
+
 def test_disabled(pytester: Pytester) -> None:
     """Test option to disable fault handler in the command line."""
     pytester.makepyfile(
@@ -94,7 +113,7 @@ def test_cancel_timeout_on_hook(monkeypatch, hook_name) -> None:
     to timeout before entering pdb (pytest-dev/pytest-faulthandler#12) or any
     other interactive exception (pytest-dev/pytest-faulthandler#14)."""
     import faulthandler
-    from _pytest.faulthandler import FaultHandlerHooks
+    from _pytest import faulthandler as faulthandler_plugin
 
     called = []
 
@@ -104,19 +123,18 @@ def test_cancel_timeout_on_hook(monkeypatch, hook_name) -> None:
 
     # call our hook explicitly, we can trust that pytest will call the hook
     # for us at the appropriate moment
-    hook_func = getattr(FaultHandlerHooks, hook_name)
-    hook_func(self=None)
+    hook_func = getattr(faulthandler_plugin, hook_name)
+    hook_func()
     assert called == [1]
 
 
-@pytest.mark.parametrize("faulthandler_timeout", [0, 2])
-def test_already_initialized(faulthandler_timeout: int, pytester: Pytester) -> None:
-    """Test for faulthandler being initialized earlier than pytest (#6575)."""
+def test_already_initialized_crash(pytester: Pytester) -> None:
+    """Even if faulthandler is already initialized, we still dump tracebacks on crashes (#8258)."""
     pytester.makepyfile(
         """
         def test():
             import faulthandler
-            assert faulthandler.is_enabled()
+            faulthandler._sigabrt()
     """
     )
     result = pytester.run(
@@ -125,22 +143,14 @@ def test_already_initialized(faulthandler_timeout: int, pytester: Pytester) -> N
         "faulthandler",
         "-mpytest",
         pytester.path,
-        "-o",
-        f"faulthandler_timeout={faulthandler_timeout}",
     )
-    # ensure warning is emitted if faulthandler_timeout is configured
-    warning_line = "*faulthandler.py*faulthandler module enabled before*"
-    if faulthandler_timeout > 0:
-        result.stdout.fnmatch_lines(warning_line)
-    else:
-        result.stdout.no_fnmatch_line(warning_line)
-    result.stdout.fnmatch_lines("*1 passed*")
-    assert result.ret == 0
+    result.stderr.fnmatch_lines(["*Fatal Python error*"])
+    assert result.ret != 0
 
 
 def test_get_stderr_fileno_invalid_fd() -> None:
     """Test for faulthandler being able to handle invalid file descriptors for stderr (#8249)."""
-    from _pytest.faulthandler import FaultHandlerHooks
+    from _pytest.faulthandler import get_stderr_fileno
 
     class StdErrWrapper(io.StringIO):
         """
@@ -159,4 +169,4 @@ def test_get_stderr_fileno_invalid_fd() -> None:
 
         # Even when the stderr wrapper signals an invalid file descriptor,
         # ``_get_stderr_fileno()`` should return the real one.
-        assert FaultHandlerHooks._get_stderr_fileno() == 2
+        assert get_stderr_fileno() == 2
index af6aeb3a56dcfe522c8340abeadd232f106e2169..8287de603ed5b4e21b653d75ea6fe4589b88d408 100644 (file)
@@ -1,9 +1,12 @@
+import os
 from pathlib import Path
 from textwrap import dedent
 
 import pytest
+from _pytest.config import UsageError
 from _pytest.config.findpaths import get_common_ancestor
 from _pytest.config.findpaths import get_dirs_from_args
+from _pytest.config.findpaths import is_fs_root
 from _pytest.config.findpaths import load_config_dict_from_file
 
 
@@ -52,6 +55,13 @@ class TestLoadConfigDictFromFile:
             load_config_dict_from_file(fn)
 
     def test_invalid_toml_file(self, tmp_path: Path) -> None:
+        """Invalid .toml files should raise `UsageError`."""
+        fn = tmp_path / "myconfig.toml"
+        fn.write_text("]invalid toml[", encoding="utf-8")
+        with pytest.raises(UsageError):
+            load_config_dict_from_file(fn)
+
+    def test_custom_toml_file(self, tmp_path: Path) -> None:
         """.toml files without [tool.pytest.ini_options] are not considered for configuration."""
         fn = tmp_path / "myconfig.toml"
         fn.write_text(
@@ -77,6 +87,7 @@ class TestLoadConfigDictFromFile:
             y = 20.0
             values = ["tests", "integration"]
             name = "foo"
+            heterogeneous_array = [1, "str"]
             """
             ),
             encoding="utf-8",
@@ -86,6 +97,7 @@ class TestLoadConfigDictFromFile:
             "y": "20.0",
             "values": ["tests", "integration"],
             "name": "foo",
+            "heterogeneous_array": [1, "str"],
         }
 
 
@@ -123,3 +135,18 @@ def test_get_dirs_from_args(tmp_path):
     assert get_dirs_from_args(
         [str(fn), str(tmp_path / "does_not_exist"), str(d), option, xdist_rsync_option]
     ) == [fn.parent, d]
+
+
+@pytest.mark.parametrize(
+    "path, expected",
+    [
+        pytest.param(
+            f"e:{os.sep}", True, marks=pytest.mark.skipif("sys.platform != 'win32'")
+        ),
+        (f"{os.sep}", True),
+        (f"e:{os.sep}projects", False),
+        (f"{os.sep}projects", False),
+    ],
+)
+def test_is_fs_root(path: Path, expected: bool) -> None:
+    assert is_fs_root(Path(path)) is expected
index c2533ef304ab6319ee850a2e441a5ef951868f6e..ba89d0c4acffca55d35df3c88fca97210f75f9db 100644 (file)
@@ -7,17 +7,22 @@ def test_version_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None:
     monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
     result = pytester.runpytest("--version", "--version")
     assert result.ret == 0
-    result.stderr.fnmatch_lines([f"*pytest*{pytest.__version__}*imported from*"])
+    result.stdout.fnmatch_lines([f"*pytest*{pytest.__version__}*imported from*"])
     if pytestconfig.pluginmanager.list_plugin_distinfo():
-        result.stderr.fnmatch_lines(["*setuptools registered plugins:", "*at*"])
+        result.stdout.fnmatch_lines(["*setuptools registered plugins:", "*at*"])
 
 
 def test_version_less_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None:
     monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
     result = pytester.runpytest("--version")
     assert result.ret == 0
-    # p = py.path.local(py.__file__).dirpath()
-    result.stderr.fnmatch_lines([f"pytest {pytest.__version__}"])
+    result.stdout.fnmatch_lines([f"pytest {pytest.__version__}"])
+
+
+def test_versions():
+    """Regression check for the public version attributes in pytest."""
+    assert isinstance(pytest.__version__, str)
+    assert isinstance(pytest.version_tuple, tuple)
 
 
 def test_help(pytester: Pytester) -> None:
@@ -25,10 +30,13 @@ def test_help(pytester: Pytester) -> None:
     assert result.ret == 0
     result.stdout.fnmatch_lines(
         """
-          -m MARKEXPR           only run tests matching given mark expression.
-                                For example: -m 'mark1 and not mark2'.
-        reporting:
+          -m MARKEXPR           Only run tests matching given mark expression. For
+                                example: -m 'mark1 and not mark2'.
+        Reporting:
           --durations=N *
+          -V, --version         Display pytest version and information about plugins.
+                                When given twice, also display information about
+                                plugins.
         *setup.cfg*
         *minversion*
         *to see*markers*pytest --markers*
@@ -63,9 +71,9 @@ def test_empty_help_param(pytester: Pytester) -> None:
     assert result.ret == 0
     lines = [
         "  required_plugins (args):",
-        "                        plugins that must be present for pytest to run*",
+        "                        Plugins that must be present for pytest to run*",
         "  test_ini (bool):*",
-        "environment variables:",
+        "Environment variables:",
     ]
     result.stdout.fnmatch_lines(lines, consecutive=True)
 
@@ -97,7 +105,7 @@ def test_hookvalidation_optional(pytester: Pytester) -> None:
 
 def test_traceconfig(pytester: Pytester) -> None:
     result = pytester.runpytest("--traceconfig")
-    result.stdout.fnmatch_lines(["*using*pytest*py*", "*active plugins*"])
+    result.stdout.fnmatch_lines(["*using*pytest*", "*active plugins*"])
 
 
 def test_debug(pytester: Pytester) -> None:
index 006bea96280a4cb9f27cde24efe123c3af1063d4..3f88c21e2b7b30b960e972e33094afd9127c13fb 100644 (file)
@@ -4,51 +4,62 @@ from datetime import datetime
 from pathlib import Path
 from typing import cast
 from typing import List
+from typing import Optional
 from typing import Tuple
 from typing import TYPE_CHECKING
+from typing import Union
 from xml.dom import minidom
 
-import py
 import xmlschema
 
 import pytest
 from _pytest.config import Config
 from _pytest.junitxml import bin_xml_escape
 from _pytest.junitxml import LogXML
+from _pytest.monkeypatch import MonkeyPatch
+from _pytest.pytester import Pytester
+from _pytest.pytester import RunResult
 from _pytest.reports import BaseReport
 from _pytest.reports import TestReport
-from _pytest.store import Store
+from _pytest.stash import Stash
 
 
 @pytest.fixture(scope="session")
-def schema():
+def schema() -> xmlschema.XMLSchema:
     """Return an xmlschema.XMLSchema object for the junit-10.xsd file."""
     fn = Path(__file__).parent / "example_scripts/junit-10.xsd"
-    with fn.open() as f:
+    with fn.open(encoding="utf-8") as f:
         return xmlschema.XMLSchema(f)
 
 
-@pytest.fixture
-def run_and_parse(testdir, schema):
-    """Fixture that returns a function that can be used to execute pytest and
-    return the parsed ``DomNode`` of the root xml node.
+class RunAndParse:
+    def __init__(self, pytester: Pytester, schema: xmlschema.XMLSchema) -> None:
+        self.pytester = pytester
+        self.schema = schema
 
-    The ``family`` parameter is used to configure the ``junit_family`` of the written report.
-    "xunit2" is also automatically validated against the schema.
-    """
-
-    def run(*args, family="xunit1"):
+    def __call__(
+        self, *args: Union[str, "os.PathLike[str]"], family: Optional[str] = "xunit1"
+    ) -> Tuple[RunResult, "DomNode"]:
         if family:
             args = ("-o", "junit_family=" + family) + args
-        xml_path = testdir.tmpdir.join("junit.xml")
-        result = testdir.runpytest("--junitxml=%s" % xml_path, *args)
+        xml_path = self.pytester.path.joinpath("junit.xml")
+        result = self.pytester.runpytest("--junitxml=%s" % xml_path, *args)
         if family == "xunit2":
-            with xml_path.open() as f:
-                schema.validate(f)
+            with xml_path.open(encoding="utf-8") as f:
+                self.schema.validate(f)
         xmldoc = minidom.parse(str(xml_path))
         return result, DomNode(xmldoc)
 
-    return run
+
+@pytest.fixture
+def run_and_parse(pytester: Pytester, schema: xmlschema.XMLSchema) -> RunAndParse:
+    """Fixture that returns a function that can be used to execute pytest and
+    return the parsed ``DomNode`` of the root xml node.
+
+    The ``family`` parameter is used to configure the ``junit_family`` of the written report.
+    "xunit2" is also automatically validated against the schema.
+    """
+    return RunAndParse(pytester, schema)
 
 
 def assert_attr(node, **kwargs):
@@ -130,8 +141,10 @@ parametrize_families = pytest.mark.parametrize("xunit_family", ["xunit1", "xunit
 
 class TestPython:
     @parametrize_families
-    def test_summing_simple(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_summing_simple(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def test_pass():
@@ -154,8 +167,10 @@ class TestPython:
         node.assert_attr(name="pytest", errors=0, failures=1, skipped=2, tests=5)
 
     @parametrize_families
-    def test_summing_simple_with_errors(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_summing_simple_with_errors(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.fixture
@@ -181,8 +196,10 @@ class TestPython:
         node.assert_attr(name="pytest", errors=1, failures=2, skipped=1, tests=5)
 
     @parametrize_families
-    def test_hostname_in_xml(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_hostname_in_xml(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             def test_pass():
                 pass
@@ -193,8 +210,10 @@ class TestPython:
         node.assert_attr(hostname=platform.node())
 
     @parametrize_families
-    def test_timestamp_in_xml(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_timestamp_in_xml(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             def test_pass():
                 pass
@@ -206,8 +225,10 @@ class TestPython:
         timestamp = datetime.strptime(node["timestamp"], "%Y-%m-%dT%H:%M:%S.%f")
         assert start_time <= timestamp < datetime.now()
 
-    def test_timing_function(self, testdir, run_and_parse, mock_timing):
-        testdir.makepyfile(
+    def test_timing_function(
+        self, pytester: Pytester, run_and_parse: RunAndParse, mock_timing
+    ) -> None:
+        pytester.makepyfile(
             """
             from _pytest import timing
             def setup_module():
@@ -226,9 +247,12 @@ class TestPython:
 
     @pytest.mark.parametrize("duration_report", ["call", "total"])
     def test_junit_duration_report(
-        self, testdir, monkeypatch, duration_report, run_and_parse
-    ):
-
+        self,
+        pytester: Pytester,
+        monkeypatch: MonkeyPatch,
+        duration_report: str,
+        run_and_parse: RunAndParse,
+    ) -> None:
         # mock LogXML.node_reporter so it always sets a known duration to each test report object
         original_node_reporter = LogXML.node_reporter
 
@@ -239,7 +263,7 @@ class TestPython:
 
         monkeypatch.setattr(LogXML, "node_reporter", node_reporter_wrapper)
 
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_foo():
                 pass
@@ -256,8 +280,10 @@ class TestPython:
             assert val == 1.0
 
     @parametrize_families
-    def test_setup_error(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_setup_error(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -279,8 +305,10 @@ class TestPython:
         assert "ValueError" in fnode.toxml()
 
     @parametrize_families
-    def test_teardown_error(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_teardown_error(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -302,8 +330,10 @@ class TestPython:
         assert "ValueError" in fnode.toxml()
 
     @parametrize_families
-    def test_call_failure_teardown_error(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_call_failure_teardown_error(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -331,8 +361,10 @@ class TestPython:
         )
 
     @parametrize_families
-    def test_skip_contains_name_reason(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_skip_contains_name_reason(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def test_skip():
@@ -349,8 +381,10 @@ class TestPython:
         snode.assert_attr(type="pytest.skip", message="hello23")
 
     @parametrize_families
-    def test_mark_skip_contains_name_reason(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_mark_skip_contains_name_reason(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.skip(reason="hello24")
@@ -371,9 +405,9 @@ class TestPython:
 
     @parametrize_families
     def test_mark_skipif_contains_name_reason(
-        self, testdir, run_and_parse, xunit_family
-    ):
-        testdir.makepyfile(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             GLOBAL_CONDITION = True
@@ -395,9 +429,9 @@ class TestPython:
 
     @parametrize_families
     def test_mark_skip_doesnt_capture_output(
-        self, testdir, run_and_parse, xunit_family
-    ):
-        testdir.makepyfile(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.skip(reason="foo")
@@ -411,8 +445,10 @@ class TestPython:
         assert "bar!" not in node_xml
 
     @parametrize_families
-    def test_classname_instance(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_classname_instance(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             class TestClass(object):
                 def test_method(self):
@@ -429,9 +465,11 @@ class TestPython:
         )
 
     @parametrize_families
-    def test_classname_nested_dir(self, testdir, run_and_parse, xunit_family):
-        p = testdir.tmpdir.ensure("sub", "test_hello.py")
-        p.write("def test_func(): 0/0")
+    def test_classname_nested_dir(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        p = pytester.mkdir("sub").joinpath("test_hello.py")
+        p.write_text("def test_func(): 0/0", encoding="utf-8")
         result, dom = run_and_parse(family=xunit_family)
         assert result.ret
         node = dom.find_first_by_tag("testsuite")
@@ -440,9 +478,11 @@ class TestPython:
         tnode.assert_attr(classname="sub.test_hello", name="test_func")
 
     @parametrize_families
-    def test_internal_error(self, testdir, run_and_parse, xunit_family):
-        testdir.makeconftest("def pytest_runtest_protocol(): 0 / 0")
-        testdir.makepyfile("def test_function(): pass")
+    def test_internal_error(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makeconftest("def pytest_runtest_protocol(): 0 / 0")
+        pytester.makepyfile("def test_function(): pass")
         result, dom = run_and_parse(family=xunit_family)
         assert result.ret
         node = dom.find_first_by_tag("testsuite")
@@ -458,9 +498,13 @@ class TestPython:
     )
     @parametrize_families
     def test_failure_function(
-        self, testdir, junit_logging, run_and_parse, xunit_family
-    ):
-        testdir.makepyfile(
+        self,
+        pytester: Pytester,
+        junit_logging,
+        run_and_parse: RunAndParse,
+        xunit_family,
+    ) -> None:
+        pytester.makepyfile(
             """
             import logging
             import sys
@@ -521,8 +565,10 @@ class TestPython:
             ), "Found unexpected content: system-err"
 
     @parametrize_families
-    def test_failure_verbose_message(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_failure_verbose_message(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import sys
             def test_fail():
@@ -536,8 +582,10 @@ class TestPython:
         fnode.assert_attr(message="AssertionError: An error\nassert 0")
 
     @parametrize_families
-    def test_failure_escape(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_failure_escape(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.parametrize('arg1', "<&'", ids="<&'")
@@ -554,7 +602,6 @@ class TestPython:
         node.assert_attr(failures=3, tests=3)
 
         for index, char in enumerate("<&'"):
-
             tnode = node.find_nth_by_tag("testcase", index)
             tnode.assert_attr(
                 classname="test_failure_escape", name="test_func[%s]" % char
@@ -564,8 +611,10 @@ class TestPython:
             assert "%s\n" % char in text
 
     @parametrize_families
-    def test_junit_prefixing(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_junit_prefixing(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             def test_func():
                 assert 0
@@ -586,8 +635,10 @@ class TestPython:
         )
 
     @parametrize_families
-    def test_xfailure_function(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_xfailure_function(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             def test_xfail():
@@ -604,8 +655,10 @@ class TestPython:
         fnode.assert_attr(type="pytest.xfail", message="42")
 
     @parametrize_families
-    def test_xfailure_marker(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_xfailure_marker(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.xfail(reason="42")
@@ -625,8 +678,10 @@ class TestPython:
     @pytest.mark.parametrize(
         "junit_logging", ["no", "log", "system-out", "system-err", "out-err", "all"]
     )
-    def test_xfail_captures_output_once(self, testdir, junit_logging, run_and_parse):
-        testdir.makepyfile(
+    def test_xfail_captures_output_once(
+        self, pytester: Pytester, junit_logging: str, run_and_parse: RunAndParse
+    ) -> None:
+        pytester.makepyfile(
             """
             import sys
             import pytest
@@ -652,8 +707,10 @@ class TestPython:
             assert len(tnode.find_by_tag("system-out")) == 0
 
     @parametrize_families
-    def test_xfailure_xpass(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_xfailure_xpass(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.xfail
@@ -669,8 +726,10 @@ class TestPython:
         tnode.assert_attr(classname="test_xfailure_xpass", name="test_xpass")
 
     @parametrize_families
-    def test_xfailure_xpass_strict(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile(
+    def test_xfailure_xpass_strict(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
             @pytest.mark.xfail(strict=True, reason="This needs to fail!")
@@ -688,8 +747,10 @@ class TestPython:
         fnode.assert_attr(message="[XPASS(strict)] This needs to fail!")
 
     @parametrize_families
-    def test_collect_error(self, testdir, run_and_parse, xunit_family):
-        testdir.makepyfile("syntax error")
+    def test_collect_error(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makepyfile("syntax error")
         result, dom = run_and_parse(family=xunit_family)
         assert result.ret
         node = dom.find_first_by_tag("testsuite")
@@ -699,9 +760,9 @@ class TestPython:
         fnode.assert_attr(message="collection failure")
         assert "SyntaxError" in fnode.toxml()
 
-    def test_unicode(self, testdir, run_and_parse):
+    def test_unicode(self, pytester: Pytester, run_and_parse: RunAndParse) -> None:
         value = "hx\xc4\x85\xc4\x87\n"
-        testdir.makepyfile(
+        pytester.makepyfile(
             """\
             # coding: latin1
             def test_hello():
@@ -716,9 +777,11 @@ class TestPython:
         fnode = tnode.find_first_by_tag("failure")
         assert "hx" in fnode.toxml()
 
-    def test_assertion_binchars(self, testdir, run_and_parse):
+    def test_assertion_binchars(
+        self, pytester: Pytester, run_and_parse: RunAndParse
+    ) -> None:
         """This test did fail when the escaping wasn't strict."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
 
             M1 = '\x01\x02\x03\x04'
@@ -732,8 +795,10 @@ class TestPython:
         print(dom.toxml())
 
     @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
-    def test_pass_captures_stdout(self, testdir, run_and_parse, junit_logging):
-        testdir.makepyfile(
+    def test_pass_captures_stdout(
+        self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
+    ) -> None:
+        pytester.makepyfile(
             """
             def test_pass():
                 print('hello-stdout')
@@ -753,8 +818,10 @@ class TestPython:
             ), "'hello-stdout' should be in system-out"
 
     @pytest.mark.parametrize("junit_logging", ["no", "system-err"])
-    def test_pass_captures_stderr(self, testdir, run_and_parse, junit_logging):
-        testdir.makepyfile(
+    def test_pass_captures_stderr(
+        self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import sys
             def test_pass():
@@ -775,8 +842,10 @@ class TestPython:
             ), "'hello-stderr' should be in system-err"
 
     @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
-    def test_setup_error_captures_stdout(self, testdir, run_and_parse, junit_logging):
-        testdir.makepyfile(
+    def test_setup_error_captures_stdout(
+        self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import pytest
 
@@ -802,8 +871,10 @@ class TestPython:
             ), "'hello-stdout' should be in system-out"
 
     @pytest.mark.parametrize("junit_logging", ["no", "system-err"])
-    def test_setup_error_captures_stderr(self, testdir, run_and_parse, junit_logging):
-        testdir.makepyfile(
+    def test_setup_error_captures_stderr(
+        self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import sys
             import pytest
@@ -830,8 +901,10 @@ class TestPython:
             ), "'hello-stderr' should be in system-err"
 
     @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
-    def test_avoid_double_stdout(self, testdir, run_and_parse, junit_logging):
-        testdir.makepyfile(
+    def test_avoid_double_stdout(
+        self, pytester: Pytester, run_and_parse: RunAndParse, junit_logging: str
+    ) -> None:
+        pytester.makepyfile(
             """
             import sys
             import pytest
@@ -858,15 +931,15 @@ class TestPython:
             assert "hello-stdout teardown" in systemout.toxml()
 
 
-def test_mangle_test_address():
+def test_mangle_test_address() -> None:
     from _pytest.junitxml import mangle_test_address
 
-    address = "::".join(["a/my.py.thing.py", "Class", "()", "method", "[a-1-::]"])
+    address = "::".join(["a/my.py.thing.py", "Class", "method", "[a-1-::]"])
     newnames = mangle_test_address(address)
     assert newnames == ["a.my.py.thing", "Class", "method", "[a-1-::]"]
 
 
-def test_dont_configure_on_workers(tmpdir) -> None:
+def test_dont_configure_on_workers(tmp_path: Path) -> None:
     gotten: List[object] = []
 
     class FakeConfig:
@@ -876,14 +949,14 @@ def test_dont_configure_on_workers(tmpdir) -> None:
         def __init__(self):
             self.pluginmanager = self
             self.option = self
-            self._store = Store()
+            self.stash = Stash()
 
         def getini(self, name):
             return "pytest"
 
         junitprefix = None
-        # XXX: shouldn't need tmpdir ?
-        xmlpath = str(tmpdir.join("junix.xml"))
+        # XXX: shouldn't need tmp_path ?
+        xmlpath = str(tmp_path.joinpath("junix.xml"))
         register = gotten.append
 
     fake_config = cast(Config, FakeConfig())
@@ -898,13 +971,15 @@ def test_dont_configure_on_workers(tmpdir) -> None:
 
 class TestNonPython:
     @parametrize_families
-    def test_summing_simple(self, testdir, run_and_parse, xunit_family):
-        testdir.makeconftest(
+    def test_summing_simple(
+        self, pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+    ) -> None:
+        pytester.makeconftest(
             """
             import pytest
-            def pytest_collect_file(path, parent):
-                if path.ext == ".xyz":
-                    return MyItem.from_parent(name=path.basename, parent=parent)
+            def pytest_collect_file(file_path, parent):
+                if file_path.suffix == ".xyz":
+                    return MyItem.from_parent(name=file_path.name, parent=parent)
             class MyItem(pytest.Item):
                 def runtest(self):
                     raise ValueError(42)
@@ -912,7 +987,7 @@ class TestNonPython:
                     return "custom item runtest failed"
         """
         )
-        testdir.tmpdir.join("myfile.xyz").write("hello")
+        pytester.path.joinpath("myfile.xyz").write_text("hello", encoding="utf-8")
         result, dom = run_and_parse(family=xunit_family)
         assert result.ret
         node = dom.find_first_by_tag("testsuite")
@@ -925,9 +1000,9 @@ class TestNonPython:
 
 
 @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
-def test_nullbyte(testdir, junit_logging):
+def test_nullbyte(pytester: Pytester, junit_logging: str) -> None:
     # A null byte can not occur in XML (see section 2.2 of the spec)
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import sys
         def test_print_nullbyte():
@@ -936,9 +1011,9 @@ def test_nullbyte(testdir, junit_logging):
             assert False
     """
     )
-    xmlf = testdir.tmpdir.join("junit.xml")
-    testdir.runpytest("--junitxml=%s" % xmlf, "-o", "junit_logging=%s" % junit_logging)
-    text = xmlf.read()
+    xmlf = pytester.path.joinpath("junit.xml")
+    pytester.runpytest("--junitxml=%s" % xmlf, "-o", "junit_logging=%s" % junit_logging)
+    text = xmlf.read_text(encoding="utf-8")
     assert "\x00" not in text
     if junit_logging == "system-out":
         assert "#x00" in text
@@ -947,9 +1022,9 @@ def test_nullbyte(testdir, junit_logging):
 
 
 @pytest.mark.parametrize("junit_logging", ["no", "system-out"])
-def test_nullbyte_replace(testdir, junit_logging):
+def test_nullbyte_replace(pytester: Pytester, junit_logging: str) -> None:
     # Check if the null byte gets replaced
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import sys
         def test_print_nullbyte():
@@ -958,16 +1033,16 @@ def test_nullbyte_replace(testdir, junit_logging):
             assert False
     """
     )
-    xmlf = testdir.tmpdir.join("junit.xml")
-    testdir.runpytest("--junitxml=%s" % xmlf, "-o", "junit_logging=%s" % junit_logging)
-    text = xmlf.read()
+    xmlf = pytester.path.joinpath("junit.xml")
+    pytester.runpytest("--junitxml=%s" % xmlf, "-o", "junit_logging=%s" % junit_logging)
+    text = xmlf.read_text(encoding="utf-8")
     if junit_logging == "system-out":
         assert "#x0" in text
     if junit_logging == "no":
         assert "#x0" not in text
 
 
-def test_invalid_xml_escape():
+def test_invalid_xml_escape() -> None:
     # Test some more invalid xml chars, the full range should be
     # tested really but let's just test the edges of the ranges
     # instead.
@@ -1003,52 +1078,54 @@ def test_invalid_xml_escape():
         assert chr(i) == bin_xml_escape(chr(i))
 
 
-def test_logxml_path_expansion(tmpdir, monkeypatch):
-    home_tilde = py.path.local(os.path.expanduser("~")).join("test.xml")
-    xml_tilde = LogXML("~%stest.xml" % tmpdir.sep, None)
-    assert xml_tilde.logfile == home_tilde
+def test_logxml_path_expansion(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
+    home_tilde = Path(os.path.expanduser("~")).joinpath("test.xml")
+    xml_tilde = LogXML(Path("~", "test.xml"), None)
+    assert xml_tilde.logfile == str(home_tilde)
 
-    monkeypatch.setenv("HOME", str(tmpdir))
+    monkeypatch.setenv("HOME", str(tmp_path))
     home_var = os.path.normpath(os.path.expandvars("$HOME/test.xml"))
-    xml_var = LogXML("$HOME%stest.xml" % tmpdir.sep, None)
-    assert xml_var.logfile == home_var
+    xml_var = LogXML(Path("$HOME", "test.xml"), None)
+    assert xml_var.logfile == str(home_var)
 
 
-def test_logxml_changingdir(testdir):
-    testdir.makepyfile(
+def test_logxml_changingdir(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         def test_func():
             import os
             os.chdir("a")
     """
     )
-    testdir.tmpdir.mkdir("a")
-    result = testdir.runpytest("--junitxml=a/x.xml")
+    pytester.mkdir("a")
+    result = pytester.runpytest("--junitxml=a/x.xml")
     assert result.ret == 0
-    assert testdir.tmpdir.join("a/x.xml").check()
+    assert pytester.path.joinpath("a/x.xml").exists()
 
 
-def test_logxml_makedir(testdir):
+def test_logxml_makedir(pytester: Pytester) -> None:
     """--junitxml should automatically create directories for the xml file"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         def test_pass():
             pass
     """
     )
-    result = testdir.runpytest("--junitxml=path/to/results.xml")
+    result = pytester.runpytest("--junitxml=path/to/results.xml")
     assert result.ret == 0
-    assert testdir.tmpdir.join("path/to/results.xml").check()
+    assert pytester.path.joinpath("path/to/results.xml").exists()
 
 
-def test_logxml_check_isdir(testdir):
+def test_logxml_check_isdir(pytester: Pytester) -> None:
     """Give an error if --junit-xml is a directory (#2089)"""
-    result = testdir.runpytest("--junit-xml=.")
+    result = pytester.runpytest("--junit-xml=.")
     result.stderr.fnmatch_lines(["*--junitxml must be a filename*"])
 
 
-def test_escaped_parametrized_names_xml(testdir, run_and_parse):
-    testdir.makepyfile(
+def test_escaped_parametrized_names_xml(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
         """\
         import pytest
         @pytest.mark.parametrize('char', ["\\x00"])
@@ -1062,8 +1139,10 @@ def test_escaped_parametrized_names_xml(testdir, run_and_parse):
     node.assert_attr(name="test_func[\\x00]")
 
 
-def test_double_colon_split_function_issue469(testdir, run_and_parse):
-    testdir.makepyfile(
+def test_double_colon_split_function_issue469(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
         """
         import pytest
         @pytest.mark.parametrize('param', ["double::colon"])
@@ -1078,8 +1157,10 @@ def test_double_colon_split_function_issue469(testdir, run_and_parse):
     node.assert_attr(name="test_func[double::colon]")
 
 
-def test_double_colon_split_method_issue469(testdir, run_and_parse):
-    testdir.makepyfile(
+def test_double_colon_split_method_issue469(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
         """
         import pytest
         class TestClass(object):
@@ -1095,8 +1176,8 @@ def test_double_colon_split_method_issue469(testdir, run_and_parse):
     node.assert_attr(name="test_func[double::colon]")
 
 
-def test_unicode_issue368(testdir) -> None:
-    path = testdir.tmpdir.join("test.xml")
+def test_unicode_issue368(pytester: Pytester) -> None:
+    path = pytester.path.joinpath("test.xml")
     log = LogXML(str(path), None)
     ustr = "ВНИ!"
 
@@ -1125,8 +1206,8 @@ def test_unicode_issue368(testdir) -> None:
     log.pytest_sessionfinish()
 
 
-def test_record_property(testdir, run_and_parse):
-    testdir.makepyfile(
+def test_record_property(pytester: Pytester, run_and_parse: RunAndParse) -> None:
+    pytester.makepyfile(
         """
         import pytest
 
@@ -1147,8 +1228,40 @@ def test_record_property(testdir, run_and_parse):
     result.stdout.fnmatch_lines(["*= 1 passed in *"])
 
 
-def test_record_property_same_name(testdir, run_and_parse):
-    testdir.makepyfile(
+def test_record_property_on_test_and_teardown_failure(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
+        """
+        import pytest
+
+        @pytest.fixture
+        def other(record_property):
+            record_property("bar", 1)
+            yield
+            assert 0
+
+        def test_record(record_property, other):
+            record_property("foo", "<1")
+            assert 0
+    """
+    )
+    result, dom = run_and_parse()
+    node = dom.find_first_by_tag("testsuite")
+    tnodes = node.find_by_tag("testcase")
+    for tnode in tnodes:
+        psnode = tnode.find_first_by_tag("properties")
+        assert psnode, f"testcase didn't had expected properties:\n{tnode}"
+        pnodes = psnode.find_by_tag("property")
+        pnodes[0].assert_attr(name="bar", value="1")
+        pnodes[1].assert_attr(name="foo", value="<1")
+    result.stdout.fnmatch_lines(["*= 1 failed, 1 error *"])
+
+
+def test_record_property_same_name(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
         """
         def test_record_with_same_name(record_property):
             record_property("foo", "bar")
@@ -1165,8 +1278,10 @@ def test_record_property_same_name(testdir, run_and_parse):
 
 
 @pytest.mark.parametrize("fixture_name", ["record_property", "record_xml_attribute"])
-def test_record_fixtures_without_junitxml(testdir, fixture_name):
-    testdir.makepyfile(
+def test_record_fixtures_without_junitxml(
+    pytester: Pytester, fixture_name: str
+) -> None:
+    pytester.makepyfile(
         """
         def test_record({fixture_name}):
             {fixture_name}("foo", "bar")
@@ -1174,19 +1289,19 @@ def test_record_fixtures_without_junitxml(testdir, fixture_name):
             fixture_name=fixture_name
         )
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 0
 
 
 @pytest.mark.filterwarnings("default")
-def test_record_attribute(testdir, run_and_parse):
-    testdir.makeini(
+def test_record_attribute(pytester: Pytester, run_and_parse: RunAndParse) -> None:
+    pytester.makeini(
         """
         [pytest]
         junit_family = xunit1
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
 
@@ -1209,15 +1324,17 @@ def test_record_attribute(testdir, run_and_parse):
 
 @pytest.mark.filterwarnings("default")
 @pytest.mark.parametrize("fixture_name", ["record_xml_attribute", "record_property"])
-def test_record_fixtures_xunit2(testdir, fixture_name, run_and_parse):
+def test_record_fixtures_xunit2(
+    pytester: Pytester, fixture_name: str, run_and_parse: RunAndParse
+) -> None:
     """Ensure record_xml_attribute and record_property drop values when outside of legacy family."""
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         junit_family = xunit2
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
 
@@ -1246,13 +1363,15 @@ def test_record_fixtures_xunit2(testdir, fixture_name, run_and_parse):
     result.stdout.fnmatch_lines(expected_lines)
 
 
-def test_random_report_log_xdist(testdir, monkeypatch, run_and_parse):
+def test_random_report_log_xdist(
+    pytester: Pytester, monkeypatch: MonkeyPatch, run_and_parse: RunAndParse
+) -> None:
     """`xdist` calls pytest_runtest_logreport as they are executed by the workers,
     with nodes from several nodes overlapping, so junitxml must cope with that
     to produce correct reports (#1064)."""
     pytest.importorskip("xdist")
     monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest, time
         @pytest.mark.parametrize('i', list(range(30)))
@@ -1271,8 +1390,10 @@ def test_random_report_log_xdist(testdir, monkeypatch, run_and_parse):
 
 
 @parametrize_families
-def test_root_testsuites_tag(testdir, run_and_parse, xunit_family):
-    testdir.makepyfile(
+def test_root_testsuites_tag(
+    pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+) -> None:
+    pytester.makepyfile(
         """
         def test_x():
             pass
@@ -1285,8 +1406,8 @@ def test_root_testsuites_tag(testdir, run_and_parse, xunit_family):
     assert suite_node.tag == "testsuite"
 
 
-def test_runs_twice(testdir, run_and_parse):
-    f = testdir.makepyfile(
+def test_runs_twice(pytester: Pytester, run_and_parse: RunAndParse) -> None:
+    f = pytester.makepyfile(
         """
         def test_pass():
             pass
@@ -1295,14 +1416,16 @@ def test_runs_twice(testdir, run_and_parse):
 
     result, dom = run_and_parse(f, f)
     result.stdout.no_fnmatch_line("*INTERNALERROR*")
-    first, second = [x["classname"] for x in dom.find_by_tag("testcase")]
+    first, second = (x["classname"] for x in dom.find_by_tag("testcase"))
     assert first == second
 
 
-def test_runs_twice_xdist(testdir, run_and_parse):
+def test_runs_twice_xdist(
+    pytester: Pytester, monkeypatch: MonkeyPatch, run_and_parse: RunAndParse
+) -> None:
     pytest.importorskip("xdist")
-    testdir.monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
-    f = testdir.makepyfile(
+    monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
+    f = pytester.makepyfile(
         """
         def test_pass():
             pass
@@ -1311,13 +1434,13 @@ def test_runs_twice_xdist(testdir, run_and_parse):
 
     result, dom = run_and_parse(f, "--dist", "each", "--tx", "2*popen")
     result.stdout.no_fnmatch_line("*INTERNALERROR*")
-    first, second = [x["classname"] for x in dom.find_by_tag("testcase")]
+    first, second = (x["classname"] for x in dom.find_by_tag("testcase"))
     assert first == second
 
 
-def test_fancy_items_regression(testdir, run_and_parse):
+def test_fancy_items_regression(pytester: Pytester, run_and_parse: RunAndParse) -> None:
     # issue 1259
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import pytest
         class FunItem(pytest.Item):
@@ -1335,13 +1458,13 @@ def test_fancy_items_regression(testdir, run_and_parse):
                     NoFunItem.from_parent(name='b', parent=self),
                 ]
 
-        def pytest_collect_file(path, parent):
-            if path.check(ext='.py'):
-                return FunCollector.from_parent(fspath=path, parent=parent)
+        def pytest_collect_file(file_path, parent):
+            if file_path.suffix == '.py':
+                return FunCollector.from_parent(path=file_path, parent=parent)
     """
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         def test_pass():
             pass
@@ -1368,8 +1491,8 @@ def test_fancy_items_regression(testdir, run_and_parse):
 
 
 @parametrize_families
-def test_global_properties(testdir, xunit_family) -> None:
-    path = testdir.tmpdir.join("test_global_properties.xml")
+def test_global_properties(pytester: Pytester, xunit_family: str) -> None:
+    path = pytester.path.joinpath("test_global_properties.xml")
     log = LogXML(str(path), None, family=xunit_family)
 
     class Report(BaseReport):
@@ -1402,9 +1525,9 @@ def test_global_properties(testdir, xunit_family) -> None:
     assert actual == expected
 
 
-def test_url_property(testdir) -> None:
+def test_url_property(pytester: Pytester) -> None:
     test_url = "http://www.github.com/pytest-dev"
-    path = testdir.tmpdir.join("test_url_property.xml")
+    path = pytester.path.joinpath("test_url_property.xml")
     log = LogXML(str(path), None)
 
     class Report(BaseReport):
@@ -1429,8 +1552,10 @@ def test_url_property(testdir) -> None:
 
 
 @parametrize_families
-def test_record_testsuite_property(testdir, run_and_parse, xunit_family):
-    testdir.makepyfile(
+def test_record_testsuite_property(
+    pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+) -> None:
+    pytester.makepyfile(
         """
         def test_func1(record_testsuite_property):
             record_testsuite_property("stats", "all good")
@@ -1449,27 +1574,29 @@ def test_record_testsuite_property(testdir, run_and_parse, xunit_family):
     p2_node.assert_attr(name="stats", value="10")
 
 
-def test_record_testsuite_property_junit_disabled(testdir):
-    testdir.makepyfile(
+def test_record_testsuite_property_junit_disabled(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         def test_func1(record_testsuite_property):
             record_testsuite_property("stats", "all good")
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 0
 
 
 @pytest.mark.parametrize("junit", [True, False])
-def test_record_testsuite_property_type_checking(testdir, junit):
-    testdir.makepyfile(
+def test_record_testsuite_property_type_checking(
+    pytester: Pytester, junit: bool
+) -> None:
+    pytester.makepyfile(
         """
         def test_func1(record_testsuite_property):
             record_testsuite_property(1, 2)
     """
     )
     args = ("--junitxml=tests.xml",) if junit else ()
-    result = testdir.runpytest(*args)
+    result = pytester.runpytest(*args)
     assert result.ret == 1
     result.stdout.fnmatch_lines(
         ["*TypeError: name parameter needs to be a string, but int given"]
@@ -1478,9 +1605,11 @@ def test_record_testsuite_property_type_checking(testdir, junit):
 
 @pytest.mark.parametrize("suite_name", ["my_suite", ""])
 @parametrize_families
-def test_set_suite_name(testdir, suite_name, run_and_parse, xunit_family):
+def test_set_suite_name(
+    pytester: Pytester, suite_name: str, run_and_parse: RunAndParse, xunit_family: str
+) -> None:
     if suite_name:
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             junit_suite_name={suite_name}
@@ -1492,7 +1621,7 @@ def test_set_suite_name(testdir, suite_name, run_and_parse, xunit_family):
         expected = suite_name
     else:
         expected = "pytest"
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
 
@@ -1506,8 +1635,10 @@ def test_set_suite_name(testdir, suite_name, run_and_parse, xunit_family):
     node.assert_attr(name=expected)
 
 
-def test_escaped_skipreason_issue3533(testdir, run_and_parse):
-    testdir.makepyfile(
+def test_escaped_skipreason_issue3533(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
         """
         import pytest
         @pytest.mark.skip(reason='1 <> 2')
@@ -1522,11 +1653,33 @@ def test_escaped_skipreason_issue3533(testdir, run_and_parse):
     snode.assert_attr(message="1 <> 2")
 
 
+def test_escaped_setup_teardown_error(
+    pytester: Pytester, run_and_parse: RunAndParse
+) -> None:
+    pytester.makepyfile(
+        """
+        import pytest
+
+        @pytest.fixture()
+        def my_setup():
+            raise Exception("error: \033[31mred\033[m")
+
+        def test_esc(my_setup):
+            pass
+    """
+    )
+    _, dom = run_and_parse()
+    node = dom.find_first_by_tag("testcase")
+    snode = node.find_first_by_tag("error")
+    assert "#x1B[31mred#x1B[m" in snode["message"]
+    assert "#x1B[31mred#x1B[m" in snode.text
+
+
 @parametrize_families
 def test_logging_passing_tests_disabled_does_not_log_test_output(
-    testdir, run_and_parse, xunit_family
-):
-    testdir.makeini(
+    pytester: Pytester, run_and_parse: RunAndParse, xunit_family: str
+) -> None:
+    pytester.makeini(
         """
         [pytest]
         junit_log_passing_tests=False
@@ -1536,7 +1689,7 @@ def test_logging_passing_tests_disabled_does_not_log_test_output(
             family=xunit_family
         )
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
@@ -1558,9 +1711,12 @@ def test_logging_passing_tests_disabled_does_not_log_test_output(
 @parametrize_families
 @pytest.mark.parametrize("junit_logging", ["no", "system-out", "system-err"])
 def test_logging_passing_tests_disabled_logs_output_for_failing_test_issue5430(
-    testdir, junit_logging, run_and_parse, xunit_family
-):
-    testdir.makeini(
+    pytester: Pytester,
+    junit_logging: str,
+    run_and_parse: RunAndParse,
+    xunit_family: str,
+) -> None:
+    pytester.makeini(
         """
         [pytest]
         junit_log_passing_tests=False
@@ -1569,7 +1725,7 @@ def test_logging_passing_tests_disabled_logs_output_for_failing_test_issue5430(
             family=xunit_family
         )
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import logging
diff --git a/testing/test_legacypath.py b/testing/test_legacypath.py
new file mode 100644 (file)
index 0000000..fbfd88b
--- /dev/null
@@ -0,0 +1,180 @@
+from pathlib import Path
+
+import pytest
+from _pytest.compat import LEGACY_PATH
+from _pytest.legacypath import TempdirFactory
+from _pytest.legacypath import Testdir
+
+
+def test_item_fspath(pytester: pytest.Pytester) -> None:
+    pytester.makepyfile("def test_func(): pass")
+    items, hookrec = pytester.inline_genitems()
+    assert len(items) == 1
+    (item,) = items
+    items2, hookrec = pytester.inline_genitems(item.nodeid)
+    (item2,) = items2
+    assert item2.name == item.name
+    assert item2.fspath == item.fspath
+    assert item2.path == item.path
+
+
+def test_testdir_testtmproot(testdir: Testdir) -> None:
+    """Check test_tmproot is a py.path attribute for backward compatibility."""
+    assert testdir.test_tmproot.check(dir=1)
+
+
+def test_testdir_makefile_dot_prefixes_extension_silently(
+    testdir: Testdir,
+) -> None:
+    """For backwards compat #8192"""
+    p1 = testdir.makefile("foo.bar", "")
+    assert ".foo.bar" in str(p1)
+
+
+def test_testdir_makefile_ext_none_raises_type_error(testdir: Testdir) -> None:
+    """For backwards compat #8192"""
+    with pytest.raises(TypeError):
+        testdir.makefile(None, "")
+
+
+def test_testdir_makefile_ext_empty_string_makes_file(testdir: Testdir) -> None:
+    """For backwards compat #8192"""
+    p1 = testdir.makefile("", "")
+    assert "test_testdir_makefile" in str(p1)
+
+
+def attempt_symlink_to(path: str, to_path: str) -> None:
+    """Try to make a symlink from "path" to "to_path", skipping in case this platform
+    does not support it or we don't have sufficient privileges (common on Windows)."""
+    try:
+        Path(path).symlink_to(Path(to_path))
+    except OSError:
+        pytest.skip("could not create symbolic link")
+
+
+def test_tmpdir_factory(
+    tmpdir_factory: TempdirFactory,
+    tmp_path_factory: pytest.TempPathFactory,
+) -> None:
+    assert str(tmpdir_factory.getbasetemp()) == str(tmp_path_factory.getbasetemp())
+    dir = tmpdir_factory.mktemp("foo")
+    assert dir.exists()
+
+
+def test_tmpdir_equals_tmp_path(tmpdir: LEGACY_PATH, tmp_path: Path) -> None:
+    assert Path(tmpdir) == tmp_path
+
+
+def test_tmpdir_always_is_realpath(pytester: pytest.Pytester) -> None:
+    # See test_tmp_path_always_is_realpath.
+    realtemp = pytester.mkdir("myrealtemp")
+    linktemp = pytester.path.joinpath("symlinktemp")
+    attempt_symlink_to(str(linktemp), str(realtemp))
+    p = pytester.makepyfile(
+        """
+        def test_1(tmpdir):
+            import os
+            assert os.path.realpath(str(tmpdir)) == str(tmpdir)
+    """
+    )
+    result = pytester.runpytest("-s", p, "--basetemp=%s/bt" % linktemp)
+    assert not result.ret
+
+
+def test_cache_makedir(cache: pytest.Cache) -> None:
+    dir = cache.makedir("foo")  # type: ignore[attr-defined]
+    assert dir.exists()
+    dir.remove()
+
+
+def test_fixturerequest_getmodulepath(pytester: pytest.Pytester) -> None:
+    modcol = pytester.getmodulecol("def test_somefunc(): pass")
+    (item,) = pytester.genitems([modcol])
+    req = pytest.FixtureRequest(item, _ispytest=True)
+    assert req.path == modcol.path
+    assert req.fspath == modcol.fspath  # type: ignore[attr-defined]
+
+
+class TestFixtureRequestSessionScoped:
+    @pytest.fixture(scope="session")
+    def session_request(self, request):
+        return request
+
+    def test_session_scoped_unavailable_attributes(self, session_request):
+        with pytest.raises(
+            AttributeError,
+            match="path not available in session-scoped context",
+        ):
+            session_request.fspath
+
+
+@pytest.mark.parametrize("config_type", ["ini", "pyproject"])
+def test_addini_paths(pytester: pytest.Pytester, config_type: str) -> None:
+    pytester.makeconftest(
+        """
+        def pytest_addoption(parser):
+            parser.addini("paths", "my new ini value", type="pathlist")
+            parser.addini("abc", "abc value")
+    """
+    )
+    if config_type == "ini":
+        inipath = pytester.makeini(
+            """
+            [pytest]
+            paths=hello world/sub.py
+        """
+        )
+    elif config_type == "pyproject":
+        inipath = pytester.makepyprojecttoml(
+            """
+            [tool.pytest.ini_options]
+            paths=["hello", "world/sub.py"]
+        """
+        )
+    config = pytester.parseconfig()
+    values = config.getini("paths")
+    assert len(values) == 2
+    assert values[0] == inipath.parent.joinpath("hello")
+    assert values[1] == inipath.parent.joinpath("world/sub.py")
+    pytest.raises(ValueError, config.getini, "other")
+
+
+def test_override_ini_paths(pytester: pytest.Pytester) -> None:
+    pytester.makeconftest(
+        """
+        def pytest_addoption(parser):
+            parser.addini("paths", "my new ini value", type="pathlist")"""
+    )
+    pytester.makeini(
+        """
+        [pytest]
+        paths=blah.py"""
+    )
+    pytester.makepyfile(
+        r"""
+        def test_overriden(pytestconfig):
+            config_paths = pytestconfig.getini("paths")
+            print(config_paths)
+            for cpf in config_paths:
+                print('\nuser_path:%s' % cpf.basename)
+        """
+    )
+    result = pytester.runpytest("--override-ini", "paths=foo/bar1.py foo/bar2.py", "-s")
+    result.stdout.fnmatch_lines(["user_path:bar1.py", "user_path:bar2.py"])
+
+
+def test_inifile_from_cmdline_main_hook(pytester: pytest.Pytester) -> None:
+    """Ensure Config.inifile is available during pytest_cmdline_main (#9396)."""
+    p = pytester.makeini(
+        """
+        [pytest]
+        """
+    )
+    pytester.makeconftest(
+        """
+        def pytest_cmdline_main(config):
+            print("pytest_cmdline_main inifile =", config.inifile)
+        """
+    )
+    result = pytester.runpytest_subprocess("-s")
+    result.stdout.fnmatch_lines(f"*pytest_cmdline_main inifile = {p}")
index 7eaf41247960a7e20ca8373136168390505db36c..1ac3afd09e897de1e514feb2140ee6c5fd1e8ba0 100644 (file)
@@ -3,15 +3,14 @@ import subprocess
 import sys
 import textwrap
 from contextlib import contextmanager
+from pathlib import Path
 from string import ascii_lowercase
 
-import py.path
-
-from _pytest import pytester
+from _pytest.pytester import Pytester
 
 
 @contextmanager
-def subst_path_windows(filename):
+def subst_path_windows(filepath: Path):
     for c in ascii_lowercase[7:]:  # Create a subst drive from H-Z.
         c += ":"
         if not os.path.exists(c):
@@ -20,14 +19,14 @@ def subst_path_windows(filename):
     else:
         raise AssertionError("Unable to find suitable drive letter for subst.")
 
-    directory = filename.dirpath()
-    basename = filename.basename
+    directory = filepath.parent
+    basename = filepath.name
 
     args = ["subst", drive, str(directory)]
     subprocess.check_call(args)
     assert os.path.exists(drive)
     try:
-        filename = py.path.local(drive) / basename
+        filename = Path(drive, os.sep, basename)
         yield filename
     finally:
         args = ["subst", "/D", drive]
@@ -35,9 +34,9 @@ def subst_path_windows(filename):
 
 
 @contextmanager
-def subst_path_linux(filename):
-    directory = filename.dirpath()
-    basename = filename.basename
+def subst_path_linux(filepath: Path):
+    directory = filepath.parent
+    basename = filepath.name
 
     target = directory / ".." / "sub2"
     os.symlink(str(directory), str(target), target_is_directory=True)
@@ -49,18 +48,19 @@ def subst_path_linux(filename):
         pass
 
 
-def test_link_resolve(testdir: pytester.Testdir) -> None:
+def test_link_resolve(pytester: Pytester) -> None:
     """See: https://github.com/pytest-dev/pytest/issues/5965."""
-    sub1 = testdir.mkpydir("sub1")
-    p = sub1.join("test_foo.py")
-    p.write(
+    sub1 = pytester.mkpydir("sub1")
+    p = sub1.joinpath("test_foo.py")
+    p.write_text(
         textwrap.dedent(
             """
         import pytest
         def test_foo():
             raise AssertionError()
         """
-        )
+        ),
+        encoding="utf-8",
     )
 
     subst = subst_path_linux
@@ -68,7 +68,7 @@ def test_link_resolve(testdir: pytester.Testdir) -> None:
         subst = subst_path_windows
 
     with subst(p) as subst_p:
-        result = testdir.runpytest(str(subst_p), "-v")
+        result = pytester.runpytest(str(subst_p), "-v")
         # i.e.: Make sure that the error is reported as a relative path, not as a
         # resolved path.
         # See: https://github.com/pytest-dev/pytest/issues/5965
index 3e94668e82f3b7d5dcde6cce46812ef9eb86064e..3c8998c1a353834ba4ec8e5a9e35a20dbadb33cb 100644 (file)
@@ -1,17 +1,16 @@
 import argparse
 import os
 import re
+import sys
 from pathlib import Path
 from typing import Optional
 
-import py.path
-
 import pytest
 from _pytest.config import ExitCode
 from _pytest.config import UsageError
 from _pytest.main import resolve_collection_argument
 from _pytest.main import validate_basetemp
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
 
 
 @pytest.mark.parametrize(
@@ -22,9 +21,9 @@ from _pytest.pytester import Testdir
         pytest.param((False, SystemExit)),
     ),
 )
-def test_wrap_session_notify_exception(ret_exc, testdir):
+def test_wrap_session_notify_exception(ret_exc, pytester: Pytester) -> None:
     returncode, exc = ret_exc
-    c1 = testdir.makeconftest(
+    c1 = pytester.makeconftest(
         """
         import pytest
 
@@ -39,23 +38,39 @@ def test_wrap_session_notify_exception(ret_exc, testdir):
             returncode=returncode, exc=exc.__name__
         )
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     if returncode:
         assert result.ret == returncode
     else:
         assert result.ret == ExitCode.INTERNAL_ERROR
     assert result.stdout.lines[0] == "INTERNALERROR> Traceback (most recent call last):"
 
+    end_lines = (
+        result.stdout.lines[-4:]
+        if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
+        else result.stdout.lines[-3:]
+    )
+
     if exc == SystemExit:
-        assert result.stdout.lines[-3:] == [
+        assert end_lines == [
             f'INTERNALERROR>   File "{c1}", line 4, in pytest_sessionstart',
             'INTERNALERROR>     raise SystemExit("boom")',
+            *(
+                ("INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^",)
+                if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
+                else ()
+            ),
             "INTERNALERROR> SystemExit: boom",
         ]
     else:
-        assert result.stdout.lines[-3:] == [
+        assert end_lines == [
             f'INTERNALERROR>   File "{c1}", line 4, in pytest_sessionstart',
             'INTERNALERROR>     raise ValueError("boom")',
+            *(
+                ("INTERNALERROR>     ^^^^^^^^^^^^^^^^^^^^^^^^",)
+                if (3, 11, 0, "beta", 4) > sys.version_info >= (3, 11)
+                else ()
+            ),
             "INTERNALERROR> ValueError: boom",
         ]
     if returncode is False:
@@ -66,18 +81,18 @@ def test_wrap_session_notify_exception(ret_exc, testdir):
 
 @pytest.mark.parametrize("returncode", (None, 42))
 def test_wrap_session_exit_sessionfinish(
-    returncode: Optional[int], testdir: Testdir
+    returncode: Optional[int], pytester: Pytester
 ) -> None:
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         import pytest
         def pytest_sessionfinish():
-            pytest.exit(msg="exit_pytest_sessionfinish", returncode={returncode})
+            pytest.exit(reason="exit_pytest_sessionfinish", returncode={returncode})
     """.format(
             returncode=returncode
         )
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     if returncode:
         assert result.ret == returncode
     else:
@@ -102,47 +117,44 @@ def test_validate_basetemp_fails(tmp_path, basetemp, monkeypatch):
         validate_basetemp(basetemp)
 
 
-def test_validate_basetemp_integration(testdir):
-    result = testdir.runpytest("--basetemp=.")
+def test_validate_basetemp_integration(pytester: Pytester) -> None:
+    result = pytester.runpytest("--basetemp=.")
     result.stderr.fnmatch_lines("*basetemp must not be*")
 
 
 class TestResolveCollectionArgument:
     @pytest.fixture
-    def invocation_dir(self, testdir: Testdir) -> py.path.local:
-        testdir.syspathinsert(str(testdir.tmpdir / "src"))
-        testdir.chdir()
-
-        pkg = testdir.tmpdir.join("src/pkg").ensure_dir()
-        pkg.join("__init__.py").ensure()
-        pkg.join("test.py").ensure()
-        return testdir.tmpdir
+    def invocation_path(self, pytester: Pytester) -> Path:
+        pytester.syspathinsert(pytester.path / "src")
+        pytester.chdir()
 
-    @pytest.fixture
-    def invocation_path(self, invocation_dir: py.path.local) -> Path:
-        return Path(str(invocation_dir))
+        pkg = pytester.path.joinpath("src/pkg")
+        pkg.mkdir(parents=True)
+        pkg.joinpath("__init__.py").touch()
+        pkg.joinpath("test.py").touch()
+        return pytester.path
 
-    def test_file(self, invocation_dir: py.path.local, invocation_path: Path) -> None:
+    def test_file(self, invocation_path: Path) -> None:
         """File and parts."""
         assert resolve_collection_argument(invocation_path, "src/pkg/test.py") == (
-            invocation_dir / "src/pkg/test.py",
+            invocation_path / "src/pkg/test.py",
             [],
         )
         assert resolve_collection_argument(invocation_path, "src/pkg/test.py::") == (
-            invocation_dir / "src/pkg/test.py",
+            invocation_path / "src/pkg/test.py",
             [""],
         )
         assert resolve_collection_argument(
             invocation_path, "src/pkg/test.py::foo::bar"
-        ) == (invocation_dir / "src/pkg/test.py", ["foo", "bar"])
+        ) == (invocation_path / "src/pkg/test.py", ["foo", "bar"])
         assert resolve_collection_argument(
             invocation_path, "src/pkg/test.py::foo::bar::"
-        ) == (invocation_dir / "src/pkg/test.py", ["foo", "bar", ""])
+        ) == (invocation_path / "src/pkg/test.py", ["foo", "bar", ""])
 
-    def test_dir(self, invocation_dir: py.path.local, invocation_path: Path) -> None:
+    def test_dir(self, invocation_path: Path) -> None:
         """Directory and parts."""
         assert resolve_collection_argument(invocation_path, "src/pkg") == (
-            invocation_dir / "src/pkg",
+            invocation_path / "src/pkg",
             [],
         )
 
@@ -156,16 +168,16 @@ class TestResolveCollectionArgument:
         ):
             resolve_collection_argument(invocation_path, "src/pkg::foo::bar")
 
-    def test_pypath(self, invocation_dir: py.path.local, invocation_path: Path) -> None:
+    def test_pypath(self, invocation_path: Path) -> None:
         """Dotted name and parts."""
         assert resolve_collection_argument(
             invocation_path, "pkg.test", as_pypath=True
-        ) == (invocation_dir / "src/pkg/test.py", [])
+        ) == (invocation_path / "src/pkg/test.py", [])
         assert resolve_collection_argument(
             invocation_path, "pkg.test::foo::bar", as_pypath=True
-        ) == (invocation_dir / "src/pkg/test.py", ["foo", "bar"])
+        ) == (invocation_path / "src/pkg/test.py", ["foo", "bar"])
         assert resolve_collection_argument(invocation_path, "pkg", as_pypath=True) == (
-            invocation_dir / "src/pkg",
+            invocation_path / "src/pkg",
             [],
         )
 
@@ -176,6 +188,12 @@ class TestResolveCollectionArgument:
                 invocation_path, "pkg::foo::bar", as_pypath=True
             )
 
+    def test_parametrized_name_with_colons(self, invocation_path: Path) -> None:
+        ret = resolve_collection_argument(
+            invocation_path, "src/pkg/test.py::test[a::b]"
+        )
+        assert ret == (invocation_path / "src/pkg/test.py", ["test[a::b]"])
+
     def test_does_not_exist(self, invocation_path: Path) -> None:
         """Given a file/module that does not exist raises UsageError."""
         with pytest.raises(
@@ -191,13 +209,11 @@ class TestResolveCollectionArgument:
         ):
             resolve_collection_argument(invocation_path, "foobar", as_pypath=True)
 
-    def test_absolute_paths_are_resolved_correctly(
-        self, invocation_dir: py.path.local, invocation_path: Path
-    ) -> None:
+    def test_absolute_paths_are_resolved_correctly(self, invocation_path: Path) -> None:
         """Absolute paths resolve back to absolute paths."""
-        full_path = str(invocation_dir / "src")
+        full_path = str(invocation_path / "src")
         assert resolve_collection_argument(invocation_path, full_path) == (
-            py.path.local(os.path.abspath("src")),
+            Path(os.path.abspath("src")),
             [],
         )
 
@@ -206,17 +222,17 @@ class TestResolveCollectionArgument:
         drive, full_path_without_drive = os.path.splitdrive(full_path)
         assert resolve_collection_argument(
             invocation_path, full_path_without_drive
-        ) == (py.path.local(os.path.abspath("src")), [])
+        ) == (Path(os.path.abspath("src")), [])
 
 
-def test_module_full_path_without_drive(testdir):
+def test_module_full_path_without_drive(pytester: Pytester) -> None:
     """Collect and run test using full path except for the drive letter (#7628).
 
-    Passing a full path without a drive letter would trigger a bug in py.path.local
+    Passing a full path without a drive letter would trigger a bug in legacy_path
     where it would keep the full path without the drive letter around, instead of resolving
     to the full path, resulting in fixtures node ids not matching against test node ids correctly.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         **{
             "project/conftest.py": """
                 import pytest
@@ -226,7 +242,7 @@ def test_module_full_path_without_drive(testdir):
         }
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         **{
             "project/tests/dummy_test.py": """
                 def test(fix):
@@ -234,15 +250,46 @@ def test_module_full_path_without_drive(testdir):
             """
         }
     )
-    fn = testdir.tmpdir.join("project/tests/dummy_test.py")
-    assert fn.isfile()
+    fn = pytester.path.joinpath("project/tests/dummy_test.py")
+    assert fn.is_file()
 
     drive, path = os.path.splitdrive(str(fn))
 
-    result = testdir.runpytest(path, "-v")
+    result = pytester.runpytest(path, "-v")
     result.stdout.fnmatch_lines(
         [
             os.path.join("project", "tests", "dummy_test.py") + "::test PASSED *",
             "* 1 passed in *",
         ]
     )
+
+
+def test_very_long_cmdline_arg(pytester: Pytester) -> None:
+    """
+    Regression test for #11394.
+
+    Note: we could not manage to actually reproduce the error with this code, we suspect
+    GitHub runners are configured to support very long paths, however decided to leave
+    the test in place in case this ever regresses in the future.
+    """
+    pytester.makeconftest(
+        """
+        import pytest
+
+        def pytest_addoption(parser):
+            parser.addoption("--long-list", dest="long_list", action="store", default="all", help="List of things")
+
+        @pytest.fixture(scope="module")
+        def specified_feeds(request):
+            list_string = request.config.getoption("--long-list")
+            return list_string.split(',')
+        """
+    )
+    pytester.makepyfile(
+        """
+        def test_foo(specified_feeds):
+            assert len(specified_feeds) == 100_000
+        """
+    )
+    result = pytester.runpytest("--long-list", ",".join(["helloworld"] * 100_000))
+    result.stdout.fnmatch_lines("* 1 passed *")
index e0b91f0cef4b6e53505d12f2f67ccad20eb63a04..2767260df8cf904aba7ac2732b83ec61b8f918fe 100644 (file)
@@ -15,13 +15,12 @@ from _pytest.pytester import Pytester
 
 class TestMark:
     @pytest.mark.parametrize("attr", ["mark", "param"])
-    @pytest.mark.parametrize("modulename", ["py.test", "pytest"])
-    def test_pytest_exists_in_namespace_all(self, attr: str, modulename: str) -> None:
-        module = sys.modules[modulename]
+    def test_pytest_exists_in_namespace_all(self, attr: str) -> None:
+        module = sys.modules["pytest"]
         assert attr in module.__all__  # type: ignore
 
     def test_pytest_mark_notcallable(self) -> None:
-        mark = MarkGenerator()
+        mark = MarkGenerator(_ispytest=True)
         with pytest.raises(TypeError):
             mark()  # type: ignore[operator]
 
@@ -40,7 +39,7 @@ class TestMark:
         assert pytest.mark.foo.with_args(SomeClass) is not SomeClass  # type: ignore[comparison-overlap]
 
     def test_pytest_mark_name_starts_with_underscore(self) -> None:
-        mark = MarkGenerator()
+        mark = MarkGenerator(_ispytest=True)
         with pytest.raises(AttributeError):
             mark._some_name
 
@@ -356,8 +355,14 @@ def test_parametrize_with_module(pytester: Pytester) -> None:
             "foo or or",
             "at column 8: expected not OR left parenthesis OR identifier; got or",
         ),
-        ("(foo", "at column 5: expected right parenthesis; got end of input",),
-        ("foo bar", "at column 5: expected end of input; got identifier",),
+        (
+            "(foo",
+            "at column 5: expected right parenthesis; got end of input",
+        ),
+        (
+            "foo bar",
+            "at column 5: expected end of input; got identifier",
+        ),
         (
             "or or",
             "at column 1: expected not OR left parenthesis OR identifier; got or",
@@ -818,23 +823,6 @@ class TestKeywordSelection:
         assert len(dlist) == 1
         assert dlist[0].items[0].name == "test_1"
 
-    def test_select_starton(self, pytester: Pytester) -> None:
-        threepass = pytester.makepyfile(
-            test_threepass="""
-            def test_one(): assert 1
-            def test_two(): assert 1
-            def test_three(): assert 1
-        """
-        )
-        reprec = pytester.inline_run("-k", "test_two:", threepass)
-        passed, skipped, failed = reprec.listoutcomes()
-        assert len(passed) == 2
-        assert not failed
-        dlist = reprec.getcalls("pytest_deselected")
-        assert len(dlist) == 1
-        item = dlist[0].items[0]
-        assert item.name == "test_one"
-
     def test_keyword_extra(self, pytester: Pytester) -> None:
         p = pytester.makepyfile(
             """
@@ -863,7 +851,8 @@ class TestKeywordSelection:
         assert passed + skipped + failed == 0
 
     @pytest.mark.parametrize(
-        "keyword", ["__", "+", ".."],
+        "keyword",
+        ["__", "+", ".."],
     )
     def test_no_magic_values(self, pytester: Pytester, keyword: str) -> None:
         """Make sure the tests do not match on magic values,
@@ -1041,11 +1030,12 @@ def test_mark_expressions_no_smear(pytester: Pytester) -> None:
     # assert skipped_k == failed_k == 0
 
 
-def test_addmarker_order() -> None:
+def test_addmarker_order(pytester) -> None:
     session = mock.Mock()
     session.own_markers = []
     session.parent = None
     session.nodeid = ""
+    session.path = pytester.path
     node = Node.from_parent(session, name="Test")
     node.add_marker("foo")
     node.add_marker("bar")
@@ -1104,7 +1094,7 @@ def test_pytest_param_id_allows_none_or_string(s) -> None:
     assert pytest.param(id=s)
 
 
-@pytest.mark.parametrize("expr", ("NOT internal_err", "NOT (internal_err)", "bogus/"))
+@pytest.mark.parametrize("expr", ("NOT internal_err", "NOT (internal_err)", "bogus="))
 def test_marker_expr_eval_failure_handling(pytester: Pytester, expr) -> None:
     foo = pytester.makepyfile(
         """
@@ -1119,3 +1109,62 @@ def test_marker_expr_eval_failure_handling(pytester: Pytester, expr) -> None:
     result = pytester.runpytest(foo, "-m", expr)
     result.stderr.fnmatch_lines([expected])
     assert result.ret == ExitCode.USAGE_ERROR
+
+
+def test_mark_mro() -> None:
+    xfail = pytest.mark.xfail
+
+    @xfail("a")
+    class A:
+        pass
+
+    @xfail("b")
+    class B:
+        pass
+
+    @xfail("c")
+    class C(A, B):
+        pass
+
+    from _pytest.mark.structures import get_unpacked_marks
+
+    all_marks = get_unpacked_marks(C)
+
+    assert all_marks == [xfail("b").mark, xfail("a").mark, xfail("c").mark]
+
+    assert get_unpacked_marks(C, consider_mro=False) == [xfail("c").mark]
+
+
+# @pytest.mark.issue("https://github.com/pytest-dev/pytest/issues/10447")
+def test_mark_fixture_order_mro(pytester: Pytester):
+    """This ensures we walk marks of the mro starting with the base classes
+    the action at a distance fixtures are taken as minimal example from a real project
+
+    """
+    foo = pytester.makepyfile(
+        """
+        import pytest
+
+        @pytest.fixture
+        def add_attr1(request):
+            request.instance.attr1 = object()
+
+
+        @pytest.fixture
+        def add_attr2(request):
+            request.instance.attr2 = request.instance.attr1
+
+
+        @pytest.mark.usefixtures('add_attr1')
+        class Parent:
+            pass
+
+
+        @pytest.mark.usefixtures('add_attr2')
+        class TestThings(Parent):
+            def test_attrs(self):
+                assert self.attr1 == self.attr2
+        """
+    )
+    result = pytester.runpytest(foo)
+    result.assert_outcomes(passed=1)
index faca02d9330cea2ec6d509afb0f82d2e1a68f344..f3643e7b4098d4f4b74b8a925ef93831be831022 100644 (file)
@@ -66,11 +66,29 @@ def test_syntax_oddeties(expr: str, expected: bool) -> None:
     assert evaluate(expr, matcher) is expected
 
 
+def test_backslash_not_treated_specially() -> None:
+    r"""When generating nodeids, if the source name contains special characters
+    like a newline, they are escaped into two characters like \n. Therefore, a
+    user will never need to insert a literal newline, only \n (two chars). So
+    mark expressions themselves do not support escaping, instead they treat
+    backslashes as regular identifier characters."""
+    matcher = {r"\nfoo\n"}.__contains__
+
+    assert evaluate(r"\nfoo\n", matcher)
+    assert not evaluate(r"foo", matcher)
+    with pytest.raises(ParseError):
+        evaluate("\nfoo\n", matcher)
+
+
 @pytest.mark.parametrize(
     ("expr", "column", "message"),
     (
         ("(", 2, "expected not OR left parenthesis OR identifier; got end of input"),
-        (" (", 3, "expected not OR left parenthesis OR identifier; got end of input",),
+        (
+            " (",
+            3,
+            "expected not OR left parenthesis OR identifier; got end of input",
+        ),
         (
             ")",
             1,
@@ -81,7 +99,11 @@ def test_syntax_oddeties(expr: str, expected: bool) -> None:
             1,
             "expected not OR left parenthesis OR identifier; got right parenthesis",
         ),
-        ("not", 4, "expected not OR left parenthesis OR identifier; got end of input",),
+        (
+            "not",
+            4,
+            "expected not OR left parenthesis OR identifier; got end of input",
+        ),
         (
             "not not",
             8,
@@ -98,7 +120,11 @@ def test_syntax_oddeties(expr: str, expected: bool) -> None:
             10,
             "expected not OR left parenthesis OR identifier; got end of input",
         ),
-        ("ident and or", 11, "expected not OR left parenthesis OR identifier; got or",),
+        (
+            "ident and or",
+            11,
+            "expected not OR left parenthesis OR identifier; got or",
+        ),
         ("ident ident", 7, "expected end of input; got identifier"),
     ),
 )
@@ -117,6 +143,8 @@ def test_syntax_errors(expr: str, column: int, message: str) -> None:
         ":::",
         "a:::c",
         "a+-b",
+        r"\nhe\\l\lo\n\t\rbye",
+        "a/b",
         "אבגד",
         "aaאבגדcc",
         "a[bcd]",
@@ -143,8 +171,6 @@ def test_valid_idents(ident: str) -> None:
 @pytest.mark.parametrize(
     "ident",
     (
-        "/",
-        "\\",
         "^",
         "*",
         "=",
index c20ff7480a86c9f7e553a4a6dee519d513ece87c..8175b5f0fad34fde28974d9a0805d7d011ae0de0 100644 (file)
@@ -2,15 +2,14 @@ import os
 import re
 import sys
 import textwrap
+from pathlib import Path
 from typing import Dict
 from typing import Generator
 from typing import Type
 
-import py
-
 import pytest
 from _pytest.monkeypatch import MonkeyPatch
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
 
 
 @pytest.fixture
@@ -51,21 +50,24 @@ def test_setattr() -> None:
 
 class TestSetattrWithImportPath:
     def test_string_expression(self, monkeypatch: MonkeyPatch) -> None:
-        monkeypatch.setattr("os.path.abspath", lambda x: "hello2")
-        assert os.path.abspath("123") == "hello2"
+        with monkeypatch.context() as mp:
+            mp.setattr("os.path.abspath", lambda x: "hello2")
+            assert os.path.abspath("123") == "hello2"
 
     def test_string_expression_class(self, monkeypatch: MonkeyPatch) -> None:
-        monkeypatch.setattr("_pytest.config.Config", 42)
-        import _pytest
+        with monkeypatch.context() as mp:
+            mp.setattr("_pytest.config.Config", 42)
+            import _pytest
 
-        assert _pytest.config.Config == 42  # type: ignore
+            assert _pytest.config.Config == 42  # type: ignore
 
     def test_unicode_string(self, monkeypatch: MonkeyPatch) -> None:
-        monkeypatch.setattr("_pytest.config.Config", 42)
-        import _pytest
+        with monkeypatch.context() as mp:
+            mp.setattr("_pytest.config.Config", 42)
+            import _pytest
 
-        assert _pytest.config.Config == 42  # type: ignore
-        monkeypatch.delattr("_pytest.config.Config")
+            assert _pytest.config.Config == 42  # type: ignore
+            mp.delattr("_pytest.config.Config")
 
     def test_wrong_target(self, monkeypatch: MonkeyPatch) -> None:
         with pytest.raises(TypeError):
@@ -81,14 +83,16 @@ class TestSetattrWithImportPath:
 
     def test_unknown_attr_non_raising(self, monkeypatch: MonkeyPatch) -> None:
         # https://github.com/pytest-dev/pytest/issues/746
-        monkeypatch.setattr("os.path.qweqwe", 42, raising=False)
-        assert os.path.qweqwe == 42  # type: ignore
+        with monkeypatch.context() as mp:
+            mp.setattr("os.path.qweqwe", 42, raising=False)
+            assert os.path.qweqwe == 42  # type: ignore
 
     def test_delattr(self, monkeypatch: MonkeyPatch) -> None:
-        monkeypatch.delattr("os.path.abspath")
-        assert not hasattr(os.path, "abspath")
-        monkeypatch.undo()
-        assert os.path.abspath
+        with monkeypatch.context() as mp:
+            mp.delattr("os.path.abspath")
+            assert not hasattr(os.path, "abspath")
+            mp.undo()
+            assert os.path.abspath  # type:ignore[truthy-function]
 
 
 def test_delattr() -> None:
@@ -233,8 +237,8 @@ def test_setenv_prepend() -> None:
     assert "XYZ123" not in os.environ
 
 
-def test_monkeypatch_plugin(testdir: Testdir) -> None:
-    reprec = testdir.inline_runsource(
+def test_monkeypatch_plugin(pytester: Pytester) -> None:
+    reprec = pytester.inline_runsource(
         """
         def test_method(monkeypatch):
             assert monkeypatch.__class__.__name__ == "MonkeyPatch"
@@ -268,33 +272,33 @@ def test_syspath_prepend_double_undo(mp: MonkeyPatch) -> None:
         sys.path[:] = old_syspath
 
 
-def test_chdir_with_path_local(mp: MonkeyPatch, tmpdir: py.path.local) -> None:
-    mp.chdir(tmpdir)
-    assert os.getcwd() == tmpdir.strpath
+def test_chdir_with_path_local(mp: MonkeyPatch, tmp_path: Path) -> None:
+    mp.chdir(tmp_path)
+    assert os.getcwd() == str(tmp_path)
 
 
-def test_chdir_with_str(mp: MonkeyPatch, tmpdir: py.path.local) -> None:
-    mp.chdir(tmpdir.strpath)
-    assert os.getcwd() == tmpdir.strpath
+def test_chdir_with_str(mp: MonkeyPatch, tmp_path: Path) -> None:
+    mp.chdir(str(tmp_path))
+    assert os.getcwd() == str(tmp_path)
 
 
-def test_chdir_undo(mp: MonkeyPatch, tmpdir: py.path.local) -> None:
+def test_chdir_undo(mp: MonkeyPatch, tmp_path: Path) -> None:
     cwd = os.getcwd()
-    mp.chdir(tmpdir)
+    mp.chdir(tmp_path)
     mp.undo()
     assert os.getcwd() == cwd
 
 
-def test_chdir_double_undo(mp: MonkeyPatch, tmpdir: py.path.local) -> None:
-    mp.chdir(tmpdir.strpath)
+def test_chdir_double_undo(mp: MonkeyPatch, tmp_path: Path) -> None:
+    mp.chdir(str(tmp_path))
     mp.undo()
-    tmpdir.chdir()
+    os.chdir(tmp_path)
     mp.undo()
-    assert os.getcwd() == tmpdir.strpath
+    assert os.getcwd() == str(tmp_path)
 
 
-def test_issue185_time_breaks(testdir: Testdir) -> None:
-    testdir.makepyfile(
+def test_issue185_time_breaks(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import time
         def test_m(monkeypatch):
@@ -303,7 +307,7 @@ def test_issue185_time_breaks(testdir: Testdir) -> None:
             monkeypatch.setattr(time, "time", f)
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         """
         *1 passed*
@@ -311,26 +315,28 @@ def test_issue185_time_breaks(testdir: Testdir) -> None:
     )
 
 
-def test_importerror(testdir: Testdir) -> None:
-    p = testdir.mkpydir("package")
-    p.join("a.py").write(
+def test_importerror(pytester: Pytester) -> None:
+    p = pytester.mkpydir("package")
+    p.joinpath("a.py").write_text(
         textwrap.dedent(
             """\
         import doesnotexist
 
         x = 1
     """
-        )
+        ),
+        encoding="utf-8",
     )
-    testdir.tmpdir.join("test_importerror.py").write(
+    pytester.path.joinpath("test_importerror.py").write_text(
         textwrap.dedent(
             """\
         def test_importerror(monkeypatch):
             monkeypatch.setattr('package.a.x', 2)
     """
-        )
+        ),
+        encoding="utf-8",
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         """
         *import error in package.a: No module named 'doesnotexist'*
@@ -349,7 +355,9 @@ class SampleInherit(Sample):
 
 
 @pytest.mark.parametrize(
-    "Sample", [Sample, SampleInherit], ids=["new", "new-inherit"],
+    "Sample",
+    [Sample, SampleInherit],
+    ids=["new", "new-inherit"],
 )
 def test_issue156_undo_staticmethod(Sample: Type[Sample]) -> None:
     monkeypatch = MonkeyPatch()
@@ -419,17 +427,22 @@ def test_context_classmethod() -> None:
     assert A.x == 1
 
 
+@pytest.mark.filterwarnings(r"ignore:.*\bpkg_resources\b:DeprecationWarning")
 def test_syspath_prepend_with_namespace_packages(
-    testdir: Testdir, monkeypatch: MonkeyPatch
+    pytester: Pytester, monkeypatch: MonkeyPatch
 ) -> None:
     for dirname in "hello", "world":
-        d = testdir.mkdir(dirname)
-        ns = d.mkdir("ns_pkg")
-        ns.join("__init__.py").write(
-            "__import__('pkg_resources').declare_namespace(__name__)"
+        d = pytester.mkdir(dirname)
+        ns = d.joinpath("ns_pkg")
+        ns.mkdir()
+        ns.joinpath("__init__.py").write_text(
+            "__import__('pkg_resources').declare_namespace(__name__)", encoding="utf-8"
+        )
+        lib = ns.joinpath(dirname)
+        lib.mkdir()
+        lib.joinpath("__init__.py").write_text(
+            "def check(): return %r" % dirname, encoding="utf-8"
         )
-        lib = ns.mkdir(dirname)
-        lib.join("__init__.py").write("def check(): return %r" % dirname)
 
     monkeypatch.syspath_prepend("hello")
     import ns_pkg.hello
@@ -446,8 +459,7 @@ def test_syspath_prepend_with_namespace_packages(
     assert ns_pkg.world.check() == "world"
 
     # Should invalidate caches via importlib.invalidate_caches.
-    tmpdir = testdir.tmpdir
-    modules_tmpdir = tmpdir.mkdir("modules_tmpdir")
+    modules_tmpdir = pytester.mkdir("modules_tmpdir")
     monkeypatch.syspath_prepend(str(modules_tmpdir))
-    modules_tmpdir.join("main_app.py").write("app = True")
+    modules_tmpdir.joinpath("main_app.py").write_text("app = True", encoding="utf-8")
     from main_app import app  # noqa: F401
index f3824c5709022d38d724def1cb48295b6836a60b..df1439e1c49cccb22197537453cc265b698200ae 100644 (file)
@@ -1,10 +1,14 @@
+import re
+import warnings
+from pathlib import Path
+from typing import cast
 from typing import List
 from typing import Type
 
-import py
-
 import pytest
 from _pytest import nodes
+from _pytest.compat import legacy_path
+from _pytest.outcomes import OutcomeException
 from _pytest.pytester import Pytester
 from _pytest.warning_types import PytestWarning
 
@@ -18,11 +22,13 @@ from _pytest.warning_types import PytestWarning
         ("a/b/c", ["", "a", "a/b", "a/b/c"]),
         ("a/bbb/c::D", ["", "a", "a/bbb", "a/bbb/c", "a/bbb/c::D"]),
         ("a/b/c::D::eee", ["", "a", "a/b", "a/b/c", "a/b/c::D", "a/b/c::D::eee"]),
-        # :: considered only at the last component.
         ("::xx", ["", "::xx"]),
-        ("a/b/c::D/d::e", ["", "a", "a/b", "a/b/c::D", "a/b/c::D/d", "a/b/c::D/d::e"]),
+        # / only considered until first ::
+        ("a/b/c::D/d::e", ["", "a", "a/b", "a/b/c", "a/b/c::D/d", "a/b/c::D/d::e"]),
         # : alone is not a separator.
         ("a/b::D:e:f::g", ["", "a", "a/b", "a/b::D:e:f", "a/b::D:e:f::g"]),
+        # / not considered if a part of a test name
+        ("a/b::c/d::e[/test]", ["", "a", "a/b", "a/b::c/d", "a/b::c/d::e[/test]"]),
     ),
 )
 def test_iterparentnodeids(nodeid: str, expected: List[str]) -> None:
@@ -37,6 +43,50 @@ def test_node_from_parent_disallowed_arguments() -> None:
         nodes.Node.from_parent(None, config=None)  # type: ignore[arg-type]
 
 
+def test_node_direct_construction_deprecated() -> None:
+    with pytest.raises(
+        OutcomeException,
+        match=(
+            "Direct construction of _pytest.nodes.Node has been deprecated, please "
+            "use _pytest.nodes.Node.from_parent.\nSee "
+            "https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent"
+            " for more details."
+        ),
+    ):
+        nodes.Node(None, session=None)  # type: ignore[arg-type]
+
+
+def test_subclassing_both_item_and_collector_deprecated(
+    request, tmp_path: Path
+) -> None:
+    """
+    Verifies we warn on diamond inheritance as well as correctly managing legacy
+    inheritance constructors with missing args as found in plugins.
+    """
+
+    # We do not expect any warnings messages to issued during class definition.
+    with warnings.catch_warnings():
+        warnings.simplefilter("error")
+
+        class SoWrong(nodes.Item, nodes.File):
+            def __init__(self, fspath, parent):
+                """Legacy ctor with legacy call # don't wana see"""
+                super().__init__(fspath, parent)
+
+    with pytest.warns(PytestWarning) as rec:
+        SoWrong.from_parent(
+            request.session, fspath=legacy_path(tmp_path / "broken.txt")
+        )
+    messages = [str(x.message) for x in rec]
+    assert any(
+        re.search(".*SoWrong.* not using a cooperative constructor.*", x)
+        for x in messages
+    )
+    assert any(
+        re.search("(?m)SoWrong .* should not be a collector", x) for x in messages
+    )
+
+
 @pytest.mark.parametrize(
     "warn_type, msg", [(DeprecationWarning, "deprecated"), (PytestWarning, "pytest")]
 )
@@ -68,22 +118,26 @@ def test_node_warning_enforces_warning_types(pytester: Pytester) -> None:
 
 def test__check_initialpaths_for_relpath() -> None:
     """Ensure that it handles dirs, and does not always use dirname."""
-    cwd = py.path.local()
+    cwd = Path.cwd()
 
     class FakeSession1:
-        _initialpaths = [cwd]
+        _initialpaths = frozenset({cwd})
+
+    session = cast(pytest.Session, FakeSession1)
 
-    assert nodes._check_initialpaths_for_relpath(FakeSession1, cwd) == ""
+    assert nodes._check_initialpaths_for_relpath(session, cwd) == ""
 
-    sub = cwd.join("file")
+    sub = cwd / "file"
 
     class FakeSession2:
-        _initialpaths = [cwd]
+        _initialpaths = frozenset({cwd})
+
+    session = cast(pytest.Session, FakeSession2)
 
-    assert nodes._check_initialpaths_for_relpath(FakeSession2, sub) == "file"
+    assert nodes._check_initialpaths_for_relpath(session, sub) == "file"
 
-    outside = py.path.local("/outside")
-    assert nodes._check_initialpaths_for_relpath(FakeSession2, outside) is None
+    outside = Path("/outside-this-does-not-exist")
+    assert nodes._check_initialpaths_for_relpath(session, outside) is None
 
 
 def test_failure_with_changed_cwd(pytester: Pytester) -> None:
index 13429afafd4a7653414f51c25ce4dc89fcd0875b..e838e79ddd502fa1def8b87ea5f656492ddeb4c9 100644 (file)
@@ -37,7 +37,7 @@ def test_setup_func_with_setup_decorator() -> None:
         def f(self):
             values.append(1)
 
-    call_optional(A(), "f")
+    call_optional(A(), "f", "A.f")
     assert not values
 
 
@@ -47,7 +47,7 @@ def test_setup_func_not_callable() -> None:
     class A:
         f = 1
 
-    call_optional(A(), "f")
+    call_optional(A(), "f", "A.f")
 
 
 def test_nose_setup_func(pytester: Pytester) -> None:
@@ -165,28 +165,36 @@ def test_module_level_setup(pytester: Pytester) -> None:
         items = {}
 
         def setup():
-            items[1]=1
+            items.setdefault("setup", []).append("up")
 
         def teardown():
-            del items[1]
+            items.setdefault("setup", []).append("down")
 
         def setup2():
-            items[2] = 2
+            items.setdefault("setup2", []).append("up")
 
         def teardown2():
-            del items[2]
+            items.setdefault("setup2", []).append("down")
 
         def test_setup_module_setup():
-            assert items[1] == 1
+            assert items["setup"] == ["up"]
+
+        def test_setup_module_setup_again():
+            assert items["setup"] == ["up"]
 
         @with_setup(setup2, teardown2)
         def test_local_setup():
-            assert items[2] == 2
-            assert 1 not in items
+            assert items["setup"] == ["up"]
+            assert items["setup2"] == ["up"]
+
+        @with_setup(setup2, teardown2)
+        def test_local_setup_again():
+            assert items["setup"] == ["up"]
+            assert items["setup2"] == ["up", "down", "up"]
     """
     )
     result = pytester.runpytest("-p", "nose")
-    result.stdout.fnmatch_lines(["*2 passed*"])
+    result.stdout.fnmatch_lines(["*4 passed*"])
 
 
 def test_nose_style_setup_teardown(pytester: Pytester) -> None:
@@ -211,6 +219,50 @@ def test_nose_style_setup_teardown(pytester: Pytester) -> None:
     result.stdout.fnmatch_lines(["*2 passed*"])
 
 
+def test_fixtures_nose_setup_issue8394(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        def setup_module():
+            pass
+
+        def teardown_module():
+            pass
+
+        def setup_function(func):
+            pass
+
+        def teardown_function(func):
+            pass
+
+        def test_world():
+            pass
+
+        class Test(object):
+            def setup_class(cls):
+                pass
+
+            def teardown_class(cls):
+                pass
+
+            def setup_method(self, meth):
+                pass
+
+            def teardown_method(self, meth):
+                pass
+
+            def test_method(self): pass
+        """
+    )
+    match = "*no docstring available*"
+    result = pytester.runpytest("--fixtures")
+    assert result.ret == 0
+    result.stdout.no_fnmatch_line(match)
+
+    result = pytester.runpytest("--fixtures", "-v")
+    assert result.ret == 0
+    result.stdout.fnmatch_lines([match, match, match, match])
+
+
 def test_nose_setup_ordering(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
@@ -220,8 +272,10 @@ def test_nose_setup_ordering(pytester: Pytester) -> None:
         class TestClass(object):
             def setup(self):
                 assert visited
+                self.visited_cls = True
             def test_first(self):
-                pass
+                assert visited
+                assert self.visited_cls
         """
     )
     result = pytester.runpytest()
@@ -291,7 +345,7 @@ def test_SkipTest_during_collection(pytester: Pytester) -> None:
         """
     )
     result = pytester.runpytest(p)
-    result.assert_outcomes(skipped=1)
+    result.assert_outcomes(skipped=1, warnings=0)
 
 
 def test_SkipTest_in_test(pytester: Pytester) -> None:
@@ -423,3 +477,43 @@ def test_raises(pytester: Pytester) -> None:
             "* 1 failed, 2 passed *",
         ]
     )
+
+
+def test_nose_setup_skipped_if_non_callable(pytester: Pytester) -> None:
+    """Regression test for #9391."""
+    p = pytester.makepyfile(
+        __init__="",
+        setup="""
+        """,
+        teardown="""
+        """,
+        test_it="""
+        from . import setup, teardown
+
+        def test_it():
+            pass
+        """,
+    )
+    result = pytester.runpytest(p, "-p", "nose")
+    assert result.ret == 0
+
+
+@pytest.mark.parametrize("fixture_name", ("teardown", "teardown_class"))
+def test_teardown_fixture_not_called_directly(fixture_name, pytester: Pytester) -> None:
+    """Regression test for #10597."""
+    p = pytester.makepyfile(
+        f"""
+        import pytest
+
+        class TestHello:
+
+            @pytest.fixture
+            def {fixture_name}(self):
+                yield
+
+            def test_hello(self, {fixture_name}):
+                assert True
+        """
+    )
+    result = pytester.runpytest(p, "-p", "nose")
+    assert result.ret == 0
index a124009c40123df7056058b24d3b76aa29861df2..b6df035aacf11a3cc005c277920cbbf4f79c9dce 100644 (file)
@@ -1,10 +1,10 @@
 import argparse
+import locale
 import os
 import shlex
 import subprocess
 import sys
-
-import py
+from pathlib import Path
 
 import pytest
 from _pytest.config import argparsing as parseopt
@@ -15,12 +15,12 @@ from _pytest.pytester import Pytester
 
 @pytest.fixture
 def parser() -> parseopt.Parser:
-    return parseopt.Parser()
+    return parseopt.Parser(_ispytest=True)
 
 
 class TestParser:
     def test_no_help_by_default(self) -> None:
-        parser = parseopt.Parser(usage="xyz")
+        parser = parseopt.Parser(usage="xyz", _ispytest=True)
         pytest.raises(UsageError, lambda: parser.parse(["-h"]))
 
     def test_custom_prog(self, parser: parseopt.Parser) -> None:
@@ -91,13 +91,13 @@ class TestParser:
         assert groups_names == list("132")
 
     def test_group_addoption(self) -> None:
-        group = parseopt.OptionGroup("hello")
+        group = parseopt.OptionGroup("hello", _ispytest=True)
         group.addoption("--option1", action="store_true")
         assert len(group.options) == 1
         assert isinstance(group.options[0], parseopt.Argument)
 
     def test_group_addoption_conflict(self) -> None:
-        group = parseopt.OptionGroup("hello again")
+        group = parseopt.OptionGroup("hello again", _ispytest=True)
         group.addoption("--option1", "--option-1", action="store_true")
         with pytest.raises(ValueError) as err:
             group.addoption("--option1", "--option-one", action="store_true")
@@ -124,11 +124,11 @@ class TestParser:
         assert not getattr(args, parseopt.FILE_OR_DIR)
 
     def test_parse2(self, parser: parseopt.Parser) -> None:
-        args = parser.parse([py.path.local()])
-        assert getattr(args, parseopt.FILE_OR_DIR)[0] == py.path.local()
+        args = parser.parse([Path(".")])
+        assert getattr(args, parseopt.FILE_OR_DIR)[0] == "."
 
     def test_parse_known_args(self, parser: parseopt.Parser) -> None:
-        parser.parse_known_args([py.path.local()])
+        parser.parse_known_args([Path(".")])
         parser.addoption("--hello", action="store_true")
         ns = parser.parse_known_args(["x", "--y", "--hello", "this"])
         assert ns.hello
@@ -189,7 +189,7 @@ class TestParser:
             elif option.type is str:
                 option.default = "world"
 
-        parser = parseopt.Parser(processopt=defaultget)
+        parser = parseopt.Parser(processopt=defaultget, _ispytest=True)
         parser.addoption("--this", dest="this", type=int, action="store")
         parser.addoption("--hello", dest="hello", type=str, action="store")
         parser.addoption("--no", dest="no", action="store_true")
@@ -290,13 +290,19 @@ class TestParser:
 
 
 def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
+    try:
+        # New in Python 3.11, ignores utf-8 mode
+        encoding = locale.getencoding()  # type: ignore[attr-defined]
+    except AttributeError:
+        encoding = locale.getpreferredencoding(False)
     try:
         bash_version = subprocess.run(
             ["bash", "--version"],
             stdout=subprocess.PIPE,
             stderr=subprocess.DEVNULL,
             check=True,
-            universal_newlines=True,
+            text=True,
+            encoding=encoding,
         ).stdout
     except (OSError, subprocess.CalledProcessError):
         pytest.skip("bash is not available")
@@ -306,7 +312,7 @@ def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
 
     script = str(pytester.path.joinpath("test_argcomplete"))
 
-    with open(str(script), "w") as fp:
+    with open(str(script), "w", encoding="utf-8") as fp:
         # redirect output from argcomplete to stdin and stderr is not trivial
         # http://stackoverflow.com/q/12589419/1307905
         # so we use bash
@@ -315,7 +321,7 @@ def test_argcomplete(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
                 shlex.quote(sys.executable)
             )
         )
-    # alternative would be extended Testdir.{run(),_run(),popen()} to be able
+    # alternative would be extended Pytester.{run(),_run(),popen()} to be able
     # to handle a keyword argument env that replaces os.environ in popen or
     # extends the copy, advantage: could not forget to restore
     monkeypatch.setenv("_ARGCOMPLETE", "1")
index eaa9e7511c7732f65e5b6fed5a58303580342463..86b231f8b5effc30722d3f1c925ff73834a1567d 100644 (file)
@@ -1,3 +1,4 @@
+import email.message
 import io
 from typing import List
 from typing import Union
@@ -98,7 +99,9 @@ class TestPaste:
 
         def mocked(url, data):
             calls.append((url, data))
-            raise urllib.error.HTTPError(url, 400, "Bad request", {}, io.BytesIO())
+            raise urllib.error.HTTPError(
+                url, 400, "Bad request", email.message.Message(), io.BytesIO()
+            )
 
         monkeypatch.setattr(urllib.request, "urlopen", mocked)
         return calls
@@ -161,12 +164,12 @@ class TestPaste:
 
     def test_create_new_paste(self, pastebin, mocked_urlopen) -> None:
         result = pastebin.create_new_paste(b"full-paste-contents")
-        assert result == "https://bpaste.net/show/3c0c6750bd"
+        assert result == "https://bpa.st/show/3c0c6750bd"
         assert len(mocked_urlopen) == 1
         url, data = mocked_urlopen[0]
         assert type(data) is bytes
         lexer = "text"
-        assert url == "https://bpaste.net"
+        assert url == "https://bpa.st"
         assert "lexer=%s" % lexer in data.decode()
         assert "code=full-paste-contents" in data.decode()
         assert "expiry=1week" in data.decode()
index f60b9f26369e63cb6da1846f88bd7a12bedb4eff..5ae0bcdde0905a1a5623b8d5ac327ca888f6185b 100644 (file)
@@ -1,10 +1,14 @@
+import errno
 import os.path
+import pickle
 import sys
 import unittest.mock
 from pathlib import Path
 from textwrap import dedent
-
-import py
+from types import ModuleType
+from typing import Any
+from typing import Generator
+from typing import Iterator
 
 import pytest
 from _pytest.monkeypatch import MonkeyPatch
@@ -15,31 +19,21 @@ from _pytest.pathlib import fnmatch_ex
 from _pytest.pathlib import get_extended_length_path_str
 from _pytest.pathlib import get_lock_path
 from _pytest.pathlib import import_path
+from _pytest.pathlib import ImportMode
 from _pytest.pathlib import ImportPathMismatchError
+from _pytest.pathlib import insert_missing_modules
 from _pytest.pathlib import maybe_delete_a_numbered_dir
+from _pytest.pathlib import module_name_from_path
 from _pytest.pathlib import resolve_package_path
+from _pytest.pathlib import safe_exists
 from _pytest.pathlib import symlink_or_skip
 from _pytest.pathlib import visit
+from _pytest.pytester import Pytester
+from _pytest.tmpdir import TempPathFactory
 
 
 class TestFNMatcherPort:
-    """Test that our port of py.common.FNMatcher (fnmatch_ex) produces the
-    same results as the original py.path.local.fnmatch method."""
-
-    @pytest.fixture(params=["pathlib", "py.path"])
-    def match(self, request):
-        if request.param == "py.path":
-
-            def match_(pattern, path):
-                return py.path.local(path).fnmatch(pattern)
-
-        else:
-            assert request.param == "pathlib"
-
-            def match_(pattern, path):
-                return fnmatch_ex(pattern, path)
-
-        return match_
+    """Test our port of py.common.FNMatcher (fnmatch_ex)."""
 
     if sys.platform == "win32":
         drv1 = "c:"
@@ -55,19 +49,19 @@ class TestFNMatcherPort:
             ("*.py", "bar/foo.py"),
             ("test_*.py", "foo/test_foo.py"),
             ("tests/*.py", "tests/foo.py"),
-            (drv1 + "/*.py", drv1 + "/foo.py"),
-            (drv1 + "/foo/*.py", drv1 + "/foo/foo.py"),
+            (f"{drv1}/*.py", f"{drv1}/foo.py"),
+            (f"{drv1}/foo/*.py", f"{drv1}/foo/foo.py"),
             ("tests/**/test*.py", "tests/foo/test_foo.py"),
             ("tests/**/doc/test*.py", "tests/foo/bar/doc/test_foo.py"),
             ("tests/**/doc/**/test*.py", "tests/foo/doc/bar/test_foo.py"),
         ],
     )
-    def test_matching(self, match, pattern, path):
-        assert match(pattern, path)
+    def test_matching(self, pattern: str, path: str) -> None:
+        assert fnmatch_ex(pattern, path)
 
-    def test_matching_abspath(self, match):
+    def test_matching_abspath(self) -> None:
         abspath = os.path.abspath(os.path.join("tests/foo.py"))
-        assert match("tests/foo.py", abspath)
+        assert fnmatch_ex("tests/foo.py", abspath)
 
     @pytest.mark.parametrize(
         "pattern, path",
@@ -75,16 +69,16 @@ class TestFNMatcherPort:
             ("*.py", "foo.pyc"),
             ("*.py", "foo/foo.pyc"),
             ("tests/*.py", "foo/foo.py"),
-            (drv1 + "/*.py", drv2 + "/foo.py"),
-            (drv1 + "/foo/*.py", drv2 + "/foo/foo.py"),
+            (f"{drv1}/*.py", f"{drv2}/foo.py"),
+            (f"{drv1}/foo/*.py", f"{drv2}/foo/foo.py"),
             ("tests/**/test*.py", "tests/foo.py"),
             ("tests/**/test*.py", "foo/test_foo.py"),
             ("tests/**/doc/test*.py", "tests/foo/bar/doc/foo.py"),
             ("tests/**/doc/test*.py", "tests/foo/bar/test_foo.py"),
         ],
     )
-    def test_not_matching(self, match, pattern, path):
-        assert not match(pattern, path)
+    def test_not_matching(self, pattern: str, path: str) -> None:
+        assert not fnmatch_ex(pattern, path)
 
 
 class TestImportPath:
@@ -96,210 +90,256 @@ class TestImportPath:
     """
 
     @pytest.fixture(scope="session")
-    def path1(self, tmpdir_factory):
-        path = tmpdir_factory.mktemp("path")
+    def path1(self, tmp_path_factory: TempPathFactory) -> Generator[Path, None, None]:
+        path = tmp_path_factory.mktemp("path")
         self.setuptestfs(path)
         yield path
-        assert path.join("samplefile").check()
+        assert path.joinpath("samplefile").exists()
+
+    @pytest.fixture(autouse=True)
+    def preserve_sys(self):
+        with unittest.mock.patch.dict(sys.modules):
+            with unittest.mock.patch.object(sys, "path", list(sys.path)):
+                yield
 
-    def setuptestfs(self, path):
+    def setuptestfs(self, path: Path) -> None:
         # print "setting up test fs for", repr(path)
-        samplefile = path.ensure("samplefile")
-        samplefile.write("samplefile\n")
+        samplefile = path / "samplefile"
+        samplefile.write_text("samplefile\n", encoding="utf-8")
 
-        execfile = path.ensure("execfile")
-        execfile.write("x=42")
+        execfile = path / "execfile"
+        execfile.write_text("x=42", encoding="utf-8")
 
-        execfilepy = path.ensure("execfile.py")
-        execfilepy.write("x=42")
+        execfilepy = path / "execfile.py"
+        execfilepy.write_text("x=42", encoding="utf-8")
 
         d = {1: 2, "hello": "world", "answer": 42}
-        path.ensure("samplepickle").dump(d)
-
-        sampledir = path.ensure("sampledir", dir=1)
-        sampledir.ensure("otherfile")
-
-        otherdir = path.ensure("otherdir", dir=1)
-        otherdir.ensure("__init__.py")
-
-        module_a = otherdir.ensure("a.py")
-        module_a.write("from .b import stuff as result\n")
-        module_b = otherdir.ensure("b.py")
-        module_b.write('stuff="got it"\n')
-        module_c = otherdir.ensure("c.py")
-        module_c.write(
+        path.joinpath("samplepickle").write_bytes(pickle.dumps(d, 1))
+
+        sampledir = path / "sampledir"
+        sampledir.mkdir()
+        sampledir.joinpath("otherfile").touch()
+
+        otherdir = path / "otherdir"
+        otherdir.mkdir()
+        otherdir.joinpath("__init__.py").touch()
+
+        module_a = otherdir / "a.py"
+        module_a.write_text("from .b import stuff as result\n", encoding="utf-8")
+        module_b = otherdir / "b.py"
+        module_b.write_text('stuff="got it"\n', encoding="utf-8")
+        module_c = otherdir / "c.py"
+        module_c.write_text(
             dedent(
                 """
-            import py;
+            import pluggy;
             import otherdir.a
             value = otherdir.a.result
         """
-            )
+            ),
+            encoding="utf-8",
         )
-        module_d = otherdir.ensure("d.py")
-        module_d.write(
+        module_d = otherdir / "d.py"
+        module_d.write_text(
             dedent(
                 """
-            import py;
+            import pluggy;
             from otherdir import a
             value2 = a.result
         """
-            )
+            ),
+            encoding="utf-8",
         )
 
-    def test_smoke_test(self, path1):
-        obj = import_path(path1.join("execfile.py"))
+    def test_smoke_test(self, path1: Path) -> None:
+        obj = import_path(path1 / "execfile.py", root=path1)
         assert obj.x == 42  # type: ignore[attr-defined]
         assert obj.__name__ == "execfile"
 
-    def test_renamed_dir_creates_mismatch(self, tmpdir, monkeypatch):
-        p = tmpdir.ensure("a", "test_x123.py")
-        import_path(p)
-        tmpdir.join("a").move(tmpdir.join("b"))
+    def test_import_path_missing_file(self, path1: Path) -> None:
+        with pytest.raises(ImportPathMismatchError):
+            import_path(path1 / "sampledir", root=path1)
+
+    def test_renamed_dir_creates_mismatch(
+        self, tmp_path: Path, monkeypatch: MonkeyPatch
+    ) -> None:
+        tmp_path.joinpath("a").mkdir()
+        p = tmp_path.joinpath("a", "test_x123.py")
+        p.touch()
+        import_path(p, root=tmp_path)
+        tmp_path.joinpath("a").rename(tmp_path.joinpath("b"))
         with pytest.raises(ImportPathMismatchError):
-            import_path(tmpdir.join("b", "test_x123.py"))
+            import_path(tmp_path.joinpath("b", "test_x123.py"), root=tmp_path)
 
         # Errors can be ignored.
         monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "1")
-        import_path(tmpdir.join("b", "test_x123.py"))
+        import_path(tmp_path.joinpath("b", "test_x123.py"), root=tmp_path)
 
         # PY_IGNORE_IMPORTMISMATCH=0 does not ignore error.
         monkeypatch.setenv("PY_IGNORE_IMPORTMISMATCH", "0")
         with pytest.raises(ImportPathMismatchError):
-            import_path(tmpdir.join("b", "test_x123.py"))
+            import_path(tmp_path.joinpath("b", "test_x123.py"), root=tmp_path)
 
-    def test_messy_name(self, tmpdir):
-        # http://bitbucket.org/hpk42/py-trunk/issue/129
-        path = tmpdir.ensure("foo__init__.py")
-        module = import_path(path)
+    def test_messy_name(self, tmp_path: Path) -> None:
+        # https://bitbucket.org/hpk42/py-trunk/issue/129
+        path = tmp_path / "foo__init__.py"
+        path.touch()
+        module = import_path(path, root=tmp_path)
         assert module.__name__ == "foo__init__"
 
-    def test_dir(self, tmpdir):
-        p = tmpdir.join("hello_123")
-        p_init = p.ensure("__init__.py")
-        m = import_path(p)
+    def test_dir(self, tmp_path: Path) -> None:
+        p = tmp_path / "hello_123"
+        p.mkdir()
+        p_init = p / "__init__.py"
+        p_init.touch()
+        m = import_path(p, root=tmp_path)
         assert m.__name__ == "hello_123"
-        m = import_path(p_init)
+        m = import_path(p_init, root=tmp_path)
         assert m.__name__ == "hello_123"
 
-    def test_a(self, path1):
-        otherdir = path1.join("otherdir")
-        mod = import_path(otherdir.join("a.py"))
+    def test_a(self, path1: Path) -> None:
+        otherdir = path1 / "otherdir"
+        mod = import_path(otherdir / "a.py", root=path1)
         assert mod.result == "got it"  # type: ignore[attr-defined]
         assert mod.__name__ == "otherdir.a"
 
-    def test_b(self, path1):
-        otherdir = path1.join("otherdir")
-        mod = import_path(otherdir.join("b.py"))
+    def test_b(self, path1: Path) -> None:
+        otherdir = path1 / "otherdir"
+        mod = import_path(otherdir / "b.py", root=path1)
         assert mod.stuff == "got it"  # type: ignore[attr-defined]
         assert mod.__name__ == "otherdir.b"
 
-    def test_c(self, path1):
-        otherdir = path1.join("otherdir")
-        mod = import_path(otherdir.join("c.py"))
+    def test_c(self, path1: Path) -> None:
+        otherdir = path1 / "otherdir"
+        mod = import_path(otherdir / "c.py", root=path1)
         assert mod.value == "got it"  # type: ignore[attr-defined]
 
-    def test_d(self, path1):
-        otherdir = path1.join("otherdir")
-        mod = import_path(otherdir.join("d.py"))
+    def test_d(self, path1: Path) -> None:
+        otherdir = path1 / "otherdir"
+        mod = import_path(otherdir / "d.py", root=path1)
         assert mod.value2 == "got it"  # type: ignore[attr-defined]
 
-    def test_import_after(self, tmpdir):
-        tmpdir.ensure("xxxpackage", "__init__.py")
-        mod1path = tmpdir.ensure("xxxpackage", "module1.py")
-        mod1 = import_path(mod1path)
+    def test_import_after(self, tmp_path: Path) -> None:
+        tmp_path.joinpath("xxxpackage").mkdir()
+        tmp_path.joinpath("xxxpackage", "__init__.py").touch()
+        mod1path = tmp_path.joinpath("xxxpackage", "module1.py")
+        mod1path.touch()
+        mod1 = import_path(mod1path, root=tmp_path)
         assert mod1.__name__ == "xxxpackage.module1"
         from xxxpackage import module1
 
         assert module1 is mod1
 
-    def test_check_filepath_consistency(self, monkeypatch, tmpdir):
+    def test_check_filepath_consistency(
+        self, monkeypatch: MonkeyPatch, tmp_path: Path
+    ) -> None:
         name = "pointsback123"
-        ModuleType = type(os)
-        p = tmpdir.ensure(name + ".py")
+        p = tmp_path.joinpath(name + ".py")
+        p.touch()
         for ending in (".pyc", ".pyo"):
             mod = ModuleType(name)
-            pseudopath = tmpdir.ensure(name + ending)
+            pseudopath = tmp_path.joinpath(name + ending)
+            pseudopath.touch()
             mod.__file__ = str(pseudopath)
             monkeypatch.setitem(sys.modules, name, mod)
-            newmod = import_path(p)
+            newmod = import_path(p, root=tmp_path)
             assert mod == newmod
         monkeypatch.undo()
         mod = ModuleType(name)
-        pseudopath = tmpdir.ensure(name + "123.py")
+        pseudopath = tmp_path.joinpath(name + "123.py")
+        pseudopath.touch()
         mod.__file__ = str(pseudopath)
         monkeypatch.setitem(sys.modules, name, mod)
         with pytest.raises(ImportPathMismatchError) as excinfo:
-            import_path(p)
+            import_path(p, root=tmp_path)
         modname, modfile, orig = excinfo.value.args
         assert modname == name
-        assert modfile == pseudopath
+        assert modfile == str(pseudopath)
         assert orig == p
         assert issubclass(ImportPathMismatchError, ImportError)
 
-    def test_issue131_on__init__(self, tmpdir):
+    def test_issue131_on__init__(self, tmp_path: Path) -> None:
         # __init__.py files may be namespace packages, and thus the
         # __file__ of an imported module may not be ourselves
         # see issue
-        p1 = tmpdir.ensure("proja", "__init__.py")
-        p2 = tmpdir.ensure("sub", "proja", "__init__.py")
-        m1 = import_path(p1)
-        m2 = import_path(p2)
+        tmp_path.joinpath("proja").mkdir()
+        p1 = tmp_path.joinpath("proja", "__init__.py")
+        p1.touch()
+        tmp_path.joinpath("sub", "proja").mkdir(parents=True)
+        p2 = tmp_path.joinpath("sub", "proja", "__init__.py")
+        p2.touch()
+        m1 = import_path(p1, root=tmp_path)
+        m2 = import_path(p2, root=tmp_path)
         assert m1 == m2
 
-    def test_ensuresyspath_append(self, tmpdir):
-        root1 = tmpdir.mkdir("root1")
-        file1 = root1.ensure("x123.py")
+    def test_ensuresyspath_append(self, tmp_path: Path) -> None:
+        root1 = tmp_path / "root1"
+        root1.mkdir()
+        file1 = root1 / "x123.py"
+        file1.touch()
         assert str(root1) not in sys.path
-        import_path(file1, mode="append")
+        import_path(file1, mode="append", root=tmp_path)
         assert str(root1) == sys.path[-1]
         assert str(root1) not in sys.path[:-1]
 
-    def test_invalid_path(self, tmpdir):
+    def test_invalid_path(self, tmp_path: Path) -> None:
         with pytest.raises(ImportError):
-            import_path(tmpdir.join("invalid.py"))
+            import_path(tmp_path / "invalid.py", root=tmp_path)
 
     @pytest.fixture
-    def simple_module(self, tmpdir):
-        fn = tmpdir.join("mymod.py")
-        fn.write(
-            dedent(
-                """
-            def foo(x): return 40 + x
-            """
-            )
-        )
-        return fn
-
-    def test_importmode_importlib(self, simple_module):
+    def simple_module(
+        self, tmp_path: Path, request: pytest.FixtureRequest
+    ) -> Iterator[Path]:
+        name = f"mymod_{request.node.name}"
+        fn = tmp_path / f"_src/tests/{name}.py"
+        fn.parent.mkdir(parents=True)
+        fn.write_text("def foo(x): return 40 + x", encoding="utf-8")
+        module_name = module_name_from_path(fn, root=tmp_path)
+        yield fn
+        sys.modules.pop(module_name, None)
+
+    def test_importmode_importlib(
+        self, simple_module: Path, tmp_path: Path, request: pytest.FixtureRequest
+    ) -> None:
         """`importlib` mode does not change sys.path."""
-        module = import_path(simple_module, mode="importlib")
+        module = import_path(simple_module, mode="importlib", root=tmp_path)
         assert module.foo(2) == 42  # type: ignore[attr-defined]
-        assert simple_module.dirname not in sys.path
-
-    def test_importmode_twice_is_different_module(self, simple_module):
-        """`importlib` mode always returns a new module."""
-        module1 = import_path(simple_module, mode="importlib")
-        module2 = import_path(simple_module, mode="importlib")
-        assert module1 is not module2
-
-    def test_no_meta_path_found(self, simple_module, monkeypatch):
+        assert str(simple_module.parent) not in sys.path
+        assert module.__name__ in sys.modules
+        assert module.__name__ == f"_src.tests.mymod_{request.node.name}"
+        assert "_src" in sys.modules
+        assert "_src.tests" in sys.modules
+
+    def test_remembers_previous_imports(
+        self, simple_module: Path, tmp_path: Path
+    ) -> None:
+        """`importlib` mode called remembers previous module (#10341, #10811)."""
+        module1 = import_path(simple_module, mode="importlib", root=tmp_path)
+        module2 = import_path(simple_module, mode="importlib", root=tmp_path)
+        assert module1 is module2
+
+    def test_no_meta_path_found(
+        self, simple_module: Path, monkeypatch: MonkeyPatch, tmp_path: Path
+    ) -> None:
         """Even without any meta_path should still import module."""
         monkeypatch.setattr(sys, "meta_path", [])
-        module = import_path(simple_module, mode="importlib")
+        module = import_path(simple_module, mode="importlib", root=tmp_path)
         assert module.foo(2) == 42  # type: ignore[attr-defined]
 
         # mode='importlib' fails if no spec is found to load the module
         import importlib.util
 
+        # Force module to be re-imported.
+        del sys.modules[module.__name__]
+
         monkeypatch.setattr(
             importlib.util, "spec_from_file_location", lambda *args: None
         )
         with pytest.raises(ImportError):
-            import_path(simple_module, mode="importlib")
+            import_path(simple_module, mode="importlib", root=tmp_path)
 
 
-def test_resolve_package_path(tmp_path):
+def test_resolve_package_path(tmp_path: Path) -> None:
     pkg = tmp_path / "pkg1"
     pkg.mkdir()
     (pkg / "__init__.py").touch()
@@ -309,7 +349,7 @@ def test_resolve_package_path(tmp_path):
     assert resolve_package_path(pkg.joinpath("subdir", "__init__.py")) == pkg
 
 
-def test_package_unimportable(tmp_path):
+def test_package_unimportable(tmp_path: Path) -> None:
     pkg = tmp_path / "pkg1-1"
     pkg.mkdir()
     pkg.joinpath("__init__.py").touch()
@@ -323,7 +363,7 @@ def test_package_unimportable(tmp_path):
     assert not resolve_package_path(pkg)
 
 
-def test_access_denied_during_cleanup(tmp_path, monkeypatch):
+def test_access_denied_during_cleanup(tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
     """Ensure that deleting a numbered dir does not fail because of OSErrors (#4262)."""
     path = tmp_path / "temp-1"
     path.mkdir()
@@ -338,7 +378,7 @@ def test_access_denied_during_cleanup(tmp_path, monkeypatch):
     assert not lock_path.is_file()
 
 
-def test_long_path_during_cleanup(tmp_path):
+def test_long_path_during_cleanup(tmp_path: Path) -> None:
     """Ensure that deleting long path works (particularly on Windows (#6775))."""
     path = (tmp_path / ("a" * 250)).resolve()
     if sys.platform == "win32":
@@ -354,14 +394,14 @@ def test_long_path_during_cleanup(tmp_path):
     assert not os.path.isdir(extended_path)
 
 
-def test_get_extended_length_path_str():
+def test_get_extended_length_path_str() -> None:
     assert get_extended_length_path_str(r"c:\foo") == r"\\?\c:\foo"
     assert get_extended_length_path_str(r"\\share\foo") == r"\\?\UNC\share\foo"
     assert get_extended_length_path_str(r"\\?\UNC\share\foo") == r"\\?\UNC\share\foo"
     assert get_extended_length_path_str(r"\\?\c:\foo") == r"\\?\c:\foo"
 
 
-def test_suppress_error_removing_lock(tmp_path):
+def test_suppress_error_removing_lock(tmp_path: Path) -> None:
     """ensure_deletable should be resilient if lock file cannot be removed (#5456, #7491)"""
     path = tmp_path / "dir"
     path.mkdir()
@@ -406,15 +446,14 @@ def test_commonpath() -> None:
     assert commonpath(path, path.parent.parent) == path.parent.parent
 
 
-def test_visit_ignores_errors(tmpdir) -> None:
-    symlink_or_skip("recursive", tmpdir.join("recursive"))
-    tmpdir.join("foo").write_binary(b"")
-    tmpdir.join("bar").write_binary(b"")
+def test_visit_ignores_errors(tmp_path: Path) -> None:
+    symlink_or_skip("recursive", tmp_path / "recursive")
+    tmp_path.joinpath("foo").write_bytes(b"")
+    tmp_path.joinpath("bar").write_bytes(b"")
 
-    assert [entry.name for entry in visit(tmpdir, recurse=lambda entry: False)] == [
-        "bar",
-        "foo",
-    ]
+    assert [
+        entry.name for entry in visit(str(tmp_path), recurse=lambda entry: False)
+    ] == ["bar", "foo"]
 
 
 @pytest.mark.skipif(not sys.platform.startswith("win"), reason="Windows only")
@@ -425,7 +464,7 @@ def test_samefile_false_negatives(tmp_path: Path, monkeypatch: MonkeyPatch) -> N
     return False, even when they are clearly equal.
     """
     module_path = tmp_path.joinpath("my_module.py")
-    module_path.write_text("def foo(): return 42")
+    module_path.write_text("def foo(): return 42", encoding="utf-8")
     monkeypatch.syspath_prepend(tmp_path)
 
     with monkeypatch.context() as mp:
@@ -433,5 +472,243 @@ def test_samefile_false_negatives(tmp_path: Path, monkeypatch: MonkeyPatch) -> N
         # the paths too. Using a context to narrow the patch as much as possible given
         # this is an important system function.
         mp.setattr(os.path, "samefile", lambda x, y: False)
-        module = import_path(module_path)
+        module = import_path(module_path, root=tmp_path)
     assert getattr(module, "foo")() == 42
+
+
+class TestImportLibMode:
+    def test_importmode_importlib_with_dataclass(self, tmp_path: Path) -> None:
+        """Ensure that importlib mode works with a module containing dataclasses (#7856)."""
+        fn = tmp_path.joinpath("_src/tests/test_dataclass.py")
+        fn.parent.mkdir(parents=True)
+        fn.write_text(
+            dedent(
+                """
+                from dataclasses import dataclass
+
+                @dataclass
+                class Data:
+                    value: str
+                """
+            ),
+            encoding="utf-8",
+        )
+
+        module = import_path(fn, mode="importlib", root=tmp_path)
+        Data: Any = getattr(module, "Data")
+        data = Data(value="foo")
+        assert data.value == "foo"
+        assert data.__module__ == "_src.tests.test_dataclass"
+
+    def test_importmode_importlib_with_pickle(self, tmp_path: Path) -> None:
+        """Ensure that importlib mode works with pickle (#7859)."""
+        fn = tmp_path.joinpath("_src/tests/test_pickle.py")
+        fn.parent.mkdir(parents=True)
+        fn.write_text(
+            dedent(
+                """
+                import pickle
+
+                def _action():
+                    return 42
+
+                def round_trip():
+                    s = pickle.dumps(_action)
+                    return pickle.loads(s)
+                """
+            ),
+            encoding="utf-8",
+        )
+
+        module = import_path(fn, mode="importlib", root=tmp_path)
+        round_trip = getattr(module, "round_trip")
+        action = round_trip()
+        assert action() == 42
+
+    def test_importmode_importlib_with_pickle_separate_modules(
+        self, tmp_path: Path
+    ) -> None:
+        """
+        Ensure that importlib mode works can load pickles that look similar but are
+        defined in separate modules.
+        """
+        fn1 = tmp_path.joinpath("_src/m1/tests/test.py")
+        fn1.parent.mkdir(parents=True)
+        fn1.write_text(
+            dedent(
+                """
+                import dataclasses
+                import pickle
+
+                @dataclasses.dataclass
+                class Data:
+                    x: int = 42
+                """
+            ),
+            encoding="utf-8",
+        )
+
+        fn2 = tmp_path.joinpath("_src/m2/tests/test.py")
+        fn2.parent.mkdir(parents=True)
+        fn2.write_text(
+            dedent(
+                """
+                import dataclasses
+                import pickle
+
+                @dataclasses.dataclass
+                class Data:
+                    x: str = ""
+                """
+            ),
+            encoding="utf-8",
+        )
+
+        import pickle
+
+        def round_trip(obj):
+            s = pickle.dumps(obj)
+            return pickle.loads(s)
+
+        module = import_path(fn1, mode="importlib", root=tmp_path)
+        Data1 = getattr(module, "Data")
+
+        module = import_path(fn2, mode="importlib", root=tmp_path)
+        Data2 = getattr(module, "Data")
+
+        assert round_trip(Data1(20)) == Data1(20)
+        assert round_trip(Data2("hello")) == Data2("hello")
+        assert Data1.__module__ == "_src.m1.tests.test"
+        assert Data2.__module__ == "_src.m2.tests.test"
+
+    def test_module_name_from_path(self, tmp_path: Path) -> None:
+        result = module_name_from_path(tmp_path / "src/tests/test_foo.py", tmp_path)
+        assert result == "src.tests.test_foo"
+
+        # Path is not relative to root dir: use the full path to obtain the module name.
+        result = module_name_from_path(Path("/home/foo/test_foo.py"), Path("/bar"))
+        assert result == "home.foo.test_foo"
+
+        # Importing __init__.py files should return the package as module name.
+        result = module_name_from_path(tmp_path / "src/app/__init__.py", tmp_path)
+        assert result == "src.app"
+
+        # Unless __init__.py file is at the root, in which case we cannot have an empty module name.
+        result = module_name_from_path(tmp_path / "__init__.py", tmp_path)
+        assert result == "__init__"
+
+    def test_insert_missing_modules(
+        self, monkeypatch: MonkeyPatch, tmp_path: Path
+    ) -> None:
+        monkeypatch.chdir(tmp_path)
+        # Use 'xxx' and 'xxy' as parent names as they are unlikely to exist and
+        # don't end up being imported.
+        modules = {"xxx.tests.foo": ModuleType("xxx.tests.foo")}
+        insert_missing_modules(modules, "xxx.tests.foo")
+        assert sorted(modules) == ["xxx", "xxx.tests", "xxx.tests.foo"]
+
+        mod = ModuleType("mod", doc="My Module")
+        modules = {"xxy": mod}
+        insert_missing_modules(modules, "xxy")
+        assert modules == {"xxy": mod}
+
+        modules = {}
+        insert_missing_modules(modules, "")
+        assert modules == {}
+
+    def test_parent_contains_child_module_attribute(
+        self, monkeypatch: MonkeyPatch, tmp_path: Path
+    ):
+        monkeypatch.chdir(tmp_path)
+        # Use 'xxx' and 'xxy' as parent names as they are unlikely to exist and
+        # don't end up being imported.
+        modules = {"xxx.tests.foo": ModuleType("xxx.tests.foo")}
+        insert_missing_modules(modules, "xxx.tests.foo")
+        assert sorted(modules) == ["xxx", "xxx.tests", "xxx.tests.foo"]
+        assert modules["xxx"].tests is modules["xxx.tests"]
+        assert modules["xxx.tests"].foo is modules["xxx.tests.foo"]
+
+    def test_importlib_package(self, monkeypatch: MonkeyPatch, tmp_path: Path):
+        """
+        Importing a package using --importmode=importlib should not import the
+        package's __init__.py file more than once (#11306).
+        """
+        monkeypatch.chdir(tmp_path)
+        monkeypatch.syspath_prepend(tmp_path)
+
+        package_name = "importlib_import_package"
+        tmp_path.joinpath(package_name).mkdir()
+        init = tmp_path.joinpath(f"{package_name}/__init__.py")
+        init.write_text(
+            dedent(
+                """
+                from .singleton import Singleton
+
+                instance = Singleton()
+                """
+            ),
+            encoding="ascii",
+        )
+        singleton = tmp_path.joinpath(f"{package_name}/singleton.py")
+        singleton.write_text(
+            dedent(
+                """
+                class Singleton:
+                    INSTANCES = []
+
+                    def __init__(self) -> None:
+                        self.INSTANCES.append(self)
+                        if len(self.INSTANCES) > 1:
+                            raise RuntimeError("Already initialized")
+                """
+            ),
+            encoding="ascii",
+        )
+
+        mod = import_path(init, root=tmp_path, mode=ImportMode.importlib)
+        assert len(mod.instance.INSTANCES) == 1
+
+    def test_importlib_root_is_package(self, pytester: Pytester) -> None:
+        """
+        Regression for importing a `__init__`.py file that is at the root
+        (#11417).
+        """
+        pytester.makepyfile(__init__="")
+        pytester.makepyfile(
+            """
+            def test_my_test():
+                assert True
+            """
+        )
+
+        result = pytester.runpytest("--import-mode=importlib")
+        result.stdout.fnmatch_lines("* 1 passed *")
+
+
+def test_safe_exists(tmp_path: Path) -> None:
+    d = tmp_path.joinpath("some_dir")
+    d.mkdir()
+    assert safe_exists(d) is True
+
+    f = tmp_path.joinpath("some_file")
+    f.touch()
+    assert safe_exists(f) is True
+
+    # Use unittest.mock() as a context manager to have a very narrow
+    # patch lifetime.
+    p = tmp_path.joinpath("some long filename" * 100)
+    with unittest.mock.patch.object(
+        Path,
+        "exists",
+        autospec=True,
+        side_effect=OSError(errno.ENAMETOOLONG, "name too long"),
+    ):
+        assert safe_exists(p) is False
+
+    with unittest.mock.patch.object(
+        Path,
+        "exists",
+        autospec=True,
+        side_effect=ValueError("name too long"),
+    ):
+        assert safe_exists(p) is False
index 2099f5ae1e368768ec46bd5c35c7ebd805884ea0..e5773412fbfab3e625fe68d7a51137a44f89c881 100644 (file)
@@ -1,13 +1,18 @@
 import os
+import shutil
 import sys
 import types
 from typing import List
 
 import pytest
+from _pytest.config import Config
 from _pytest.config import ExitCode
 from _pytest.config import PytestPluginManager
 from _pytest.config.exceptions import UsageError
 from _pytest.main import Session
+from _pytest.monkeypatch import MonkeyPatch
+from _pytest.pathlib import import_path
+from _pytest.pytester import Pytester
 
 
 @pytest.fixture
@@ -16,14 +21,16 @@ def pytestpm() -> PytestPluginManager:
 
 
 class TestPytestPluginInteractions:
-    def test_addhooks_conftestplugin(self, testdir, _config_for_test):
-        testdir.makepyfile(
+    def test_addhooks_conftestplugin(
+        self, pytester: Pytester, _config_for_test: Config
+    ) -> None:
+        pytester.makepyfile(
             newhooks="""
             def pytest_myhook(xyz):
                 "new hook"
         """
         )
-        conf = testdir.makeconftest(
+        conf = pytester.makeconftest(
             """
             import newhooks
             def pytest_addhooks(pluginmanager):
@@ -37,38 +44,42 @@ class TestPytestPluginInteractions:
         pm.hook.pytest_addhooks.call_historic(
             kwargs=dict(pluginmanager=config.pluginmanager)
         )
-        config.pluginmanager._importconftest(conf, importmode="prepend")
+        config.pluginmanager._importconftest(
+            conf, importmode="prepend", rootpath=pytester.path
+        )
         # print(config.pluginmanager.get_plugins())
         res = config.hook.pytest_myhook(xyz=10)
         assert res == [11]
 
-    def test_addhooks_nohooks(self, testdir):
-        testdir.makeconftest(
+    def test_addhooks_nohooks(self, pytester: Pytester) -> None:
+        pytester.makeconftest(
             """
             import sys
             def pytest_addhooks(pluginmanager):
                 pluginmanager.add_hookspecs(sys)
         """
         )
-        res = testdir.runpytest()
+        res = pytester.runpytest()
         assert res.ret != 0
         res.stderr.fnmatch_lines(["*did not find*sys*"])
 
-    def test_do_option_postinitialize(self, testdir):
-        config = testdir.parseconfigure()
+    def test_do_option_postinitialize(self, pytester: Pytester) -> None:
+        config = pytester.parseconfigure()
         assert not hasattr(config.option, "test123")
-        p = testdir.makepyfile(
+        p = pytester.makepyfile(
             """
             def pytest_addoption(parser):
                 parser.addoption('--test123', action="store_true",
                     default=True)
         """
         )
-        config.pluginmanager._importconftest(p, importmode="prepend")
+        config.pluginmanager._importconftest(
+            p, importmode="prepend", rootpath=pytester.path
+        )
         assert config.option.test123
 
-    def test_configure(self, testdir):
-        config = testdir.parseconfig()
+    def test_configure(self, pytester: Pytester) -> None:
+        config = pytester.parseconfig()
         values = []
 
         class A:
@@ -87,7 +98,7 @@ class TestPytestPluginInteractions:
         config.pluginmanager.register(A())
         assert len(values) == 2
 
-    def test_hook_tracing(self, _config_for_test) -> None:
+    def test_hook_tracing(self, _config_for_test: Config) -> None:
         pytestpm = _config_for_test.pluginmanager  # fully initialized with plugins
         saveindent = []
 
@@ -120,25 +131,29 @@ class TestPytestPluginInteractions:
         finally:
             undo()
 
-    def test_hook_proxy(self, testdir):
+    def test_hook_proxy(self, pytester: Pytester) -> None:
         """Test the gethookproxy function(#2016)"""
-        config = testdir.parseconfig()
+        config = pytester.parseconfig()
         session = Session.from_config(config)
-        testdir.makepyfile(**{"tests/conftest.py": "", "tests/subdir/conftest.py": ""})
+        pytester.makepyfile(**{"tests/conftest.py": "", "tests/subdir/conftest.py": ""})
 
-        conftest1 = testdir.tmpdir.join("tests/conftest.py")
-        conftest2 = testdir.tmpdir.join("tests/subdir/conftest.py")
+        conftest1 = pytester.path.joinpath("tests/conftest.py")
+        conftest2 = pytester.path.joinpath("tests/subdir/conftest.py")
 
-        config.pluginmanager._importconftest(conftest1, importmode="prepend")
-        ihook_a = session.gethookproxy(testdir.tmpdir.join("tests"))
+        config.pluginmanager._importconftest(
+            conftest1, importmode="prepend", rootpath=pytester.path
+        )
+        ihook_a = session.gethookproxy(pytester.path / "tests")
         assert ihook_a is not None
-        config.pluginmanager._importconftest(conftest2, importmode="prepend")
-        ihook_b = session.gethookproxy(testdir.tmpdir.join("tests"))
+        config.pluginmanager._importconftest(
+            conftest2, importmode="prepend", rootpath=pytester.path
+        )
+        ihook_b = session.gethookproxy(pytester.path / "tests")
         assert ihook_a is not ihook_b
 
-    def test_hook_with_addoption(self, testdir):
+    def test_hook_with_addoption(self, pytester: Pytester) -> None:
         """Test that hooks can be used in a call to pytest_addoption"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             newhooks="""
             import pytest
             @pytest.hookspec(firstresult=True)
@@ -146,7 +161,7 @@ class TestPytestPluginInteractions:
                 pass
         """
         )
-        testdir.makepyfile(
+        pytester.makepyfile(
             myplugin="""
             import newhooks
             def pytest_addhooks(pluginmanager):
@@ -156,30 +171,32 @@ class TestPytestPluginInteractions:
                 parser.addoption("--config", help="Config, defaults to %(default)s", default=default_value)
         """
         )
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             pytest_plugins=("myplugin",)
             def pytest_default_value():
                 return "default_value"
         """
         )
-        res = testdir.runpytest("--help")
+        res = pytester.runpytest("--help")
         res.stdout.fnmatch_lines(["*--config=CONFIG*default_value*"])
 
 
-def test_default_markers(testdir):
-    result = testdir.runpytest("--markers")
+def test_default_markers(pytester: Pytester) -> None:
+    result = pytester.runpytest("--markers")
     result.stdout.fnmatch_lines(["*tryfirst*first*", "*trylast*last*"])
 
 
-def test_importplugin_error_message(testdir, pytestpm):
+def test_importplugin_error_message(
+    pytester: Pytester, pytestpm: PytestPluginManager
+) -> None:
     """Don't hide import errors when importing plugins and provide
     an easy to debug message.
 
     See #375 and #1998.
     """
-    testdir.syspathinsert(testdir.tmpdir)
-    testdir.makepyfile(
+    pytester.syspathinsert(pytester.path)
+    pytester.makepyfile(
         qwe="""\
         def test_traceback():
             raise ImportError('Not possible to import: ☺')
@@ -196,7 +213,7 @@ def test_importplugin_error_message(testdir, pytestpm):
 
 
 class TestPytestPluginManager:
-    def test_register_imported_modules(self):
+    def test_register_imported_modules(self) -> None:
         pm = PytestPluginManager()
         mod = types.ModuleType("x.y.pytest_hello")
         pm.register(mod)
@@ -216,23 +233,31 @@ class TestPytestPluginManager:
         assert pm.get_plugin("pytest_xyz") == mod
         assert pm.is_registered(mod)
 
-    def test_consider_module(self, testdir, pytestpm: PytestPluginManager) -> None:
-        testdir.syspathinsert()
-        testdir.makepyfile(pytest_p1="#")
-        testdir.makepyfile(pytest_p2="#")
+    def test_consider_module(
+        self, pytester: Pytester, pytestpm: PytestPluginManager
+    ) -> None:
+        pytester.syspathinsert()
+        pytester.makepyfile(pytest_p1="#")
+        pytester.makepyfile(pytest_p2="#")
         mod = types.ModuleType("temp")
         mod.__dict__["pytest_plugins"] = ["pytest_p1", "pytest_p2"]
         pytestpm.consider_module(mod)
-        assert pytestpm.get_plugin("pytest_p1").__name__ == "pytest_p1"
-        assert pytestpm.get_plugin("pytest_p2").__name__ == "pytest_p2"
-
-    def test_consider_module_import_module(self, testdir, _config_for_test) -> None:
+        p1 = pytestpm.get_plugin("pytest_p1")
+        assert p1 is not None
+        assert p1.__name__ == "pytest_p1"
+        p2 = pytestpm.get_plugin("pytest_p2")
+        assert p2 is not None
+        assert p2.__name__ == "pytest_p2"
+
+    def test_consider_module_import_module(
+        self, pytester: Pytester, _config_for_test: Config
+    ) -> None:
         pytestpm = _config_for_test.pluginmanager
         mod = types.ModuleType("x")
         mod.__dict__["pytest_plugins"] = "pytest_a"
-        aplugin = testdir.makepyfile(pytest_a="#")
-        reprec = testdir.make_hook_recorder(pytestpm)
-        testdir.syspathinsert(aplugin.dirpath())
+        aplugin = pytester.makepyfile(pytest_a="#")
+        reprec = pytester.make_hook_recorder(pytestpm)
+        pytester.syspathinsert(aplugin.parent)
         pytestpm.consider_module(mod)
         call = reprec.getcall(pytestpm.hook.pytest_plugin_registered.name)
         assert call.plugin.__name__ == "pytest_a"
@@ -242,30 +267,37 @@ class TestPytestPluginManager:
         values = reprec.getcalls("pytest_plugin_registered")
         assert len(values) == 1
 
-    def test_consider_env_fails_to_import(self, monkeypatch, pytestpm):
+    def test_consider_env_fails_to_import(
+        self, monkeypatch: MonkeyPatch, pytestpm: PytestPluginManager
+    ) -> None:
         monkeypatch.setenv("PYTEST_PLUGINS", "nonexisting", prepend=",")
         with pytest.raises(ImportError):
             pytestpm.consider_env()
 
     @pytest.mark.filterwarnings("always")
-    def test_plugin_skip(self, testdir, monkeypatch):
-        p = testdir.makepyfile(
+    def test_plugin_skip(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
+        p = pytester.makepyfile(
             skipping1="""
             import pytest
             pytest.skip("hello", allow_module_level=True)
         """
         )
-        p.copy(p.dirpath("skipping2.py"))
+        shutil.copy(p, p.with_name("skipping2.py"))
         monkeypatch.setenv("PYTEST_PLUGINS", "skipping2")
-        result = testdir.runpytest("-p", "skipping1", syspathinsert=True)
+        result = pytester.runpytest("-p", "skipping1", syspathinsert=True)
         assert result.ret == ExitCode.NO_TESTS_COLLECTED
         result.stdout.fnmatch_lines(
             ["*skipped plugin*skipping1*hello*", "*skipped plugin*skipping2*hello*"]
         )
 
-    def test_consider_env_plugin_instantiation(self, testdir, monkeypatch, pytestpm):
-        testdir.syspathinsert()
-        testdir.makepyfile(xy123="#")
+    def test_consider_env_plugin_instantiation(
+        self,
+        pytester: Pytester,
+        monkeypatch: MonkeyPatch,
+        pytestpm: PytestPluginManager,
+    ) -> None:
+        pytester.syspathinsert()
+        pytester.makepyfile(xy123="#")
         monkeypatch.setitem(os.environ, "PYTEST_PLUGINS", "xy123")
         l1 = len(pytestpm.get_plugins())
         pytestpm.consider_env()
@@ -276,9 +308,11 @@ class TestPytestPluginManager:
         l3 = len(pytestpm.get_plugins())
         assert l2 == l3
 
-    def test_pluginmanager_ENV_startup(self, testdir, monkeypatch):
-        testdir.makepyfile(pytest_x500="#")
-        p = testdir.makepyfile(
+    def test_pluginmanager_ENV_startup(
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
+    ) -> None:
+        pytester.makepyfile(pytest_x500="#")
+        p = pytester.makepyfile(
             """
             import pytest
             def test_hello(pytestconfig):
@@ -287,46 +321,58 @@ class TestPytestPluginManager:
         """
         )
         monkeypatch.setenv("PYTEST_PLUGINS", "pytest_x500", prepend=",")
-        result = testdir.runpytest(p, syspathinsert=True)
+        result = pytester.runpytest(p, syspathinsert=True)
         assert result.ret == 0
         result.stdout.fnmatch_lines(["*1 passed*"])
 
-    def test_import_plugin_importname(self, testdir, pytestpm):
+    def test_import_plugin_importname(
+        self, pytester: Pytester, pytestpm: PytestPluginManager
+    ) -> None:
         pytest.raises(ImportError, pytestpm.import_plugin, "qweqwex.y")
         pytest.raises(ImportError, pytestpm.import_plugin, "pytest_qweqwx.y")
 
-        testdir.syspathinsert()
+        pytester.syspathinsert()
         pluginname = "pytest_hello"
-        testdir.makepyfile(**{pluginname: ""})
+        pytester.makepyfile(**{pluginname: ""})
         pytestpm.import_plugin("pytest_hello")
         len1 = len(pytestpm.get_plugins())
         pytestpm.import_plugin("pytest_hello")
         len2 = len(pytestpm.get_plugins())
         assert len1 == len2
         plugin1 = pytestpm.get_plugin("pytest_hello")
+        assert plugin1 is not None
         assert plugin1.__name__.endswith("pytest_hello")
         plugin2 = pytestpm.get_plugin("pytest_hello")
         assert plugin2 is plugin1
 
-    def test_import_plugin_dotted_name(self, testdir, pytestpm):
+    def test_import_plugin_dotted_name(
+        self, pytester: Pytester, pytestpm: PytestPluginManager
+    ) -> None:
         pytest.raises(ImportError, pytestpm.import_plugin, "qweqwex.y")
         pytest.raises(ImportError, pytestpm.import_plugin, "pytest_qweqwex.y")
 
-        testdir.syspathinsert()
-        testdir.mkpydir("pkg").join("plug.py").write("x=3")
+        pytester.syspathinsert()
+        pytester.mkpydir("pkg").joinpath("plug.py").write_text("x=3", encoding="utf-8")
         pluginname = "pkg.plug"
         pytestpm.import_plugin(pluginname)
         mod = pytestpm.get_plugin("pkg.plug")
+        assert mod is not None
         assert mod.x == 3
 
-    def test_consider_conftest_deps(self, testdir, pytestpm):
-        mod = testdir.makepyfile("pytest_plugins='xyz'").pyimport()
+    def test_consider_conftest_deps(
+        self,
+        pytester: Pytester,
+        pytestpm: PytestPluginManager,
+    ) -> None:
+        mod = import_path(
+            pytester.makepyfile("pytest_plugins='xyz'"), root=pytester.path
+        )
         with pytest.raises(ImportError):
             pytestpm.consider_conftest(mod)
 
 
 class TestPytestPluginManagerBootstrapming:
-    def test_preparse_args(self, pytestpm):
+    def test_preparse_args(self, pytestpm: PytestPluginManager) -> None:
         pytest.raises(
             ImportError, lambda: pytestpm.consider_preparse(["xyz", "-p", "hello123"])
         )
@@ -343,7 +389,7 @@ class TestPytestPluginManagerBootstrapming:
         with pytest.raises(UsageError, match="^plugin main cannot be disabled$"):
             pytestpm.consider_preparse(["-p", "no:main"])
 
-    def test_plugin_prevent_register(self, pytestpm):
+    def test_plugin_prevent_register(self, pytestpm: PytestPluginManager) -> None:
         pytestpm.consider_preparse(["xyz", "-p", "no:abc"])
         l1 = pytestpm.get_plugins()
         pytestpm.register(42, name="abc")
@@ -351,7 +397,9 @@ class TestPytestPluginManagerBootstrapming:
         assert len(l2) == len(l1)
         assert 42 not in l2
 
-    def test_plugin_prevent_register_unregistered_alredy_registered(self, pytestpm):
+    def test_plugin_prevent_register_unregistered_alredy_registered(
+        self, pytestpm: PytestPluginManager
+    ) -> None:
         pytestpm.register(42, name="abc")
         l1 = pytestpm.get_plugins()
         assert 42 in l1
@@ -360,10 +408,10 @@ class TestPytestPluginManagerBootstrapming:
         assert 42 not in l2
 
     def test_plugin_prevent_register_stepwise_on_cacheprovider_unregister(
-        self, pytestpm
-    ):
+        self, pytestpm: PytestPluginManager
+    ) -> None:
         """From PR #4304: The only way to unregister a module is documented at
-        the end of https://docs.pytest.org/en/stable/plugins.html.
+        the end of https://docs.pytest.org/en/stable/how-to/plugins.html.
 
         When unregister cacheprovider, then unregister stepwise too.
         """
@@ -377,7 +425,7 @@ class TestPytestPluginManagerBootstrapming:
         assert 42 not in l2
         assert 43 not in l2
 
-    def test_blocked_plugin_can_be_used(self, pytestpm):
+    def test_blocked_plugin_can_be_used(self, pytestpm: PytestPluginManager) -> None:
         pytestpm.consider_preparse(["xyz", "-p", "no:abc", "-p", "abc"])
 
         assert pytestpm.has_plugin("abc")
index f2e8dd5a36aea9ae3bfce7552b214361ad12aab7..8f8b4d2914f14c87f30db29c28b548b45d53c79b 100644 (file)
@@ -2,26 +2,26 @@ import os
 import subprocess
 import sys
 import time
+from pathlib import Path
+from types import ModuleType
 from typing import List
 
-import py.path
-
-import _pytest.pytester as pytester
+import _pytest.pytester as pytester_mod
 import pytest
 from _pytest.config import ExitCode
 from _pytest.config import PytestPluginManager
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pytester import CwdSnapshot
 from _pytest.pytester import HookRecorder
 from _pytest.pytester import LineMatcher
 from _pytest.pytester import Pytester
 from _pytest.pytester import SysModulesSnapshot
 from _pytest.pytester import SysPathsSnapshot
-from _pytest.pytester import Testdir
 
 
-def test_make_hook_recorder(testdir) -> None:
-    item = testdir.getitem("def test_func(): pass")
-    recorder = testdir.make_hook_recorder(item.config.pluginmanager)
+def test_make_hook_recorder(pytester: Pytester) -> None:
+    item = pytester.getitem("def test_func(): pass")
+    recorder = pytester.make_hook_recorder(item.config.pluginmanager)
     assert not recorder.getfailures()
 
     # (The silly condition is to fool mypy that the code below this is reachable)
@@ -35,11 +35,11 @@ def test_make_hook_recorder(testdir) -> None:
         skipped = False
         when = "call"
 
-    recorder.hook.pytest_runtest_logreport(report=rep)
+    recorder.hook.pytest_runtest_logreport(report=rep)  # type: ignore[attr-defined]
     failures = recorder.getfailures()
-    assert failures == [rep]
+    assert failures == [rep]  # type: ignore[comparison-overlap]
     failures = recorder.getfailures()
-    assert failures == [rep]
+    assert failures == [rep]  # type: ignore[comparison-overlap]
 
     class rep2:
         excinfo = None
@@ -50,14 +50,14 @@ def test_make_hook_recorder(testdir) -> None:
 
     rep2.passed = False
     rep2.skipped = True
-    recorder.hook.pytest_runtest_logreport(report=rep2)
+    recorder.hook.pytest_runtest_logreport(report=rep2)  # type: ignore[attr-defined]
 
-    modcol = testdir.getmodulecol("")
+    modcol = pytester.getmodulecol("")
     rep3 = modcol.config.hook.pytest_make_collect_report(collector=modcol)
     rep3.passed = False
     rep3.failed = True
     rep3.skipped = False
-    recorder.hook.pytest_collectreport(report=rep3)
+    recorder.hook.pytest_collectreport(report=rep3)  # type: ignore[attr-defined]
 
     passed, skipped, failed = recorder.listoutcomes()
     assert not passed and skipped and failed
@@ -68,55 +68,55 @@ def test_make_hook_recorder(testdir) -> None:
     assert numfailed == 1
     assert len(recorder.getfailedcollections()) == 1
 
-    recorder.unregister()
+    recorder.unregister()  # type: ignore[attr-defined]
     recorder.clear()
-    recorder.hook.pytest_runtest_logreport(report=rep3)
+    recorder.hook.pytest_runtest_logreport(report=rep3)  # type: ignore[attr-defined]
     pytest.raises(ValueError, recorder.getfailures)
 
 
-def test_parseconfig(testdir) -> None:
-    config1 = testdir.parseconfig()
-    config2 = testdir.parseconfig()
+def test_parseconfig(pytester: Pytester) -> None:
+    config1 = pytester.parseconfig()
+    config2 = pytester.parseconfig()
     assert config2 is not config1
 
 
-def test_testdir_runs_with_plugin(testdir) -> None:
-    testdir.makepyfile(
+def test_pytester_runs_with_plugin(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         pytest_plugins = "pytester"
-        def test_hello(testdir):
+        def test_hello(pytester):
             assert 1
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(passed=1)
 
 
-def test_testdir_with_doctest(testdir):
-    """Check that testdir can be used within doctests.
+def test_pytester_with_doctest(pytester: Pytester) -> None:
+    """Check that pytester can be used within doctests.
 
     It used to use `request.function`, which is `None` with doctests."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         **{
             "sub/t-doctest.py": """
         '''
         >>> import os
-        >>> testdir = getfixture("testdir")
-        >>> str(testdir.makepyfile("content")).replace(os.sep, '/')
+        >>> pytester = getfixture("pytester")
+        >>> str(pytester.makepyfile("content")).replace(os.sep, '/')
         '.../basetemp/sub.t-doctest0/sub.py'
         '''
     """,
             "sub/__init__.py": "",
         }
     )
-    result = testdir.runpytest(
+    result = pytester.runpytest(
         "-p", "pytester", "--doctest-modules", "sub/t-doctest.py"
     )
     assert result.ret == 0
 
 
-def test_runresult_assertion_on_xfail(testdir) -> None:
-    testdir.makepyfile(
+def test_runresult_assertion_on_xfail(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
 
@@ -127,13 +127,13 @@ def test_runresult_assertion_on_xfail(testdir) -> None:
             assert False
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(xfailed=1)
     assert result.ret == 0
 
 
-def test_runresult_assertion_on_xpassed(testdir) -> None:
-    testdir.makepyfile(
+def test_runresult_assertion_on_xpassed(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
 
@@ -144,13 +144,13 @@ def test_runresult_assertion_on_xpassed(testdir) -> None:
             assert True
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(xpassed=1)
     assert result.ret == 0
 
 
-def test_xpassed_with_strict_is_considered_a_failure(testdir) -> None:
-    testdir.makepyfile(
+def test_xpassed_with_strict_is_considered_a_failure(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import pytest
 
@@ -161,7 +161,7 @@ def test_xpassed_with_strict_is_considered_a_failure(testdir) -> None:
             assert True
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.assert_outcomes(failed=1)
     assert result.ret != 0
 
@@ -191,7 +191,7 @@ def make_holder():
 def test_hookrecorder_basic(holder) -> None:
     pm = PytestPluginManager()
     pm.add_hookspecs(holder)
-    rec = HookRecorder(pm)
+    rec = HookRecorder(pm, _ispytest=True)
     pm.hook.pytest_xyz(arg=123)
     call = rec.popcall("pytest_xyz")
     assert call.arg == 123
@@ -202,28 +202,28 @@ def test_hookrecorder_basic(holder) -> None:
     assert call._name == "pytest_xyz_noarg"
 
 
-def test_makepyfile_unicode(testdir) -> None:
-    testdir.makepyfile(chr(0xFFFD))
+def test_makepyfile_unicode(pytester: Pytester) -> None:
+    pytester.makepyfile(chr(0xFFFD))
 
 
-def test_makepyfile_utf8(testdir) -> None:
+def test_makepyfile_utf8(pytester: Pytester) -> None:
     """Ensure makepyfile accepts utf-8 bytes as input (#2738)"""
     utf8_contents = """
         def setup_function(function):
             mixed_encoding = 'São Paulo'
     """.encode()
-    p = testdir.makepyfile(utf8_contents)
-    assert "mixed_encoding = 'São Paulo'".encode() in p.read("rb")
+    p = pytester.makepyfile(utf8_contents)
+    assert "mixed_encoding = 'São Paulo'".encode() in p.read_bytes()
 
 
 class TestInlineRunModulesCleanup:
-    def test_inline_run_test_module_not_cleaned_up(self, testdir) -> None:
-        test_mod = testdir.makepyfile("def test_foo(): assert True")
-        result = testdir.inline_run(str(test_mod))
+    def test_inline_run_test_module_not_cleaned_up(self, pytester: Pytester) -> None:
+        test_mod = pytester.makepyfile("def test_foo(): assert True")
+        result = pytester.inline_run(str(test_mod))
         assert result.ret == ExitCode.OK
         # rewrite module, now test should fail if module was re-imported
-        test_mod.write("def test_foo(): assert False")
-        result2 = testdir.inline_run(str(test_mod))
+        test_mod.write_text("def test_foo(): assert False", encoding="utf-8")
+        result2 = pytester.inline_run(str(test_mod))
         assert result2.ret == ExitCode.TESTS_FAILED
 
     def spy_factory(self):
@@ -243,20 +243,20 @@ class TestInlineRunModulesCleanup:
         return SysModulesSnapshotSpy
 
     def test_inline_run_taking_and_restoring_a_sys_modules_snapshot(
-        self, testdir, monkeypatch
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
     ) -> None:
         spy_factory = self.spy_factory()
-        monkeypatch.setattr(pytester, "SysModulesSnapshot", spy_factory)
-        testdir.syspathinsert()
+        monkeypatch.setattr(pytester_mod, "SysModulesSnapshot", spy_factory)
+        pytester.syspathinsert()
         original = dict(sys.modules)
-        testdir.makepyfile(import1="# you son of a silly person")
-        testdir.makepyfile(import2="# my hovercraft is full of eels")
-        test_mod = testdir.makepyfile(
+        pytester.makepyfile(import1="# you son of a silly person")
+        pytester.makepyfile(import2="# my hovercraft is full of eels")
+        test_mod = pytester.makepyfile(
             """
             import import1
             def test_foo(): import import2"""
         )
-        testdir.inline_run(str(test_mod))
+        pytester.inline_run(str(test_mod))
         assert len(spy_factory.instances) == 1
         spy = spy_factory.instances[0]
         assert spy._spy_restore_count == 1
@@ -264,51 +264,52 @@ class TestInlineRunModulesCleanup:
         assert all(sys.modules[x] is original[x] for x in sys.modules)
 
     def test_inline_run_sys_modules_snapshot_restore_preserving_modules(
-        self, testdir, monkeypatch
+        self, pytester: Pytester, monkeypatch: MonkeyPatch
     ) -> None:
         spy_factory = self.spy_factory()
-        monkeypatch.setattr(pytester, "SysModulesSnapshot", spy_factory)
-        test_mod = testdir.makepyfile("def test_foo(): pass")
-        testdir.inline_run(str(test_mod))
+        monkeypatch.setattr(pytester_mod, "SysModulesSnapshot", spy_factory)
+        test_mod = pytester.makepyfile("def test_foo(): pass")
+        pytester.inline_run(str(test_mod))
         spy = spy_factory.instances[0]
         assert not spy._spy_preserve("black_knight")
         assert spy._spy_preserve("zope")
         assert spy._spy_preserve("zope.interface")
         assert spy._spy_preserve("zopelicious")
 
-    def test_external_test_module_imports_not_cleaned_up(self, testdir) -> None:
-        testdir.syspathinsert()
-        testdir.makepyfile(imported="data = 'you son of a silly person'")
+    def test_external_test_module_imports_not_cleaned_up(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.syspathinsert()
+        pytester.makepyfile(imported="data = 'you son of a silly person'")
         import imported
 
-        test_mod = testdir.makepyfile(
+        test_mod = pytester.makepyfile(
             """
             def test_foo():
                 import imported
                 imported.data = 42"""
         )
-        testdir.inline_run(str(test_mod))
+        pytester.inline_run(str(test_mod))
         assert imported.data == 42
 
 
-def test_assert_outcomes_after_pytest_error(testdir) -> None:
-    testdir.makepyfile("def test_foo(): assert True")
+def test_assert_outcomes_after_pytest_error(pytester: Pytester) -> None:
+    pytester.makepyfile("def test_foo(): assert True")
 
-    result = testdir.runpytest("--unexpected-argument")
+    result = pytester.runpytest("--unexpected-argument")
     with pytest.raises(ValueError, match="Pytest terminal summary report not found"):
         result.assert_outcomes(passed=0)
 
 
-def test_cwd_snapshot(testdir: Testdir) -> None:
-    tmpdir = testdir.tmpdir
-    foo = tmpdir.ensure("foo", dir=1)
-    bar = tmpdir.ensure("bar", dir=1)
-    foo.chdir()
+def test_cwd_snapshot(pytester: Pytester) -> None:
+    foo = pytester.mkdir("foo")
+    bar = pytester.mkdir("bar")
+    os.chdir(foo)
     snapshot = CwdSnapshot()
-    bar.chdir()
-    assert py.path.local() == bar
+    os.chdir(bar)
+    assert Path().absolute() == bar
     snapshot.restore()
-    assert py.path.local() == foo
+    assert Path().absolute() == foo
 
 
 class TestSysModulesSnapshot:
@@ -318,14 +319,14 @@ class TestSysModulesSnapshot:
         original = dict(sys.modules)
         assert self.key not in sys.modules
         snapshot = SysModulesSnapshot()
-        sys.modules[self.key] = "something"  # type: ignore
+        sys.modules[self.key] = ModuleType("something")
         assert self.key in sys.modules
         snapshot.restore()
         assert sys.modules == original
 
-    def test_add_removed(self, monkeypatch) -> None:
+    def test_add_removed(self, monkeypatch: MonkeyPatch) -> None:
         assert self.key not in sys.modules
-        monkeypatch.setitem(sys.modules, self.key, "something")
+        monkeypatch.setitem(sys.modules, self.key, ModuleType("something"))
         assert self.key in sys.modules
         original = dict(sys.modules)
         snapshot = SysModulesSnapshot()
@@ -334,38 +335,39 @@ class TestSysModulesSnapshot:
         snapshot.restore()
         assert sys.modules == original
 
-    def test_restore_reloaded(self, monkeypatch) -> None:
+    def test_restore_reloaded(self, monkeypatch: MonkeyPatch) -> None:
         assert self.key not in sys.modules
-        monkeypatch.setitem(sys.modules, self.key, "something")
+        monkeypatch.setitem(sys.modules, self.key, ModuleType("something"))
         assert self.key in sys.modules
         original = dict(sys.modules)
         snapshot = SysModulesSnapshot()
-        sys.modules[self.key] = "something else"  # type: ignore
+        sys.modules[self.key] = ModuleType("something else")
         snapshot.restore()
         assert sys.modules == original
 
-    def test_preserve_modules(self, monkeypatch) -> None:
+    def test_preserve_modules(self, monkeypatch: MonkeyPatch) -> None:
         key = [self.key + str(i) for i in range(3)]
         assert not any(k in sys.modules for k in key)
         for i, k in enumerate(key):
-            monkeypatch.setitem(sys.modules, k, "something" + str(i))
+            mod = ModuleType("something" + str(i))
+            monkeypatch.setitem(sys.modules, k, mod)
         original = dict(sys.modules)
 
         def preserve(name):
             return name in (key[0], key[1], "some-other-key")
 
         snapshot = SysModulesSnapshot(preserve=preserve)
-        sys.modules[key[0]] = original[key[0]] = "something else0"  # type: ignore
-        sys.modules[key[1]] = original[key[1]] = "something else1"  # type: ignore
-        sys.modules[key[2]] = "something else2"  # type: ignore
+        sys.modules[key[0]] = original[key[0]] = ModuleType("something else0")
+        sys.modules[key[1]] = original[key[1]] = ModuleType("something else1")
+        sys.modules[key[2]] = ModuleType("something else2")
         snapshot.restore()
         assert sys.modules == original
 
-    def test_preserve_container(self, monkeypatch) -> None:
+    def test_preserve_container(self, monkeypatch: MonkeyPatch) -> None:
         original = dict(sys.modules)
         assert self.key not in original
         replacement = dict(sys.modules)
-        replacement[self.key] = "life of brian"  # type: ignore
+        replacement[self.key] = ModuleType("life of brian")
         snapshot = SysModulesSnapshot()
         monkeypatch.setattr(sys, "modules", replacement)
         snapshot.restore()
@@ -381,7 +383,7 @@ class TestSysPathsSnapshot:
     def path(n: int) -> str:
         return "my-dirty-little-secret-" + str(n)
 
-    def test_restore(self, monkeypatch, path_type) -> None:
+    def test_restore(self, monkeypatch: MonkeyPatch, path_type) -> None:
         other_path_type = self.other_path[path_type]
         for i in range(10):
             assert self.path(i) not in getattr(sys, path_type)
@@ -404,7 +406,7 @@ class TestSysPathsSnapshot:
         assert getattr(sys, path_type) == original
         assert getattr(sys, other_path_type) == original_other
 
-    def test_preserve_container(self, monkeypatch, path_type) -> None:
+    def test_preserve_container(self, monkeypatch: MonkeyPatch, path_type) -> None:
         other_path_type = self.other_path[path_type]
         original_data = list(getattr(sys, path_type))
         original_other = getattr(sys, other_path_type)
@@ -419,49 +421,49 @@ class TestSysPathsSnapshot:
         assert getattr(sys, other_path_type) == original_other_data
 
 
-def test_testdir_subprocess(testdir) -> None:
-    testfile = testdir.makepyfile("def test_one(): pass")
-    assert testdir.runpytest_subprocess(testfile).ret == 0
+def test_pytester_subprocess(pytester: Pytester) -> None:
+    testfile = pytester.makepyfile("def test_one(): pass")
+    assert pytester.runpytest_subprocess(testfile).ret == 0
 
 
-def test_testdir_subprocess_via_runpytest_arg(testdir) -> None:
-    testfile = testdir.makepyfile(
+def test_pytester_subprocess_via_runpytest_arg(pytester: Pytester) -> None:
+    testfile = pytester.makepyfile(
         """
-        def test_testdir_subprocess(testdir):
+        def test_pytester_subprocess(pytester):
             import os
-            testfile = testdir.makepyfile(
+            testfile = pytester.makepyfile(
                 \"""
                 import os
                 def test_one():
                     assert {} != os.getpid()
                 \""".format(os.getpid())
             )
-            assert testdir.runpytest(testfile).ret == 0
+            assert pytester.runpytest(testfile).ret == 0
         """
     )
-    result = testdir.runpytest_subprocess(
+    result = pytester.runpytest_inprocess(
         "-p", "pytester", "--runpytest", "subprocess", testfile
     )
     assert result.ret == 0
 
 
-def test_unicode_args(testdir) -> None:
-    result = testdir.runpytest("-k", "אבג")
+def test_unicode_args(pytester: Pytester) -> None:
+    result = pytester.runpytest("-k", "אבג")
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
 
-def test_testdir_run_no_timeout(testdir) -> None:
-    testfile = testdir.makepyfile("def test_no_timeout(): pass")
-    assert testdir.runpytest_subprocess(testfile).ret == ExitCode.OK
+def test_pytester_run_no_timeout(pytester: Pytester) -> None:
+    testfile = pytester.makepyfile("def test_no_timeout(): pass")
+    assert pytester.runpytest_subprocess(testfile).ret == ExitCode.OK
 
 
-def test_testdir_run_with_timeout(testdir) -> None:
-    testfile = testdir.makepyfile("def test_no_timeout(): pass")
+def test_pytester_run_with_timeout(pytester: Pytester) -> None:
+    testfile = pytester.makepyfile("def test_no_timeout(): pass")
 
     timeout = 120
 
     start = time.time()
-    result = testdir.runpytest_subprocess(testfile, timeout=timeout)
+    result = pytester.runpytest_subprocess(testfile, timeout=timeout)
     end = time.time()
     duration = end - start
 
@@ -469,16 +471,16 @@ def test_testdir_run_with_timeout(testdir) -> None:
     assert duration < timeout
 
 
-def test_testdir_run_timeout_expires(testdir) -> None:
-    testfile = testdir.makepyfile(
+def test_pytester_run_timeout_expires(pytester: Pytester) -> None:
+    testfile = pytester.makepyfile(
         """
         import time
 
         def test_timeout():
             time.sleep(10)"""
     )
-    with pytest.raises(testdir.TimeoutExpired):
-        testdir.runpytest_subprocess(testfile, timeout=1)
+    with pytest.raises(pytester.TimeoutExpired):
+        pytester.runpytest_subprocess(testfile, timeout=1)
 
 
 def test_linematcher_with_nonlist() -> None:
@@ -533,7 +535,7 @@ def test_linematcher_match_failure() -> None:
     ]
 
 
-def test_linematcher_consecutive():
+def test_linematcher_consecutive() -> None:
     lm = LineMatcher(["1", "", "2"])
     with pytest.raises(pytest.fail.Exception) as excinfo:
         lm.fnmatch_lines(["1", "2"], consecutive=True)
@@ -554,7 +556,7 @@ def test_linematcher_consecutive():
 
 
 @pytest.mark.parametrize("function", ["no_fnmatch_line", "no_re_match_line"])
-def test_linematcher_no_matching(function) -> None:
+def test_linematcher_no_matching(function: str) -> None:
     if function == "no_fnmatch_line":
         good_pattern = "*.py OK*"
         bad_pattern = "*X.py OK*"
@@ -615,20 +617,15 @@ def test_linematcher_string_api() -> None:
     assert str(lm) == "foo\nbar"
 
 
-def test_pytester_addopts_before_testdir(request, monkeypatch) -> None:
-    orig = os.environ.get("PYTEST_ADDOPTS", None)
+def test_pytest_addopts_before_pytester(request, monkeypatch: MonkeyPatch) -> None:
     monkeypatch.setenv("PYTEST_ADDOPTS", "--orig-unused")
-    testdir = request.getfixturevalue("testdir")
+    _: Pytester = request.getfixturevalue("pytester")
     assert "PYTEST_ADDOPTS" not in os.environ
-    testdir.finalize()
-    assert os.environ.get("PYTEST_ADDOPTS") == "--orig-unused"
-    monkeypatch.undo()
-    assert os.environ.get("PYTEST_ADDOPTS") == orig
 
 
-def test_run_stdin(testdir) -> None:
-    with pytest.raises(testdir.TimeoutExpired):
-        testdir.run(
+def test_run_stdin(pytester: Pytester) -> None:
+    with pytest.raises(pytester.TimeoutExpired):
+        pytester.run(
             sys.executable,
             "-c",
             "import sys, time; time.sleep(1); print(sys.stdin.read())",
@@ -636,8 +633,8 @@ def test_run_stdin(testdir) -> None:
             timeout=0.1,
         )
 
-    with pytest.raises(testdir.TimeoutExpired):
-        result = testdir.run(
+    with pytest.raises(pytester.TimeoutExpired):
+        result = pytester.run(
             sys.executable,
             "-c",
             "import sys, time; time.sleep(1); print(sys.stdin.read())",
@@ -645,7 +642,7 @@ def test_run_stdin(testdir) -> None:
             timeout=0.1,
         )
 
-    result = testdir.run(
+    result = pytester.run(
         sys.executable,
         "-c",
         "import sys; print(sys.stdin.read())",
@@ -656,8 +653,8 @@ def test_run_stdin(testdir) -> None:
     assert result.ret == 0
 
 
-def test_popen_stdin_pipe(testdir) -> None:
-    proc = testdir.popen(
+def test_popen_stdin_pipe(pytester: Pytester) -> None:
+    proc = pytester.popen(
         [sys.executable, "-c", "import sys; print(sys.stdin.read())"],
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE,
@@ -670,8 +667,8 @@ def test_popen_stdin_pipe(testdir) -> None:
     assert proc.returncode == 0
 
 
-def test_popen_stdin_bytes(testdir) -> None:
-    proc = testdir.popen(
+def test_popen_stdin_bytes(pytester: Pytester) -> None:
+    proc = pytester.popen(
         [sys.executable, "-c", "import sys; print(sys.stdin.read())"],
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE,
@@ -683,18 +680,18 @@ def test_popen_stdin_bytes(testdir) -> None:
     assert proc.returncode == 0
 
 
-def test_popen_default_stdin_stderr_and_stdin_None(testdir) -> None:
+def test_popen_default_stdin_stderr_and_stdin_None(pytester: Pytester) -> None:
     # stdout, stderr default to pipes,
     # stdin can be None to not close the pipe, avoiding
     # "ValueError: flush of closed file" with `communicate()`.
     #
     # Wraps the test to make it not hang when run with "-s".
-    p1 = testdir.makepyfile(
+    p1 = pytester.makepyfile(
         '''
         import sys
 
-        def test_inner(testdir):
-            p1 = testdir.makepyfile(
+        def test_inner(pytester):
+            p1 = pytester.makepyfile(
                 """
                 import sys
                 print(sys.stdin.read())  # empty
@@ -702,14 +699,14 @@ def test_popen_default_stdin_stderr_and_stdin_None(testdir) -> None:
                 sys.stderr.write('stderr')
                 """
             )
-            proc = testdir.popen([sys.executable, str(p1)], stdin=None)
+            proc = pytester.popen([sys.executable, str(p1)], stdin=None)
             stdout, stderr = proc.communicate(b"ignored")
             assert stdout.splitlines() == [b"", b"stdout"]
             assert stderr.splitlines() == [b"stderr"]
             assert proc.returncode == 0
         '''
     )
-    result = testdir.runpytest("-p", "pytester", str(p1))
+    result = pytester.runpytest("-p", "pytester", str(p1))
     assert result.ret == 0
 
 
@@ -740,22 +737,22 @@ def test_run_result_repr() -> None:
     errlines = ["some", "nasty", "errors", "happened"]
 
     # known exit code
-    r = pytester.RunResult(1, outlines, errlines, duration=0.5)
-    assert (
-        repr(r) == "<RunResult ret=ExitCode.TESTS_FAILED len(stdout.lines)=3"
+    r = pytester_mod.RunResult(1, outlines, errlines, duration=0.5)
+    assert repr(r) == (
+        f"<RunResult ret={str(pytest.ExitCode.TESTS_FAILED)} len(stdout.lines)=3"
         " len(stderr.lines)=4 duration=0.50s>"
     )
 
     # unknown exit code: just the number
-    r = pytester.RunResult(99, outlines, errlines, duration=0.5)
+    r = pytester_mod.RunResult(99, outlines, errlines, duration=0.5)
     assert (
         repr(r) == "<RunResult ret=99 len(stdout.lines)=3"
         " len(stderr.lines)=4 duration=0.50s>"
     )
 
 
-def test_testdir_outcomes_with_multiple_errors(testdir):
-    p1 = testdir.makepyfile(
+def test_pytester_outcomes_with_multiple_errors(pytester: Pytester) -> None:
+    p1 = pytester.makepyfile(
         """
         import pytest
 
@@ -770,13 +767,13 @@ def test_testdir_outcomes_with_multiple_errors(testdir):
             pass
     """
     )
-    result = testdir.runpytest(str(p1))
+    result = pytester.runpytest(str(p1))
     result.assert_outcomes(errors=2)
 
     assert result.parseoutcomes() == {"errors": 2}
 
 
-def test_parse_summary_line_always_plural():
+def test_parse_summary_line_always_plural() -> None:
     """Parsing summaries always returns plural nouns (#6505)"""
     lines = [
         "some output 1",
@@ -784,7 +781,7 @@ def test_parse_summary_line_always_plural():
         "======= 1 failed, 1 passed, 1 warning, 1 error in 0.13s ====",
         "done.",
     ]
-    assert pytester.RunResult.parse_summary_nouns(lines) == {
+    assert pytester_mod.RunResult.parse_summary_nouns(lines) == {
         "errors": 1,
         "failed": 1,
         "passed": 1,
@@ -797,7 +794,7 @@ def test_parse_summary_line_always_plural():
         "======= 1 failed, 1 passed, 2 warnings, 2 errors in 0.13s ====",
         "done.",
     ]
-    assert pytester.RunResult.parse_summary_nouns(lines) == {
+    assert pytester_mod.RunResult.parse_summary_nouns(lines) == {
         "errors": 2,
         "failed": 1,
         "passed": 1,
@@ -805,12 +802,49 @@ def test_parse_summary_line_always_plural():
     }
 
 
-def test_makefile_joins_absolute_path(testdir: Testdir) -> None:
-    absfile = testdir.tmpdir / "absfile"
-    p1 = testdir.makepyfile(**{str(absfile): ""})
-    assert str(p1) == str(testdir.tmpdir / "absfile.py")
+def test_makefile_joins_absolute_path(pytester: Pytester) -> None:
+    absfile = pytester.path / "absfile"
+    p1 = pytester.makepyfile(**{str(absfile): ""})
+    assert str(p1) == str(pytester.path / "absfile.py")
+
 
+def test_pytester_makefile_dot_prefixes_extension_with_warning(
+    pytester: Pytester,
+) -> None:
+    with pytest.raises(
+        ValueError,
+        match="pytester.makefile expects a file extension, try .foo.bar instead of foo.bar",
+    ):
+        pytester.makefile("foo.bar", "")
 
-def test_testtmproot(testdir):
-    """Check test_tmproot is a py.path attribute for backward compatibility."""
-    assert testdir.test_tmproot.check(dir=1)
+
+@pytest.mark.filterwarnings("default")
+def test_pytester_assert_outcomes_warnings(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        import warnings
+
+        def test_with_warning():
+            warnings.warn(UserWarning("some custom warning"))
+        """
+    )
+    result = pytester.runpytest()
+    result.assert_outcomes(passed=1, warnings=1)
+    # If warnings is not passed, it is not checked at all.
+    result.assert_outcomes(passed=1)
+
+
+def test_pytester_outcomes_deselected(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        def test_one():
+            pass
+
+        def test_two():
+            pass
+        """
+    )
+    result = pytester.runpytest("-k", "test_one")
+    result.assert_outcomes(passed=1, deselected=1)
+    # If deselected is not passed, it is not checked at all.
+    result.assert_outcomes(passed=1)
diff --git a/testing/test_python_path.py b/testing/test_python_path.py
new file mode 100644 (file)
index 0000000..e1628fe
--- /dev/null
@@ -0,0 +1,110 @@
+import sys
+from textwrap import dedent
+from typing import Generator
+from typing import List
+from typing import Optional
+
+import pytest
+from _pytest.pytester import Pytester
+
+
+@pytest.fixture()
+def file_structure(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        test_foo="""
+        from foo import foo
+
+        def test_foo():
+            assert foo() == 1
+        """
+    )
+
+    pytester.makepyfile(
+        test_bar="""
+        from bar import bar
+
+        def test_bar():
+            assert bar() == 2
+        """
+    )
+
+    foo_py = pytester.mkdir("sub") / "foo.py"
+    content = dedent(
+        """
+        def foo():
+            return 1
+        """
+    )
+    foo_py.write_text(content, encoding="utf-8")
+
+    bar_py = pytester.mkdir("sub2") / "bar.py"
+    content = dedent(
+        """
+        def bar():
+            return 2
+        """
+    )
+    bar_py.write_text(content, encoding="utf-8")
+
+
+def test_one_dir(pytester: Pytester, file_structure) -> None:
+    pytester.makefile(".ini", pytest="[pytest]\npythonpath=sub\n")
+    result = pytester.runpytest("test_foo.py")
+    assert result.ret == 0
+    result.assert_outcomes(passed=1)
+
+
+def test_two_dirs(pytester: Pytester, file_structure) -> None:
+    pytester.makefile(".ini", pytest="[pytest]\npythonpath=sub sub2\n")
+    result = pytester.runpytest("test_foo.py", "test_bar.py")
+    assert result.ret == 0
+    result.assert_outcomes(passed=2)
+
+
+def test_module_not_found(pytester: Pytester, file_structure) -> None:
+    """Without the pythonpath setting, the module should not be found."""
+    pytester.makefile(".ini", pytest="[pytest]\n")
+    result = pytester.runpytest("test_foo.py")
+    assert result.ret == pytest.ExitCode.INTERRUPTED
+    result.assert_outcomes(errors=1)
+    expected_error = "E   ModuleNotFoundError: No module named 'foo'"
+    result.stdout.fnmatch_lines([expected_error])
+
+
+def test_no_ini(pytester: Pytester, file_structure) -> None:
+    """If no ini file, test should error."""
+    result = pytester.runpytest("test_foo.py")
+    assert result.ret == pytest.ExitCode.INTERRUPTED
+    result.assert_outcomes(errors=1)
+    expected_error = "E   ModuleNotFoundError: No module named 'foo'"
+    result.stdout.fnmatch_lines([expected_error])
+
+
+def test_clean_up(pytester: Pytester) -> None:
+    """Test that the plugin cleans up after itself."""
+    # This is tough to test behaviorally because the cleanup really runs last.
+    # So the test make several implementation assumptions:
+    # - Cleanup is done in pytest_unconfigure().
+    # - Not a hookwrapper.
+    # So we can add a hookwrapper ourselves to test what it does.
+    pytester.makefile(".ini", pytest="[pytest]\npythonpath=I_SHALL_BE_REMOVED\n")
+    pytester.makepyfile(test_foo="""def test_foo(): pass""")
+
+    before: Optional[List[str]] = None
+    after: Optional[List[str]] = None
+
+    class Plugin:
+        @pytest.hookimpl(hookwrapper=True, tryfirst=True)
+        def pytest_unconfigure(self) -> Generator[None, None, None]:
+            nonlocal before, after
+            before = sys.path.copy()
+            yield
+            after = sys.path.copy()
+
+    result = pytester.runpytest_inprocess(plugins=[Plugin()])
+    assert result.ret == 0
+
+    assert before is not None
+    assert after is not None
+    assert any("I_SHALL_BE_REMOVED" in entry for entry in before)
+    assert not any("I_SHALL_BE_REMOVED" in entry for entry in after)
index 91efe6d23939c9213167065b389a47fb6a4b0e42..7e0f836a63451a85b83f1e1f51b65ed04ff660eb 100644 (file)
@@ -1,4 +1,3 @@
-import re
 import warnings
 from typing import Optional
 
@@ -27,6 +26,17 @@ def test_recwarn_functional(pytester: Pytester) -> None:
     reprec.assertoutcome(passed=1)
 
 
+@pytest.mark.filterwarnings("")
+def test_recwarn_captures_deprecation_warning(recwarn: WarningsRecorder) -> None:
+    """
+    Check that recwarn can capture DeprecationWarning by default
+    without custom filterwarnings (see #8666).
+    """
+    warnings.warn(DeprecationWarning("some deprecation"))
+    assert len(recwarn) == 1
+    assert recwarn.pop(DeprecationWarning)
+
+
 class TestWarningsRecorderChecker:
     def test_recording(self) -> None:
         rec = WarningsRecorder(_ispytest=True)
@@ -103,13 +113,13 @@ class TestDeprecatedCall:
         # Type ignored because `onceregistry` and `filters` are not
         # documented API.
         onceregistry = warnings.onceregistry.copy()  # type: ignore
-        filters = warnings.filters[:]  # type: ignore
+        filters = warnings.filters[:]
         warn = warnings.warn
         warn_explicit = warnings.warn_explicit
         self.test_deprecated_call_raises()
         self.test_deprecated_call()
         assert onceregistry == warnings.onceregistry  # type: ignore
-        assert filters == warnings.filters  # type: ignore
+        assert filters == warnings.filters
         assert warn is warnings.warn
         assert warn_explicit is warnings.warn_explicit
 
@@ -252,7 +262,7 @@ class TestWarns:
             with pytest.warns(RuntimeWarning):
                 warnings.warn("user", UserWarning)
         excinfo.match(
-            r"DID NOT WARN. No warnings of type \(.+RuntimeWarning.+,\) was emitted. "
+            r"DID NOT WARN. No warnings of type \(.+RuntimeWarning.+,\) were emitted.\n"
             r"The list of emitted warnings is: \[UserWarning\('user',?\)\]."
         )
 
@@ -260,15 +270,15 @@ class TestWarns:
             with pytest.warns(UserWarning):
                 warnings.warn("runtime", RuntimeWarning)
         excinfo.match(
-            r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) was emitted. "
-            r"The list of emitted warnings is: \[RuntimeWarning\('runtime',?\)\]."
+            r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted.\n"
+            r"The list of emitted warnings is: \[RuntimeWarning\('runtime',?\)]."
         )
 
         with pytest.raises(pytest.fail.Exception) as excinfo:
             with pytest.warns(UserWarning):
                 pass
         excinfo.match(
-            r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) was emitted. "
+            r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted.\n"
             r"The list of emitted warnings is: \[\]."
         )
 
@@ -278,18 +288,14 @@ class TestWarns:
                 warnings.warn("runtime", RuntimeWarning)
                 warnings.warn("import", ImportWarning)
 
-        message_template = (
-            "DID NOT WARN. No warnings of type {0} was emitted. "
-            "The list of emitted warnings is: {1}."
-        )
-        excinfo.match(
-            re.escape(
-                message_template.format(
-                    warning_classes, [each.message for each in warninfo]
-                )
-            )
+        messages = [each.message for each in warninfo]
+        expected_str = (
+            f"DID NOT WARN. No warnings of type {warning_classes} were emitted.\n"
+            f"The list of emitted warnings is: {messages}."
         )
 
+        assert str(excinfo.value) == expected_str
+
     def test_record(self) -> None:
         with pytest.warns(UserWarning) as record:
             warnings.warn("user", UserWarning)
@@ -298,7 +304,7 @@ class TestWarns:
         assert str(record[0].message) == "user"
 
     def test_record_only(self) -> None:
-        with pytest.warns(None) as record:
+        with pytest.warns() as record:
             warnings.warn("user", UserWarning)
             warnings.warn("runtime", RuntimeWarning)
 
@@ -306,6 +312,18 @@ class TestWarns:
         assert str(record[0].message) == "user"
         assert str(record[1].message) == "runtime"
 
+    def test_record_only_none_deprecated_warn(self) -> None:
+        # This should become an error when WARNS_NONE_ARG is removed in Pytest 8.0
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore")
+            with pytest.warns(None) as record:  # type: ignore[call-overload]
+                warnings.warn("user", UserWarning)
+                warnings.warn("runtime", RuntimeWarning)
+
+            assert len(record) == 2
+            assert str(record[0].message) == "user"
+            assert str(record[1].message) == "runtime"
+
     def test_record_by_subclass(self) -> None:
         with pytest.warns(Warning) as record:
             warnings.warn("user", UserWarning)
index b97b1fc2970ffdaeb7ade2d5e36f7e33df31af6e..387d2e807cec67fcc0476fbecc6b59df07a74aa9 100644 (file)
@@ -1,4 +1,3 @@
-from pathlib import Path
 from typing import Sequence
 from typing import Union
 
@@ -6,24 +5,25 @@ import pytest
 from _pytest._code.code import ExceptionChainRepr
 from _pytest._code.code import ExceptionRepr
 from _pytest.config import Config
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
+from _pytest.python_api import approx
 from _pytest.reports import CollectReport
 from _pytest.reports import TestReport
 
 
 class TestReportSerialization:
-    def test_xdist_longrepr_to_str_issue_241(self, testdir: Testdir) -> None:
+    def test_xdist_longrepr_to_str_issue_241(self, pytester: Pytester) -> None:
         """Regarding issue pytest-xdist#241.
 
         This test came originally from test_remote.py in xdist (ca03269).
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_a(): assert False
             def test_b(): pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reports = reprec.getreports("pytest_runtest_logreport")
         assert len(reports) == 6
         test_a_call = reports[1]
@@ -35,12 +35,12 @@ class TestReportSerialization:
         assert test_b_call.outcome == "passed"
         assert test_b_call._to_json()["longrepr"] is None
 
-    def test_xdist_report_longrepr_reprcrash_130(self, testdir: Testdir) -> None:
+    def test_xdist_report_longrepr_reprcrash_130(self, pytester: Pytester) -> None:
         """Regarding issue pytest-xdist#130
 
         This test came originally from test_remote.py in xdist (ca03269).
         """
-        reprec = testdir.inline_runsource(
+        reprec = pytester.inline_runsource(
             """
                     def test_fail():
                         assert False, 'Expected Message'
@@ -74,14 +74,14 @@ class TestReportSerialization:
         # Missing section attribute PR171
         assert added_section in a.longrepr.sections
 
-    def test_reprentries_serialization_170(self, testdir: Testdir) -> None:
+    def test_reprentries_serialization_170(self, pytester: Pytester) -> None:
         """Regarding issue pytest-xdist#170
 
         This test came originally from test_remote.py in xdist (ca03269).
         """
         from _pytest._code.code import ReprEntry
 
-        reprec = testdir.inline_runsource(
+        reprec = pytester.inline_runsource(
             """
                             def test_repr_entry():
                                 x = 0
@@ -120,14 +120,14 @@ class TestReportSerialization:
             assert rep_entry.reprlocals.lines == a_entry.reprlocals.lines
             assert rep_entry.style == a_entry.style
 
-    def test_reprentries_serialization_196(self, testdir: Testdir) -> None:
+    def test_reprentries_serialization_196(self, pytester: Pytester) -> None:
         """Regarding issue pytest-xdist#196
 
         This test came originally from test_remote.py in xdist (ca03269).
         """
         from _pytest._code.code import ReprEntryNative
 
-        reprec = testdir.inline_runsource(
+        reprec = pytester.inline_runsource(
             """
                             def test_repr_entry_native():
                                 x = 0
@@ -149,9 +149,9 @@ class TestReportSerialization:
             assert isinstance(rep_entries[i], ReprEntryNative)
             assert rep_entries[i].lines == a_entries[i].lines
 
-    def test_itemreport_outcomes(self, testdir: Testdir) -> None:
+    def test_itemreport_outcomes(self, pytester: Pytester) -> None:
         # This test came originally from test_remote.py in xdist (ca03269).
-        reprec = testdir.inline_runsource(
+        reprec = pytester.inline_runsource(
             """
             import pytest
             def test_pass(): pass
@@ -183,9 +183,9 @@ class TestReportSerialization:
             if rep.failed:
                 assert newrep.longreprtext == rep.longreprtext
 
-    def test_collectreport_passed(self, testdir: Testdir) -> None:
+    def test_collectreport_passed(self, pytester: Pytester) -> None:
         """This test came originally from test_remote.py in xdist (ca03269)."""
-        reprec = testdir.inline_runsource("def test_func(): pass")
+        reprec = pytester.inline_runsource("def test_func(): pass")
         reports = reprec.getreports("pytest_collectreport")
         for rep in reports:
             d = rep._to_json()
@@ -194,9 +194,9 @@ class TestReportSerialization:
             assert newrep.failed == rep.failed
             assert newrep.skipped == rep.skipped
 
-    def test_collectreport_fail(self, testdir: Testdir) -> None:
+    def test_collectreport_fail(self, pytester: Pytester) -> None:
         """This test came originally from test_remote.py in xdist (ca03269)."""
-        reprec = testdir.inline_runsource("qwe abc")
+        reprec = pytester.inline_runsource("qwe abc")
         reports = reprec.getreports("pytest_collectreport")
         assert reports
         for rep in reports:
@@ -208,9 +208,9 @@ class TestReportSerialization:
             if rep.failed:
                 assert newrep.longrepr == str(rep.longrepr)
 
-    def test_extended_report_deserialization(self, testdir: Testdir) -> None:
+    def test_extended_report_deserialization(self, pytester: Pytester) -> None:
         """This test came originally from test_remote.py in xdist (ca03269)."""
-        reprec = testdir.inline_runsource("qwe abc")
+        reprec = pytester.inline_runsource("qwe abc")
         reports = reprec.getreports("pytest_collectreport")
         assert reports
         for rep in reports:
@@ -224,33 +224,41 @@ class TestReportSerialization:
             if rep.failed:
                 assert newrep.longrepr == str(rep.longrepr)
 
-    def test_paths_support(self, testdir: Testdir) -> None:
-        """Report attributes which are py.path or pathlib objects should become strings."""
-        testdir.makepyfile(
+    def test_paths_support(self, pytester: Pytester) -> None:
+        """Report attributes which are path-like should become strings."""
+        pytester.makepyfile(
             """
             def test_a():
                 assert False
         """
         )
-        reprec = testdir.inline_run()
+
+        class MyPathLike:
+            def __init__(self, path: str) -> None:
+                self.path = path
+
+            def __fspath__(self) -> str:
+                return self.path
+
+        reprec = pytester.inline_run()
         reports = reprec.getreports("pytest_runtest_logreport")
         assert len(reports) == 3
         test_a_call = reports[1]
-        test_a_call.path1 = testdir.tmpdir  # type: ignore[attr-defined]
-        test_a_call.path2 = Path(testdir.tmpdir)  # type: ignore[attr-defined]
+        test_a_call.path1 = MyPathLike(str(pytester.path))  # type: ignore[attr-defined]
+        test_a_call.path2 = pytester.path  # type: ignore[attr-defined]
         data = test_a_call._to_json()
-        assert data["path1"] == str(testdir.tmpdir)
-        assert data["path2"] == str(testdir.tmpdir)
+        assert data["path1"] == str(pytester.path)
+        assert data["path2"] == str(pytester.path)
 
-    def test_deserialization_failure(self, testdir: Testdir) -> None:
+    def test_deserialization_failure(self, pytester: Pytester) -> None:
         """Check handling of failure during deserialization of report types."""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_a():
                 assert False
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reports = reprec.getreports("pytest_runtest_logreport")
         assert len(reports) == 3
         test_a_call = reports[1]
@@ -265,9 +273,11 @@ class TestReportSerialization:
             TestReport._from_json(data)
 
     @pytest.mark.parametrize("report_class", [TestReport, CollectReport])
-    def test_chained_exceptions(self, testdir: Testdir, tw_mock, report_class) -> None:
+    def test_chained_exceptions(
+        self, pytester: Pytester, tw_mock, report_class
+    ) -> None:
         """Check serialization/deserialization of report objects containing chained exceptions (#5786)"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def foo():
                 raise ValueError('value error')
@@ -283,7 +293,7 @@ class TestReportSerialization:
             )
         )
 
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         if report_class is TestReport:
             reports: Union[
                 Sequence[TestReport], Sequence[CollectReport]
@@ -338,14 +348,14 @@ class TestReportSerialization:
         # elsewhere and we do check the contents of the longrepr object after loading it.
         loaded_report.longrepr.toterminal(tw_mock)
 
-    def test_chained_exceptions_no_reprcrash(self, testdir: Testdir, tw_mock) -> None:
+    def test_chained_exceptions_no_reprcrash(self, pytester: Pytester, tw_mock) -> None:
         """Regression test for tracebacks without a reprcrash (#5971)
 
         This happens notably on exceptions raised by multiprocess.pool: the exception transfer
         from subprocess to main process creates an artificial exception, which ExceptionInfo
         can't obtain the ReprFileLocation from.
         """
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             from concurrent.futures import ProcessPoolExecutor
 
@@ -358,8 +368,8 @@ class TestReportSerialization:
         """
         )
 
-        testdir.syspathinsert()
-        reprec = testdir.inline_run()
+        pytester.syspathinsert()
+        reprec = pytester.inline_run()
 
         reports = reprec.getreports("pytest_runtest_logreport")
 
@@ -396,27 +406,48 @@ class TestReportSerialization:
         loaded_report.longrepr.toterminal(tw_mock)
 
     def test_report_prevent_ConftestImportFailure_hiding_exception(
-        self, testdir: Testdir
+        self, pytester: Pytester
     ) -> None:
-        sub_dir = testdir.tmpdir.join("ns").ensure_dir()
-        sub_dir.join("conftest").new(ext=".py").write("import unknown")
+        sub_dir = pytester.path.joinpath("ns")
+        sub_dir.mkdir()
+        sub_dir.joinpath("conftest.py").write_text("import unknown", encoding="utf-8")
 
-        result = testdir.runpytest_subprocess(".")
+        result = pytester.runpytest_subprocess(".")
         result.stdout.fnmatch_lines(["E   *Error: No module named 'unknown'"])
         result.stdout.no_fnmatch_line("ERROR  - *ConftestImportFailure*")
 
+    def test_report_timestamps_match_duration(self, pytester: Pytester, mock_timing):
+        reprec = pytester.inline_runsource(
+            """
+            import pytest
+            from _pytest import timing
+            @pytest.fixture
+            def fixture_():
+                timing.sleep(5)
+                yield
+                timing.sleep(5)
+            def test_1(fixture_): timing.sleep(10)
+        """
+        )
+        reports = reprec.getreports("pytest_runtest_logreport")
+        assert len(reports) == 3
+        for report in reports:
+            data = report._to_json()
+            loaded_report = TestReport._from_json(data)
+            assert loaded_report.stop - loaded_report.start == approx(report.duration)
+
 
 class TestHooks:
     """Test that the hooks are working correctly for plugins"""
 
-    def test_test_report(self, testdir: Testdir, pytestconfig: Config) -> None:
-        testdir.makepyfile(
+    def test_test_report(self, pytester: Pytester, pytestconfig: Config) -> None:
+        pytester.makepyfile(
             """
             def test_a(): assert False
             def test_b(): pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reports = reprec.getreports("pytest_runtest_logreport")
         assert len(reports) == 6
         for rep in reports:
@@ -431,14 +462,14 @@ class TestHooks:
             assert new_rep.when == rep.when
             assert new_rep.outcome == rep.outcome
 
-    def test_collect_report(self, testdir: Testdir, pytestconfig: Config) -> None:
-        testdir.makepyfile(
+    def test_collect_report(self, pytester: Pytester, pytestconfig: Config) -> None:
+        pytester.makepyfile(
             """
             def test_a(): assert False
             def test_b(): pass
         """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reports = reprec.getreports("pytest_collectreport")
         assert len(reports) == 2
         for rep in reports:
@@ -457,14 +488,14 @@ class TestHooks:
         "hook_name", ["pytest_runtest_logreport", "pytest_collectreport"]
     )
     def test_invalid_report_types(
-        self, testdir: Testdir, pytestconfig: Config, hook_name: str
+        self, pytester: Pytester, pytestconfig: Config, hook_name: str
     ) -> None:
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             def test_a(): pass
             """
         )
-        reprec = testdir.inline_run()
+        reprec = pytester.inline_run()
         reports = reprec.getreports(hook_name)
         assert reports
         rep = reports[0]
index a1f1db48d06b8f5cf33ff9fe31354790d6e69b71..de3e18184c7e22af52255cc6e800fa5f74b3de6b 100644 (file)
@@ -2,53 +2,62 @@ import inspect
 import os
 import sys
 import types
+from functools import partial
+from pathlib import Path
 from typing import Dict
 from typing import List
 from typing import Tuple
 from typing import Type
 
-import py
-
-import _pytest._code
 import pytest
 from _pytest import outcomes
 from _pytest import reports
 from _pytest import runner
+from _pytest._code import ExceptionInfo
+from _pytest._code.code import ExceptionChainRepr
 from _pytest.config import ExitCode
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.outcomes import OutcomeException
+from _pytest.pytester import Pytester
+
+if sys.version_info[:2] < (3, 11):
+    from exceptiongroup import ExceptionGroup
 
 
 class TestSetupState:
-    def test_setup(self, testdir) -> None:
-        ss = runner.SetupState()
-        item = testdir.getitem("def test_func(): pass")
+    def test_setup(self, pytester: Pytester) -> None:
+        item = pytester.getitem("def test_func(): pass")
+        ss = item.session._setupstate
         values = [1]
-        ss.prepare(item)
-        ss.addfinalizer(values.pop, colitem=item)
+        ss.setup(item)
+        ss.addfinalizer(values.pop, item)
         assert values
-        ss._pop_and_teardown()
+        ss.teardown_exact(None)
         assert not values
 
-    def test_teardown_exact_stack_empty(self, testdir) -> None:
-        item = testdir.getitem("def test_func(): pass")
-        ss = runner.SetupState()
-        ss.teardown_exact(item, None)
-        ss.teardown_exact(item, None)
-        ss.teardown_exact(item, None)
+    def test_teardown_exact_stack_empty(self, pytester: Pytester) -> None:
+        item = pytester.getitem("def test_func(): pass")
+        ss = item.session._setupstate
+        ss.setup(item)
+        ss.teardown_exact(None)
+        ss.teardown_exact(None)
+        ss.teardown_exact(None)
 
-    def test_setup_fails_and_failure_is_cached(self, testdir) -> None:
-        item = testdir.getitem(
+    def test_setup_fails_and_failure_is_cached(self, pytester: Pytester) -> None:
+        item = pytester.getitem(
             """
             def setup_module(mod):
                 raise ValueError(42)
             def test_func(): pass
         """
         )
-        ss = runner.SetupState()
-        pytest.raises(ValueError, lambda: ss.prepare(item))
-        pytest.raises(ValueError, lambda: ss.prepare(item))
+        ss = item.session._setupstate
+        with pytest.raises(ValueError):
+            ss.setup(item)
+        with pytest.raises(ValueError):
+            ss.setup(item)
 
-    def test_teardown_multiple_one_fails(self, testdir) -> None:
+    def test_teardown_multiple_one_fails(self, pytester: Pytester) -> None:
         r = []
 
         def fin1():
@@ -60,34 +69,39 @@ class TestSetupState:
         def fin3():
             r.append("fin3")
 
-        item = testdir.getitem("def test_func(): pass")
-        ss = runner.SetupState()
+        item = pytester.getitem("def test_func(): pass")
+        ss = item.session._setupstate
+        ss.setup(item)
         ss.addfinalizer(fin1, item)
         ss.addfinalizer(fin2, item)
         ss.addfinalizer(fin3, item)
         with pytest.raises(Exception) as err:
-            ss._callfinalizers(item)
+            ss.teardown_exact(None)
         assert err.value.args == ("oops",)
         assert r == ["fin3", "fin1"]
 
-    def test_teardown_multiple_fail(self, testdir) -> None:
-        # Ensure the first exception is the one which is re-raised.
-        # Ideally both would be reported however.
+    def test_teardown_multiple_fail(self, pytester: Pytester) -> None:
         def fin1():
             raise Exception("oops1")
 
         def fin2():
             raise Exception("oops2")
 
-        item = testdir.getitem("def test_func(): pass")
-        ss = runner.SetupState()
+        item = pytester.getitem("def test_func(): pass")
+        ss = item.session._setupstate
+        ss.setup(item)
         ss.addfinalizer(fin1, item)
         ss.addfinalizer(fin2, item)
-        with pytest.raises(Exception) as err:
-            ss._callfinalizers(item)
-        assert err.value.args == ("oops2",)
+        with pytest.raises(ExceptionGroup) as err:
+            ss.teardown_exact(None)
 
-    def test_teardown_multiple_scopes_one_fails(self, testdir) -> None:
+        # Note that finalizers are run LIFO, but because FIFO is more intuitive for
+        # users we reverse the order of messages, and see the error from fin1 first.
+        err1, err2 = err.value.exceptions
+        assert err1.args == ("oops1",)
+        assert err2.args == ("oops2",)
+
+    def test_teardown_multiple_scopes_one_fails(self, pytester: Pytester) -> None:
         module_teardown = []
 
         def fin_func():
@@ -96,19 +110,39 @@ class TestSetupState:
         def fin_module():
             module_teardown.append("fin_module")
 
-        item = testdir.getitem("def test_func(): pass")
-        ss = runner.SetupState()
-        ss.addfinalizer(fin_module, item.listchain()[-2])
+        item = pytester.getitem("def test_func(): pass")
+        mod = item.listchain()[-2]
+        ss = item.session._setupstate
+        ss.setup(item)
+        ss.addfinalizer(fin_module, mod)
         ss.addfinalizer(fin_func, item)
-        ss.prepare(item)
         with pytest.raises(Exception, match="oops1"):
-            ss.teardown_exact(item, None)
-        assert module_teardown
+            ss.teardown_exact(None)
+        assert module_teardown == ["fin_module"]
+
+    def test_teardown_multiple_scopes_several_fail(self, pytester) -> None:
+        def raiser(exc):
+            raise exc
+
+        item = pytester.getitem("def test_func(): pass")
+        mod = item.listchain()[-2]
+        ss = item.session._setupstate
+        ss.setup(item)
+        ss.addfinalizer(partial(raiser, KeyError("from module scope")), mod)
+        ss.addfinalizer(partial(raiser, TypeError("from function scope 1")), item)
+        ss.addfinalizer(partial(raiser, ValueError("from function scope 2")), item)
+
+        with pytest.raises(ExceptionGroup, match="errors during test teardown") as e:
+            ss.teardown_exact(None)
+        mod, func = e.value.exceptions
+        assert isinstance(mod, KeyError)
+        assert isinstance(func.exceptions[0], TypeError)  # type: ignore
+        assert isinstance(func.exceptions[1], ValueError)  # type: ignore
 
 
 class BaseFunctionalTests:
-    def test_passfunction(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_passfunction(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             def test_func():
                 pass
@@ -120,8 +154,8 @@ class BaseFunctionalTests:
         assert rep.outcome == "passed"
         assert not rep.longrepr
 
-    def test_failfunction(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_failfunction(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             def test_func():
                 assert 0
@@ -135,8 +169,8 @@ class BaseFunctionalTests:
         assert rep.outcome == "failed"
         # assert isinstance(rep.longrepr, ReprExceptionInfo)
 
-    def test_skipfunction(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_skipfunction(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             import pytest
             def test_func():
@@ -155,8 +189,8 @@ class BaseFunctionalTests:
         # assert rep.skipped.location.path
         # assert not rep.skipped.failurerepr
 
-    def test_skip_in_setup_function(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_skip_in_setup_function(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             import pytest
             def setup_function(func):
@@ -176,8 +210,8 @@ class BaseFunctionalTests:
         assert len(reports) == 2
         assert reports[1].passed  # teardown
 
-    def test_failure_in_setup_function(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_failure_in_setup_function(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             import pytest
             def setup_function(func):
@@ -193,8 +227,8 @@ class BaseFunctionalTests:
         assert rep.when == "setup"
         assert len(reports) == 2
 
-    def test_failure_in_teardown_function(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_failure_in_teardown_function(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             import pytest
             def teardown_function(func):
@@ -213,8 +247,8 @@ class BaseFunctionalTests:
         # assert rep.longrepr.reprcrash.lineno == 3
         # assert rep.longrepr.reprtraceback.reprentries
 
-    def test_custom_failure_repr(self, testdir) -> None:
-        testdir.makepyfile(
+    def test_custom_failure_repr(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             conftest="""
             import pytest
             class Function(pytest.Function):
@@ -222,7 +256,7 @@ class BaseFunctionalTests:
                     return "hello"
         """
         )
-        reports = testdir.runitem(
+        reports = pytester.runitem(
             """
             import pytest
             def test_func():
@@ -238,8 +272,8 @@ class BaseFunctionalTests:
         # assert rep.failed.where.path.basename == "test_func.py"
         # assert rep.failed.failurerepr == "hello"
 
-    def test_teardown_final_returncode(self, testdir) -> None:
-        rec = testdir.inline_runsource(
+    def test_teardown_final_returncode(self, pytester: Pytester) -> None:
+        rec = pytester.inline_runsource(
             """
             def test_func():
                 pass
@@ -249,8 +283,8 @@ class BaseFunctionalTests:
         )
         assert rec.ret == 1
 
-    def test_logstart_logfinish_hooks(self, testdir) -> None:
-        rec = testdir.inline_runsource(
+    def test_logstart_logfinish_hooks(self, pytester: Pytester) -> None:
+        rec = pytester.inline_runsource(
             """
             import pytest
             def test_func():
@@ -266,8 +300,8 @@ class BaseFunctionalTests:
             assert rep.nodeid == "test_logstart_logfinish_hooks.py::test_func"
             assert rep.location == ("test_logstart_logfinish_hooks.py", 1, "test_func")
 
-    def test_exact_teardown_issue90(self, testdir) -> None:
-        rec = testdir.inline_runsource(
+    def test_exact_teardown_issue90(self, pytester: Pytester) -> None:
+        rec = pytester.inline_runsource(
             """
             import pytest
 
@@ -279,7 +313,7 @@ class BaseFunctionalTests:
 
             def test_func():
                 import sys
-                # on python2 exc_info is keept till a function exits
+                # on python2 exc_info is kept till a function exits
                 # so we would end up calling test functions while
                 # sys.exc_info would return the indexerror
                 # from guessing the lastitem
@@ -306,9 +340,9 @@ class BaseFunctionalTests:
         assert reps[5].nodeid.endswith("test_func")
         assert reps[5].failed
 
-    def test_exact_teardown_issue1206(self, testdir) -> None:
+    def test_exact_teardown_issue1206(self, pytester: Pytester) -> None:
         """Issue shadowing error with wrong number of arguments on teardown_method."""
-        rec = testdir.inline_runsource(
+        rec = pytester.inline_runsource(
             """
             import pytest
 
@@ -335,14 +369,19 @@ class BaseFunctionalTests:
         assert reps[2].nodeid.endswith("test_method")
         assert reps[2].failed
         assert reps[2].when == "teardown"
-        assert reps[2].longrepr.reprcrash.message in (
+        longrepr = reps[2].longrepr
+        assert isinstance(longrepr, ExceptionChainRepr)
+        assert longrepr.reprcrash
+        assert longrepr.reprcrash.message in (
             "TypeError: teardown_method() missing 2 required positional arguments: 'y' and 'z'",
             # Python >= 3.10
             "TypeError: TestClass.teardown_method() missing 2 required positional arguments: 'y' and 'z'",
         )
 
-    def test_failure_in_setup_function_ignores_custom_repr(self, testdir) -> None:
-        testdir.makepyfile(
+    def test_failure_in_setup_function_ignores_custom_repr(
+        self, pytester: Pytester
+    ) -> None:
+        pytester.makepyfile(
             conftest="""
             import pytest
             class Function(pytest.Function):
@@ -350,7 +389,7 @@ class BaseFunctionalTests:
                     assert 0
         """
         )
-        reports = testdir.runitem(
+        reports = pytester.runitem(
             """
             def setup_function(func):
                 raise ValueError(42)
@@ -369,9 +408,9 @@ class BaseFunctionalTests:
         # assert rep.outcome.where.path.basename == "test_func.py"
         # assert instanace(rep.failed.failurerepr, PythonFailureRepr)
 
-    def test_systemexit_does_not_bail_out(self, testdir) -> None:
+    def test_systemexit_does_not_bail_out(self, pytester: Pytester) -> None:
         try:
-            reports = testdir.runitem(
+            reports = pytester.runitem(
                 """
                 def test_func():
                     raise SystemExit(42)
@@ -383,9 +422,9 @@ class BaseFunctionalTests:
         assert rep.failed
         assert rep.when == "call"
 
-    def test_exit_propagates(self, testdir) -> None:
+    def test_exit_propagates(self, pytester: Pytester) -> None:
         try:
-            testdir.runitem(
+            pytester.runitem(
                 """
                 import pytest
                 def test_func():
@@ -405,9 +444,9 @@ class TestExecutionNonForked(BaseFunctionalTests):
 
         return f
 
-    def test_keyboardinterrupt_propagates(self, testdir) -> None:
+    def test_keyboardinterrupt_propagates(self, pytester: Pytester) -> None:
         try:
-            testdir.runitem(
+            pytester.runitem(
                 """
                 def test_func():
                     raise KeyboardInterrupt("fake")
@@ -420,8 +459,8 @@ class TestExecutionNonForked(BaseFunctionalTests):
 
 
 class TestSessionReports:
-    def test_collect_result(self, testdir) -> None:
-        col = testdir.getmodulecol(
+    def test_collect_result(self, pytester: Pytester) -> None:
+        col = pytester.getmodulecol(
             """
             def test_func1():
                 pass
@@ -434,9 +473,10 @@ class TestSessionReports:
         assert not rep.skipped
         assert rep.passed
         locinfo = rep.location
-        assert locinfo[0] == col.fspath.basename
+        assert locinfo is not None
+        assert locinfo[0] == col.path.name
         assert not locinfo[1]
-        assert locinfo[2] == col.fspath.basename
+        assert locinfo[2] == col.path.name
         res = rep.result
         assert len(res) == 2
         assert res[0].name == "test_func1"
@@ -489,8 +529,8 @@ def test_callinfo() -> None:
 
 
 @pytest.mark.xfail
-def test_runtest_in_module_ordering(testdir) -> None:
-    p1 = testdir.makepyfile(
+def test_runtest_in_module_ordering(pytester: Pytester) -> None:
+    p1 = pytester.makepyfile(
         """
         import pytest
         def pytest_runtest_setup(item): # runs after class-level!
@@ -517,7 +557,7 @@ def test_runtest_in_module_ordering(testdir) -> None:
             del item.function.mylist
     """
     )
-    result = testdir.runpytest(p1)
+    result = pytester.runpytest(p1)
     result.stdout.fnmatch_lines(["*2 passed*"])
 
 
@@ -547,8 +587,8 @@ def test_pytest_fail() -> None:
     assert s.startswith("Failed")
 
 
-def test_pytest_exit_msg(testdir) -> None:
-    testdir.makeconftest(
+def test_pytest_exit_msg(pytester: Pytester) -> None:
+    pytester.makeconftest(
         """
     import pytest
 
@@ -556,7 +596,7 @@ def test_pytest_exit_msg(testdir) -> None:
         pytest.exit('oh noes')
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stderr.fnmatch_lines(["Exit: oh noes"])
 
 
@@ -570,22 +610,22 @@ def _strip_resource_warnings(lines):
     ]
 
 
-def test_pytest_exit_returncode(testdir) -> None:
-    testdir.makepyfile(
+def test_pytest_exit_returncode(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """\
         import pytest
         def test_foo():
             pytest.exit("some exit msg", 99)
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*! *Exit: some exit msg !*"])
 
     assert _strip_resource_warnings(result.stderr.lines) == []
     assert result.ret == 99
 
     # It prints to stderr also in case of exit during pytest_sessionstart.
-    testdir.makeconftest(
+    pytester.makeconftest(
         """\
         import pytest
 
@@ -593,7 +633,7 @@ def test_pytest_exit_returncode(testdir) -> None:
             pytest.exit("during_sessionstart", 98)
         """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*! *Exit: during_sessionstart !*"])
     assert _strip_resource_warnings(result.stderr.lines) == [
         "Exit: during_sessionstart"
@@ -601,9 +641,9 @@ def test_pytest_exit_returncode(testdir) -> None:
     assert result.ret == 98
 
 
-def test_pytest_fail_notrace_runtest(testdir) -> None:
+def test_pytest_fail_notrace_runtest(pytester: Pytester) -> None:
     """Test pytest.fail(..., pytrace=False) does not show tracebacks during test run."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         def test_hello():
@@ -612,14 +652,14 @@ def test_pytest_fail_notrace_runtest(testdir) -> None:
             pytest.fail("world", pytrace=False)
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["world", "hello"])
     result.stdout.no_fnmatch_line("*def teardown_function*")
 
 
-def test_pytest_fail_notrace_collection(testdir) -> None:
+def test_pytest_fail_notrace_collection(pytester: Pytester) -> None:
     """Test pytest.fail(..., pytrace=False) does not show tracebacks during collection."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         def some_internal_function():
@@ -627,17 +667,17 @@ def test_pytest_fail_notrace_collection(testdir) -> None:
         some_internal_function()
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["hello"])
     result.stdout.no_fnmatch_line("*def some_internal_function()*")
 
 
-def test_pytest_fail_notrace_non_ascii(testdir) -> None:
+def test_pytest_fail_notrace_non_ascii(pytester: Pytester) -> None:
     """Fix pytest.fail with pytrace=False with non-ascii characters (#1178).
 
     This tests with native and unicode strings containing non-ascii chars.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """\
         import pytest
 
@@ -645,28 +685,28 @@ def test_pytest_fail_notrace_non_ascii(testdir) -> None:
             pytest.fail('oh oh: ☺', pytrace=False)
         """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*test_hello*", "oh oh: ☺"])
     result.stdout.no_fnmatch_line("*def test_hello*")
 
 
-def test_pytest_no_tests_collected_exit_status(testdir) -> None:
-    result = testdir.runpytest()
+def test_pytest_no_tests_collected_exit_status(pytester: Pytester) -> None:
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*collected 0 items*"])
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         test_foo="""
         def test_foo():
             assert 1
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*collected 1 item*"])
     result.stdout.fnmatch_lines(["*1 passed*"])
     assert result.ret == ExitCode.OK
 
-    result = testdir.runpytest("-k nonmatch")
+    result = pytester.runpytest("-k nonmatch")
     result.stdout.fnmatch_lines(["*collected 1 item*"])
     result.stdout.fnmatch_lines(["*1 deselected*"])
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
@@ -677,7 +717,7 @@ def test_exception_printing_skip() -> None:
     try:
         pytest.skip("hello")
     except pytest.skip.Exception:
-        excinfo = _pytest._code.ExceptionInfo.from_current()
+        excinfo = ExceptionInfo.from_current()
         s = excinfo.exconly(tryshort=True)
         assert s.startswith("Skipped")
 
@@ -698,10 +738,10 @@ def test_importorskip(monkeypatch) -> None:
         excrepr = excinfo.getrepr()
         assert excrepr is not None
         assert excrepr.reprcrash is not None
-        path = py.path.local(excrepr.reprcrash.path)
+        path = Path(excrepr.reprcrash.path)
         # check that importorskip reports the actual call
         # in this test the test_runner.py file
-        assert path.purebasename == "test_runner"
+        assert path.stem == "test_runner"
         pytest.raises(SyntaxError, pytest.importorskip, "x y z")
         pytest.raises(SyntaxError, pytest.importorskip, "x=y")
         mod = types.ModuleType("hello123")
@@ -712,9 +752,7 @@ def test_importorskip(monkeypatch) -> None:
         mod2 = pytest.importorskip("hello123", minversion="1.3")
         assert mod2 == mod
     except pytest.skip.Exception:  # pragma: no cover
-        assert False, "spurious skip: {}".format(
-            _pytest._code.ExceptionInfo.from_current()
-        )
+        assert False, f"spurious skip: {ExceptionInfo.from_current()}"
 
 
 def test_importorskip_imports_last_module_part() -> None:
@@ -732,14 +770,12 @@ def test_importorskip_dev_module(monkeypatch) -> None:
         with pytest.raises(pytest.skip.Exception):
             pytest.importorskip("mockmodule1", minversion="0.14.0")
     except pytest.skip.Exception:  # pragma: no cover
-        assert False, "spurious skip: {}".format(
-            _pytest._code.ExceptionInfo.from_current()
-        )
+        assert False, f"spurious skip: {ExceptionInfo.from_current()}"
 
 
-def test_importorskip_module_level(testdir) -> None:
+def test_importorskip_module_level(pytester: Pytester) -> None:
     """`importorskip` must be able to skip entire modules when used at module level."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         foobarbaz = pytest.importorskip("foobarbaz")
@@ -748,13 +784,13 @@ def test_importorskip_module_level(testdir) -> None:
             pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*collected 0 items / 1 skipped*"])
 
 
-def test_importorskip_custom_reason(testdir) -> None:
+def test_importorskip_custom_reason(pytester: Pytester) -> None:
     """Make sure custom reasons are used."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         foobarbaz = pytest.importorskip("foobarbaz2", reason="just because")
@@ -763,13 +799,13 @@ def test_importorskip_custom_reason(testdir) -> None:
             pass
     """
     )
-    result = testdir.runpytest("-ra")
+    result = pytester.runpytest("-ra")
     result.stdout.fnmatch_lines(["*just because*"])
     result.stdout.fnmatch_lines(["*collected 0 items / 1 skipped*"])
 
 
-def test_pytest_cmdline_main(testdir) -> None:
-    p = testdir.makepyfile(
+def test_pytest_cmdline_main(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
         """
         import pytest
         def test_hello():
@@ -786,8 +822,8 @@ def test_pytest_cmdline_main(testdir) -> None:
     assert ret == 0
 
 
-def test_unicode_in_longrepr(testdir) -> None:
-    testdir.makeconftest(
+def test_unicode_in_longrepr(pytester: Pytester) -> None:
+    pytester.makeconftest(
         """\
         import pytest
         @pytest.hookimpl(hookwrapper=True)
@@ -798,19 +834,19 @@ def test_unicode_in_longrepr(testdir) -> None:
                 rep.longrepr = 'ä'
         """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         def test_out():
             assert 0
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 1
     assert "UnicodeEncodeError" not in result.stderr.str()
 
 
-def test_failure_in_setup(testdir) -> None:
-    testdir.makepyfile(
+def test_failure_in_setup(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         def setup_module():
             0/0
@@ -818,24 +854,26 @@ def test_failure_in_setup(testdir) -> None:
             pass
     """
     )
-    result = testdir.runpytest("--tb=line")
+    result = pytester.runpytest("--tb=line")
     result.stdout.no_fnmatch_line("*def setup_module*")
 
 
-def test_makereport_getsource(testdir) -> None:
-    testdir.makepyfile(
+def test_makereport_getsource(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         def test_foo():
             if False: pass
             else: assert False
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.no_fnmatch_line("*INTERNALERROR*")
     result.stdout.fnmatch_lines(["*else: assert False*"])
 
 
-def test_makereport_getsource_dynamic_code(testdir, monkeypatch) -> None:
+def test_makereport_getsource_dynamic_code(
+    pytester: Pytester, monkeypatch: MonkeyPatch
+) -> None:
     """Test that exception in dynamically generated code doesn't break getting the source line."""
     import inspect
 
@@ -849,7 +887,7 @@ def test_makereport_getsource_dynamic_code(testdir, monkeypatch) -> None:
 
     monkeypatch.setattr(inspect, "findsource", findsource)
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
 
@@ -861,7 +899,7 @@ def test_makereport_getsource_dynamic_code(testdir, monkeypatch) -> None:
             assert False
     """
     )
-    result = testdir.runpytest("-vv")
+    result = pytester.runpytest("-vv")
     result.stdout.no_fnmatch_line("*INTERNALERROR*")
     result.stdout.fnmatch_lines(["*test_fix*", "*fixture*'missing'*not found*"])
 
@@ -869,6 +907,7 @@ def test_makereport_getsource_dynamic_code(testdir, monkeypatch) -> None:
 def test_store_except_info_on_error() -> None:
     """Test that upon test failure, the exception info is stored on
     sys.last_traceback and friends."""
+
     # Simulate item that might raise a specific exception, depending on `raise_error` class var
     class ItemMightRaise:
         nodeid = "item_that_raises"
@@ -896,12 +935,12 @@ def test_store_except_info_on_error() -> None:
     assert not hasattr(sys, "last_traceback")
 
 
-def test_current_test_env_var(testdir, monkeypatch) -> None:
+def test_current_test_env_var(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
     pytest_current_test_vars: List[Tuple[str, str]] = []
     monkeypatch.setattr(
         sys, "pytest_current_test_vars", pytest_current_test_vars, raising=False
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import sys
@@ -917,7 +956,7 @@ def test_current_test_env_var(testdir, monkeypatch) -> None:
             sys.pytest_current_test_vars.append(('call', os.environ['PYTEST_CURRENT_TEST']))
     """
     )
-    result = testdir.runpytest_inprocess()
+    result = pytester.runpytest_inprocess()
     assert result.ret == 0
     test_id = "test_current_test_env_var.py::test"
     assert pytest_current_test_vars == [
@@ -934,8 +973,8 @@ class TestReportContents:
     def getrunner(self):
         return lambda item: runner.runtestprotocol(item, log=False)
 
-    def test_longreprtext_pass(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_longreprtext_pass(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             def test_func():
                 pass
@@ -944,9 +983,9 @@ class TestReportContents:
         rep = reports[1]
         assert rep.longreprtext == ""
 
-    def test_longreprtext_skip(self, testdir) -> None:
+    def test_longreprtext_skip(self, pytester: Pytester) -> None:
         """TestReport.longreprtext can handle non-str ``longrepr`` attributes (#7559)"""
-        reports = testdir.runitem(
+        reports = pytester.runitem(
             """
             import pytest
             def test_func():
@@ -957,22 +996,22 @@ class TestReportContents:
         assert isinstance(call_rep.longrepr, tuple)
         assert "Skipped" in call_rep.longreprtext
 
-    def test_longreprtext_collect_skip(self, testdir) -> None:
+    def test_longreprtext_collect_skip(self, pytester: Pytester) -> None:
         """CollectReport.longreprtext can handle non-str ``longrepr`` attributes (#7559)"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             import pytest
             pytest.skip(allow_module_level=True)
             """
         )
-        rec = testdir.inline_run()
+        rec = pytester.inline_run()
         calls = rec.getcalls("pytest_collectreport")
         _, call = calls
         assert isinstance(call.report.longrepr, tuple)
         assert "Skipped" in call.report.longreprtext
 
-    def test_longreprtext_failure(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_longreprtext_failure(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             def test_func():
                 x = 1
@@ -982,8 +1021,8 @@ class TestReportContents:
         rep = reports[1]
         assert "assert 1 == 4" in rep.longreprtext
 
-    def test_captured_text(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_captured_text(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             import pytest
             import sys
@@ -1012,8 +1051,8 @@ class TestReportContents:
         assert call.capstderr == "setup: stderr\ncall: stderr\n"
         assert teardown.capstderr == "setup: stderr\ncall: stderr\nteardown: stderr\n"
 
-    def test_no_captured_text(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_no_captured_text(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             def test_func():
                 pass
@@ -1023,8 +1062,8 @@ class TestReportContents:
         assert rep.capstdout == ""
         assert rep.capstderr == ""
 
-    def test_longrepr_type(self, testdir) -> None:
-        reports = testdir.runitem(
+    def test_longrepr_type(self, pytester: Pytester) -> None:
+        reports = pytester.runitem(
             """
             import pytest
             def test_func():
@@ -1032,7 +1071,7 @@ class TestReportContents:
         """
         )
         rep = reports[1]
-        assert isinstance(rep.longrepr, _pytest._code.code.ExceptionRepr)
+        assert isinstance(rep.longrepr, ExceptionChainRepr)
 
 
 def test_outcome_exception_bad_msg() -> None:
index e90d761f633e12f98f405fe32e7bed1cda84f36f..e077ac41e2c2e7b012835750c0e2c9d2bea96635 100644 (file)
@@ -242,7 +242,9 @@ def test_setup_funcarg_setup_when_outer_scope_fails(pytester: Pytester) -> None:
 
 @pytest.mark.parametrize("arg", ["", "arg"])
 def test_setup_teardown_function_level_with_optional_argument(
-    pytester: Pytester, monkeypatch, arg: str,
+    pytester: Pytester,
+    monkeypatch,
+    arg: str,
 ) -> None:
     """Parameter to setup/teardown xunit-style functions parameter is now optional (#1728)."""
     import sys
diff --git a/testing/test_scope.py b/testing/test_scope.py
new file mode 100644 (file)
index 0000000..09ee134
--- /dev/null
@@ -0,0 +1,39 @@
+import re
+
+import pytest
+from _pytest.scope import Scope
+
+
+def test_ordering() -> None:
+    assert Scope.Session > Scope.Package
+    assert Scope.Package > Scope.Module
+    assert Scope.Module > Scope.Class
+    assert Scope.Class > Scope.Function
+
+
+def test_next_lower() -> None:
+    assert Scope.Session.next_lower() is Scope.Package
+    assert Scope.Package.next_lower() is Scope.Module
+    assert Scope.Module.next_lower() is Scope.Class
+    assert Scope.Class.next_lower() is Scope.Function
+
+    with pytest.raises(ValueError, match="Function is the lower-most scope"):
+        Scope.Function.next_lower()
+
+
+def test_next_higher() -> None:
+    assert Scope.Function.next_higher() is Scope.Class
+    assert Scope.Class.next_higher() is Scope.Module
+    assert Scope.Module.next_higher() is Scope.Package
+    assert Scope.Package.next_higher() is Scope.Session
+
+    with pytest.raises(ValueError, match="Session is the upper-most scope"):
+        Scope.Session.next_higher()
+
+
+def test_from_user() -> None:
+    assert Scope.from_user("module", "for parametrize", "some::id") is Scope.Module
+
+    expected_msg = "for parametrize from some::id got an unexpected scope value 'foo'"
+    with pytest.raises(pytest.fail.Exception, match=re.escape(expected_msg)):
+        Scope.from_user("foo", "for parametrize", "some::id")  # type:ignore[arg-type]
index 5389e5b2b19a406ad9b4156f8c988d5a91fd63a6..48dc08e8c8f450cf288bd971410c2fb3dbcee0b9 100644 (file)
@@ -227,7 +227,7 @@ class TestNewSession(SessionTests):
         started = reprec.getcalls("pytest_collectstart")
         finished = reprec.getreports("pytest_collectreport")
         assert len(started) == len(finished)
-        assert len(started) == 8
+        assert len(started) == 6
         colfail = [x for x in finished if x.failed]
         assert len(colfail) == 1
 
@@ -265,9 +265,9 @@ def test_plugin_already_exists(pytester: Pytester) -> None:
 
 def test_exclude(pytester: Pytester) -> None:
     hellodir = pytester.mkdir("hello")
-    hellodir.joinpath("test_hello.py").write_text("x y syntaxerror")
+    hellodir.joinpath("test_hello.py").write_text("x y syntaxerror", encoding="utf-8")
     hello2dir = pytester.mkdir("hello2")
-    hello2dir.joinpath("test_hello2.py").write_text("x y syntaxerror")
+    hello2dir.joinpath("test_hello2.py").write_text("x y syntaxerror", encoding="utf-8")
     pytester.makepyfile(test_ok="def test_pass(): pass")
     result = pytester.runpytest("--ignore=hello", "--ignore=hello2")
     assert result.ret == 0
@@ -276,13 +276,13 @@ def test_exclude(pytester: Pytester) -> None:
 
 def test_exclude_glob(pytester: Pytester) -> None:
     hellodir = pytester.mkdir("hello")
-    hellodir.joinpath("test_hello.py").write_text("x y syntaxerror")
+    hellodir.joinpath("test_hello.py").write_text("x y syntaxerror", encoding="utf-8")
     hello2dir = pytester.mkdir("hello2")
-    hello2dir.joinpath("test_hello2.py").write_text("x y syntaxerror")
+    hello2dir.joinpath("test_hello2.py").write_text("x y syntaxerror", encoding="utf-8")
     hello3dir = pytester.mkdir("hallo3")
-    hello3dir.joinpath("test_hello3.py").write_text("x y syntaxerror")
+    hello3dir.joinpath("test_hello3.py").write_text("x y syntaxerror", encoding="utf-8")
     subdir = pytester.mkdir("sub")
-    subdir.joinpath("test_hello4.py").write_text("x y syntaxerror")
+    subdir.joinpath("test_hello4.py").write_text("x y syntaxerror", encoding="utf-8")
     pytester.makepyfile(test_ok="def test_pass(): pass")
     result = pytester.runpytest("--ignore-glob=*h[ea]llo*")
     assert result.ret == 0
@@ -335,6 +335,54 @@ def test_sessionfinish_with_start(pytester: Pytester) -> None:
     assert res.ret == ExitCode.NO_TESTS_COLLECTED
 
 
+def test_collection_args_do_not_duplicate_modules(pytester: Pytester) -> None:
+    """Test that when multiple collection args are specified on the command line
+    for the same module, only a single Module collector is created.
+
+    Regression test for #723, #3358.
+    """
+    pytester.makepyfile(
+        **{
+            "d/test_it": """
+                def test_1(): pass
+                def test_2(): pass
+                """
+        }
+    )
+
+    result = pytester.runpytest(
+        "--collect-only",
+        "d/test_it.py::test_1",
+        "d/test_it.py::test_2",
+    )
+    result.stdout.fnmatch_lines(
+        [
+            "<Module d/test_it.py>",
+            "  <Function test_1>",
+            "  <Function test_2>",
+        ],
+        consecutive=True,
+    )
+
+    # Different, but related case.
+    result = pytester.runpytest(
+        "--collect-only",
+        "--keep-duplicates",
+        "d",
+        "d",
+    )
+    result.stdout.fnmatch_lines(
+        [
+            "<Module d/test_it.py>",
+            "  <Function test_1>",
+            "  <Function test_2>",
+            "  <Function test_1>",
+            "  <Function test_2>",
+        ],
+        consecutive=True,
+    )
+
+
 @pytest.mark.parametrize("path", ["root", "{relative}/root", "{environment}/root"])
 def test_rootdir_option_arg(
     pytester: Pytester, monkeypatch: MonkeyPatch, path: str
index fc66eb18e64e39a5edc79b88d51115b0fa3b9f91..6b80346108ff1ba9a64cfbb275b5df218590340e 100644 (file)
@@ -195,7 +195,8 @@ class TestEvaluation:
             def pytest_markeval_namespace():
                 return {"arg": "root"}
             """
-            )
+            ),
+            encoding="utf-8",
         )
         root.joinpath("test_root.py").write_text(
             textwrap.dedent(
@@ -206,7 +207,8 @@ class TestEvaluation:
             def test_root():
                 assert False
             """
-            )
+            ),
+            encoding="utf-8",
         )
         foo = root.joinpath("foo")
         foo.mkdir()
@@ -219,7 +221,8 @@ class TestEvaluation:
             def pytest_markeval_namespace():
                 return {"arg": "foo"}
             """
-            )
+            ),
+            encoding="utf-8",
         )
         foo.joinpath("test_foo.py").write_text(
             textwrap.dedent(
@@ -230,7 +233,8 @@ class TestEvaluation:
             def test_foo():
                 assert False
             """
-            )
+            ),
+            encoding="utf-8",
         )
         bar = root.joinpath("bar")
         bar.mkdir()
@@ -243,7 +247,8 @@ class TestEvaluation:
             def pytest_markeval_namespace():
                 return {"arg": "bar"}
             """
-            )
+            ),
+            encoding="utf-8",
         )
         bar.joinpath("test_bar.py").write_text(
             textwrap.dedent(
@@ -254,7 +259,8 @@ class TestEvaluation:
             def test_bar():
                 assert False
             """
-            )
+            ),
+            encoding="utf-8",
         )
 
         reprec = pytester.inline_run("-vs", "--capture=no")
@@ -441,10 +447,8 @@ class TestXFail:
         result = pytester.runpytest(p, "-rx")
         result.stdout.fnmatch_lines(
             [
-                "*test_one*test_this*",
-                "*NOTRUN*noway",
-                "*test_one*test_this_true*",
-                "*NOTRUN*condition:*True*",
+                "*test_one*test_this - reason: *NOTRUN* noway",
+                "*test_one*test_this_true - reason: *NOTRUN* condition: True",
                 "*1 passed*",
             ]
         )
@@ -461,9 +465,7 @@ class TestXFail:
         """
         )
         result = pytester.runpytest(p, "-rx")
-        result.stdout.fnmatch_lines(
-            ["*test_one*test_this*", "*NOTRUN*hello", "*1 xfailed*"]
-        )
+        result.stdout.fnmatch_lines(["*test_one*test_this*NOTRUN*hello", "*1 xfailed*"])
 
     def test_xfail_xpass(self, pytester: Pytester) -> None:
         p = pytester.makepyfile(
@@ -489,7 +491,7 @@ class TestXFail:
         result = pytester.runpytest(p)
         result.stdout.fnmatch_lines(["*1 xfailed*"])
         result = pytester.runpytest(p, "-rx")
-        result.stdout.fnmatch_lines(["*XFAIL*test_this*", "*reason:*hello*"])
+        result.stdout.fnmatch_lines(["*XFAIL*test_this*reason:*hello*"])
         result = pytester.runpytest(p, "--runxfail")
         result.stdout.fnmatch_lines(["*1 pass*"])
 
@@ -507,7 +509,7 @@ class TestXFail:
         result = pytester.runpytest(p)
         result.stdout.fnmatch_lines(["*1 xfailed*"])
         result = pytester.runpytest(p, "-rx")
-        result.stdout.fnmatch_lines(["*XFAIL*test_this*", "*reason:*hello*"])
+        result.stdout.fnmatch_lines(["*XFAIL*test_this*reason:*hello*"])
         result = pytester.runpytest(p, "--runxfail")
         result.stdout.fnmatch_lines(
             """
@@ -543,7 +545,7 @@ class TestXFail:
         """
         )
         result = pytester.runpytest(p, "-rxX")
-        result.stdout.fnmatch_lines(["*XFAIL*test_this*", "*NOTRUN*"])
+        result.stdout.fnmatch_lines(["*XFAIL*test_this*NOTRUN*"])
 
     def test_dynamic_xfail_set_during_funcarg_setup(self, pytester: Pytester) -> None:
         p = pytester.makepyfile(
@@ -622,7 +624,7 @@ class TestXFail:
         """
         )
         result = pytester.runpytest(p, "-rxX")
-        result.stdout.fnmatch_lines(["*XFAIL*", "*unsupported feature*"])
+        result.stdout.fnmatch_lines(["*XFAIL*unsupported feature*"])
         assert result.ret == 0
 
     @pytest.mark.parametrize("strict", [True, False])
@@ -633,7 +635,8 @@ class TestXFail:
 
             @pytest.mark.xfail(reason='unsupported feature', strict=%s)
             def test_foo():
-                with open('foo_executed', 'w'): pass  # make sure test executes
+                with open('foo_executed', 'w', encoding='utf-8'):
+                    pass  # make sure test executes
         """
             % strict
         )
@@ -861,9 +864,26 @@ class TestSkip:
                 pass
         """
         )
-        result = pytester.runpytest("-rs")
+        result = pytester.runpytest("-rs", "--strict-markers")
         result.stdout.fnmatch_lines(["*unconditional skip*", "*1 skipped*"])
 
+    def test_wrong_skip_usage(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            """
+            import pytest
+            @pytest.mark.skip(False, reason="I thought this was skipif")
+            def test_hello():
+                pass
+        """
+        )
+        result = pytester.runpytest()
+        result.stdout.fnmatch_lines(
+            [
+                "*TypeError: *__init__() got multiple values for argument 'reason'"
+                " - maybe you meant pytest.mark.skipif?"
+            ]
+        )
+
 
 class TestSkipif:
     def test_skipif_conditional(self, pytester: Pytester) -> None:
@@ -1128,19 +1148,30 @@ def test_errors_in_xfail_skip_expressions(pytester: Pytester) -> None:
         markline = markline[5:]
     elif sys.version_info >= (3, 8) or hasattr(sys, "pypy_version_info"):
         markline = markline[4:]
-    result.stdout.fnmatch_lines(
-        [
+
+    if sys.version_info[:2] >= (3, 10):
+        expected = [
             "*ERROR*test_nameerror*",
-            "*evaluating*skipif*condition*",
             "*asd*",
-            "*ERROR*test_syntax*",
-            "*evaluating*xfail*condition*",
-            "    syntax error",
-            markline,
-            "SyntaxError: invalid syntax",
-            "*1 pass*2 errors*",
+            "",
+            "During handling of the above exception, another exception occurred:",
         ]
-    )
+    else:
+        expected = [
+            "*ERROR*test_nameerror*",
+        ]
+
+    expected += [
+        "*evaluating*skipif*condition*",
+        "*asd*",
+        "*ERROR*test_syntax*",
+        "*evaluating*xfail*condition*",
+        "    syntax error",
+        markline,
+        "SyntaxError: invalid syntax",
+        "*1 pass*2 errors*",
+    ]
+    result.stdout.fnmatch_lines(expected)
 
 
 def test_xfail_skipif_with_globals(pytester: Pytester) -> None:
@@ -1157,7 +1188,7 @@ def test_xfail_skipif_with_globals(pytester: Pytester) -> None:
     """
     )
     result = pytester.runpytest("-rsx")
-    result.stdout.fnmatch_lines(["*SKIP*x == 3*", "*XFAIL*test_boolean*", "*x == 3*"])
+    result.stdout.fnmatch_lines(["*SKIP*x == 3*", "*XFAIL*test_boolean*x == 3*"])
 
 
 def test_default_markers(pytester: Pytester) -> None:
@@ -1269,8 +1300,7 @@ class TestBooleanCondition:
         result = pytester.runpytest("-rxs")
         result.stdout.fnmatch_lines(
             """
-            *XFAIL*
-            *True123*
+            *XFAIL*True123*
             *1 xfail*
         """
         )
@@ -1287,7 +1317,7 @@ def test_xfail_item(pytester: Pytester) -> None:
             def runtest(self):
                 pytest.xfail("Expected Failure")
 
-        def pytest_collect_file(path, parent):
+        def pytest_collect_file(file_path, parent):
             return MyItem.from_parent(name="foo", parent=parent)
     """
     )
@@ -1311,7 +1341,7 @@ def test_module_level_skip_error(pytester: Pytester) -> None:
     )
     result = pytester.runpytest()
     result.stdout.fnmatch_lines(
-        ["*Using pytest.skip outside of a test is not allowed*"]
+        ["*Using pytest.skip outside of a test will skip the entire module*"]
     )
 
 
@@ -1361,7 +1391,7 @@ def test_mark_xfail_item(pytester: Pytester) -> None:
             def runtest(self):
                 assert False
 
-        def pytest_collect_file(path, parent):
+        def pytest_collect_file(file_path, parent):
             return MyItem.from_parent(name="foo", parent=parent)
     """
     )
@@ -1414,3 +1444,113 @@ def test_relpath_rootdir(pytester: Pytester) -> None:
     result.stdout.fnmatch_lines(
         ["SKIPPED [[]1[]] tests/test_1.py:2: unconditional skip"]
     )
+
+
+def test_skip_from_fixture(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        **{
+            "tests/test_1.py": """
+        import pytest
+        def test_pass(arg):
+            pass
+        @pytest.fixture
+        def arg():
+            condition = True
+            if condition:
+                pytest.skip("Fixture conditional skip")
+            """,
+        }
+    )
+    result = pytester.runpytest("-rs", "tests/test_1.py", "--rootdir=tests")
+    result.stdout.fnmatch_lines(
+        ["SKIPPED [[]1[]] tests/test_1.py:2: Fixture conditional skip"]
+    )
+
+
+def test_skip_using_reason_works_ok(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        """
+        import pytest
+
+        def test_skipping_reason():
+            pytest.skip(reason="skippedreason")
+        """
+    )
+    result = pytester.runpytest(p)
+    result.stdout.no_fnmatch_line("*PytestDeprecationWarning*")
+    result.assert_outcomes(skipped=1)
+
+
+def test_fail_using_reason_works_ok(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        """
+        import pytest
+
+        def test_failing_reason():
+            pytest.fail(reason="failedreason")
+        """
+    )
+    result = pytester.runpytest(p)
+    result.stdout.no_fnmatch_line("*PytestDeprecationWarning*")
+    result.assert_outcomes(failed=1)
+
+
+def test_fail_fails_with_msg_and_reason(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        """
+        import pytest
+
+        def test_fail_both_arguments():
+            pytest.fail(reason="foo", msg="bar")
+        """
+    )
+    result = pytester.runpytest(p)
+    result.stdout.fnmatch_lines(
+        "*UsageError: Passing both ``reason`` and ``msg`` to pytest.fail(...) is not permitted.*"
+    )
+    result.assert_outcomes(failed=1)
+
+
+def test_skip_fails_with_msg_and_reason(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        """
+        import pytest
+
+        def test_skip_both_arguments():
+            pytest.skip(reason="foo", msg="bar")
+        """
+    )
+    result = pytester.runpytest(p)
+    result.stdout.fnmatch_lines(
+        "*UsageError: Passing both ``reason`` and ``msg`` to pytest.skip(...) is not permitted.*"
+    )
+    result.assert_outcomes(failed=1)
+
+
+def test_exit_with_msg_and_reason_fails(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        """
+        import pytest
+
+        def test_exit_both_arguments():
+            pytest.exit(reason="foo", msg="bar")
+        """
+    )
+    result = pytester.runpytest(p)
+    result.stdout.fnmatch_lines(
+        "*UsageError: cannot pass reason and msg to exit(), `msg` is deprecated, use `reason`.*"
+    )
+    result.assert_outcomes(failed=1)
+
+
+def test_exit_with_reason_works_ok(pytester: Pytester) -> None:
+    p = pytester.makepyfile(
+        """
+        import pytest
+
+        def test_exit_reason_only():
+            pytest.exit(reason="foo")
+        """
+    )
+    result = pytester.runpytest(p)
+    result.stdout.fnmatch_lines("*_pytest.outcomes.Exit: foo*")
diff --git a/testing/test_stash.py b/testing/test_stash.py
new file mode 100644 (file)
index 0000000..2c9df48
--- /dev/null
@@ -0,0 +1,67 @@
+import pytest
+from _pytest.stash import Stash
+from _pytest.stash import StashKey
+
+
+def test_stash() -> None:
+    stash = Stash()
+
+    assert len(stash) == 0
+    assert not stash
+
+    key1 = StashKey[str]()
+    key2 = StashKey[int]()
+
+    # Basic functionality - single key.
+    assert key1 not in stash
+    stash[key1] = "hello"
+    assert key1 in stash
+    assert stash[key1] == "hello"
+    assert stash.get(key1, None) == "hello"
+    stash[key1] = "world"
+    assert stash[key1] == "world"
+    # Has correct type (no mypy error).
+    stash[key1] + "string"
+    assert len(stash) == 1
+    assert stash
+
+    # No interaction with another key.
+    assert key2 not in stash
+    assert stash.get(key2, None) is None
+    with pytest.raises(KeyError):
+        stash[key2]
+    with pytest.raises(KeyError):
+        del stash[key2]
+    stash[key2] = 1
+    assert stash[key2] == 1
+    # Has correct type (no mypy error).
+    stash[key2] + 20
+    del stash[key1]
+    with pytest.raises(KeyError):
+        del stash[key1]
+    with pytest.raises(KeyError):
+        stash[key1]
+
+    # setdefault
+    stash[key1] = "existing"
+    assert stash.setdefault(key1, "default") == "existing"
+    assert stash[key1] == "existing"
+    key_setdefault = StashKey[bytes]()
+    assert stash.setdefault(key_setdefault, b"default") == b"default"
+    assert stash[key_setdefault] == b"default"
+    assert len(stash) == 3
+    assert stash
+
+    # Can't accidentally add attributes to stash object itself.
+    with pytest.raises(AttributeError):
+        stash.foo = "nope"  # type: ignore[attr-defined]
+
+    # No interaction with another stash.
+    stash2 = Stash()
+    key3 = StashKey[int]()
+    assert key2 not in stash2
+    stash2[key2] = 100
+    stash2[key3] = 200
+    assert stash2[key2] + stash2[key3] == 300
+    assert stash[key2] == 1
+    assert key3 not in stash
index ff2ec16b707742e6338f97a70b62a23d9b82ce71..85e38c7d568133eaee2b8b6158632f5866f198af 100644 (file)
@@ -1,6 +1,10 @@
+from pathlib import Path
+
 import pytest
+from _pytest.cacheprovider import Cache
 from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pytester import Pytester
+from _pytest.stepwise import STEPWISE_CACHE_DIR
 
 
 @pytest.fixture
@@ -138,7 +142,12 @@ def test_fail_and_continue_with_stepwise(stepwise_pytester: Pytester) -> None:
 @pytest.mark.parametrize("stepwise_skip", ["--stepwise-skip", "--sw-skip"])
 def test_run_with_skip_option(stepwise_pytester: Pytester, stepwise_skip: str) -> None:
     result = stepwise_pytester.runpytest(
-        "-v", "--strict-markers", "--stepwise", stepwise_skip, "--fail", "--fail-last",
+        "-v",
+        "--strict-markers",
+        "--stepwise",
+        stepwise_skip,
+        "--fail",
+        "--fail-last",
     )
     assert _strip_resource_warnings(result.stderr.lines) == []
 
@@ -243,3 +252,106 @@ def test_xfail_handling(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
             "* 2 passed, 1 deselected, 1 xfailed in *",
         ]
     )
+
+
+def test_stepwise_skip_is_independent(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        def test_one():
+            assert False
+
+        def test_two():
+            assert False
+
+        def test_three():
+            assert False
+
+        """
+    )
+    result = pytester.runpytest("--tb", "no", "--stepwise-skip")
+    result.assert_outcomes(failed=2)
+    result.stdout.fnmatch_lines(
+        [
+            "FAILED test_stepwise_skip_is_independent.py::test_one - assert False",
+            "FAILED test_stepwise_skip_is_independent.py::test_two - assert False",
+            "*Interrupted: Test failed, continuing from this test next run.*",
+        ]
+    )
+
+
+def test_sw_skip_help(pytester: Pytester) -> None:
+    result = pytester.runpytest("-h")
+    result.stdout.fnmatch_lines("*Implicitly enables --stepwise.")
+
+
+def test_stepwise_xdist_dont_store_lastfailed(pytester: Pytester) -> None:
+    pytester.makefile(
+        ext=".ini",
+        pytest=f"[pytest]\ncache_dir = {pytester.path}\n",
+    )
+
+    pytester.makepyfile(
+        conftest="""
+import pytest
+
+@pytest.hookimpl(tryfirst=True)
+def pytest_configure(config) -> None:
+    config.workerinput = True
+"""
+    )
+    pytester.makepyfile(
+        test_one="""
+def test_one():
+    assert False
+"""
+    )
+    result = pytester.runpytest("--stepwise")
+    assert result.ret == pytest.ExitCode.INTERRUPTED
+
+    stepwise_cache_file = (
+        pytester.path / Cache._CACHE_PREFIX_VALUES / STEPWISE_CACHE_DIR
+    )
+    assert not Path(stepwise_cache_file).exists()
+
+
+def test_disabled_stepwise_xdist_dont_clear_cache(pytester: Pytester) -> None:
+    pytester.makefile(
+        ext=".ini",
+        pytest=f"[pytest]\ncache_dir = {pytester.path}\n",
+    )
+
+    stepwise_cache_file = (
+        pytester.path / Cache._CACHE_PREFIX_VALUES / STEPWISE_CACHE_DIR
+    )
+    stepwise_cache_dir = stepwise_cache_file.parent
+    stepwise_cache_dir.mkdir(exist_ok=True, parents=True)
+
+    stepwise_cache_file_relative = f"{Cache._CACHE_PREFIX_VALUES}/{STEPWISE_CACHE_DIR}"
+
+    expected_value = '"test_one.py::test_one"'
+    content = {f"{stepwise_cache_file_relative}": expected_value}
+
+    pytester.makefile(ext="", **content)
+
+    pytester.makepyfile(
+        conftest="""
+import pytest
+
+@pytest.hookimpl(tryfirst=True)
+def pytest_configure(config) -> None:
+    config.workerinput = True
+"""
+    )
+    pytester.makepyfile(
+        test_one="""
+def test_one():
+    assert True
+"""
+    )
+    result = pytester.runpytest()
+    assert result.ret == 0
+
+    assert Path(stepwise_cache_file).exists()
+    with stepwise_cache_file.open(encoding="utf-8") as file_handle:
+        observed_value = file_handle.readlines()
+    assert [expected_value] == observed_value
diff --git a/testing/test_store.py b/testing/test_store.py
deleted file mode 100644 (file)
index b6d4208..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-import pytest
-from _pytest.store import Store
-from _pytest.store import StoreKey
-
-
-def test_store() -> None:
-    store = Store()
-
-    key1 = StoreKey[str]()
-    key2 = StoreKey[int]()
-
-    # Basic functionality - single key.
-    assert key1 not in store
-    store[key1] = "hello"
-    assert key1 in store
-    assert store[key1] == "hello"
-    assert store.get(key1, None) == "hello"
-    store[key1] = "world"
-    assert store[key1] == "world"
-    # Has correct type (no mypy error).
-    store[key1] + "string"
-
-    # No interaction with another key.
-    assert key2 not in store
-    assert store.get(key2, None) is None
-    with pytest.raises(KeyError):
-        store[key2]
-    with pytest.raises(KeyError):
-        del store[key2]
-    store[key2] = 1
-    assert store[key2] == 1
-    # Has correct type (no mypy error).
-    store[key2] + 20
-    del store[key1]
-    with pytest.raises(KeyError):
-        del store[key1]
-    with pytest.raises(KeyError):
-        store[key1]
-
-    # setdefault
-    store[key1] = "existing"
-    assert store.setdefault(key1, "default") == "existing"
-    assert store[key1] == "existing"
-    key_setdefault = StoreKey[bytes]()
-    assert store.setdefault(key_setdefault, b"default") == b"default"
-    assert store[key_setdefault] == b"default"
-
-    # Can't accidentally add attributes to store object itself.
-    with pytest.raises(AttributeError):
-        store.foo = "nope"  # type: ignore[attr-defined]
-
-    # No interaction with anoter store.
-    store2 = Store()
-    key3 = StoreKey[int]()
-    assert key2 not in store2
-    store2[key2] = 100
-    store2[key3] = 200
-    assert store2[key2] + store2[key3] == 300
-    assert store[key2] == 1
-    assert key3 not in store
index 5e833f40d4395928511bf17b743fcae6b9d24425..7c2f7c94a50c7b9e22bd84b0a3796e9e98ee20f7 100644 (file)
@@ -12,7 +12,6 @@ from typing import List
 from typing import Tuple
 
 import pluggy
-import py
 
 import _pytest.config
 import _pytest.terminal
@@ -133,7 +132,7 @@ class TestTerminal:
         item.config.pluginmanager.register(tr)
         location = item.reportinfo()
         tr.config.hook.pytest_runtest_logstart(
-            nodeid=item.nodeid, location=location, fspath=str(item.fspath)
+            nodeid=item.nodeid, location=location, fspath=str(item.path)
         )
         linecomp.assert_contains_lines(["*test_show_runtest_logstart.py*"])
 
@@ -245,7 +244,8 @@ class TestTerminal:
                     def test_method(self):
                         pass
                 """
-            )
+            ),
+            encoding="utf-8",
         )
         result = pytester.runpytest("-vv")
         assert result.ret == 0
@@ -386,21 +386,57 @@ class TestTerminal:
 
             def test_10():
                 pytest.xfail("It's 🕙 o'clock")
+
+            @pytest.mark.skip(
+                reason="1 cannot do foobar because baz is missing due to I don't know what"
+            )
+            def test_long_skip():
+                pass
+
+            @pytest.mark.xfail(
+                reason="2 cannot do foobar because baz is missing due to I don't know what"
+            )
+            def test_long_xfail():
+                print(1 / 0)
         """
         )
+
+        common_output = [
+            "test_verbose_skip_reason.py::test_1 SKIPPED (123) *",
+            "test_verbose_skip_reason.py::test_2 XPASS (456) *",
+            "test_verbose_skip_reason.py::test_3 XFAIL (789) *",
+            "test_verbose_skip_reason.py::test_4 XFAIL  *",
+            "test_verbose_skip_reason.py::test_5 SKIPPED (unconditional skip) *",
+            "test_verbose_skip_reason.py::test_6 XPASS  *",
+            "test_verbose_skip_reason.py::test_7 SKIPPED  *",
+            "test_verbose_skip_reason.py::test_8 SKIPPED (888 is great) *",
+            "test_verbose_skip_reason.py::test_9 XFAIL  *",
+            "test_verbose_skip_reason.py::test_10 XFAIL (It's 🕙 o'clock) *",
+        ]
+
         result = pytester.runpytest("-v")
         result.stdout.fnmatch_lines(
-            [
-                "test_verbose_skip_reason.py::test_1 SKIPPED (123) *",
-                "test_verbose_skip_reason.py::test_2 XPASS (456) *",
-                "test_verbose_skip_reason.py::test_3 XFAIL (789) *",
-                "test_verbose_skip_reason.py::test_4 XFAIL  *",
-                "test_verbose_skip_reason.py::test_5 SKIPPED (unconditional skip) *",
-                "test_verbose_skip_reason.py::test_6 XPASS  *",
-                "test_verbose_skip_reason.py::test_7 SKIPPED  *",
-                "test_verbose_skip_reason.py::test_8 SKIPPED (888 is great) *",
-                "test_verbose_skip_reason.py::test_9 XFAIL  *",
-                "test_verbose_skip_reason.py::test_10 XFAIL (It's 🕙 o'clock) *",
+            common_output
+            + [
+                "test_verbose_skip_reason.py::test_long_skip SKIPPED (1 cannot *...) *",
+                "test_verbose_skip_reason.py::test_long_xfail XFAIL (2 cannot *...) *",
+            ]
+        )
+
+        result = pytester.runpytest("-vv")
+        result.stdout.fnmatch_lines(
+            common_output
+            + [
+                (
+                    "test_verbose_skip_reason.py::test_long_skip SKIPPED"
+                    " (1 cannot do foobar"
+                ),
+                "because baz is missing due to I don't know what) *",
+                (
+                    "test_verbose_skip_reason.py::test_long_xfail XFAIL"
+                    " (2 cannot do foobar"
+                ),
+                "because baz is missing due to I don't know what) *",
             ]
         )
 
@@ -683,7 +719,7 @@ class TestTerminalFunctional:
                     pass
            """
         )
-        result = pytester.runpytest("-k", "test_two:", testpath)
+        result = pytester.runpytest("-k", "test_t", testpath)
         result.stdout.fnmatch_lines(
             ["collected 3 items / 1 deselected / 2 selected", "*test_deselected.py ..*"]
         )
@@ -750,6 +786,33 @@ class TestTerminalFunctional:
         result.stdout.no_fnmatch_line("*= 1 deselected =*")
         assert result.ret == 0
 
+    def test_selected_count_with_error(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
+            test_selected_count_3="""
+                def test_one():
+                    pass
+                def test_two():
+                    pass
+                def test_three():
+                    pass
+            """,
+            test_selected_count_error="""
+                5/0
+                def test_foo():
+                    pass
+                def test_bar():
+                    pass
+            """,
+        )
+        result = pytester.runpytest("-k", "test_t")
+        result.stdout.fnmatch_lines(
+            [
+                "collected 3 items / 1 error / 1 deselected / 2 selected",
+                "* ERROR collecting test_selected_count_error.py *",
+            ]
+        )
+        assert result.ret == ExitCode.INTERRUPTED
+
     def test_no_skip_summary_if_failure(self, pytester: Pytester) -> None:
         pytester.makepyfile(
             """
@@ -800,12 +863,11 @@ class TestTerminalFunctional:
         result.stdout.fnmatch_lines(
             [
                 "*===== test session starts ====*",
-                "platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
+                "platform %s -- Python %s*pytest-%s**pluggy-%s"
                 % (
                     sys.platform,
                     verinfo,
                     pytest.__version__,
-                    py.__version__,
                     pluggy.__version__,
                 ),
                 "*test_header_trailer_info.py .*",
@@ -828,12 +890,11 @@ class TestTerminalFunctional:
         result = pytester.runpytest("--no-header")
         verinfo = ".".join(map(str, sys.version_info[:3]))
         result.stdout.no_fnmatch_line(
-            "platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
+            "platform %s -- Python %s*pytest-%s**pluggy-%s"
             % (
                 sys.platform,
                 verinfo,
                 pytest.__version__,
-                py.__version__,
                 pluggy.__version__,
             )
         )
@@ -851,7 +912,7 @@ class TestTerminalFunctional:
         # with configfile
         pytester.makeini("""[pytest]""")
         result = pytester.runpytest()
-        result.stdout.fnmatch_lines(["rootdir: *test_header0configfile: tox.ini"])
+        result.stdout.fnmatch_lines(["rootdir: *test_header0", "configfile: tox.ini"])
 
         # with testpaths option, and not passing anything in the command-line
         pytester.makeini(
@@ -862,12 +923,12 @@ class TestTerminalFunctional:
         )
         result = pytester.runpytest()
         result.stdout.fnmatch_lines(
-            ["rootdir: *test_header0, configfile: tox.ini, testpaths: tests, gui"]
+            ["rootdir: *test_header0", "configfile: tox.ini", "testpaths: tests, gui"]
         )
 
         # with testpaths option, passing directory in command-line: do not show testpaths then
         result = pytester.runpytest("tests")
-        result.stdout.fnmatch_lines(["rootdir: *test_header0configfile: tox.ini"])
+        result.stdout.fnmatch_lines(["rootdir: *test_header0", "configfile: tox.ini"])
 
     def test_header_absolute_testpath(
         self, pytester: Pytester, monkeypatch: MonkeyPatch
@@ -886,9 +947,9 @@ class TestTerminalFunctional:
         result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             [
-                "rootdir: *absolute_testpath0, configfile: pyproject.toml, testpaths: {}".format(
-                    tests
-                )
+                "rootdir: *absolute_testpath0",
+                "configfile: pyproject.toml",
+                f"testpaths: {tests}",
             ]
         )
 
@@ -940,6 +1001,22 @@ class TestTerminalFunctional:
             ]
         )
 
+    def test_noshowlocals_addopts_override(self, pytester: Pytester) -> None:
+        pytester.makeini("[pytest]\naddopts=--showlocals")
+        p1 = pytester.makepyfile(
+            """
+            def test_noshowlocals():
+                x = 3
+                y = "x" * 5000
+                assert 0
+        """
+        )
+
+        # Override global --showlocals for py.test via arg
+        result = pytester.runpytest(p1, "--no-showlocals")
+        result.stdout.no_fnmatch_line("x* = 3")
+        result.stdout.no_fnmatch_line("y* = 'xxxxxx*")
+
     def test_showlocals_short(self, pytester: Pytester) -> None:
         p1 = pytester.makepyfile(
             """
@@ -1036,8 +1113,8 @@ class TestTerminalFunctional:
     def test_report_collectionfinish_hook(self, pytester: Pytester, params) -> None:
         pytester.makeconftest(
             """
-            def pytest_report_collectionfinish(config, startdir, items):
-                return ['hello from hook: {0} items'.format(len(items))]
+            def pytest_report_collectionfinish(config, start_path, items):
+                return [f'hello from hook: {len(items)} items']
         """
         )
         pytester.makepyfile(
@@ -1081,7 +1158,21 @@ class TestTerminalFunctional:
         assert result.stdout.lines.count(expected) == 1
 
 
-def test_fail_extra_reporting(pytester: Pytester, monkeypatch) -> None:
+@pytest.mark.parametrize(
+    ("use_ci", "expected_message"),
+    (
+        (True, f"- AssertionError: {'this_failed'*100}"),
+        (False, "- AssertionError: this_failedt..."),
+    ),
+    ids=("on CI", "not on CI"),
+)
+def test_fail_extra_reporting(
+    pytester: Pytester, monkeypatch, use_ci: bool, expected_message: str
+) -> None:
+    if use_ci:
+        monkeypatch.setenv("CI", "true")
+    else:
+        monkeypatch.delenv("CI", raising=False)
     monkeypatch.setenv("COLUMNS", "80")
     pytester.makepyfile("def test_this(): assert 0, 'this_failed' * 100")
     result = pytester.runpytest("-rN")
@@ -1090,7 +1181,7 @@ def test_fail_extra_reporting(pytester: Pytester, monkeypatch) -> None:
     result.stdout.fnmatch_lines(
         [
             "*test summary*",
-            "FAILED test_fail_extra_reporting.py::test_this - AssertionError: this_failedt...",
+            f"FAILED test_fail_extra_reporting.py::test_this {expected_message}",
         ]
     )
 
@@ -1177,14 +1268,14 @@ def test_color_yes(pytester: Pytester, color_mapping) -> None:
                 "=*= FAILURES =*=",
                 "{red}{bold}_*_ test_this _*_{reset}",
                 "",
-                "    {kw}def{hl-reset} {function}test_this{hl-reset}():",
-                ">       fail()",
+                "    {kw}def{hl-reset} {function}test_this{hl-reset}():{endline}",
+                ">       fail(){endline}",
                 "",
                 "{bold}{red}test_color_yes.py{reset}:5: ",
                 "_ _ * _ _*",
                 "",
-                "    {kw}def{hl-reset} {function}fail{hl-reset}():",
-                ">       {kw}assert{hl-reset} {number}0{hl-reset}",
+                "    {kw}def{hl-reset} {function}fail{hl-reset}():{endline}",
+                ">       {kw}assert{hl-reset} {number}0{hl-reset}{endline}",
                 "{bold}{red}E       assert 0{reset}",
                 "",
                 "{bold}{red}test_color_yes.py{reset}:2: AssertionError",
@@ -1204,9 +1295,9 @@ def test_color_yes(pytester: Pytester, color_mapping) -> None:
                 "=*= FAILURES =*=",
                 "{red}{bold}_*_ test_this _*_{reset}",
                 "{bold}{red}test_color_yes.py{reset}:5: in test_this",
-                "    fail()",
+                "    fail(){endline}",
                 "{bold}{red}test_color_yes.py{reset}:2: in fail",
-                "    {kw}assert{hl-reset} {number}0{hl-reset}",
+                "    {kw}assert{hl-reset} {number}0{hl-reset}{endline}",
                 "{bold}{red}E   assert 0{reset}",
                 "{red}=*= {red}{bold}1 failed{reset}{red} in *s{reset}{red} =*={reset}",
             ]
@@ -1451,6 +1542,19 @@ class TestGenericReporting:
         s = result.stdout.str()
         assert "def test_func2" not in s
 
+    def test_tb_crashline_pytrace_false(self, pytester: Pytester, option) -> None:
+        p = pytester.makepyfile(
+            """
+            import pytest
+            def test_func1():
+                pytest.fail('test_func1', pytrace=False)
+        """
+        )
+        result = pytester.runpytest("--tb=line")
+        result.stdout.str()
+        bn = p.name
+        result.stdout.fnmatch_lines(["*%s:3: Failed: test_func1" % bn])
+
     def test_pytest_report_header(self, pytester: Pytester, option) -> None:
         pytester.makeconftest(
             """
@@ -1462,9 +1566,10 @@ class TestGenericReporting:
         )
         pytester.mkdir("a").joinpath("conftest.py").write_text(
             """
-def pytest_report_header(config, startdir):
-    return ["line1", str(startdir)]
-"""
+def pytest_report_header(config, start_path):
+    return ["line1", str(start_path)]
+""",
+            encoding="utf-8",
         )
         result = pytester.runpytest("a")
         result.stdout.fnmatch_lines(["*hello: 42*", "line1", str(pytester.path)])
@@ -1568,7 +1673,7 @@ def test_fdopen_kept_alive_issue124(pytester: Pytester) -> None:
         import os, sys
         k = []
         def test_open_file_and_keep_alive(capfd):
-            stdout = os.fdopen(1, 'w', 1)
+            stdout = os.fdopen(1, 'w', buffering=1, encoding='utf-8')
             k.append(stdout)
 
         def test_close_kept_alive_file():
@@ -1618,7 +1723,7 @@ def test_terminal_summary(pytester: Pytester) -> None:
     )
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::UserWarning")
 def test_terminal_summary_warnings_are_displayed(pytester: Pytester) -> None:
     """Test that warnings emitted during pytest_terminal_summary are displayed.
     (#1305).
@@ -1655,7 +1760,7 @@ def test_terminal_summary_warnings_are_displayed(pytester: Pytester) -> None:
     assert stdout.count("=== warnings summary ") == 2
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::UserWarning")
 def test_terminal_summary_warnings_header_once(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
@@ -2125,6 +2230,24 @@ class TestProgressOutputStyle:
         output = pytester.runpytest("--capture=no")
         output.stdout.no_fnmatch_line("*%]*")
 
+    def test_capture_no_progress_enabled(
+        self, many_tests_files, pytester: Pytester
+    ) -> None:
+        pytester.makeini(
+            """
+            [pytest]
+            console_output_style = progress-even-when-capture-no
+        """
+        )
+        output = pytester.runpytest("-s")
+        output.stdout.re_match_lines(
+            [
+                r"test_bar.py \.{10} \s+ \[ 50%\]",
+                r"test_foo.py \.{5} \s+ \[ 75%\]",
+                r"test_foobar.py \.{5} \s+ \[100%\]",
+            ]
+        )
+
 
 class TestProgressWithTeardown:
     """Ensure we show the correct percentages for tests that fail during teardown (#3088)"""
@@ -2230,19 +2353,19 @@ def test_skip_reasons_folding() -> None:
 
     ev1 = cast(CollectReport, X())
     ev1.when = "execute"
-    ev1.skipped = True
+    ev1.skipped = True  # type: ignore[misc]
     ev1.longrepr = longrepr
 
     ev2 = cast(CollectReport, X())
     ev2.when = "execute"
     ev2.longrepr = longrepr
-    ev2.skipped = True
+    ev2.skipped = True  # type: ignore[misc]
 
     # ev3 might be a collection report
     ev3 = cast(CollectReport, X())
     ev3.when = "collect"
     ev3.longrepr = longrepr
-    ev3.skipped = True
+    ev3.skipped = True  # type: ignore[misc]
 
     values = _folded_skips(Path.cwd(), [ev1, ev2, ev3])
     assert len(values) == 1
@@ -2261,7 +2384,7 @@ def test_line_with_reprcrash(monkeypatch: MonkeyPatch) -> None:
     def mock_get_pos(*args):
         return mocked_pos
 
-    monkeypatch.setattr(_pytest.terminal, "_get_pos", mock_get_pos)
+    monkeypatch.setattr(_pytest.terminal, "_get_node_id_with_markup", mock_get_pos)
 
     class config:
         pass
@@ -2275,10 +2398,16 @@ def test_line_with_reprcrash(monkeypatch: MonkeyPatch) -> None:
                 pass
 
     def check(msg, width, expected):
+        class DummyTerminalWriter:
+            fullwidth = width
+
+            def markup(self, word: str, **markup: str):
+                return word
+
         __tracebackhide__ = True
         if msg:
             rep.longrepr.reprcrash.message = msg  # type: ignore
-        actual = _get_line_with_reprcrash_message(config, rep(), width)  # type: ignore
+        actual = _get_line_with_reprcrash_message(config, rep(), DummyTerminalWriter(), {})  # type: ignore
 
         assert actual == expected
         if actual != f"{mocked_verbose_word} {mocked_pos}":
@@ -2378,8 +2507,8 @@ class TestCodeHighlight:
         result.stdout.fnmatch_lines(
             color_mapping.format_for_fnmatch(
                 [
-                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():",
-                    ">       {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}",
+                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():{endline}",
+                    ">       {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}{endline}",
                     "{bold}{red}E       assert 1 == 10{reset}",
                 ]
             )
@@ -2400,14 +2529,68 @@ class TestCodeHighlight:
         result.stdout.fnmatch_lines(
             color_mapping.format_for_fnmatch(
                 [
-                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():",
+                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():{endline}",
                     "        {print}print{hl-reset}({str}'''{hl-reset}{str}{hl-reset}",
-                    ">   {str}    {hl-reset}{str}'''{hl-reset}); {kw}assert{hl-reset} {number}0{hl-reset}",
+                    ">   {str}    {hl-reset}{str}'''{hl-reset}); {kw}assert{hl-reset} {number}0{hl-reset}{endline}",
                     "{bold}{red}E       assert 0{reset}",
                 ]
             )
         )
 
+    def test_code_highlight_custom_theme(
+        self, pytester: Pytester, color_mapping, monkeypatch: MonkeyPatch
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_foo():
+                assert 1 == 10
+        """
+        )
+        monkeypatch.setenv("PYTEST_THEME", "solarized-dark")
+        monkeypatch.setenv("PYTEST_THEME_MODE", "dark")
+        result = pytester.runpytest("--color=yes")
+        result.stdout.fnmatch_lines(
+            color_mapping.format_for_fnmatch(
+                [
+                    "    {kw}def{hl-reset} {function}test_foo{hl-reset}():{endline}",
+                    ">       {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}{endline}",
+                    "{bold}{red}E       assert 1 == 10{reset}",
+                ]
+            )
+        )
+
+    def test_code_highlight_invalid_theme(
+        self, pytester: Pytester, color_mapping, monkeypatch: MonkeyPatch
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_foo():
+                assert 1 == 10
+        """
+        )
+        monkeypatch.setenv("PYTEST_THEME", "invalid")
+        result = pytester.runpytest_subprocess("--color=yes")
+        result.stderr.fnmatch_lines(
+            "ERROR: PYTEST_THEME environment variable had an invalid value: 'invalid'. "
+            "Only valid pygment styles are allowed."
+        )
+
+    def test_code_highlight_invalid_theme_mode(
+        self, pytester: Pytester, color_mapping, monkeypatch: MonkeyPatch
+    ) -> None:
+        pytester.makepyfile(
+            """
+            def test_foo():
+                assert 1 == 10
+        """
+        )
+        monkeypatch.setenv("PYTEST_THEME_MODE", "invalid")
+        result = pytester.runpytest_subprocess("--color=yes")
+        result.stderr.fnmatch_lines(
+            "ERROR: PYTEST_THEME_MODE environment variable had an invalid value: 'invalid'. "
+            "The only allowed values are 'dark' and 'light'."
+        )
+
 
 def test_raw_skip_reason_skipped() -> None:
     report = SimpleNamespace()
index 399692bc9637bae9891e73bf28c58e42b2d6de28..5b7519f27d87a83dcd562f2f6ce7f53de5947a3d 100644 (file)
@@ -8,7 +8,7 @@ if sys.version_info < (3, 8):
     pytest.skip("threadexception plugin needs Python>=3.8", allow_module_level=True)
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnhandledThreadExceptionWarning")
 def test_unhandled_thread_exception(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_it="""
@@ -42,7 +42,7 @@ def test_unhandled_thread_exception(pytester: Pytester) -> None:
     )
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnhandledThreadExceptionWarning")
 def test_unhandled_thread_exception_in_setup(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_it="""
@@ -78,7 +78,7 @@ def test_unhandled_thread_exception_in_setup(pytester: Pytester) -> None:
     )
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnhandledThreadExceptionWarning")
 def test_unhandled_thread_exception_in_teardown(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_it="""
index d123287aa38f93a5766ad030777d087d0cd2deb7..1e1446af1270248d3f283a9c90100c82e71896a0 100644 (file)
@@ -1,16 +1,18 @@
+import dataclasses
 import os
 import stat
 import sys
+import warnings
 from pathlib import Path
 from typing import Callable
 from typing import cast
 from typing import List
-
-import attr
+from typing import Union
 
 import pytest
 from _pytest import pathlib
 from _pytest.config import Config
+from _pytest.monkeypatch import MonkeyPatch
 from _pytest.pathlib import cleanup_numbered_dir
 from _pytest.pathlib import create_cleanup_lock
 from _pytest.pathlib import make_numbered_dir
@@ -20,19 +22,18 @@ from _pytest.pathlib import register_cleanup_lock_removal
 from _pytest.pathlib import rm_rf
 from _pytest.pytester import Pytester
 from _pytest.tmpdir import get_user
-from _pytest.tmpdir import TempdirFactory
 from _pytest.tmpdir import TempPathFactory
 
 
-def test_tmpdir_fixture(pytester: Pytester) -> None:
-    p = pytester.copy_example("tmpdir/tmpdir_fixture.py")
+def test_tmp_path_fixture(pytester: Pytester) -> None:
+    p = pytester.copy_example("tmpdir/tmp_path_fixture.py")
     results = pytester.runpytest(p)
     results.stdout.fnmatch_lines(["*1 passed*"])
 
 
-@attr.s
+@dataclasses.dataclass
 class FakeConfig:
-    basetemp = attr.ib()
+    basetemp: Union[str, Path]
 
     @property
     def trace(self):
@@ -41,26 +42,34 @@ class FakeConfig:
     def get(self, key):
         return lambda *k: None
 
+    def getini(self, name):
+        if name == "tmp_path_retention_count":
+            return 3
+        elif name == "tmp_path_retention_policy":
+            return "all"
+        else:
+            assert False
+
     @property
     def option(self):
         return self
 
 
-class TestTempdirHandler:
-    def test_mktemp(self, tmp_path):
+class TestTmpPathHandler:
+    def test_mktemp(self, tmp_path: Path) -> None:
         config = cast(Config, FakeConfig(tmp_path))
-        t = TempdirFactory(
-            TempPathFactory.from_config(config, _ispytest=True), _ispytest=True
-        )
+        t = TempPathFactory.from_config(config, _ispytest=True)
         tmp = t.mktemp("world")
-        assert tmp.relto(t.getbasetemp()) == "world0"
+        assert str(tmp.relative_to(t.getbasetemp())) == "world0"
         tmp = t.mktemp("this")
-        assert tmp.relto(t.getbasetemp()).startswith("this")
+        assert str(tmp.relative_to(t.getbasetemp())).startswith("this")
         tmp2 = t.mktemp("this")
-        assert tmp2.relto(t.getbasetemp()).startswith("this")
+        assert str(tmp2.relative_to(t.getbasetemp())).startswith("this")
         assert tmp2 != tmp
 
-    def test_tmppath_relative_basetemp_absolute(self, tmp_path, monkeypatch):
+    def test_tmppath_relative_basetemp_absolute(
+        self, tmp_path: Path, monkeypatch: MonkeyPatch
+    ) -> None:
         """#4425"""
         monkeypatch.chdir(tmp_path)
         config = cast(Config, FakeConfig("hello"))
@@ -68,12 +77,12 @@ class TestTempdirHandler:
         assert t.getbasetemp().resolve() == (tmp_path / "hello").resolve()
 
 
-class TestConfigTmpdir:
+class TestConfigTmpPath:
     def test_getbasetemp_custom_removes_old(self, pytester: Pytester) -> None:
         mytemp = pytester.path.joinpath("xyz")
         p = pytester.makepyfile(
             """
-            def test_1(tmpdir):
+            def test_1(tmp_path):
                 pass
         """
         )
@@ -85,6 +94,136 @@ class TestConfigTmpdir:
         assert mytemp.exists()
         assert not mytemp.joinpath("hello").exists()
 
+    def test_policy_failed_removes_only_passed_dir(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
+            """
+            def test_1(tmp_path):
+                assert 0 == 0
+            def test_2(tmp_path):
+                assert 0 == 1
+        """
+        )
+        pytester.makepyprojecttoml(
+            """
+            [tool.pytest.ini_options]
+            tmp_path_retention_policy = "failed"
+        """
+        )
+
+        pytester.inline_run(p)
+        root = pytester._test_tmproot
+
+        for child in root.iterdir():
+            base_dir = list(
+                filter(lambda x: x.is_dir() and not x.is_symlink(), child.iterdir())
+            )
+            assert len(base_dir) == 1
+            test_dir = list(
+                filter(
+                    lambda x: x.is_dir() and not x.is_symlink(), base_dir[0].iterdir()
+                )
+            )
+            # Check only the failed one remains
+            assert len(test_dir) == 1
+            assert test_dir[0].name == "test_20"
+
+    def test_policy_failed_removes_basedir_when_all_passed(
+        self, pytester: Pytester
+    ) -> None:
+        p = pytester.makepyfile(
+            """
+            def test_1(tmp_path):
+                assert 0 == 0
+        """
+        )
+        pytester.makepyprojecttoml(
+            """
+            [tool.pytest.ini_options]
+            tmp_path_retention_policy = "failed"
+        """
+        )
+
+        pytester.inline_run(p)
+        root = pytester._test_tmproot
+        for child in root.iterdir():
+            # This symlink will be deleted by cleanup_numbered_dir **after**
+            # the test finishes because it's triggered by atexit.
+            # So it has to be ignored here.
+            base_dir = filter(lambda x: not x.is_symlink(), child.iterdir())
+            # Check the base dir itself is gone
+            assert len(list(base_dir)) == 0
+
+    # issue #10502
+    def test_policy_failed_removes_dir_when_skipped_from_fixture(
+        self, pytester: Pytester
+    ) -> None:
+        p = pytester.makepyfile(
+            """
+            import pytest
+
+            @pytest.fixture
+            def fixt(tmp_path):
+                pytest.skip()
+
+            def test_fixt(fixt):
+                pass
+        """
+        )
+        pytester.makepyprojecttoml(
+            """
+            [tool.pytest.ini_options]
+            tmp_path_retention_policy = "failed"
+        """
+        )
+
+        pytester.inline_run(p)
+
+        # Check if the whole directory is removed
+        root = pytester._test_tmproot
+        for child in root.iterdir():
+            base_dir = list(
+                filter(lambda x: x.is_dir() and not x.is_symlink(), child.iterdir())
+            )
+            assert len(base_dir) == 0
+
+    # issue #10502
+    def test_policy_all_keeps_dir_when_skipped_from_fixture(
+        self, pytester: Pytester
+    ) -> None:
+        p = pytester.makepyfile(
+            """
+            import pytest
+
+            @pytest.fixture
+            def fixt(tmp_path):
+                pytest.skip()
+
+            def test_fixt(fixt):
+                pass
+        """
+        )
+        pytester.makepyprojecttoml(
+            """
+            [tool.pytest.ini_options]
+            tmp_path_retention_policy = "all"
+        """
+        )
+        pytester.inline_run(p)
+
+        # Check if the whole directory is kept
+        root = pytester._test_tmproot
+        for child in root.iterdir():
+            base_dir = list(
+                filter(lambda x: x.is_dir() and not x.is_symlink(), child.iterdir())
+            )
+            assert len(base_dir) == 1
+            test_dir = list(
+                filter(
+                    lambda x: x.is_dir() and not x.is_symlink(), base_dir[0].iterdir()
+                )
+            )
+            assert len(test_dir) == 1
+
 
 testdata = [
     ("mypath", True),
@@ -103,8 +242,8 @@ def test_mktemp(pytester: Pytester, basename: str, is_ok: bool) -> None:
     mytemp = pytester.mkdir("mytemp")
     p = pytester.makepyfile(
         """
-        def test_abs_path(tmpdir_factory):
-            tmpdir_factory.mktemp('{}', numbered=False)
+        def test_abs_path(tmp_path_factory):
+            tmp_path_factory.mktemp('{}', numbered=False)
         """.format(
             basename
         )
@@ -119,8 +258,8 @@ def test_mktemp(pytester: Pytester, basename: str, is_ok: bool) -> None:
         result.stdout.fnmatch_lines("*ValueError*")
 
 
-def test_tmpdir_always_is_realpath(pytester: Pytester) -> None:
-    # the reason why tmpdir should be a realpath is that
+def test_tmp_path_always_is_realpath(pytester: Pytester, monkeypatch) -> None:
+    # the reason why tmp_path should be a realpath is that
     # when you cd to it and do "os.getcwd()" you will anyway
     # get the realpath.  Using the symlinked path can thus
     # easily result in path-inequality
@@ -129,22 +268,6 @@ def test_tmpdir_always_is_realpath(pytester: Pytester) -> None:
     realtemp = pytester.mkdir("myrealtemp")
     linktemp = pytester.path.joinpath("symlinktemp")
     attempt_symlink_to(linktemp, str(realtemp))
-    p = pytester.makepyfile(
-        """
-        def test_1(tmpdir):
-            import os
-            assert os.path.realpath(str(tmpdir)) == str(tmpdir)
-    """
-    )
-    result = pytester.runpytest("-s", p, "--basetemp=%s/bt" % linktemp)
-    assert not result.ret
-
-
-def test_tmp_path_always_is_realpath(pytester: Pytester, monkeypatch) -> None:
-    # for reasoning see: test_tmpdir_always_is_realpath test-case
-    realtemp = pytester.mkdir("myrealtemp")
-    linktemp = pytester.path.joinpath("symlinktemp")
-    attempt_symlink_to(linktemp, str(realtemp))
     monkeypatch.setenv("PYTEST_DEBUG_TEMPROOT", str(linktemp))
     pytester.makepyfile(
         """
@@ -156,44 +279,44 @@ def test_tmp_path_always_is_realpath(pytester: Pytester, monkeypatch) -> None:
     reprec.assertoutcome(passed=1)
 
 
-def test_tmpdir_too_long_on_parametrization(pytester: Pytester) -> None:
+def test_tmp_path_too_long_on_parametrization(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
         import pytest
         @pytest.mark.parametrize("arg", ["1"*1000])
-        def test_some(arg, tmpdir):
-            tmpdir.ensure("hello")
+        def test_some(arg, tmp_path):
+            tmp_path.joinpath("hello").touch()
     """
     )
     reprec = pytester.inline_run()
     reprec.assertoutcome(passed=1)
 
 
-def test_tmpdir_factory(pytester: Pytester) -> None:
+def test_tmp_path_factory(pytester: Pytester) -> None:
     pytester.makepyfile(
         """
         import pytest
         @pytest.fixture(scope='session')
-        def session_dir(tmpdir_factory):
-            return tmpdir_factory.mktemp('data', numbered=False)
+        def session_dir(tmp_path_factory):
+            return tmp_path_factory.mktemp('data', numbered=False)
         def test_some(session_dir):
-            assert session_dir.isdir()
+            assert session_dir.is_dir()
     """
     )
     reprec = pytester.inline_run()
     reprec.assertoutcome(passed=1)
 
 
-def test_tmpdir_fallback_tox_env(pytester: Pytester, monkeypatch) -> None:
-    """Test that tmpdir works even if environment variables required by getpass
+def test_tmp_path_fallback_tox_env(pytester: Pytester, monkeypatch) -> None:
+    """Test that tmp_path works even if environment variables required by getpass
     module are missing (#1010).
     """
     monkeypatch.delenv("USER", raising=False)
     monkeypatch.delenv("USERNAME", raising=False)
     pytester.makepyfile(
         """
-        def test_some(tmpdir):
-            assert tmpdir.isdir()
+        def test_some(tmp_path):
+            assert tmp_path.is_dir()
     """
     )
     reprec = pytester.inline_run()
@@ -210,15 +333,15 @@ def break_getuser(monkeypatch):
 
 @pytest.mark.usefixtures("break_getuser")
 @pytest.mark.skipif(sys.platform.startswith("win"), reason="no os.getuid on windows")
-def test_tmpdir_fallback_uid_not_found(pytester: Pytester) -> None:
-    """Test that tmpdir works even if the current process's user id does not
+def test_tmp_path_fallback_uid_not_found(pytester: Pytester) -> None:
+    """Test that tmp_path works even if the current process's user id does not
     correspond to a valid user.
     """
 
     pytester.makepyfile(
         """
-        def test_some(tmpdir):
-            assert tmpdir.isdir()
+        def test_some(tmp_path):
+            assert tmp_path.is_dir()
     """
     )
     reprec = pytester.inline_run()
@@ -292,12 +415,12 @@ class TestNumberedDir:
 
         assert not lock.exists()
 
-    def _do_cleanup(self, tmp_path: Path) -> None:
+    def _do_cleanup(self, tmp_path: Path, keep: int = 2) -> None:
         self.test_make(tmp_path)
         cleanup_numbered_dir(
             root=tmp_path,
             prefix=self.PREFIX,
-            keep=2,
+            keep=keep,
             consider_lock_dead_if_created_before=0,
         )
 
@@ -306,6 +429,11 @@ class TestNumberedDir:
         a, b = (x for x in tmp_path.iterdir() if not x.is_symlink())
         print(a, b)
 
+    def test_cleanup_keep_0(self, tmp_path: Path):
+        self._do_cleanup(tmp_path, 0)
+        dir_num = len(list(tmp_path.iterdir()))
+        assert dir_num == 0
+
     def test_cleanup_locked(self, tmp_path):
         p = make_numbered_dir(root=tmp_path, prefix=self.PREFIX)
 
@@ -384,31 +512,33 @@ class TestRmRf:
 
         # unknown exception
         with pytest.warns(pytest.PytestWarning):
-            exc_info1 = (None, RuntimeError(), None)
+            exc_info1 = (RuntimeError, RuntimeError(), None)
             on_rm_rf_error(os.unlink, str(fn), exc_info1, start_path=tmp_path)
             assert fn.is_file()
 
         # we ignore FileNotFoundError
-        exc_info2 = (None, FileNotFoundError(), None)
+        exc_info2 = (FileNotFoundError, FileNotFoundError(), None)
         assert not on_rm_rf_error(None, str(fn), exc_info2, start_path=tmp_path)
 
         # unknown function
         with pytest.warns(
             pytest.PytestWarning,
-            match=r"^\(rm_rf\) unknown function None when removing .*foo.txt:\nNone: ",
+            match=r"^\(rm_rf\) unknown function None when removing .*foo.txt:\n<class 'PermissionError'>: ",
         ):
-            exc_info3 = (None, PermissionError(), None)
+            exc_info3 = (PermissionError, PermissionError(), None)
             on_rm_rf_error(None, str(fn), exc_info3, start_path=tmp_path)
             assert fn.is_file()
 
         # ignored function
-        with pytest.warns(None) as warninfo:
-            exc_info4 = (None, PermissionError(), None)
-            on_rm_rf_error(os.open, str(fn), exc_info4, start_path=tmp_path)
-            assert fn.is_file()
-        assert not [x.message for x in warninfo]
-
-        exc_info5 = (None, PermissionError(), None)
+        with warnings.catch_warnings():
+            warnings.simplefilter("ignore")
+            with pytest.warns(None) as warninfo:  # type: ignore[call-overload]
+                exc_info4 = PermissionError()
+                on_rm_rf_error(os.open, str(fn), exc_info4, start_path=tmp_path)
+                assert fn.is_file()
+            assert not [x.message for x in warninfo]
+
+        exc_info5 = PermissionError()
         on_rm_rf_error(os.unlink, str(fn), exc_info5, start_path=tmp_path)
         assert not fn.is_file()
 
@@ -422,10 +552,6 @@ def attempt_symlink_to(path, to_path):
         pytest.skip("could not create symbolic link")
 
 
-def test_tmpdir_equals_tmp_path(tmpdir, tmp_path):
-    assert Path(tmpdir) == tmp_path
-
-
 def test_basetemp_with_read_only_files(pytester: Pytester) -> None:
     """Integration test for #5524"""
     pytester.makepyfile(
@@ -435,7 +561,7 @@ def test_basetemp_with_read_only_files(pytester: Pytester) -> None:
 
         def test(tmp_path):
             fn = tmp_path / 'foo.txt'
-            fn.write_text('hello')
+            fn.write_text('hello', encoding='utf-8')
             mode = os.stat(str(fn)).st_mode
             os.chmod(str(fn), mode & ~stat.S_IREAD)
     """
@@ -445,3 +571,55 @@ def test_basetemp_with_read_only_files(pytester: Pytester) -> None:
     # running a second time and ensure we don't crash
     result = pytester.runpytest("--basetemp=tmp")
     assert result.ret == 0
+
+
+def test_tmp_path_factory_handles_invalid_dir_characters(
+    tmp_path_factory: TempPathFactory, monkeypatch: MonkeyPatch
+) -> None:
+    monkeypatch.setattr("getpass.getuser", lambda: "os/<:*?;>agnostic")
+    # _basetemp / _given_basetemp are cached / set in parallel runs, patch them
+    monkeypatch.setattr(tmp_path_factory, "_basetemp", None)
+    monkeypatch.setattr(tmp_path_factory, "_given_basetemp", None)
+    p = tmp_path_factory.getbasetemp()
+    assert "pytest-of-unknown" in str(p)
+
+
+@pytest.mark.skipif(not hasattr(os, "getuid"), reason="checks unix permissions")
+def test_tmp_path_factory_create_directory_with_safe_permissions(
+    tmp_path: Path, monkeypatch: MonkeyPatch
+) -> None:
+    """Verify that pytest creates directories under /tmp with private permissions."""
+    # Use the test's tmp_path as the system temproot (/tmp).
+    monkeypatch.setenv("PYTEST_DEBUG_TEMPROOT", str(tmp_path))
+    tmp_factory = TempPathFactory(None, 3, "all", lambda *args: None, _ispytest=True)
+    basetemp = tmp_factory.getbasetemp()
+
+    # No world-readable permissions.
+    assert (basetemp.stat().st_mode & 0o077) == 0
+    # Parent too (pytest-of-foo).
+    assert (basetemp.parent.stat().st_mode & 0o077) == 0
+
+
+@pytest.mark.skipif(not hasattr(os, "getuid"), reason="checks unix permissions")
+def test_tmp_path_factory_fixes_up_world_readable_permissions(
+    tmp_path: Path, monkeypatch: MonkeyPatch
+) -> None:
+    """Verify that if a /tmp/pytest-of-foo directory already exists with
+    world-readable permissions, it is fixed.
+
+    pytest used to mkdir with such permissions, that's why we fix it up.
+    """
+    # Use the test's tmp_path as the system temproot (/tmp).
+    monkeypatch.setenv("PYTEST_DEBUG_TEMPROOT", str(tmp_path))
+    tmp_factory = TempPathFactory(None, 3, "all", lambda *args: None, _ispytest=True)
+    basetemp = tmp_factory.getbasetemp()
+
+    # Before - simulate bad perms.
+    os.chmod(basetemp.parent, 0o777)
+    assert (basetemp.parent.stat().st_mode & 0o077) != 0
+
+    tmp_factory = TempPathFactory(None, 3, "all", lambda *args: None, _ispytest=True)
+    basetemp = tmp_factory.getbasetemp()
+
+    # After - fixed.
+    assert (basetemp.parent.stat().st_mode & 0o077) == 0
index 8b00cb826accf2434403b437470861c744d7abeb..d917d331a0330c0f2e52fe63387e01620be4233c 100644 (file)
@@ -4,11 +4,12 @@ from typing import List
 
 import pytest
 from _pytest.config import ExitCode
-from _pytest.pytester import Testdir
+from _pytest.monkeypatch import MonkeyPatch
+from _pytest.pytester import Pytester
 
 
-def test_simple_unittest(testdir):
-    testpath = testdir.makepyfile(
+def test_simple_unittest(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -18,13 +19,13 @@ def test_simple_unittest(testdir):
                 self.assertEqual('foo', 'bar')
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     assert reprec.matchreport("testpassing").passed
     assert reprec.matchreport("test_failing").failed
 
 
-def test_runTest_method(testdir):
-    testdir.makepyfile(
+def test_runTest_method(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import unittest
         class MyTestCaseWithRunTest(unittest.TestCase):
@@ -37,7 +38,7 @@ def test_runTest_method(testdir):
                 pass
         """
     )
-    result = testdir.runpytest("-v")
+    result = pytester.runpytest("-v")
     result.stdout.fnmatch_lines(
         """
         *MyTestCaseWithRunTest::runTest*
@@ -47,8 +48,8 @@ def test_runTest_method(testdir):
     )
 
 
-def test_isclasscheck_issue53(testdir):
-    testpath = testdir.makepyfile(
+def test_isclasscheck_issue53(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class _E(object):
@@ -57,12 +58,12 @@ def test_isclasscheck_issue53(testdir):
         E = _E()
     """
     )
-    result = testdir.runpytest(testpath)
+    result = pytester.runpytest(testpath)
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
 
-def test_setup(testdir):
-    testpath = testdir.makepyfile(
+def test_setup(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -78,14 +79,14 @@ def test_setup(testdir):
 
     """
     )
-    reprec = testdir.inline_run("-s", testpath)
+    reprec = pytester.inline_run("-s", testpath)
     assert reprec.matchreport("test_both", when="call").passed
     rep = reprec.matchreport("test_both", when="teardown")
     assert rep.failed and "42" in str(rep.longrepr)
 
 
-def test_setUpModule(testdir):
-    testpath = testdir.makepyfile(
+def test_setUpModule(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         values = []
 
@@ -102,12 +103,12 @@ def test_setUpModule(testdir):
             assert values == [1]
         """
     )
-    result = testdir.runpytest(testpath)
+    result = pytester.runpytest(testpath)
     result.stdout.fnmatch_lines(["*2 passed*"])
 
 
-def test_setUpModule_failing_no_teardown(testdir):
-    testpath = testdir.makepyfile(
+def test_setUpModule_failing_no_teardown(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         values = []
 
@@ -121,14 +122,14 @@ def test_setUpModule_failing_no_teardown(testdir):
             pass
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(passed=0, failed=1)
     call = reprec.getcalls("pytest_runtest_setup")[0]
     assert not call.item.module.values
 
 
-def test_new_instances(testdir):
-    testpath = testdir.makepyfile(
+def test_new_instances(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -138,13 +139,13 @@ def test_new_instances(testdir):
                 assert not hasattr(self, 'x')
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(passed=2)
 
 
-def test_function_item_obj_is_instance(testdir):
+def test_function_item_obj_is_instance(pytester: Pytester) -> None:
     """item.obj should be a bound method on unittest.TestCase function items (#5390)."""
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         def pytest_runtest_makereport(item, call):
             if call.when == 'call':
@@ -152,7 +153,7 @@ def test_function_item_obj_is_instance(testdir):
                 assert isinstance(item.obj.__self__, class_)
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import unittest
 
@@ -161,12 +162,12 @@ def test_function_item_obj_is_instance(testdir):
                 pass
     """
     )
-    result = testdir.runpytest_inprocess()
+    result = pytester.runpytest_inprocess()
     result.stdout.fnmatch_lines(["* 1 passed in*"])
 
 
-def test_teardown(testdir):
-    testpath = testdir.makepyfile(
+def test_teardown(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -180,14 +181,14 @@ def test_teardown(testdir):
                 self.assertEqual(MyTestCase.values, [None])
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert failed == 0, failed
     assert passed == 2
     assert passed + skipped + failed == 2
 
 
-def test_teardown_issue1649(testdir):
+def test_teardown_issue1649(pytester: Pytester) -> None:
     """
     Are TestCase objects cleaned up? Often unittest TestCase objects set
     attributes that are large and expensive during setUp.
@@ -195,7 +196,7 @@ def test_teardown_issue1649(testdir):
     The TestCase will not be cleaned up if the test fails, because it
     would then exist in the stackframe.
     """
-    testpath = testdir.makepyfile(
+    testpath = pytester.makepyfile(
         """
         import unittest
         class TestCaseObjectsShouldBeCleanedUp(unittest.TestCase):
@@ -206,14 +207,14 @@ def test_teardown_issue1649(testdir):
 
     """
     )
-    testdir.inline_run("-s", testpath)
+    pytester.inline_run("-s", testpath)
     gc.collect()
     for obj in gc.get_objects():
         assert type(obj).__name__ != "TestCaseObjectsShouldBeCleanedUp"
 
 
-def test_unittest_skip_issue148(testdir):
-    testpath = testdir.makepyfile(
+def test_unittest_skip_issue148(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
 
@@ -229,12 +230,12 @@ def test_unittest_skip_issue148(testdir):
                 xxx
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(skipped=1)
 
 
-def test_method_and_teardown_failing_reporting(testdir):
-    testdir.makepyfile(
+def test_method_and_teardown_failing_reporting(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import unittest
         class TC(unittest.TestCase):
@@ -244,7 +245,7 @@ def test_method_and_teardown_failing_reporting(testdir):
                 assert False, "down2"
     """
     )
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
     assert result.ret == 1
     result.stdout.fnmatch_lines(
         [
@@ -257,8 +258,8 @@ def test_method_and_teardown_failing_reporting(testdir):
     )
 
 
-def test_setup_failure_is_shown(testdir):
-    testdir.makepyfile(
+def test_setup_failure_is_shown(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -270,14 +271,14 @@ def test_setup_failure_is_shown(testdir):
                 xyz
     """
     )
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
     assert result.ret == 1
     result.stdout.fnmatch_lines(["*setUp*", "*assert 0*down1*", "*1 failed*"])
     result.stdout.no_fnmatch_line("*never42*")
 
 
-def test_setup_setUpClass(testdir):
-    testpath = testdir.makepyfile(
+def test_setup_setUpClass(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -297,12 +298,36 @@ def test_setup_setUpClass(testdir):
             assert MyTestCase.x == 0
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(passed=3)
 
 
-def test_setup_class(testdir):
-    testpath = testdir.makepyfile(
+def test_fixtures_setup_setUpClass_issue8394(pytester: Pytester) -> None:
+    pytester.makepyfile(
+        """
+        import unittest
+        class MyTestCase(unittest.TestCase):
+            @classmethod
+            def setUpClass(cls):
+                pass
+            def test_func1(self):
+                pass
+            @classmethod
+            def tearDownClass(cls):
+                pass
+    """
+    )
+    result = pytester.runpytest("--fixtures")
+    assert result.ret == 0
+    result.stdout.no_fnmatch_line("*no docstring available*")
+
+    result = pytester.runpytest("--fixtures", "-v")
+    assert result.ret == 0
+    result.stdout.fnmatch_lines(["*no docstring available*"])
+
+
+def test_setup_class(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -320,13 +345,13 @@ def test_setup_class(testdir):
             assert MyTestCase.x == 0
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(passed=3)
 
 
 @pytest.mark.parametrize("type", ["Error", "Failure"])
-def test_testcase_adderrorandfailure_defers(testdir, type):
-    testdir.makepyfile(
+def test_testcase_adderrorandfailure_defers(pytester: Pytester, type: str) -> None:
+    pytester.makepyfile(
         """
         from unittest import TestCase
         import pytest
@@ -344,38 +369,46 @@ def test_testcase_adderrorandfailure_defers(testdir, type):
     """
         % (type, type)
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.no_fnmatch_line("*should not raise*")
 
 
 @pytest.mark.parametrize("type", ["Error", "Failure"])
-def test_testcase_custom_exception_info(testdir, type):
-    testdir.makepyfile(
+def test_testcase_custom_exception_info(pytester: Pytester, type: str) -> None:
+    pytester.makepyfile(
         """
+        from typing import Generic, TypeVar
         from unittest import TestCase
-        import py, pytest
-        import _pytest._code
+        import pytest, _pytest._code
+
         class MyTestCase(TestCase):
             def run(self, result):
                 excinfo = pytest.raises(ZeroDivisionError, lambda: 0/0)
-                # we fake an incompatible exception info
-                from _pytest.monkeypatch import MonkeyPatch
-                mp = MonkeyPatch()
-                def t(*args):
-                    mp.undo()
-                    raise TypeError()
-                mp.setattr(_pytest._code, 'ExceptionInfo', t)
+                # We fake an incompatible exception info.
+                class FakeExceptionInfo(Generic[TypeVar("E")]):
+                    def __init__(self, *args, **kwargs):
+                        mp.undo()
+                        raise TypeError()
+                    @classmethod
+                    def from_current(cls):
+                        return cls()
+                    @classmethod
+                    def from_exc_info(cls, *args, **kwargs):
+                        return cls()
+                mp = pytest.MonkeyPatch()
+                mp.setattr(_pytest._code, 'ExceptionInfo', FakeExceptionInfo)
                 try:
                     excinfo = excinfo._excinfo
                     result.add%(type)s(self, excinfo)
                 finally:
                     mp.undo()
+
             def test_hello(self):
                 pass
     """
         % locals()
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "NOTE: Incompatible Exception Representation*",
@@ -385,8 +418,10 @@ def test_testcase_custom_exception_info(testdir, type):
     )
 
 
-def test_testcase_totally_incompatible_exception_info(testdir):
-    (item,) = testdir.getitems(
+def test_testcase_totally_incompatible_exception_info(pytester: Pytester) -> None:
+    import _pytest.unittest
+
+    (item,) = pytester.getitems(
         """
         from unittest import TestCase
         class MyTestCase(TestCase):
@@ -394,13 +429,15 @@ def test_testcase_totally_incompatible_exception_info(testdir):
                 pass
     """
     )
-    item.addError(None, 42)
-    excinfo = item._excinfo.pop(0)
-    assert "ERROR: Unknown Incompatible" in str(excinfo.getrepr())
+    assert isinstance(item, _pytest.unittest.TestCaseFunction)
+    item.addError(None, 42)  # type: ignore[arg-type]
+    excinfo = item._excinfo
+    assert excinfo is not None
+    assert "ERROR: Unknown Incompatible" in str(excinfo.pop(0).getrepr())
 
 
-def test_module_level_pytestmark(testdir):
-    testpath = testdir.makepyfile(
+def test_module_level_pytestmark(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -410,7 +447,7 @@ def test_module_level_pytestmark(testdir):
                 assert 0
     """
     )
-    reprec = testdir.inline_run(testpath, "-s")
+    reprec = pytester.inline_run(testpath, "-s")
     reprec.assertoutcome(skipped=1)
 
 
@@ -421,8 +458,8 @@ class TestTrialUnittest:
         # https://twistedmatrix.com/trac/ticket/9227
         cls.ignore_unclosed_socket_warning = ("-W", "always")
 
-    def test_trial_testcase_runtest_not_collected(self, testdir):
-        testdir.makepyfile(
+    def test_trial_testcase_runtest_not_collected(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             from twisted.trial.unittest import TestCase
 
@@ -431,9 +468,9 @@ class TestTrialUnittest:
                     pass
         """
         )
-        reprec = testdir.inline_run(*self.ignore_unclosed_socket_warning)
+        reprec = pytester.inline_run(*self.ignore_unclosed_socket_warning)
         reprec.assertoutcome(passed=1)
-        testdir.makepyfile(
+        pytester.makepyfile(
             """
             from twisted.trial.unittest import TestCase
 
@@ -442,11 +479,11 @@ class TestTrialUnittest:
                     pass
         """
         )
-        reprec = testdir.inline_run(*self.ignore_unclosed_socket_warning)
+        reprec = pytester.inline_run(*self.ignore_unclosed_socket_warning)
         reprec.assertoutcome(passed=1)
 
-    def test_trial_exceptions_with_skips(self, testdir):
-        testdir.makepyfile(
+    def test_trial_exceptions_with_skips(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             from twisted.trial import unittest
             import pytest
@@ -480,7 +517,7 @@ class TestTrialUnittest:
                     pass
         """
         )
-        result = testdir.runpytest("-rxs", *self.ignore_unclosed_socket_warning)
+        result = pytester.runpytest("-rxs", *self.ignore_unclosed_socket_warning)
         result.stdout.fnmatch_lines_random(
             [
                 "*XFAIL*test_trial_todo*",
@@ -495,8 +532,8 @@ class TestTrialUnittest:
         )
         assert result.ret == 1
 
-    def test_trial_error(self, testdir):
-        testdir.makepyfile(
+    def test_trial_error(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """
             from twisted.trial.unittest import TestCase
             from twisted.internet.defer import Deferred
@@ -533,7 +570,9 @@ class TestTrialUnittest:
                 # will crash both at test time and at teardown
         """
         )
-        result = testdir.runpytest("-vv", "-oconsole_output_style=classic")
+        result = pytester.runpytest(
+            "-vv", "-oconsole_output_style=classic", "-W", "ignore::DeprecationWarning"
+        )
         result.stdout.fnmatch_lines(
             [
                 "test_trial_error.py::TC::test_four FAILED",
@@ -557,8 +596,8 @@ class TestTrialUnittest:
             ]
         )
 
-    def test_trial_pdb(self, testdir):
-        p = testdir.makepyfile(
+    def test_trial_pdb(self, pytester: Pytester) -> None:
+        p = pytester.makepyfile(
             """
             from twisted.trial import unittest
             import pytest
@@ -567,12 +606,12 @@ class TestTrialUnittest:
                     assert 0, "hellopdb"
         """
         )
-        child = testdir.spawn_pytest(p)
+        child = pytester.spawn_pytest(str(p))
         child.expect("hellopdb")
         child.sendeof()
 
-    def test_trial_testcase_skip_property(self, testdir):
-        testpath = testdir.makepyfile(
+    def test_trial_testcase_skip_property(self, pytester: Pytester) -> None:
+        testpath = pytester.makepyfile(
             """
             from twisted.trial import unittest
             class MyTestCase(unittest.TestCase):
@@ -581,11 +620,11 @@ class TestTrialUnittest:
                     pass
             """
         )
-        reprec = testdir.inline_run(testpath, "-s")
+        reprec = pytester.inline_run(testpath, "-s")
         reprec.assertoutcome(skipped=1)
 
-    def test_trial_testfunction_skip_property(self, testdir):
-        testpath = testdir.makepyfile(
+    def test_trial_testfunction_skip_property(self, pytester: Pytester) -> None:
+        testpath = pytester.makepyfile(
             """
             from twisted.trial import unittest
             class MyTestCase(unittest.TestCase):
@@ -594,11 +633,11 @@ class TestTrialUnittest:
                 test_func.skip = 'dont run'
             """
         )
-        reprec = testdir.inline_run(testpath, "-s")
+        reprec = pytester.inline_run(testpath, "-s")
         reprec.assertoutcome(skipped=1)
 
-    def test_trial_testcase_todo_property(self, testdir):
-        testpath = testdir.makepyfile(
+    def test_trial_testcase_todo_property(self, pytester: Pytester) -> None:
+        testpath = pytester.makepyfile(
             """
             from twisted.trial import unittest
             class MyTestCase(unittest.TestCase):
@@ -607,11 +646,11 @@ class TestTrialUnittest:
                     assert 0
             """
         )
-        reprec = testdir.inline_run(testpath, "-s")
+        reprec = pytester.inline_run(testpath, "-s")
         reprec.assertoutcome(skipped=1)
 
-    def test_trial_testfunction_todo_property(self, testdir):
-        testpath = testdir.makepyfile(
+    def test_trial_testfunction_todo_property(self, pytester: Pytester) -> None:
+        testpath = pytester.makepyfile(
             """
             from twisted.trial import unittest
             class MyTestCase(unittest.TestCase):
@@ -620,15 +659,15 @@ class TestTrialUnittest:
                 test_func.todo = 'dont run'
             """
         )
-        reprec = testdir.inline_run(
+        reprec = pytester.inline_run(
             testpath, "-s", *self.ignore_unclosed_socket_warning
         )
         reprec.assertoutcome(skipped=1)
 
 
-def test_djangolike_testcase(testdir):
+def test_djangolike_testcase(pytester: Pytester) -> None:
     # contributed from Morten Breekevold
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         from unittest import TestCase, main
 
@@ -671,7 +710,7 @@ def test_djangolike_testcase(testdir):
                 print("_post_teardown()")
     """
     )
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
     assert result.ret == 0
     result.stdout.fnmatch_lines(
         [
@@ -684,8 +723,8 @@ def test_djangolike_testcase(testdir):
     )
 
 
-def test_unittest_not_shown_in_traceback(testdir):
-    testdir.makepyfile(
+def test_unittest_not_shown_in_traceback(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import unittest
         class t(unittest.TestCase):
@@ -694,12 +733,12 @@ def test_unittest_not_shown_in_traceback(testdir):
                 self.assertEqual(x, 4)
     """
     )
-    res = testdir.runpytest()
+    res = pytester.runpytest()
     res.stdout.no_fnmatch_line("*failUnlessEqual*")
 
 
-def test_unorderable_types(testdir):
-    testdir.makepyfile(
+def test_unorderable_types(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import unittest
         class TestJoinEmpty(unittest.TestCase):
@@ -713,13 +752,13 @@ def test_unorderable_types(testdir):
         TestFoo = make_test()
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.no_fnmatch_line("*TypeError*")
     assert result.ret == ExitCode.NO_TESTS_COLLECTED
 
 
-def test_unittest_typerror_traceback(testdir):
-    testdir.makepyfile(
+def test_unittest_typerror_traceback(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import unittest
         class TestJoinEmpty(unittest.TestCase):
@@ -727,14 +766,16 @@ def test_unittest_typerror_traceback(testdir):
                 pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert "TypeError" in result.stdout.str()
     assert result.ret == 1
 
 
 @pytest.mark.parametrize("runner", ["pytest", "unittest"])
-def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner):
-    script = testdir.makepyfile(
+def test_unittest_expected_failure_for_failing_test_is_xfail(
+    pytester: Pytester, runner
+) -> None:
+    script = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -746,19 +787,22 @@ def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner):
     """
     )
     if runner == "pytest":
-        result = testdir.runpytest("-rxX")
+        result = pytester.runpytest("-rxX")
         result.stdout.fnmatch_lines(
             ["*XFAIL*MyTestCase*test_failing_test_is_xfail*", "*1 xfailed*"]
         )
     else:
-        result = testdir.runpython(script)
+        result = pytester.runpython(script)
         result.stderr.fnmatch_lines(["*1 test in*", "*OK*(expected failures=1)*"])
     assert result.ret == 0
 
 
 @pytest.mark.parametrize("runner", ["pytest", "unittest"])
-def test_unittest_expected_failure_for_passing_test_is_fail(testdir, runner):
-    script = testdir.makepyfile(
+def test_unittest_expected_failure_for_passing_test_is_fail(
+    pytester: Pytester,
+    runner: str,
+) -> None:
+    script = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -771,20 +815,24 @@ def test_unittest_expected_failure_for_passing_test_is_fail(testdir, runner):
     )
 
     if runner == "pytest":
-        result = testdir.runpytest("-rxX")
+        result = pytester.runpytest("-rxX")
         result.stdout.fnmatch_lines(
-            ["*MyTestCase*test_passing_test_is_fail*", "*1 failed*"]
+            [
+                "*MyTestCase*test_passing_test_is_fail*",
+                "Unexpected success",
+                "*1 failed*",
+            ]
         )
     else:
-        result = testdir.runpython(script)
+        result = pytester.runpython(script)
         result.stderr.fnmatch_lines(["*1 test in*", "*(unexpected successes=1)*"])
 
     assert result.ret == 1
 
 
 @pytest.mark.parametrize("stmt", ["return", "yield"])
-def test_unittest_setup_interaction(testdir: Testdir, stmt: str) -> None:
-    testdir.makepyfile(
+def test_unittest_setup_interaction(pytester: Pytester, stmt: str) -> None:
+    pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -811,12 +859,12 @@ def test_unittest_setup_interaction(testdir: Testdir, stmt: str) -> None:
             stmt=stmt
         )
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*3 passed*"])
 
 
-def test_non_unittest_no_setupclass_support(testdir):
-    testpath = testdir.makepyfile(
+def test_non_unittest_no_setupclass_support(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         class TestFoo(object):
             x = 0
@@ -837,12 +885,12 @@ def test_non_unittest_no_setupclass_support(testdir):
 
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(passed=2)
 
 
-def test_no_teardown_if_setupclass_failed(testdir):
-    testpath = testdir.makepyfile(
+def test_no_teardown_if_setupclass_failed(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
 
@@ -865,13 +913,13 @@ def test_no_teardown_if_setupclass_failed(testdir):
             assert MyTestCase.x == 1
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     reprec.assertoutcome(passed=1, failed=1)
 
 
-def test_cleanup_functions(testdir):
+def test_cleanup_functions(pytester: Pytester) -> None:
     """Ensure functions added with addCleanup are always called after each test ends (#6947)"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import unittest
 
@@ -890,7 +938,7 @@ def test_cleanup_functions(testdir):
                 assert cleanups == ["test_func_1", "test_func_2"]
     """
     )
-    result = testdir.runpytest("-v")
+    result = pytester.runpytest("-v")
     result.stdout.fnmatch_lines(
         [
             "*::test_func_1 PASSED *",
@@ -900,8 +948,8 @@ def test_cleanup_functions(testdir):
     )
 
 
-def test_issue333_result_clearing(testdir):
-    testdir.makeconftest(
+def test_issue333_result_clearing(pytester: Pytester) -> None:
+    pytester.makeconftest(
         """
         import pytest
         @pytest.hookimpl(hookwrapper=True)
@@ -910,7 +958,7 @@ def test_issue333_result_clearing(testdir):
             assert 0
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import unittest
         class TestIt(unittest.TestCase):
@@ -919,12 +967,12 @@ def test_issue333_result_clearing(testdir):
     """
     )
 
-    reprec = testdir.inline_run()
+    reprec = pytester.inline_run()
     reprec.assertoutcome(failed=1)
 
 
-def test_unittest_raise_skip_issue748(testdir):
-    testdir.makepyfile(
+def test_unittest_raise_skip_issue748(pytester: Pytester) -> None:
+    pytester.makepyfile(
         test_foo="""
         import unittest
 
@@ -933,7 +981,7 @@ def test_unittest_raise_skip_issue748(testdir):
                 raise unittest.SkipTest('skipping due to reasons')
     """
     )
-    result = testdir.runpytest("-v", "-rs")
+    result = pytester.runpytest("-v", "-rs")
     result.stdout.fnmatch_lines(
         """
         *SKIP*[1]*test_foo.py*skipping due to reasons*
@@ -942,8 +990,8 @@ def test_unittest_raise_skip_issue748(testdir):
     )
 
 
-def test_unittest_skip_issue1169(testdir):
-    testdir.makepyfile(
+def test_unittest_skip_issue1169(pytester: Pytester) -> None:
+    pytester.makepyfile(
         test_foo="""
         import unittest
 
@@ -953,7 +1001,7 @@ def test_unittest_skip_issue1169(testdir):
                  self.fail()
         """
     )
-    result = testdir.runpytest("-v", "-rs")
+    result = pytester.runpytest("-v", "-rs")
     result.stdout.fnmatch_lines(
         """
         *SKIP*[1]*skipping due to reasons*
@@ -962,8 +1010,8 @@ def test_unittest_skip_issue1169(testdir):
     )
 
 
-def test_class_method_containing_test_issue1558(testdir):
-    testdir.makepyfile(
+def test_class_method_containing_test_issue1558(pytester: Pytester) -> None:
+    pytester.makepyfile(
         test_foo="""
         import unittest
 
@@ -975,16 +1023,16 @@ def test_class_method_containing_test_issue1558(testdir):
             test_should_not_run.__test__ = False
     """
     )
-    reprec = testdir.inline_run()
+    reprec = pytester.inline_run()
     reprec.assertoutcome(passed=1)
 
 
 @pytest.mark.parametrize("base", ["builtins.object", "unittest.TestCase"])
-def test_usefixtures_marker_on_unittest(base, testdir):
+def test_usefixtures_marker_on_unittest(base, pytester: Pytester) -> None:
     """#3498"""
     module = base.rsplit(".", 1)[0]
     pytest.importorskip(module)
-    testdir.makepyfile(
+    pytester.makepyfile(
         conftest="""
         import pytest
 
@@ -1013,7 +1061,7 @@ def test_usefixtures_marker_on_unittest(base, testdir):
         """
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import {module}
@@ -1038,16 +1086,16 @@ def test_usefixtures_marker_on_unittest(base, testdir):
         )
     )
 
-    result = testdir.runpytest("-s")
+    result = pytester.runpytest("-s")
     result.assert_outcomes(passed=2)
 
 
-def test_testcase_handles_init_exceptions(testdir):
+def test_testcase_handles_init_exceptions(pytester: Pytester) -> None:
     """
     Regression test to make sure exceptions in the __init__ method are bubbled up correctly.
     See https://github.com/pytest-dev/pytest/issues/3788
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         from unittest import TestCase
         import pytest
@@ -1058,14 +1106,14 @@ def test_testcase_handles_init_exceptions(testdir):
                 pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert "should raise this exception" in result.stdout.str()
     result.stdout.no_fnmatch_line("*ERROR at teardown of MyTestCase.test_hello*")
 
 
-def test_error_message_with_parametrized_fixtures(testdir):
-    testdir.copy_example("unittest/test_parametrized_fixture_error_message.py")
-    result = testdir.runpytest()
+def test_error_message_with_parametrized_fixtures(pytester: Pytester) -> None:
+    pytester.copy_example("unittest/test_parametrized_fixture_error_message.py")
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*test_two does not support fixtures*",
@@ -1083,15 +1131,17 @@ def test_error_message_with_parametrized_fixtures(testdir):
         ("test_setup_skip_module.py", "1 error"),
     ],
 )
-def test_setup_inheritance_skipping(testdir, test_name, expected_outcome):
+def test_setup_inheritance_skipping(
+    pytester: Pytester, test_name, expected_outcome
+) -> None:
     """Issue #4700"""
-    testdir.copy_example(f"unittest/{test_name}")
-    result = testdir.runpytest()
+    pytester.copy_example(f"unittest/{test_name}")
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines([f"* {expected_outcome} in *"])
 
 
-def test_BdbQuit(testdir):
-    testdir.makepyfile(
+def test_BdbQuit(pytester: Pytester) -> None:
+    pytester.makepyfile(
         test_foo="""
         import unittest
 
@@ -1104,12 +1154,12 @@ def test_BdbQuit(testdir):
                 pass
     """
     )
-    reprec = testdir.inline_run()
+    reprec = pytester.inline_run()
     reprec.assertoutcome(failed=1, passed=1)
 
 
-def test_exit_outcome(testdir):
-    testdir.makepyfile(
+def test_exit_outcome(pytester: Pytester) -> None:
+    pytester.makepyfile(
         test_foo="""
         import pytest
         import unittest
@@ -1122,11 +1172,11 @@ def test_exit_outcome(testdir):
                 pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*Exit: pytest_exit called*", "*= no tests ran in *"])
 
 
-def test_trace(testdir, monkeypatch):
+def test_trace(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
     calls = []
 
     def check_call(*args, **kwargs):
@@ -1141,7 +1191,7 @@ def test_trace(testdir, monkeypatch):
 
     monkeypatch.setattr("_pytest.debugging.pytestPDB._init_pdb", check_call)
 
-    p1 = testdir.makepyfile(
+    p1 = pytester.makepyfile(
         """
         import unittest
 
@@ -1150,12 +1200,12 @@ def test_trace(testdir, monkeypatch):
                 self.assertEqual('foo', 'foo')
     """
     )
-    result = testdir.runpytest("--trace", str(p1))
+    result = pytester.runpytest("--trace", str(p1))
     assert len(calls) == 2
     assert result.ret == 0
 
 
-def test_pdb_teardown_called(testdir, monkeypatch) -> None:
+def test_pdb_teardown_called(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
     """Ensure tearDown() is always called when --pdb is given in the command-line.
 
     We delay the normal tearDown() calls when --pdb is given, so this ensures we are calling
@@ -1166,7 +1216,7 @@ def test_pdb_teardown_called(testdir, monkeypatch) -> None:
         pytest, "test_pdb_teardown_called_teardowns", teardowns, raising=False
     )
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -1182,7 +1232,7 @@ def test_pdb_teardown_called(testdir, monkeypatch) -> None:
                 pass
     """
     )
-    result = testdir.runpytest_inprocess("--pdb")
+    result = pytester.runpytest_inprocess("--pdb")
     result.stdout.fnmatch_lines("* 2 passed in *")
     assert teardowns == [
         "test_pdb_teardown_called.MyTestCase.test_1",
@@ -1191,12 +1241,17 @@ def test_pdb_teardown_called(testdir, monkeypatch) -> None:
 
 
 @pytest.mark.parametrize("mark", ["@unittest.skip", "@pytest.mark.skip"])
-def test_pdb_teardown_skipped(testdir, monkeypatch, mark: str) -> None:
-    """With --pdb, setUp and tearDown should not be called for skipped tests."""
+def test_pdb_teardown_skipped_for_functions(
+    pytester: Pytester, monkeypatch: MonkeyPatch, mark: str
+) -> None:
+    """
+    With --pdb, setUp and tearDown should not be called for tests skipped
+    via a decorator (#7215).
+    """
     tracked: List[str] = []
-    monkeypatch.setattr(pytest, "test_pdb_teardown_skipped", tracked, raising=False)
+    monkeypatch.setattr(pytest, "track_pdb_teardown_skipped", tracked, raising=False)
 
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import unittest
         import pytest
@@ -1204,10 +1259,10 @@ def test_pdb_teardown_skipped(testdir, monkeypatch, mark: str) -> None:
         class MyTestCase(unittest.TestCase):
 
             def setUp(self):
-                pytest.test_pdb_teardown_skipped.append("setUp:" + self.id())
+                pytest.track_pdb_teardown_skipped.append("setUp:" + self.id())
 
             def tearDown(self):
-                pytest.test_pdb_teardown_skipped.append("tearDown:" + self.id())
+                pytest.track_pdb_teardown_skipped.append("tearDown:" + self.id())
 
             {mark}("skipped for reasons")
             def test_1(self):
@@ -1217,29 +1272,66 @@ def test_pdb_teardown_skipped(testdir, monkeypatch, mark: str) -> None:
             mark=mark
         )
     )
-    result = testdir.runpytest_inprocess("--pdb")
+    result = pytester.runpytest_inprocess("--pdb")
     result.stdout.fnmatch_lines("* 1 skipped in *")
     assert tracked == []
 
 
-def test_async_support(testdir):
+@pytest.mark.parametrize("mark", ["@unittest.skip", "@pytest.mark.skip"])
+def test_pdb_teardown_skipped_for_classes(
+    pytester: Pytester, monkeypatch: MonkeyPatch, mark: str
+) -> None:
+    """
+    With --pdb, setUp and tearDown should not be called for tests skipped
+    via a decorator on the class (#10060).
+    """
+    tracked: List[str] = []
+    monkeypatch.setattr(pytest, "track_pdb_teardown_skipped", tracked, raising=False)
+
+    pytester.makepyfile(
+        """
+        import unittest
+        import pytest
+
+        {mark}("skipped for reasons")
+        class MyTestCase(unittest.TestCase):
+
+            def setUp(self):
+                pytest.track_pdb_teardown_skipped.append("setUp:" + self.id())
+
+            def tearDown(self):
+                pytest.track_pdb_teardown_skipped.append("tearDown:" + self.id())
+
+            def test_1(self):
+                pass
+
+    """.format(
+            mark=mark
+        )
+    )
+    result = pytester.runpytest_inprocess("--pdb")
+    result.stdout.fnmatch_lines("* 1 skipped in *")
+    assert tracked == []
+
+
+def test_async_support(pytester: Pytester) -> None:
     pytest.importorskip("unittest.async_case")
 
-    testdir.copy_example("unittest/test_unittest_asyncio.py")
-    reprec = testdir.inline_run()
+    pytester.copy_example("unittest/test_unittest_asyncio.py")
+    reprec = pytester.inline_run()
     reprec.assertoutcome(failed=1, passed=2)
 
 
-def test_asynctest_support(testdir):
+def test_asynctest_support(pytester: Pytester) -> None:
     """Check asynctest support (#7110)"""
     pytest.importorskip("asynctest")
 
-    testdir.copy_example("unittest/test_unittest_asynctest.py")
-    reprec = testdir.inline_run()
+    pytester.copy_example("unittest/test_unittest_asynctest.py")
+    reprec = pytester.inline_run()
     reprec.assertoutcome(failed=1, passed=2)
 
 
-def test_plain_unittest_does_not_support_async(testdir):
+def test_plain_unittest_does_not_support_async(pytester: Pytester) -> None:
     """Async functions in plain unittest.TestCase subclasses are not supported without plugins.
 
     This test exists here to avoid introducing this support by accident, leading users
@@ -1247,8 +1339,8 @@ def test_plain_unittest_does_not_support_async(testdir):
 
     See https://github.com/pytest-dev/pytest-asyncio/issues/180 for more context.
     """
-    testdir.copy_example("unittest/test_unittest_plain_async.py")
-    result = testdir.runpytest_subprocess()
+    pytester.copy_example("unittest/test_unittest_plain_async.py")
+    result = pytester.runpytest_subprocess()
     if hasattr(sys, "pypy_version_info"):
         # in PyPy we can't reliable get the warning about the coroutine not being awaited,
         # because it depends on the coroutine being garbage collected; given that
@@ -1265,8 +1357,8 @@ def test_plain_unittest_does_not_support_async(testdir):
 @pytest.mark.skipif(
     sys.version_info < (3, 8), reason="Feature introduced in Python 3.8"
 )
-def test_do_class_cleanups_on_success(testdir):
-    testpath = testdir.makepyfile(
+def test_do_class_cleanups_on_success(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -1284,7 +1376,7 @@ def test_do_class_cleanups_on_success(testdir):
             assert MyTestCase.values == [1]
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert failed == 0
     assert passed == 3
@@ -1293,8 +1385,8 @@ def test_do_class_cleanups_on_success(testdir):
 @pytest.mark.skipif(
     sys.version_info < (3, 8), reason="Feature introduced in Python 3.8"
 )
-def test_do_class_cleanups_on_setupclass_failure(testdir):
-    testpath = testdir.makepyfile(
+def test_do_class_cleanups_on_setupclass_failure(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -1311,7 +1403,7 @@ def test_do_class_cleanups_on_setupclass_failure(testdir):
             assert MyTestCase.values == [1]
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert failed == 1
     assert passed == 1
@@ -1320,8 +1412,8 @@ def test_do_class_cleanups_on_setupclass_failure(testdir):
 @pytest.mark.skipif(
     sys.version_info < (3, 8), reason="Feature introduced in Python 3.8"
 )
-def test_do_class_cleanups_on_teardownclass_failure(testdir):
-    testpath = testdir.makepyfile(
+def test_do_class_cleanups_on_teardownclass_failure(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -1342,13 +1434,13 @@ def test_do_class_cleanups_on_teardownclass_failure(testdir):
             assert MyTestCase.values == [1]
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert passed == 3
 
 
-def test_do_cleanups_on_success(testdir):
-    testpath = testdir.makepyfile(
+def test_do_cleanups_on_success(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -1365,14 +1457,14 @@ def test_do_cleanups_on_success(testdir):
             assert MyTestCase.values == [1, 1]
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert failed == 0
     assert passed == 3
 
 
-def test_do_cleanups_on_setup_failure(testdir):
-    testpath = testdir.makepyfile(
+def test_do_cleanups_on_setup_failure(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -1390,14 +1482,14 @@ def test_do_cleanups_on_setup_failure(testdir):
             assert MyTestCase.values == [1, 1]
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert failed == 2
     assert passed == 1
 
 
-def test_do_cleanups_on_teardown_failure(testdir):
-    testpath = testdir.makepyfile(
+def test_do_cleanups_on_teardown_failure(pytester: Pytester) -> None:
+    testpath = pytester.makepyfile(
         """
         import unittest
         class MyTestCase(unittest.TestCase):
@@ -1416,7 +1508,60 @@ def test_do_cleanups_on_teardown_failure(testdir):
             assert MyTestCase.values == [1, 1]
     """
     )
-    reprec = testdir.inline_run(testpath)
+    reprec = pytester.inline_run(testpath)
     passed, skipped, failed = reprec.countoutcomes()
     assert failed == 2
     assert passed == 1
+
+
+def test_traceback_pruning(pytester: Pytester) -> None:
+    """Regression test for #9610 - doesn't crash during traceback pruning."""
+    pytester.makepyfile(
+        """
+        import unittest
+
+        class MyTestCase(unittest.TestCase):
+            def __init__(self, test_method):
+                unittest.TestCase.__init__(self, test_method)
+
+        class TestIt(MyTestCase):
+            @classmethod
+            def tearDownClass(cls) -> None:
+                assert False
+
+            def test_it(self):
+                pass
+        """
+    )
+    reprec = pytester.inline_run()
+    passed, skipped, failed = reprec.countoutcomes()
+    assert passed == 1
+    assert failed == 1
+    assert reprec.ret == 1
+
+
+def test_raising_unittest_skiptest_during_collection(
+    pytester: Pytester,
+) -> None:
+    pytester.makepyfile(
+        """
+        import unittest
+
+        class TestIt(unittest.TestCase):
+            def test_it(self): pass
+            def test_it2(self): pass
+
+        raise unittest.SkipTest()
+
+        class TestIt2(unittest.TestCase):
+            def test_it(self): pass
+            def test_it2(self): pass
+        """
+    )
+    reprec = pytester.inline_run()
+    passed, skipped, failed = reprec.countoutcomes()
+    assert passed == 0
+    # Unittest reports one fake test for a skipped module.
+    assert skipped == 1
+    assert failed == 0
+    assert reprec.ret == ExitCode.NO_TESTS_COLLECTED
index 32f890334092db6b99c2f8d3231591704f821379..f625833dceaca49c0026f0dd0691482891ac0264 100644 (file)
@@ -8,7 +8,7 @@ if sys.version_info < (3, 8):
     pytest.skip("unraisableexception plugin needs Python>=3.8", allow_module_level=True)
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
 def test_unraisable(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_it="""
@@ -40,7 +40,7 @@ def test_unraisable(pytester: Pytester) -> None:
     )
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
 def test_unraisable_in_setup(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_it="""
@@ -76,7 +76,7 @@ def test_unraisable_in_setup(pytester: Pytester) -> None:
     )
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning")
 def test_unraisable_in_teardown(pytester: Pytester) -> None:
     pytester.makepyfile(
         test_it="""
index b49cc68f9c6990fc0127a20c6e81e8346c5866c0..5f69439ef3eeecd3b7d0a9290d966833eaefc9c9 100644 (file)
@@ -36,3 +36,11 @@ def test_pytest_warnings_repr_integration_test(pytester: Pytester) -> None:
     )
     result = pytester.runpytest()
     result.stdout.fnmatch_lines(["E       pytest.PytestWarning: some warning"])
+
+
+@pytest.mark.filterwarnings("error")
+def test_warn_explicit_for_annotates_errors_with_location():
+    with pytest.raises(Warning, match="(?m)test\n at .*python_api.py:\\d+"):
+        warning_types.warn_explicit_for(
+            pytest.raises, warning_types.PytestWarning("test")  # type: ignore
+        )
index 66898041f0836c7d394c2a2266138458deb41267..03846cb30c39c9a6931f8c59e0ed80dd67ac6a67 100644 (file)
@@ -1,4 +1,5 @@
 import os
+import sys
 import warnings
 from typing import List
 from typing import Optional
@@ -6,18 +7,18 @@ from typing import Tuple
 
 import pytest
 from _pytest.fixtures import FixtureRequest
-from _pytest.pytester import Testdir
+from _pytest.pytester import Pytester
 
 WARNINGS_SUMMARY_HEADER = "warnings summary"
 
 
 @pytest.fixture
-def pyfile_with_warnings(testdir: Testdir, request: FixtureRequest) -> str:
+def pyfile_with_warnings(pytester: Pytester, request: FixtureRequest) -> str:
     """Create a test file which calls a function in a module which generates warnings."""
-    testdir.syspathinsert()
+    pytester.syspathinsert()
     test_name = request.function.__name__
     module_name = test_name.lstrip("test_") + "_module"
-    test_file = testdir.makepyfile(
+    test_file = pytester.makepyfile(
         """
         import {module_name}
         def test_func():
@@ -38,10 +39,10 @@ def pyfile_with_warnings(testdir: Testdir, request: FixtureRequest) -> str:
     return str(test_file)
 
 
-@pytest.mark.filterwarnings("default")
-def test_normal_flow(testdir, pyfile_with_warnings):
+@pytest.mark.filterwarnings("default::UserWarning", "default::RuntimeWarning")
+def test_normal_flow(pytester: Pytester, pyfile_with_warnings) -> None:
     """Check that the warnings section is displayed."""
-    result = testdir.runpytest(pyfile_with_warnings)
+    result = pytester.runpytest(pyfile_with_warnings)
     result.stdout.fnmatch_lines(
         [
             "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -55,9 +56,9 @@ def test_normal_flow(testdir, pyfile_with_warnings):
     )
 
 
-@pytest.mark.filterwarnings("always")
-def test_setup_teardown_warnings(testdir):
-    testdir.makepyfile(
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_setup_teardown_warnings(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import warnings
         import pytest
@@ -72,7 +73,7 @@ def test_setup_teardown_warnings(testdir):
             pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -86,10 +87,10 @@ def test_setup_teardown_warnings(testdir):
 
 
 @pytest.mark.parametrize("method", ["cmdline", "ini"])
-def test_as_errors(testdir, pyfile_with_warnings, method):
+def test_as_errors(pytester: Pytester, pyfile_with_warnings, method) -> None:
     args = ("-W", "error") if method == "cmdline" else ()
     if method == "ini":
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             filterwarnings=error
@@ -97,7 +98,7 @@ def test_as_errors(testdir, pyfile_with_warnings, method):
         )
     # Use a subprocess, since changing logging level affects other threads
     # (xdist).
-    result = testdir.runpytest_subprocess(*args, pyfile_with_warnings)
+    result = pytester.runpytest_subprocess(*args, pyfile_with_warnings)
     result.stdout.fnmatch_lines(
         [
             "E       UserWarning: user warning",
@@ -108,24 +109,24 @@ def test_as_errors(testdir, pyfile_with_warnings, method):
 
 
 @pytest.mark.parametrize("method", ["cmdline", "ini"])
-def test_ignore(testdir, pyfile_with_warnings, method):
+def test_ignore(pytester: Pytester, pyfile_with_warnings, method) -> None:
     args = ("-W", "ignore") if method == "cmdline" else ()
     if method == "ini":
-        testdir.makeini(
+        pytester.makeini(
             """
         [pytest]
         filterwarnings= ignore
         """
         )
 
-    result = testdir.runpytest(*args, pyfile_with_warnings)
+    result = pytester.runpytest(*args, pyfile_with_warnings)
     result.stdout.fnmatch_lines(["* 1 passed in *"])
     assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
 
 
-@pytest.mark.filterwarnings("always")
-def test_unicode(testdir):
-    testdir.makepyfile(
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_unicode(pytester: Pytester) -> None:
+    pytester.makepyfile(
         """
         import warnings
         import pytest
@@ -140,7 +141,7 @@ def test_unicode(testdir):
             pass
         """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -150,9 +151,9 @@ def test_unicode(testdir):
     )
 
 
-def test_works_with_filterwarnings(testdir):
+def test_works_with_filterwarnings(pytester: Pytester) -> None:
     """Ensure our warnings capture does not mess with pre-installed filters (#2430)."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import warnings
 
@@ -170,22 +171,22 @@ def test_works_with_filterwarnings(testdir):
                     assert True
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(["*== 1 passed in *"])
 
 
 @pytest.mark.parametrize("default_config", ["ini", "cmdline"])
-def test_filterwarnings_mark(testdir, default_config):
+def test_filterwarnings_mark(pytester: Pytester, default_config) -> None:
     """Test ``filterwarnings`` mark works and takes precedence over command
     line and ini options."""
     if default_config == "ini":
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
-            filterwarnings = always
+            filterwarnings = always::RuntimeWarning
         """
         )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import warnings
         import pytest
@@ -202,13 +203,15 @@ def test_filterwarnings_mark(testdir, default_config):
             warnings.warn(RuntimeWarning())
     """
     )
-    result = testdir.runpytest("-W always" if default_config == "cmdline" else "")
+    result = pytester.runpytest(
+        "-W always::RuntimeWarning" if default_config == "cmdline" else ""
+    )
     result.stdout.fnmatch_lines(["*= 1 failed, 2 passed, 1 warning in *"])
 
 
-def test_non_string_warning_argument(testdir):
+def test_non_string_warning_argument(pytester: Pytester) -> None:
     """Non-str argument passed to warning breaks pytest (#2956)"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """\
         import warnings
         import pytest
@@ -217,13 +220,13 @@ def test_non_string_warning_argument(testdir):
             warnings.warn(UserWarning(1, 'foo'))
         """
     )
-    result = testdir.runpytest("-W", "always")
+    result = pytester.runpytest("-W", "always::UserWarning")
     result.stdout.fnmatch_lines(["*= 1 passed, 1 warning in *"])
 
 
-def test_filterwarnings_mark_registration(testdir):
+def test_filterwarnings_mark_registration(pytester: Pytester) -> None:
     """Ensure filterwarnings mark is registered"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
 
@@ -232,19 +235,19 @@ def test_filterwarnings_mark_registration(testdir):
             pass
     """
     )
-    result = testdir.runpytest("--strict-markers")
+    result = pytester.runpytest("--strict-markers")
     assert result.ret == 0
 
 
-@pytest.mark.filterwarnings("always")
-def test_warning_captured_hook(testdir):
-    testdir.makeconftest(
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_warning_recorded_hook(pytester: Pytester) -> None:
+    pytester.makeconftest(
         """
         def pytest_configure(config):
             config.issue_config_time_warning(UserWarning("config warning"), stacklevel=2)
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest, warnings
 
@@ -268,15 +271,15 @@ def test_warning_captured_hook(testdir):
         def pytest_warning_recorded(self, warning_message, when, nodeid, location):
             collected.append((str(warning_message.message), when, nodeid, location))
 
-    result = testdir.runpytest(plugins=[WarningCollector()])
+    result = pytester.runpytest(plugins=[WarningCollector()])
     result.stdout.fnmatch_lines(["*1 passed*"])
 
     expected = [
         ("config warning", "config", ""),
         ("collect warning", "collect", ""),
-        ("setup warning", "runtest", "test_warning_captured_hook.py::test_func"),
-        ("call warning", "runtest", "test_warning_captured_hook.py::test_func"),
-        ("teardown warning", "runtest", "test_warning_captured_hook.py::test_func"),
+        ("setup warning", "runtest", "test_warning_recorded_hook.py::test_func"),
+        ("call warning", "runtest", "test_warning_recorded_hook.py::test_func"),
+        ("teardown warning", "runtest", "test_warning_recorded_hook.py::test_func"),
     ]
     for index in range(len(expected)):
         collected_result = collected[index]
@@ -287,7 +290,7 @@ def test_warning_captured_hook(testdir):
         assert collected_result[2] == expected_result[2], str(collected)
 
         # NOTE: collected_result[3] is location, which differs based on the platform you are on
-        #       thus, the best we can do here is assert the types of the paremeters match what we expect
+        #       thus, the best we can do here is assert the types of the parameters match what we expect
         #       and not try and preload it in the expected array
         if collected_result[3] is not None:
             assert type(collected_result[3][0]) is str, str(collected)
@@ -297,10 +300,10 @@ def test_warning_captured_hook(testdir):
             assert collected_result[3] is None, str(collected)
 
 
-@pytest.mark.filterwarnings("always")
-def test_collection_warnings(testdir):
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_collection_warnings(pytester: Pytester) -> None:
     """Check that we also capture warnings issued during test collection (#3251)."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import warnings
 
@@ -310,7 +313,7 @@ def test_collection_warnings(testdir):
             pass
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -321,10 +324,10 @@ def test_collection_warnings(testdir):
     )
 
 
-@pytest.mark.filterwarnings("always")
-def test_mark_regex_escape(testdir):
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_mark_regex_escape(pytester: Pytester) -> None:
     """@pytest.mark.filterwarnings should not try to escape regex characters (#3936)"""
-    testdir.makepyfile(
+    pytester.makepyfile(
         r"""
         import pytest, warnings
 
@@ -333,15 +336,17 @@ def test_mark_regex_escape(testdir):
             warnings.warn(UserWarning("some (warning)"))
     """
     )
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
 
 
-@pytest.mark.filterwarnings("default")
+@pytest.mark.filterwarnings("default::pytest.PytestWarning")
 @pytest.mark.parametrize("ignore_pytest_warnings", ["no", "ini", "cmdline"])
-def test_hide_pytest_internal_warnings(testdir, ignore_pytest_warnings):
+def test_hide_pytest_internal_warnings(
+    pytester: Pytester, ignore_pytest_warnings
+) -> None:
     """Make sure we can ignore internal pytest warnings using a warnings filter."""
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest
         import warnings
@@ -353,7 +358,7 @@ def test_hide_pytest_internal_warnings(testdir, ignore_pytest_warnings):
     """
     )
     if ignore_pytest_warnings == "ini":
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             filterwarnings = ignore::pytest.PytestWarning
@@ -364,7 +369,7 @@ def test_hide_pytest_internal_warnings(testdir, ignore_pytest_warnings):
         if ignore_pytest_warnings == "cmdline"
         else []
     )
-    result = testdir.runpytest(*args)
+    result = pytester.runpytest(*args)
     if ignore_pytest_warnings != "no":
         assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
     else:
@@ -378,15 +383,17 @@ def test_hide_pytest_internal_warnings(testdir, ignore_pytest_warnings):
 
 
 @pytest.mark.parametrize("ignore_on_cmdline", [True, False])
-def test_option_precedence_cmdline_over_ini(testdir, ignore_on_cmdline):
+def test_option_precedence_cmdline_over_ini(
+    pytester: Pytester, ignore_on_cmdline
+) -> None:
     """Filters defined in the command-line should take precedence over filters in ini files (#3946)."""
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
-        filterwarnings = error
+        filterwarnings = error::UserWarning
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import warnings
         def test():
@@ -394,22 +401,22 @@ def test_option_precedence_cmdline_over_ini(testdir, ignore_on_cmdline):
     """
     )
     args = ["-W", "ignore"] if ignore_on_cmdline else []
-    result = testdir.runpytest(*args)
+    result = pytester.runpytest(*args)
     if ignore_on_cmdline:
         result.stdout.fnmatch_lines(["* 1 passed in*"])
     else:
         result.stdout.fnmatch_lines(["* 1 failed in*"])
 
 
-def test_option_precedence_mark(testdir):
+def test_option_precedence_mark(pytester: Pytester) -> None:
     """Filters defined by marks should always take precedence (#3946)."""
-    testdir.makeini(
+    pytester.makeini(
         """
         [pytest]
         filterwarnings = ignore
     """
     )
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import pytest, warnings
         @pytest.mark.filterwarnings('error')
@@ -417,7 +424,7 @@ def test_option_precedence_mark(testdir):
             warnings.warn(UserWarning('hello'))
     """
     )
-    result = testdir.runpytest("-W", "ignore")
+    result = pytester.runpytest("-W", "ignore")
     result.stdout.fnmatch_lines(["* 1 failed in*"])
 
 
@@ -427,8 +434,8 @@ class TestDeprecationWarningsByDefault:
     from pytest's own test suite
     """
 
-    def create_file(self, testdir, mark=""):
-        testdir.makepyfile(
+    def create_file(self, pytester: Pytester, mark="") -> None:
+        pytester.makepyfile(
             """
             import pytest, warnings
 
@@ -443,18 +450,18 @@ class TestDeprecationWarningsByDefault:
         )
 
     @pytest.mark.parametrize("customize_filters", [True, False])
-    def test_shown_by_default(self, testdir, customize_filters):
+    def test_shown_by_default(self, pytester: Pytester, customize_filters) -> None:
         """Show deprecation warnings by default, even if user has customized the warnings filters (#4013)."""
-        self.create_file(testdir)
+        self.create_file(pytester)
         if customize_filters:
-            testdir.makeini(
+            pytester.makeini(
                 """
                 [pytest]
                 filterwarnings =
                     once::UserWarning
             """
             )
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         result.stdout.fnmatch_lines(
             [
                 "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -464,9 +471,9 @@ class TestDeprecationWarningsByDefault:
             ]
         )
 
-    def test_hidden_by_ini(self, testdir):
-        self.create_file(testdir)
-        testdir.makeini(
+    def test_hidden_by_ini(self, pytester: Pytester) -> None:
+        self.create_file(pytester)
+        pytester.makeini(
             """
             [pytest]
             filterwarnings =
@@ -474,18 +481,18 @@ class TestDeprecationWarningsByDefault:
                 ignore::PendingDeprecationWarning
         """
         )
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
 
-    def test_hidden_by_mark(self, testdir):
+    def test_hidden_by_mark(self, pytester: Pytester) -> None:
         """Should hide the deprecation warning from the function, but the warning during collection should
         be displayed normally.
         """
         self.create_file(
-            testdir,
+            pytester,
             mark='@pytest.mark.filterwarnings("ignore::PendingDeprecationWarning")',
         )
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         result.stdout.fnmatch_lines(
             [
                 "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -494,9 +501,9 @@ class TestDeprecationWarningsByDefault:
             ]
         )
 
-    def test_hidden_by_cmdline(self, testdir):
-        self.create_file(testdir)
-        result = testdir.runpytest_subprocess(
+    def test_hidden_by_cmdline(self, pytester: Pytester) -> None:
+        self.create_file(pytester)
+        result = pytester.runpytest_subprocess(
             "-W",
             "ignore::DeprecationWarning",
             "-W",
@@ -504,45 +511,43 @@ class TestDeprecationWarningsByDefault:
         )
         assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
 
-    def test_hidden_by_system(self, testdir, monkeypatch):
-        self.create_file(testdir)
+    def test_hidden_by_system(self, pytester: Pytester, monkeypatch) -> None:
+        self.create_file(pytester)
         monkeypatch.setenv("PYTHONWARNINGS", "once::UserWarning")
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
 
 
+@pytest.mark.skip("not relevant until pytest 8.0")
 @pytest.mark.parametrize("change_default", [None, "ini", "cmdline"])
-@pytest.mark.skip(
-    reason="This test should be enabled again before pytest 7.0 is released"
-)
-def test_deprecation_warning_as_error(testdir, change_default):
-    """This ensures that PytestDeprecationWarnings raised by pytest are turned into errors.
+def test_removed_in_x_warning_as_error(pytester: Pytester, change_default) -> None:
+    """This ensures that PytestRemovedInXWarnings raised by pytest are turned into errors.
 
     This test should be enabled as part of each major release, and skipped again afterwards
     to ensure our deprecations are turning into warnings as expected.
     """
-    testdir.makepyfile(
+    pytester.makepyfile(
         """
         import warnings, pytest
         def test():
-            warnings.warn(pytest.PytestDeprecationWarning("some warning"))
+            warnings.warn(pytest.PytestRemovedIn8Warning("some warning"))
     """
     )
     if change_default == "ini":
-        testdir.makeini(
+        pytester.makeini(
             """
             [pytest]
             filterwarnings =
-                ignore::pytest.PytestDeprecationWarning
+                ignore::pytest.PytestRemovedIn8Warning
         """
         )
 
     args = (
-        ("-Wignore::pytest.PytestDeprecationWarning",)
+        ("-Wignore::pytest.PytestRemovedIn8Warning",)
         if change_default == "cmdline"
         else ()
     )
-    result = testdir.runpytest(*args)
+    result = pytester.runpytest(*args)
     if change_default is None:
         result.stdout.fnmatch_lines(["* 1 failed in *"])
     else:
@@ -552,23 +557,23 @@ def test_deprecation_warning_as_error(testdir, change_default):
 
 class TestAssertionWarnings:
     @staticmethod
-    def assert_result_warns(result, msg):
+    def assert_result_warns(result, msg) -> None:
         result.stdout.fnmatch_lines(["*PytestAssertRewriteWarning: %s*" % msg])
 
-    def test_tuple_warning(self, testdir):
-        testdir.makepyfile(
+    def test_tuple_warning(self, pytester: Pytester) -> None:
+        pytester.makepyfile(
             """\
             def test_foo():
                 assert (1,2)
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         self.assert_result_warns(
             result, "assertion is always true, perhaps remove parentheses?"
         )
 
 
-def test_warnings_checker_twice():
+def test_warnings_checker_twice() -> None:
     """Issue #4617"""
     expectation = pytest.warns(UserWarning)
     with expectation:
@@ -577,11 +582,10 @@ def test_warnings_checker_twice():
         warnings.warn("Message B", UserWarning)
 
 
-@pytest.mark.filterwarnings("ignore::pytest.PytestExperimentalApiWarning")
-@pytest.mark.filterwarnings("always")
-def test_group_warnings_by_message(testdir):
-    testdir.copy_example("warnings/test_group_warnings_by_message.py")
-    result = testdir.runpytest()
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_group_warnings_by_message(pytester: Pytester) -> None:
+    pytester.copy_example("warnings/test_group_warnings_by_message.py")
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -609,12 +613,11 @@ def test_group_warnings_by_message(testdir):
     )
 
 
-@pytest.mark.filterwarnings("ignore::pytest.PytestExperimentalApiWarning")
-@pytest.mark.filterwarnings("always")
-def test_group_warnings_by_message_summary(testdir):
-    testdir.copy_example("warnings/test_group_warnings_by_message_summary")
-    testdir.syspathinsert()
-    result = testdir.runpytest()
+@pytest.mark.filterwarnings("always::UserWarning")
+def test_group_warnings_by_message_summary(pytester: Pytester) -> None:
+    pytester.copy_example("warnings/test_group_warnings_by_message_summary")
+    pytester.syspathinsert()
+    result = pytester.runpytest()
     result.stdout.fnmatch_lines(
         [
             "*== %s ==*" % WARNINGS_SUMMARY_HEADER,
@@ -634,9 +637,9 @@ def test_group_warnings_by_message_summary(testdir):
     )
 
 
-def test_pytest_configure_warning(testdir, recwarn):
+def test_pytest_configure_warning(pytester: Pytester, recwarn) -> None:
     """Issue 5115."""
-    testdir.makeconftest(
+    pytester.makeconftest(
         """
         def pytest_configure():
             import warnings
@@ -645,7 +648,7 @@ def test_pytest_configure_warning(testdir, recwarn):
         """
     )
 
-    result = testdir.runpytest()
+    result = pytester.runpytest()
     assert result.ret == 5
     assert "INTERNALERROR" not in result.stderr.str()
     warning = recwarn.pop()
@@ -654,26 +657,26 @@ def test_pytest_configure_warning(testdir, recwarn):
 
 class TestStackLevel:
     @pytest.fixture
-    def capwarn(self, testdir):
+    def capwarn(self, pytester: Pytester):
         class CapturedWarnings:
             captured: List[
                 Tuple[warnings.WarningMessage, Optional[Tuple[str, int, str]]]
-            ] = ([])
+            ] = []
 
             @classmethod
             def pytest_warning_recorded(cls, warning_message, when, nodeid, location):
                 cls.captured.append((warning_message, location))
 
-        testdir.plugins = [CapturedWarnings()]
+        pytester.plugins = [CapturedWarnings()]
 
         return CapturedWarnings
 
-    def test_issue4445_rewrite(self, testdir, capwarn):
+    def test_issue4445_rewrite(self, pytester: Pytester, capwarn) -> None:
         """#4445: Make sure the warning points to a reasonable location
         See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241
         """
-        testdir.makepyfile(some_mod="")
-        conftest = testdir.makeconftest(
+        pytester.makepyfile(some_mod="")
+        conftest = pytester.makeconftest(
             """
                 import some_mod
                 import pytest
@@ -681,7 +684,7 @@ class TestStackLevel:
                 pytest.register_assert_rewrite("some_mod")
             """
         )
-        testdir.parseconfig()
+        pytester.parseconfig()
 
         # with stacklevel=5 the warning originates from register_assert_rewrite
         # function in the created conftest.py
@@ -694,19 +697,19 @@ class TestStackLevel:
         assert func == "<module>"  # the above conftest.py
         assert lineno == 4
 
-    def test_issue4445_preparse(self, testdir, capwarn):
+    def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None:
         """#4445: Make sure the warning points to a reasonable location
         See origin of _issue_warning_captured at: _pytest.config.__init__.py:910
         """
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import nothing
             """
         )
-        testdir.parseconfig("--help")
+        pytester.parseconfig("--help")
 
         # with stacklevel=2 the warning should originate from config._preparse and is
-        # thrown by an errorneous conftest.py
+        # thrown by an erroneous conftest.py
         assert len(capwarn.captured) == 1
         warning, location = capwarn.captured.pop()
         file, _, func = location
@@ -716,29 +719,29 @@ class TestStackLevel:
         assert func == "_preparse"
 
     @pytest.mark.filterwarnings("default")
-    def test_conftest_warning_captured(self, testdir: Testdir) -> None:
+    def test_conftest_warning_captured(self, pytester: Pytester) -> None:
         """Warnings raised during importing of conftest.py files is captured (#2891)."""
-        testdir.makeconftest(
+        pytester.makeconftest(
             """
             import warnings
             warnings.warn(UserWarning("my custom warning"))
             """
         )
-        result = testdir.runpytest()
+        result = pytester.runpytest()
         result.stdout.fnmatch_lines(
             ["conftest.py:2", "*UserWarning: my custom warning*"]
         )
 
-    def test_issue4445_import_plugin(self, testdir, capwarn):
+    def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None:
         """#4445: Make sure the warning points to a reasonable location"""
-        testdir.makepyfile(
+        pytester.makepyfile(
             some_plugin="""
             import pytest
             pytest.skip("thing", allow_module_level=True)
             """
         )
-        testdir.syspathinsert()
-        testdir.parseconfig("-p", "some_plugin")
+        pytester.syspathinsert()
+        pytester.parseconfig("-p", "some_plugin")
 
         # with stacklevel=2 the warning should originate from
         # config.PytestPluginManager.import_plugin is thrown by a skipped plugin
@@ -751,11 +754,11 @@ class TestStackLevel:
         assert f"config{os.sep}__init__.py" in file
         assert func == "_warn_about_skipped_plugins"
 
-    def test_issue4445_issue5928_mark_generator(self, testdir):
+    def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None:
         """#4445 and #5928: Make sure the warning from an unknown mark points to
         the test file where this mark is used.
         """
-        testfile = testdir.makepyfile(
+        testfile = pytester.makepyfile(
             """
             import pytest
 
@@ -764,11 +767,79 @@ class TestStackLevel:
                 pass
             """
         )
-        result = testdir.runpytest_subprocess()
+        result = pytester.runpytest_subprocess()
         # with stacklevel=2 the warning should originate from the above created test file
         result.stdout.fnmatch_lines_random(
             [
-                "*{testfile}:3*".format(testfile=str(testfile)),
+                f"*{testfile}:3*",
                 "*Unknown pytest.mark.unknown*",
             ]
         )
+
+
+def test_warning_on_testpaths_not_found(pytester: Pytester) -> None:
+    # Check for warning when testpaths set, but not found by glob
+    pytester.makeini(
+        """
+        [pytest]
+        testpaths = absent
+        """
+    )
+    result = pytester.runpytest()
+    result.stdout.fnmatch_lines(
+        ["*ConfigWarning: No files were found in testpaths*", "*1 warning*"]
+    )
+
+
+def test_resource_warning(pytester: Pytester, monkeypatch: pytest.MonkeyPatch) -> None:
+    # Some platforms (notably PyPy) don't have tracemalloc.
+    # We choose to explicitly not skip this in case tracemalloc is not
+    # available, using `importorskip("tracemalloc")` for example,
+    # because we want to ensure the same code path does not break in those platforms.
+    try:
+        import tracemalloc  # noqa
+
+        has_tracemalloc = True
+    except ImportError:
+        has_tracemalloc = False
+
+    # Explicitly disable PYTHONTRACEMALLOC in case pytest's test suite is running
+    # with it enabled.
+    monkeypatch.delenv("PYTHONTRACEMALLOC", raising=False)
+
+    pytester.makepyfile(
+        """
+        def open_file(p):
+            f = p.open("r", encoding="utf-8")
+            assert p.read_text() == "hello"
+
+        def test_resource_warning(tmp_path):
+            p = tmp_path.joinpath("foo.txt")
+            p.write_text("hello", encoding="utf-8")
+            open_file(p)
+        """
+    )
+    result = pytester.run(sys.executable, "-Xdev", "-m", "pytest")
+    expected_extra = (
+        [
+            "*ResourceWarning* unclosed file*",
+            "*Enable tracemalloc to get traceback where the object was allocated*",
+            "*See https* for more info.",
+        ]
+        if has_tracemalloc
+        else []
+    )
+    result.stdout.fnmatch_lines([*expected_extra, "*1 passed*"])
+
+    monkeypatch.setenv("PYTHONTRACEMALLOC", "20")
+
+    result = pytester.run(sys.executable, "-Xdev", "-m", "pytest")
+    expected_extra = (
+        [
+            "*ResourceWarning* unclosed file*",
+            "*Object allocated at*",
+        ]
+        if has_tracemalloc
+        else []
+    )
+    result.stdout.fnmatch_lines([*expected_extra, "*1 passed*"])
index 0a6b5ad284104d37fb04bd9ae78cb5a26469a97d..57f2bae475f48a8343a7aac680cb49c14e741953 100644 (file)
@@ -3,7 +3,13 @@
 This file is not executed, it is only checked by mypy to ensure that
 none of the code triggers any mypy errors.
 """
+import contextlib
+from typing import Optional
+
+from typing_extensions import assert_type
+
 import pytest
+from pytest import MonkeyPatch
 
 
 # Issue #7488.
@@ -22,3 +28,22 @@ def check_fixture_ids_callable() -> None:
 @pytest.mark.parametrize("func", [str, int], ids=lambda x: str(x.__name__))
 def check_parametrize_ids_callable(func) -> None:
     pass
+
+
+# Issue #10999.
+def check_monkeypatch_typeddict(monkeypatch: MonkeyPatch) -> None:
+    from typing import TypedDict
+
+    class Foo(TypedDict):
+        x: int
+        y: float
+
+    a: Foo = {"x": 1, "y": 3.14}
+    monkeypatch.setitem(a, "x", 2)
+    monkeypatch.delitem(a, "y")
+
+
+def check_raises_is_a_context_manager(val: bool) -> None:
+    with pytest.raises(RuntimeError) if val else contextlib.nullcontext() as excinfo:
+        pass
+    assert_type(excinfo, Optional[pytest.ExceptionInfo[RuntimeError]])
diff --git a/tox.ini b/tox.ini
index f0cfaa460fb018ffc58a41376244c649e2ba23a3..05c1842af8a1b27b8fecc6f1b2303ba046834b20 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -2,31 +2,46 @@
 isolated_build = True
 minversion = 3.20.0
 distshare = {homedir}/.tox/distshare
-# make sure to update environment list in travis.yml and appveyor.yml
 envlist =
     linting
-    py36
     py37
     py38
     py39
+    py310
+    py311
+    py312
     pypy3
-    py37-{pexpect,xdist,unittestextras,numpy,pluggymaster}
+    py37-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib}
     doctesting
     plugins
     py37-freeze
     docs
     docs-checklinks
 
+    # checks that 3.11 native ExceptionGroup works with exceptiongroup
+    # not included in CI.
+    py311-exceptiongroup
+
+
+
 [testenv]
 commands =
     {env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}}
     doctesting: {env:_PYTEST_TOX_COVERAGE_RUN:} pytest --doctest-modules --pyargs _pytest
     coverage: coverage combine
     coverage: coverage report -m
-passenv = USER USERNAME COVERAGE_* TRAVIS PYTEST_ADDOPTS TERM
+passenv =
+    COVERAGE_*
+    PYTEST_ADDOPTS
+    TERM
+    SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST
 setenv =
     _PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:}
 
+    # See https://docs.python.org/3/library/io.html#io-encoding-warning
+    # If we don't enable this, neither can any of our downstream users!
+    PYTHONWARNDEFAULTENCODING=1
+
     # Configuration to run with coverage similar to CI, e.g.
     # "tox -e py37-coverage".
     coverage: _PYTEST_TOX_COVERAGE_RUN=coverage run -m
@@ -44,10 +59,11 @@ setenv =
 extras = testing
 deps =
     doctesting: PyYAML
+    exceptiongroup: exceptiongroup>=1.0.0rc8
     numpy: numpy>=1.19.4
     pexpect: pexpect>=4.8.0
-    pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master
-    pygments>=2.7.2
+    pluggymain: pluggy @ git+https://github.com/pytest-dev/pluggy.git
+    pylib: py>=1.8.2
     unittestextras: twisted
     unittestextras: asynctest
     xdist: pytest-xdist>=2.1.0
@@ -65,7 +81,8 @@ basepython = python3
 usedevelop = True
 deps =
     -r{toxinidir}/doc/en/requirements.txt
-    towncrier
+    # https://github.com/twisted/towncrier/issues/340
+    towncrier<21.3.0
 commands =
     python scripts/towncrier-draft-to-file.py
     # the '-t changelog_towncrier_draft' tags makes sphinx include the draft
@@ -84,37 +101,27 @@ commands =
 [testenv:regen]
 changedir = doc/en
 basepython = python3
-passenv = SETUPTOOLS_SCM_PRETEND_VERSION
-# TODO: When setuptools-scm 5.0.0 is released, use SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST
-# and remove the next line.
-install_command=python -m pip --use-deprecated=legacy-resolver install {opts} {packages}
+passenv =
+    SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST
 deps =
-    dataclasses
     PyYAML
-    regendoc>=0.6.1
+    regendoc>=0.8.1
     sphinx
-whitelist_externals =
-    rm
+allowlist_externals =
     make
 commands =
-    # don't show hypothesis plugin info in docs, see #4602
-    pip uninstall hypothesis -y
-    rm -rf /tmp/doc-exec*
-    rm -rf {envdir}/.pytest_cache
     make regen
 
 [testenv:plugins]
 # use latest versions of all plugins, including pre-releases
 pip_pre=true
-# use latest pip and new dependency resolver (#7783)
+# use latest pip to get new dependency resolver (#7783)
 download=true
-install_command=python -m pip --use-feature=2020-resolver install {opts} {packages}
+install_command=python -m pip install {opts} {packages}
 changedir = testing/plugins_integration
 deps = -rtesting/plugins_integration/requirements.txt
 setenv =
     PYTHONPATH=.
-    # due to pytest-rerunfailures requiring 6.2+; can be removed after 6.2.0
-    SETUPTOOLS_SCM_PRETEND_VERSION=6.2.0a1
 commands =
     pip check
     pytest bdd_wallet.py
@@ -138,7 +145,7 @@ commands =
     {envpython} tox_run.py
 
 [testenv:release]
-decription = do a release, required posarg of the version number
+description = do a release, required posarg of the version number
 basepython = python3
 usedevelop = True
 passenv = *
@@ -147,21 +154,25 @@ deps =
     github3.py
     pre-commit>=2.9.3
     wheel
-    towncrier
+    # https://github.com/twisted/towncrier/issues/340
+    towncrier<21.3.0
 commands = python scripts/release.py {posargs}
 
-[testenv:release-on-comment]
-decription = do a release from a comment on GitHub
+[testenv:prepare-release-pr]
+description = prepare a release PR from a manual trigger in GitHub actions
 usedevelop = {[testenv:release]usedevelop}
 passenv = {[testenv:release]passenv}
 deps = {[testenv:release]deps}
-commands = python scripts/release-on-comment.py {posargs}
+commands = python scripts/prepare-release-pr.py {posargs}
 
 [testenv:publish-gh-release-notes]
 description = create GitHub release after deployment
 basepython = python3
 usedevelop = True
-passenv = GH_RELEASE_NOTES_TOKEN GITHUB_REF GITHUB_REPOSITORY
+passenv =
+    GH_RELEASE_NOTES_TOKEN
+    GITHUB_REF
+    GITHUB_REPOSITORY
 deps =
     github3.py
     pypandoc
@@ -181,6 +192,7 @@ extend-ignore =
     ; Docstring Content Issues
     D400,D401,D401,D402,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D415,D416,D417
 
+
 [isort]
 ; This config mimics what reorder-python-imports does.
 force_single_line = 1