diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index 4da55e6d5..ade8452af 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -47,7 +47,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c85175f29..56d9a0c86 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.4.9" + rev: "v0.4.10" hooks: - id: ruff args: ["--fix"] diff --git a/changelog/12505.bugfix.rst b/changelog/12505.bugfix.rst index bf16cdb48..f55a8a17e 100644 --- a/changelog/12505.bugfix.rst +++ b/changelog/12505.bugfix.rst @@ -1 +1 @@ -Improve handling of invalid regex patterns in :func:`pytest.raises(match=r'...') ` by providing a clear error message. \ No newline at end of file +Improve handling of invalid regex patterns in :func:`pytest.raises(match=r'...') ` by providing a clear error message. diff --git a/changelog/12533.contrib.rst b/changelog/12533.contrib.rst new file mode 100644 index 000000000..3da7007a0 --- /dev/null +++ b/changelog/12533.contrib.rst @@ -0,0 +1,7 @@ +The ``extlinks`` Sphinx extension is no longer enabled. The ``:bpo:`` +role it used to declare has been removed with that. BPO itself has +migrated to GitHub some years ago and it is possible to link the +respective issues by using their GitHub issue numbers and the +``:issue:`` role that the ``sphinx-issues`` extension implements. + +-- by :user:`webknjaz` diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 2c07f208a..8e3efd047 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -3360,7 +3360,9 @@ Bug Fixes - :issue:`5914`: pytester: fix :py:func:`~pytest.LineMatcher.no_fnmatch_line` when used after positive matching. -- :issue:`6082`: Fix line detection for doctest samples inside :py:class:`python:property` docstrings, as a workaround to :bpo:`17446`. +- :issue:`6082`: Fix line detection for doctest samples inside + :py:class:`python:property` docstrings, as a workaround to + :issue:`python/cpython#61648`. - :issue:`6254`: Fix compatibility with pytest-parallel (regression in pytest 5.3.0). diff --git a/doc/en/conf.py b/doc/en/conf.py index 7ec862a60..0d440ec44 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -82,7 +82,6 @@ extensions = [ "pygments_pytest", "sphinx.ext.autodoc", "sphinx.ext.autosummary", - "sphinx.ext.extlinks", "sphinx.ext.intersphinx", "sphinx.ext.todo", "sphinx.ext.viewcode", @@ -171,11 +170,6 @@ linkcheck_ignore = [ linkcheck_workers = 5 -extlinks = { - "bpo": ("https://bugs.python.org/issue%s", "bpo-%s"), -} - - nitpicky = True nitpick_ignore = [ # TODO (fix in pluggy?) diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index 159ff2cd1..babcd9e2f 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -80,7 +80,7 @@ keyword arguments, e.g. to run only tests marked with ``device`` and the specifi .. code-block:: pytest - $ pytest -v -m 'device(serial="123")' + $ pytest -v -m "device(serial='123')" =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-8.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python cachedir: .pytest_cache diff --git a/doc/en/how-to/usage.rst b/doc/en/how-to/usage.rst index 05ee04600..0e0a0310f 100644 --- a/doc/en/how-to/usage.rst +++ b/doc/en/how-to/usage.rst @@ -88,7 +88,7 @@ with the ``phase`` keyword argument set to ``1``: .. code-block:: bash - pytest -m slow(phase=1) + pytest -m "slow(phase=1)" For more information see :ref:`marks `. diff --git a/doc/en/index.rst b/doc/en/index.rst index 58527ea73..8de3b3993 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -4,8 +4,7 @@ .. sidebar:: **Next Open Trainings and Events** - - `pytest development sprint `_, **June 17th -- 22nd 2024**, Klaus (AT) / Remote - - `pytest tips and tricks for a better testsuite `_, at `Europython 2024 `_, **July 8th -- 14th 2024** (3h), Prague (CZ) + - `pytest tips and tricks for a better testsuite `_, at `Europython 2024 `_, **July 9th 2024** (3h), Prague (CZ) - `pytest: Professionelles Testen (nicht nur) für Python `_, at `CH Open Workshoptage `_, **September 2nd 2024**, HSLU Rotkreuz (CH) - `Professional Testing with Python `_, via `Python Academy `_ (3 day in-depth training), **March 4th -- 6th 2025**, Leipzig (DE) / Remote diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py index 3f4071dce..89cc0e94d 100644 --- a/src/_pytest/mark/expression.py +++ b/src/_pytest/mark/expression.py @@ -5,15 +5,19 @@ The grammar is: expression: expr? EOF expr: and_expr ('or' and_expr)* and_expr: not_expr ('and' not_expr)* -not_expr: 'not' not_expr | '(' expr ')' | ident ( '(' name '=' value ( ', ' name '=' value )* ')')* +not_expr: 'not' not_expr | '(' expr ')' | ident kwargs? ident: (\w|:|\+|-|\.|\[|\]|\\|/)+ +kwargs: ('(' name '=' value ( ', ' name '=' value )* ')') +name: a valid ident, but not a reserved keyword +value: (unescaped) string literal | (-)?[0-9]+ | 'False' | 'True' | 'None' The semantics are: - Empty expression evaluates to False. -- ident evaluates to True of False according to a provided matcher function. +- ident evaluates to True or False according to a provided matcher function. - or/and/not evaluate according to the usual boolean semantics. +- ident with parentheses and keyword arguments evaluates to True or False according to a provided matcher function. """ from __future__ import annotations @@ -48,7 +52,7 @@ class TokenType(enum.Enum): IDENT = "identifier" EOF = "end of input" EQUAL = "=" - STRING = "str" + STRING = "string literal" COMMA = "," diff --git a/testing/test_mark.py b/testing/test_mark.py index 6a94cc9f7..89eef7920 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -235,7 +235,7 @@ def test_mark_option( @pytest.mark.parametrize( ("expr", "expected_passed"), - [ # TODO: improve/sort out + [ ("car(color='red')", ["test_one"]), ("car(color='red') or car(color='blue')", ["test_one", "test_two"]), ("car and not car(temp=5)", ["test_one", "test_three"]), diff --git a/testing/test_mark_expression.py b/testing/test_mark_expression.py index c31ab4470..f8f5f9221 100644 --- a/testing/test_mark_expression.py +++ b/testing/test_mark_expression.py @@ -228,9 +228,10 @@ def test_invalid_idents(ident: str) -> None: r'escaping with "\\" not supported in marker expression', ), ("mark(empty_list=[])", r'unexpected character/s "\[\]"'), + ("'str'", "expected not OR left parenthesis OR identifier; got string literal"), ), ) -def test_invalid_kwarg_name_or_value( # TODO: move to `test_syntax_errors` ? +def test_invalid_kwarg_name_or_value( expr: str, expected_error_msg: str, mark_matcher: MarkMatcher ) -> None: with pytest.raises(ParseError, match=expected_error_msg): @@ -289,7 +290,7 @@ def test_keyword_expressions_with_numbers( ("builtin_matchers_mark(z=1)", False), ), ) -def test_builtin_matchers_keyword_expressions( # TODO: naming when decided +def test_builtin_matchers_keyword_expressions( expr: str, expected: bool, mark_matcher: MarkMatcher ) -> None: assert evaluate(expr, mark_matcher) is expected