Merge branch 'main' into clean-garbage-tmpdirs-with-tempfile-temporary-directory

This commit is contained in:
Thomas Grainger 2021-08-04 11:24:44 +01:00 committed by GitHub
commit 49bf3a3834
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
318 changed files with 19723 additions and 10424 deletions

View File

@ -3,3 +3,23 @@ name: 🚀 Feature Request
about: Ideas for new features and improvements about: Ideas for new features and improvements
--- ---
<!--
Thanks for suggesting a feature!
Quick check-list while suggesting features:
-->
#### What's the problem this feature will solve?
<!-- What are you trying to do, that you are unable to achieve with pytest as it currently stands? -->
#### Describe the solution you'd like
<!-- A clear and concise description of what you want to happen. -->
<!-- Provide examples of real-world use cases that this would enable and how it solves the problem described above. -->
#### Alternative Solutions
<!-- Have you tried to workaround the problem using a pytest plugin or other tools? Or a different approach to solving this issue? Please elaborate here. -->
#### Additional context
<!-- Add any other context, links, etc. about the feature here. -->

View File

@ -13,7 +13,7 @@ If this change fixes an issue, please:
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please: Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
- [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details. - [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/main/changelog/README.rst) for details.
Write sentences in the **past or present tense**, examples: Write sentences in the **past or present tense**, examples:

View File

@ -3,20 +3,29 @@ name: main
on: on:
push: push:
branches: branches:
- master - main
- "[0-9]+.[0-9]+.x" - "[0-9]+.[0-9]+.x"
tags: tags:
- "*" - "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
pull_request: pull_request:
branches: branches:
- master - main
- "[0-9]+.[0-9]+.x" - "[0-9]+.[0-9]+.x"
env:
PYTEST_ADDOPTS: "--color=yes"
# Set permissions at the job level.
permissions: {}
jobs: jobs:
build: build:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 30 timeout-minutes: 30
permissions:
contents: read
strategy: strategy:
fail-fast: false fail-fast: false
@ -26,6 +35,8 @@ jobs:
"windows-py37", "windows-py37",
"windows-py37-pluggy", "windows-py37-pluggy",
"windows-py38", "windows-py38",
"windows-py39",
"windows-py310",
"ubuntu-py36", "ubuntu-py36",
"ubuntu-py37", "ubuntu-py37",
@ -33,6 +44,7 @@ jobs:
"ubuntu-py37-freeze", "ubuntu-py37-freeze",
"ubuntu-py38", "ubuntu-py38",
"ubuntu-py39", "ubuntu-py39",
"ubuntu-py310",
"ubuntu-pypy3", "ubuntu-pypy3",
"macos-py37", "macos-py37",
@ -55,12 +67,20 @@ jobs:
- name: "windows-py37-pluggy" - name: "windows-py37-pluggy"
python: "3.7" python: "3.7"
os: windows-latest os: windows-latest
tox_env: "py37-pluggymaster-xdist" tox_env: "py37-pluggymain-xdist"
- name: "windows-py38" - name: "windows-py38"
python: "3.8" python: "3.8"
os: windows-latest os: windows-latest
tox_env: "py38-unittestextras" tox_env: "py38-unittestextras"
use_coverage: true use_coverage: true
- name: "windows-py39"
python: "3.9"
os: windows-latest
tox_env: "py39-xdist"
- name: "windows-py310"
python: "3.10-dev"
os: windows-latest
tox_env: "py310-xdist"
- name: "ubuntu-py36" - name: "ubuntu-py36"
python: "3.6" python: "3.6"
@ -74,7 +94,7 @@ jobs:
- name: "ubuntu-py37-pluggy" - name: "ubuntu-py37-pluggy"
python: "3.7" python: "3.7"
os: ubuntu-latest os: ubuntu-latest
tox_env: "py37-pluggymaster-xdist" tox_env: "py37-pluggymain-xdist"
- name: "ubuntu-py37-freeze" - name: "ubuntu-py37-freeze"
python: "3.7" python: "3.7"
os: ubuntu-latest os: ubuntu-latest
@ -84,11 +104,15 @@ jobs:
os: ubuntu-latest os: ubuntu-latest
tox_env: "py38-xdist" tox_env: "py38-xdist"
- name: "ubuntu-py39" - name: "ubuntu-py39"
python: "3.9-dev" python: "3.9"
os: ubuntu-latest os: ubuntu-latest
tox_env: "py39-xdist" tox_env: "py39-xdist"
- name: "ubuntu-py310"
python: "3.10-dev"
os: ubuntu-latest
tox_env: "py310-xdist"
- name: "ubuntu-pypy3" - name: "ubuntu-pypy3"
python: "pypy3" python: "pypy-3.7"
os: ubuntu-latest os: ubuntu-latest
tox_env: "pypy3-xdist" tox_env: "pypy3-xdist"
@ -121,16 +145,13 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
persist-credentials: false
- name: Set up Python ${{ matrix.python }} - name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2 uses: actions/setup-python@v2
if: matrix.python != '3.9-dev'
with:
python-version: ${{ matrix.python }}
- name: Set up Python ${{ matrix.python }} (deadsnakes)
uses: deadsnakes/action@v2.0.0
if: matrix.python == '3.9-dev'
with: with:
python-version: ${{ matrix.python }} python-version: ${{ matrix.python }}
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
@ -142,35 +163,39 @@ jobs:
- name: Test with coverage - name: Test with coverage
if: "matrix.use_coverage" if: "matrix.use_coverage"
env: run: "tox -e ${{ matrix.tox_env }}-coverage"
_PYTEST_TOX_COVERAGE_RUN: "coverage run -m"
COVERAGE_PROCESS_START: ".coveragerc"
_PYTEST_TOX_EXTRA_DEP: "coverage-enable-subprocess"
run: "tox -e ${{ matrix.tox_env }}"
- name: Prepare coverage token - name: Upload coverage
if: (matrix.use_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' )) if: matrix.use_coverage && github.repository == 'pytest-dev/pytest'
run: |
python scripts/append_codecov_token.py
- name: Report coverage
if: (matrix.use_coverage)
env: env:
CODECOV_NAME: ${{ matrix.name }} CODECOV_NAME: ${{ matrix.name }}
run: bash scripts/report-coverage.sh -F GHA,${{ runner.os }} run: bash scripts/upload-coverage.sh -F GHA,${{ runner.os }}
linting: linting:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- name: set PY - name: set PY
run: echo "::set-env name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- uses: actions/cache@v1
- uses: actions/cache@v2
with: with:
path: ~/.cache/pre-commit path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: pip install tox
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- run: tox -e linting - run: tox -e linting
deploy: deploy:
@ -178,6 +203,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30 timeout-minutes: 30
permissions:
contents: write
needs: [build] needs: [build]
@ -185,25 +212,31 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
fetch-depth: 0 fetch-depth: 0
persist-credentials: false
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: "3.7" python-version: "3.7"
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install --upgrade wheel setuptools tox pip install --upgrade wheel setuptools tox
- name: Build package - name: Build package
run: | run: |
python setup.py sdist bdist_wheel python setup.py sdist bdist_wheel
- name: Publish package to PyPI - name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master uses: pypa/gh-action-pypi-publish@master
with: with:
user: __token__ user: __token__
password: ${{ secrets.pypi_token }} password: ${{ secrets.pypi_token }}
- name: Publish GitHub release notes - name: Publish GitHub release notes
env: env:
GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }} GH_RELEASE_NOTES_TOKEN: ${{ github.token }}
run: | run: |
sudo apt-get install pandoc sudo apt-get install pandoc
tox -e publish-gh-release-notes tox -e publish-gh-release-notes

View File

@ -0,0 +1,52 @@
name: prepare release pr
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to base the release from'
required: true
default: ''
major:
description: 'Major release? (yes/no)'
required: true
default: 'no'
prerelease:
description: 'Prerelease (ex: rc1). Leave empty if not a pre-release.'
required: true
default: ''
# Set permissions at the job level.
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools tox
- name: Prepare release PR (minor/patch release)
if: github.event.inputs.major == 'no'
run: |
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --prerelease '${{ github.event.inputs.prerelease }}'
- name: Prepare release PR (major release)
if: github.event.inputs.major == 'yes'
run: |
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --major --prerelease '${{ github.event.inputs.prerelease }}'

View File

@ -1,31 +0,0 @@
# part of our release process, see `release-on-comment.py`
name: release on comment
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
jobs:
build:
runs-on: ubuntu-latest
if: (github.event.comment && startsWith(github.event.comment.body, '@pytestbot please')) || (github.event.issue && !github.event.comment && startsWith(github.event.issue.body, '@pytestbot please'))
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools tox
- name: Prepare release
run: |
tox -e release-on-comment -- $GITHUB_EVENT_PATH ${{ secrets.chatops }}

View File

@ -0,0 +1,48 @@
name: Update Plugin List
on:
schedule:
# At 00:00 on Sunday.
# https://crontab.guru
- cron: '0 0 * * 0'
workflow_dispatch:
# Set permissions at the job level.
permissions: {}
jobs:
createPullRequest:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install packaging requests tabulate[widechars]
- name: Update Plugin List
run: python scripts/update-plugin-list.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@2455e1596942c2902952003bbb574afbbe2ab2e6
with:
commit-message: '[automated] Update plugin list'
author: 'pytest bot <pytestbot@users.noreply.github.com>'
branch: update-plugin-list/patch
delete-branch: true
branch-suffix: short-commit-hash
title: '[automated] Update plugin list'
body: '[automated] Update plugin list'

4
.gitignore vendored
View File

@ -34,6 +34,7 @@ issue/
env/ env/
.env/ .env/
.venv/ .venv/
/pythonenv*/
3rdparty/ 3rdparty/
.tox .tox
.cache .cache
@ -52,3 +53,6 @@ coverage.xml
# generated by pip # generated by pip
pip-wheel-metadata/ pip-wheel-metadata/
# pytest debug logs generated via --debug
pytestdebug.log

View File

@ -1,16 +1,16 @@
repos: repos:
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 19.10b0 rev: 21.7b0
hooks: hooks:
- id: black - id: black
args: [--safe, --quiet] args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs - repo: https://github.com/asottile/blacken-docs
rev: v1.8.0 rev: v1.10.0
hooks: hooks:
- id: blacken-docs - id: blacken-docs
additional_dependencies: [black==19.10b0] additional_dependencies: [black==20.8b1]
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0 rev: v4.0.1
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
@ -20,8 +20,8 @@ repos:
- id: debug-statements - id: debug-statements
exclude: _pytest/(debugging|hookspec).py exclude: _pytest/(debugging|hookspec).py
language_version: python3 language_version: python3
- repo: https://gitlab.com/pycqa/flake8 - repo: https://github.com/PyCQA/flake8
rev: 3.8.3 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
language_version: python3 language_version: python3
@ -29,33 +29,38 @@ repos:
- flake8-typing-imports==1.9.0 - flake8-typing-imports==1.9.0
- flake8-docstrings==1.5.0 - flake8-docstrings==1.5.0
- repo: https://github.com/asottile/reorder_python_imports - repo: https://github.com/asottile/reorder_python_imports
rev: v2.3.5 rev: v2.6.0
hooks: hooks:
- id: reorder-python-imports - id: reorder-python-imports
args: ['--application-directories=.:src', --py36-plus] args: ['--application-directories=.:src', --py36-plus]
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.7.2 rev: v2.23.1
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [--py36-plus] args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt - repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.11.0 rev: v1.17.0
hooks: hooks:
- id: setup-cfg-fmt - id: setup-cfg-fmt
# TODO: when upgrading setup-cfg-fmt this can be removed args: [--max-py-version=3.10]
args: [--max-py-version=3.9]
- repo: https://github.com/pre-commit/pygrep-hooks - repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.6.0 rev: v1.9.0
hooks: hooks:
- id: python-use-type-annotations - id: python-use-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790 # NOTE: keep this in sync with setup.cfg. rev: v0.910
hooks: hooks:
- id: mypy - id: mypy
files: ^(src/|testing/) files: ^(src/|testing/)
args: [] args: []
additional_dependencies: additional_dependencies:
- iniconfig>=1.1.0 - iniconfig>=1.1.0
- py>=1.8.2
- attrs>=19.2.0
- packaging
- tomli
- types-atomicwrites
- types-pkg_resources
- repo: local - repo: local
hooks: hooks:
- id: rst - id: rst
@ -86,3 +91,9 @@ repos:
xml\. xml\.
) )
types: [python] types: [python]
- id: py-path-deprecated
name: py.path usage is deprecated
exclude: docs|src/_pytest/deprecated.py|testing/deprecated_test.py
language: pygrep
entry: \bpy\.path\.local
types: [python]

31
AUTHORS
View File

@ -5,6 +5,7 @@ Contributors include::
Aaron Coleman Aaron Coleman
Abdeali JK Abdeali JK
Abdelrahman Elbehery
Abhijeet Kasurde Abhijeet Kasurde
Adam Johnson Adam Johnson
Adam Uhlir Adam Uhlir
@ -21,7 +22,9 @@ Anders Hovmöller
Andras Mitzki Andras Mitzki
Andras Tim Andras Tim
Andrea Cimatoribus Andrea Cimatoribus
Andreas Motl
Andreas Zeidler Andreas Zeidler
Andrew Shapton
Andrey Paramonov Andrey Paramonov
Andrzej Klajnert Andrzej Klajnert
Andrzej Ostrowski Andrzej Ostrowski
@ -29,15 +32,19 @@ Andy Freeland
Anthon van der Neut Anthon van der Neut
Anthony Shaw Anthony Shaw
Anthony Sottile Anthony Sottile
Anton Grinevich
Anton Lodder Anton Lodder
Antony Lee Antony Lee
Arel Cordero Arel Cordero
Arias Emmanuel
Ariel Pillemer
Armin Rigo Armin Rigo
Aron Coyle Aron Coyle
Aron Curzon Aron Curzon
Aviral Verma Aviral Verma
Aviv Palivoda Aviv Palivoda
Barney Gale Barney Gale
Ben Gartner
Ben Webb Ben Webb
Benjamin Peterson Benjamin Peterson
Bernard Pratz Bernard Pratz
@ -55,11 +62,14 @@ Charles Cloud
Charles Machalow Charles Machalow
Charnjit SiNGH (CCSJ) Charnjit SiNGH (CCSJ)
Chris Lamb Chris Lamb
Chris NeJame
Chris Rose
Christian Boelsen Christian Boelsen
Christian Fetzer Christian Fetzer
Christian Neumüller Christian Neumüller
Christian Theunert Christian Theunert
Christian Tismer Christian Tismer
Christine Mecklenborg
Christoph Buelter Christoph Buelter
Christopher Dignam Christopher Dignam
Christopher Gilling Christopher Gilling
@ -72,6 +82,7 @@ Daniel Grana
Daniel Hahler Daniel Hahler
Daniel Nuri Daniel Nuri
Daniel Wandschneider Daniel Wandschneider
Daniele Procida
Danielle Jenkins Danielle Jenkins
Daniil Galiev Daniil Galiev
Dave Hunt Dave Hunt
@ -87,14 +98,17 @@ Dhiren Serai
Diego Russo Diego Russo
Dmitry Dygalo Dmitry Dygalo
Dmitry Pribysh Dmitry Pribysh
Dominic Mortlock
Duncan Betts Duncan Betts
Edison Gustavo Muenz Edison Gustavo Muenz
Edoardo Batini Edoardo Batini
Edson Tadeu M. Manoel
Eduardo Schettino Eduardo Schettino
Eli Boyarski Eli Boyarski
Elizaveta Shashkova Elizaveta Shashkova
Endre Galaczi Endre Galaczi
Eric Hunsberger Eric Hunsberger
Eric Liu
Eric Siegerman Eric Siegerman
Erik Aronesty Erik Aronesty
Erik M. Bray Erik M. Bray
@ -107,10 +121,12 @@ Florian Bruhin
Florian Dahlitz Florian Dahlitz
Floris Bruynooghe Floris Bruynooghe
Gabriel Reis Gabriel Reis
Garvit Shubham
Gene Wood Gene Wood
George Kussumoto George Kussumoto
Georgy Dyuldin Georgy Dyuldin
Gleb Nikonorov Gleb Nikonorov
Graeme Smecher
Graham Horler Graham Horler
Greg Price Greg Price
Gregory Lee Gregory Lee
@ -131,6 +147,7 @@ Iwan Briquemont
Jaap Broekhuizen Jaap Broekhuizen
Jakob van Santen Jakob van Santen
Jakub Mitoraj Jakub Mitoraj
James Bourbeau
Jan Balster Jan Balster
Janne Vanhala Janne Vanhala
Jason R. Coombs Jason R. Coombs
@ -151,9 +168,11 @@ Josh Karpel
Joshua Bronson Joshua Bronson
Jurko Gospodnetić Jurko Gospodnetić
Justyna Janczyszyn Justyna Janczyszyn
Justice Ndou
Kale Kundert Kale Kundert
Kamran Ahmad Kamran Ahmad
Karl O. Pinc Karl O. Pinc
Karthikeyan Singaravelan
Katarzyna Jachim Katarzyna Jachim
Katarzyna Król Katarzyna Król
Katerina Koukiou Katerina Koukiou
@ -196,6 +215,7 @@ Matthias Hafner
Maxim Filipenko Maxim Filipenko
Maximilian Cosmo Sitter Maximilian Cosmo Sitter
mbyt mbyt
Mickey Pashov
Michael Aquilina Michael Aquilina
Michael Birtwell Michael Birtwell
Michael Droettboom Michael Droettboom
@ -216,6 +236,7 @@ Nicholas Murphy
Niclas Olofsson Niclas Olofsson
Nicolas Delaby Nicolas Delaby
Nikolay Kondratyev Nikolay Kondratyev
Olga Matoula
Oleg Pidsadnyi Oleg Pidsadnyi
Oleg Sushchenko Oleg Sushchenko
Oliver Bestwalter Oliver Bestwalter
@ -223,15 +244,18 @@ Omar Kohl
Omer Hadari Omer Hadari
Ondřej Súkup Ondřej Súkup
Oscar Benjamin Oscar Benjamin
Parth Patel
Patrick Hayes Patrick Hayes
Pauli Virtanen Pauli Virtanen
Pavel Karateev Pavel Karateev
Paweł Adamczak Paweł Adamczak
Pedro Algarvio Pedro Algarvio
Petter Strandmark
Philipp Loose Philipp Loose
Pieter Mulder Pieter Mulder
Piotr Banaszkiewicz Piotr Banaszkiewicz
Piotr Helm Piotr Helm
Prakhar Gurunani
Prashant Anand Prashant Anand
Prashant Sharma Prashant Sharma
Pulkit Goyal Pulkit Goyal
@ -255,13 +279,17 @@ Ross Lawley
Ruaridh Williamson Ruaridh Williamson
Russel Winder Russel Winder
Ryan Wooden Ryan Wooden
Saiprasad Kale
Samuel Dion-Girardeau Samuel Dion-Girardeau
Samuel Searles-Bryant Samuel Searles-Bryant
Samuele Pedroni Samuele Pedroni
Sanket Duthade
Sankt Petersbug Sankt Petersbug
Segev Finer Segev Finer
Serhii Mozghovyi Serhii Mozghovyi
Seth Junot Seth Junot
Shantanu Jain
Shubham Adep
Simon Gomizelj Simon Gomizelj
Simon Kerr Simon Kerr
Skylar Downes Skylar Downes
@ -276,6 +304,7 @@ Sven-Hendrik Haase
Sylvain Marié Sylvain Marié
Tadek Teleżyński Tadek Teleżyński
Takafumi Arakaki Takafumi Arakaki
Taneli Hukkinen
Tanvi Mehta Tanvi Mehta
Tarcisio Fischer Tarcisio Fischer
Tareq Alayan Tareq Alayan
@ -312,4 +341,6 @@ Xuan Luong
Xuecong Liao Xuecong Liao
Yoav Caspi Yoav Caspi
Zac Hatfield-Dodds Zac Hatfield-Dodds
Zachary Kneupper
Zoltán Máté Zoltán Máté
Zsolt Cserna

View File

@ -4,4 +4,4 @@ Changelog
The pytest CHANGELOG is located `here <https://docs.pytest.org/en/stable/changelog.html>`__. The pytest CHANGELOG is located `here <https://docs.pytest.org/en/stable/changelog.html>`__.
The source document can be found at: https://github.com/pytest-dev/pytest/blob/master/doc/en/changelog.rst The source document can be found at: https://github.com/pytest-dev/pytest/blob/main/doc/en/changelog.rst

View File

@ -160,7 +160,7 @@ the following:
- an issue tracker for bug reports and enhancement requests. - an issue tracker for bug reports and enhancement requests.
- a `changelog <http://keepachangelog.com/>`_. - a `changelog <https://keepachangelog.com/>`_.
If no contributor strongly objects and two agree, the repository can then be If no contributor strongly objects and two agree, the repository can then be
transferred to the ``pytest-dev`` organisation. transferred to the ``pytest-dev`` organisation.
@ -234,9 +234,9 @@ Here is a simple overview, with pytest-specific bits:
$ git clone git@github.com:YOUR_GITHUB_USERNAME/pytest.git $ git clone git@github.com:YOUR_GITHUB_USERNAME/pytest.git
$ cd pytest $ cd pytest
# now, create your own branch off "master": # now, create your own branch off "main":
$ git checkout -b your-bugfix-branch-name master $ git checkout -b your-bugfix-branch-name main
Given we have "major.minor.micro" version numbers, bug fixes will usually Given we have "major.minor.micro" version numbers, bug fixes will usually
be released in micro releases whereas features will be released in be released in micro releases whereas features will be released in
@ -259,7 +259,7 @@ Here is a simple overview, with pytest-specific bits:
Tox is used to run all the tests and will automatically setup virtualenvs Tox is used to run all the tests and will automatically setup virtualenvs
to run the tests in. to run the tests in.
(will implicitly use http://www.virtualenv.org/en/latest/):: (will implicitly use https://virtualenv.pypa.io/en/latest/)::
$ pip install tox $ pip install tox
@ -318,26 +318,26 @@ Here is a simple overview, with pytest-specific bits:
compare: your-branch-name compare: your-branch-name
base-fork: pytest-dev/pytest base-fork: pytest-dev/pytest
base: master base: main
Writing Tests Writing Tests
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Writing tests for plugins or for pytest itself is often done using the `testdir fixture <https://docs.pytest.org/en/stable/reference.html#testdir>`_, as a "black-box" test. Writing tests for plugins or for pytest itself is often done using the `pytester fixture <https://docs.pytest.org/en/stable/reference/reference.html#pytester>`_, as a "black-box" test.
For example, to ensure a simple test passes you can write: For example, to ensure a simple test passes you can write:
.. code-block:: python .. code-block:: python
def test_true_assertion(testdir): def test_true_assertion(pytester):
testdir.makepyfile( pytester.makepyfile(
""" """
def test_foo(): def test_foo():
assert True assert True
""" """
) )
result = testdir.runpytest() result = pytester.runpytest()
result.assert_outcomes(failed=0, passed=1) result.assert_outcomes(failed=0, passed=1)
@ -346,14 +346,14 @@ Alternatively, it is possible to make checks based on the actual output of the t
.. code-block:: python .. code-block:: python
def test_true_assertion(testdir): def test_true_assertion(pytester):
testdir.makepyfile( pytester.makepyfile(
""" """
def test_foo(): def test_foo():
assert False assert False
""" """
) )
result = testdir.runpytest() result = pytester.runpytest()
result.stdout.fnmatch_lines(["*assert False*", "*1 failed*"]) result.stdout.fnmatch_lines(["*assert False*", "*1 failed*"])
When choosing a file where to write a new test, take a look at the existing files and see if there's When choosing a file where to write a new test, take a look at the existing files and see if there's
@ -387,15 +387,15 @@ Suppose for example that the latest release was 1.2.3, and you want to include
a bug fix in 1.2.4 (check https://github.com/pytest-dev/pytest/releases for the a bug fix in 1.2.4 (check https://github.com/pytest-dev/pytest/releases for the
actual latest release). The procedure for this is: actual latest release). The procedure for this is:
#. First, make sure the bug is fixed the ``master`` branch, with a regular pull #. First, make sure the bug is fixed the ``main`` branch, with a regular pull
request, as described above. An exception to this is if the bug fix is not request, as described above. An exception to this is if the bug fix is not
applicable to ``master`` anymore. applicable to ``main`` anymore.
#. ``git checkout origin/1.2.x -b backport-XXXX`` # use the master PR number here #. ``git checkout origin/1.2.x -b backport-XXXX`` # use the main PR number here
#. Locate the merge commit on the PR, in the *merged* message, for example: #. Locate the merge commit on the PR, in the *merged* message, for example:
nicoddemus merged commit 0f8b462 into pytest-dev:master nicoddemus merged commit 0f8b462 into pytest-dev:main
#. ``git cherry-pick -x -m1 REVISION`` # use the revision you found above (``0f8b462``). #. ``git cherry-pick -x -m1 REVISION`` # use the revision you found above (``0f8b462``).
@ -408,8 +408,8 @@ actual latest release). The procedure for this is:
Who does the backporting Who does the backporting
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
As mentioned above, bugs should first be fixed on ``master`` (except in rare occasions As mentioned above, bugs should first be fixed on ``main`` (except in rare occasions
that a bug only happens in a previous release). So who should do the backport procedure described that a bug only happens in a previous release). So, who should do the backport procedure described
above? above?
1. If the bug was fixed by a core developer, it is the main responsibility of that core developer 1. If the bug was fixed by a core developer, it is the main responsibility of that core developer
@ -417,8 +417,8 @@ above?
2. However, often the merge is done by another maintainer, in which case it is nice of them to 2. However, often the merge is done by another maintainer, in which case it is nice of them to
do the backport procedure if they have the time. do the backport procedure if they have the time.
3. For bugs submitted by non-maintainers, it is expected that a core developer will to do 3. For bugs submitted by non-maintainers, it is expected that a core developer will to do
the backport, normally the one that merged the PR on ``master``. the backport, normally the one that merged the PR on ``main``.
4. If a non-maintainers notices a bug which is fixed on ``master`` but has not been backported 4. If a non-maintainers notices a bug which is fixed on ``main`` but has not been backported
(due to maintainers forgetting to apply the *needs backport* label, or just plain missing it), (due to maintainers forgetting to apply the *needs backport* label, or just plain missing it),
they are also welcome to open a PR with the backport. The procedure is simple and really they are also welcome to open a PR with the backport. The procedure is simple and really
helps with the maintenance of the project. helps with the maintenance of the project.
@ -447,7 +447,7 @@ can always reopen the issue/pull request in their own time later if it makes sen
When to close When to close
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Here are a few general rules the maintainers use to decide when to close issues/PRs because Here are a few general rules the maintainers use deciding when to close issues/PRs because
of lack of inactivity: of lack of inactivity:
* Issues labeled ``question`` or ``needs information``: closed after 14 days inactive. * Issues labeled ``question`` or ``needs information``: closed after 14 days inactive.
@ -459,15 +459,15 @@ The above are **not hard rules**, but merely **guidelines**, and can be (and oft
Closing pull requests Closing pull requests
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
When closing a Pull Request, it needs to be acknowledge the time, effort, and interest demonstrated by the person which submitted it. As mentioned previously, it is not the intent of the team to dismiss stalled pull request entirely but to merely to clear up our queue, so a message like the one below is warranted when closing a pull request that went stale: When closing a Pull Request, it needs to be acknowledging the time, effort, and interest demonstrated by the person which submitted it. As mentioned previously, it is not the intent of the team to dismiss a stalled pull request entirely but to merely to clear up our queue, so a message like the one below is warranted when closing a pull request that went stale:
Hi <contributor>, Hi <contributor>,
First of all we would like to thank you for your time and effort on working on this, the pytest team deeply appreciates it. First of all, we would like to thank you for your time and effort on working on this, the pytest team deeply appreciates it.
We noticed it has been awhile since you have updated this PR, however. pytest is a high activity project, with many issues/PRs being opened daily, so it is hard for us maintainers to track which PRs are ready for merging, for review, or need more attention. We noticed it has been awhile since you have updated this PR, however. pytest is a high activity project, with many issues/PRs being opened daily, so it is hard for us maintainers to track which PRs are ready for merging, for review, or need more attention.
So for those reasons we think it is best to close the PR for now, but with the only intention to cleanup our queue, it is by no means a rejection of your changes. We still encourage you to re-open this PR (it is just a click of a button away) when you are ready to get back to it. So for those reasons we, think it is best to close the PR for now, but with the only intention to clean up our queue, it is by no means a rejection of your changes. We still encourage you to re-open this PR (it is just a click of a button away) when you are ready to get back to it.
Again we appreciate your time for working on this, and hope you might get back to this at a later time! Again we appreciate your time for working on this, and hope you might get back to this at a later time!

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2004-2020 Holger Krekel and others Copyright (c) 2004-2021 Holger Krekel and others
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in

View File

@ -1,6 +1,7 @@
.. image:: https://docs.pytest.org/en/stable/_static/pytest1.png .. image:: https://github.com/pytest-dev/pytest/raw/main/doc/en/img/pytest_logo_curves.svg
:target: https://docs.pytest.org/en/stable/ :target: https://docs.pytest.org/en/stable/
:align: center :align: center
:height: 200
:alt: pytest :alt: pytest
@ -15,16 +16,17 @@
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg .. image:: https://img.shields.io/pypi/pyversions/pytest.svg
:target: https://pypi.org/project/pytest/ :target: https://pypi.org/project/pytest/
.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/master/graph/badge.svg .. image:: https://codecov.io/gh/pytest-dev/pytest/branch/main/graph/badge.svg
:target: https://codecov.io/gh/pytest-dev/pytest :target: https://codecov.io/gh/pytest-dev/pytest
:alt: Code coverage Status :alt: Code coverage Status
.. image:: https://travis-ci.org/pytest-dev/pytest.svg?branch=master
:target: https://travis-ci.org/pytest-dev/pytest
.. image:: https://github.com/pytest-dev/pytest/workflows/main/badge.svg .. image:: https://github.com/pytest-dev/pytest/workflows/main/badge.svg
:target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Amain :target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Amain
.. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
:target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
:alt: pre-commit.ci status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black :target: https://github.com/psf/black
@ -80,18 +82,18 @@ Features
- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/assert.html>`_ (no need to remember ``self.assert*`` names) - Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/assert.html>`_ (no need to remember ``self.assert*`` names)
- `Auto-discovery - `Auto-discovery
<https://docs.pytest.org/en/stable/goodpractices.html#python-test-discovery>`_ <https://docs.pytest.org/en/stable/explanation/goodpractices.html#python-test-discovery>`_
of test modules and functions of test modules and functions
- `Modular fixtures <https://docs.pytest.org/en/stable/fixture.html>`_ for - `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
managing small or parametrized long-lived test resources managing small or parametrized long-lived test resources
- Can run `unittest <https://docs.pytest.org/en/stable/unittest.html>`_ (or trial), - Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
`nose <https://docs.pytest.org/en/stable/nose.html>`_ test suites out of the box `nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
- Python 3.6+ and PyPy3 - Python 3.6+ and PyPy3
- Rich plugin architecture, with over 850+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community - Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
Documentation Documentation
@ -149,8 +151,8 @@ Tidelift will coordinate the fix and disclosure.
License License
------- -------
Copyright Holger Krekel and others, 2004-2020. Copyright Holger Krekel and others, 2004-2021.
Distributed under the terms of the `MIT`_ license, pytest is free and open source software. Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE .. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE

View File

@ -14,59 +14,89 @@ Preparing: Automatic Method
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have developed an automated workflow for releases, that uses GitHub workflows and is triggered We have developed an automated workflow for releases, that uses GitHub workflows and is triggered
by opening an issue. by `manually running <https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow>`__
the `prepare-release-pr workflow <https://github.com/pytest-dev/pytest/actions/workflows/prepare-release-pr.yml>`__
on GitHub Actions.
Bug-fix releases The automation will decide the new version number based on the following criteria:
^^^^^^^^^^^^^^^^
A bug-fix release is always done from a maintenance branch, so for example to release bug-fix - If the "major release" input is set to "yes", release a new major release
``5.1.2``, open a new issue and add this comment to the body:: (e.g. 7.0.0 -> 8.0.0)
- If there are any ``.feature.rst`` or ``.breaking.rst`` files in the
``changelog`` directory, release a new minor release (e.g. 7.0.0 -> 7.1.0)
- Otherwise, release a bugfix release (e.g. 7.0.0 -> 7.0.1)
- If the "prerelease" input is set, append the string to the version number
(e.g. 7.0.0 -> 8.0.0rc1), if "major" is set, and "prerelease" is set to `rc1`)
@pytestbot please prepare release from 5.1.x Bug-fix and minor releases
^^^^^^^^^^^^^^^^^^^^^^^^^^
Where ``5.1.x`` is the maintenance branch for the ``5.1`` series. Bug-fix and minor releases are always done from a maintenance branch. First,
consider double-checking the ``changelog`` directory to see if there are any
breaking changes or new features.
The automated workflow will publish a PR for a branch ``release-5.1.2`` For a new minor release, first create a new maintenance branch from ``main``::
and notify it as a comment in the issue.
Minor releases git fetch --all
git branch 7.1.x upstream/main
git push upstream 7.1.x
Then, trigger the workflow with the following inputs:
- branch: **7.1.x**
- major release: **no**
- prerelease: empty
Or via the commandline using `GitHub's cli <https://github.com/cli/cli>`__::
gh workflow run prepare-release-pr.yml -f branch=7.1.x -f major=no -f prerelease=
Where ``7.1.x`` is the maintenance branch for the ``7.1`` series. The automated
workflow will publish a PR for a branch ``release-7.1.0``.
Similarly, for a bug-fix release, use the existing maintenance branch and
trigger the workflow with e.g. ``branch: 7.0.x`` to get a new ``release-7.0.1``
PR.
Major releases
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
1. Create a new maintenance branch from ``master``:: 1. Create a new maintenance branch from ``main``::
git fetch --all git fetch --all
git branch 5.2.x upstream/master git branch 8.0.x upstream/main
git push upstream 5.2.x git push upstream 8.0.x
2. Open a new issue and add this comment to the body:: 2. Trigger the workflow with the following inputs:
@pytestbot please prepare release from 5.2.x - branch: **8.0.x**
- major release: **yes**
- prerelease: empty
The automated workflow will publish a PR for a branch ``release-5.2.0`` and Or via the commandline::
notify it as a comment in the issue.
Major and release candidates gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1. Create a new maintenance branch from ``master``:: The automated workflow will publish a PR for a branch ``release-8.0.0``.
git fetch --all
git branch 6.0.x upstream/master
git push upstream 6.0.x
2. For a **major release**, open a new issue and add this comment in the body::
@pytestbot please prepare major release from 6.0.x
For a **release candidate**, the comment must be (TODO: `#7551 <https://github.com/pytest-dev/pytest/issues/7551>`__)::
@pytestbot please prepare release candidate from 6.0.x
The automated workflow will publish a PR for a branch ``release-6.0.0`` and
notify it as a comment in the issue.
At this point on, this follows the same workflow as other maintenance branches: bug-fixes are merged At this point on, this follows the same workflow as other maintenance branches: bug-fixes are merged
into ``master`` and ported back to the maintenance branch, even for release candidates. into ``main`` and ported back to the maintenance branch, even for release candidates.
Release candidates
^^^^^^^^^^^^^^^^^^
To release a release candidate, set the "prerelease" input to the version number
suffix to use. To release a ``8.0.0rc1``, proceed like under "major releases", but set:
- branch: 8.0.x
- major release: yes
- prerelease: **rc1**
Or via the commandline::
gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=rc1
The automated workflow will publish a PR for a branch ``release-8.0.0rc1``.
**A note about release candidates** **A note about release candidates**
@ -83,7 +113,7 @@ to be executed on that platform.
To release a version ``MAJOR.MINOR.PATCH``, follow these steps: To release a version ``MAJOR.MINOR.PATCH``, follow these steps:
#. For major and minor releases, create a new branch ``MAJOR.MINOR.x`` from #. For major and minor releases, create a new branch ``MAJOR.MINOR.x`` from
``upstream/master`` and push it to ``upstream``. ``upstream/main`` and push it to ``upstream``.
#. Create a branch ``release-MAJOR.MINOR.PATCH`` from the ``MAJOR.MINOR.x`` branch. #. Create a branch ``release-MAJOR.MINOR.PATCH`` from the ``MAJOR.MINOR.x`` branch.
@ -114,14 +144,22 @@ Both automatic and manual processes described above follow the same steps from t
#. Merge the PR. #. Merge the PR.
#. Cherry-pick the CHANGELOG / announce files to the ``master`` branch:: #. Cherry-pick the CHANGELOG / announce files to the ``main`` branch::
git fetch --all --prune git fetch --all --prune
git checkout origin/master -b cherry-pick-release git checkout upstream/main -b cherry-pick-release
git cherry-pick -x -m1 upstream/MAJOR.MINOR.x git cherry-pick -x -m1 upstream/MAJOR.MINOR.x
#. Open a PR for ``cherry-pick-release`` and merge it once CI passes. No need to wait for approvals if there were no conflicts on the previous step. #. Open a PR for ``cherry-pick-release`` and merge it once CI passes. No need to wait for approvals if there were no conflicts on the previous step.
#. For major and minor releases, tag the release cherry-pick merge commit in main with
a dev tag for the next feature release::
git checkout main
git pull
git tag MAJOR.{MINOR+1}.0.dev0
git push git@github.com:pytest-dev/pytest.git MAJOR.{MINOR+1}.0.dev0
#. Send an email announcement with the contents from:: #. Send an email announcement with the contents from::
doc/en/announce/release-<VERSION>.rst doc/en/announce/release-<VERSION>.rst

