Compare commits
89 Commits
Author | SHA1 | Date |
---|---|---|
|
8e3b8dc7e7 | |
|
2e01db1fc1 | |
|
c45812ed93 | |
|
77e93c248a | |
|
60c92473af | |
|
f484eaf1fd | |
|
d4d4ca3213 | |
|
1dc3a28805 | |
|
3980206012 | |
|
09888fa263 | |
|
2d5b20ac6c | |
|
90e70c3071 | |
|
64be38da80 | |
|
d68e0e4602 | |
|
f8277264de | |
|
8985f0475c | |
|
e6884c80c3 | |
|
7f3469f7af | |
|
f48f31291b | |
|
8effd29884 | |
|
a177ba7905 | |
|
68ea72b89c | |
|
d3dacc74c9 | |
|
a22b8e196d | |
|
29987a4e12 | |
|
7a0cb6b37d | |
|
b19cbf3e36 | |
|
0f6118596d | |
|
481aa764eb | |
|
780d0c10cd | |
|
277951fab9 | |
|
76065e5028 | |
|
cffcbdfbba | |
|
4f7ada5b6a | |
|
e60afd5af2 | |
|
2b16e7b138 | |
|
fc6ba92c30 | |
|
a36b74ead8 | |
|
69936d32a5 | |
|
d51fac48d6 | |
|
8e495e32c6 | |
|
2a75bab290 | |
|
0fce6d4ddb | |
|
f839730d22 | |
|
4716ba546f | |
|
c87707122c | |
|
31e07cf151 | |
|
3931fe2fbf | |
|
4f4bcc2e24 | |
|
65a8e4a744 | |
|
fdc53750f9 | |
|
a64fb18305 | |
|
53d2d4717d | |
|
56c0b1db3a | |
|
eb8721d387 | |
|
36f0ea10b4 | |
|
f3a494cca3 | |
|
329d371214 | |
|
214d098fcc | |
|
153a436bc4 | |
|
b41d5a52bb | |
|
9bb73d734f | |
|
4569a01e3d | |
|
1d103e5cdc | |
|
240a252d34 | |
|
a5ee3c4126 | |
|
f7358aec28 | |
|
558e4fa71a | |
|
f0e7a07667 | |
|
22e885f109 | |
|
bddbeba74b | |
|
66ff8dffdf | |
|
3ffcfd122c | |
|
0b28313b46 | |
|
f3dd93ad8d | |
|
bb5a1257b0 | |
|
f179bf252f | |
|
2b671b5f92 | |
|
65ab7cb96c | |
|
4d5fb7d71c | |
|
cbe5996cc6 | |
|
c9e9315725 | |
|
328001eab1 | |
|
8fdb72947e | |
|
5c1c73b961 | |
|
a152c2cee4 | |
|
69c3bcea36 | |
|
6bd3f31344 | |
|
9b6219b5e8 |
|
@ -29,3 +29,5 @@ exclude_lines =
|
||||||
|
|
||||||
^\s*if TYPE_CHECKING:
|
^\s*if TYPE_CHECKING:
|
||||||
^\s*@overload( |$)
|
^\s*@overload( |$)
|
||||||
|
|
||||||
|
^\s*@pytest\.mark\.xfail
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
...
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
...
|
|
@ -1,51 +0,0 @@
|
||||||
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,6 +19,11 @@ jobs:
|
||||||
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
|
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.version }}
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
|
|
||||||
|
# Required by attest-build-provenance-github.
|
||||||
|
permissions:
|
||||||
|
id-token: write
|
||||||
|
attestations: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
@ -26,7 +31,9 @@ jobs:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Build and Check Package
|
- name: Build and Check Package
|
||||||
uses: hynek/build-and-inspect-python-package@v2.4.0
|
uses: hynek/build-and-inspect-python-package@v2.5.0
|
||||||
|
with:
|
||||||
|
attest-build-provenance-github: 'true'
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
if: github.repository == 'pytest-dev/pytest'
|
if: github.repository == 'pytest-dev/pytest'
|
||||||
|
|
|
@ -35,7 +35,7 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Build and Check Package
|
- name: Build and Check Package
|
||||||
uses: hynek/build-and-inspect-python-package@v2.4.0
|
uses: hynek/build-and-inspect-python-package@v2.5.0
|
||||||
|
|
||||||
build:
|
build:
|
||||||
needs: [package]
|
needs: [package]
|
||||||
|
@ -55,6 +55,7 @@ jobs:
|
||||||
"windows-py310",
|
"windows-py310",
|
||||||
"windows-py311",
|
"windows-py311",
|
||||||
"windows-py312",
|
"windows-py312",
|
||||||
|
"windows-py313",
|
||||||
|
|
||||||
"ubuntu-py38",
|
"ubuntu-py38",
|
||||||
"ubuntu-py38-pluggy",
|
"ubuntu-py38-pluggy",
|
||||||
|
@ -63,12 +64,14 @@ jobs:
|
||||||
"ubuntu-py310",
|
"ubuntu-py310",
|
||||||
"ubuntu-py311",
|
"ubuntu-py311",
|
||||||
"ubuntu-py312",
|
"ubuntu-py312",
|
||||||
|
"ubuntu-py313",
|
||||||
"ubuntu-pypy3",
|
"ubuntu-pypy3",
|
||||||
|
|
||||||
"macos-py38",
|
"macos-py38",
|
||||||
"macos-py39",
|
"macos-py39",
|
||||||
"macos-py310",
|
"macos-py310",
|
||||||
"macos-py312",
|
"macos-py312",
|
||||||
|
"macos-py313",
|
||||||
|
|
||||||
"doctesting",
|
"doctesting",
|
||||||
"plugins",
|
"plugins",
|
||||||
|
@ -97,9 +100,13 @@ jobs:
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
tox_env: "py311"
|
tox_env: "py311"
|
||||||
- name: "windows-py312"
|
- name: "windows-py312"
|
||||||
python: "3.12-dev"
|
python: "3.12"
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
tox_env: "py312"
|
tox_env: "py312"
|
||||||
|
- name: "windows-py313"
|
||||||
|
python: "3.13-dev"
|
||||||
|
os: windows-latest
|
||||||
|
tox_env: "py313"
|
||||||
|
|
||||||
- name: "ubuntu-py38"
|
- name: "ubuntu-py38"
|
||||||
python: "3.8"
|
python: "3.8"
|
||||||
|
@ -128,10 +135,15 @@ jobs:
|
||||||
tox_env: "py311"
|
tox_env: "py311"
|
||||||
use_coverage: true
|
use_coverage: true
|
||||||
- name: "ubuntu-py312"
|
- name: "ubuntu-py312"
|
||||||
python: "3.12-dev"
|
python: "3.12"
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
tox_env: "py312"
|
tox_env: "py312"
|
||||||
use_coverage: true
|
use_coverage: true
|
||||||
|
- name: "ubuntu-py313"
|
||||||
|
python: "3.13-dev"
|
||||||
|
os: ubuntu-latest
|
||||||
|
tox_env: "py313"
|
||||||
|
use_coverage: true
|
||||||
- name: "ubuntu-pypy3"
|
- name: "ubuntu-pypy3"
|
||||||
python: "pypy-3.8"
|
python: "pypy-3.8"
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
|
@ -151,9 +163,13 @@ jobs:
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
tox_env: "py310-xdist"
|
tox_env: "py310-xdist"
|
||||||
- name: "macos-py312"
|
- name: "macos-py312"
|
||||||
python: "3.12-dev"
|
python: "3.12"
|
||||||
os: macos-latest
|
os: macos-latest
|
||||||
tox_env: "py312-xdist"
|
tox_env: "py312-xdist"
|
||||||
|
- name: "macos-py313"
|
||||||
|
python: "3.13-dev"
|
||||||
|
os: macos-latest
|
||||||
|
tox_env: "py313-xdist"
|
||||||
|
|
||||||
- name: "plugins"
|
- name: "plugins"
|
||||||
python: "3.12"
|
python: "3.12"
|
||||||
|
@ -166,6 +182,26 @@ jobs:
|
||||||
tox_env: "doctesting"
|
tox_env: "doctesting"
|
||||||
use_coverage: true
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
@ -206,8 +242,21 @@ jobs:
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
if: "matrix.use_coverage"
|
if: "matrix.use_coverage"
|
||||||
uses: codecov/codecov-action@v4
|
uses: codecov/codecov-action@v4
|
||||||
continue-on-error: true
|
|
||||||
with:
|
with:
|
||||||
fail_ci_if_error: true
|
fail_ci_if_error: false
|
||||||
files: ./coverage.xml
|
files: ./coverage.xml
|
||||||
verbose: true
|
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) }}
|
||||||
|
|
|
@ -25,7 +25,6 @@ src/_pytest/_version.py
|
||||||
|
|
||||||
doc/*/_build
|
doc/*/_build
|
||||||
doc/*/.doctrees
|
doc/*/.doctrees
|
||||||
doc/*/_changelog_towncrier_draft.rst
|
|
||||||
build/
|
build/
|
||||||
dist/
|
dist/
|
||||||
*.egg-info
|
*.egg-info
|
||||||
|
|
|
@ -66,9 +66,50 @@ repos:
|
||||||
- id: changelogs-rst
|
- id: changelogs-rst
|
||||||
name: changelog filenames
|
name: changelog filenames
|
||||||
language: fail
|
language: fail
|
||||||
entry: 'changelog files must be named ####.(breaking|bugfix|deprecation|doc|feature|improvement|trivial|vendor).rst'
|
entry: >-
|
||||||
exclude: changelog/(\d+\.(breaking|bugfix|deprecation|doc|feature|improvement|trivial|vendor).rst|README.rst|_template.rst)
|
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
|
||||||
|
)
|
||||||
|
$
|
||||||
files: ^changelog/
|
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
|
- id: py-deprecated
|
||||||
name: py library is deprecated
|
name: py library is deprecated
|
||||||
language: pygrep
|
language: pygrep
|
||||||
|
|
|
@ -14,11 +14,16 @@ sphinx:
|
||||||
fail_on_warning: true
|
fail_on_warning: true
|
||||||
|
|
||||||
build:
|
build:
|
||||||
os: ubuntu-20.04
|
os: ubuntu-24.04
|
||||||
tools:
|
tools:
|
||||||
python: "3.9"
|
python: >-
|
||||||
|
3.12
|
||||||
apt_packages:
|
apt_packages:
|
||||||
- inkscape
|
- inkscape
|
||||||
|
jobs:
|
||||||
|
post_checkout:
|
||||||
|
- git fetch --unshallow || true
|
||||||
|
- git fetch --tags || true
|
||||||
|
|
||||||
formats:
|
formats:
|
||||||
- epub
|
- epub
|
||||||
|
|
8
AUTHORS
8
AUTHORS
|
@ -36,6 +36,7 @@ Andrey Paramonov
|
||||||
Andrzej Klajnert
|
Andrzej Klajnert
|
||||||
Andrzej Ostrowski
|
Andrzej Ostrowski
|
||||||
Andy Freeland
|
Andy Freeland
|
||||||
|
Anita Hammer
|
||||||
Anthon van der Neut
|
Anthon van der Neut
|
||||||
Anthony Shaw
|
Anthony Shaw
|
||||||
Anthony Sottile
|
Anthony Sottile
|
||||||
|
@ -191,6 +192,7 @@ Jake VanderPlas
|
||||||
Jakob van Santen
|
Jakob van Santen
|
||||||
Jakub Mitoraj
|
Jakub Mitoraj
|
||||||
James Bourbeau
|
James Bourbeau
|
||||||
|
James Frost
|
||||||
Jan Balster
|
Jan Balster
|
||||||
Janne Vanhala
|
Janne Vanhala
|
||||||
Jason R. Coombs
|
Jason R. Coombs
|
||||||
|
@ -257,6 +259,7 @@ Marc Bresson
|
||||||
Marco Gorelli
|
Marco Gorelli
|
||||||
Mark Abramowitz
|
Mark Abramowitz
|
||||||
Mark Dickinson
|
Mark Dickinson
|
||||||
|
Mark Vong
|
||||||
Marko Pacak
|
Marko Pacak
|
||||||
Markus Unterwaditzer
|
Markus Unterwaditzer
|
||||||
Martijn Faassen
|
Martijn Faassen
|
||||||
|
@ -288,6 +291,7 @@ Mike Lundy
|
||||||
Milan Lesnek
|
Milan Lesnek
|
||||||
Miro Hrončok
|
Miro Hrončok
|
||||||
mrbean-bremen
|
mrbean-bremen
|
||||||
|
Nathan Goldbaum
|
||||||
Nathaniel Compton
|
Nathaniel Compton
|
||||||
Nathaniel Waisbrot
|
Nathaniel Waisbrot
|
||||||
Ned Batchelder
|
Ned Batchelder
|
||||||
|
@ -297,6 +301,7 @@ Nicholas Devenish
|
||||||
Nicholas Murphy
|
Nicholas Murphy
|
||||||
Niclas Olofsson
|
Niclas Olofsson
|
||||||
Nicolas Delaby
|
Nicolas Delaby
|
||||||
|
Nico Vidal
|
||||||
Nikolay Kondratyev
|
Nikolay Kondratyev
|
||||||
Nipunn Koorapati
|
Nipunn Koorapati
|
||||||
Oleg Pidsadnyi
|
Oleg Pidsadnyi
|
||||||
|
@ -357,6 +362,7 @@ Sadra Barikbin
|
||||||
Saiprasad Kale
|
Saiprasad Kale
|
||||||
Samuel Colvin
|
Samuel Colvin
|
||||||
Samuel Dion-Girardeau
|
Samuel Dion-Girardeau
|
||||||
|
Samuel Jirovec
|
||||||
Samuel Searles-Bryant
|
Samuel Searles-Bryant
|
||||||
Samuel Therrien (Avasam)
|
Samuel Therrien (Avasam)
|
||||||
Samuele Pedroni
|
Samuele Pedroni
|
||||||
|
@ -385,6 +391,7 @@ Stefano Taschini
|
||||||
Steffen Allner
|
Steffen Allner
|
||||||
Stephan Obermann
|
Stephan Obermann
|
||||||
Sven-Hendrik Haase
|
Sven-Hendrik Haase
|
||||||
|
Sviatoslav Sydorenko
|
||||||
Sylvain Marié
|
Sylvain Marié
|
||||||
Tadek Teleżyński
|
Tadek Teleżyński
|
||||||
Takafumi Arakaki
|
Takafumi Arakaki
|
||||||
|
@ -440,6 +447,7 @@ Yao Xiao
|
||||||
Yoav Caspi
|
Yoav Caspi
|
||||||
Yuliang Shao
|
Yuliang Shao
|
||||||
Yusuke Kadowaki
|
Yusuke Kadowaki
|
||||||
|
Yutian Li
|
||||||
Yuval Shimon
|
Yuval Shimon
|
||||||
Zac Hatfield-Dodds
|
Zac Hatfield-Dodds
|
||||||
Zachary Kneupper
|
Zachary Kneupper
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
============================
|
============================
|
||||||
Contribution getting started
|
Contributing
|
||||||
============================
|
============================
|
||||||
|
|
||||||
Contributions are highly welcomed and appreciated. Every little bit of help counts,
|
Contributions are highly welcomed and appreciated. Every little bit of help counts,
|
||||||
so do not hesitate!
|
so do not hesitate!
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:depth: 2
|
|
||||||
:backlinks: none
|
|
||||||
|
|
||||||
|
|
||||||
.. _submitfeedback:
|
.. _submitfeedback:
|
||||||
|
|
||||||
|
@ -128,7 +124,7 @@ For example:
|
||||||
Submitting Plugins to pytest-dev
|
Submitting Plugins to pytest-dev
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
Pytest development of the core, some plugins and support code happens
|
Development of the pytest core, support code, and some plugins happens
|
||||||
in repositories living under the ``pytest-dev`` organisations:
|
in repositories living under the ``pytest-dev`` organisations:
|
||||||
|
|
||||||
- `pytest-dev on GitHub <https://github.com/pytest-dev>`_
|
- `pytest-dev on GitHub <https://github.com/pytest-dev>`_
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
# 2.7.5 3.3.2
|
# 2.7.5 3.3.2
|
||||||
# FilesCompleter 75.1109 69.2116
|
# FilesCompleter 75.1109 69.2116
|
||||||
# FastFilesCompleter 0.7383 1.0760
|
# FastFilesCompleter 0.7383 1.0760
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import timeit
|
import timeit
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
for i in range(1000):
|
for i in range(1000):
|
||||||
exec("def test_func_%d(): pass" % i)
|
exec("def test_func_%d(): pass" % i)
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from unittest import TestCase # noqa: F401
|
from unittest import TestCase # noqa: F401
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
for i in range(5000):
|
for i in range(5000):
|
||||||
exec(
|
exec(
|
||||||
f"""
|
f"""
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
*
|
||||||
|
!.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,5 +0,0 @@
|
||||||
: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.
|
|
|
@ -1 +0,0 @@
|
||||||
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.
|
|
|
@ -1 +0,0 @@
|
||||||
Text is no longer truncated in the ``short test summary info`` section when ``-vv`` is given.
|
|
|
@ -1 +0,0 @@
|
||||||
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.
|
|
|
@ -1,4 +0,0 @@
|
||||||
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``.
|
|
|
@ -1,12 +0,0 @@
|
||||||
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.
|
|
|
@ -1 +0,0 @@
|
||||||
``pluggy>=1.5.0`` is now required.
|
|
|
@ -1 +0,0 @@
|
||||||
Improve namespace packages detection when :confval:`consider_namespace_packages` is enabled, covering more situations (like editable installs).
|
|
|
@ -1 +0,0 @@
|
||||||
Fix fixtures adding their finalizer multiple times to fixtures they request, causing unreliable and non-intuitive teardown ordering in some instances.
|
|
|
@ -1 +0,0 @@
|
||||||
cache: create cache directory supporting files (``CACHEDIR.TAG``, ``.gitignore``, etc.) in a temporary directory to provide atomic semantics.
|
|
|
@ -1 +0,0 @@
|
||||||
Fixed a bug with ``--importmode=importlib`` and ``--doctest-modules`` where child modules did not appear as attributes in parent modules.
|
|
|
@ -0,0 +1 @@
|
||||||
|
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.
|
|
@ -0,0 +1,3 @@
|
||||||
|
Migrated all internal type-annotations to the python3.10+ style by using the `annotations` future import.
|
||||||
|
|
||||||
|
-- by :user:`RonnyPfannschmidt`
|
|
@ -0,0 +1,13 @@
|
||||||
|
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`
|
|
@ -0,0 +1,5 @@
|
||||||
|
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`
|
|
@ -0,0 +1,11 @@
|
||||||
|
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`
|
|
@ -0,0 +1,4 @@
|
||||||
|
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`.
|
|
@ -0,0 +1,6 @@
|
||||||
|
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`
|
|
@ -0,0 +1,7 @@
|
||||||
|
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`
|
|
@ -0,0 +1,2 @@
|
||||||
|
Possible typos in using the ``:user:`` RST role is now being linted
|
||||||
|
through the pre-commit tool integration -- by :user:`webknjaz`.
|
|
@ -1 +0,0 @@
|
||||||
Fix some instances where teardown of higher-scoped fixtures was not happening in the reverse order they were initialized in.
|
|
|
@ -1 +0,0 @@
|
||||||
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.
|
|
|
@ -20,10 +20,22 @@ Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
|
||||||
* ``deprecation``: feature deprecation.
|
* ``deprecation``: feature deprecation.
|
||||||
* ``breaking``: a change which may break existing suites, such as feature removal or behavior change.
|
* ``breaking``: a change which may break existing suites, such as feature removal or behavior change.
|
||||||
* ``vendor``: changes in packages vendored in pytest.
|
* ``vendor``: changes in packages vendored in pytest.
|
||||||
* ``trivial``: fixing a small typo or internal change that might be noteworthy.
|
* ``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.
|
||||||
|
|
||||||
So for example: ``123.feature.rst``, ``456.bugfix.rst``.
|
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,
|
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
|
then after you submit the PR and get the PR number you can add a
|
||||||
changelog using that instead.
|
changelog using that instead.
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
# reference: https://docs.codecov.io/docs/codecovyml-reference
|
# reference: https://docs.codecov.io/docs/codecovyml-reference
|
||||||
|
---
|
||||||
|
|
||||||
|
codecov:
|
||||||
|
token: 1eca3b1f-31a2-4fb8-a8c3-138b441b50a7 #repo token
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
status:
|
status:
|
||||||
patch: true
|
patch: true
|
||||||
|
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
@ -0,0 +1,7 @@
|
||||||
|
<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>
|
|
@ -1,14 +0,0 @@
|
||||||
{#
|
|
||||||
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 %}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<style>
|
||||||
|
ul {list-style: none;}
|
||||||
|
li {margin: 0.4em 0;}
|
||||||
|
@media (min-width: 46em) {
|
||||||
|
#features {width: 50%;}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -6,6 +6,9 @@ Release announcements
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
|
||||||
|
release-8.2.2
|
||||||
|
release-8.2.1
|
||||||
|
release-8.2.0
|
||||||
release-8.1.2
|
release-8.1.2
|
||||||
release-8.1.1
|
release-8.1.1
|
||||||
release-8.1.0
|
release-8.1.0
|
||||||
|
|
|
@ -62,7 +62,7 @@ New Features
|
||||||
- new "-q" option which decreases verbosity and prints a more
|
- new "-q" option which decreases verbosity and prints a more
|
||||||
nose/unittest-style "dot" output.
|
nose/unittest-style "dot" output.
|
||||||
|
|
||||||
- many many more detailed improvements details
|
- many, many, more detailed improvements details
|
||||||
|
|
||||||
Fixes
|
Fixes
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -109,7 +109,7 @@ Important Notes
|
||||||
in conftest.py files. They will cause nothing special.
|
in conftest.py files. They will cause nothing special.
|
||||||
- removed support for calling the pre-1.0 collection API of "run()" and "join"
|
- 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.
|
- 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.
|
mechanism and the "addopts" entry in particular.
|
||||||
- removed the "disabled" attribute in test classes. Use the skipping
|
- removed the "disabled" attribute in test classes. Use the skipping
|
||||||
and pytestmark mechanism to skip or xfail a test class.
|
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
|
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
|
backward-compatible release of the versatile py.test testing tool. It
|
||||||
contains bug fixes and a few refinements particularly to reporting with
|
contains bug fixes and a few refinements particularly to reporting with
|
||||||
"--collectonly", see below for betails.
|
"--collectonly", see below for details.
|
||||||
|
|
||||||
For general information see here:
|
For general information see here:
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ Bug fixes:
|
||||||
partially failed (finalizers would not always be called before)
|
partially failed (finalizers would not always be called before)
|
||||||
|
|
||||||
- fix issue320 - fix class scope for fixtures when mixed with
|
- fix issue320 - fix class scope for fixtures when mixed with
|
||||||
module-level functions. Thanks Anatloy Bubenkoff.
|
module-level functions. Thanks Anatoly Bubenkoff.
|
||||||
|
|
||||||
- you can specify "-q" or "-qq" to get different levels of "quieter"
|
- you can specify "-q" or "-qq" to get different levels of "quieter"
|
||||||
reporting (thanks Katarzyna Jachim)
|
reporting (thanks Katarzyna Jachim)
|
||||||
|
|
|
@ -83,7 +83,7 @@ holger krekel
|
||||||
Thanks Ralph Schmitt for the precise failure example.
|
Thanks Ralph Schmitt for the precise failure example.
|
||||||
|
|
||||||
- fix issue244 by implementing special index for parameters to only use
|
- fix issue244 by implementing special index for parameters to only use
|
||||||
indices for paramentrized test ids
|
indices for parametrized test ids
|
||||||
|
|
||||||
- fix issue287 by running all finalizers but saving the exception
|
- fix issue287 by running all finalizers but saving the exception
|
||||||
from the first failing finalizer and re-raising it so teardown will
|
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
|
- cleanup setup.py a bit and specify supported versions. Thanks Jurko
|
||||||
Gospodnetic for the PR.
|
Gospodnetic for the PR.
|
||||||
|
|
||||||
- change XPASS colour to yellow rather then red when tests are run
|
- change XPASS colour to yellow rather than red when tests are run
|
||||||
with -v.
|
with -v.
|
||||||
|
|
||||||
- fix issue473: work around mock putting an unbound method into a class
|
- 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 .
|
github. See https://pytest.org/en/stable/contributing.html .
|
||||||
Thanks to Anatoly for pushing and initial work on this.
|
Thanks to Anatoly for pushing and initial work on this.
|
||||||
|
|
||||||
- fix issue650: new option ``--docttest-ignore-import-errors`` which
|
- fix issue650: new option ``--doctest-ignore-import-errors`` which
|
||||||
will turn import errors in doctests into skips. Thanks Charles Cloud
|
will turn import errors in doctests into skips. Thanks Charles Cloud
|
||||||
for the complete PR.
|
for the complete PR.
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ The py.test Development Team
|
||||||
**New Features**
|
**New Features**
|
||||||
|
|
||||||
* New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
|
* New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
|
||||||
Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
|
Thanks :user:`MichaelAquilina` for the complete PR (:pr:`1040`).
|
||||||
|
|
||||||
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
||||||
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
|
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
|
||||||
|
|
|
@ -44,7 +44,7 @@ The py.test Development Team
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
|
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
|
||||||
contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
|
contain ``::``. Thanks :user:`tomviner` for the PR (:pr:`1431`).
|
||||||
|
|
||||||
* Fix (:issue:`578`): SyntaxErrors
|
* Fix (:issue:`578`): SyntaxErrors
|
||||||
containing non-ascii lines at the point of failure generated an internal
|
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.
|
* Fix Xfail does not work with condition keyword argument.
|
||||||
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
|
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
|
||||||
for PR the (:pull:`1524`).
|
for PR the (:pr:`1524`).
|
||||||
|
|
||||||
* Fix win32 path issue when putting custom config file with absolute path
|
* Fix win32 path issue when putting custom config file with absolute path
|
||||||
in ``pytest.main("-c your_absolute_path")``.
|
in ``pytest.main("-c your_absolute_path")``.
|
||||||
|
|
||||||
* Fix maximum recursion depth detection when raised error class is not aware
|
* Fix maximum recursion depth detection when raised error class is not aware
|
||||||
of unicode/encoded bytes.
|
of unicode/encoded bytes.
|
||||||
Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
|
Thanks :user:`prusse-martin` for the PR (:pr:`1506`).
|
||||||
|
|
||||||
* Fix ``pytest.mark.skip`` mark when used in strict mode.
|
* Fix ``pytest.mark.skip`` mark when used in strict mode.
|
||||||
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
|
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
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
|
|
@ -0,0 +1,19 @@
|
||||||
|
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
|
|
@ -0,0 +1,19 @@
|
||||||
|
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.
|
day for some hot hiking in the Black Forest.
|
||||||
|
|
||||||
Sprint activity was organised heavily around pairing, with plenty of group
|
Sprint activity was organised heavily around pairing, with plenty of group
|
||||||
discusssions to take advantage of the high bandwidth, and lightning talks
|
discussions to take advantage of the high bandwidth, and lightning talks
|
||||||
as well.
|
as well.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,30 +5,26 @@ Backwards Compatibility Policy
|
||||||
|
|
||||||
.. versionadded: 6.0
|
.. versionadded: 6.0
|
||||||
|
|
||||||
pytest is actively evolving and is a project that has been decades in the making,
|
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.
|
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:
|
As of now, pytest considers multiple types of backward compatibility transitions:
|
||||||
|
|
||||||
a) trivial: APIs which trivially translate to the new mechanism,
|
a) trivial: APIs that trivially translate to the new mechanism and do not cause problematic changes.
|
||||||
and do not cause problematic changes.
|
|
||||||
|
|
||||||
We try to support those indefinitely while encouraging users to switch to newer/better mechanisms through documentation.
|
We try to support those indefinitely while encouraging users to switch to newer or better mechanisms through documentation.
|
||||||
|
|
||||||
b) transitional: the old and new API don't conflict
|
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.
|
||||||
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`).
|
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:
|
Examples for such upcoming changes:
|
||||||
|
|
||||||
|
@ -62,11 +58,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.
|
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.
|
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
|
cachedir: .pytest_cache
|
||||||
rootdir: /home/sweet/project
|
rootdir: /home/sweet/project
|
||||||
collected 0 items
|
collected 0 items
|
||||||
cache -- .../_pytest/cacheprovider.py:527
|
cache -- .../_pytest/cacheprovider.py:560
|
||||||
Return a cache object that can persist state between testing sessions.
|
Return a cache object that can persist state between testing sessions.
|
||||||
|
|
||||||
cache.get(key, default)
|
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.
|
Values can be any object handled by the json stdlib module.
|
||||||
|
|
||||||
capsysbinary -- .../_pytest/capture.py:1008
|
capsysbinary -- .../_pytest/capture.py:1003
|
||||||
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
||||||
|
|
||||||
The captured output is made available via ``capsysbinary.readouterr()``
|
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()
|
captured = capsysbinary.readouterr()
|
||||||
assert captured.out == b"hello\n"
|
assert captured.out == b"hello\n"
|
||||||
|
|
||||||
capfd -- .../_pytest/capture.py:1035
|
capfd -- .../_pytest/capture.py:1030
|
||||||
Enable text capturing of writes to file descriptors ``1`` and ``2``.
|
Enable text capturing of writes to file descriptors ``1`` and ``2``.
|
||||||
|
|
||||||
The captured output is made available via ``capfd.readouterr()`` method
|
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()
|
captured = capfd.readouterr()
|
||||||
assert captured.out == "hello\n"
|
assert captured.out == "hello\n"
|
||||||
|
|
||||||
capfdbinary -- .../_pytest/capture.py:1062
|
capfdbinary -- .../_pytest/capture.py:1057
|
||||||
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
|
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
|
||||||
|
|
||||||
The captured output is made available via ``capfd.readouterr()`` method
|
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()
|
captured = capfdbinary.readouterr()
|
||||||
assert captured.out == b"hello\n"
|
assert captured.out == b"hello\n"
|
||||||
|
|
||||||
capsys -- .../_pytest/capture.py:981
|
capsys -- .../_pytest/capture.py:976
|
||||||
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
|
||||||
|
|
||||||
The captured output is made available via ``capsys.readouterr()`` method
|
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()
|
captured = capsys.readouterr()
|
||||||
assert captured.out == "hello\n"
|
assert captured.out == "hello\n"
|
||||||
|
|
||||||
doctest_namespace [session scope] -- .../_pytest/doctest.py:737
|
doctest_namespace [session scope] -- .../_pytest/doctest.py:738
|
||||||
Fixture that returns a :py:class:`dict` that will be injected into the
|
Fixture that returns a :py:class:`dict` that will be injected into the
|
||||||
namespace of doctests.
|
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`.
|
For more details: :ref:`doctest_namespace`.
|
||||||
|
|
||||||
pytestconfig [session scope] -- .../_pytest/fixtures.py:1346
|
pytestconfig [session scope] -- .../_pytest/fixtures.py:1338
|
||||||
Session-scoped fixture that returns the session's :class:`pytest.Config`
|
Session-scoped fixture that returns the session's :class:`pytest.Config`
|
||||||
object.
|
object.
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||||
if pytestconfig.getoption("verbose") > 0:
|
if pytestconfig.getoption("verbose") > 0:
|
||||||
...
|
...
|
||||||
|
|
||||||
record_property -- .../_pytest/junitxml.py:283
|
record_property -- .../_pytest/junitxml.py:284
|
||||||
Add extra properties to the calling test.
|
Add extra properties to the calling test.
|
||||||
|
|
||||||
User properties become part of the test report and are available to the
|
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):
|
def test_function(record_property):
|
||||||
record_property("example_key", 1)
|
record_property("example_key", 1)
|
||||||
|
|
||||||
record_xml_attribute -- .../_pytest/junitxml.py:306
|
record_xml_attribute -- .../_pytest/junitxml.py:307
|
||||||
Add extra xml attributes to the tag for the calling test.
|
Add extra xml attributes to the tag for the calling test.
|
||||||
|
|
||||||
The fixture is callable with ``name, value``. The value is
|
The fixture is callable with ``name, value``. The value is
|
||||||
automatically XML-encoded.
|
automatically XML-encoded.
|
||||||
|
|
||||||
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:344
|
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:345
|
||||||
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
|
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
|
||||||
|
|
||||||
This is suitable to writing global information regarding the entire test
|
This is suitable to writing global information regarding the entire test
|
||||||
|
@ -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
|
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
|
||||||
|
|
||||||
caplog -- .../_pytest/logging.py:601
|
caplog -- .../_pytest/logging.py:602
|
||||||
Access and control log capturing.
|
Access and control log capturing.
|
||||||
|
|
||||||
Captured logs are available through the following properties/methods::
|
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.record_tuples -> list of (logger_name, level, message) tuples
|
||||||
* caplog.clear() -> clear captured records and formatted log output string
|
* caplog.clear() -> clear captured records and formatted log output string
|
||||||
|
|
||||||
monkeypatch -- .../_pytest/monkeypatch.py:32
|
monkeypatch -- .../_pytest/monkeypatch.py:33
|
||||||
A convenient fixture for monkey-patching.
|
A convenient fixture for monkey-patching.
|
||||||
|
|
||||||
The fixture provides these methods to modify objects, dictionaries, or
|
The fixture provides these methods to modify objects, dictionaries, or
|
||||||
|
@ -227,16 +227,16 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
|
||||||
To undo modifications done by the fixture in a contained scope,
|
To undo modifications done by the fixture in a contained scope,
|
||||||
use :meth:`context() <pytest.MonkeyPatch.context>`.
|
use :meth:`context() <pytest.MonkeyPatch.context>`.
|
||||||
|
|
||||||
recwarn -- .../_pytest/recwarn.py:31
|
recwarn -- .../_pytest/recwarn.py:32
|
||||||
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
|
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
|
||||||
|
|
||||||
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
|
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information
|
||||||
on warning categories.
|
on warning categories.
|
||||||
|
|
||||||
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:241
|
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242
|
||||||
Return a :class:`pytest.TempPathFactory` instance for the test session.
|
Return a :class:`pytest.TempPathFactory` instance for the test session.
|
||||||
|
|
||||||
tmp_path -- .../_pytest/tmpdir.py:256
|
tmp_path -- .../_pytest/tmpdir.py:257
|
||||||
Return a temporary directory path object which is unique to each test
|
Return a temporary directory path object which is unique to each test
|
||||||
function invocation, created as a sub directory of the base temporary
|
function invocation, created as a sub directory of the base temporary
|
||||||
directory.
|
directory.
|
||||||
|
|
|
@ -19,15 +19,178 @@ with advance notice in the **Deprecations** section of releases.
|
||||||
we named the news folder changelog
|
we named the news folder changelog
|
||||||
|
|
||||||
|
|
||||||
.. only:: changelog_towncrier_draft
|
.. only:: not is_release
|
||||||
|
|
||||||
.. The 'changelog_towncrier_draft' tag is included by our 'tox -e docs',
|
To be included in v\ |release| (if present)
|
||||||
but not on readthedocs.
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. include:: _changelog_towncrier_draft.rst
|
.. towncrier-draft-entries:: |release| [UNRELEASED DRAFT]
|
||||||
|
|
||||||
|
Released versions
|
||||||
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
.. towncrier release notes start
|
.. 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)
|
pytest 8.1.2 (2024-04-26)
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
@ -69,7 +232,7 @@ Improvements
|
||||||
- `#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
|
- `#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.
|
as the relative directory.
|
||||||
|
|
||||||
Previoulsy this would raise an :class:`AssertionError`.
|
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.
|
- `#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.
|
||||||
|
@ -105,7 +268,7 @@ Bug Fixes
|
||||||
|
|
||||||
- `#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``.
|
- `#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 :pull:`12043` for a comparison with pytest 8.0 and <8.
|
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.
|
- `#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.
|
||||||
|
@ -1259,7 +1422,7 @@ Bug Fixes
|
||||||
tests/link -> tests/real
|
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``.
|
running ``pytest tests`` now imports the conftest twice, once as ``tests/real/conftest.py`` and once as ``tests/link/conftest.py``.
|
||||||
This is a fix to match a similar change made to test collection itself in pytest 6.0 (see :pull:`6523` for details).
|
This is a fix to match a similar change made to test collection itself in pytest 6.0 (see :pr:`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.
|
- `#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.
|
||||||
|
@ -1312,7 +1475,7 @@ Deprecations
|
||||||
``__init__`` method, they should take ``**kwargs``. See
|
``__init__`` method, they should take ``**kwargs``. See
|
||||||
:ref:`uncooperative-constructors-deprecated` for details.
|
:ref:`uncooperative-constructors-deprecated` for details.
|
||||||
|
|
||||||
Note that a deprection warning is only emitted when there is a conflict in the
|
Note that a deprecation warning is only emitted when there is a conflict in the
|
||||||
arguments pytest expected to pass. This deprecation was already part of pytest
|
arguments pytest expected to pass. This deprecation was already part of pytest
|
||||||
7.0.0rc1 but wasn't documented.
|
7.0.0rc1 but wasn't documented.
|
||||||
|
|
||||||
|
@ -1354,7 +1517,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`.
|
- `#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.
|
Most plugins which refer to `reportinfo()` only define it as part of a custom :class:`pytest.Item` implementation.
|
||||||
Since `py.path.local` is an `os.PathLike[str]`, these plugins are unaffacted.
|
Since `py.path.local` is an `os.PathLike[str]`, these plugins are unaffected.
|
||||||
|
|
||||||
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)`.
|
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.
|
Although preferably, avoid the legacy `py.path.local` and use `pathlib.Path`, or use `item.location` or `item.path`, instead.
|
||||||
|
@ -1862,7 +2025,7 @@ Bug Fixes
|
||||||
the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with
|
the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with
|
||||||
private permissions.
|
private permissions.
|
||||||
|
|
||||||
pytest used to silently use a pre-existing ``/tmp/pytest-of-<username>`` directory,
|
pytest used to silently use a preexisting ``/tmp/pytest-of-<username>`` directory,
|
||||||
even if owned by another user. This means another user could pre-create such a
|
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
|
directory and gain control of another user's temporary directory. Now such a
|
||||||
condition results in an error.
|
condition results in an error.
|
||||||
|
@ -2428,7 +2591,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.
|
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
|
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
|
||||||
:pull:`6523` for details).
|
:pr:`6523` for details).
|
||||||
|
|
||||||
This might break test suites which made use of this feature; the fix is to create a symlink
|
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.
|
for the entire test tree, and not only to partial files/tress as it was possible previously.
|
||||||
|
@ -2589,7 +2752,7 @@ Features
|
||||||
also changes ``sys.modules`` as a side-effect), which works but has a number of drawbacks, like requiring test modules
|
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``).
|
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
|
require pytest to change ``sys.path`` or ``sys.modules`` at all, eliminating much of the drawbacks
|
||||||
of the previous mode.
|
of the previous mode.
|
||||||
|
|
||||||
|
@ -2606,7 +2769,7 @@ Improvements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
- :issue:`4375`: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that
|
- :issue:`4375`: The ``pytest`` command now suppresses the ``BrokenPipeError`` error message that
|
||||||
is printed to stderr when the output of ``pytest`` is piped and and the pipe is
|
is printed to stderr when the output of ``pytest`` is piped and the pipe is
|
||||||
closed by the piped-to program (common examples are ``less`` and ``head``).
|
closed by the piped-to program (common examples are ``less`` and ``head``).
|
||||||
|
|
||||||
|
|
||||||
|
@ -2711,7 +2874,7 @@ Bug Fixes
|
||||||
- :issue:`6871`: Fix crash with captured output when using :fixture:`capsysbinary`.
|
- :issue:`6871`: Fix crash with captured output when using :fixture:`capsysbinary`.
|
||||||
|
|
||||||
|
|
||||||
- :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.
|
- :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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
@ -2881,7 +3044,7 @@ pytest 5.4.1 (2020-03-13)
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
---------
|
---------
|
||||||
|
|
||||||
- :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.
|
- :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.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
@ -2908,7 +3071,7 @@ Breaking Changes
|
||||||
This hook has been marked as deprecated and not been even called by pytest for over 10 years now.
|
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 sth. expected is missing in the result and "+" means that there are unexpected extras in the result.
|
- :issue:`6673`: Reversed / fix meaning of "+/-" in error diffs. "-" means that something 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
|
- :issue:`6737`: The ``cached_result`` attribute of ``FixtureDef`` is now set to ``None`` when
|
||||||
|
@ -3197,7 +3360,9 @@ Bug Fixes
|
||||||
- :issue:`5914`: pytester: fix :py:func:`~pytest.LineMatcher.no_fnmatch_line` when used after positive matching.
|
- :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 :bpo:`17446`.
|
- :issue:`6082`: Fix line detection for doctest samples inside
|
||||||
|
:py:class:`python:property` docstrings, as a workaround to
|
||||||
|
:issue:`python/cpython#61648`.
|
||||||
|
|
||||||
|
|
||||||
- :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0).
|
- :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0).
|
||||||
|
@ -3904,7 +4069,7 @@ Bug Fixes
|
||||||
(``--collect-only``) when ``--log-cli-level`` is used.
|
(``--collect-only``) when ``--log-cli-level`` is used.
|
||||||
|
|
||||||
|
|
||||||
- :issue:`5389`: Fix regressions of :pull:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
|
- :issue:`5389`: Fix regressions of :pr:`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.
|
- :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
|
||||||
|
@ -4105,7 +4270,7 @@ Bug Fixes
|
||||||
(``--collect-only``) when ``--log-cli-level`` is used.
|
(``--collect-only``) when ``--log-cli-level`` is used.
|
||||||
|
|
||||||
|
|
||||||
- :issue:`5389`: Fix regressions of :pull:`5063` for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
|
- :issue:`5389`: Fix regressions of :pr:`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.
|
- :issue:`5390`: Fix regression where the ``obj`` attribute of ``TestCase`` items was no longer bound to methods.
|
||||||
|
@ -4513,7 +4678,7 @@ Bug Fixes
|
||||||
Improved Documentation
|
Improved Documentation
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
- :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability liminations
|
- :issue:`4974`: Update docs for ``pytest_cmdline_parse`` hook to note availability limitations
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6371,7 +6536,7 @@ Features
|
||||||
Bug Fixes
|
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`)
|
(:issue:`2022`)
|
||||||
|
|
||||||
- Fix restoring Python state after in-process pytest runs with the
|
- Fix restoring Python state after in-process pytest runs with the
|
||||||
|
@ -6419,7 +6584,7 @@ Trivial/Internal Changes
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
- Show a simple and easy error when keyword expressions trigger a syntax error
|
- Show a simple and easy error when keyword expressions trigger a syntax error
|
||||||
(for example, ``"-k foo and import"`` will show an error that you can not use
|
(for example, ``"-k foo and import"`` will show an error that you cannot use
|
||||||
the ``import`` keyword in expressions). (:issue:`2953`)
|
the ``import`` keyword in expressions). (:issue:`2953`)
|
||||||
|
|
||||||
- Change parametrized automatic test id generation to use the ``__name__``
|
- Change parametrized automatic test id generation to use the ``__name__``
|
||||||
|
@ -7066,10 +7231,10 @@ New Features
|
||||||
* Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (:issue:`533`).
|
* Added ``junit_suite_name`` ini option to specify root ``<testsuite>`` name for JUnit XML reports (:issue:`533`).
|
||||||
|
|
||||||
* Added an ini option ``doctest_encoding`` to specify which encoding to use for doctest files.
|
* Added an ini option ``doctest_encoding`` to specify which encoding to use for doctest files.
|
||||||
Thanks :user:`wheerd` for the PR (:pull:`2101`).
|
Thanks :user:`wheerd` for the PR (:pr:`2101`).
|
||||||
|
|
||||||
* ``pytest.warns`` now checks for subclass relationship rather than
|
* ``pytest.warns`` now checks for subclass relationship rather than
|
||||||
class equality. Thanks :user:`lesteve` for the PR (:pull:`2166`)
|
class equality. Thanks :user:`lesteve` for the PR (:pr:`2166`)
|
||||||
|
|
||||||
* ``pytest.raises`` now asserts that the error message matches a text or regex
|
* ``pytest.raises`` now asserts that the error message matches a text or regex
|
||||||
with the ``match`` keyword argument. Thanks :user:`Kriechi` for the PR.
|
with the ``match`` keyword argument. Thanks :user:`Kriechi` for the PR.
|
||||||
|
@ -7097,7 +7262,7 @@ Changes
|
||||||
the failure. (:issue:`2228`) Thanks to :user:`kkoukiou` for the PR.
|
the failure. (:issue:`2228`) Thanks to :user:`kkoukiou` for the PR.
|
||||||
|
|
||||||
* Testcase reports with a ``url`` attribute will now properly write this to junitxml.
|
* Testcase reports with a ``url`` attribute will now properly write this to junitxml.
|
||||||
Thanks :user:`fushi` for the PR (:pull:`1874`).
|
Thanks :user:`fushi` for the PR (:pr:`1874`).
|
||||||
|
|
||||||
* Remove common items from dict comparison output when verbosity=1. Also update
|
* Remove common items from dict comparison output when verbosity=1. Also update
|
||||||
the truncation message to make it clearer that pytest truncates all
|
the truncation message to make it clearer that pytest truncates all
|
||||||
|
@ -7106,7 +7271,7 @@ Changes
|
||||||
|
|
||||||
* ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use
|
* ``--pdbcls`` no longer implies ``--pdb``. This makes it possible to use
|
||||||
``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for
|
``addopts=--pdbcls=module.SomeClass`` on ``pytest.ini``. Thanks :user:`davidszotten` for
|
||||||
the PR (:pull:`1952`).
|
the PR (:pr:`1952`).
|
||||||
|
|
||||||
* fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
|
* fix :issue:`2013`: turn RecordedWarning into ``namedtuple``,
|
||||||
to give it a comprehensible repr while preventing unwarranted modification.
|
to give it a comprehensible repr while preventing unwarranted modification.
|
||||||
|
@ -7360,7 +7525,7 @@ Bug Fixes
|
||||||
a sequence of strings) when modules are considered for assertion rewriting.
|
a sequence of strings) when modules are considered for assertion rewriting.
|
||||||
Due to this bug, much more modules were being rewritten than necessary
|
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`).
|
if a test suite uses ``pytest_plugins`` to load internal plugins (:issue:`1888`).
|
||||||
Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR (:pull:`1891`).
|
Thanks :user:`jaraco` for the report and :user:`nicoddemus` for the PR (:pr:`1891`).
|
||||||
|
|
||||||
* Do not call tearDown and cleanups when running tests from
|
* Do not call tearDown and cleanups when running tests from
|
||||||
``unittest.TestCase`` subclasses with ``--pdb``
|
``unittest.TestCase`` subclasses with ``--pdb``
|
||||||
|
@ -7415,12 +7580,12 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
* ``--nomagic``: use ``--assert=plain`` instead;
|
* ``--nomagic``: use ``--assert=plain`` instead;
|
||||||
* ``--report``: use ``-r`` instead;
|
* ``--report``: use ``-r`` instead;
|
||||||
|
|
||||||
Thanks to :user:`RedBeardCode` for the PR (:pull:`1664`).
|
Thanks to :user:`RedBeardCode` for the PR (:pr:`1664`).
|
||||||
|
|
||||||
* ImportErrors in plugins now are a fatal error instead of issuing a
|
* ImportErrors in plugins now are a fatal error instead of issuing a
|
||||||
pytest warning (:issue:`1479`). Thanks to :user:`The-Compiler` for the PR.
|
pytest warning (:issue:`1479`). Thanks to :user:`The-Compiler` for the PR.
|
||||||
|
|
||||||
* Removed support code for Python 3 versions < 3.3 (:pull:`1627`).
|
* Removed support code for Python 3 versions < 3.3 (:pr:`1627`).
|
||||||
|
|
||||||
* Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points
|
* 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
|
were never documented and a leftover from a pre-virtualenv era. These entry
|
||||||
|
@ -7431,19 +7596,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,
|
* ``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
|
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`).
|
this usage would cause the entire module to be skipped (:issue:`607`).
|
||||||
Thanks :user:`omarkohl` for the complete PR (:pull:`1519`).
|
Thanks :user:`omarkohl` for the complete PR (:pr:`1519`).
|
||||||
|
|
||||||
* Exit tests if a collection error occurs. A poll indicated most users will hit CTRL-C
|
* 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`).
|
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.
|
A ``--continue-on-collection-errors`` option has been added to restore the previous behaviour.
|
||||||
Thanks :user:`olegpidsadnyi` and :user:`omarkohl` for the complete PR (:pull:`1628`).
|
Thanks :user:`olegpidsadnyi` and :user:`omarkohl` for the complete PR (:pr:`1628`).
|
||||||
|
|
||||||
* Renamed the pytest ``pdb`` module (plugin) into ``debugging`` to avoid clashes with the builtin ``pdb`` module.
|
* 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,
|
* Raise a helpful failure message when requesting a parametrized fixture at runtime,
|
||||||
e.g. with ``request.getfixturevalue``. Previously these parameters were simply
|
e.g. with ``request.getfixturevalue``. Previously these parameters were simply
|
||||||
never defined, so a fixture decorated like ``@pytest.fixture(params=[0, 1, 2])``
|
never defined, so a fixture decorated like ``@pytest.fixture(params=[0, 1, 2])``
|
||||||
only ran once (:pull:`460`).
|
only ran once (:pr:`460`).
|
||||||
Thanks to :user:`nikratio` for the bug report, :user:`RedBeardCode` and :user:`tomviner` for the PR.
|
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``
|
* ``_pytest.monkeypatch.monkeypatch`` class has been renamed to ``_pytest.monkeypatch.MonkeyPatch``
|
||||||
|
@ -7461,7 +7626,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
|
|
||||||
* New ``doctest_namespace`` fixture for injecting names into the
|
* New ``doctest_namespace`` fixture for injecting names into the
|
||||||
namespace in which doctests run.
|
namespace in which doctests run.
|
||||||
Thanks :user:`milliams` for the complete PR (:pull:`1428`).
|
Thanks :user:`milliams` for the complete PR (:pr:`1428`).
|
||||||
|
|
||||||
* New ``--doctest-report`` option available to change the output format of diffs
|
* New ``--doctest-report`` option available to change the output format of diffs
|
||||||
when running (failing) doctests (implements :issue:`1749`).
|
when running (failing) doctests (implements :issue:`1749`).
|
||||||
|
@ -7469,23 +7634,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
|
* New ``name`` argument to ``pytest.fixture`` decorator which allows a custom name
|
||||||
for a fixture (to solve the funcarg-shadowing-fixture problem).
|
for a fixture (to solve the funcarg-shadowing-fixture problem).
|
||||||
Thanks :user:`novas0x2a` for the complete PR (:pull:`1444`).
|
Thanks :user:`novas0x2a` for the complete PR (:pr:`1444`).
|
||||||
|
|
||||||
* New ``approx()`` function for easily comparing floating-point numbers in
|
* New ``approx()`` function for easily comparing floating-point numbers in
|
||||||
tests.
|
tests.
|
||||||
Thanks :user:`kalekundert` for the complete PR (:pull:`1441`).
|
Thanks :user:`kalekundert` for the complete PR (:pr:`1441`).
|
||||||
|
|
||||||
* Ability to add global properties in the final xunit output file by accessing
|
* Ability to add global properties in the final xunit output file by accessing
|
||||||
the internal ``junitxml`` plugin (experimental).
|
the internal ``junitxml`` plugin (experimental).
|
||||||
Thanks :user:`tareqalayan` for the complete PR :pull:`1454`).
|
Thanks :user:`tareqalayan` for the complete PR :pr:`1454`).
|
||||||
|
|
||||||
* New ``ExceptionInfo.match()`` method to match a regular expression on the
|
* New ``ExceptionInfo.match()`` method to match a regular expression on the
|
||||||
string representation of an exception (:issue:`372`).
|
string representation of an exception (:issue:`372`).
|
||||||
Thanks :user:`omarkohl` for the complete PR (:pull:`1502`).
|
Thanks :user:`omarkohl` for the complete PR (:pr:`1502`).
|
||||||
|
|
||||||
* ``__tracebackhide__`` can now also be set to a callable which then can decide
|
* ``__tracebackhide__`` can now also be set to a callable which then can decide
|
||||||
whether to filter the traceback based on the ``ExceptionInfo`` object passed
|
whether to filter the traceback based on the ``ExceptionInfo`` object passed
|
||||||
to it. Thanks :user:`The-Compiler` for the complete PR (:pull:`1526`).
|
to it. Thanks :user:`The-Compiler` for the complete PR (:pr:`1526`).
|
||||||
|
|
||||||
* New ``pytest_make_parametrize_id(config, val)`` hook which can be used by plugins to provide
|
* New ``pytest_make_parametrize_id(config, val)`` hook which can be used by plugins to provide
|
||||||
friendly strings for custom types.
|
friendly strings for custom types.
|
||||||
|
@ -7503,7 +7668,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``
|
* Introduce ``pytest`` command as recommended entry point. Note that ``py.test``
|
||||||
still works and is not scheduled for removal. Closes proposal
|
still works and is not scheduled for removal. Closes proposal
|
||||||
:issue:`1629`. Thanks :user:`obestwalter` and :user:`davehunt` for the complete PR
|
:issue:`1629`. Thanks :user:`obestwalter` and :user:`davehunt` for the complete PR
|
||||||
(:pull:`1633`).
|
(:pr:`1633`).
|
||||||
|
|
||||||
* New cli flags:
|
* New cli flags:
|
||||||
|
|
||||||
|
@ -7547,19 +7712,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
|
* Change ``report.outcome`` for ``xpassed`` tests to ``"passed"`` in non-strict
|
||||||
mode and ``"failed"`` in strict mode. Thanks to :user:`hackebrot` for the PR
|
mode and ``"failed"`` in strict mode. Thanks to :user:`hackebrot` for the PR
|
||||||
(:pull:`1795`) and :user:`gprasad84` for report (:issue:`1546`).
|
(:pr:`1795`) and :user:`gprasad84` for report (:issue:`1546`).
|
||||||
|
|
||||||
* Tests marked with ``xfail(strict=False)`` (the default) now appear in
|
* Tests marked with ``xfail(strict=False)`` (the default) now appear in
|
||||||
JUnitXML reports as passing tests instead of skipped.
|
JUnitXML reports as passing tests instead of skipped.
|
||||||
Thanks to :user:`hackebrot` for the PR (:pull:`1795`).
|
Thanks to :user:`hackebrot` for the PR (:pr:`1795`).
|
||||||
|
|
||||||
* Highlight path of the file location in the error report to make it easier to copy/paste.
|
* Highlight path of the file location in the error report to make it easier to copy/paste.
|
||||||
Thanks :user:`suzaku` for the PR (:pull:`1778`).
|
Thanks :user:`suzaku` for the PR (:pr:`1778`).
|
||||||
|
|
||||||
* Fixtures marked with ``@pytest.fixture`` can now use ``yield`` statements exactly like
|
* Fixtures marked with ``@pytest.fixture`` can now use ``yield`` statements exactly like
|
||||||
those marked with the ``@pytest.yield_fixture`` decorator. This change renders
|
those marked with the ``@pytest.yield_fixture`` decorator. This change renders
|
||||||
``@pytest.yield_fixture`` deprecated and makes ``@pytest.fixture`` with ``yield`` statements
|
``@pytest.yield_fixture`` deprecated and makes ``@pytest.fixture`` with ``yield`` statements
|
||||||
the preferred way to write teardown code (:pull:`1461`).
|
the preferred way to write teardown code (:pr:`1461`).
|
||||||
Thanks :user:`csaftoiu` for bringing this to attention and :user:`nicoddemus` for the PR.
|
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`).
|
* Explicitly passed parametrize ids do not get escaped to ascii (:issue:`1351`).
|
||||||
|
@ -7570,11 +7735,11 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* ``pytest_terminal_summary`` hook now receives the ``exitstatus``
|
* ``pytest_terminal_summary`` hook now receives the ``exitstatus``
|
||||||
of the test session as argument. Thanks :user:`blueyed` for the PR (:pull:`1809`).
|
of the test session as argument. Thanks :user:`blueyed` for the PR (:pr:`1809`).
|
||||||
|
|
||||||
* Parametrize ids can accept ``None`` as specific test id, in which case the
|
* Parametrize ids can accept ``None`` as specific test id, in which case the
|
||||||
automatically generated id for that argument will be used.
|
automatically generated id for that argument will be used.
|
||||||
Thanks :user:`palaviv` for the complete PR (:pull:`1468`).
|
Thanks :user:`palaviv` for the complete PR (:pr:`1468`).
|
||||||
|
|
||||||
* The parameter to xunit-style setup/teardown methods (``setup_method``,
|
* The parameter to xunit-style setup/teardown methods (``setup_method``,
|
||||||
``setup_module``, etc.) is now optional and may be omitted.
|
``setup_module``, etc.) is now optional and may be omitted.
|
||||||
|
@ -7582,32 +7747,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
|
* Improved automatic id generation selection in case of duplicate ids in
|
||||||
parametrize.
|
parametrize.
|
||||||
Thanks :user:`palaviv` for the complete PR (:pull:`1474`).
|
Thanks :user:`palaviv` for the complete PR (:pr:`1474`).
|
||||||
|
|
||||||
* Now pytest warnings summary is shown up by default. Added a new flag
|
* Now pytest warnings summary is shown up by default. Added a new flag
|
||||||
``--disable-pytest-warnings`` to explicitly disable the warnings summary (:issue:`1668`).
|
``--disable-pytest-warnings`` to explicitly disable the warnings summary (:issue:`1668`).
|
||||||
|
|
||||||
* Make ImportError during collection more explicit by reminding
|
* Make ImportError during collection more explicit by reminding
|
||||||
the user to check the name of the test module/package(s) (:issue:`1426`).
|
the user to check the name of the test module/package(s) (:issue:`1426`).
|
||||||
Thanks :user:`omarkohl` for the complete PR (:pull:`1520`).
|
Thanks :user:`omarkohl` for the complete PR (:pr:`1520`).
|
||||||
|
|
||||||
* Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks
|
* Add ``build/`` and ``dist/`` to the default ``--norecursedirs`` list. Thanks
|
||||||
:user:`mikofski` for the report and :user:`tomviner` for the PR (:issue:`1544`).
|
:user:`mikofski` for the report and :user:`tomviner` for the PR (:issue:`1544`).
|
||||||
|
|
||||||
* ``pytest.raises`` in the context manager form accepts a custom
|
* ``pytest.raises`` in the context manager form accepts a custom
|
||||||
``message`` to raise when no exception occurred.
|
``message`` to raise when no exception occurred.
|
||||||
Thanks :user:`palaviv` for the complete PR (:pull:`1616`).
|
Thanks :user:`palaviv` for the complete PR (:pr:`1616`).
|
||||||
|
|
||||||
* ``conftest.py`` files now benefit from assertion rewriting; previously it
|
* ``conftest.py`` files now benefit from assertion rewriting; previously it
|
||||||
was only available for test modules. Thanks :user:`flub`, :user:`sober7` and
|
was only available for test modules. Thanks :user:`flub`, :user:`sober7` and
|
||||||
:user:`nicoddemus` for the PR (:issue:`1619`).
|
:user:`nicoddemus` for the PR (:issue:`1619`).
|
||||||
|
|
||||||
* Text documents without any doctests no longer appear as "skipped".
|
* Text documents without any doctests no longer appear as "skipped".
|
||||||
Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`).
|
Thanks :user:`graingert` for reporting and providing a full PR (:pr:`1580`).
|
||||||
|
|
||||||
* Ensure that a module within a namespace package can be found when it
|
* Ensure that a module within a namespace package can be found when it
|
||||||
is specified on the command line together with the ``--pyargs``
|
is specified on the command line together with the ``--pyargs``
|
||||||
option. Thanks to :user:`taschini` for the PR (:pull:`1597`).
|
option. Thanks to :user:`taschini` for the PR (:pr:`1597`).
|
||||||
|
|
||||||
* Always include full assertion explanation during assertion rewriting. The previous behaviour was hiding
|
* 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.
|
sub-expressions that happened to be ``False``, assuming this was redundant information.
|
||||||
|
@ -7623,20 +7788,20 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* ``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
|
* ``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
|
||||||
to avoid conflicts with other distutils commands (see :pull:`567`). ``[pytest]`` sections in
|
to avoid conflicts with other distutils commands (see :pr:`567`). ``[pytest]`` sections in
|
||||||
``pytest.ini`` or ``tox.ini`` files are supported and unchanged.
|
``pytest.ini`` or ``tox.ini`` files are supported and unchanged.
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* Using ``pytest_funcarg__`` prefix to declare fixtures is considered deprecated and will be
|
* Using ``pytest_funcarg__`` prefix to declare fixtures is considered deprecated and will be
|
||||||
removed in pytest-4.0 (:pull:`1684`).
|
removed in pytest-4.0 (:pr:`1684`).
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* Passing a command-line string to ``pytest.main()`` is considered deprecated and scheduled
|
* 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 (:pull:`1723`).
|
for removal in pytest-4.0. It is recommended to pass a list of arguments instead (:pr:`1723`).
|
||||||
|
|
||||||
* Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is
|
* Rename ``getfuncargvalue`` to ``getfixturevalue``. ``getfuncargvalue`` is
|
||||||
still present but is now considered deprecated. Thanks to :user:`RedBeardCode` and :user:`tomviner`
|
still present but is now considered deprecated. Thanks to :user:`RedBeardCode` and :user:`tomviner`
|
||||||
for the PR (:pull:`1626`).
|
for the PR (:pr:`1626`).
|
||||||
|
|
||||||
* ``optparse`` type usage now triggers DeprecationWarnings (:issue:`1740`).
|
* ``optparse`` type usage now triggers DeprecationWarnings (:issue:`1740`).
|
||||||
|
|
||||||
|
@ -7694,11 +7859,11 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
:user:`tomviner` for the PR.
|
:user:`tomviner` for the PR.
|
||||||
|
|
||||||
* ``ConftestImportFailure`` now shows the traceback making it easier to
|
* ``ConftestImportFailure`` now shows the traceback making it easier to
|
||||||
identify bugs in ``conftest.py`` files (:pull:`1516`). Thanks :user:`txomon` for
|
identify bugs in ``conftest.py`` files (:pr:`1516`). Thanks :user:`txomon` for
|
||||||
the PR.
|
the PR.
|
||||||
|
|
||||||
* Text documents without any doctests no longer appear as "skipped".
|
* Text documents without any doctests no longer appear as "skipped".
|
||||||
Thanks :user:`graingert` for reporting and providing a full PR (:pull:`1580`).
|
Thanks :user:`graingert` for reporting and providing a full PR (:pr:`1580`).
|
||||||
|
|
||||||
* Fixed collection of classes with custom ``__new__`` method.
|
* Fixed collection of classes with custom ``__new__`` method.
|
||||||
Fixes :issue:`1579`. Thanks to :user:`Stranger6667` for the PR.
|
Fixes :issue:`1579`. Thanks to :user:`Stranger6667` for the PR.
|
||||||
|
@ -7706,7 +7871,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
* Fixed scope overriding inside metafunc.parametrize (:issue:`634`).
|
* Fixed scope overriding inside metafunc.parametrize (:issue:`634`).
|
||||||
Thanks to :user:`Stranger6667` for the PR.
|
Thanks to :user:`Stranger6667` for the PR.
|
||||||
|
|
||||||
* Fixed the total tests tally in junit xml output (:pull:`1798`).
|
* Fixed the total tests tally in junit xml output (:pr:`1798`).
|
||||||
Thanks to :user:`cboelsen` for the PR.
|
Thanks to :user:`cboelsen` for the PR.
|
||||||
|
|
||||||
* Fixed off-by-one error with lines from ``request.node.warn``.
|
* Fixed off-by-one error with lines from ``request.node.warn``.
|
||||||
|
@ -7723,14 +7888,14 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
|
|
||||||
* Fix Xfail does not work with condition keyword argument.
|
* Fix Xfail does not work with condition keyword argument.
|
||||||
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
|
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
|
||||||
for PR the (:pull:`1524`).
|
for PR the (:pr:`1524`).
|
||||||
|
|
||||||
* Fix win32 path issue when putting custom config file with absolute path
|
* Fix win32 path issue when putting custom config file with absolute path
|
||||||
in ``pytest.main("-c your_absolute_path")``.
|
in ``pytest.main("-c your_absolute_path")``.
|
||||||
|
|
||||||
* Fix maximum recursion depth detection when raised error class is not aware
|
* Fix maximum recursion depth detection when raised error class is not aware
|
||||||
of unicode/encoded bytes.
|
of unicode/encoded bytes.
|
||||||
Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
|
Thanks :user:`prusse-martin` for the PR (:pr:`1506`).
|
||||||
|
|
||||||
* Fix ``pytest.mark.skip`` mark when used in strict mode.
|
* Fix ``pytest.mark.skip`` mark when used in strict mode.
|
||||||
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
|
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
|
||||||
|
@ -7757,7 +7922,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
|
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
|
||||||
contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
|
contain ``::``. Thanks :user:`tomviner` for the PR (:pr:`1431`).
|
||||||
|
|
||||||
* Fix (:issue:`578`): SyntaxErrors
|
* Fix (:issue:`578`): SyntaxErrors
|
||||||
containing non-ascii lines at the point of failure generated an internal
|
containing non-ascii lines at the point of failure generated an internal
|
||||||
|
@ -7778,7 +7943,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
**New Features**
|
**New Features**
|
||||||
|
|
||||||
* New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
|
* New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
|
||||||
Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
|
Thanks :user:`MichaelAquilina` for the complete PR (:pr:`1040`).
|
||||||
|
|
||||||
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
* ``--doctest-glob`` may now be passed multiple times in the command-line.
|
||||||
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
|
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
|
||||||
|
@ -7789,14 +7954,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``
|
* ``pytest.mark.xfail`` now has a ``strict`` option, which makes ``XPASS``
|
||||||
tests to fail the test suite (defaulting to ``False``). There's also a
|
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.
|
``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 (:pull:`1355`).
|
Thanks :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (:pr:`1355`).
|
||||||
|
|
||||||
* ``Parser.addini`` now supports options of type ``bool``.
|
* ``Parser.addini`` now supports options of type ``bool``.
|
||||||
Thanks :user:`nicoddemus` for the PR.
|
Thanks :user:`nicoddemus` for the PR.
|
||||||
|
|
||||||
* New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings
|
* New ``ALLOW_BYTES`` doctest option. This strips ``b`` prefixes from byte strings
|
||||||
in doctest output (similar to ``ALLOW_UNICODE``).
|
in doctest output (similar to ``ALLOW_UNICODE``).
|
||||||
Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:pull:`1287`).
|
Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:pr:`1287`).
|
||||||
|
|
||||||
* Give a hint on ``KeyboardInterrupt`` to use the ``--fulltrace`` option to show the errors.
|
* Give a hint on ``KeyboardInterrupt`` to use the ``--fulltrace`` option to show the errors.
|
||||||
Fixes :issue:`1366`.
|
Fixes :issue:`1366`.
|
||||||
|
@ -7828,7 +7993,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,
|
* Removed code and documentation for Python 2.5 or lower versions,
|
||||||
including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
|
including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
|
||||||
Thanks :user:`nicoddemus` for the PR (:pull:`1226`).
|
Thanks :user:`nicoddemus` for the PR (:pr:`1226`).
|
||||||
|
|
||||||
* Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is
|
* Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is
|
||||||
found in the environment, even when ``-vv`` isn't used.
|
found in the environment, even when ``-vv`` isn't used.
|
||||||
|
@ -8195,7 +8360,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.
|
one will also have a "reprec" attribute with the recorded events/reports.
|
||||||
|
|
||||||
- fix monkeypatch.setattr("x.y", raising=False) to actually not raise
|
- fix monkeypatch.setattr("x.y", raising=False) to actually not raise
|
||||||
if "y" is not a pre-existing attribute. Thanks Florian Bruhin.
|
if "y" is not a preexisting attribute. Thanks Florian Bruhin.
|
||||||
|
|
||||||
- fix issue741: make running output from testdir.run copy/pasteable
|
- fix issue741: make running output from testdir.run copy/pasteable
|
||||||
Thanks Bruno Oliveira.
|
Thanks Bruno Oliveira.
|
||||||
|
@ -8251,7 +8416,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
|
- fix issue854: autouse yield_fixtures defined as class members of
|
||||||
unittest.TestCase subclasses now work as expected.
|
unittest.TestCase subclasses now work as expected.
|
||||||
Thannks xmo-odoo for the report and Bruno Oliveira for the PR.
|
Thanks 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
|
- fix issue833: --fixtures now shows all fixtures of collected test files, instead of just the
|
||||||
fixtures declared on the first one.
|
fixtures declared on the first one.
|
||||||
|
@ -8355,7 +8520,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
github. See https://pytest.org/en/stable/contributing.html .
|
github. See https://pytest.org/en/stable/contributing.html .
|
||||||
Thanks to Anatoly for pushing and initial work on this.
|
Thanks to Anatoly for pushing and initial work on this.
|
||||||
|
|
||||||
- fix issue650: new option ``--docttest-ignore-import-errors`` which
|
- fix issue650: new option ``--doctest-ignore-import-errors`` which
|
||||||
will turn import errors in doctests into skips. Thanks Charles Cloud
|
will turn import errors in doctests into skips. Thanks Charles Cloud
|
||||||
for the complete PR.
|
for the complete PR.
|
||||||
|
|
||||||
|
@ -8543,7 +8708,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
|
- cleanup setup.py a bit and specify supported versions. Thanks Jurko
|
||||||
Gospodnetic for the PR.
|
Gospodnetic for the PR.
|
||||||
|
|
||||||
- change XPASS colour to yellow rather then red when tests are run
|
- change XPASS colour to yellow rather than red when tests are run
|
||||||
with -v.
|
with -v.
|
||||||
|
|
||||||
- fix issue473: work around mock putting an unbound method into a class
|
- fix issue473: work around mock putting an unbound method into a class
|
||||||
|
@ -8716,7 +8881,7 @@ time or change existing behaviors in order to make them less surprising/more use
|
||||||
Thanks Ralph Schmitt for the precise failure example.
|
Thanks Ralph Schmitt for the precise failure example.
|
||||||
|
|
||||||
- fix issue244 by implementing special index for parameters to only use
|
- fix issue244 by implementing special index for parameters to only use
|
||||||
indices for paramentrized test ids
|
indices for parametrized test ids
|
||||||
|
|
||||||
- fix issue287 by running all finalizers but saving the exception
|
- fix issue287 by running all finalizers but saving the exception
|
||||||
from the first failing finalizer and re-raising it so teardown will
|
from the first failing finalizer and re-raising it so teardown will
|
||||||
|
@ -8724,7 +8889,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.
|
it might be the cause for other finalizers to fail.
|
||||||
|
|
||||||
- fix ordering when mock.patch or other standard decorator-wrappings
|
- fix ordering when mock.patch or other standard decorator-wrappings
|
||||||
are used with test methods. This fixues issue346 and should
|
are used with test methods. This fixes issue346 and should
|
||||||
help with random "xdist" collection failures. Thanks to
|
help with random "xdist" collection failures. Thanks to
|
||||||
Ronny Pfannschmidt and Donald Stufft for helping to isolate it.
|
Ronny Pfannschmidt and Donald Stufft for helping to isolate it.
|
||||||
|
|
||||||
|
@ -8981,7 +9146,7 @@ Bug fixes:
|
||||||
partially failed (finalizers would not always be called before)
|
partially failed (finalizers would not always be called before)
|
||||||
|
|
||||||
- fix issue320 - fix class scope for fixtures when mixed with
|
- fix issue320 - fix class scope for fixtures when mixed with
|
||||||
module-level functions. Thanks Anatloy Bubenkoff.
|
module-level functions. Thanks Anatoly Bubenkoff.
|
||||||
|
|
||||||
- you can specify "-q" or "-qq" to get different levels of "quieter"
|
- you can specify "-q" or "-qq" to get different levels of "quieter"
|
||||||
reporting (thanks Katarzyna Jachim)
|
reporting (thanks Katarzyna Jachim)
|
||||||
|
@ -9403,7 +9568,7 @@ Bug fixes:
|
||||||
unexpected exceptions
|
unexpected exceptions
|
||||||
- fix issue47: timing output in junitxml for test cases is now correct
|
- fix issue47: timing output in junitxml for test cases is now correct
|
||||||
- fix issue48: typo in MarkInfo repr leading to exception
|
- fix issue48: typo in MarkInfo repr leading to exception
|
||||||
- fix issue49: avoid confusing error when initizaliation partially fails
|
- fix issue49: avoid confusing error when initialization partially fails
|
||||||
- fix issue44: env/username expansion for junitxml file path
|
- fix issue44: env/username expansion for junitxml file path
|
||||||
- show releaselevel information in test runs for pypy
|
- show releaselevel information in test runs for pypy
|
||||||
- reworked doc pages for better navigation and PDF generation
|
- reworked doc pages for better navigation and PDF generation
|
||||||
|
@ -9528,7 +9693,7 @@ Bug fixes:
|
||||||
collection-before-running semantics were not
|
collection-before-running semantics were not
|
||||||
setup as with pytest 1.3.4. Note, however, that
|
setup as with pytest 1.3.4. Note, however, that
|
||||||
the recommended and much cleaner way to do test
|
the recommended and much cleaner way to do test
|
||||||
parametraization remains the "pytest_generate_tests"
|
parameterization remains the "pytest_generate_tests"
|
||||||
mechanism, see the docs.
|
mechanism, see the docs.
|
||||||
|
|
||||||
2.0.0 (2010-11-25)
|
2.0.0 (2010-11-25)
|
||||||
|
|
106
doc/en/conf.py
106
doc/en/conf.py
|
@ -15,19 +15,33 @@
|
||||||
#
|
#
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from pathlib import Path
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from _pytest import __version__ as version
|
from _pytest import __version__ as full_version
|
||||||
|
|
||||||
|
|
||||||
|
version = full_version.split("+")[0]
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
import sphinx.application
|
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])
|
release = ".".join(version.split(".")[:2])
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
|
@ -65,16 +79,16 @@ latex_elements = {
|
||||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
# Add any Sphinx extension module names here, as strings. They can be extensions
|
||||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||||
extensions = [
|
extensions = [
|
||||||
"pallets_sphinx_themes",
|
|
||||||
"pygments_pytest",
|
"pygments_pytest",
|
||||||
"sphinx.ext.autodoc",
|
"sphinx.ext.autodoc",
|
||||||
"sphinx.ext.autosummary",
|
"sphinx.ext.autosummary",
|
||||||
"sphinx.ext.extlinks",
|
|
||||||
"sphinx.ext.intersphinx",
|
"sphinx.ext.intersphinx",
|
||||||
"sphinx.ext.todo",
|
"sphinx.ext.todo",
|
||||||
"sphinx.ext.viewcode",
|
"sphinx.ext.viewcode",
|
||||||
"sphinx_removed_in",
|
"sphinx_removed_in",
|
||||||
"sphinxcontrib_trio",
|
"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
|
# Building PDF docs on readthedocs requires inkscape for svg to pdf
|
||||||
|
@ -140,10 +154,6 @@ add_module_names = False
|
||||||
# output. They are ignored by default.
|
# output. They are ignored by default.
|
||||||
# show_authors = False
|
# 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.
|
# A list of ignored prefixes for module index sorting.
|
||||||
# modindex_common_prefix = []
|
# modindex_common_prefix = []
|
||||||
|
|
||||||
|
@ -160,16 +170,6 @@ linkcheck_ignore = [
|
||||||
linkcheck_workers = 5
|
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
|
nitpicky = True
|
||||||
nitpick_ignore = [
|
nitpick_ignore = [
|
||||||
# TODO (fix in pluggy?)
|
# TODO (fix in pluggy?)
|
||||||
|
@ -183,6 +183,7 @@ nitpick_ignore = [
|
||||||
("py:class", "SubRequest"),
|
("py:class", "SubRequest"),
|
||||||
("py:class", "TerminalReporter"),
|
("py:class", "TerminalReporter"),
|
||||||
("py:class", "_pytest._code.code.TerminalRepr"),
|
("py:class", "_pytest._code.code.TerminalRepr"),
|
||||||
|
("py:class", "TerminalRepr"),
|
||||||
("py:class", "_pytest.fixtures.FixtureFunctionMarker"),
|
("py:class", "_pytest.fixtures.FixtureFunctionMarker"),
|
||||||
("py:class", "_pytest.logging.LogCaptureHandler"),
|
("py:class", "_pytest.logging.LogCaptureHandler"),
|
||||||
("py:class", "_pytest.mark.structures.ParameterSet"),
|
("py:class", "_pytest.mark.structures.ParameterSet"),
|
||||||
|
@ -204,24 +205,24 @@ nitpick_ignore = [
|
||||||
("py:class", "_PluggyPlugin"),
|
("py:class", "_PluggyPlugin"),
|
||||||
# TypeVars
|
# TypeVars
|
||||||
("py:class", "_pytest._code.code.E"),
|
("py:class", "_pytest._code.code.E"),
|
||||||
|
("py:class", "E"), # due to delayed annotation
|
||||||
("py:class", "_pytest.fixtures.FixtureFunction"),
|
("py:class", "_pytest.fixtures.FixtureFunction"),
|
||||||
("py:class", "_pytest.nodes._NodeType"),
|
("py:class", "_pytest.nodes._NodeType"),
|
||||||
|
("py:class", "_NodeType"), # due to delayed annotation
|
||||||
("py:class", "_pytest.python_api.E"),
|
("py:class", "_pytest.python_api.E"),
|
||||||
("py:class", "_pytest.recwarn.T"),
|
("py:class", "_pytest.recwarn.T"),
|
||||||
("py:class", "_pytest.runner.TResult"),
|
("py:class", "_pytest.runner.TResult"),
|
||||||
("py:obj", "_pytest.fixtures.FixtureValue"),
|
("py:obj", "_pytest.fixtures.FixtureValue"),
|
||||||
("py:obj", "_pytest.stash.T"),
|
("py:obj", "_pytest.stash.T"),
|
||||||
|
("py:class", "_ScopeName"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ---------------------------------------------------
|
# -- 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
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
html_theme = "flask"
|
html_theme = "furo"
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# 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
|
# further. For a list of options available for each theme, see the
|
||||||
|
@ -266,18 +267,24 @@ html_favicon = "img/favicon.png"
|
||||||
|
|
||||||
html_sidebars = {
|
html_sidebars = {
|
||||||
"index": [
|
"index": [
|
||||||
"slim_searchbox.html",
|
"sidebar/brand.html",
|
||||||
|
"sidebar/search.html",
|
||||||
|
"sidebar/scroll-start.html",
|
||||||
"sidebarintro.html",
|
"sidebarintro.html",
|
||||||
"globaltoc.html",
|
"globaltoc.html",
|
||||||
"links.html",
|
"links.html",
|
||||||
"sourcelink.html",
|
"sidebar/scroll-end.html",
|
||||||
|
"style.html",
|
||||||
],
|
],
|
||||||
"**": [
|
"**": [
|
||||||
"slim_searchbox.html",
|
"sidebar/brand.html",
|
||||||
|
"sidebar/search.html",
|
||||||
|
"sidebar/scroll-start.html",
|
||||||
"globaltoc.html",
|
"globaltoc.html",
|
||||||
"relations.html",
|
"relations.html",
|
||||||
"links.html",
|
"links.html",
|
||||||
"sourcelink.html",
|
"sidebar/scroll-end.html",
|
||||||
|
"style.html",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +323,9 @@ html_show_sourcelink = False
|
||||||
# Output file base name for HTML help builder.
|
# Output file base name for HTML help builder.
|
||||||
htmlhelp_basename = "pytestdoc"
|
htmlhelp_basename = "pytestdoc"
|
||||||
|
|
||||||
|
# The base URL which points to the root of the HTML documentation. It is used
|
||||||
|
# to indicate the location of document using the canonical link relation (#12363).
|
||||||
|
html_baseurl = "https://docs.pytest.org/en/stable/"
|
||||||
|
|
||||||
# -- Options for LaTeX output --------------------------------------------------
|
# -- Options for LaTeX output --------------------------------------------------
|
||||||
|
|
||||||
|
@ -337,10 +347,6 @@ 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,
|
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||||
# not chapters.
|
# not chapters.
|
||||||
# latex_use_parts = False
|
# latex_use_parts = False
|
||||||
|
@ -427,6 +433,18 @@ 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 = {
|
intersphinx_mapping = {
|
||||||
"pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
|
"pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
|
||||||
|
@ -440,31 +458,7 @@ intersphinx_mapping = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def configure_logging(app: "sphinx.application.Sphinx") -> None:
|
def setup(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(
|
app.add_crossref_type(
|
||||||
"fixture",
|
"fixture",
|
||||||
"fixture",
|
"fixture",
|
||||||
|
@ -493,8 +487,6 @@ def setup(app: "sphinx.application.Sphinx") -> None:
|
||||||
indextemplate="pair: %s; hook",
|
indextemplate="pair: %s; hook",
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_logging(app)
|
|
||||||
|
|
||||||
# legacypath.py monkey-patches pytest.Testdir in. Import the file so
|
# legacypath.py monkey-patches pytest.Testdir in. Import the file so
|
||||||
# that autodoc can discover references to it.
|
# that autodoc can discover references to it.
|
||||||
import _pytest.legacypath # noqa: F401
|
import _pytest.legacypath # noqa: F401
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
collect_ignore = ["conf.py"]
|
collect_ignore = ["conf.py"]
|
||||||
|
|
|
@ -22,23 +22,16 @@ Contact channels
|
||||||
requests to GitHub.
|
requests to GitHub.
|
||||||
|
|
||||||
- ``#pytest`` `on irc.libera.chat <ircs://irc.libera.chat:6697/#pytest>`_ IRC
|
- ``#pytest`` `on irc.libera.chat <ircs://irc.libera.chat:6697/#pytest>`_ IRC
|
||||||
channel for random questions (using an IRC client, `via webchat
|
channel for random questions (using an IRC client, or `via webchat
|
||||||
<https://web.libera.chat/#pytest>`_, or `via Matrix
|
<https://web.libera.chat/#pytest>`)
|
||||||
<https://matrix.to/#/%23pytest:libera.chat>`_).
|
- ``#pytest`` `on Matrix https://matrix.to/#/#pytest:matrix.org>`.
|
||||||
|
|
||||||
- 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
|
.. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues
|
||||||
.. _`old issue tracker`: https://bitbucket.org/hpk42/py-trunk/issues/
|
.. _`old issue tracker`: https://bitbucket.org/hpk42/py-trunk/issues/
|
||||||
|
|
||||||
.. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions
|
.. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions
|
||||||
|
|
||||||
.. _`merlinux.eu`: https://merlinux.eu/
|
|
||||||
|
|
||||||
.. _`get an account`:
|
.. _`get an account`:
|
||||||
|
|
||||||
.. _tetamap: https://tetamap.wordpress.com/
|
.. _tetamap: https://tetamap.wordpress.com/
|
||||||
|
|
|
@ -7,10 +7,6 @@ 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
|
The objective is to give users a clear rationale why a certain feature has been removed, and what alternatives
|
||||||
should be used instead.
|
should be used instead.
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:depth: 3
|
|
||||||
:local:
|
|
||||||
|
|
||||||
|
|
||||||
Deprecated Features
|
Deprecated Features
|
||||||
-------------------
|
-------------------
|
||||||
|
@ -462,7 +458,7 @@ Now :class:`~pytest.Class` collects the test methods directly.
|
||||||
Most plugins which reference ``Instance`` do so in order to ignore or skip it,
|
Most plugins which reference ``Instance`` do so in order to ignore or skip it,
|
||||||
using a check such as ``if isinstance(node, Instance): return``.
|
using a check such as ``if isinstance(node, Instance): return``.
|
||||||
Such plugins should simply remove consideration of ``Instance`` on pytest>=7.
|
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``,
|
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.
|
and importing it emits a deprecation warning. This was removed in pytest 8.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest import raises
|
from pytest import raises
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
hello = "world"
|
hello = "world"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def setup_module(module):
|
def setup_module(module):
|
||||||
module.TestStateFullThing.classcount = 0
|
module.TestStateFullThing.classcount = 0
|
||||||
|
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
collect_ignore = ["nonpython", "customdirectory"]
|
collect_ignore = ["nonpython", "customdirectory"]
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# content of conftest.py
|
# content of conftest.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -21,7 +23,7 @@ class ManifestDirectory(pytest.Directory):
|
||||||
|
|
||||||
@pytest.hookimpl
|
@pytest.hookimpl
|
||||||
def pytest_collect_directory(path, parent):
|
def pytest_collect_directory(path, parent):
|
||||||
# Use our custom collector for directories containing a `mainfest.json` file.
|
# Use our custom collector for directories containing a `manifest.json` file.
|
||||||
if path.joinpath("manifest.json").is_file():
|
if path.joinpath("manifest.json").is_file():
|
||||||
return ManifestDirectory.from_parent(parent=parent, path=path)
|
return ManifestDirectory.from_parent(parent=parent, path=path)
|
||||||
# Otherwise fallback to the standard behavior.
|
# Otherwise fallback to the standard behavior.
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
# content of test_first.py
|
# content of test_first.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def test_1():
|
def test_1():
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
# content of test_second.py
|
# content of test_second.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def test_2():
|
def test_2():
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
# content of test_third.py
|
# content of test_third.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def test_3():
|
def test_3():
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
"""Module containing a parametrized tests testing cross-python serialization
|
"""Module containing a parametrized tests testing cross-python serialization
|
||||||
via the pickle module."""
|
via the pickle module."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
# content of conftest.py
|
# content of conftest.py
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ objects, they are still using the default pytest representation:
|
||||||
rootdir: /home/sweet/project
|
rootdir: /home/sweet/project
|
||||||
collected 8 items
|
collected 8 items
|
||||||
|
|
||||||
<Dir parametrize.rst-197>
|
<Dir parametrize.rst-200>
|
||||||
<Module test_time.py>
|
<Module test_time.py>
|
||||||
<Function test_timedistance_v0[a0-b0-expected0]>
|
<Function test_timedistance_v0[a0-b0-expected0]>
|
||||||
<Function test_timedistance_v0[a1-b1-expected1]>
|
<Function test_timedistance_v0[a1-b1-expected1]>
|
||||||
|
@ -239,7 +239,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia
|
||||||
rootdir: /home/sweet/project
|
rootdir: /home/sweet/project
|
||||||
collected 4 items
|
collected 4 items
|
||||||
|
|
||||||
<Dir parametrize.rst-197>
|
<Dir parametrize.rst-200>
|
||||||
<Module test_scenarios.py>
|
<Module test_scenarios.py>
|
||||||
<Class TestSampleWithScenarios>
|
<Class TestSampleWithScenarios>
|
||||||
<Function test_demo1[basic]>
|
<Function test_demo1[basic]>
|
||||||
|
@ -318,7 +318,7 @@ Let's first see how it looks like at collection time:
|
||||||
rootdir: /home/sweet/project
|
rootdir: /home/sweet/project
|
||||||
collected 2 items
|
collected 2 items
|
||||||
|
|
||||||
<Dir parametrize.rst-197>
|
<Dir parametrize.rst-200>
|
||||||
<Module test_backends.py>
|
<Module test_backends.py>
|
||||||
<Function test_db_initialized[d1]>
|
<Function test_db_initialized[d1]>
|
||||||
<Function test_db_initialized[d2]>
|
<Function test_db_initialized[d2]>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# run this with $ pytest --collect-only test_collectonly.py
|
# run this with $ pytest --collect-only test_collectonly.py
|
||||||
#
|
#
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
|
||||||
def test_function():
|
def test_function():
|
||||||
|
|
|
@ -152,7 +152,7 @@ The test collection would look like this:
|
||||||
configfile: pytest.ini
|
configfile: pytest.ini
|
||||||
collected 2 items
|
collected 2 items
|
||||||
|
|
||||||
<Dir pythoncollection.rst-198>
|
<Dir pythoncollection.rst-201>
|
||||||
<Module check_myapp.py>
|
<Module check_myapp.py>
|
||||||
<Class CheckMyApp>
|
<Class CheckMyApp>
|
||||||
<Function simple_check>
|
<Function simple_check>
|
||||||
|
@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this:
|
||||||
configfile: pytest.ini
|
configfile: pytest.ini
|
||||||
collected 3 items
|
collected 3 items
|
||||||
|
|
||||||
<Dir pythoncollection.rst-198>
|
<Dir pythoncollection.rst-201>
|
||||||
<Dir CWD>
|
<Dir CWD>
|
||||||
<Module pythoncollection.py>
|
<Module pythoncollection.py>
|
||||||
<Function test_function>
|
<Function test_function>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ System state
|
||||||
|
|
||||||
Broadly speaking, a flaky test indicates that the test relies on some system state that is not being appropriately controlled - the test environment is not sufficiently isolated. Higher level tests are more likely to be flaky as they rely on more state.
|
Broadly speaking, a flaky test indicates that the test relies on some system state that is not being appropriately controlled - the test environment is not sufficiently isolated. Higher level tests are more likely to be flaky as they rely on more state.
|
||||||
|
|
||||||
Flaky tests sometimes appear when a test suite is run in parallel (such as use of pytest-xdist). This can indicate a test is reliant on test ordering.
|
Flaky tests sometimes appear when a test suite is run in parallel (such as use of `pytest-xdist`_). This can indicate a test is reliant on test ordering.
|
||||||
|
|
||||||
- Perhaps a different test is failing to clean up after itself and leaving behind data which causes the flaky test to fail.
|
- Perhaps a different test is failing to clean up after itself and leaving behind data which causes the flaky test to fail.
|
||||||
- The flaky test is reliant on data from a previous test that doesn't clean up after itself, and in parallel runs that previous test is not always present
|
- The flaky test is reliant on data from a previous test that doesn't clean up after itself, and in parallel runs that previous test is not always present
|
||||||
|
@ -30,9 +30,22 @@ Overly strict assertion
|
||||||
|
|
||||||
Overly strict assertions can cause problems with floating point comparison as well as timing issues. :func:`pytest.approx` is useful here.
|
Overly strict assertions can cause problems with floating point comparison as well as timing issues. :func:`pytest.approx` is useful here.
|
||||||
|
|
||||||
|
Thread safety
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
Pytest features
|
pytest is single-threaded, executing its tests always in the same thread, sequentially, never spawning any threads itself.
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
Even in case of plugins which run tests in parallel, for example `pytest-xdist`_, usually work by spawning multiple *processes* and running tests in batches, without using multiple threads.
|
||||||
|
|
||||||
|
It is of course possible (and common) for tests and fixtures to spawn threads themselves as part of their testing workflow (for example, a fixture that starts a server thread in the background, or a test which executes production code that spawns threads), but some care must be taken:
|
||||||
|
|
||||||
|
* Make sure to eventually wait on any spawned threads -- for example at the end of a test, or during the teardown of a fixture.
|
||||||
|
* Avoid using primitives provided by pytest (:func:`pytest.warns`, :func:`pytest.raises`, etc) from multiple threads, as they are not thread-safe.
|
||||||
|
|
||||||
|
If your test suite uses threads and your are seeing flaky test results, do not discount the possibility that the test is implicitly using global state in pytest itself.
|
||||||
|
|
||||||
|
Related features
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Xfail strict
|
Xfail strict
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
|
@ -123,3 +136,6 @@ Resources
|
||||||
|
|
||||||
* `Flaky Tests at Google and How We Mitigate Them <https://testing.googleblog.com/2016/05/flaky-tests-at-google-and-how-we.html>`_ by John Micco, 2016
|
* `Flaky Tests at Google and How We Mitigate Them <https://testing.googleblog.com/2016/05/flaky-tests-at-google-and-how-we.html>`_ by John Micco, 2016
|
||||||
* `Where do Google's flaky tests come from? <https://testing.googleblog.com/2017/04/where-do-our-flaky-tests-come-from.html>`_ by Jeff Listfield, 2017
|
* `Where do Google's flaky tests come from? <https://testing.googleblog.com/2017/04/where-do-our-flaky-tests-come-from.html>`_ by Jeff Listfield, 2017
|
||||||
|
|
||||||
|
|
||||||
|
.. _pytest-xdist: https://github.com/pytest-dev/pytest-xdist
|
||||||
|
|
|
@ -8,15 +8,15 @@ pytest import mechanisms and ``sys.path``/``PYTHONPATH``
|
||||||
Import modes
|
Import modes
|
||||||
------------
|
------------
|
||||||
|
|
||||||
pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution.
|
pytest as a testing framework that needs to import test modules and ``conftest.py`` files for execution.
|
||||||
|
|
||||||
Importing files in Python is a non-trivial processes, so aspects of the
|
Importing files in Python is a non-trivial process, so aspects of the
|
||||||
import process can be controlled through the ``--import-mode`` command-line flag, which can assume
|
import process can be controlled through the ``--import-mode`` command-line flag, which can assume
|
||||||
these values:
|
these values:
|
||||||
|
|
||||||
.. _`import-mode-prepend`:
|
.. _`import-mode-prepend`:
|
||||||
|
|
||||||
* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
|
* ``prepend`` (default): The directory path containing each module will be inserted into the *beginning*
|
||||||
of :py:data:`sys.path` if not already there, and then imported with
|
of :py:data:`sys.path` if not already there, and then imported with
|
||||||
the :func:`importlib.import_module <importlib.import_module>` function.
|
the :func:`importlib.import_module <importlib.import_module>` function.
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ these values:
|
||||||
* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
|
* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
|
||||||
there, and imported with :func:`importlib.import_module <importlib.import_module>`.
|
there, and imported with :func:`importlib.import_module <importlib.import_module>`.
|
||||||
|
|
||||||
This better allows to run test modules against installed versions of a package even if the
|
This better allows users to run test modules against installed versions of a package even if the
|
||||||
package under test has the same import root. For example:
|
package under test has the same import root. For example:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
@ -45,7 +45,7 @@ these values:
|
||||||
|
|
||||||
the tests will run against the installed version
|
the tests will run against the installed version
|
||||||
of ``pkg_under_test`` when ``--import-mode=append`` is used whereas
|
of ``pkg_under_test`` when ``--import-mode=append`` is used whereas
|
||||||
with ``prepend`` they would pick up the local version. This kind of confusion is why
|
with ``prepend``, they would pick up the local version. This kind of confusion is why
|
||||||
we advocate for using :ref:`src-layouts <src-layout>`.
|
we advocate for using :ref:`src-layouts <src-layout>`.
|
||||||
|
|
||||||
Same as ``prepend``, requires test module names to be unique when the test directory tree is
|
Same as ``prepend``, requires test module names to be unique when the test directory tree is
|
||||||
|
@ -67,7 +67,7 @@ these values:
|
||||||
are not importable. The recommendation in this case it to place testing utility modules together with the application/library
|
are not importable. The recommendation in this case it to place testing utility modules together with the application/library
|
||||||
code, for example ``app.testing.helpers``.
|
code, for example ``app.testing.helpers``.
|
||||||
|
|
||||||
Important: by "test utility modules" we mean functions/classes which are imported by
|
Important: by "test utility modules", we mean functions/classes which are imported by
|
||||||
other tests directly; this does not include fixtures, which should be placed in ``conftest.py`` files, along
|
other tests directly; this does not include fixtures, which should be placed in ``conftest.py`` files, along
|
||||||
with the test modules, and are discovered automatically by pytest.
|
with the test modules, and are discovered automatically by pytest.
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ these values:
|
||||||
1. Given a certain module path, for example ``tests/core/test_models.py``, derives a canonical name
|
1. Given a certain module path, for example ``tests/core/test_models.py``, derives a canonical name
|
||||||
like ``tests.core.test_models`` and tries to import it.
|
like ``tests.core.test_models`` and tries to import it.
|
||||||
|
|
||||||
For non-test modules this will work if they are accessible via :py:data:`sys.path`, so
|
For non-test modules, this will work if they are accessible via :py:data:`sys.path`. So
|
||||||
for example ``.env/lib/site-packages/app/core.py`` will be importable as ``app.core``.
|
for example, ``.env/lib/site-packages/app/core.py`` will be importable as ``app.core``.
|
||||||
This is happens when plugins import non-test modules (for example doctesting).
|
This is happens when plugins import non-test modules (for example doctesting).
|
||||||
|
|
||||||
If this step succeeds, the module is returned.
|
If this step succeeds, the module is returned.
|
||||||
|
|
|
@ -22,7 +22,7 @@ Install ``pytest``
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ pytest --version
|
$ pytest --version
|
||||||
pytest 8.1.2
|
pytest 8.2.2
|
||||||
|
|
||||||
.. _`simpletest`:
|
.. _`simpletest`:
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ Continue reading
|
||||||
Check out additional pytest resources to help you customize tests for your unique workflow:
|
Check out additional pytest resources to help you customize tests for your unique workflow:
|
||||||
|
|
||||||
* ":ref:`usage`" for command line invocation examples
|
* ":ref:`usage`" for command line invocation examples
|
||||||
* ":ref:`existingtestsuite`" for working with pre-existing tests
|
* ":ref:`existingtestsuite`" for working with preexisting tests
|
||||||
* ":ref:`mark`" for information on the ``pytest.mark`` mechanism
|
* ":ref:`mark`" for information on the ``pytest.mark`` mechanism
|
||||||
* ":ref:`fixtures`" for providing a functional baseline to your tests
|
* ":ref:`fixtures`" for providing a functional baseline to your tests
|
||||||
* ":ref:`plugins`" for managing and writing plugins
|
* ":ref:`plugins`" for managing and writing plugins
|
||||||
|
|
|
@ -107,7 +107,7 @@ Here is a non-exhaustive list of issues fixed by the new implementation:
|
||||||
|
|
||||||
* Marker transfer incompatible with inheritance (:issue:`535`).
|
* Marker transfer incompatible with inheritance (:issue:`535`).
|
||||||
|
|
||||||
More details can be found in the :pull:`original PR <3317>`.
|
More details can be found in the :pr:`original PR <3317>`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
|
@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used:
|
||||||
rootdir: /home/sweet/project
|
rootdir: /home/sweet/project
|
||||||
collected 12 items
|
collected 12 items
|
||||||
|
|
||||||
<Dir fixtures.rst-216>
|
<Dir fixtures.rst-219>
|
||||||
<Module test_anothersmtp.py>
|
<Module test_anothersmtp.py>
|
||||||
<Function test_showhelo[smtp.gmail.com]>
|
<Function test_showhelo[smtp.gmail.com]>
|
||||||
<Function test_showhelo[mail.python.org]>
|
<Function test_showhelo[mail.python.org]>
|
||||||
|
|
|
@ -294,9 +294,47 @@ Now if we increase verbosity even more:
|
||||||
|
|
||||||
test_verbosity_example.py:19: AssertionError
|
test_verbosity_example.py:19: AssertionError
|
||||||
========================= short test summary info ==========================
|
========================= short test summary info ==========================
|
||||||
FAILED test_verbosity_example.py::test_words_fail - AssertionError: asser...
|
FAILED test_verbosity_example.py::test_words_fail - AssertionError: assert ['banana', 'apple', 'grapes', 'melon', 'kiwi'] == ['banana', 'apple', 'orange', 'melon', 'kiwi']
|
||||||
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: ass...
|
|
||||||
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: a...
|
At index 2 diff: 'grapes' != 'orange'
|
||||||
|
|
||||||
|
Full diff:
|
||||||
|
[
|
||||||
|
'banana',
|
||||||
|
'apple',
|
||||||
|
- 'orange',
|
||||||
|
? ^ ^^
|
||||||
|
+ 'grapes',
|
||||||
|
? ^ ^ +
|
||||||
|
'melon',
|
||||||
|
'kiwi',
|
||||||
|
]
|
||||||
|
FAILED test_verbosity_example.py::test_numbers_fail - AssertionError: assert {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4} == {'0': 0, '10': 10, '20': 20, '30': 30, '40': 40}
|
||||||
|
|
||||||
|
Common items:
|
||||||
|
{'0': 0}
|
||||||
|
Left contains 4 more items:
|
||||||
|
{'1': 1, '2': 2, '3': 3, '4': 4}
|
||||||
|
Right contains 4 more items:
|
||||||
|
{'10': 10, '20': 20, '30': 30, '40': 40}
|
||||||
|
|
||||||
|
Full diff:
|
||||||
|
{
|
||||||
|
'0': 0,
|
||||||
|
- '10': 10,
|
||||||
|
? - -
|
||||||
|
+ '1': 1,
|
||||||
|
- '20': 20,
|
||||||
|
? - -
|
||||||
|
+ '2': 2,
|
||||||
|
- '30': 30,
|
||||||
|
? - -
|
||||||
|
+ '3': 3,
|
||||||
|
- '40': 40,
|
||||||
|
? - -
|
||||||
|
+ '4': 4,
|
||||||
|
}
|
||||||
|
FAILED test_verbosity_example.py::test_long_text_fail - AssertionError: assert 'hello world' in 'Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet '
|
||||||
======================= 3 failed, 1 passed in 0.12s ========================
|
======================= 3 failed, 1 passed in 0.12s ========================
|
||||||
|
|
||||||
Notice now that:
|
Notice now that:
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
:orphan:
|
:orphan:
|
||||||
|
|
||||||
.. sidebar:: Next Open Trainings and Events
|
|
||||||
|
|
||||||
- `Professional Testing with Python <https://python-academy.com/courses/python_course_testing.html>`_, via `Python Academy <https://www.python-academy.com/>`_ (3 day in-depth training):
|
|
||||||
* **June 11th to 13th 2024**, Remote
|
|
||||||
* **March 4th to 6th 2025**, Leipzig, Germany / Remote
|
|
||||||
- `pytest development sprint <https://github.com/pytest-dev/pytest/discussions/11655>`_, **June 17th -- 22nd 2024**
|
|
||||||
- pytest tips and tricks for a better testsuite, `Europython 2024 <https://ep2024.europython.eu/>`_, **July 8th -- 14th 2024** (3h), Prague
|
|
||||||
|
|
||||||
Also see :doc:`previous talks and blogposts <talks>`.
|
|
||||||
|
|
||||||
.. _features:
|
.. _features:
|
||||||
|
|
||||||
|
.. sidebar:: **Next Open Trainings and Events**
|
||||||
|
|
||||||
|
- `pytest tips and tricks for a better testsuite <https://ep2024.europython.eu/session/pytest-tips-and-tricks-for-a-better-testsuite>`_, at `Europython 2024 <https://ep2024.europython.eu/>`_, **July 9th 2024** (3h), Prague (CZ)
|
||||||
|
- `pytest: Professionelles Testen (nicht nur) für Python <https://pretalx.com/workshoptage-2024/talk/9VUHYB/>`_, at `CH Open Workshoptage <https://workshoptage.ch/>`_, **September 2nd 2024**, HSLU Rotkreuz (CH)
|
||||||
|
- `Professional Testing with Python <https://python-academy.com/courses/python_course_testing.html>`_, via `Python Academy <https://www.python-academy.com/>`_ (3 day in-depth training), **March 4th -- 6th 2025**, Leipzig (DE) / Remote
|
||||||
|
|
||||||
|
Also see :doc:`previous talks and blogposts <talks>`
|
||||||
|
|
||||||
pytest: helps you write better programs
|
pytest: helps you write better programs
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
|
@ -25,7 +23,6 @@ scale to support complex functional testing for applications and libraries.
|
||||||
|
|
||||||
**PyPI package name**: :pypi:`pytest`
|
**PyPI package name**: :pypi:`pytest`
|
||||||
|
|
||||||
|
|
||||||
A quick example
|
A quick example
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ If you used older version of the ``py`` distribution (which
|
||||||
included the py.test command line tool and Python name space)
|
included the py.test command line tool and Python name space)
|
||||||
you accessed helpers and possibly collection classes through
|
you accessed helpers and possibly collection classes through
|
||||||
the ``py.test`` Python namespaces. The new ``pytest``
|
the ``py.test`` Python namespaces. The new ``pytest``
|
||||||
Python module flaty provides the same objects, following
|
Python module flatly provides the same objects, following
|
||||||
these renaming rules::
|
these renaming rules::
|
||||||
|
|
||||||
py.test.XYZ -> pytest.XYZ
|
py.test.XYZ -> pytest.XYZ
|
||||||
|
|
|
@ -39,7 +39,7 @@ Built-in fixtures
|
||||||
Store and retrieve values across pytest runs.
|
Store and retrieve values across pytest runs.
|
||||||
|
|
||||||
:fixture:`doctest_namespace`
|
:fixture:`doctest_namespace`
|
||||||
Provide a dict injected into the docstests namespace.
|
Provide a dict injected into the doctests namespace.
|
||||||
|
|
||||||
:fixture:`monkeypatch`
|
:fixture:`monkeypatch`
|
||||||
Temporarily modify classes, functions, dictionaries,
|
Temporarily modify classes, functions, dictionaries,
|
||||||
|
|
|
@ -7,9 +7,6 @@ API Reference
|
||||||
|
|
||||||
This page contains the full reference to pytest's API.
|
This page contains the full reference to pytest's API.
|
||||||
|
|
||||||
.. contents::
|
|
||||||
:depth: 3
|
|
||||||
:local:
|
|
||||||
|
|
||||||
Constants
|
Constants
|
||||||
---------
|
---------
|
||||||
|
@ -59,11 +56,19 @@ pytest.fail
|
||||||
|
|
||||||
.. autofunction:: pytest.fail(reason, [pytrace=True, msg=None])
|
.. autofunction:: pytest.fail(reason, [pytrace=True, msg=None])
|
||||||
|
|
||||||
|
.. class:: pytest.fail.Exception
|
||||||
|
|
||||||
|
The exception raised by :func:`pytest.fail`.
|
||||||
|
|
||||||
pytest.skip
|
pytest.skip
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
.. autofunction:: pytest.skip(reason, [allow_module_level=False, msg=None])
|
.. autofunction:: pytest.skip(reason, [allow_module_level=False, msg=None])
|
||||||
|
|
||||||
|
.. class:: pytest.skip.Exception
|
||||||
|
|
||||||
|
The exception raised by :func:`pytest.skip`.
|
||||||
|
|
||||||
.. _`pytest.importorskip ref`:
|
.. _`pytest.importorskip ref`:
|
||||||
|
|
||||||
pytest.importorskip
|
pytest.importorskip
|
||||||
|
@ -76,11 +81,19 @@ pytest.xfail
|
||||||
|
|
||||||
.. autofunction:: pytest.xfail
|
.. autofunction:: pytest.xfail
|
||||||
|
|
||||||
|
.. class:: pytest.xfail.Exception
|
||||||
|
|
||||||
|
The exception raised by :func:`pytest.xfail`.
|
||||||
|
|
||||||
pytest.exit
|
pytest.exit
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
.. autofunction:: pytest.exit(reason, [returncode=None, msg=None])
|
.. autofunction:: pytest.exit(reason, [returncode=None, msg=None])
|
||||||
|
|
||||||
|
.. class:: pytest.exit.Exception
|
||||||
|
|
||||||
|
The exception raised by :func:`pytest.exit`.
|
||||||
|
|
||||||
pytest.main
|
pytest.main
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
@ -246,9 +259,10 @@ Marks a test function as *expected to fail*.
|
||||||
to specify ``reason`` (see :ref:`condition string <string conditions>`).
|
to specify ``reason`` (see :ref:`condition string <string conditions>`).
|
||||||
:keyword str reason:
|
:keyword str reason:
|
||||||
Reason why the test function is marked as xfail.
|
Reason why the test function is marked as xfail.
|
||||||
:keyword Type[Exception] raises:
|
:keyword raises:
|
||||||
Exception class (or tuple of classes) expected to be raised by the test function; other exceptions will fail the test.
|
Exception class (or tuple of classes) expected to be raised by the test function; other exceptions will fail the test.
|
||||||
Note that subclasses of the classes passed will also result in a match (similar to how the ``except`` statement works).
|
Note that subclasses of the classes passed will also result in a match (similar to how the ``except`` statement works).
|
||||||
|
:type raises: Type[:py:exc:`Exception`]
|
||||||
|
|
||||||
:keyword bool run:
|
:keyword bool run:
|
||||||
Whether the test function should actually be executed. If ``False``, the function will always xfail and will
|
Whether the test function should actually be executed. If ``False``, the function will always xfail and will
|
||||||
|
@ -1923,7 +1937,7 @@ All the command-line flags can be obtained by running ``pytest --help``::
|
||||||
|
|
||||||
general:
|
general:
|
||||||
-k EXPRESSION Only run tests which match the given substring
|
-k EXPRESSION Only run tests which match the given substring
|
||||||
expression. An expression is a Python evaluatable
|
expression. An expression is a Python evaluable
|
||||||
expression where all names are substring-matched
|
expression where all names are substring-matched
|
||||||
against test names and their parent classes.
|
against test names and their parent classes.
|
||||||
Example: -k 'test_method or test_other' matches all
|
Example: -k 'test_method or test_other' matches all
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue