Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jul 4, 2023
2 parents 4719d99 + 6995257 commit cb732f7
Show file tree
Hide file tree
Showing 65 changed files with 656 additions and 567 deletions.
42 changes: 28 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,53 @@ on:
permissions: {}

jobs:

deploy:
if: github.repository == 'pytest-dev/pytest'

build:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write

timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Build and Check Package
uses: hynek/[email protected]

deploy:
if: github.repository == 'pytest-dev/pytest'
needs: [build]
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
id-token: write
steps:
- name: Download Package
uses: actions/download-artifact@v3
with:
name: Packages
path: dist

- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_token }}
uses: pypa/gh-action-pypi-publish@v1.8.5

release-notes:

# todo: generate the content in the build job
# the goal being of using a github action script to push the release data
# after success instead of creating a complete python/tox env
needs: [deploy]
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.7"
python-version: "3.11"


- name: Install tox
run: |
Expand Down
54 changes: 22 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,23 @@ jobs:
fail-fast: false
matrix:
name: [
"windows-py37",
"windows-py37-pluggy",
"windows-py38",
"windows-py38-pluggy",
"windows-py39",
"windows-py310",
"windows-py311",
"windows-py312",

"ubuntu-py37",
"ubuntu-py37-pluggy",
"ubuntu-py37-freeze",
"ubuntu-py38",
"ubuntu-py38-pluggy",
"ubuntu-py38-freeze",
"ubuntu-py39",
"ubuntu-py310",
"ubuntu-py311",
"ubuntu-py312",
"ubuntu-pypy3",

"macos-py37",
"macos-py38",
"macos-py39",
"macos-py310",
"macos-py312",
Expand All @@ -66,19 +64,15 @@ jobs:
]

include:
- name: "windows-py37"
python: "3.7"
os: windows-latest
tox_env: "py37-numpy"
- name: "windows-py37-pluggy"
python: "3.7"
os: windows-latest
tox_env: "py37-pluggymain-pylib-xdist"
- name: "windows-py38"
python: "3.8"
os: windows-latest
tox_env: "py38-unittestextras"
use_coverage: true
- name: "windows-py38-pluggy"
python: "3.8"
os: windows-latest
tox_env: "py38-pluggymain-pylib-xdist"
- name: "windows-py39"
python: "3.9"
os: windows-latest
Expand All @@ -96,23 +90,19 @@ jobs:
os: windows-latest
tox_env: "py312"

- name: "ubuntu-py37"
python: "3.7"
- name: "ubuntu-py38"
python: "3.8"
os: ubuntu-latest
tox_env: "py37-lsof-numpy-pexpect"
tox_env: "py38-lsof-numpy-pexpect"
use_coverage: true
- name: "ubuntu-py37-pluggy"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-pluggymain-pylib-xdist"
- name: "ubuntu-py37-freeze"
python: "3.7"
- name: "ubuntu-py38-pluggy"
python: "3.8"
os: ubuntu-latest
tox_env: "py37-freeze"
- name: "ubuntu-py38"
tox_env: "py38-pluggymain-pylib-xdist"
- name: "ubuntu-py38-freeze"
python: "3.8"
os: ubuntu-latest
tox_env: "py38-xdist"
tox_env: "py38-freeze"
- name: "ubuntu-py39"
python: "3.9"
os: ubuntu-latest
Expand All @@ -132,14 +122,14 @@ jobs:
tox_env: "py312"
use_coverage: true
- name: "ubuntu-pypy3"
python: "pypy-3.7"
python: "pypy-3.8"
os: ubuntu-latest
tox_env: "pypy3-xdist"

- name: "macos-py37"
python: "3.7"
- name: "macos-py38"
python: "3.8"
os: macos-latest
tox_env: "py37-xdist"
tox_env: "py38-xdist"
- name: "macos-py39"
python: "3.9"
os: macos-latest
Expand All @@ -160,11 +150,11 @@ jobs:
tox_env: "plugins"