View File

@ -25,6 +25,7 @@ The current list of contributors receiving funding are:
* `@asottile`_ * `@asottile`_
* `@nicoddemus`_ * `@nicoddemus`_
* `@The-Compiler`_
Contributors interested in receiving a part of the funds just need to submit a PR adding their Contributors interested in receiving a part of the funds just need to submit a PR adding their
name to the list. Contributors that want to stop receiving the funds should also submit a PR name to the list. Contributors that want to stop receiving the funds should also submit a PR
@ -56,3 +57,4 @@ funds. Just drop a line to one of the `@pytest-dev/tidelift-admins`_ or use the
.. _`@asottile`: https://github.com/asottile .. _`@asottile`: https://github.com/asottile
.. _`@nicoddemus`: https://github.com/nicoddemus .. _`@nicoddemus`: https://github.com/nicoddemus
.. _`@The-Compiler`: https://github.com/The-Compiler

13
bench/unit_test.py Normal file
View File

@ -0,0 +1,13 @@
from unittest import TestCase # noqa: F401
for i in range(15000):
exec(
f"""
class Test{i}(TestCase):
@classmethod
def setUpClass(cls): pass
def test_1(self): pass
def test_2(self): pass
def test_3(self): pass
"""
)

View File

@ -1 +0,0 @@
Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures.

1
changelog/5105.doc.rst Normal file
View File

@ -0,0 +1 @@
Add automatically generated :ref:`plugin-list`. The list is updated on a periodic schedule.

View File

@ -0,0 +1 @@
Fixed an issue where ``__main__.py`` would raise an ``ImportError`` when ``--doctest-modules`` was provided.

View File

@ -0,0 +1,7 @@
Added :meth:`cache.mkdir() <pytest.Cache.mkdir>`, which is similar to the existing :meth:`cache.makedir() <pytest.Cache.makedir>`,
but returns a :class:`pathlib.Path` instead of a legacy ``py.path.local``.
Added a ``paths`` type to :meth:`parser.addini() <pytest.Parser.addini>`,
as in ``parser.addini("mypaths", "my paths", type="paths")``,
which is similar to the existing ``pathlist``,
but returns a list of :class:`pathlib.Path` instead of legacy ``py.path.local``.

View File

@ -1,5 +0,0 @@
New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``.
This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
Internally, the old :class:`Testdir` is now a thin wrapper around :class:`Pytester`, preserving the old interface.

View File

@ -0,0 +1,12 @@
Directly constructing the following classes is now deprecated:
- ``_pytest.mark.structures.Mark``
- ``_pytest.mark.structures.MarkDecorator``
- ``_pytest.mark.structures.MarkGenerator``
- ``_pytest.python.Metafunc``
- ``_pytest.runner.CallInfo``
- ``_pytest._code.ExceptionInfo``
- ``_pytest.config.argparsing.Parser``
- ``_pytest.config.argparsing.OptionGroup``
These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.0.0.

View File

@ -0,0 +1,19 @@
The types of objects used in pytest's API are now exported so they may be used in type annotations.
The newly-exported types are:
- ``pytest.Config`` for :class:`Config <pytest.Config>`.
- ``pytest.Mark`` for :class:`marks <pytest.Mark>`.
- ``pytest.MarkDecorator`` for :class:`mark decorators <pytest.MarkDecorator>`.
- ``pytest.MarkGenerator`` for the :class:`pytest.mark <pytest.MarkGenerator>` singleton.
- ``pytest.Metafunc`` for the :class:`metafunc <pytest.MarkGenerator>` argument to the :func:`pytest_generate_tests <pytest.hookspec.pytest_generate_tests>` hook.
- ``pytest.CallInfo`` for the :class:`CallInfo <pytest.CallInfo>` type passed to various hooks.
- ``pytest.PytestPluginManager`` for :class:`PytestPluginManager <pytest.PytestPluginManager>`.
- ``pytest.ExceptionInfo`` for the :class:`ExceptionInfo <pytest.ExceptionInfo>` type returned from :func:`pytest.raises` and passed to various hooks.
- ``pytest.Parser`` for the :class:`Parser <pytest.Parser>` type passed to the :func:`pytest_addoption <pytest.hookspec.pytest_addoption>` hook.
- ``pytest.OptionGroup`` for the :class:`OptionGroup <pytest.OptionGroup>` type returned from the :func:`parser.addgroup <pytest.Parser.getgroup>` method.
Constructing them directly is not supported; they are only meant for use in type annotations.
Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.

View File

@ -1,3 +0,0 @@
Use strict equality comparison for nonnumeric types in ``approx`` instead of
raising ``TypeError``.
This was the undocumented behavior before 3.7, but is now officially a supported feature.

View File

@ -1 +0,0 @@
Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.

View File

@ -1 +0,0 @@
Classes which should not be inherited from are now marked ``final class`` in the API reference.

View File

@ -1 +0,0 @@
The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.

View File

@ -1 +0,0 @@
pytest now supports python3.6+ only.

View File

@ -1 +0,0 @@
Improve deprecation warning message for ``pytest._fillfuncargs()``.

View File

@ -0,0 +1,2 @@
:ref:`--import-mode=importlib <import-modes>` now works with features that
depend on modules being on :py:data:`sys.modules`, such as :mod:`pickle` and :mod:`dataclasses`.

View File

@ -1 +0,0 @@
``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``.

View File

@ -1 +0,0 @@
In pull request section, ask to commit after editing changelog and authors file.

View File

@ -1 +0,0 @@
Fixed a crash or hang in ``pytester.spawn`` when the ``readline`` module is involved.

View File

@ -0,0 +1 @@
Fixed failing staticmethod test cases if they are inherited from a parent test class.

View File

@ -0,0 +1,7 @@
The following hooks now receive an additional ``pathlib.Path`` argument, equivalent to an existing ``py.path.local`` argument:
- :func:`pytest_ignore_collect <_pytest.hookspec.pytest_ignore_collect>` - The ``fspath`` parameter (equivalent to existing ``path`` parameter).
- :func:`pytest_collect_file <_pytest.hookspec.pytest_collect_file>` - The ``fspath`` parameter (equivalent to existing ``path`` parameter).
- :func:`pytest_pycollect_makemodule <_pytest.hookspec.pytest_pycollect_makemodule>` - The ``fspath`` parameter (equivalent to existing ``path`` parameter).
- :func:`pytest_report_header <_pytest.hookspec.pytest_report_header>` - The ``startpath`` parameter (equivalent to existing ``startdir`` parameter).
- :func:`pytest_report_collectionfinish <_pytest.hookspec.pytest_report_collectionfinish>` - The ``startpath`` parameter (equivalent to existing ``startdir`` parameter).

View File

@ -0,0 +1,6 @@
The following changes have been made to internal pytest types/functions:
- The ``path`` property of ``_pytest.code.Code`` returns ``Path`` instead of ``py.path.local``.
- The ``path`` property of ``_pytest.code.TracebackEntry`` returns ``Path`` instead of ``py.path.local``.
- The ``_pytest.code.getfslineno()`` function returns ``Path`` instead of ``py.path.local``.
- The ``_pytest.python.path_matches_patterns()`` function takes ``Path`` instead of ``py.path.local``.

View File

@ -0,0 +1,3 @@
``testdir.makefile`` now silently accepts values which don't start with ``.`` to maintain backward compatibility with older pytest versions.
``pytester.makefile`` now issues a clearer error if the ``.`` is missing in the ``ext`` argument.

View File

@ -0,0 +1,7 @@
Raising :class:`unittest.SkipTest` to skip collection of tests during the
pytest collection phase is deprecated. Use :func:`pytest.skip` instead.
Note: This deprecation only relates to using :class:`unittest.SkipTest` during test
collection. You are probably not doing that. Ordinary usage of
:class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` /
:func:`unittest.skip` in unittest test cases is fully supported.

View File

@ -0,0 +1 @@
``--version`` now writes version information to ``stdout`` rather than ``stderr``.

View File

@ -0,0 +1 @@
Internal Restructure: let ``python.PyObjMixin`` inherit from ``nodes.Node`` to carry over typing information.

View File

@ -0,0 +1 @@
Deprecate ``Node.fspath`` as we plan to move off `py.path.local <https://py.readthedocs.io/en/latest/path.html>`__ and switch to :mod:``pathlib``.

View File

@ -0,0 +1 @@
Implement ``Node.path`` as a ``pathlib.Path``.

View File

@ -0,0 +1,3 @@
Fixed issue where pytest's ``faulthandler`` support would not dump traceback on crashes
if the :mod:`faulthandler` module was already enabled during pytest startup (using
``python -X dev -m pytest`` for example).

View File

@ -0,0 +1,5 @@
Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
scheduled for removal in pytest 8 (deprecated since pytest 2.4.0):
- ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.

View File

@ -0,0 +1 @@
Fixed an issue where illegal directory characters derived from ``getpass.getuser()`` raised an ``OSError``.

View File

@ -0,0 +1,10 @@
Improved :func:`pytest.approx` assertion messages for sequences of numbers.
The assertion messages now dumps a table with the index and the error of each diff.
Example::
> assert [1, 2, 3, 4] == pytest.approx([1, 3, 3, 5])
E assert comparison failed for 2 values:
E Index | Obtained | Expected
E 1 | 2 | 3 +- 3.0e-06
E 3 | 4 | 5 +- 5.0e-06

1
changelog/8337.doc.rst Normal file
View File

@ -0,0 +1 @@
Recommend `numpy.testing <https://numpy.org/doc/stable/reference/routines.testing.html>`__ module on :func:`pytest.approx` documentation.

View File

@ -0,0 +1 @@
Fix ``Class.from_parent`` so it forwards extra keyword arguments to the constructor.

View File

@ -0,0 +1 @@
The ``@pytest.mark.skip`` decorator now correctly handles its arguments. When the ``reason`` argument is accidentally given both positional and as a keyword (e.g. because it was confused with ``skipif``), a ``TypeError`` now occurs. Before, such tests were silently skipped, and the positional argument ignored. Additionally, ``reason`` is now documented correctly as positional or keyword (rather than keyword-only).

View File

@ -0,0 +1 @@
Use private names for internal fixtures that handle classic setup/teardown so that they don't show up with the default ``--fixtures`` invocation (but they still show up with ``--fixtures -v``).

View File

@ -0,0 +1,5 @@
By default, pytest will truncate long strings in assert errors so they don't clutter the output too much,
currently at ``240`` characters by default.
However, in some cases the longer output helps, or is even crucial, to diagnose a failure. Using ``-v`` will
now increase the truncation threshold to ``2400`` characters, and ``-vv`` or higher will disable truncation entirely.

View File

@ -0,0 +1 @@
:func:`pytest.approx` now works on :class:`~decimal.Decimal` within mappings/dicts and sequences/lists.

View File

@ -0,0 +1 @@
Improve error message when :func:`pytest.skip` is used at module level without passing `allow_module_level=True`.

View File

@ -0,0 +1,4 @@
Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` now issues a warning.
It was never sanely supported and triggers hard to debug errors.
Instead, a separate collector node should be used, which collects the item. See :ref:`non-python tests` for an example.

View File

@ -0,0 +1 @@
The :confval:`required_plugins` config option now works correctly when pre-releases of plugins are installed, rather than falsely claiming that those plugins aren't installed at all.

View File

@ -0,0 +1 @@
``-c <config file>`` now also properly defines ``rootdir`` as the directory that contains ``<config file>``.

View File

@ -0,0 +1 @@
Python 3.10 is now supported.

View File

@ -0,0 +1,4 @@
:meth:`pytest.MonkeyPatch.syspath_prepend` no longer fails when
``setuptools`` is not installed.
It now only calls :func:`pkg_resources.fixup_namespace_packages` if
``pkg_resources`` was previously imported, because it is not needed otherwise.

View File

@ -0,0 +1,5 @@
Fixed issue where :meth:`unittest.TestCase.setUpClass` is not called when a test has `/` in its name since pytest 6.2.0.
This refers to the path part in pytest node IDs, e.g. ``TestClass::test_it`` in the node ID ``tests/test_file.py::TestClass::test_it``.
Now, instead of assuming that the test name does not contain ``/``, it is assumed that test path does not contain ``::``. We plan to hopefully make both of these work in the future.

View File

@ -0,0 +1 @@
Introduce fix to handle precision width in ``log-cli-format`` in turn to fix output coloring for certain formats.

View File

@ -0,0 +1 @@
:func:`pytest_cmdline_preparse <_pytest.hookspec.pytest_cmdline_preparse>` has been officially deprecated. It will be removed in a future release. Use :func:`pytest_load_initial_conftests <_pytest.hookspec.pytest_load_initial_conftests>` instead.

View File

@ -0,0 +1,5 @@
pytest invocations with ``--fixtures-per-test`` and ``--fixtures`` have been enriched with:
- Fixture location path printed with the fixture name.
- First section of the fixture's docstring printed under the fixture name.
- Whole of fixture's docstring printed under the fixture name using ``--verbose`` option.

View File

@ -0,0 +1,4 @@
:func:`pytest.warns(None) <pytest.warns>` is now deprecated because many people used
it to mean "this code does not emit warnings", but it actually had the effect of
checking that the code emits at least one warning of any type - like ``pytest.warns()``
or ``pytest.warns(Warning)``.

1
changelog/8655.doc.rst Normal file
View File

@ -0,0 +1 @@
Help text for ``--pdbcls`` more accurately reflects the option's behavior.

View File

@ -0,0 +1 @@
New :ref:`version-tuple` attribute, which makes it simpler for users to do something depending on the pytest version (such as declaring hooks which are introduced in later versions).

View File

@ -0,0 +1 @@
Switch TOML parser from ``toml`` to ``tomli`` for TOML v1.0.0 support in ``pyproject.toml``.

0
changelog/8897.doc.rst Normal file
View File

View File

@ -0,0 +1 @@
Complex numbers are now treated like floats and integers when generating parameterization IDs.

View File

@ -0,0 +1 @@
The private ``CallSpec2._arg2scopenum`` attribute has been removed after an internal refactoring.

View File

@ -0,0 +1,2 @@
Added :class:`pytest.Stash`, a facility for plugins to store their data on :class:`~pytest.Config` and :class:`~_pytest.nodes.Node`\s in a type-safe and conflict-free manner.
See :ref:`plugin-stash` for details.

View File

@ -0,0 +1,2 @@
:class:`RunResult <_pytest.pytester.RunResult>` method :meth:`assert_outcomes <_pytest.pytester.RunResult.assert_outcomes>` now accepts a
``warnings`` argument to assert the total number of warnings captured.

View File

@ -0,0 +1 @@
``--debug`` flag now accepts a :class:`str` file to route debug logs into, remains defaulted to `pytestdebug.log`.

View File

@ -0,0 +1,2 @@
:func:`pytest_assertion_pass <_pytest.hookspec.pytest_assertion_pass>` is no longer considered experimental and
future changes to it will be considered more carefully.

View File

@ -1,12 +1,19 @@
<h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3> <h3>Contents</h3>
<ul> <ul>
<li><a href="{{ pathto('index') }}">Home</a></li> <li><a href="{{ pathto('index') }}">Home</a></li>
<li><a href="{{ pathto('getting-started') }}">Install</a></li>
<li><a href="{{ pathto('contents') }}">Contents</a></li> <li><a href="{{ pathto('getting-started') }}">Get started</a></li>
<li><a href="{{ pathto('reference') }}">API Reference</a></li> <li><a href="{{ pathto('how-to/index') }}">How-to guides</a></li>
<li><a href="{{ pathto('example/index') }}">Examples</a></li> <li><a href="{{ pathto('reference/index') }}">Reference guides</a></li>
<li><a href="{{ pathto('customize') }}">Customize</a></li> <li><a href="{{ pathto('explanation/index') }}">Explanation</a></li>
<li><a href="{{ pathto('contents') }}">Complete table of contents</a></li>
<li><a href="{{ pathto('example/index') }}">Library of examples</a></li>
</ul>
<h3>About the project</h3>
<ul>
<li><a href="{{ pathto('changelog') }}">Changelog</a></li> <li><a href="{{ pathto('changelog') }}">Changelog</a></li>
<li><a href="{{ pathto('contributing') }}">Contributing</a></li> <li><a href="{{ pathto('contributing') }}">Contributing</a></li>
<li><a href="{{ pathto('backwards-compatibility') }}">Backwards Compatibility</a></li> <li><a href="{{ pathto('backwards-compatibility') }}">Backwards Compatibility</a></li>

View File

@ -2,7 +2,6 @@
<ul> <ul>
<li><a href="https://pypi.org/project/pytest/">pytest @ PyPI</a></li> <li><a href="https://pypi.org/project/pytest/">pytest @ PyPI</a></li>
<li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li> <li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li>
<li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li>
<li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li> <li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li>
<li><a href="https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf">PDF Documentation</a> <li><a href="https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf">PDF Documentation</a>
</ul> </ul>

View File

@ -6,6 +6,12 @@ Release announcements
:maxdepth: 2 :maxdepth: 2
release-6.2.4
release-6.2.3
release-6.2.2
release-6.2.1
release-6.2.0
release-6.1.2
release-6.1.1 release-6.1.1
release-6.1.0 release-6.1.0
release-6.0.2 release-6.0.2

View File

@ -36,12 +36,12 @@ New Features
import pytest ; pytest.main(arglist, pluginlist) import pytest ; pytest.main(arglist, pluginlist)
see http://pytest.org/en/stable/usage.html for details. see http://pytest.org/en/stable/how-to/usage.html for details.
- new and better reporting information in assert expressions - new and better reporting information in assert expressions
if comparing lists, sequences or strings. if comparing lists, sequences or strings.
see http://pytest.org/en/stable/assert.html#newreport see http://pytest.org/en/stable/how-to/assert.html#newreport
- new configuration through ini-files (setup.cfg or tox.ini recognized), - new configuration through ini-files (setup.cfg or tox.ini recognized),
for example:: for example::
@ -50,7 +50,7 @@ New Features
norecursedirs = .hg data* # don't ever recurse in such dirs norecursedirs = .hg data* # don't ever recurse in such dirs
addopts = -x --pyargs # add these command line options by default addopts = -x --pyargs # add these command line options by default
see http://pytest.org/en/stable/customize.html see http://pytest.org/en/stable/reference/customize.html
- improved standard unittest support. In general py.test should now - improved standard unittest support. In general py.test should now
better be able to run custom unittest.TestCases like twisted trial better be able to run custom unittest.TestCases like twisted trial

View File

@ -57,7 +57,7 @@ Changes between 2.0.0 and 2.0.1
- refinements to "collecting" output on non-ttys - refinements to "collecting" output on non-ttys
- refine internal plugin registration and --traceconfig output - refine internal plugin registration and --traceconfig output
- introduce a mechanism to prevent/unregister plugins from the - introduce a mechanism to prevent/unregister plugins from the
command line, see http://pytest.org/en/stable/plugins.html#cmdunregister command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister
- activate resultlog plugin by default - activate resultlog plugin by default
- fix regression wrt yielded tests which due to the - fix regression wrt yielded tests which due to the
collection-before-running semantics were not collection-before-running semantics were not

View File

@ -12,7 +12,7 @@ courtesy of Benjamin Peterson. You can now safely use ``assert``
statements in test modules without having to worry about side effects statements in test modules without having to worry about side effects
or python optimization ("-OO") options. This is achieved by rewriting or python optimization ("-OO") options. This is achieved by rewriting
assert statements in test modules upon import, using a PEP302 hook. assert statements in test modules upon import, using a PEP302 hook.
See https://docs.pytest.org/en/stable/assert.html for See https://docs.pytest.org/en/stable/how-to/assert.html for
detailed information. The work has been partly sponsored by my company, detailed information. The work has been partly sponsored by my company,
merlinux GmbH. merlinux GmbH.
@ -24,7 +24,7 @@ If you want to install or upgrade pytest, just type one of::
easy_install -U pytest easy_install -U pytest
best, best,
holger krekel / http://merlinux.eu holger krekel / https://merlinux.eu/
Changes between 2.0.3 and 2.1.0 Changes between 2.0.3 and 2.1.0
---------------------------------------------- ----------------------------------------------

View File

@ -20,7 +20,7 @@ If you want to install or upgrade pytest, just type one of::
easy_install -U pytest easy_install -U pytest
best, best,
holger krekel / http://merlinux.eu holger krekel / https://merlinux.eu/
Changes between 2.1.0 and 2.1.1 Changes between 2.1.0 and 2.1.1
---------------------------------------------- ----------------------------------------------

View File

@ -19,7 +19,7 @@ If you want to install or upgrade pytest, just type one of::
easy_install -U pytest easy_install -U pytest
best, best,
holger krekel / http://merlinux.eu holger krekel / https://merlinux.eu/
Changes between 2.1.1 and 2.1.2 Changes between 2.1.1 and 2.1.2
---------------------------------------- ----------------------------------------

View File

@ -9,7 +9,7 @@ with these improvements:
- new @pytest.mark.parametrize decorator to run tests with different arguments - new @pytest.mark.parametrize decorator to run tests with different arguments
- new metafunc.parametrize() API for parametrizing arguments independently - new metafunc.parametrize() API for parametrizing arguments independently
- see examples at http://pytest.org/en/stable/example/parametrize.html - see examples at http://pytest.org/en/stable/example/how-to/parametrize.html
- NOTE that parametrize() related APIs are still a bit experimental - NOTE that parametrize() related APIs are still a bit experimental
and might change in future releases. and might change in future releases.
@ -78,7 +78,7 @@ Changes between 2.1.3 and 2.2.0
or through plugin hooks. Also introduce a "--strict" option which or through plugin hooks. Also introduce a "--strict" option which
will treat unregistered markers as errors will treat unregistered markers as errors
allowing to avoid typos and maintain a well described set of markers allowing to avoid typos and maintain a well described set of markers
for your test suite. See examples at http://pytest.org/en/stable/mark.html for your test suite. See examples at http://pytest.org/en/stable/how-to/mark.html
and its links. and its links.
- issue50: introduce "-m marker" option to select tests based on markers - issue50: introduce "-m marker" option to select tests based on markers
(this is a stricter and more predictable version of "-k" in that "-m" (this is a stricter and more predictable version of "-k" in that "-m"

View File

@ -13,12 +13,12 @@ re-usable fixture design.
For detailed info and tutorial-style examples, see: For detailed info and tutorial-style examples, see:
http://pytest.org/en/stable/fixture.html http://pytest.org/en/stable/explanation/fixtures.html
Moreover, there is now support for using pytest fixtures/funcargs with Moreover, there is now support for using pytest fixtures/funcargs with
unittest-style suites, see here for examples: unittest-style suites, see here for examples:
http://pytest.org/en/stable/unittest.html http://pytest.org/en/stable/how-to/unittest.html
Besides, more unittest-test suites are now expected to "simply work" Besides, more unittest-test suites are now expected to "simply work"
with pytest. with pytest.

View File

@ -16,7 +16,7 @@ comes with the following fixes and features:
- yielded test functions will now have autouse-fixtures active but - yielded test functions will now have autouse-fixtures active but
cannot accept fixtures as funcargs - it's anyway recommended to cannot accept fixtures as funcargs - it's anyway recommended to
rather use the post-2.0 parametrize features instead of yield, see: rather use the post-2.0 parametrize features instead of yield, see:
http://pytest.org/en/stable/example/parametrize.html http://pytest.org/en/stable/example/how-to/parametrize.html
- fix autouse-issue where autouse-fixtures would not be discovered - fix autouse-issue where autouse-fixtures would not be discovered
if defined in an a/conftest.py file and tests in a/tests/test_some.py if defined in an a/conftest.py file and tests in a/tests/test_some.py
- fix issue226 - LIFO ordering for fixture teardowns - fix issue226 - LIFO ordering for fixture teardowns

View File

@ -131,7 +131,7 @@ The py.test Development Team
with same name. with same name.
.. _`traceback style docs`: https://pytest.org/en/stable/usage.html#modifying-python-traceback-printing .. _`traceback style docs`: https://pytest.org/en/stable/how-to/output.html#modifying-python-traceback-printing
.. _#1422: https://github.com/pytest-dev/pytest/issues/1422 .. _#1422: https://github.com/pytest-dev/pytest/issues/1422
.. _#1379: https://github.com/pytest-dev/pytest/issues/1379 .. _#1379: https://github.com/pytest-dev/pytest/issues/1379

View File

@ -0,0 +1,22 @@
pytest-6.1.2
=======================================
pytest 6.1.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
Thanks to all of the contributors to this release:
* Bruno Oliveira
* Manuel Mariñez
* Ran Benita
* Vasilis Gerakaris
* William Jamir Silva
Happy testing,
The pytest Development Team

View File

@ -0,0 +1,76 @@
pytest-6.2.0
=======================================
The pytest team is proud to announce the 6.2.0 release!
This release contains new features, improvements, bug fixes, and breaking changes, so users
are encouraged to take a look at the CHANGELOG carefully:
https://docs.pytest.org/en/stable/changelog.html
For complete documentation, please visit:
https://docs.pytest.org/en/stable/
As usual, you can upgrade from PyPI via:
pip install -U pytest
Thanks to all of the contributors to this release:
* Adam Johnson
* Albert Villanova del Moral
* Anthony Sottile
* Anton
* Ariel Pillemer
* Bruno Oliveira
* Charles Aracil
* Christine M
* Christine Mecklenborg
* Cserna Zsolt
* Dominic Mortlock
* Emiel van de Laar
* Florian Bruhin
* Garvit Shubham
* Gustavo Camargo
* Hugo Martins
* Hugo van Kemenade
* Jakob van Santen
* Josias Aurel
* Jürgen Gmach
* Karthikeyan Singaravelan
* Katarzyna
* Kyle Altendorf
* Manuel Mariñez
* Matthew Hughes
* Matthias Gabriel
* Max Voitko
* Maximilian Cosmo Sitter
* Mikhail Fesenko
* Nimesh Vashistha
* Pedro Algarvio
* Petter Strandmark
* Prakhar Gurunani
* Prashant Sharma
* Ran Benita
* Ronny Pfannschmidt
* Sanket Duthade
* Shubham Adep
* Simon K
* Tanvi Mehta
* Thomas Grainger
* Tim Hoffmann
* Vasilis Gerakaris
* William Jamir Silva
* Zac Hatfield-Dodds
* crricks
* dependabot[bot]
* duthades
* frankgerhardt
* kwgchi
* mickeypash
* symonk
Happy testing,
The pytest Development Team

View File

@ -0,0 +1,20 @@
pytest-6.2.1
=======================================
pytest 6.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
* Jakob van Santen
* Ran Benita
Happy testing,
The pytest Development Team

View File

@ -0,0 +1,21 @@
pytest-6.2.2
=======================================
pytest 6.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:
* Adam Johnson
* Bruno Oliveira
* Chris NeJame
* Ran Benita
Happy testing,
The pytest Development Team

View File

@ -0,0 +1,19 @@
pytest-6.2.3
=======================================
pytest 6.2.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
Thanks to all of the contributors to this release:
* Bruno Oliveira
* Ran Benita
Happy testing,
The pytest Development Team

View File

@ -0,0 +1,22 @@
pytest-6.2.4
=======================================
pytest 6.2.4 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/stable/changelog.html.
Thanks to all of the contributors to this release:
* Anthony Sottile
* Bruno Oliveira
* Christian Maurer
* Florian Bruhin
* Ran Benita
Happy testing,
The pytest Development Team

View File

@ -6,7 +6,7 @@ Pytest API and builtin fixtures
================================================ ================================================
Most of the information of this page has been moved over to :ref:`reference`. Most of the information of this page has been moved over to :ref:`api-reference`.
For information on plugin hooks and objects, see :ref:`plugins`. For information on plugin hooks and objects, see :ref:`plugins`.
@ -61,7 +61,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
namespace of doctests. namespace of doctests.
pytestconfig [session scope] pytestconfig [session scope]
Session-scoped fixture that returns the :class:`_pytest.config.Config` object. Session-scoped fixture that returns the :class:`pytest.Config` object.
Example:: Example::
@ -132,7 +132,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
monkeypatch.delattr(obj, name, raising=True) monkeypatch.delattr(obj, name, raising=True)
monkeypatch.setitem(mapping, name, value) monkeypatch.setitem(mapping, name, value)
monkeypatch.delitem(obj, name, raising=True) monkeypatch.delitem(obj, name, raising=True)
monkeypatch.setenv(name, value, prepend=False) monkeypatch.setenv(name, value, prepend=None)
monkeypatch.delenv(name, raising=True) monkeypatch.delenv(name, raising=True)
monkeypatch.syspath_prepend(path) monkeypatch.syspath_prepend(path)
monkeypatch.chdir(path) monkeypatch.chdir(path)
@ -144,20 +144,25 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
recwarn recwarn
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 http://docs.python.org/library/warnings.html for information See https://docs.python.org/library/how-to/capture-warnings.html for information
on warning categories. on warning categories.
tmpdir_factory [session scope] tmpdir_factory [session scope]
Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session. Return a :class:`pytest.TempdirFactory` instance for the test session.
tmp_path_factory [session scope] tmp_path_factory [session scope]
Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session. Return a :class:`pytest.TempPathFactory` instance for the test session.
tmpdir tmpdir
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.
By default, a new base temporary directory is created each test session,
and old bases are removed after 3 sessions, to aid in debugging. If
``--basetemp`` is used then it is cleared each session. See :ref:`base
temporary directory`.
The returned object is a `py.path.local`_ path object. The returned object is a `py.path.local`_ path object.
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html .. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
@ -167,6 +172,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
function invocation, created as a sub directory of the base temporary function invocation, created as a sub directory of the base temporary
directory. directory.
By default, a new base temporary directory is created each test session,
and old bases are removed after 3 sessions, to aid in debugging. If
``--basetemp`` is used then it is cleared each session. See :ref:`base
temporary directory`.
The returned object is a :class:`pathlib.Path` object. The returned object is a :class:`pathlib.Path` object.

View File

@ -28,6 +28,283 @@ with advance notice in the **Deprecations** section of releases.
.. towncrier release notes start .. towncrier release notes start
pytest 6.2.4 (2021-05-04)
=========================
Bug Fixes
---------
- `#8539 <https://github.com/pytest-dev/pytest/issues/8539>`_: Fixed assertion rewriting on Python 3.10.
pytest 6.2.3 (2021-04-03)
=========================
Bug Fixes
---------
- `#8414 <https://github.com/pytest-dev/pytest/issues/8414>`_: pytest used to create directories under ``/tmp`` with world-readable
permissions. This means that any user in the system was able to read
information written by tests in temporary directories (such as those created by
the ``tmp_path``/``tmpdir`` fixture). Now the directories are created with
private permissions.
pytest used to silenty use a pre-existing ``/tmp/pytest-of-<username>`` directory,
even if owned by another user. This means another user could pre-create such a
directory and gain control of another user's temporary directory. Now such a
condition results in an error.
pytest 6.2.2 (2021-01-25)
=========================
Bug Fixes
---------
- `#8152 <https://github.com/pytest-dev/pytest/issues/8152>`_: Fixed "(<Skipped instance>)" being shown as a skip reason in the verbose test summary line when the reason is empty.
- `#8249 <https://github.com/pytest-dev/pytest/issues/8249>`_: Fix the ``faulthandler`` plugin for occasions when running with ``twisted.logger`` and using ``pytest --capture=no``.
pytest 6.2.1 (2020-12-15)
=========================
Bug Fixes
---------
- `#7678 <https://github.com/pytest-dev/pytest/issues/7678>`_: Fixed bug where ``ImportPathMismatchError`` would be raised for files compiled in
the host and loaded later from an UNC mounted path (Windows).
- `#8132 <https://github.com/pytest-dev/pytest/issues/8132>`_: Fixed regression in ``approx``: in 6.2.0 ``approx`` no longer raises
``TypeError`` when dealing with non-numeric types, falling back to normal comparison.
Before 6.2.0, array types like tf.DeviceArray fell through to the scalar case,
and happened to compare correctly to a scalar if they had only one element.
After 6.2.0, these types began failing, because they inherited neither from
standard Python number hierarchy nor from ``numpy.ndarray``.
``approx`` now converts arguments to ``numpy.ndarray`` if they expose the array
protocol and are not scalars. This treats array-like objects like numpy arrays,
regardless of size.
pytest 6.2.0 (2020-12-12)
=========================
Breaking Changes
----------------
- `#7808 <https://github.com/pytest-dev/pytest/issues/7808>`_: pytest now supports python3.6+ only.
Deprecations
------------
- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_: Directly constructing/calling the following classes/functions is now deprecated:
- ``_pytest.cacheprovider.Cache``
- ``_pytest.cacheprovider.Cache.for_config()``
- ``_pytest.cacheprovider.Cache.clear_cache()``
- ``_pytest.cacheprovider.Cache.cache_dir_from_config()``
- ``_pytest.capture.CaptureFixture``
- ``_pytest.fixtures.FixtureRequest``
- ``_pytest.fixtures.SubRequest``
- ``_pytest.logging.LogCaptureFixture``
- ``_pytest.pytester.Pytester``
- ``_pytest.pytester.Testdir``
- ``_pytest.recwarn.WarningsRecorder``
- ``_pytest.recwarn.WarningsChecker``
- ``_pytest.tmpdir.TempPathFactory``
- ``_pytest.tmpdir.TempdirFactory``
These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.0.0.
- `#7530 <https://github.com/pytest-dev/pytest/issues/7530>`_: The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead.
We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing flag for all strictness
related options (``--strict-markers`` and ``--strict-config`` at the moment, more might be introduced in the future).
- `#7988 <https://github.com/pytest-dev/pytest/issues/7988>`_: The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead.
``yield_fixture`` has been an alias for ``fixture`` for a very long time, so can be search/replaced safely.
Features
--------
- `#5299 <https://github.com/pytest-dev/pytest/issues/5299>`_: pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8.
See :ref:`unraisable` for more information.
- `#7425 <https://github.com/pytest-dev/pytest/issues/7425>`_: New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``.
This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future.
Internally, the old :class:`Testdir <_pytest.pytester.Testdir>` is now a thin wrapper around :class:`Pytester <_pytest.pytester.Pytester>`, preserving the old interface.
- `#7695 <https://github.com/pytest-dev/pytest/issues/7695>`_: A new hook was added, `pytest_markeval_namespace` which should return a dictionary.
This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers.
Pseudo example
``conftest.py``:
.. code-block:: python
def pytest_markeval_namespace():
return {"color": "red"}
``test_func.py``:
.. code-block:: python
@pytest.mark.skipif("color == 'blue'", reason="Color is not red")
def test_func():
assert False
- `#8006 <https://github.com/pytest-dev/pytest/issues/8006>`_: It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``,
in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it
from the private `_pytest.monkeypatch.MonkeyPatch` namespace.
Additionally, :meth:`MonkeyPatch.context <pytest.MonkeyPatch.context>` is now a classmethod,
and can be used as ``with MonkeyPatch.context() as mp: ...``. This is the recommended way to use
``MonkeyPatch`` directly, since unlike the ``monkeypatch`` fixture, an instance created directly
is not ``undo()``-ed automatically.
Improvements
------------
- `#1265 <https://github.com/pytest-dev/pytest/issues/1265>`_: Added an ``__str__`` implementation to the :class:`~pytest.pytester.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method.
- `#2044 <https://github.com/pytest-dev/pytest/issues/2044>`_: Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS".
- `#7469 <https://github.com/pytest-dev/pytest/issues/7469>`_ The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions.
The newly-exported types are:
- ``pytest.FixtureRequest`` for the :fixture:`request` fixture.
- ``pytest.Cache`` for the :fixture:`cache` fixture.
- ``pytest.CaptureFixture[str]`` for the :fixture:`capfd` and :fixture:`capsys` fixtures.
- ``pytest.CaptureFixture[bytes]`` for the :fixture:`capfdbinary` and :fixture:`capsysbinary` fixtures.
- ``pytest.LogCaptureFixture`` for the :fixture:`caplog` fixture.
- ``pytest.Pytester`` for the :fixture:`pytester` fixture.
- ``pytest.Testdir`` for the :fixture:`testdir` fixture.
- ``pytest.TempdirFactory`` for the :fixture:`tmpdir_factory` fixture.
- ``pytest.TempPathFactory`` for the :fixture:`tmp_path_factory` fixture.
- ``pytest.MonkeyPatch`` for the :fixture:`monkeypatch` fixture.
- ``pytest.WarningsRecorder`` for the :fixture:`recwarn` fixture.
Constructing them is not supported (except for `MonkeyPatch`); they are only meant for use in type annotations.
Doing so will emit a deprecation warning, and may become a hard-error in pytest 8.0.
Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy.
- `#7527 <https://github.com/pytest-dev/pytest/issues/7527>`_: When a comparison between :func:`namedtuple <collections.namedtuple>` instances of the same type fails, pytest now shows the differing field names (possibly nested) instead of their indexes.
- `#7615 <https://github.com/pytest-dev/pytest/issues/7615>`_: :meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning <pytest.PytestWarning>`.
- `#7701 <https://github.com/pytest-dev/pytest/issues/7701>`_: Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats.
- `#7710 <https://github.com/pytest-dev/pytest/issues/7710>`_: Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of
raising :class:`TypeError`.
This was the undocumented behavior before 3.7, but is now officially a supported feature.
- `#7938 <https://github.com/pytest-dev/pytest/issues/7938>`_: New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``.
- `#8023 <https://github.com/pytest-dev/pytest/issues/8023>`_: Added ``'node_modules'`` to default value for :confval:`norecursedirs`.
- `#8032 <https://github.com/pytest-dev/pytest/issues/8032>`_: :meth:`doClassCleanups <unittest.TestCase.doClassCleanups>` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately.
Bug Fixes
---------
- `#4824 <https://github.com/pytest-dev/pytest/issues/4824>`_: Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures.
- `#7758 <https://github.com/pytest-dev/pytest/issues/7758>`_: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
- `#7911 <https://github.com/pytest-dev/pytest/issues/7911>`_: Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
- `#7913 <https://github.com/pytest-dev/pytest/issues/7913>`_: Fixed a crash or hang in :meth:`pytester.spawn <_pytest.pytester.Pytester.spawn>` when the :mod:`readline` module is involved.
- `#7951 <https://github.com/pytest-dev/pytest/issues/7951>`_: Fixed handling of recursive symlinks when collecting tests.
- `#7981 <https://github.com/pytest-dev/pytest/issues/7981>`_: Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0.
- `#8016 <https://github.com/pytest-dev/pytest/issues/8016>`_: Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``.
Improved Documentation
----------------------
- `#7429 <https://github.com/pytest-dev/pytest/issues/7429>`_: Add more information and use cases about skipping doctests.
- `#7780 <https://github.com/pytest-dev/pytest/issues/7780>`_: Classes which should not be inherited from are now marked ``final class`` in the API reference.
- `#7872 <https://github.com/pytest-dev/pytest/issues/7872>`_: ``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``.
- `#7878 <https://github.com/pytest-dev/pytest/issues/7878>`_: In pull request section, ask to commit after editing changelog and authors file.
Trivial/Internal Changes
------------------------
- `#7802 <https://github.com/pytest-dev/pytest/issues/7802>`_: The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.
- `#8014 <https://github.com/pytest-dev/pytest/issues/8014>`_: `.pyc` files created by pytest's assertion rewriting now conform to the newer PEP-552 format on Python>=3.7.
(These files are internal and only interpreted by pytest itself.)
pytest 6.1.2 (2020-10-28)
=========================
Bug Fixes
---------
- `#7758 <https://github.com/pytest-dev/pytest/issues/7758>`_: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0.
- `#7911 <https://github.com/pytest-dev/pytest/issues/7911>`_: Directories created by `tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites.
Improved Documentation
----------------------
- `#7815 <https://github.com/pytest-dev/pytest/issues/7815>`_: Improve deprecation warning message for ``pytest._fillfuncargs()``.
pytest 6.1.1 (2020-10-03) pytest 6.1.1 (2020-10-03)
========================= =========================
@ -460,7 +737,7 @@ Features
"integration", "integration",
] ]
More information can be found `in the docs <https://docs.pytest.org/en/stable/customize.html#configuration-file-formats>`__. More information can be found `in the docs <https://docs.pytest.org/en/stable/reference/customize.html#configuration-file-formats>`__.
- `#3342 <https://github.com/pytest-dev/pytest/issues/3342>`_: pytest now includes inline type annotations and exposes them to user programs. - `#3342 <https://github.com/pytest-dev/pytest/issues/3342>`_: pytest now includes inline type annotations and exposes them to user programs.
@ -508,7 +785,7 @@ Features
We intend to make ``--import-mode=importlib`` the default in future versions, so users are encouraged We intend to make ``--import-mode=importlib`` the default in future versions, so users are encouraged
to try the new mode and provide feedback (both positive or negative) in issue `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`__. to try the new mode and provide feedback (both positive or negative) in issue `#7245 <https://github.com/pytest-dev/pytest/issues/7245>`__.
You can read more about this option in `the documentation <https://docs.pytest.org/en/latest/pythonpath.html#import-modes>`__. You can read more about this option in `the documentation <https://docs.pytest.org/en/latest/explanation/pythonpath.html#import-modes>`__.
- `#7305 <https://github.com/pytest-dev/pytest/issues/7305>`_: New ``required_plugins`` configuration option allows the user to specify a list of plugins, including version information, that are required for pytest to run. An error is raised if any required plugins are not found when running pytest. - `#7305 <https://github.com/pytest-dev/pytest/issues/7305>`_: New ``required_plugins`` configuration option allows the user to specify a list of plugins, including version information, that are required for pytest to run. An error is raised if any required plugins are not found when running pytest.
@ -778,7 +1055,7 @@ Bug Fixes
- `#7110 <https://github.com/pytest-dev/pytest/issues/7110>`_: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again. - `#7110 <https://github.com/pytest-dev/pytest/issues/7110>`_: Fixed regression: ``asyncbase.TestCase`` tests are executed correctly again.
- `#7143 <https://github.com/pytest-dev/pytest/issues/7143>`_: Fix ``File.from_constructor`` so it forwards extra keyword arguments to the constructor. - `#7143 <https://github.com/pytest-dev/pytest/issues/7143>`_: Fix ``File.from_parent`` so it forwards extra keyword arguments to the constructor.
- `#7145 <https://github.com/pytest-dev/pytest/issues/7145>`_: Classes with broken ``__getattribute__`` methods are displayed correctly during failures. - `#7145 <https://github.com/pytest-dev/pytest/issues/7145>`_: Classes with broken ``__getattribute__`` methods are displayed correctly during failures.
@ -1400,7 +1677,7 @@ Features
- `#1682 <https://github.com/pytest-dev/pytest/issues/1682>`_: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives - `#1682 <https://github.com/pytest-dev/pytest/issues/1682>`_: The ``scope`` parameter of ``@pytest.fixture`` can now be a callable that receives
the fixture name and the ``config`` object as keyword-only parameters. the fixture name and the ``config`` object as keyword-only parameters.
See `the docs <https://docs.pytest.org/en/stable/fixture.html#dynamic-scope>`__ for more information. See `the docs <https://docs.pytest.org/en/stable/how-to/fixtures.html#dynamic-scope>`__ for more information.
- `#5764 <https://github.com/pytest-dev/pytest/issues/5764>`_: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run - `#5764 <https://github.com/pytest-dev/pytest/issues/5764>`_: New behavior of the ``--pastebin`` option: failures to connect to the pastebin server are reported, without failing the pytest run
@ -1539,7 +1816,7 @@ Features
- `#5564 <https://github.com/pytest-dev/pytest/issues/5564>`_: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``. - `#5564 <https://github.com/pytest-dev/pytest/issues/5564>`_: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
- `#5576 <https://github.com/pytest-dev/pytest/issues/5576>`_: New `NUMBER <https://docs.pytest.org/en/stable/doctest.html#using-doctest-options>`__ - `#5576 <https://github.com/pytest-dev/pytest/issues/5576>`_: New `NUMBER <https://docs.pytest.org/en/stable/how-to/doctest.html#using-doctest-options>`__
option for doctests to ignore irrelevant differences in floating-point numbers. option for doctests to ignore irrelevant differences in floating-point numbers.
Inspired by Sébastien Boisgérault's `numtest <https://github.com/boisgera/numtest>`__ Inspired by Sébastien Boisgérault's `numtest <https://github.com/boisgera/numtest>`__
extension for doctest. extension for doctest.
@ -1736,7 +2013,7 @@ Deprecations
Features Features
-------- --------
- `#3457 <https://github.com/pytest-dev/pytest/issues/3457>`_: New `pytest_assertion_pass <https://docs.pytest.org/en/stable/reference.html#_pytest.hookspec.pytest_assertion_pass>`__ - `#3457 <https://github.com/pytest-dev/pytest/issues/3457>`_: New `pytest_assertion_pass <https://docs.pytest.org/en/stable/reference/reference.html#_pytest.hookspec.pytest_assertion_pass>`__
hook, called with context information when an assertion *passes*. hook, called with context information when an assertion *passes*.
This hook is still **experimental** so use it with caution. This hook is still **experimental** so use it with caution.
@ -1749,7 +2026,7 @@ Features
`pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin into the core, `pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin into the core,
so users should remove that plugin from their requirements if used. so users should remove that plugin from their requirements if used.
For more information see the docs: https://docs.pytest.org/en/stable/usage.html#fault-handler For more information see the docs: https://docs.pytest.org/en/stable/how-to/failures.html#fault-handler
- `#5452 <https://github.com/pytest-dev/pytest/issues/5452>`_: When warnings are configured as errors, pytest warnings now appear as originating from ``pytest.`` instead of the internal ``_pytest.warning_types.`` module. - `#5452 <https://github.com/pytest-dev/pytest/issues/5452>`_: When warnings are configured as errors, pytest warnings now appear as originating from ``pytest.`` instead of the internal ``_pytest.warning_types.`` module.
@ -1854,6 +2131,44 @@ Improved Documentation
- `#5416 <https://github.com/pytest-dev/pytest/issues/5416>`_: Fix PytestUnknownMarkWarning in run/skip example. - `#5416 <https://github.com/pytest-dev/pytest/issues/5416>`_: Fix PytestUnknownMarkWarning in run/skip example.
pytest 4.6.11 (2020-06-04)
==========================
Bug Fixes
---------
- `#6334 <https://github.com/pytest-dev/pytest/issues/6334>`_: Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
The upper case variants were never documented and the preferred form should be the lower case.
- `#7310 <https://github.com/pytest-dev/pytest/issues/7310>`_: Fix ``UnboundLocalError: local variable 'letter' referenced before
assignment`` in ``_pytest.terminal.pytest_report_teststatus()``
when plugins return report objects in an unconventional state.
This was making ``pytest_report_teststatus()`` skip
entering if-block branches that declare the ``letter`` variable.
The fix was to set the initial value of the ``letter`` before
the if-block cascade so that it always has a value.
pytest 4.6.10 (2020-05-08)
==========================
Features
--------
- `#6870 <https://github.com/pytest-dev/pytest/issues/6870>`_: New ``Config.invocation_args`` attribute containing the unchanged arguments passed to ``pytest.main()``.
Remark: while this is technically a new feature and according to our `policy <https://docs.pytest.org/en/latest/py27-py34-deprecation.html#what-goes-into-4-6-x-releases>`_ it should not have been backported, we have opened an exception in this particular case because it fixes a serious interaction with ``pytest-xdist``, so it can also be considered a bugfix.
Trivial/Internal Changes
------------------------
- `#6404 <https://github.com/pytest-dev/pytest/issues/6404>`_: Remove usage of ``parser`` module, deprecated in Python 3.9.
pytest 4.6.9 (2020-01-04) pytest 4.6.9 (2020-01-04)
========================= =========================
@ -2108,7 +2423,7 @@ Features
The existing ``--strict`` option has the same behavior currently, but can be augmented in the future for additional checks. The existing ``--strict`` option has the same behavior currently, but can be augmented in the future for additional checks.
.. _`markers option`: https://docs.pytest.org/en/stable/reference.html#confval-markers .. _`markers option`: https://docs.pytest.org/en/stable/reference/reference.html#confval-markers
- `#5026 <https://github.com/pytest-dev/pytest/issues/5026>`_: Assertion failure messages for sequences and dicts contain the number of different items now. - `#5026 <https://github.com/pytest-dev/pytest/issues/5026>`_: Assertion failure messages for sequences and dicts contain the number of different items now.
@ -2165,7 +2480,7 @@ Features
CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test
The formatting can be changed through the `log_format <https://docs.pytest.org/en/stable/reference.html#confval-log_format>`__ configuration option. The formatting can be changed through the `log_format <https://docs.pytest.org/en/stable/reference/reference.html#confval-log_format>`__ configuration option.
- `#5220 <https://github.com/pytest-dev/pytest/issues/5220>`_: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``. - `#5220 <https://github.com/pytest-dev/pytest/issues/5220>`_: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``.
@ -2301,7 +2616,7 @@ Features
.. _pdb++: https://pypi.org/project/pdbpp/ .. _pdb++: https://pypi.org/project/pdbpp/
- `#4875 <https://github.com/pytest-dev/pytest/issues/4875>`_: The `testpaths <https://docs.pytest.org/en/stable/reference.html#confval-testpaths>`__ configuration option is now displayed next - `#4875 <https://github.com/pytest-dev/pytest/issues/4875>`_: The `testpaths <https://docs.pytest.org/en/stable/reference/reference.html#confval-testpaths>`__ configuration option is now displayed next
to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were to the ``rootdir`` and ``inifile`` lines in the pytest header if the option is in effect, i.e., directories or file names were
not explicitly passed in the command line. not explicitly passed in the command line.
@ -2556,7 +2871,7 @@ pytest 4.2.0 (2019-01-30)
Features Features
-------- --------
- `#3094 <https://github.com/pytest-dev/pytest/issues/3094>`_: `Classic xunit-style <https://docs.pytest.org/en/stable/xunit_setup.html>`__ functions and methods - `#3094 <https://github.com/pytest-dev/pytest/issues/3094>`_: `Classic xunit-style <https://docs.pytest.org/en/stable/how-to/xunit_setup.html>`__ functions and methods
now obey the scope of *autouse* fixtures. now obey the scope of *autouse* fixtures.
This fixes a number of surprising issues like ``setup_method`` being called before session-scoped This fixes a number of surprising issues like ``setup_method`` being called before session-scoped
@ -2802,12 +3117,12 @@ Features
will not issue the warning. will not issue the warning.
- `#3632 <https://github.com/pytest-dev/pytest/issues/3632>`_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <http://www.attrs.org/en/stable/>`__ or `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (Python 3.7+, `backported to 3.6 <https://pypi.org/project/dataclasses>`__). - `#3632 <https://github.com/pytest-dev/pytest/issues/3632>`_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <https://www.attrs.org/en/stable/>`__ or `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (Python 3.7+, `backported to 3.6 <https://pypi.org/project/dataclasses>`__).
- `#4278 <https://github.com/pytest-dev/pytest/issues/4278>`_: ``CACHEDIR.TAG`` files are now created inside cache directories. - `#4278 <https://github.com/pytest-dev/pytest/issues/4278>`_: ``CACHEDIR.TAG`` files are now created inside cache directories.
Those files are part of the `Cache Directory Tagging Standard <http://www.bford.info/cachedir/spec.html>`__, and can Those files are part of the `Cache Directory Tagging Standard <https://bford.info/cachedir/spec.html>`__, and can
be used by backup or synchronization programs to identify pytest's cache directory as such. be used by backup or synchronization programs to identify pytest's cache directory as such.
@ -3064,7 +3379,7 @@ Features
existing ``pytest_enter_pdb`` hook. existing ``pytest_enter_pdb`` hook.
- `#4147 <https://github.com/pytest-dev/pytest/issues/4147>`_: Add ``--sw``, ``--stepwise`` as an alternative to ``--lf -x`` for stopping at the first failure, but starting the next test invocation from that test. See `the documentation <https://docs.pytest.org/en/stable/cache.html#stepwise>`__ for more info. - `#4147 <https://github.com/pytest-dev/pytest/issues/4147>`_: Add ``--sw``, ``--stepwise`` as an alternative to ``--lf -x`` for stopping at the first failure, but starting the next test invocation from that test. See `the documentation <https://docs.pytest.org/en/stable/how-to/cache.html#stepwise>`__ for more info.
- `#4188 <https://github.com/pytest-dev/pytest/issues/4188>`_: Make ``--color`` emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if ``--verbose`` was also passed. - `#4188 <https://github.com/pytest-dev/pytest/issues/4188>`_: Make ``--color`` emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if ``--verbose`` was also passed.
@ -3469,13 +3784,13 @@ Features
the standard warnings filters to manage those warnings. This introduces ``PytestWarning``, the standard warnings filters to manage those warnings. This introduces ``PytestWarning``,
``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API. ``PytestDeprecationWarning`` and ``RemovedInPytest4Warning`` warning types as part of the public API.
Consult `the documentation <https://docs.pytest.org/en/stable/warnings.html#internal-pytest-warnings>`__ for more info. Consult `the documentation <https://docs.pytest.org/en/stable/how-to/capture-warnings.html#internal-pytest-warnings>`__ for more info.
- `#2908 <https://github.com/pytest-dev/pytest/issues/2908>`_: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is - `#2908 <https://github.com/pytest-dev/pytest/issues/2908>`_: ``DeprecationWarning`` and ``PendingDeprecationWarning`` are now shown by default if no other warning filter is
configured. This makes pytest more compliant with configured. This makes pytest more compliant with
`PEP-0506 <https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners>`_. See `PEP-0506 <https://www.python.org/dev/peps/pep-0565/#recommended-filter-settings-for-test-runners>`_. See
`the docs <https://docs.pytest.org/en/stable/warnings.html#deprecationwarning-and-pendingdeprecationwarning>`_ for `the docs <https://docs.pytest.org/en/stable/how-to/capture-warnings.html#deprecationwarning-and-pendingdeprecationwarning>`_ for
more info. more info.
@ -3908,7 +4223,7 @@ Features
- Support for Python 3.7's builtin ``breakpoint()`` method, see `Using the - Support for Python 3.7's builtin ``breakpoint()`` method, see `Using the
builtin breakpoint function builtin breakpoint function
<https://docs.pytest.org/en/stable/usage.html#breakpoint-builtin>`_ for <https://docs.pytest.org/en/stable/how-to/failures.html#using-the-builtin-breakpoint-function>`_ for
details. (`#3180 <https://github.com/pytest-dev/pytest/issues/3180>`_) details. (`#3180 <https://github.com/pytest-dev/pytest/issues/3180>`_)
- ``monkeypatch`` now supports a ``context()`` function which acts as a context - ``monkeypatch`` now supports a ``context()`` function which acts as a context
@ -4048,7 +4363,7 @@ Features
- New ``--rootdir`` command-line option to override the rules for discovering - New ``--rootdir`` command-line option to override the rules for discovering
the root directory. See `customize the root directory. See `customize
<https://docs.pytest.org/en/stable/customize.html>`_ in the documentation for <https://docs.pytest.org/en/stable/reference/customize.html>`_ in the documentation for
details. (`#1642 <https://github.com/pytest-dev/pytest/issues/1642>`_) details. (`#1642 <https://github.com/pytest-dev/pytest/issues/1642>`_)
- Fixtures are now instantiated based on their scopes, with higher-scoped - Fixtures are now instantiated based on their scopes, with higher-scoped
@ -4135,7 +4450,7 @@ Bug Fixes
Improved Documentation Improved Documentation
---------------------- ----------------------
- Added a `reference <https://docs.pytest.org/en/stable/reference.html>`_ page - Added a `reference <https://docs.pytest.org/en/stable/reference/reference.html>`_ page
to the docs. (`#1713 <https://github.com/pytest-dev/pytest/issues/1713>`_) to the docs. (`#1713 <https://github.com/pytest-dev/pytest/issues/1713>`_)
@ -4295,9 +4610,9 @@ Features
<https://github.com/pytest-dev/pytest/issues/2527>`_) <https://github.com/pytest-dev/pytest/issues/2527>`_)
- **Incompatible change**: after community feedback the `logging - **Incompatible change**: after community feedback the `logging
<https://docs.pytest.org/en/stable/logging.html>`_ functionality has <https://docs.pytest.org/en/stable/how-to/logging.html>`_ functionality has
undergone some changes. Please consult the `logging documentation undergone some changes. Please consult the `logging documentation
<https://docs.pytest.org/en/stable/logging.html#incompatible-changes-in-pytest-3-4>`_ <https://docs.pytest.org/en/stable/how-to/logging.html#incompatible-changes-in-pytest-3-4>`_
for details. (`#3013 <https://github.com/pytest-dev/pytest/issues/3013>`_) for details. (`#3013 <https://github.com/pytest-dev/pytest/issues/3013>`_)
- Console output falls back to "classic" mode when capturing is disabled (``-s``), - Console output falls back to "classic" mode when capturing is disabled (``-s``),
@ -4305,10 +4620,10 @@ Features
<https://github.com/pytest-dev/pytest/issues/3038>`_) <https://github.com/pytest-dev/pytest/issues/3038>`_)
- New `pytest_runtest_logfinish - New `pytest_runtest_logfinish
<https://docs.pytest.org/en/stable/reference.html#_pytest.hookspec.pytest_runtest_logfinish>`_ <https://docs.pytest.org/en/stable/reference/reference.html#_pytest.hookspec.pytest_runtest_logfinish>`_
hook which is called when a test item has finished executing, analogous to hook which is called when a test item has finished executing, analogous to
`pytest_runtest_logstart `pytest_runtest_logstart
<https://docs.pytest.org/en/stable/reference.html#_pytest.hookspec.pytest_runtest_logstart>`_. <https://docs.pytest.org/en/stable/reference/reference.html#_pytest.hookspec.pytest_runtest_logstart>`_.
(`#3101 <https://github.com/pytest-dev/pytest/issues/3101>`_) (`#3101 <https://github.com/pytest-dev/pytest/issues/3101>`_)
- Improve performance when collecting tests using many fixtures. (`#3107 - Improve performance when collecting tests using many fixtures. (`#3107
@ -4550,7 +4865,7 @@ Features
markers. Also, a ``caplog`` fixture is available that enables users to test markers. Also, a ``caplog`` fixture is available that enables users to test
the captured log during specific tests (similar to ``capsys`` for example). the captured log during specific tests (similar to ``capsys`` for example).
For more information, please see the `logging docs For more information, please see the `logging docs
<https://docs.pytest.org/en/stable/logging.html>`_. This feature was <https://docs.pytest.org/en/stable/how-to/logging.html>`_. This feature was
introduced by merging the popular `pytest-catchlog introduced by merging the popular `pytest-catchlog
<https://pypi.org/project/pytest-catchlog/>`_ plugin, thanks to `Thomas Hisch <https://pypi.org/project/pytest-catchlog/>`_ plugin, thanks to `Thomas Hisch
<https://github.com/thisch>`_. Be advised that during the merging the <https://github.com/thisch>`_. Be advised that during the merging the
@ -4791,7 +5106,7 @@ Improved Documentation
- In one of the simple examples, use ``pytest_collection_modifyitems()`` to skip - In one of the simple examples, use ``pytest_collection_modifyitems()`` to skip
tests based on a command-line option, allowing its sharing while preventing a tests based on a command-line option, allowing its sharing while preventing a
user error when acessing ``pytest.config`` before the argument parsing. user error when accessing ``pytest.config`` before the argument parsing.
(`#2653 <https://github.com/pytest-dev/pytest/issues/2653>`_) (`#2653 <https://github.com/pytest-dev/pytest/issues/2653>`_)
@ -4846,7 +5161,7 @@ Deprecations and Removals
- ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=`` - ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=``
operators to avoid surprising/inconsistent behavior. See `the approx docs operators to avoid surprising/inconsistent behavior. See `the approx docs
<https://docs.pytest.org/en/stable/reference.html#pytest-approx>`_ for more <https://docs.pytest.org/en/stable/reference/reference.html#pytest-approx>`_ for more
information. (`#2003 <https://github.com/pytest-dev/pytest/issues/2003>`_) information. (`#2003 <https://github.com/pytest-dev/pytest/issues/2003>`_)
- All old-style specific behavior in current classes in the pytest's API is - All old-style specific behavior in current classes in the pytest's API is
@ -4898,7 +5213,7 @@ Features
- Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the - Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the
warnings filter on a per test, class or module level. See the `docs warnings filter on a per test, class or module level. See the `docs
<https://docs.pytest.org/en/stable/warnings.html#pytest-mark- <https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-
filterwarnings>`_ for more information. (`#2598 <https://github.com/pytest- filterwarnings>`_ for more information. (`#2598 <https://github.com/pytest-
dev/pytest/issues/2598>`_) dev/pytest/issues/2598>`_)
@ -5128,7 +5443,7 @@ New Features
[pytest] [pytest]
addopts = -p no:warnings addopts = -p no:warnings
See the `warnings documentation page <https://docs.pytest.org/en/stable/warnings.html>`_ for more See the `warnings documentation page <https://docs.pytest.org/en/stable/how-to/capture-warnings.html>`_ for more
information. information.
Thanks `@nicoddemus`_ for the PR. Thanks `@nicoddemus`_ for the PR.
@ -5203,7 +5518,7 @@ Changes
Thanks `@ojii`_ for the PR. Thanks `@ojii`_ for the PR.
* Replace minor/patch level version numbers in the documentation with placeholders. * Replace minor/patch level version numbers in the documentation with placeholders.
This significantly reduces change-noise as different contributors regnerate This significantly reduces change-noise as different contributors regenerate
the documentation on different platforms. the documentation on different platforms.
Thanks `@RonnyPfannschmidt`_ for the PR. Thanks `@RonnyPfannschmidt`_ for the PR.
@ -6202,7 +6517,7 @@ time or change existing behaviors in order to make them less surprising/more use
* Fix (`#1422`_): junit record_xml_property doesn't allow multiple records * Fix (`#1422`_): junit record_xml_property doesn't allow multiple records
with same name. with same name.
.. _`traceback style docs`: https://pytest.org/en/stable/usage.html#modifying-python-traceback-printing .. _`traceback style docs`: https://docs.pytest.org/en/stable/how-to/output.html#modifying-python-traceback-printing
.. _#1609: https://github.com/pytest-dev/pytest/issues/1609 .. _#1609: https://github.com/pytest-dev/pytest/issues/1609
.. _#1422: https://github.com/pytest-dev/pytest/issues/1422 .. _#1422: https://github.com/pytest-dev/pytest/issues/1422
@ -7461,7 +7776,7 @@ Bug fixes:
- yielded test functions will now have autouse-fixtures active but - yielded test functions will now have autouse-fixtures active but
cannot accept fixtures as funcargs - it's anyway recommended to cannot accept fixtures as funcargs - it's anyway recommended to
rather use the post-2.0 parametrize features instead of yield, see: rather use the post-2.0 parametrize features instead of yield, see:
http://pytest.org/en/stable/example/parametrize.html http://pytest.org/en/stable/example/how-to/parametrize.html
- fix autouse-issue where autouse-fixtures would not be discovered - fix autouse-issue where autouse-fixtures would not be discovered
if defined in an a/conftest.py file and tests in a/tests/test_some.py if defined in an a/conftest.py file and tests in a/tests/test_some.py
- fix issue226 - LIFO ordering for fixture teardowns - fix issue226 - LIFO ordering for fixture teardowns
@ -7707,7 +8022,7 @@ Bug fixes:
or through plugin hooks. Also introduce a "--strict" option which or through plugin hooks. Also introduce a "--strict" option which
will treat unregistered markers as errors will treat unregistered markers as errors
allowing to avoid typos and maintain a well described set of markers allowing to avoid typos and maintain a well described set of markers
for your test suite. See exaples at http://pytest.org/en/stable/mark.html for your test suite. See exaples at http://pytest.org/en/stable/how-to/mark.html
and its links. and its links.
- issue50: introduce "-m marker" option to select tests based on markers - issue50: introduce "-m marker" option to select tests based on markers
(this is a stricter and more predictable version of '-k' in that "-m" (this is a stricter and more predictable version of '-k' in that "-m"
@ -7890,7 +8205,7 @@ Bug fixes:
- refinements to "collecting" output on non-ttys - refinements to "collecting" output on non-ttys
- refine internal plugin registration and --traceconfig output - refine internal plugin registration and --traceconfig output
- introduce a mechanism to prevent/unregister plugins from the - introduce a mechanism to prevent/unregister plugins from the
command line, see http://pytest.org/en/stable/plugins.html#cmdunregister command line, see http://pytest.org/en/stable/how-to/plugins.html#cmdunregister
- activate resultlog plugin by default - activate resultlog plugin by default
- fix regression wrt yielded tests which due to the - fix regression wrt yielded tests which due to the
collection-before-running semantics were not collection-before-running semantics were not
@ -8160,7 +8475,7 @@ Bug fixes:
- fixes for making the jython/win32 combination work, note however: - fixes for making the jython/win32 combination work, note however:
jython2.5.1/win32 does not provide a command line launcher, see jython2.5.1/win32 does not provide a command line launcher, see
http://bugs.jython.org/issue1491 . See pylib install documentation https://bugs.jython.org/issue1491 . See pylib install documentation
for how to work around. for how to work around.
- fixes for handling of unicode exception values and unprintable objects - fixes for handling of unicode exception values and unprintable objects

View File

@ -35,6 +35,7 @@ release = ".".join(version.split(".")[:2])
# sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
autodoc_member_order = "bysource" autodoc_member_order = "bysource"
autodoc_typehints = "description"
todo_include_todos = 1 todo_include_todos = 1
# -- General configuration ----------------------------------------------------- # -- General configuration -----------------------------------------------------
@ -70,7 +71,7 @@ master_doc = "contents"
# General information about the project. # General information about the project.
project = "pytest" project = "pytest"
copyright = "20152020, holger krekel and pytest-dev team" copyright = "20152021, holger krekel and pytest-dev team"
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
@ -159,7 +160,7 @@ html_short_title = "pytest-%s" % release
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
html_logo = "img/pytest1.png" html_logo = "img/pytest_logo_curves.svg"
# The name of an image file (within the static path) to use as favicon of the # The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
@ -251,7 +252,7 @@ latex_documents = [
"contents", "contents",
"pytest.tex", "pytest.tex",
"pytest Documentation", "pytest Documentation",
"holger krekel, trainer and consultant, http://merlinux.eu", "holger krekel, trainer and consultant, https://merlinux.eu/",
"manual", "manual",
) )
] ]
@ -292,7 +293,7 @@ man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"
epub_title = "pytest" epub_title = "pytest"
epub_author = "holger krekel at merlinux eu" epub_author = "holger krekel at merlinux eu"
epub_publisher = "holger krekel at merlinux eu" epub_publisher = "holger krekel at merlinux eu"
epub_copyright = "2013-2020, holger krekel et alii" epub_copyright = "2013-2021, holger krekel et alii"
# The language of the text. It defaults to the language option # The language of the text. It defaults to the language option
# or en if the language is not set. # or en if the language is not set.

View File

@ -7,21 +7,22 @@ Contact channels
- `pytest issue tracker`_ to report bugs or suggest features (for version - `pytest issue tracker`_ to report bugs or suggest features (for version
2.0 and above). 2.0 and above).
- `pytest discussions`_ at github for general questions.
- `pytest on stackoverflow.com <http://stackoverflow.com/search?q=pytest>`_ - `pytest on stackoverflow.com <http://stackoverflow.com/search?q=pytest>`_
to post questions with the tag ``pytest``. New Questions will usually to post precise questions with the tag ``pytest``. New Questions will usually
be seen by pytest users or developers and answered quickly. be seen by pytest users or developers and answered quickly.
- `Testing In Python`_: a mailing list for Python testing tools and discussion. - `Testing In Python`_: a mailing list for Python testing tools and discussion.
- `pytest-dev at python.org (mailing list)`_ pytest specific announcements and discussions. - `pytest-dev at python.org (mailing list)`_ pytest specific announcements and discussions.
- `pytest-commit at python.org (mailing list)`_: for commits and new issues
- :doc:`contribution guide <contributing>` for help on submitting pull - :doc:`contribution guide <contributing>` for help on submitting pull
requests to GitHub. requests to GitHub.
- ``#pylib`` on irc.freenode.net IRC channel for random questions. - ``#pytest`` `on irc.libera.chat <ircs://irc.libera.chat:6697/#pytest>`_ IRC
channel for random questions (using an IRC client, `via webchat
<https://web.libera.chat/#pytest>`_, or `via Matrix
<https://matrix.to/#/%23pytest:libera.chat>`_).
- private mail to Holger.Krekel at gmail com if you want to communicate sensitive issues - private mail to Holger.Krekel at gmail com if you want to communicate sensitive issues
@ -30,19 +31,21 @@ Contact channels
consulting. consulting.
.. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues .. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues
.. _`old issue tracker`: http://bitbucket.org/hpk42/py-trunk/issues/ .. _`old issue tracker`: https://bitbucket.org/hpk42/py-trunk/issues/
.. _`merlinux.eu`: http://merlinux.eu .. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions
.. _`merlinux.eu`: https://merlinux.eu/
.. _`get an account`: .. _`get an account`:
.. _tetamap: http://tetamap.wordpress.com .. _tetamap: https://tetamap.wordpress.com/
.. _`@pylibcommit`: http://twitter.com/pylibcommit .. _`@pylibcommit`: https://twitter.com/pylibcommit
.. _`Testing in Python`: http://lists.idyll.org/listinfo/testing-in-python .. _`Testing in Python`: http://lists.idyll.org/listinfo/testing-in-python
.. _FOAF: http://en.wikipedia.org/wiki/FOAF .. _FOAF: https://en.wikipedia.org/wiki/FOAF
.. _`py-dev`: .. _`py-dev`:
.. _`development mailing list`: .. _`development mailing list`:
.. _`pytest-dev at python.org (mailing list)`: http://mail.python.org/mailman/listinfo/pytest-dev .. _`pytest-dev at python.org (mailing list)`: http://mail.python.org/mailman/listinfo/pytest-dev

View File

@ -7,37 +7,81 @@ Full pytest documentation
.. `Download latest version as EPUB <http://media.readthedocs.org/epub/pytest/latest/pytest.epub>`_ .. `Download latest version as EPUB <http://media.readthedocs.org/epub/pytest/latest/pytest.epub>`_
Start here
-----------
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
getting-started getting-started
usage
existingtestsuite
assert
fixture
mark
monkeypatch
tmpdir
capture
warnings
doctest
skipping
parametrize
cache
unittest
nose
xunit_setup
plugins
writing_plugins
logging
reference
goodpractices
flaky How-to guides
pythonpath -------------
customize
.. toctree::
:maxdepth: 2
how-to/usage
how-to/assert
how-to/fixtures
how-to/mark
how-to/parametrize
how-to/tmp_path
how-to/monkeypatch
how-to/doctest
how-to/cache
how-to/logging
how-to/capture-stdout-stderr
how-to/capture-warnings
how-to/skipping
how-to/plugins
how-to/writing_plugins
how-to/writing_hook_functions
how-to/existingtestsuite
how-to/unittest
how-to/nose
how-to/xunit_setup
how-to/bash-completion
Reference guides
-----------------
.. toctree::
:maxdepth: 2
reference/fixtures
reference/plugin_list
reference/customize
reference/reference
Explanation
-----------------
.. toctree::
:maxdepth: 2
explanation/anatomy
explanation/fixtures
explanation/goodpractices
explanation/flaky
explanation/pythonpath
Further topics
-----------------
.. toctree::
:maxdepth: 2
example/index example/index
bash-completion
backwards-compatibility backwards-compatibility
deprecations deprecations
@ -51,6 +95,7 @@ Full pytest documentation
license license
contact contact
history
historical-notes historical-notes
talks talks
projects projects

View File

@ -19,6 +19,107 @@ Below is a complete list of all pytest features which are considered deprecated.
:class:`PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`. :class:`PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
``py.path.local`` arguments for hooks replaced with ``pathlib.Path``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to support the transition to :mod:`pathlib`, the following hooks now receive additional arguments:
* :func:`pytest_ignore_collect(fspath: pathlib.Path) <_pytest.hookspec.pytest_ignore_collect>`
* :func:`pytest_collect_file(fspath: pathlib.Path) <_pytest.hookspec.pytest_collect_file>`
* :func:`pytest_pycollect_makemodule(fspath: pathlib.Path) <_pytest.hookspec.pytest_pycollect_makemodule>`
* :func:`pytest_report_header(startpath: pathlib.Path) <_pytest.hookspec.pytest_report_header>`
* :func:`pytest_report_collectionfinish(startpath: pathlib.Path) <_pytest.hookspec.pytest_report_collectionfinish>`
The accompanying ``py.path.local`` based paths have been deprecated: plugins which manually invoke those hooks should only pass the new ``pathlib.Path`` arguments, and users should change their hook implementations to use the new ``pathlib.Path`` arguments.
Implementing the ``pytest_cmdline_preparse`` hook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
Implementing the :func:`pytest_cmdline_preparse <_pytest.hookspec.pytest_cmdline_preparse>` hook has been officially deprecated.
Implement the :func:`pytest_load_initial_conftests <_pytest.hookspec.pytest_load_initial_conftests>` hook instead.
.. code-block:: python
def pytest_cmdline_preparse(config: Config, args: List[str]) -> None:
...
# becomes:
def pytest_load_initial_conftests(
early_config: Config, parser: Parser, args: List[str]
) -> None:
...
Diamond inheritance between :class:`pytest.File` and :class:`pytest.Item`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 6.3
Inheriting from both Item and file at once has never been supported officially,
however some plugins providing linting/code analysis have been using this as a hack.
This practice is now officially deprecated and a common way to fix this is `example pr fixing inheritance`_.
.. _example pr fixing inheritance: https://github.com/asmeurer/pytest-flakes/pull/40/files
Backward compatibilities in ``Parser.addoption``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 2.4
Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
scheduled for removal in pytest 7 (deprecated since pytest 2.4.0):
- ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
Raising ``unittest.SkipTest`` during collection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 6.3
Raising :class:`unittest.SkipTest` to skip collection of tests during the
pytest collection phase is deprecated. Use :func:`pytest.skip` instead.
Note: This deprecation only relates to using `unittest.SkipTest` during test
collection. You are probably not doing that. Ordinary usage of
:class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` /
:func:`unittest.skip` in unittest test cases is fully supported.
The ``--strict`` command-line option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 6.2
The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which
better conveys what the option does.
We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing
flag for all strictness related options (``--strict-markers`` and ``--strict-config``
at the moment, more might be introduced in the future).
The ``yield_fixture`` function/decorator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 6.2
``pytest.yield_fixture`` is a deprecated alias for :func:`pytest.fixture`.
It has been so for a very long time, so can be search/replaced safely.
The ``pytest_warning_captured`` hook The ``pytest_warning_captured`` hook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -375,8 +476,8 @@ Metafunc.addcall
.. versionremoved:: 4.0 .. versionremoved:: 4.0
``_pytest.python.Metafunc.addcall`` was a precursor to the current parametrized mechanism. Users should use ``Metafunc.addcall`` was a precursor to the current parametrized mechanism. Users should use
:meth:`_pytest.python.Metafunc.parametrize` instead. :meth:`pytest.Metafunc.parametrize` instead.
Example: Example:

View File

@ -4,4 +4,4 @@ Development Guide
The contributing guidelines are to be found :ref:`here <contributing>`. The contributing guidelines are to be found :ref:`here <contributing>`.
The release procedure for pytest is documented on The release procedure for pytest is documented on
`GitHub <https://github.com/pytest-dev/pytest/blob/master/RELEASING.rst>`_. `GitHub <https://github.com/pytest-dev/pytest/blob/main/RELEASING.rst>`_.

View File

@ -5,9 +5,9 @@ failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py")
pytest_plugins = ("pytester",) pytest_plugins = ("pytester",)
def test_failure_demo_fails_properly(testdir): def test_failure_demo_fails_properly(pytester):
target = testdir.tmpdir.join(os.path.basename(failure_demo)) target = pytester.path.joinpath(os.path.basename(failure_demo))
shutil.copy(failure_demo, target) shutil.copy(failure_demo, target)
result = testdir.runpytest(target, syspathinsert=True) result = pytester.runpytest(target, syspathinsert=True)
result.stdout.fnmatch_lines(["*44 failed*"]) result.stdout.fnmatch_lines(["*44 failed*"])
assert result.ret != 0 assert result.ret != 0

View File

@ -0,0 +1,132 @@
<svg xmlns="http://www.w3.org/2000/svg" width="572" height="542">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class, circle.module, circle.package {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class, text.module, text.package {
fill: #0e84b5;
}
line, path {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<!-- main scope -->
<circle class="package" r="270" cx="286" cy="271" />
<!-- scope name -->
<defs>
<path d="M 26,271 A 260 260 0 0 1 546 271" id="testp"/>
</defs>
<text class="package">
<textPath href="#testp" startOffset="50%">tests</textPath>
</text>
<!-- subpackage -->
<circle class="package" r="140" cx="186" cy="271" />
<!-- scope name -->
<defs>
<path d="M 56,271 A 130 130 0 0 1 316 271" id="subpackage"/>
</defs>
<text class="package">
<textPath href="#subpackage" startOffset="50%">subpackage</textPath>
</text>
<!-- test_subpackage.py -->
<circle class="module" r="90" cx="186" cy="311" />
<!-- scope name -->
<defs>
<path d="M 106,311 A 80 80 0 0 1 266 311" id="testSubpackage"/>
</defs>
<text class="module">
<textPath href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
</text>
<!-- innermost -->
<line x1="186" x2="186" y1="271" y2="351"/>
<!-- mid -->
<path d="M 186 351 L 136 351 L 106 331 L 106 196" />
<!-- order -->
<path d="M 186 351 L 256 351 L 316 291 L 316 136" />
<!-- top -->
<path d="M 186 351 L 186 391 L 231 436 L 331 436" />
<ellipse class="fixture" rx="50" ry="25" cx="186" cy="271" />
<text x="186" y="271">innermost</text>
<rect class="test" width="110" height="50" x="131" y="326" />
<text x="186" y="351">test_order</text>
<ellipse class="fixture" rx="50" ry="25" cx="126" cy="196" />
<text x="126" y="196">mid</text>
<!-- scope order number -->
<mask id="testSubpackageOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="90" cx="186" cy="311" />
</mask>
<circle class="module" r="15" cx="96" cy="311" mask="url(#testSubpackageOrderMask)"/>
<text class="module" x="96" y="311">1</text>
<!-- scope order number -->
<mask id="subpackageOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="140" cx="186" cy="271" />
</mask>
<circle class="module" r="15" cx="46" cy="271" mask="url(#subpackageOrderMask)"/>
<text class="module" x="46" y="271">2</text>
<!-- scope order number -->
<mask id="testsOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="270" cx="286" cy="271" />
</mask>
<circle class="module" r="15" cx="16" cy="271" mask="url(#testsOrderMask)"/>
<text class="module" x="16" y="271">3</text>
<!-- test_top.py -->
<circle class="module" r="85" cx="441" cy="271" />
<!-- scope name -->
<defs>
<path d="M 366,271 A 75 75 0 0 1 516 271" id="testTop"/>
</defs>
<text class="module">
<textPath href="#testTop" startOffset="50%">test_top.py</textPath>
</text>
<!-- innermost -->
<line x1="441" x2="441" y1="306" y2="236"/>
<!-- order -->
<path d="M 441 306 L 376 306 L 346 276 L 346 136" />
<!-- top -->
<path d="M 441 306 L 441 411 L 411 436 L 331 436" />
<ellipse class="fixture" rx="50" ry="25" cx="441" cy="236" />
<text x="441" y="236">innermost</text>
<rect class="test" width="110" height="50" x="386" y="281" />
<text x="441" y="306">test_order</text>
<!-- scope order number -->
<mask id="testTopOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="85" cx="441" cy="271" />
</mask>
<circle class="module" r="15" cx="526" cy="271" mask="url(#testTopOrderMask)"/>
<text class="module" x="526" y="271">1</text>
<!-- scope order number -->
<circle class="module" r="15" cx="556" cy="271" mask="url(#testsOrderMask)"/>
<text class="module" x="556" y="271">2</text>
<ellipse class="fixture" rx="50" ry="25" cx="331" cy="436" />
<text x="331" y="436">top</text>
<ellipse class="fixture" rx="50" ry="25" cx="331" cy="136" />
<text x="331" y="136">order</text>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

Some files were not shown because too many files have changed in this diff Show More