Compare commits

...

15 Commits

Author SHA1 Message Date
Sviatoslav Sydorenko (Святослав Сидоренко) ac41898755
Merge pull request #12563 from webknjaz/maintenance/hotfixes/note/12264--reraise-with-original-tb
📝🚑 Polish the PR #12264 changelog entry
2024-07-02 21:30:19 +02:00
Sviatoslav Sydorenko (Святослав Сидоренко) 07ed62ae27
Merge pull request #12561 from webknjaz/maintenance/hotfixes/note/12502--ci-plugin-update-draft-ux
📝💄 Drop trailing period from #12502 byline
2024-07-02 21:28:41 +02:00
Virendra Patil 49bb5c89a6
Improved handling of invalid regex pattern in pytest.raises (#12526) 2024-07-02 21:58:08 +03:00
Sviatoslav Sydorenko (Святослав Сидоренко) e8aee21384
Merge pull request #12562 from webknjaz/maintenance/docs/user-role-validation 2024-07-02 20:52:05 +02:00
Sviatoslav Sydorenko (Святослав Сидоренко) 4a75f65c73
Merge pull request #12560 from webknjaz/maintenance/hotfixes/note/12531--xfail-no-cover 2024-07-02 20:50:16 +02:00
Sviatoslav Sydorenko (Святослав Сидоренко) 2719fd6825
Merge pull request #12559 from webknjaz/maintenance/hotfixes/note/12545--venv-detection-mingw 2024-07-02 20:49:57 +02:00
Sviatoslav Sydorenko b62974e63f
📝💅 Link #12264 change note to #12204 2024-07-02 15:54:35 +02:00
Sviatoslav Sydorenko ffcc001562
📝 Add a byline to #12264 change note 2024-07-02 15:54:35 +02:00
Sviatoslav Sydorenko 94c0122a17
📝 Use past tense in #12204 change note 2024-07-02 15:54:34 +02:00
Sviatoslav Sydorenko 8398609f08
📝🚑 Fix RST list in #12264 changelog entry
It was being rendered inline and now it's not.
2024-07-02 15:54:34 +02:00
Sviatoslav Sydorenko 57fe9f53c6
📝 Add a change note for PR #12562 2024-07-02 15:26:35 +02:00
Sviatoslav Sydorenko 9c319d6605
🧪 Lint for typos in `:user:` RST role
It is easy to forget backticks in change note bylines. It's happened
in #12531 already, requiring a hotfix in #12560.

The pre-commit based check idea is coming from the Tox project and
have been battle-tested in aiohttp, CherryPy, and other ecosystems.
2024-07-02 15:21:24 +02:00
Sviatoslav Sydorenko a34f2f06db
📝💄 Drop trailing period from #12502 byline 2024-07-02 15:15:31 +02:00
Sviatoslav Sydorenko 388cf8f381
Correct the `:user:` role @ PR #12531 change note 2024-07-02 15:12:27 +02:00
Sviatoslav Sydorenko 2455e99ea3
📝 Add markup to the PR #12545 changelog entry 2024-07-02 15:09:32 +02:00
12 changed files with 56 additions and 10 deletions

View File

@ -102,6 +102,14 @@ repos:
)
$
files: ^changelog/
- id: changelogs-user-role
name: Changelog files should use a non-broken :user:`name` role
language: pygrep
entry: :user:([^`]+`?|`[^`]+[\s,])
pass_filenames: true
types:
- file
- rst
- id: py-deprecated
name: py library is deprecated
language: pygrep

View File

@ -430,6 +430,7 @@ Victor Rodriguez
Victor Uriarte
Vidar T. Fauske
Vijay Arora
Virendra Patil
Virgil Dupras
Vitaly Lashmanov
Vivaan Verma

View File

@ -1,7 +1,11 @@
Fix a regression in pytest 8.0 where tracebacks get longer and longer when multiple tests fail due to a shared higher-scope fixture which raised.
Fixed a regression in pytest 8.0 where tracebacks get longer and longer when multiple
tests fail due to a shared higher-scope fixture which raised -- by :user:`bluetech`.
Also fix a similar regression in pytest 5.4 for collectors which raise during setup.
Also fixed a similar regression in pytest 5.4 for collectors which raise during setup.
The fix necessitated internal changes which may affect some plugins:
- ``FixtureDef.cached_result[2]`` is now a tuple ``(exc, tb)`` instead of ``exc``.
- ``SetupState.stack`` failures are now a tuple ``(exc, tb)`` instead of ``exc``.
* ``FixtureDef.cached_result[2]`` is now a tuple ``(exc, tb)``
instead of ``exc``.
* ``SetupState.stack`` failures are now a tuple ``(exc, tb)``
instead of ``exc``.

1
changelog/12264.bugfix.rst Symbolic link
View File

@ -0,0 +1 @@
12204.bugfix.rst

View File

@ -4,4 +4,4 @@ the automatically created pull requests and re-open them to trigger the
CI runs. From now on, they only need to click the `Ready for review`
button instead.
-- by :user:`webknjaz`.
-- by :user:`webknjaz`

View File

@ -0,0 +1 @@
Improve handling of invalid regex patterns in :func:`pytest.raises(match=r'...') <pytest.raises>` by providing a clear error message.

View File

@ -3,4 +3,4 @@ pytest's own tests marked as expected to fail from the coverage
report. This has an effect of reducing the influence of flaky
tests on the resulting number.
-- by :user`webknjaz`
-- by :user:`webknjaz`

View File

@ -1,4 +1,3 @@
The _in_venv function now detects Python virtual environments by checking
for a pyvenv.cfg file, ensuring reliable detection on various platforms.
-- by :user:`zachsnickers`.
The ``_in_venv()`` function now detects Python virtual environments by
checking for a :file:`pyvenv.cfg` file, ensuring reliable detection on
various platforms -- by :user:`zachsnickers`.

View File

@ -0,0 +1 @@
12544.improvement.rst

View File

@ -0,0 +1,2 @@
Possible typos in using the ``:user:`` RST role is now being linted
through the pre-commit tool integration -- by :user:`webknjaz`.

View File

@ -7,6 +7,7 @@ from decimal import Decimal
import math
from numbers import Complex
import pprint
import re
from types import TracebackType
from typing import Any
from typing import Callable
@ -986,6 +987,14 @@ class RaisesContext(ContextManager[_pytest._code.ExceptionInfo[E]]):
self.message = message
self.match_expr = match_expr
self.excinfo: _pytest._code.ExceptionInfo[E] | None = None
if self.match_expr is not None:
re_error = None
try:
re.compile(self.match_expr)
except re.error as e:
re_error = e
if re_error is not None:
fail(f"Invalid regex pattern provided to 'match': {re_error}")
def __enter__(self) -> _pytest._code.ExceptionInfo[E]:
self.excinfo = _pytest._code.ExceptionInfo.for_later()

View File

@ -132,6 +132,26 @@ class TestRaises:
result = pytester.runpytest()
result.stdout.fnmatch_lines(["*2 failed*"])
def test_raises_with_invalid_regex(self, pytester: Pytester) -> None:
pytester.makepyfile(
"""
import pytest
def test_invalid_regex():
with pytest.raises(ValueError, match="invalid regex character ["):
raise ValueError()
"""
)
result = pytester.runpytest()
result.stdout.fnmatch_lines(
[
"*Invalid regex pattern provided to 'match': unterminated character set at position 24*",
]
)
result.stdout.no_fnmatch_line("*Traceback*")
result.stdout.no_fnmatch_line("*File*")
result.stdout.no_fnmatch_line("*line*")
def test_noclass(self) -> None:
with pytest.raises(TypeError):
pytest.raises("wrong", lambda: None) # type: ignore[call-overload]