- name: "docs"
python: "3.7"
python: "3.8"
os: ubuntu-latest
tox_env: "docs"
- name: "doctesting"
python: "3.7"
python: "3.8"
os: ubuntu-latest
tox_env: "doctesting"
use_coverage: true
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
exclude: _pytest/(debugging|hookspec).py
language_version: python3
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
rev: v2.2.0
hooks:
- id: autoflake
name: autoflake
Expand All @@ -40,14 +40,14 @@ repos:
rev: v3.10.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src', --py37-plus]
args: ['--application-directories=.:src', --py38-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.7.0
rev: v3.8.0
hooks:
- id: pyupgrade
args: [--py37-plus]
args: [--py38-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.3.0
rev: v2.4.0
hooks:
- id: setup-cfg-fmt
args: ["--max-py-version=3.12", "--include-version-classifiers"]
Expand All @@ -56,7 +56,7 @@ repos:
hooks:
- id: python-use-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.4.1
hooks:
- id: mypy
files: ^(src/|testing/)
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Adam Johnson
Adam Stewart
Adam Uhlir
Ahn Ki-Wook
Akhilesh Ramakrishnan
Akiomi Kamakura
Alan Velasco
Alessio Izzo
Expand Down Expand Up @@ -129,6 +130,7 @@ Eric Hunsberger
Eric Liu
Eric Siegerman
Erik Aronesty
Erik Hasse
Erik M. Bray
Evan Kepner
Evgeny Seliverstov
Expand Down Expand Up @@ -310,6 +312,7 @@ Raphael Pierzina
Rafal Semik
Raquel Alegre
Ravi Chandra
Reagan Lee
Robert Holt
Roberto Aldera
Roberto Polli
Expand Down
16 changes: 8 additions & 8 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Short version
#. Follow **PEP-8** for naming and `black <https://github.com/psf/black>`_ for formatting.
#. Tests are run using ``tox``::

tox -e linting,py37
tox -e linting,py39

The test environments above are usually enough to cover most cases locally.

Expand Down Expand Up @@ -272,24 +272,24 @@ Here is a simple overview, with pytest-specific bits:

#. Run all the tests

You need to have Python 3.7 available in your system. Now
You need to have Python 3.8 or later available in your system. Now
running tests is as simple as issuing this command::

$ tox -e linting,py37
$ tox -e linting,py39

This command will run tests via the "tox" tool against Python 3.7
This command will run tests via the "tox" tool against Python 3.9
and also perform "lint" coding-style checks.

#. You can now edit your local working copy and run the tests again as necessary. Please follow PEP-8 for naming.

You can pass different options to ``tox``. For example, to run tests on Python 3.7 and pass options to pytest
You can pass different options to ``tox``. For example, to run tests on Python 3.9 and pass options to pytest
(e.g. enter pdb on failure) to pytest you can do::

$ tox -e py37 -- --pdb
$ tox -e py39 -- --pdb

Or to only run tests in a particular test module on Python 3.7::
Or to only run tests in a particular test module on Python 3.9::

$ tox -e py37 -- testing/test_config.py
$ tox -e py39 -- testing/test_config.py


When committing, ``pre-commit`` will re-format the files if necessary.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Features
- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
`nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box

- Python 3.7+ or PyPy3
- Python 3.8+ or PyPy3

- Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community

Expand Down
2 changes: 2 additions & 0 deletions changelog/10337.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed that fake intermediate modules generated by ``--import-mode=importlib`` would not include the
child modules as attributes of the parent modules.
2 changes: 2 additions & 0 deletions changelog/10447.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
markers are now considered in the reverse mro order to ensure base class markers are considered first
this resolves a regression.
2 changes: 2 additions & 0 deletions changelog/10811.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed issue when using ``--import-mode=importlib`` together with ``--doctest-modules`` that caused modules
to be imported more than once, causing problems with modules that have import side effects.
1 change: 1 addition & 0 deletions changelog/11011.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a warning about modifying the root logger during tests when using ``caplog``.
2 changes: 2 additions & 0 deletions changelog/11151.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dropped support for Python 3.7, which `reached end-of-life on 2023-06-27
<https://devguide.python.org/versions/>`__.
1 change: 1 addition & 0 deletions changelog/9036.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pytest.warns`` and similar functions now capture warnings when an exception is raised inside a ``with`` block.
7 changes: 7 additions & 0 deletions changelog/9288.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:func:`pytest.warns <warns>` now re-emits unmatched warnings when the context
closes -- previously it would consume all warnings, hiding those that were not
matched by the function.

While this is a new feature, we decided to announce this as a breaking change
because many test suites are configured to error-out on warnings, and will
therefore fail on the newly-re-emitted warnings.
1 change: 1 addition & 0 deletions doc/en/backwards-compatibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Released pytest versions support all Python versions that are actively maintaine
============== ===================
pytest version min. Python version
============== ===================
8.0+ 3.8+
7.1+ 3.7+
6.2 - 7.0 3.6+
5.0 - 6.1 3.5+
Expand Down
21 changes: 0 additions & 21 deletions doc/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
#
# The full version, including alpha/beta/rc tags.
# The short X.Y version.
import ast
import os
import shutil
import sys
from textwrap import dedent
from typing import List
from typing import TYPE_CHECKING

from _pytest import __version__ as version
Expand Down Expand Up @@ -451,25 +449,6 @@ def setup(app: "sphinx.application.Sphinx") -> None:

configure_logging(app)

# Make Sphinx mark classes with "final" when decorated with @final.
# We need this because we import final from pytest._compat, not from
# typing (for Python < 3.8 compat), so Sphinx doesn't detect it.
# To keep things simple we accept any `@final` decorator.
# Ref: https://github.com/pytest-dev/pytest/pull/7780
import sphinx.pycode.ast
import sphinx.pycode.parser

original_is_final = sphinx.pycode.parser.VariableCommentPicker.is_final

def patched_is_final(self, decorators: List[ast.expr]) -> bool:
if original_is_final(self, decorators):
return True
return any(
sphinx.pycode.ast.unparse(decorator) == "final" for decorator in decorators
)

sphinx.pycode.parser.VariableCommentPicker.is_final = patched_is_final

# legacypath.py monkey-patches pytest.Testdir in. Import the file so
# that autodoc can discover references to it.
import _pytest.legacypath # noqa: F401
2 changes: 1 addition & 1 deletion doc/en/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Get Started
Install ``pytest``
----------------------------------------

``pytest`` requires: Python 3.7+ or PyPy3.
``pytest`` requires: Python 3.8+ or PyPy3.

1. Run the following command in your command line:

Expand Down
7 changes: 7 additions & 0 deletions doc/en/how-to/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ the records for the ``setup`` and ``call`` stages during teardown like so:
The full API is available at :class:`pytest.LogCaptureFixture`.

.. warning::

The ``caplog`` fixture adds a handler to the root logger to capture logs. If the root logger is
modified during a test, for example with ``logging.config.dictConfig``, this handler may be
removed and cause no logs to be captured. To avoid this, ensure that any root logger configuration
only adds to the existing handlers.


.. _live_logs:

Expand Down
Loading

0 comments on commit cb732f7

Please sign in to comment.