Compare commits
57 Commits
Author | SHA1 | Date |
---|---|---|
|
029b2b6008 | |
|
e53f798932 | |
|
31afeeb0df | |
|
1b00a2f4fb | |
|
ff2f66d84a | |
|
8a8eed609c | |
|
74346f027c | |
|
b7657b4d6b | |
|
feb7c5e12e | |
|
090965574e | |
|
68524d4858 | |
|
d7d320a15a | |
|
93699166dc | |
|
a232abd56c | |
|
92203d2b78 | |
|
f1aa9226ac | |
|
d86d081563 | |
|
c554c3d200 | |
|
a6851e3459 | |
|
e6f6be3bc9 | |
|
23b91d12de | |
|
b188f4d10d | |
|
d60b6b0e28 | |
|
c11cdfabd1 | |
|
368cc6225e | |
|
06e592370e | |
|
a76aa6ff80 | |
|
73371a03da | |
|
eb698a64a0 | |
|
3e48ef64cd | |
|
8b70bb64d3 | |
|
169d775eec | |
|
42f709ed44 | |
|
24c681d4ee | |
|
478f8233bc | |
|
608590097a | |
|
3b41c65c81 | |
|
747072ad26 | |
|
011a475baf | |
|
97960bdd14 | |
|
6be0a3cbf7 | |
|
44ffe07165 | |
|
14ecb04973 | |
|
41c8dabee3 | |
|
6f4cbd7cd4 | |
|
b0c7f923aa | |
|
f15aff06dc | |
|
10c8898845 | |
|
5b7ddedbf9 | |
|
3ae38baca6 | |
|
6123b247d4 | |
|
bb6f5d1b10 | |
|
72eb1b7ad1 | |
|
620a454dba | |
|
838151638e | |
|
665e4e58d3 | |
|
e17d5ec871 |
|
@ -29,5 +29,3 @@ exclude_lines =
|
|||
|
||||
^\s*if TYPE_CHECKING:
|
||||
^\s*@overload( |$)
|
||||
|
||||
^\s*@pytest\.mark\.xfail
|
||||
|
|
|
@ -23,13 +23,9 @@ afc607cfd81458d4e4f3b1f3cf8cc931b933907e
|
|||
5f95dce95602921a70bfbc7d8de2f7712c5e4505
|
||||
# ran pyupgrade-docs again
|
||||
75d0b899bbb56d6849e9d69d83a9426ed3f43f8b
|
||||
|
||||
# move argument parser to own file
|
||||
c9df77cbd6a365dcb73c39618e4842711817e871
|
||||
|
||||
# Replace reorder-python-imports by isort due to black incompatibility (#11896)
|
||||
8b54596639f41dfac070030ef20394b9001fe63c
|
||||
# Run blacken-docs with black's 2024's style
|
||||
4546d5445aaefe6a03957db028c263521dfb5c4b
|
||||
# Migration to ruff / ruff format
|
||||
4588653b2497ed25976b7aaff225b889fb476756
|
||||
# Use format specifiers instead of percent format
|
||||
4788165e69d08e10fc6b9c0124083fb358e2e9b0
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
|
||||
branch-protection-check-name: Changelog entry
|
||||
action-hints:
|
||||
check-title-prefix: "Chronographer: "
|
||||
external-docs-url: >-
|
||||
https://docs.pytest.org/en/latest/contributing.html#preparing-pull-requests
|
||||
inline-markdown: >-
|
||||
See
|
||||
https://docs.pytest.org/en/latest/contributing.html#preparing-pull-requests
|
||||
for details.
|
||||
enforce-name:
|
||||
suffix: .rst
|
||||
exclude:
|
||||
humans:
|
||||
- pyup-bot
|
||||
labels:
|
||||
skip-changelog: skip news
|
||||
|
||||
...
|
|
@ -1,7 +0,0 @@
|
|||
---
|
||||
|
||||
backport_branch_prefix: patchback/backports/
|
||||
backport_label_prefix: 'backport ' # IMPORTANT: the labels are space-delimited
|
||||
# target_branch_prefix: '' # The project's backport branches are non-prefixed
|
||||
|
||||
...
|
|
@ -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@v4
|
||||
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 }}
|
|
@ -19,11 +19,6 @@ jobs:
|
|||
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
|
||||
timeout-minutes: 10
|
||||
|
||||
# Required by attest-build-provenance-github.
|
||||
permissions:
|
||||
id-token: write
|
||||
attestations: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
@ -31,9 +26,7 @@ jobs:
|
|||
persist-credentials: false
|
||||
|
||||
- name: Build and Check Package
|
||||
uses: hynek/build-and-inspect-python-package@v2.6.0
|
||||
with:
|
||||
attest-build-provenance-github: 'true'
|
||||
uses: hynek/build-and-inspect-python-package@v2.0.0
|
||||
|
||||
deploy:
|
||||
if: github.repository == 'pytest-dev/pytest'
|
||||
|
@ -54,7 +47,7 @@ jobs:
|
|||
path: dist
|
||||
|
||||
- name: Publish package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@v1.9.0
|
||||
uses: pypa/gh-action-pypi-publish@v1.8.11
|
||||
|
||||
- name: Push tag
|
||||
run: |
|
||||
|
@ -101,7 +94,7 @@ jobs:
|
|||
tox -e generate-gh-release-notes -- ${{ github.event.inputs.version }} scripts/latest-release-notes.md
|
||||
|
||||
- name: Publish GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body_path: scripts/latest-release-notes.md
|
||||
files: dist/*
|
||||
|
|
|
@ -17,7 +17,7 @@ jobs:
|
|||
days-before-issue-close: 7
|
||||
only-labels: "status: needs information"
|
||||
stale-issue-label: "stale"
|
||||
stale-issue-message: "This issue is stale because it has the `status: needs information` label and requested follow-up information was not provided for 14 days."
|
||||
close-issue-message: "This issue was closed because it has the `status: needs information` label and follow-up information has not been provided for 7 days since being marked as 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
|
||||
|
|
|
@ -14,11 +14,6 @@ on:
|
|||
branches:
|
||||
- main
|
||||
- "[0-9]+.[0-9]+.x"
|
||||
types:
|
||||
- opened # default
|
||||
- synchronize # default
|
||||
- reopened # default
|
||||
- ready_for_review # used in PRs created from the release workflow
|
||||
|
||||
env:
|
||||
PYTEST_ADDOPTS: "--color=yes"
|
||||
|
@ -40,7 +35,7 @@ jobs:
|
|||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
- name: Build and Check Package
|
||||
uses: hynek/build-and-inspect-python-package@v2.6.0
|
||||
uses: hynek/build-and-inspect-python-package@v2.0.0
|
||||
|
||||
build:
|
||||
needs: [package]
|
||||
|
@ -60,7 +55,6 @@ jobs:
|
|||
"windows-py310",
|
||||
"windows-py311",
|
||||
"windows-py312",
|
||||
"windows-py313",
|
||||
|
||||
"ubuntu-py38",
|
||||
"ubuntu-py38-pluggy",
|
||||
|
@ -69,14 +63,12 @@ jobs:
|
|||
"ubuntu-py310",
|
||||
"ubuntu-py311",
|
||||
"ubuntu-py312",
|
||||
"ubuntu-py313",
|
||||
"ubuntu-pypy3",
|
||||
|
||||
"macos-py38",
|
||||
"macos-py39",
|
||||
"macos-py310",
|
||||
"macos-py312",
|
||||
"macos-py313",
|
||||
|
||||
"doctesting",
|
||||
"plugins",
|
||||
|
@ -105,13 +97,9 @@ jobs:
|
|||
os: windows-latest
|
||||
tox_env: "py311"
|
||||
- name: "windows-py312"
|
||||
python: "3.12"
|
||||
python: "3.12-dev"
|
||||
os: windows-latest
|
||||
tox_env: "py312"
|
||||
- name: "windows-py313"
|
||||
python: "3.13-dev"
|
||||
os: windows-latest
|
||||
tox_env: "py313"
|
||||
|
||||
- name: "ubuntu-py38"
|
||||
python: "3.8"
|
||||
|
@ -140,15 +128,10 @@ jobs:
|
|||
tox_env: "py311"
|
||||
use_coverage: true
|
||||
- name: "ubuntu-py312"
|
||||
python: "3.12"
|
||||
python: "3.12-dev"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py312"
|
||||
use_coverage: true
|
||||
- name: "ubuntu-py313"
|
||||
python: "3.13-dev"
|
||||
os: ubuntu-latest
|
||||
tox_env: "py313"
|
||||
use_coverage: true
|
||||
- name: "ubuntu-pypy3"
|
||||
python: "pypy-3.8"
|
||||
os: ubuntu-latest
|
||||
|
@ -168,13 +151,9 @@ jobs:
|
|||
os: macos-latest
|
||||
tox_env: "py310-xdist"
|
||||
- name: "macos-py312"
|
||||
python: "3.12"
|
||||
python: "3.12-dev"
|
||||
os: macos-latest
|
||||
tox_env: "py312-xdist"
|
||||
- name: "macos-py313"
|
||||
python: "3.13-dev"
|
||||
os: macos-latest
|
||||
tox_env: "py313-xdist"
|
||||
|
||||
- name: "plugins"
|
||||
python: "3.12"
|
||||
|
@ -187,26 +166,6 @@ jobs:
|
|||
tox_env: "doctesting"
|
||||
use_coverage: true
|
||||
|
||||
continue-on-error: >-
|
||||
${{
|
||||
contains(
|
||||
fromJSON(
|
||||
'[
|
||||
"windows-py38-pluggy",
|
||||
"windows-py313",
|
||||
"ubuntu-py38-pluggy",
|
||||
"ubuntu-py38-freeze",
|
||||
"ubuntu-py313",
|
||||
"macos-py38",
|
||||
"macos-py313"
|
||||
]'
|
||||
),
|
||||
matrix.name
|
||||
)
|
||||
&& true
|
||||
|| false
|
||||
}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
|
@ -246,22 +205,9 @@ jobs:
|
|||
|
||||
- name: Upload coverage to Codecov
|
||||
if: "matrix.use_coverage"
|
||||
uses: codecov/codecov-action@v4
|
||||
uses: codecov/codecov-action@v3
|
||||
continue-on-error: true
|
||||
with:
|
||||
fail_ci_if_error: false
|
||||
fail_ci_if_error: true
|
||||
files: ./coverage.xml
|
||||
verbose: true
|
||||
|
||||
check: # This job does nothing and is only used for the branch protection
|
||||
if: always()
|
||||
|
||||
needs:
|
||||
- build
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Decide whether the needed jobs succeeded or failed
|
||||
uses: re-actors/alls-green@223e4bb7a751b91f43eda76992bcfbf23b8b0302
|
||||
with:
|
||||
jobs: ${{ toJSON(needs) }}
|
||||
|
|
|
@ -30,7 +30,7 @@ jobs:
|
|||
python-version: "3.11"
|
||||
cache: pip
|
||||
- name: requests-cache
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cache/pytest-plugin-list/
|
||||
key: plugins-http-cache-${{ github.run_id }} # Can use time based key as well
|
||||
|
@ -46,8 +46,7 @@ jobs:
|
|||
run: python scripts/update-plugin-list.py
|
||||
|
||||
- name: Create Pull Request
|
||||
id: pr
|
||||
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c
|
||||
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
|
||||
with:
|
||||
commit-message: '[automated] Update plugin list'
|
||||
author: 'pytest bot <pytestbot@users.noreply.github.com>'
|
||||
|
@ -56,13 +55,3 @@ jobs:
|
|||
branch-suffix: short-commit-hash
|
||||
title: '[automated] Update plugin list'
|
||||
body: '[automated] Update plugin list'
|
||||
draft: true
|
||||
|
||||
- name: Instruct the maintainers to trigger CI by undrafting the PR
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
run: >-
|
||||
gh pr comment
|
||||
--body 'Please mark the PR as ready for review to trigger PR checks.'
|
||||
--repo '${{ github.repository }}'
|
||||
'${{ steps.pr.outputs.pull-request-number }}'
|
||||
|
|
|
@ -25,6 +25,7 @@ src/_pytest/_version.py
|
|||
|
||||
doc/*/_build
|
||||
doc/*/.doctrees
|
||||
doc/*/_changelog_towncrier_draft.rst
|
||||
build/
|
||||
dist/
|
||||
*.egg-info
|
||||
|
@ -50,7 +51,6 @@ coverage.xml
|
|||
.settings
|
||||
.vscode
|
||||
__pycache__/
|
||||
.python-version
|
||||
|
||||
# generated by pip
|
||||
pip-wheel-metadata/
|
||||
|
|
|
@ -1,27 +1,37 @@
|
|||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: "v0.4.10"
|
||||
rev: "v0.1.15"
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: ["--fix"]
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.6.0
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: fix-encoding-pragma
|
||||
args: [--remove]
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
exclude: _pytest/(debugging|hookspec).py
|
||||
language_version: python3
|
||||
- repo: https://github.com/adamchainz/blacken-docs
|
||||
rev: 1.16.0
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
additional_dependencies: [black==24.1.1]
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v2.5.0
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
args: ["--max-py-version=3.12", "--include-version-classifiers"]
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: v1.10.0
|
||||
hooks:
|
||||
- id: python-use-type-annotations
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.10.0
|
||||
rev: v1.8.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
files: ^(src/|testing/|scripts/)
|
||||
|
@ -29,7 +39,7 @@ repos:
|
|||
additional_dependencies:
|
||||
- iniconfig>=1.1.0
|
||||
- attrs>=19.2.0
|
||||
- pluggy>=1.5.0
|
||||
- pluggy
|
||||
- packaging
|
||||
- tomli
|
||||
- types-pkg_resources
|
||||
|
@ -37,26 +47,8 @@ repos:
|
|||
# for mypy running on python>=3.11 since exceptiongroup is only a dependency
|
||||
# on <3.11
|
||||
- exceptiongroup>=1.0.0rc8
|
||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
||||
rev: "2.1.3"
|
||||
hooks:
|
||||
- id: pyproject-fmt
|
||||
# https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version
|
||||
additional_dependencies: ["tox>=4.9"]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.16.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
stages: [manual]
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: pylint
|
||||
name: pylint
|
||||
entry: pylint
|
||||
language: system
|
||||
types: [python]
|
||||
args: ["-rn", "-sn", "--fail-on=I"]
|
||||
stages: [manual]
|
||||
- id: rst
|
||||
name: rst
|
||||
entry: rst-lint --encoding utf-8
|
||||
|
@ -66,50 +58,9 @@ repos:
|
|||
- id: changelogs-rst
|
||||
name: changelog filenames
|
||||
language: fail
|
||||
entry: >-
|
||||
changelog files must be named
|
||||
####.(
|
||||
breaking
|
||||
| deprecation
|
||||
| feature
|
||||
| improvement
|
||||
| bugfix
|
||||
| vendor
|
||||
| doc
|
||||
| packaging
|
||||
| contrib
|
||||
| misc
|
||||
)(.#)?(.rst)?
|
||||
exclude: >-
|
||||
(?x)
|
||||
^
|
||||
changelog/(
|
||||
\.gitignore
|
||||
|\d+\.(
|
||||
breaking
|
||||
|deprecation
|
||||
|feature
|
||||
|improvement
|
||||
|bugfix
|
||||
|vendor
|
||||
|doc
|
||||
|packaging
|
||||
|contrib
|
||||
|misc
|
||||
)(\.\d+)?(\.rst)?
|
||||
|README\.rst
|
||||
|_template\.rst
|
||||
)
|
||||
$
|
||||
entry: 'changelog files must be named ####.(breaking|bugfix|deprecation|doc|feature|improvement|trivial|vendor).rst'
|
||||
exclude: changelog/(\d+\.(breaking|bugfix|deprecation|doc|feature|improvement|trivial|vendor).rst|README.rst|_template.rst)
|
||||
files: ^changelog/
|
||||
- id: changelogs-user-role
|
||||
name: Changelog files should use a non-broken :user:`name` role
|
||||
language: pygrep
|
||||
entry: :user:([^`]+`?|`[^`]+[\s,])
|
||||
pass_filenames: true
|
||||
types:
|
||||
- file
|
||||
- rst
|
||||
- id: py-deprecated
|
||||
name: py library is deprecated
|
||||
language: pygrep
|
||||
|
|
|
@ -14,16 +14,11 @@ sphinx:
|
|||
fail_on_warning: true
|
||||
|
||||
build:
|
||||
os: ubuntu-24.04
|
||||
os: ubuntu-20.04
|
||||
tools:
|
||||
python: >-
|
||||
3.12
|
||||
python: "3.9"
|
||||
apt_packages:
|
||||
- inkscape
|
||||
jobs:
|
||||
post_checkout:
|
||||
- git fetch --unshallow || true
|
||||
- git fetch --tags || true
|
||||
|
||||
formats:
|
||||
- epub
|
26
AUTHORS
26
AUTHORS
|
@ -36,7 +36,6 @@ Andrey Paramonov
|
|||
Andrzej Klajnert
|
||||
Andrzej Ostrowski
|
||||
Andy Freeland
|
||||
Anita Hammer
|
||||
Anthon van der Neut
|
||||
Anthony Shaw
|
||||
Anthony Sottile
|
||||
|
@ -57,7 +56,6 @@ Babak Keyvani
|
|||
Barney Gale
|
||||
Ben Brown
|
||||
Ben Gartner
|
||||
Ben Leith
|
||||
Ben Webb
|
||||
Benjamin Peterson
|
||||
Benjamin Schubert
|
||||
|
@ -102,7 +100,6 @@ Cyrus Maden
|
|||
Damian Skrzypczak
|
||||
Daniel Grana
|
||||
Daniel Hahler
|
||||
Daniel Miller
|
||||
Daniel Nuri
|
||||
Daniel Sánchez Castelló
|
||||
Daniel Valenzuela Zenteno
|
||||
|
@ -120,7 +117,6 @@ Daw-Ran Liou
|
|||
Debi Mishra
|
||||
Denis Kirisov
|
||||
Denivy Braiam Rück
|
||||
Dheeraj C K
|
||||
Dhiren Serai
|
||||
Diego Russo
|
||||
Dmitry Dygalo
|
||||
|
@ -131,8 +127,6 @@ Edison Gustavo Muenz
|
|||
Edoardo Batini
|
||||
Edson Tadeu M. Manoel
|
||||
Eduardo Schettino
|
||||
Edward Haigh
|
||||
Eero Vaher
|
||||
Eli Boyarski
|
||||
Elizaveta Shashkova
|
||||
Éloi Rivard
|
||||
|
@ -140,7 +134,6 @@ Endre Galaczi
|
|||
Eric Hunsberger
|
||||
Eric Liu
|
||||
Eric Siegerman
|
||||
Eric Yuan
|
||||
Erik Aronesty
|
||||
Erik Hasse
|
||||
Erik M. Bray
|
||||
|
@ -149,8 +142,6 @@ Evgeny Seliverstov
|
|||
Fabian Sturm
|
||||
Fabien Zarifian
|
||||
Fabio Zadrozny
|
||||
Farbod Ahmadian
|
||||
faph
|
||||
Felix Hofstätter
|
||||
Felix Nieuwenhuizen
|
||||
Feng Ma
|
||||
|
@ -213,7 +204,6 @@ Jordan Guymon
|
|||
Jordan Moldow
|
||||
Jordan Speicher
|
||||
Joseph Hunkeler
|
||||
Joseph Sawaya
|
||||
Josh Karpel
|
||||
Joshua Bronson
|
||||
Jurko Gospodnetić
|
||||
|
@ -242,11 +232,9 @@ Kyle Altendorf
|
|||
Lawrence Mitchell
|
||||
Lee Kamentsky
|
||||
Lev Maximov
|
||||
Levon Saldamli
|
||||
Lewis Cowles
|
||||
Llandy Riveron Del Risco
|
||||
Loic Esteve
|
||||
lovetheguitar
|
||||
Lukas Bednar
|
||||
Luke Murphy
|
||||
Maciek Fijalkowski
|
||||
|
@ -258,11 +246,9 @@ Marc Mueller
|
|||
Marc Schlaich
|
||||
Marcelo Duarte Trevisani
|
||||
Marcin Bachry
|
||||
Marc Bresson
|
||||
Marco Gorelli
|
||||
Mark Abramowitz
|
||||
Mark Dickinson
|
||||
Mark Vong
|
||||
Marko Pacak
|
||||
Markus Unterwaditzer
|
||||
Martijn Faassen
|
||||
|
@ -283,7 +269,6 @@ Michael Droettboom
|
|||
Michael Goerz
|
||||
Michael Krebs
|
||||
Michael Seifert
|
||||
Michael Vogt
|
||||
Michal Wajszczuk
|
||||
Michał Górny
|
||||
Michał Zięba
|
||||
|
@ -294,8 +279,6 @@ Mike Hoyle (hoylemd)
|
|||
Mike Lundy
|
||||
Milan Lesnek
|
||||
Miro Hrončok
|
||||
mrbean-bremen
|
||||
Nathan Goldbaum
|
||||
Nathaniel Compton
|
||||
Nathaniel Waisbrot
|
||||
Ned Batchelder
|
||||
|
@ -305,7 +288,6 @@ Nicholas Devenish
|
|||
Nicholas Murphy
|
||||
Niclas Olofsson
|
||||
Nicolas Delaby
|
||||
Nico Vidal
|
||||
Nikolay Kondratyev
|
||||
Nipunn Koorapati
|
||||
Oleg Pidsadnyi
|
||||
|
@ -331,7 +313,6 @@ Pierre Sassoulas
|
|||
Pieter Mulder
|
||||
Piotr Banaszkiewicz
|
||||
Piotr Helm
|
||||
Poulami Sau
|
||||
Prakhar Gurunani
|
||||
Prashant Anand
|
||||
Prashant Sharma
|
||||
|
@ -366,7 +347,6 @@ Sadra Barikbin
|
|||
Saiprasad Kale
|
||||
Samuel Colvin
|
||||
Samuel Dion-Girardeau
|
||||
Samuel Jirovec
|
||||
Samuel Searles-Bryant
|
||||
Samuel Therrien (Avasam)
|
||||
Samuele Pedroni
|
||||
|
@ -395,7 +375,6 @@ Stefano Taschini
|
|||
Steffen Allner
|
||||
Stephan Obermann
|
||||
Sven-Hendrik Haase
|
||||
Sviatoslav Sydorenko
|
||||
Sylvain Marié
|
||||
Tadek Teleżyński
|
||||
Takafumi Arakaki
|
||||
|
@ -430,14 +409,12 @@ Victor Rodriguez
|
|||
Victor Uriarte
|
||||
Vidar T. Fauske
|
||||
Vijay Arora
|
||||
Virendra Patil
|
||||
Virgil Dupras
|
||||
Vitaly Lashmanov
|
||||
Vivaan Verma
|
||||
Vlad Dragos
|
||||
Vlad Radziuk
|
||||
Vladyslav Rachek
|
||||
Volodymyr Kochetkov
|
||||
Volodymyr Piskun
|
||||
Wei Lin
|
||||
Wil Cooley
|
||||
|
@ -448,14 +425,11 @@ Xixi Zhao
|
|||
Xuan Luong
|
||||
Xuecong Liao
|
||||
Yannick Péroux
|
||||
Yao Xiao
|
||||
Yoav Caspi
|
||||
Yuliang Shao
|
||||
Yusuke Kadowaki
|
||||
Yutian Li
|
||||
Yuval Shimon
|
||||
Zac Hatfield-Dodds
|
||||
Zach Snicker
|
||||
Zachary Kneupper
|
||||
Zachary OBrien
|
||||
Zhouxin Qiu
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
============================
|
||||
Contributing
|
||||
Contribution getting started
|
||||
============================
|
||||
|
||||
Contributions are highly welcomed and appreciated. Every little bit of help counts,
|
||||
so do not hesitate!
|
||||
|
||||
.. contents::
|
||||
:depth: 2
|
||||
:backlinks: none
|
||||
|
||||
|
||||
.. _submitfeedback:
|
||||
|
||||
|
@ -124,7 +128,7 @@ For example:
|
|||
Submitting Plugins to pytest-dev
|
||||
--------------------------------
|
||||
|
||||
Development of the pytest core, support code, and some plugins happens
|
||||
Pytest development of the core, some plugins and support code happens
|
||||
in repositories living under the ``pytest-dev`` organisations:
|
||||
|
||||
- `pytest-dev on GitHub <https://github.com/pytest-dev>`_
|
||||
|
@ -293,12 +297,12 @@ Here is a simple overview, with pytest-specific bits:
|
|||
When committing, ``pre-commit`` will re-format the files if necessary.
|
||||
|
||||
#. If instead of using ``tox`` you prefer to run the tests directly, then we suggest to create a virtual environment and use
|
||||
an editable install with the ``dev`` extra::
|
||||
an editable install with the ``testing`` extra::
|
||||
|
||||
$ python3 -m venv .venv
|
||||
$ source .venv/bin/activate # Linux
|
||||
$ .venv/Scripts/activate.bat # Windows
|
||||
$ pip install -e ".[dev]"
|
||||
$ pip install -e ".[testing]"
|
||||
|
||||
Afterwards, you can edit the files and run pytest normally::
|
||||
|
||||
|
|
|
@ -94,12 +94,12 @@ Features
|
|||
- `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)
|
||||
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.8+ or PyPy3
|
||||
|
||||
- Rich plugin architecture, with over 1300+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ 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
|
||||
|
|
|
@ -23,9 +23,9 @@ members of the `contributors team`_ interested in receiving funding.
|
|||
|
||||
The current list of contributors receiving funding are:
|
||||
|
||||
* `@asottile`_
|
||||
* `@nicoddemus`_
|
||||
* `@The-Compiler`_
|
||||
* `@RonnyPfannschmidt`_
|
||||
|
||||
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
|
||||
|
@ -55,6 +55,6 @@ funds. Just drop a line to one of the `@pytest-dev/tidelift-admins`_ or use the
|
|||
.. _`@pytest-dev/tidelift-admins`: https://github.com/orgs/pytest-dev/teams/tidelift-admins/members
|
||||
.. _`agreement`: https://tidelift.com/docs/lifting/agreement
|
||||
|
||||
.. _`@asottile`: https://github.com/asottile
|
||||
.. _`@nicoddemus`: https://github.com/nicoddemus
|
||||
.. _`@The-Compiler`: https://github.com/The-Compiler
|
||||
.. _`@RonnyPfannschmidt`: https://github.com/RonnyPfannschmidt
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
|
@ -7,10 +5,10 @@ if __name__ == "__main__":
|
|||
import cProfile
|
||||
import pstats
|
||||
|
||||
import pytest # noqa: F401
|
||||
import pytest # NOQA
|
||||
|
||||
script = sys.argv[1:] if len(sys.argv) > 1 else ["empty.py"]
|
||||
cProfile.run(f"pytest.cmdline.main({script!r})", "prof")
|
||||
cProfile.run("pytest.cmdline.main(%r)" % script, "prof")
|
||||
p = pstats.Stats("prof")
|
||||
p.strip_dirs()
|
||||
p.sort_stats("cumulative")
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
# 2.7.5 3.3.2
|
||||
# FilesCompleter 75.1109 69.2116
|
||||
# FastFilesCompleter 0.7383 1.0760
|
||||
from __future__ import annotations
|
||||
|
||||
import timeit
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
from __future__ import annotations
|
||||
|
||||
|
||||
for i in range(1000):
|
||||
exec("def test_func_%d(): pass" % i)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest import TestCase # noqa: F401
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
|
||||
for i in range(5000):
|
||||
exec(
|
||||
f"""
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
*
|
||||
!.gitignore
|
||||
!_template.rst
|
||||
!README.rst
|
||||
!*.bugfix
|
||||
!*.bugfix.rst
|
||||
!*.bugfix.*.rst
|
||||
!*.breaking
|
||||
!*.breaking.rst
|
||||
!*.breaking.*.rst
|
||||
!*.contrib
|
||||
!*.contrib.rst
|
||||
!*.contrib.*.rst
|
||||
!*.deprecation
|
||||
!*.deprecation.rst
|
||||
!*.deprecation.*.rst
|
||||
!*.doc
|
||||
!*.doc.rst
|
||||
!*.doc.*.rst
|
||||
!*.feature
|
||||
!*.feature.rst
|
||||
!*.feature.*.rst
|
||||
!*.improvement
|
||||
!*.improvement.rst
|
||||
!*.improvement.*.rst
|
||||
!*.misc
|
||||
!*.misc.rst
|
||||
!*.misc.*.rst
|
||||
!*.packaging
|
||||
!*.packaging.rst
|
||||
!*.packaging.*.rst
|
||||
!*.vendor
|
||||
!*.vendor.rst
|
||||
!*.vendor.*.rst
|
|
@ -1,4 +0,0 @@
|
|||
Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
|
||||
|
||||
Originally added in pytest 8.0.0, but reverted in 8.0.2 due to a regression in pytest-xdist.
|
||||
This regression was fixed in pytest-xdist 3.6.1.
|
|
@ -1 +0,0 @@
|
|||
:func:`pytest.approx` now correctly handles :class:`Sequence <collections.abc.Sequence>`-like objects.
|
|
@ -1 +0,0 @@
|
|||
Documented using :envvar:`PYTEST_VERSION` to detect if code is running from within a pytest run.
|
|
@ -1,11 +0,0 @@
|
|||
Fixed a regression in pytest 8.0 where tracebacks get longer and longer when multiple
|
||||
tests fail due to a shared higher-scope fixture which raised -- by :user:`bluetech`.
|
||||
|
||||
Also fixed a similar regression in pytest 5.4 for collectors which raise during setup.
|
||||
|
||||
The fix necessitated internal changes which may affect some plugins:
|
||||
|
||||
* ``FixtureDef.cached_result[2]`` is now a tuple ``(exc, tb)``
|
||||
instead of ``exc``.
|
||||
* ``SetupState.stack`` failures are now a tuple ``(exc, tb)``
|
||||
instead of ``exc``.
|
|
@ -1,11 +0,0 @@
|
|||
Added `--xfail-tb` flag, which turns on traceback output for XFAIL results.
|
||||
|
||||
* If the `--xfail-tb` flag is not sent, tracebacks for XFAIL results are NOT shown.
|
||||
* The style of traceback for XFAIL is set with `--tb`, and can be `auto|long|short|line|native|no`.
|
||||
* Note: Even if you have `--xfail-tb` set, you won't see them if `--tb=no`.
|
||||
|
||||
Some history:
|
||||
|
||||
With pytest 8.0, `-rx` or `-ra` would not only turn on summary reports for xfail, but also report the tracebacks for xfail results. This caused issues with some projects that utilize xfail, but don't want to see all of the xfail tracebacks.
|
||||
|
||||
This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. With this, the default `-rx`/ `-ra` behavior is identical to pre-8.0 with respect to xfail tracebacks. While this is a behavior change, it brings default behavior back to pre-8.0.0 behavior, which ultimately was considered the better course of action.
|
|
@ -1 +0,0 @@
|
|||
12204.bugfix.rst
|
|
@ -1 +0,0 @@
|
|||
Fix collection error upon encountering an :mod:`abstract <abc>` class, including abstract `unittest.TestCase` subclasses.
|
|
@ -1,8 +0,0 @@
|
|||
Added support for keyword matching in marker expressions.
|
||||
|
||||
Now tests can be selected by marker keyword arguments.
|
||||
Supported values are :class:`int`, (unescaped) :class:`str`, :class:`bool` & :data:`None`.
|
||||
|
||||
See :ref:`marker examples <marker_keyword_expression_example>` for more information.
|
||||
|
||||
-- by :user:`lovetheguitar`
|
|
@ -1 +0,0 @@
|
|||
Fix a regression in pytest 8.0.0 where package-scoped parameterized items were not correctly reordered to minimize setups/teardowns in some cases.
|
|
@ -0,0 +1 @@
|
|||
The documentation webpages now links to a canonical version to reduce outdated documentation in search engine results.
|
|
@ -1 +0,0 @@
|
|||
Fix crash with `assert testcase is not None` assertion failure when re-running unittest tests using plugins like pytest-rerunfailures. Regressed in 8.2.2.
|
|
@ -1,3 +0,0 @@
|
|||
Migrated all internal type-annotations to the python3.10+ style by using the `annotations` future import.
|
||||
|
||||
-- by :user:`RonnyPfannschmidt`
|
|
@ -1,6 +0,0 @@
|
|||
The external plugin mentions in the documentation now avoid mentioning
|
||||
:std:doc:`setuptools entry-points <setuptools:index>` as the concept is
|
||||
much more generic nowadays. Instead, the terminology of "external",
|
||||
"installed", or "third-party" plugins (or packages) replaces that.
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1,4 +0,0 @@
|
|||
The console output now uses the "third-party plugins" terminology,
|
||||
replacing the previously established but confusing and outdated
|
||||
reference to :std:doc:`setuptools <setuptools:index>`
|
||||
-- by :user:`webknjaz`.
|
|
@ -1 +0,0 @@
|
|||
Fixed a crash when returning category ``"error"`` or ``"failed"`` with a custom test status from :hook:`pytest_report_teststatus` hook -- :user:`pbrezina`.
|
|
@ -1,13 +0,0 @@
|
|||
The change log draft preview integration has been refactored to use a
|
||||
third party extension ``sphinxcontib-towncrier``. The previous in-repo
|
||||
script was putting the change log preview file at
|
||||
:file:`doc/en/_changelog_towncrier_draft.rst`. Said file is no longer
|
||||
ignored in Git and might show up among untracked files in the
|
||||
development environments of the contributors. To address that, the
|
||||
contributors can run the following command that will clean it up:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ git clean -x -i -- doc/en/_changelog_towncrier_draft.rst
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1,5 +0,0 @@
|
|||
All the undocumented ``tox`` environments now have descriptions.
|
||||
They can be listed in one's development environment by invoking
|
||||
``tox -av`` in a terminal.
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1,11 +0,0 @@
|
|||
The changelog configuration has been updated to introduce more accurate
|
||||
audience-tailored categories. Previously, there was a ``trivial``
|
||||
change log fragment type with an unclear and broad meaning. It was
|
||||
removed and we now have ``contrib``, ``misc`` and ``packaging`` in
|
||||
place of it.
|
||||
|
||||
The new change note types target the readers who are downstream
|
||||
packagers and project contributors. Additionally, the miscellaneous
|
||||
section is kept for unspecified updates that do not fit anywhere else.
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1,7 +0,0 @@
|
|||
The UX of the GitHub automation making pull requests to update the
|
||||
plugin list has been updated. Previously, the maintainers had to close
|
||||
the automatically created pull requests and re-open them to trigger the
|
||||
CI runs. From now on, they only need to click the `Ready for review`
|
||||
button instead.
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1 +0,0 @@
|
|||
Improve handling of invalid regex patterns in :func:`pytest.raises(match=r'...') <pytest.raises>` by providing a clear error message.
|
|
@ -1,4 +0,0 @@
|
|||
The ``:pull:`` RST role has been replaced with a shorter
|
||||
``:pr:`` due to starting to use the implementation from
|
||||
the third-party :pypi:`sphinx-issues` Sphinx extension
|
||||
-- by :user:`webknjaz`.
|
|
@ -1,6 +0,0 @@
|
|||
The coverage reporting configuration has been updated to exclude
|
||||
pytest's own tests marked as expected to fail from the coverage
|
||||
report. This has an effect of reducing the influence of flaky
|
||||
tests on the resulting number.
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1,7 +0,0 @@
|
|||
The ``extlinks`` Sphinx extension is no longer enabled. The ``:bpo:``
|
||||
role it used to declare has been removed with that. BPO itself has
|
||||
migrated to GitHub some years ago and it is possible to link the
|
||||
respective issues by using their GitHub issue numbers and the
|
||||
``:issue:`` role that the ``sphinx-issues`` extension implements.
|
||||
|
||||
-- by :user:`webknjaz`
|
|
@ -1,3 +0,0 @@
|
|||
The ``_in_venv()`` function now detects Python virtual environments by
|
||||
checking for a :file:`pyvenv.cfg` file, ensuring reliable detection on
|
||||
various platforms -- by :user:`zachsnickers`.
|
|
@ -1 +0,0 @@
|
|||
12544.improvement.rst
|
|
@ -1,2 +0,0 @@
|
|||
Possible typos in using the ``:user:`` RST role is now being linted
|
||||
through the pre-commit tool integration -- by :user:`webknjaz`.
|
|
@ -1 +0,0 @@
|
|||
Do not truncate arguments to functions in output when running with `-vvv`.
|
|
@ -1,38 +0,0 @@
|
|||
The readability of assertion introspection of bound methods has been enhanced
|
||||
-- by :user:`farbodahm`, :user:`webknjaz`, :user:`obestwalter`, :user:`flub`
|
||||
and :user:`glyphack`.
|
||||
|
||||
Earlier, it was like:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
=================================== FAILURES ===================================
|
||||
_____________________________________ test _____________________________________
|
||||
|
||||
def test():
|
||||
> assert Help().fun() == 2
|
||||
E assert 1 == 2
|
||||
E + where 1 = <bound method Help.fun of <example.Help instance at 0x256a830>>()
|
||||
E + where <bound method Help.fun of <example.Help instance at 0x256a830>> = <example.Help instance at 0x256a830>.fun
|
||||
E + where <example.Help instance at 0x256a830> = Help()
|
||||
|
||||
example.py:7: AssertionError
|
||||
=========================== 1 failed in 0.03 seconds ===========================
|
||||
|
||||
|
||||
And now it's like:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
=================================== FAILURES ===================================
|
||||
_____________________________________ test _____________________________________
|
||||
|
||||
def test():
|
||||
> assert Help().fun() == 2
|
||||
E assert 1 == 2
|
||||
E + where 1 = fun()
|
||||
E + where fun = <test_local.Help object at 0x1074be230>.fun
|
||||
E + where <test_local.Help object at 0x1074be230> = Help()
|
||||
|
||||
test_local.py:13: AssertionError
|
||||
=========================== 1 failed in 0.03 seconds ===========================
|
|
@ -1 +0,0 @@
|
|||
Fixed progress percentages (the ``[ 87%]`` at the edge of the screen) sometimes not aligning correctly when running with pytest-xdist ``-n``.
|
|
@ -1 +0,0 @@
|
|||
Added timezone information to the testsuite timestamp in the JUnit XML report.
|
|
@ -20,22 +20,10 @@ Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
|
|||
* ``deprecation``: feature deprecation.
|
||||
* ``breaking``: a change which may break existing suites, such as feature removal or behavior change.
|
||||
* ``vendor``: changes in packages vendored in pytest.
|
||||
* ``packaging``: notes for downstreams about unobvious side effects
|
||||
and tooling. changes in the test invocation considerations and
|
||||
runtime assumptions.
|
||||
* ``contrib``: stuff that affects the contributor experience. e.g.
|
||||
Running tests, building the docs, setting up the development
|
||||
environment.
|
||||
* ``misc``: changes that are hard to assign to any of the above
|
||||
categories.
|
||||
* ``trivial``: fixing a small typo or internal change that might be noteworthy.
|
||||
|
||||
So for example: ``123.feature.rst``, ``456.bugfix.rst``.
|
||||
|
||||
.. tip::
|
||||
|
||||
See :file:`pyproject.toml` for all available categories
|
||||
(``tool.towncrier.type``).
|
||||
|
||||
If your PR fixes an issue, use that number here. If there is no issue,
|
||||
then after you submit the PR and get the PR number you can add a
|
||||
changelog using that instead.
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
# reference: https://docs.codecov.io/docs/codecovyml-reference
|
||||
---
|
||||
|
||||
codecov:
|
||||
token: 1eca3b1f-31a2-4fb8-a8c3-138b441b50a7 #repo token
|
||||
|
||||
coverage:
|
||||
status:
|
||||
patch: true
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<style>
|
||||
.logo {text-align: center;}
|
||||
</style>
|
||||
|
||||
<a class="logo" href="{{ pathto('contents') }}">
|
||||
<img src="{{ pathto('_static/pytest1.png', 1) }}" width="70%" height="70%" text="Pytest Logo"/>
|
||||
</a>
|
|
@ -0,0 +1,14 @@
|
|||
{#
|
||||
basic/searchbox.html with heading removed.
|
||||
#}
|
||||
{%- if pagename != "search" and builder != "singlehtml" %}
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="{{ pathto('search') }}" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="{{ _('Go') }}" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>document.getElementById('searchbox').style.display = "block"</script>
|
||||
{%- endif %}
|
|
@ -1,7 +0,0 @@
|
|||
<style>
|
||||
ul {list-style: none;}
|
||||
li {margin: 0.4em 0;}
|
||||
@media (min-width: 46em) {
|
||||
#features {width: 50%;}
|
||||
}
|
||||
</style>
|
|
@ -44,7 +44,7 @@ Partner projects, sign up here! (by 22 March)
|
|||
What does it mean to "adopt pytest"?
|
||||
-----------------------------------------
|
||||
|
||||
There can be many different definitions of "success". Pytest can run many unittest_ tests by default, so using pytest as your testrunner may be possible from day 1. Job done, right?
|
||||
There can be many different definitions of "success". Pytest can run many nose_ and unittest_ tests by default, so using pytest as your testrunner may be possible from day 1. Job done, right?
|
||||
|
||||
Progressive success might look like:
|
||||
|
||||
|
@ -62,6 +62,7 @@ Progressive success might look like:
|
|||
|
||||
It may be after the month is up, the partner project decides that pytest is not right for it. That's okay - hopefully the pytest team will also learn something about its weaknesses or deficiencies.
|
||||
|
||||
.. _nose: nose.html
|
||||
.. _unittest: unittest.html
|
||||
.. _assert: assert.html
|
||||
.. _pycmd: https://bitbucket.org/hpk42/pycmd/overview
|
||||
|
|
|
@ -6,12 +6,6 @@ Release announcements
|
|||
:maxdepth: 2
|
||||
|
||||
|
||||
release-8.2.2
|
||||
release-8.2.1
|
||||
release-8.2.0
|
||||
release-8.1.2
|
||||
release-8.1.1
|
||||
release-8.1.0
|
||||
release-8.0.2
|
||||
release-8.0.1
|
||||
release-8.0.0
|
||||
|
|
|
@ -62,7 +62,7 @@ New Features
|
|||
- new "-q" option which decreases verbosity and prints a more
|
||||
nose/unittest-style "dot" output.
|
||||
|
||||
- many, many, more detailed improvements details
|
||||
- many many more detailed improvements details
|
||||
|
||||
Fixes
|
||||
-----------------------
|
||||
|
@ -109,7 +109,7 @@ Important Notes
|
|||
in conftest.py files. They will cause nothing special.
|
||||
- removed support for calling the pre-1.0 collection API of "run()" and "join"
|
||||
- removed reading option values from conftest.py files or env variables.
|
||||
This can now be done much, much, better and easier through the ini-file
|
||||
This can now be done much much better and easier through the ini-file
|
||||
mechanism and the "addopts" entry in particular.
|
||||
- removed the "disabled" attribute in test classes. Use the skipping
|
||||
and pytestmark mechanism to skip or xfail a test class.
|
||||
|
|
|
@ -4,7 +4,7 @@ pytest-2.2.2: bug fixes
|
|||
pytest-2.2.2 (updated to 2.2.3 to fix packaging issues) is a minor
|
||||
backward-compatible release of the versatile py.test testing tool. It
|
||||
contains bug fixes and a few refinements particularly to reporting with
|
||||
"--collectonly", see below for details.
|
||||
"--collectonly", see below for betails.
|
||||
|
||||
For general information see here:
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ Bug fixes:
|
|||
partially failed (finalizers would not always be called before)
|
||||
|
||||
- fix issue320 - fix class scope for fixtures when mixed with
|
||||
module-level functions. Thanks Anatoly Bubenkoff.
|
||||
module-level functions. Thanks Anatloy Bubenkoff.
|
||||
|
||||
- you can specify "-q" or "-qq" to get different levels of "quieter"
|
||||
reporting (thanks Katarzyna Jachim)
|
||||
|
|
|
@ -83,7 +83,7 @@ holger krekel
|
|||
Thanks Ralph Schmitt for the precise failure example.
|
||||
|
||||
- fix issue244 by implementing special index for parameters to only use
|
||||
indices for parametrized test ids
|
||||
indices for paramentrized test ids
|
||||
|
||||
- fix issue287 by running all finalizers but saving the exception
|
||||
from the first failing finalizer and re-raising it so teardown will
|
||||
|
|
|
@ -73,7 +73,7 @@ holger krekel
|
|||
- cleanup setup.py a bit and specify supported versions. Thanks Jurko
|
||||
Gospodnetic for the PR.
|
||||
|
||||
- change XPASS colour to yellow rather than red when tests are run
|
||||
- change XPASS colour to yellow rather then red when tests are run
|
||||
with -v.
|
||||
|
||||
- fix issue473: work around mock putting an unbound method into a class
|
||||
|
|
|
@ -55,7 +55,7 @@ holger krekel
|
|||
github. See https://pytest.org/en/stable/contributing.html .
|
||||
Thanks to Anatoly for pushing and initial work on this.
|
||||
|
||||
- fix issue650: new option ``--doctest-ignore-import-errors`` which
|
||||
- fix issue650: new option ``--docttest-ignore-import-errors`` which
|
||||
will turn import errors in doctests into skips. Thanks Charles Cloud
|
||||
for the complete PR.
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ The py.test Development Team
|
|||
**New Features**
|
||||
|
||||
* New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
|
||||
Thanks :user:`MichaelAquilina` for the complete PR (:pr:`1040`).
|
||||
Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
|
||||
|
||||
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
||||
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
|
||||
|
|
|
@ -44,7 +44,7 @@ The py.test Development Team
|
|||
Thanks :user:`nicoddemus` for the PR.
|
||||
|
||||
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
|
||||
contain ``::``. Thanks :user:`tomviner` for the PR (:pr:`1431`).
|
||||
contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
|
||||
|
||||
* Fix (:issue:`578`): SyntaxErrors
|
||||
containing non-ascii lines at the point of failure generated an internal
|
||||
|
|
|
@ -44,14 +44,14 @@ The py.test Development Team
|
|||
|
||||
* Fix Xfail does not work with condition keyword argument.
|
||||
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
|
||||
for PR the (:pr:`1524`).
|
||||
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 :user:`prusse-martin` for the PR (:pr:`1506`).
|
||||
Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
|
||||
|
||||
* Fix ``pytest.mark.skip`` mark when used in strict mode.
|
||||
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
pytest-8.1.0
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.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:
|
||||
|
||||
* Ben Brown
|
||||
* Ben Leith
|
||||
* Bruno Oliveira
|
||||
* Clément Robert
|
||||
* Dave Hall
|
||||
* Dương Quốc Khánh
|
||||
* Eero Vaher
|
||||
* Eric Larson
|
||||
* Fabian Sturm
|
||||
* Faisal Fawad
|
||||
* Florian Bruhin
|
||||
* Franck Charras
|
||||
* Joachim B Haga
|
||||
* John Litborn
|
||||
* Loïc Estève
|
||||
* Marc Bresson
|
||||
* Patrick Lannigan
|
||||
* Pierre Sassoulas
|
||||
* Ran Benita
|
||||
* Reagan Lee
|
||||
* Ronny Pfannschmidt
|
||||
* Russell Martin
|
||||
* clee2000
|
||||
* donghui
|
||||
* faph
|
||||
* jakkdl
|
||||
* mrbean-bremen
|
||||
* robotherapist
|
||||
* whysage
|
||||
* woutdenolf
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
|
@ -1,18 +0,0 @@
|
|||
pytest-8.1.1
|
||||
=======================================
|
||||
|
||||
pytest 8.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
|
|
@ -1,18 +0,0 @@
|
|||
pytest-8.1.2
|
||||
=======================================
|
||||
|
||||
pytest 8.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:
|
||||
|
||||
* Bruno Oliveira
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
|
@ -1,43 +0,0 @@
|
|||
pytest-8.2.0
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.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:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Daniel Miller
|
||||
* Florian Bruhin
|
||||
* HolyMagician03-UMich
|
||||
* John Litborn
|
||||
* Levon Saldamli
|
||||
* Linghao Zhang
|
||||
* Manuel López-Ibáñez
|
||||
* Pierre Sassoulas
|
||||
* Ran Benita
|
||||
* Ronny Pfannschmidt
|
||||
* Sebastian Meyer
|
||||
* Shekhar verma
|
||||
* Tamir Duberstein
|
||||
* Tobias Stoeckmann
|
||||
* dj
|
||||
* jakkdl
|
||||
* poulami-sau
|
||||
* tserg
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
|
@ -1,19 +0,0 @@
|
|||
pytest-8.2.1
|
||||
=======================================
|
||||
|
||||
pytest 8.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:
|
||||
|
||||
* Bruno Oliveira
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
|
@ -1,19 +0,0 @@
|
|||
pytest-8.2.2
|
||||
=======================================
|
||||
|
||||
pytest 8.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
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
|
@ -49,7 +49,7 @@ place on 20th, 21st, 22nd, 24th and 25th. On the 23rd we took a break
|
|||
day for some hot hiking in the Black Forest.
|
||||
|
||||
Sprint activity was organised heavily around pairing, with plenty of group
|
||||
discussions to take advantage of the high bandwidth, and lightning talks
|
||||
discusssions to take advantage of the high bandwidth, and lightning talks
|
||||
as well.
|
||||
|
||||
|
||||
|
|
|
@ -5,26 +5,30 @@ Backwards Compatibility Policy
|
|||
|
||||
.. versionadded: 6.0
|
||||
|
||||
Pytest is an actively evolving project that has been decades in the making.
|
||||
We keep learning about new and better structures to express different details about testing.
|
||||
pytest is actively evolving and is a project that has been decades in the making,
|
||||
we keep learning about new and better structures to express different details about testing.
|
||||
|
||||
While we implement those modifications, we try to ensure an easy transition and don't want to impose unnecessary churn on our users and community/plugin authors.
|
||||
While we implement those modifications we try to ensure an easy transition and don't want to impose unnecessary churn on our users and community/plugin authors.
|
||||
|
||||
As of now, pytest considers multiple types of backward compatibility transitions:
|
||||
|
||||
a) trivial: APIs that trivially translate to the new mechanism and do not cause problematic changes.
|
||||
a) trivial: APIs which trivially translate to the new mechanism,
|
||||
and do not cause problematic changes.
|
||||
|
||||
We try to support those indefinitely while encouraging users to switch to newer or better mechanisms through documentation.
|
||||
We try to support those indefinitely while encouraging users to switch to newer/better mechanisms through documentation.
|
||||
|
||||
b) transitional: the old and new APIs don't conflict, and we can help users transition by using warnings while supporting both for a prolonged period of time.
|
||||
b) transitional: the old and new API don't conflict
|
||||
and we can help users transition by using warnings, while supporting both for a prolonged time.
|
||||
|
||||
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).
|
||||
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).
|
||||
|
||||
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.
|
||||
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 a normal transition is unreasonably unsustainable and would offset important developments or features by years. In addition, they should be limited to APIs where the number of actual users is very small (for example, only impacting some plugins) and can be coordinated with the community in advance.
|
||||
|
||||
c) true breakage: should only be considered when normal transition is unreasonably unsustainable and would offset important development/features by years.
|
||||
In addition, they should be limited to APIs where the number of actual users is very small (for example only impacting some plugins), and can be coordinated with the community in advance.
|
||||
|
||||
Examples for such upcoming changes:
|
||||
|
||||
|
@ -58,11 +62,11 @@ Focus primary on smooth transition - stance (pre 6.0)
|
|||
|
||||
Keeping backwards compatibility has a very high priority in the pytest project. Although we have deprecated functionality over the years, most of it is still supported. All deprecations in pytest were done because simpler or more efficient ways of accomplishing the same tasks have emerged, making the old way of doing things unnecessary.
|
||||
|
||||
With the pytest 3.0 release, we introduced a clear communication scheme for when we will actually remove the old busted joint and politely ask you to use the new hotness instead, while giving you enough time to adjust your tests or raise concerns if there are valid reasons to keep deprecated functionality around.
|
||||
With the pytest 3.0 release we introduced a clear communication scheme for when we will actually remove the old busted joint and politely ask you to use the new hotness instead, while giving you enough time to adjust your tests or raise concerns if there are valid reasons to keep deprecated functionality around.
|
||||
|
||||
To communicate changes, we issue deprecation warnings using a custom warning hierarchy (see :ref:`internal-warnings`). These warnings may be suppressed using the standard means: ``-W`` command-line flag or ``filterwarnings`` ini options (see :ref:`warnings`), but we suggest to use these sparingly and temporarily, and heed the warnings when possible.
|
||||
To communicate changes we issue deprecation warnings using a custom warning hierarchy (see :ref:`internal-warnings`). These warnings may be suppressed using the standard means: ``-W`` command-line flag or ``filterwarnings`` ini options (see :ref:`warnings`), but we suggest to use these sparingly and temporarily, and heed the warnings when possible.
|
||||
|
||||
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).
|
||||
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.
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
cachedir: .pytest_cache
|
||||
rootdir: /home/sweet/project
|
||||
collected 0 items
|
||||
cache -- .../_pytest/cacheprovider.py:560
|
||||
cache -- .../_pytest/cacheprovider.py:527
|
||||
Return a cache object that can persist state between testing sessions.
|
||||
|
||||
cache.get(key, default)
|
||||
|
@ -33,7 +33,7 @@ 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.
|
||||
|
||||
capsysbinary -- .../_pytest/capture.py:1003
|
||||
capsysbinary -- .../_pytest/capture.py:1007
|
||||
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
||||
|
||||
The captured output is made available via ``capsysbinary.readouterr()``
|
||||
|
@ -50,7 +50,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
captured = capsysbinary.readouterr()
|
||||
assert captured.out == b"hello\n"
|
||||
|
||||
capfd -- .../_pytest/capture.py:1030
|
||||
capfd -- .../_pytest/capture.py:1034
|
||||
Enable text capturing of writes to file descriptors ``1`` and ``2``.
|
||||
|
||||
The captured output is made available via ``capfd.readouterr()`` method
|
||||
|
@ -67,7 +67,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
captured = capfd.readouterr()
|
||||
assert captured.out == "hello\n"
|
||||
|
||||
capfdbinary -- .../_pytest/capture.py:1057
|
||||
capfdbinary -- .../_pytest/capture.py:1061
|
||||
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
|
||||
|
||||
The captured output is made available via ``capfd.readouterr()`` method
|
||||
|
@ -84,7 +84,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
captured = capfdbinary.readouterr()
|
||||
assert captured.out == b"hello\n"
|
||||
|
||||
capsys -- .../_pytest/capture.py:976
|
||||
capsys -- .../_pytest/capture.py:980
|
||||
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
||||
|
||||
The captured output is made available via ``capsys.readouterr()`` method
|
||||
|
@ -101,7 +101,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
captured = capsys.readouterr()
|
||||
assert captured.out == "hello\n"
|
||||
|
||||
doctest_namespace [session scope] -- .../_pytest/doctest.py:738
|
||||
doctest_namespace [session scope] -- .../_pytest/doctest.py:745
|
||||
Fixture that returns a :py:class:`dict` that will be injected into the
|
||||
namespace of doctests.
|
||||
|
||||
|
@ -115,7 +115,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
|
||||
For more details: :ref:`doctest_namespace`.
|
||||
|
||||
pytestconfig [session scope] -- .../_pytest/fixtures.py:1338
|
||||
pytestconfig [session scope] -- .../_pytest/fixtures.py:1354
|
||||
Session-scoped fixture that returns the session's :class:`pytest.Config`
|
||||
object.
|
||||
|
||||
|
@ -125,7 +125,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
if pytestconfig.getoption("verbose") > 0:
|
||||
...
|
||||
|
||||
record_property -- .../_pytest/junitxml.py:284
|
||||
record_property -- .../_pytest/junitxml.py:283
|
||||
Add extra properties to the calling test.
|
||||
|
||||
User properties become part of the test report and are available to the
|
||||
|
@ -139,13 +139,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 -- .../_pytest/junitxml.py:307
|
||||
record_xml_attribute -- .../_pytest/junitxml.py:306
|
||||
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] -- .../_pytest/junitxml.py:345
|
||||
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:344
|
||||
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
|
||||
|
||||
This is suitable to writing global information regarding the entire test
|
||||
|
@ -170,18 +170,18 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
`pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
|
||||
:issue:`7767` for details.
|
||||
|
||||
tmpdir_factory [session scope] -- .../_pytest/legacypath.py:303
|
||||
tmpdir_factory [session scope] -- .../_pytest/legacypath.py:302
|
||||
Return a :class:`pytest.TempdirFactory` instance for the test session.
|
||||
|
||||
tmpdir -- .../_pytest/legacypath.py:310
|
||||
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:`temporary directory location and retention`.
|
||||
``--basetemp`` is used then it is cleared each session. See :ref:`base
|
||||
temporary directory`.
|
||||
|
||||
The returned object is a `legacy_path`_ object.
|
||||
|
||||
|
@ -192,7 +192,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
|
||||
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
|
||||
|
||||
caplog -- .../_pytest/logging.py:602
|
||||
caplog -- .../_pytest/logging.py:594
|
||||
Access and control log capturing.
|
||||
|
||||
Captured logs are available through the following properties/methods::
|
||||
|
@ -203,7 +203,7 @@ 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 -- .../_pytest/monkeypatch.py:33
|
||||
monkeypatch -- .../_pytest/monkeypatch.py:32
|
||||
A convenient fixture for monkey-patching.
|
||||
|
||||
The fixture provides these methods to modify objects, dictionaries, or
|
||||
|
@ -233,10 +233,10 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
|
||||
on warning categories.
|
||||
|
||||
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242
|
||||
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:241
|
||||
Return a :class:`pytest.TempPathFactory` instance for the test session.
|
||||
|
||||
tmp_path -- .../_pytest/tmpdir.py:257
|
||||
tmp_path -- .../_pytest/tmpdir.py:256
|
||||
Return a temporary directory path object which is unique to each test
|
||||
function invocation, created as a sub directory of the base temporary
|
||||
directory.
|
||||
|
@ -245,8 +245,8 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
|||
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:`temporary directory location and retention`.
|
||||
If ``--basetemp`` is used then it is cleared each session. See :ref:`base
|
||||
temporary directory`.
|
||||
|
||||
The returned object is a :class:`pathlib.Path` object.
|
||||
|
||||
|
|
|
@ -19,308 +19,15 @@ with advance notice in the **Deprecations** section of releases.
|
|||
we named the news folder changelog
|
||||
|
||||
|
||||
.. only:: not is_release
|
||||
.. only:: changelog_towncrier_draft
|
||||
|
||||
To be included in v\ |release| (if present)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
.. The 'changelog_towncrier_draft' tag is included by our 'tox -e docs',
|
||||
but not on readthedocs.
|
||||
|
||||
.. towncrier-draft-entries:: |release| [UNRELEASED DRAFT]
|
||||
|
||||
Released versions
|
||||
^^^^^^^^^^^^^^^^^
|
||||
.. include:: _changelog_towncrier_draft.rst
|
||||
|
||||
.. towncrier release notes start
|
||||
|
||||
pytest 8.2.2 (2024-06-04)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#12355 <https://github.com/pytest-dev/pytest/issues/12355>`_: Fix possible catastrophic performance slowdown on a certain parametrization pattern involving many higher-scoped parameters.
|
||||
|
||||
|
||||
- `#12367 <https://github.com/pytest-dev/pytest/issues/12367>`_: Fix a regression in pytest 8.2.0 where unittest class instances (a fresh one is created for each test) were not released promptly on test teardown but only on session teardown.
|
||||
|
||||
|
||||
- `#12381 <https://github.com/pytest-dev/pytest/issues/12381>`_: Fix possible "Directory not empty" crashes arising from concurent cache dir (``.pytest_cache``) creation. Regressed in pytest 8.2.0.
|
||||
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- `#12290 <https://github.com/pytest-dev/pytest/issues/12290>`_: Updated Sphinx theme to use Furo instead of Flask, enabling Dark mode theme.
|
||||
|
||||
|
||||
- `#12356 <https://github.com/pytest-dev/pytest/issues/12356>`_: Added a subsection to the documentation for debugging flaky tests to mention
|
||||
lack of thread safety in pytest as a possible source of flakyness.
|
||||
|
||||
|
||||
- `#12363 <https://github.com/pytest-dev/pytest/issues/12363>`_: The documentation webpages now links to a canonical version to reduce outdated documentation in search engine results.
|
||||
|
||||
|
||||
pytest 8.2.1 (2024-05-19)
|
||||
=========================
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#12334 <https://github.com/pytest-dev/pytest/issues/12334>`_: Support for Python 3.13 (beta1 at the time of writing).
|
||||
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#12120 <https://github.com/pytest-dev/pytest/issues/12120>`_: Fix `PermissionError` crashes arising from directories which are not selected on the command-line.
|
||||
|
||||
|
||||
- `#12191 <https://github.com/pytest-dev/pytest/issues/12191>`_: Keyboard interrupts and system exits are now properly handled during the test collection.
|
||||
|
||||
|
||||
- `#12300 <https://github.com/pytest-dev/pytest/issues/12300>`_: Fixed handling of 'Function not implemented' error under squashfuse_ll, which is a different way to say that the mountpoint is read-only.
|
||||
|
||||
|
||||
- `#12308 <https://github.com/pytest-dev/pytest/issues/12308>`_: Fix a regression in pytest 8.2.0 where the permissions of automatically-created ``.pytest_cache`` directories became ``rwx------`` instead of the expected ``rwxr-xr-x``.
|
||||
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#12333 <https://github.com/pytest-dev/pytest/issues/12333>`_: pytest releases are now attested using the recent `Artifact Attestation <https://github.blog/2024-05-02-introducing-artifact-attestations-now-in-public-beta/>`_ support from GitHub, allowing users to verify the provenance of pytest's sdist and wheel artifacts.
|
||||
|
||||
|
||||
pytest 8.2.0 (2024-04-27)
|
||||
=========================
|
||||
|
||||
Breaking Changes
|
||||
----------------
|
||||
|
||||
- `#12089 <https://github.com/pytest-dev/pytest/pull/12089>`_: pytest now requires that :class:`unittest.TestCase` subclasses can be instantiated freely using ``MyTestCase('runTest')``.
|
||||
|
||||
If the class doesn't allow this, you may see an error during collection such as ``AttributeError: 'MyTestCase' object has no attribute 'runTest'``.
|
||||
|
||||
Classes which do not override ``__init__``, or do not access the test method in ``__init__`` using ``getattr`` or similar, are unaffected.
|
||||
|
||||
Classes which do should take care to not crash when ``"runTest"`` is given, as is shown in `unittest.TestCases's implementation <https://github.com/python/cpython/blob/51aefc5bf907ddffaaf083ded0de773adcdf08c8/Lib/unittest/case.py#L419-L426>`_.
|
||||
Alternatively, consider using :meth:`setUp <unittest.TestCase.setUp>` instead of ``__init__``.
|
||||
|
||||
If you run into this issue using ``tornado.AsyncTestCase``, please see `issue 12263 <https://github.com/pytest-dev/pytest/issues/12263>`_.
|
||||
|
||||
If you run into this issue using an abstract ``TestCase`` subclass, please see `issue 12275 <https://github.com/pytest-dev/pytest/issues/12275>`_.
|
||||
|
||||
Historical note: the effect of this change on custom TestCase implementations was not properly considered initially, this is why it was done in a minor release. We apologize for the inconvenience.
|
||||
|
||||
Deprecations
|
||||
------------
|
||||
|
||||
- `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: A deprecation warning is now raised when implementations of one of the following hooks request a deprecated ``py.path.local`` parameter instead of the ``pathlib.Path`` parameter which replaced it:
|
||||
|
||||
- :hook:`pytest_ignore_collect` - the ``path`` parameter - use ``collection_path`` instead.
|
||||
- :hook:`pytest_collect_file` - the ``path`` parameter - use ``file_path`` instead.
|
||||
- :hook:`pytest_pycollect_makemodule` - the ``path`` parameter - use ``module_path`` instead.
|
||||
- :hook:`pytest_report_header` - the ``startdir`` parameter - use ``start_path`` instead.
|
||||
- :hook:`pytest_report_collectionfinish` - the ``startdir`` parameter - use ``start_path`` instead.
|
||||
|
||||
The replacement parameters are available since pytest 7.0.0.
|
||||
The old parameters will be removed in pytest 9.0.0.
|
||||
|
||||
See :ref:`legacy-path-hooks-deprecated` for more details.
|
||||
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- `#11871 <https://github.com/pytest-dev/pytest/issues/11871>`_: Added support for reading command line arguments from a file using the prefix character ``@``, like e.g.: ``pytest @tests.txt``. The file must have one argument per line.
|
||||
|
||||
See :ref:`Read arguments from file <args-from-file>` for details.
|
||||
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#11523 <https://github.com/pytest-dev/pytest/issues/11523>`_: :func:`pytest.importorskip` will now issue a warning if the module could be found, but raised :class:`ImportError` instead of :class:`ModuleNotFoundError`.
|
||||
|
||||
The warning can be suppressed by passing ``exc_type=ImportError`` to :func:`pytest.importorskip`.
|
||||
|
||||
See :ref:`import-or-skip-import-error` for details.
|
||||
|
||||
|
||||
- `#11728 <https://github.com/pytest-dev/pytest/issues/11728>`_: For ``unittest``-based tests, exceptions during class cleanup (as raised by functions registered with :meth:`TestCase.addClassCleanup <unittest.TestCase.addClassCleanup>`) are now reported instead of silently failing.
|
||||
|
||||
|
||||
- `#11777 <https://github.com/pytest-dev/pytest/issues/11777>`_: Text is no longer truncated in the ``short test summary info`` section when ``-vv`` is given.
|
||||
|
||||
|
||||
- `#12112 <https://github.com/pytest-dev/pytest/issues/12112>`_: Improved namespace packages detection when :confval:`consider_namespace_packages` is enabled, covering more situations (like editable installs).
|
||||
|
||||
|
||||
- `#9502 <https://github.com/pytest-dev/pytest/issues/9502>`_: Added :envvar:`PYTEST_VERSION` environment variable which is defined at the start of the pytest session and undefined afterwards. It contains the value of ``pytest.__version__``, and among other things can be used to easily check if code is running from within a pytest run.
|
||||
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#12065 <https://github.com/pytest-dev/pytest/issues/12065>`_: Fixed a regression in pytest 8.0.0 where test classes containing ``setup_method`` and tests using ``@staticmethod`` or ``@classmethod`` would crash with ``AttributeError: 'NoneType' object has no attribute 'setup_method'``.
|
||||
|
||||
Now the :attr:`request.instance <pytest.FixtureRequest.instance>` attribute of tests using ``@staticmethod`` and ``@classmethod`` is no longer ``None``, but a fresh instance of the class, like in non-static methods.
|
||||
Previously it was ``None``, and all fixtures of such tests would share a single ``self``.
|
||||
|
||||
|
||||
- `#12135 <https://github.com/pytest-dev/pytest/issues/12135>`_: Fixed issue where fixtures adding their finalizer multiple times to fixtures they request would cause unreliable and non-intuitive teardown ordering in some instances.
|
||||
|
||||
|
||||
- `#12194 <https://github.com/pytest-dev/pytest/issues/12194>`_: Fixed a bug with ``--importmode=importlib`` and ``--doctest-modules`` where child modules did not appear as attributes in parent modules.
|
||||
|
||||
|
||||
- `#1489 <https://github.com/pytest-dev/pytest/issues/1489>`_: Fixed some instances where teardown of higher-scoped fixtures was not happening in the reverse order they were initialized in.
|
||||
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: ``pluggy>=1.5.0`` is now required.
|
||||
|
||||
|
||||
- `#12167 <https://github.com/pytest-dev/pytest/issues/12167>`_: :ref:`cache <cache>`: create supporting files (``CACHEDIR.TAG``, ``.gitignore``, etc.) in a temporary directory to provide atomic semantics.
|
||||
|
||||
|
||||
pytest 8.1.2 (2024-04-26)
|
||||
=========================
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#12114 <https://github.com/pytest-dev/pytest/issues/12114>`_: Fixed error in :func:`pytest.approx` when used with `numpy` arrays and comparing with other types.
|
||||
|
||||
|
||||
pytest 8.1.1 (2024-03-08)
|
||||
=========================
|
||||
|
||||
.. note::
|
||||
|
||||
This release is not a usual bug fix release -- it contains features and improvements, being a follow up
|
||||
to ``8.1.0``, which has been yanked from PyPI.
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Added the new :confval:`consider_namespace_packages` configuration option, defaulting to ``False``.
|
||||
|
||||
If set to ``True``, pytest will attempt to identify modules that are part of `namespace packages <https://packaging.python.org/en/latest/guides/packaging-namespace-packages>`__ when importing modules.
|
||||
|
||||
|
||||
- `#11653 <https://github.com/pytest-dev/pytest/issues/11653>`_: Added the new :confval:`verbosity_test_cases` configuration option for fine-grained control of test execution verbosity.
|
||||
See :ref:`Fine-grained verbosity <pytest.fine_grained_verbosity>` for more details.
|
||||
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#10865 <https://github.com/pytest-dev/pytest/issues/10865>`_: :func:`pytest.warns` now validates that :func:`warnings.warn` was called with a `str` or a `Warning`.
|
||||
Currently in Python it is possible to use other types, however this causes an exception when :func:`warnings.filterwarnings` is used to filter those warnings (see `CPython #103577 <https://github.com/python/cpython/issues/103577>`__ for a discussion).
|
||||
While this can be considered a bug in CPython, we decided to put guards in pytest as the error message produced without this check in place is confusing.
|
||||
|
||||
|
||||
- `#11311 <https://github.com/pytest-dev/pytest/issues/11311>`_: When using ``--override-ini`` for paths in invocations without a configuration file defined, the current working directory is used
|
||||
as the relative directory.
|
||||
|
||||
Previously this would raise an :class:`AssertionError`.
|
||||
|
||||
|
||||
- `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: :ref:`--import-mode=importlib <import-mode-importlib>` now tries to import modules using the standard import mechanism (but still without changing :py:data:`sys.path`), falling back to importing modules directly only if that fails.
|
||||
|
||||
This means that installed packages will be imported under their canonical name if possible first, for example ``app.core.models``, instead of having the module name always be derived from their path (for example ``.env310.lib.site_packages.app.core.models``).
|
||||
|
||||
|
||||
- `#11801 <https://github.com/pytest-dev/pytest/issues/11801>`_: Added the :func:`iter_parents() <_pytest.nodes.Node.iter_parents>` helper method on nodes.
|
||||
It is similar to :func:`listchain <_pytest.nodes.Node.listchain>`, but goes from bottom to top, and returns an iterator, not a list.
|
||||
|
||||
|
||||
- `#11850 <https://github.com/pytest-dev/pytest/issues/11850>`_: Added support for :data:`sys.last_exc` for post-mortem debugging on Python>=3.12.
|
||||
|
||||
|
||||
- `#11962 <https://github.com/pytest-dev/pytest/issues/11962>`_: In case no other suitable candidates for configuration file are found, a ``pyproject.toml`` (even without a ``[tool.pytest.ini_options]`` table) will be considered as the configuration file and define the ``rootdir``.
|
||||
|
||||
|
||||
- `#11978 <https://github.com/pytest-dev/pytest/issues/11978>`_: Add ``--log-file-mode`` option to the logging plugin, enabling appending to log-files. This option accepts either ``"w"`` or ``"a"`` and defaults to ``"w"``.
|
||||
|
||||
Previously, the mode was hard-coded to be ``"w"`` which truncates the file before logging.
|
||||
|
||||
|
||||
- `#12047 <https://github.com/pytest-dev/pytest/issues/12047>`_: When multiple finalizers of a fixture raise an exception, now all exceptions are reported as an exception group.
|
||||
Previously, only the first exception was reported.
|
||||
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11475 <https://github.com/pytest-dev/pytest/issues/11475>`_: Fixed regression where ``--importmode=importlib`` would import non-test modules more than once.
|
||||
|
||||
|
||||
- `#11904 <https://github.com/pytest-dev/pytest/issues/11904>`_: Fixed a regression in pytest 8.0.0 that would cause test collection to fail due to permission errors when using ``--pyargs``.
|
||||
|
||||
This change improves the collection tree for tests specified using ``--pyargs``, see :pr:`12043` for a comparison with pytest 8.0 and <8.
|
||||
|
||||
|
||||
- `#12011 <https://github.com/pytest-dev/pytest/issues/12011>`_: Fixed a regression in 8.0.1 whereby ``setup_module`` xunit-style fixtures are not executed when ``--doctest-modules`` is passed.
|
||||
|
||||
|
||||
- `#12014 <https://github.com/pytest-dev/pytest/issues/12014>`_: Fix the ``stacklevel`` used when warning about marks used on fixtures.
|
||||
|
||||
|
||||
- `#12039 <https://github.com/pytest-dev/pytest/issues/12039>`_: Fixed a regression in ``8.0.2`` where tests created using :fixture:`tmp_path` have been collected multiple times in CI under Windows.
|
||||
|
||||
|
||||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- `#11790 <https://github.com/pytest-dev/pytest/issues/11790>`_: Documented the retention of temporary directories created using the ``tmp_path`` fixture in more detail.
|
||||
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#11785 <https://github.com/pytest-dev/pytest/issues/11785>`_: Some changes were made to private functions which may affect plugins which access them:
|
||||
|
||||
- ``FixtureManager._getautousenames()`` now takes a ``Node`` itself instead of the nodeid.
|
||||
- ``FixtureManager.getfixturedefs()`` now takes the ``Node`` itself instead of the nodeid.
|
||||
- The ``_pytest.nodes.iterparentnodeids()`` function is removed without replacement.
|
||||
Prefer to traverse the node hierarchy itself instead.
|
||||
If you really need to, copy the function from the previous pytest release.
|
||||
|
||||
|
||||
- `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`_: Delayed the deprecation of the following features to ``9.0.0``:
|
||||
|
||||
* :ref:`node-ctor-fspath-deprecation`.
|
||||
* :ref:`legacy-path-hooks-deprecated`.
|
||||
|
||||
It was discovered after ``8.1.0`` was released that the warnings about the impeding removal were not being displayed, so the team decided to revert the removal.
|
||||
|
||||
This is the reason for ``8.1.0`` being yanked.
|
||||
|
||||
|
||||
pytest 8.1.0 (YANKED)
|
||||
=====================
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
This release has been **yanked**: it broke some plugins without the proper warning period, due to
|
||||
some warnings not showing up as expected.
|
||||
|
||||
See `#12069 <https://github.com/pytest-dev/pytest/issues/12069>`__.
|
||||
|
||||
|
||||
pytest 8.0.2 (2024-02-24)
|
||||
=========================
|
||||
|
||||
|
@ -608,7 +315,7 @@ These are breaking changes where deprecation was not possible.
|
|||
Deprecations
|
||||
------------
|
||||
|
||||
- `#10465 <https://github.com/pytest-dev/pytest/issues/10465>`_: Test functions returning a value other than ``None`` will now issue a :class:`pytest.PytestWarning` instead of ``pytest.PytestRemovedIn8Warning``, meaning this will stay a warning instead of becoming an error in the future.
|
||||
- `#10465 <https://github.com/pytest-dev/pytest/issues/10465>`_: Test functions returning a value other than ``None`` will now issue a :class:`pytest.PytestWarning` instead of :class:`pytest.PytestRemovedIn8Warning`, meaning this will stay a warning instead of becoming an error in the future.
|
||||
|
||||
|
||||
- `#3664 <https://github.com/pytest-dev/pytest/issues/3664>`_: Applying a mark to a fixture function now issues a warning: marks in fixtures never had any effect, but it is a common user error to apply a mark to a fixture (for example ``usefixtures``) and expect it to work.
|
||||
|
@ -1422,7 +1129,7 @@ Bug Fixes
|
|||
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 :pr:`6523` for details).
|
||||
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.
|
||||
|
@ -1475,7 +1182,7 @@ Deprecations
|
|||
``__init__`` method, they should take ``**kwargs``. See
|
||||
:ref:`uncooperative-constructors-deprecated` for details.
|
||||
|
||||
Note that a deprecation warning is only emitted when there is a conflict in the
|
||||
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.
|
||||
|
||||
|
@ -1517,7 +1224,7 @@ 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 unaffected.
|
||||
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.
|
||||
|
@ -1638,7 +1345,7 @@ Deprecations
|
|||
See :ref:`the deprecation note <diamond-inheritance-deprecated>` for full details.
|
||||
|
||||
|
||||
- `#8592 <https://github.com/pytest-dev/pytest/issues/8592>`_: ``pytest_cmdline_preparse`` has been officially deprecated. It will be removed in a future release. Use :hook:`pytest_load_initial_conftests` instead.
|
||||
- `#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.
|
||||
|
||||
|
@ -2025,7 +1732,7 @@ Bug Fixes
|
|||
the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with
|
||||
private permissions.
|
||||
|
||||
pytest used to silently use a preexisting ``/tmp/pytest-of-<username>`` directory,
|
||||
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.
|
||||
|
@ -2591,7 +2298,7 @@ Breaking Changes
|
|||
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
|
||||
:pr:`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.
|
||||
|
@ -2752,7 +2459,7 @@ Features
|
|||
also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules
|
||||
that don't live in packages to have unique names (as they need to reside under a unique name in ``sys.modules``).
|
||||
|
||||
``--import-mode=importlib`` uses more fine-grained import mechanisms from ``importlib`` which don't
|
||||
``--import-mode=importlib`` uses more fine grained import mechanisms from ``importlib`` which don't
|
||||
require pytest to change ``sys.path`` or ``sys.modules`` at all, eliminating much of the drawbacks
|
||||
of the previous mode.
|
||||
|
||||
|
@ -2769,7 +2476,7 @@ Improvements
|
|||
------------
|
||||
|
||||
- :issue:`4375`: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that
|
||||
is printed to stderr when the output of ``pytest`` is piped and the pipe is
|
||||
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``).
|
||||
|
||||
|
||||
|
@ -2874,7 +2581,7 @@ Bug Fixes
|
|||
- :issue:`6871`: Fix crash with captured output when using :fixture:`capsysbinary`.
|
||||
|
||||
|
||||
- :issue:`6909`: Revert the change introduced by :pr:`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.
|
||||
|
||||
|
@ -3044,7 +2751,7 @@ pytest 5.4.1 (2020-03-13)
|
|||
Bug Fixes
|
||||
---------
|
||||
|
||||
- :issue:`6909`: Revert the change introduced by :pr:`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.
|
||||
|
||||
|
@ -3071,7 +2778,7 @@ Breaking Changes
|
|||
This hook has been marked as deprecated and not been even called by pytest for over 10 years now.
|
||||
|
||||
|
||||
- :issue:`6673`: Reversed / fix meaning of "+/-" in error diffs. "-" means that something 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.
|
||||
|
||||
|
||||
- :issue:`6737`: The ``cached_result`` attribute of ``FixtureDef`` is now set to ``None`` when
|
||||
|
@ -3360,9 +3067,7 @@ Bug Fixes
|
|||
- :issue:`5914`: pytester: fix :py:func:`~pytest.LineMatcher.no_fnmatch_line` when used after positive matching.
|
||||
|
||||
|
||||
- :issue:`6082`: Fix line detection for doctest samples inside
|
||||
:py:class:`python:property` docstrings, as a workaround to
|
||||
:issue:`python/cpython#61648`.
|
||||
- :issue:`6082`: Fix line detection for doctest samples inside :py:class:`python:property` docstrings, as a workaround to :bpo:`17446`.
|
||||
|
||||
|
||||
- :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0).
|
||||
|
@ -4069,7 +3774,7 @@ Bug Fixes
|
|||
(``--collect-only``) when ``--log-cli-level`` is used.
|
||||
|
||||
|
||||
- :issue:`5389`: Fix regressions of :pr:`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``.
|
||||
|
||||
|
||||
- :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
|
||||
|
@ -4270,7 +3975,7 @@ Bug Fixes
|
|||
(``--collect-only``) when ``--log-cli-level`` is used.
|
||||
|
||||
|
||||
- :issue:`5389`: Fix regressions of :pr:`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``.
|
||||
|
||||
|
||||
- :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
|
||||
|
@ -4678,7 +4383,7 @@ Bug Fixes
|
|||
Improved Documentation
|
||||
----------------------
|
||||
|
||||
- :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability limitations
|
||||
- :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability liminations
|
||||
|
||||
|
||||
|
||||
|
@ -6536,7 +6241,7 @@ Features
|
|||
Bug Fixes
|
||||
---------
|
||||
|
||||
- Fix hanging pexpect test on macOS by using flush() instead of wait().
|
||||
- Fix hanging pexpect test on MacOS by using flush() instead of wait().
|
||||
(:issue:`2022`)
|
||||
|
||||
- Fix restoring Python state after in-process pytest runs with the
|
||||
|
@ -6584,7 +6289,7 @@ 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 cannot use
|
||||
(for example, ``"-k foo and import"`` will show an error that you can not use
|
||||
the ``import`` keyword in expressions). (:issue:`2953`)
|
||||
|
||||
- Change parametrized automatic test id generation to use the ``__name__``
|
||||
|
@ -7231,10 +6936,10 @@ New Features
|
|||
* 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 :user:`wheerd` for the PR (:pr:`2101`).
|
||||
Thanks :user:`wheerd` for the PR (:pull:`2101`).
|
||||
|
||||
* ``pytest.warns`` now checks for subclass relationship rather than
|
||||
class equality. Thanks :user:`lesteve` for the PR (: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 :user:`Kriechi` for the PR.
|
||||
|
@ -7262,7 +6967,7 @@ Changes
|
|||
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 :user:`fushi` for the PR (: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
|
||||
|
@ -7271,7 +6976,7 @@ Changes
|
|||
|
||||
* ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use
|
||||
``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for
|
||||
the PR (:pr:`1952`).
|
||||
the PR (:pull:`1952`).
|
||||
|
||||
* fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
|
||||
to give it a comprehensible repr while preventing unwarranted modification.
|
||||
|
@ -7525,7 +7230,7 @@ Bug Fixes
|
|||
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 (:issue:`1888`).
|
||||
Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR (:pr:`1891`).
|
||||
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``
|
||||
|
@ -7580,12 +7285,12 @@ 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 :user:`RedBeardCode` for the PR (: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 (:issue:`1479`). Thanks to :user:`The-Compiler` for the PR.
|
||||
|
||||
* Removed support code for Python 3 versions < 3.3 (:pr:`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
|
||||
|
@ -7596,19 +7301,19 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
* ``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 (:issue:`607`).
|
||||
Thanks :user:`omarkohl` for the complete PR (:pr:`1519`).
|
||||
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 (:issue:`1421`).
|
||||
A ``--continue-on-collection-errors`` option has been added to restore the previous behaviour.
|
||||
Thanks :user:`olegpidsadnyi` and :user:`omarkohl` for the complete PR (: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 (:pr:`460`).
|
||||
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``
|
||||
|
@ -7626,7 +7331,7 @@ 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 :user:`milliams` for the complete PR (: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 :issue:`1749`).
|
||||
|
@ -7634,23 +7339,23 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
* New ``name`` argument to ``pytest.fixture`` decorator which allows a custom name
|
||||
for a fixture (to solve the funcarg-shadowing-fixture problem).
|
||||
Thanks :user:`novas0x2a` for the complete PR (:pr:`1444`).
|
||||
Thanks :user:`novas0x2a` for the complete PR (:pull:`1444`).
|
||||
|
||||
* New ``approx()`` function for easily comparing floating-point numbers in
|
||||
tests.
|
||||
Thanks :user:`kalekundert` for the complete PR (: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 :user:`tareqalayan` for the complete PR :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 (:issue:`372`).
|
||||
Thanks :user:`omarkohl` for the complete PR (:pr:`1502`).
|
||||
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 :user:`The-Compiler` for the complete PR (: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.
|
||||
|
@ -7668,7 +7373,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
* Introduce ``pytest`` command as recommended entry point. Note that ``py.test``
|
||||
still works and is not scheduled for removal. Closes proposal
|
||||
:issue:`1629`. Thanks :user:`obestwalter` and :user:`davehunt` for the complete PR
|
||||
(:pr:`1633`).
|
||||
(:pull:`1633`).
|
||||
|
||||
* New cli flags:
|
||||
|
||||
|
@ -7712,19 +7417,19 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
* Change ``report.outcome`` for ``xpassed`` tests to ``"passed"`` in non-strict
|
||||
mode and ``"failed"`` in strict mode. Thanks to :user:`hackebrot` for the PR
|
||||
(:pr:`1795`) and :user:`gprasad84` for report (:issue:`1546`).
|
||||
(: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 :user:`hackebrot` for the PR (: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 :user:`suzaku` for the PR (: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 (:pr:`1461`).
|
||||
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 (:issue:`1351`).
|
||||
|
@ -7735,11 +7440,11 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
Thanks :user:`nicoddemus` for the PR.
|
||||
|
||||
* ``pytest_terminal_summary`` hook now receives the ``exitstatus``
|
||||
of the test session as argument. Thanks :user:`blueyed` for the PR (: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 :user:`palaviv` for the complete PR (: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.
|
||||
|
@ -7747,32 +7452,32 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
* Improved automatic id generation selection in case of duplicate ids in
|
||||
parametrize.
|
||||
Thanks :user:`palaviv` for the complete PR (: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 (:issue:`1668`).
|
||||
|
||||
* Make ImportError during collection more explicit by reminding
|
||||
the user to check the name of the test module/package(s) (:issue:`1426`).
|
||||
Thanks :user:`omarkohl` for the complete PR (:pr:`1520`).
|
||||
Thanks :user:`omarkohl` for the complete PR (:pull:`1520`).
|
||||
|
||||
* Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks
|
||||
: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 :user:`palaviv` for the complete PR (: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 :user:`flub`, :user:`sober7` and
|
||||
:user:`nicoddemus` for the PR (:issue:`1619`).
|
||||
|
||||
* Text documents without any doctests no longer appear as "skipped".
|
||||
Thanks :user:`graingert` for reporting and providing a full PR (: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 :user:`taschini` for the PR (: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.
|
||||
|
@ -7788,20 +7493,20 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
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 :pr:`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 :user:`nicoddemus` for the PR.
|
||||
|
||||
* Using ``pytest_funcarg__`` prefix to declare fixtures is considered deprecated and will be
|
||||
removed in pytest-4.0 (:pr:`1684`).
|
||||
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 (:pr:`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 :user:`RedBeardCode` and :user:`tomviner`
|
||||
for the PR (:pr:`1626`).
|
||||
for the PR (:pull:`1626`).
|
||||
|
||||
* ``optparse`` type usage now triggers DeprecationWarnings (:issue:`1740`).
|
||||
|
||||
|
@ -7859,11 +7564,11 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
:user:`tomviner` for the PR.
|
||||
|
||||
* ``ConftestImportFailure`` now shows the traceback making it easier to
|
||||
identify bugs in ``conftest.py`` files (:pr:`1516`). Thanks :user:`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 :user:`graingert` for reporting and providing a full PR (:pr:`1580`).
|
||||
Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`).
|
||||
|
||||
* Fixed collection of classes with custom ``__new__`` method.
|
||||
Fixes :issue:`1579`. Thanks to :user:`Stranger6667` for the PR.
|
||||
|
@ -7871,7 +7576,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
* Fixed scope overriding inside metafunc.parametrize (:issue:`634`).
|
||||
Thanks to :user:`Stranger6667` for the PR.
|
||||
|
||||
* Fixed the total tests tally in junit xml output (:pr:`1798`).
|
||||
* 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``.
|
||||
|
@ -7888,14 +7593,14 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
* Fix Xfail does not work with condition keyword argument.
|
||||
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
|
||||
for PR the (:pr:`1524`).
|
||||
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 :user:`prusse-martin` for the PR (:pr:`1506`).
|
||||
Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
|
||||
|
||||
* Fix ``pytest.mark.skip`` mark when used in strict mode.
|
||||
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
|
||||
|
@ -7922,7 +7627,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
Thanks :user:`nicoddemus` for the PR.
|
||||
|
||||
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
|
||||
contain ``::``. Thanks :user:`tomviner` for the PR (:pr:`1431`).
|
||||
contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
|
||||
|
||||
* Fix (:issue:`578`): SyntaxErrors
|
||||
containing non-ascii lines at the point of failure generated an internal
|
||||
|
@ -7943,7 +7648,7 @@ 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 :user:`MichaelAquilina` for the complete PR (:pr:`1040`).
|
||||
Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
|
||||
|
||||
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
||||
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
|
||||
|
@ -7954,14 +7659,14 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
* ``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 :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (: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 :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 :user:`jaraco` for the request and :user:`nicoddemus` for the PR (: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 :issue:`1366`.
|
||||
|
@ -7993,7 +7698,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
* Removed code and documentation for Python 2.5 or lower versions,
|
||||
including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
|
||||
Thanks :user:`nicoddemus` for the PR (: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.
|
||||
|
@ -8360,7 +8065,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
one will also have a "reprec" attribute with the recorded events/reports.
|
||||
|
||||
- fix monkeypatch.setattr("x.y", raising=False) to actually not raise
|
||||
if "y" is not a preexisting attribute. Thanks Florian Bruhin.
|
||||
if "y" is not a pre-existing attribute. Thanks Florian Bruhin.
|
||||
|
||||
- fix issue741: make running output from testdir.run copy/pasteable
|
||||
Thanks Bruno Oliveira.
|
||||
|
@ -8416,7 +8121,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
|
||||
- fix issue854: autouse yield_fixtures defined as class members of
|
||||
unittest.TestCase subclasses now work as expected.
|
||||
Thanks xmo-odoo for the report and Bruno Oliveira for the PR.
|
||||
Thannks xmo-odoo for the report and Bruno Oliveira for the PR.
|
||||
|
||||
- fix issue833: --fixtures now shows all fixtures of collected test files, instead of just the
|
||||
fixtures declared on the first one.
|
||||
|
@ -8520,7 +8225,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
github. See https://pytest.org/en/stable/contributing.html .
|
||||
Thanks to Anatoly for pushing and initial work on this.
|
||||
|
||||
- fix issue650: new option ``--doctest-ignore-import-errors`` which
|
||||
- fix issue650: new option ``--docttest-ignore-import-errors`` which
|
||||
will turn import errors in doctests into skips. Thanks Charles Cloud
|
||||
for the complete PR.
|
||||
|
||||
|
@ -8708,7 +8413,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
- cleanup setup.py a bit and specify supported versions. Thanks Jurko
|
||||
Gospodnetic for the PR.
|
||||
|
||||
- change XPASS colour to yellow rather than red when tests are run
|
||||
- change XPASS colour to yellow rather then red when tests are run
|
||||
with -v.
|
||||
|
||||
- fix issue473: work around mock putting an unbound method into a class
|
||||
|
@ -8881,7 +8586,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
Thanks Ralph Schmitt for the precise failure example.
|
||||
|
||||
- fix issue244 by implementing special index for parameters to only use
|
||||
indices for parametrized test ids
|
||||
indices for paramentrized test ids
|
||||
|
||||
- fix issue287 by running all finalizers but saving the exception
|
||||
from the first failing finalizer and re-raising it so teardown will
|
||||
|
@ -8889,7 +8594,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
|||
it might be the cause for other finalizers to fail.
|
||||
|
||||
- fix ordering when mock.patch or other standard decorator-wrappings
|
||||
are used with test methods. This fixes issue346 and should
|
||||
are used with test methods. This fixues issue346 and should
|
||||
help with random "xdist" collection failures. Thanks to
|
||||
Ronny Pfannschmidt and Donald Stufft for helping to isolate it.
|
||||
|
||||
|
@ -9146,7 +8851,7 @@ Bug fixes:
|
|||
partially failed (finalizers would not always be called before)
|
||||
|
||||
- fix issue320 - fix class scope for fixtures when mixed with
|
||||
module-level functions. Thanks Anatoly Bubenkoff.
|
||||
module-level functions. Thanks Anatloy Bubenkoff.
|
||||
|
||||
- you can specify "-q" or "-qq" to get different levels of "quieter"
|
||||
reporting (thanks Katarzyna Jachim)
|
||||
|
@ -9568,7 +9273,7 @@ Bug fixes:
|
|||
unexpected exceptions
|
||||
- fix issue47: timing output in junitxml for test cases is now correct
|
||||
- fix issue48: typo in MarkInfo repr leading to exception
|
||||
- fix issue49: avoid confusing error when initialization partially fails
|
||||
- fix issue49: avoid confusing error when initizaliation partially fails
|
||||
- fix issue44: env/username expansion for junitxml file path
|
||||
- show releaselevel information in test runs for pypy
|
||||
- reworked doc pages for better navigation and PDF generation
|
||||
|
@ -9693,7 +9398,7 @@ Bug fixes:
|
|||
collection-before-running semantics were not
|
||||
setup as with pytest 1.3.4. Note, however, that
|
||||
the recommended and much cleaner way to do test
|
||||
parameterization remains the "pytest_generate_tests"
|
||||
parametraization remains the "pytest_generate_tests"
|
||||
mechanism, see the docs.
|
||||
|
||||
2.0.0 (2010-11-25)
|
||||
|
|
107
doc/en/conf.py
107
doc/en/conf.py
|
@ -15,33 +15,19 @@
|
|||
#
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
# The short X.Y version.
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from _pytest import __version__ as full_version
|
||||
from _pytest import __version__ as version
|
||||
|
||||
|
||||
version = full_version.split("+")[0]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import sphinx.application
|
||||
|
||||
|
||||
PROJECT_ROOT_DIR = Path(__file__).parents[2].resolve()
|
||||
IS_RELEASE_ON_RTD = (
|
||||
os.getenv("READTHEDOCS", "False") == "True"
|
||||
and os.environ["READTHEDOCS_VERSION_TYPE"] == "tag"
|
||||
)
|
||||
if IS_RELEASE_ON_RTD:
|
||||
tags: set[str]
|
||||
# pylint: disable-next=used-before-assignment
|
||||
tags.add("is_release") # noqa: F821
|
||||
|
||||
release = ".".join(version.split(".")[:2])
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
|
@ -79,16 +65,16 @@ latex_elements = {
|
|||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = [
|
||||
"pallets_sphinx_themes",
|
||||
"pygments_pytest",
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.autosummary",
|
||||
"sphinx.ext.extlinks",
|
||||
"sphinx.ext.intersphinx",
|
||||
"sphinx.ext.todo",
|
||||
"sphinx.ext.viewcode",
|
||||
"sphinx_removed_in",
|
||||
"sphinxcontrib_trio",
|
||||
"sphinxcontrib.towncrier.ext", # provides `towncrier-draft-entries` directive
|
||||
"sphinx_issues", # implements `:issue:`, `:pr:` and other GH-related roles
|
||||
]
|
||||
|
||||
# Building PDF docs on readthedocs requires inkscape for svg to pdf
|
||||
|
@ -154,6 +140,10 @@ add_module_names = False
|
|||
# output. They are ignored by default.
|
||||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = "sphinx"
|
||||
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
||||
|
@ -170,6 +160,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"),
|
||||
}
|
||||
|
||||
|
||||
nitpicky = True
|
||||
nitpick_ignore = [
|
||||
# TODO (fix in pluggy?)
|
||||
|
@ -183,7 +183,6 @@ nitpick_ignore = [
|
|||
("py:class", "SubRequest"),
|
||||
("py:class", "TerminalReporter"),
|
||||
("py:class", "_pytest._code.code.TerminalRepr"),
|
||||
("py:class", "TerminalRepr"),
|
||||
("py:class", "_pytest.fixtures.FixtureFunctionMarker"),
|
||||
("py:class", "_pytest.logging.LogCaptureHandler"),
|
||||
("py:class", "_pytest.mark.structures.ParameterSet"),
|
||||
|
@ -205,24 +204,24 @@ nitpick_ignore = [
|
|||
("py:class", "_PluggyPlugin"),
|
||||
# TypeVars
|
||||
("py:class", "_pytest._code.code.E"),
|
||||
("py:class", "E"), # due to delayed annotation
|
||||
("py:class", "_pytest.fixtures.FixtureFunction"),
|
||||
("py:class", "_pytest.nodes._NodeType"),
|
||||
("py:class", "_NodeType"), # due to delayed annotation
|
||||
("py:class", "_pytest.python_api.E"),
|
||||
("py:class", "_pytest.recwarn.T"),
|
||||
("py:class", "_pytest.runner.TResult"),
|
||||
("py:obj", "_pytest.fixtures.FixtureValue"),
|
||||
("py:obj", "_pytest.stash.T"),
|
||||
("py:class", "_ScopeName"),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for HTML output ---------------------------------------------------
|
||||
|
||||
sys.path.append(os.path.abspath("_themes"))
|
||||
html_theme_path = ["_themes"]
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = "furo"
|
||||
html_theme = "flask"
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
|
@ -237,7 +236,7 @@ html_theme = "furo"
|
|||
html_title = "pytest documentation"
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
html_short_title = f"pytest-{release}"
|
||||
html_short_title = "pytest-%s" % release
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
|
@ -267,24 +266,18 @@ html_favicon = "img/favicon.png"
|
|||
|
||||
html_sidebars = {
|
||||
"index": [
|
||||
"sidebar/brand.html",
|
||||
"sidebar/search.html",
|
||||
"sidebar/scroll-start.html",
|
||||
"slim_searchbox.html",
|
||||
"sidebarintro.html",
|
||||
"globaltoc.html",
|
||||
"links.html",
|
||||
"sidebar/scroll-end.html",
|
||||
"style.html",
|
||||
"sourcelink.html",
|
||||
],
|
||||
"**": [
|
||||
"sidebar/brand.html",
|
||||
"sidebar/search.html",
|
||||
"sidebar/scroll-start.html",
|
||||
"slim_searchbox.html",
|
||||
"globaltoc.html",
|
||||
"relations.html",
|
||||
"links.html",
|
||||
"sidebar/scroll-end.html",
|
||||
"style.html",
|
||||
"sourcelink.html",
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -347,6 +340,10 @@ latex_documents = [
|
|||
)
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
latex_logo = "img/pytest1.png"
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
# latex_use_parts = False
|
||||
|
@ -401,7 +398,7 @@ epub_copyright = "2013, holger krekel et alii"
|
|||
# The format is a list of tuples containing the path and title.
|
||||
# epub_pre_files = []
|
||||
|
||||
# HTML files that should be inserted after the pages created by sphinx.
|
||||
# HTML files shat should be inserted after the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
# epub_post_files = []
|
||||
|
||||
|
@ -433,18 +430,6 @@ texinfo_documents = [
|
|||
)
|
||||
]
|
||||
|
||||
# -- Options for towncrier_draft extension -----------------------------------
|
||||
|
||||
towncrier_draft_autoversion_mode = "draft" # or: 'sphinx-version', 'sphinx-release'
|
||||
towncrier_draft_include_empty = True
|
||||
towncrier_draft_working_directory = PROJECT_ROOT_DIR
|
||||
towncrier_draft_config_path = "pyproject.toml" # relative to cwd
|
||||
|
||||
|
||||
# -- Options for sphinx_issues extension -----------------------------------
|
||||
|
||||
issues_github_path = "pytest-dev/pytest"
|
||||
|
||||
|
||||
intersphinx_mapping = {
|
||||
"pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
|
||||
|
@ -458,7 +443,31 @@ intersphinx_mapping = {
|
|||
}
|
||||
|
||||
|
||||
def setup(app: sphinx.application.Sphinx) -> None:
|
||||
def configure_logging(app: "sphinx.application.Sphinx") -> None:
|
||||
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
|
||||
import logging
|
||||
|
||||
import sphinx.util.logging
|
||||
|
||||
class WarnLogFilter(logging.Filter):
|
||||
def filter(self, record: logging.LogRecord) -> bool:
|
||||
"""Ignore warnings about missing include with "only" directive.
|
||||
|
||||
Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
|
||||
if (
|
||||
record.msg.startswith('Problems with "include" directive path:')
|
||||
and "_changelog_towncrier_draft.rst" in record.msg
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
|
||||
warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
|
||||
assert len(warn_handler) == 1, warn_handler
|
||||
warn_handler[0].filters.insert(0, WarnLogFilter())
|
||||
|
||||
|
||||
def setup(app: "sphinx.application.Sphinx") -> None:
|
||||
app.add_crossref_type(
|
||||
"fixture",
|
||||
"fixture",
|
||||
|
@ -487,6 +496,8 @@ def setup(app: sphinx.application.Sphinx) -> None:
|
|||
indextemplate="pair: %s; hook",
|
||||
)
|
||||
|
||||
configure_logging(app)
|
||||
|
||||
# legacypath.py monkey-patches pytest.Testdir in. Import the file so
|
||||
# that autodoc can discover references to it.
|
||||
import _pytest.legacypath # noqa: F401
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
from __future__ import annotations
|
||||
|
||||
|
||||
collect_ignore = ["conf.py"]
|
||||
|
|
|
@ -22,16 +22,23 @@ Contact channels
|
|||
requests to GitHub.
|
||||
|
||||
- ``#pytest`` `on irc.libera.chat <ircs://irc.libera.chat:6697/#pytest>`_ IRC
|
||||
channel for random questions (using an IRC client, or `via webchat
|
||||
<https://web.libera.chat/#pytest>`)
|
||||
- ``#pytest`` `on Matrix https://matrix.to/#/#pytest:matrix.org>`.
|
||||
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
|
||||
|
||||
|
||||
- `merlinux.eu`_ offers pytest and tox-related professional teaching and
|
||||
consulting.
|
||||
|
||||
.. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues
|
||||
.. _`old issue tracker`: https://bitbucket.org/hpk42/py-trunk/issues/
|
||||
|
||||
.. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions
|
||||
|
||||
.. _`merlinux.eu`: https://merlinux.eu/
|
||||
|
||||
.. _`get an account`:
|
||||
|
||||
.. _tetamap: https://tetamap.wordpress.com/
|
||||
|
|
|
@ -44,6 +44,7 @@ How-to guides
|
|||
|
||||
how-to/existingtestsuite
|
||||
how-to/unittest
|
||||
how-to/nose
|
||||
how-to/xunit_setup
|
||||
|
||||
how-to/bash-completion
|
||||
|
|
|
@ -7,6 +7,10 @@ This page lists all pytest features that are currently deprecated or have been r
|
|||
The objective is to give users a clear rationale why a certain feature has been removed, and what alternatives
|
||||
should be used instead.
|
||||
|
||||
.. contents::
|
||||
:depth: 3
|
||||
:local:
|
||||
|
||||
|
||||
Deprecated Features
|
||||
-------------------
|
||||
|
@ -15,302 +19,12 @@ Below is a complete list of all pytest features which are considered deprecated.
|
|||
:class:`~pytest.PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
|
||||
|
||||
|
||||
.. _import-or-skip-import-error:
|
||||
|
||||
``pytest.importorskip`` default behavior regarding :class:`ImportError`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 8.2
|
||||
|
||||
Traditionally :func:`pytest.importorskip` will capture :class:`ImportError`, with the original intent being to skip
|
||||
tests where a dependent module is not installed, for example testing with different dependencies.
|
||||
|
||||
However some packages might be installed in the system, but are not importable due to
|
||||
some other issue, for example, a compilation error or a broken installation. In those cases :func:`pytest.importorskip`
|
||||
would still silently skip the test, but more often than not users would like to see the unexpected
|
||||
error so the underlying issue can be fixed.
|
||||
|
||||
In ``8.2`` the ``exc_type`` parameter has been added, giving users the ability of passing :class:`ModuleNotFoundError`
|
||||
to skip tests only if the module cannot really be found, and not because of some other error.
|
||||
|
||||
Catching only :class:`ModuleNotFoundError` by default (and letting other errors propagate) would be the best solution,
|
||||
however for backward compatibility, pytest will keep the existing behavior but raise an warning if:
|
||||
|
||||
1. The captured exception is of type :class:`ImportError`, and:
|
||||
2. The user does not pass ``exc_type`` explicitly.
|
||||
|
||||
If the import attempt raises :class:`ModuleNotFoundError` (the usual case), then the module is skipped and no
|
||||
warning is emitted.
|
||||
|
||||
This way, the usual cases will keep working the same way, while unexpected errors will now issue a warning, with
|
||||
users being able to supress the warning by passing ``exc_type=ImportError`` explicitly.
|
||||
|
||||
In ``9.0``, the warning will turn into an error, and in ``9.1`` :func:`pytest.importorskip` will only capture
|
||||
:class:`ModuleNotFoundError` by default and no warnings will be issued anymore -- but users can still capture
|
||||
:class:`ImportError` by passing it to ``exc_type``.
|
||||
|
||||
|
||||
.. _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.
|
||||
|
||||
|
||||
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``
|
||||
|
||||
|
||||
.. _legacy-path-hooks-deprecated:
|
||||
|
||||
``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.
|
||||
|
||||
.. _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` and a :class:`~pytest.Collector` (e.g. :class:`~pytest.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.nodes.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.
|
||||
|
||||
Applying a mark to a fixture function
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.4
|
||||
|
||||
Applying a mark to a fixture function never had any effect, but it is a common user error.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.usefixtures("clean_database")
|
||||
@pytest.fixture
|
||||
def user() -> User: ...
|
||||
|
||||
Users expected in this case that the ``usefixtures`` mark would have its intended effect of using the ``clean_database`` fixture when ``user`` was invoked, when in fact it has no effect at all.
|
||||
|
||||
Now pytest will issue a warning when it encounters this problem, and will raise an error in the future versions.
|
||||
|
||||
|
||||
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 ``yield_fixture`` function/decorator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 6.2
|
||||
|
||||
``pytest.yield_fixture`` is a deprecated alias for :func:`pytest.fixture`.
|
||||
|
||||
It has been so for a very long time, so can be search/replaced safely.
|
||||
|
||||
|
||||
Removed Features and Breaking Changes
|
||||
-------------------------------------
|
||||
|
||||
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
||||
an appropriate period of deprecation has passed.
|
||||
|
||||
Some breaking changes which could not be deprecated are also listed.
|
||||
|
||||
.. _nose-deprecation:
|
||||
|
||||
Support for tests written for nose
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.2
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Support for running tests written for `nose <https://nose.readthedocs.io/en/latest/>`__ is now deprecated.
|
||||
|
||||
|
@ -401,20 +115,157 @@ Will also need to be ported to a supported pytest style. One way to do it is usi
|
|||
|
||||
.. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
|
||||
|
||||
.. _instance-collector-deprecation:
|
||||
|
||||
The ``compat_co_firstlineno`` attribute
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
The ``pytest.Instance`` collector
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Nose inspects this attribute on function objects to allow overriding the function's inferred line number.
|
||||
Pytest no longer respects this attribute.
|
||||
.. 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
|
||||
.. versionremoved:: 8.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
|
||||
|
@ -443,74 +294,12 @@ functions and the ``@pytest.mark.skip`` and ``@pytest.mark.xfail`` markers which
|
|||
pytest.exit(reason="bar")
|
||||
|
||||
|
||||
.. _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 instanced in ``pytest.Instance`` and ``_pytest.python.Instance``,
|
||||
and importing it emits a deprecation warning. This was removed in pytest 8.
|
||||
|
||||
|
||||
Using ``pytest.warns(None)``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
.. versionremoved:: 8.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.
|
||||
|
||||
|
||||
Backward compatibilities in ``Parser.addoption``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 2.4
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
|
||||
removed 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.
|
||||
|
||||
|
||||
The ``--strict`` command-line option
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 6.2
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which
|
||||
better conveys what the option does.
|
||||
|
||||
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).
|
||||
|
||||
|
||||
.. _cmdline-preparse-deprecated:
|
||||
|
||||
Implementing the ``pytest_cmdline_preparse`` hook
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 7.0
|
||||
.. versionremoved:: 8.0
|
||||
|
||||
Implementing the ``pytest_cmdline_preparse`` hook has been officially deprecated.
|
||||
Implementing the :hook:`pytest_cmdline_preparse` hook has been officially deprecated.
|
||||
Implement the :hook:`pytest_load_initial_conftests` hook instead.
|
||||
|
||||
.. code-block:: python
|
||||
|
@ -525,6 +314,170 @@ Implement the :hook:`pytest_load_initial_conftests` hook instead.
|
|||
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` and a :class:`~pytest.Collector` (e.g. :class:`~pytest.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.nodes.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.
|
||||
|
||||
Applying a mark to a fixture function
|
||||
-------------------------------------
|
||||
|
||||
.. deprecated:: 7.4
|
||||
|
||||
Applying a mark to a fixture function never had any effect, but it is a common user error.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@pytest.mark.usefixtures("clean_database")
|
||||
@pytest.fixture
|
||||
def user() -> User: ...
|
||||
|
||||
Users expected in this case that the ``usefixtures`` mark would have its intended effect of using the ``clean_database`` fixture when ``user`` was invoked, when in fact it has no effect at all.
|
||||
|
||||
Now pytest will issue a warning when it encounters this problem, and will raise an error in the future versions.
|
||||
|
||||
|
||||
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
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 6.2
|
||||
|
||||
The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which
|
||||
better conveys what the option does.
|
||||
|
||||
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).
|
||||
|
||||
|
||||
The ``yield_fixture`` function/decorator
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. deprecated:: 6.2
|
||||
|
||||
``pytest.yield_fixture`` is a deprecated alias for :func:`pytest.fixture`.
|
||||
|
||||
It has been so for a very long time, so can be search/replaced safely.
|
||||
|
||||
|
||||
Removed Features and Breaking Changes
|
||||
-------------------------------------
|
||||
|
||||
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
|
||||
an appropriate period of deprecation has passed.
|
||||
|
||||
Some breaking changes which could not be deprecated are also listed.
|
||||
|
||||
|
||||
Collection changes in pytest 8
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
|
@ -174,7 +172,7 @@ class TestRaises:
|
|||
raise ValueError("demo error")
|
||||
|
||||
def test_tupleerror(self):
|
||||
a, b = [1] # noqa: F841
|
||||
a, b = [1] # NOQA
|
||||
|
||||
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
|
||||
items = [1, 2, 3]
|
||||
|
@ -182,7 +180,7 @@ class TestRaises:
|
|||
a, b = items.pop()
|
||||
|
||||
def test_some_error(self):
|
||||
if namenotexi: # noqa: F821
|
||||
if namenotexi: # NOQA
|
||||
pass
|
||||
|
||||
def func1(self):
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os.path
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
|
||||
hello = "world"
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
|
||||
def setup_module(module):
|
||||
module.TestStateFullThing.classcount = 0
|
||||
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
from __future__ import annotations
|
||||
|
||||
|
||||
collect_ignore = ["nonpython", "customdirectory"]
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# content of conftest.py
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
@ -23,7 +21,7 @@ class ManifestDirectory(pytest.Directory):
|
|||
|
||||
@pytest.hookimpl
|
||||
def pytest_collect_directory(path, parent):
|
||||
# Use our custom collector for directories containing a `manifest.json` file.
|
||||
# Use our custom collector for directories containing a `mainfest.json` file.
|
||||
if path.joinpath("manifest.json").is_file():
|
||||
return ManifestDirectory.from_parent(parent=parent, path=path)
|
||||
# Otherwise fallback to the standard behavior.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# content of test_first.py
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_1():
|
||||
pass
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# content of test_second.py
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_2():
|
||||
pass
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# content of test_third.py
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_3():
|
||||
pass
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue