Skip to content

Commit a3b11de

Browse files
authored
Merge branch 'main' into fix-exit-exceptiongroup-13650
2 parents 03cd2a2 + 09a9c6a commit a3b11de

28 files changed

+478
-83
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Andrzej Klajnert
3939
Andrzej Ostrowski
4040
Andy Freeland
4141
Anita Hammer
42+
Anna Tasiopoulou
4243
Anthon van der Neut
4344
Anthony Shaw
4445
Anthony Sottile
@@ -227,6 +228,7 @@ Jon Parise
227228
Jon Sonesen
228229
Jonas Obrist
229230
Jordan Guymon
231+
Jordan Macdonald
230232
Jordan Moldow
231233
Jordan Speicher
232234
Joseph Hunkeler

changelog/13072.feature.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Added support for displaying test session progress in the terminal tab using the `OSC 9;4; <https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC>`_ ANSI sequence.
2+
When pytest runs in a supported terminal emulator like ConEmu, Gnome Terminal, Ptyxis, Windows Terminal, Kitty or Ghostty,
3+
you'll see the progress in the terminal tab or window,
4+
allowing you to monitor pytest's progress at a glance.
5+
6+
This feature is automatically enabled when running in a TTY. It is implemented as an internal plugin. If needed, it can be disabled as follows:
7+
- On a user level, using ``-p no:terminalprogress`` on the command line or via an environment variable ``PYTEST_ADDOPTS='-p no:terminalprogress'``.
8+
- On a project configuration level, using ``addopts = "-p no:terminalprogress"``.

changelog/13766.breaking.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Previously, pytest would assume it was running in a CI/CD environment if either of the environment variables `$CI` or `$BUILD_NUMBER` was defined;
2+
now, CI mode is only activated if at least one of those variables is defined and set to a *non-empty* value.

changelog/13773.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed the static fixture closure calculation to properly consider transitive dependencies requested by overridden fixtures.

changelog/13779.breaking.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
**PytestRemovedIn9Warning deprecation warnings are now errors by default.**
2+
3+
Following our plan to remove deprecated features with as little disruption as
4+
possible, all warnings of type ``PytestRemovedIn9Warning`` now generate errors
5+
instead of warning messages by default.
6+
7+
**The affected features will be effectively removed in pytest 9.1**, so please consult the
8+
:ref:`deprecations` section in the docs for directions on how to update existing code.
9+
10+
In the pytest ``9.0.X`` series, it is possible to change the errors back into warnings as a
11+
stopgap measure by adding this to your ``pytest.ini`` file:
12+
13+
.. code-block:: ini
14+
15+
[pytest]
16+
filterwarnings =
17+
ignore::pytest.PytestRemovedIn9Warning
18+
19+
But this will stop working when pytest ``9.1`` is released.
20+
21+
**If you have concerns** about the removal of a specific feature, please add a
22+
comment to :issue:`13779`.

doc/en/explanation/ci.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ adapt some of its behaviours.
1717
How CI is detected
1818
------------------
1919

20-
Pytest knows it is in a CI environment when either one of these environment variables are set,
21-
regardless of their value:
20+
Pytest knows it is in a CI environment when either one of these environment variables are set to a non-empty value:
2221

2322
* `CI`: used by many CI systems.
2423
* `BUILD_NUMBER`: used by Jenkins.

doc/en/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ The ``[100%]`` refers to the overall progress of running all test cases. After i
7373
Run multiple tests
7474
----------------------------------------------------------
7575

76-
``pytest`` will run all files of the form test_*.py or \*_test.py in the current directory and its subdirectories. More generally, it follows :ref:`standard test discovery rules <test discovery>`.
76+
``pytest`` will run all files of the form ``test_*.py`` or ``*_test.py`` in the current directory and its subdirectories. More generally, it follows :ref:`standard test discovery rules <test discovery>`.
7777

7878

7979
Assert that a certain exception is raised

doc/en/reference/reference.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,11 +1165,11 @@ Environment variables that can be used to change pytest's behavior.
11651165

11661166
.. envvar:: CI
11671167

1168-
When set (regardless of value), pytest acknowledges that is running in a CI process. Alternative to ``BUILD_NUMBER`` variable. See also :ref:`ci-pipelines`.
1168+
When set to a non-empty value, pytest acknowledges that is running in a CI process. See also :ref:`ci-pipelines`.
11691169

11701170
.. envvar:: BUILD_NUMBER
11711171

1172-
When set (regardless of value), pytest acknowledges that is running in a CI process. Alternative to CI variable. See also :ref:`ci-pipelines`.
1172+
When set to a non-empty value, pytest acknowledges that is running in a CI process. Alternative to :envvar:`CI`. See also :ref:`ci-pipelines`.
11731173

11741174
.. envvar:: PYTEST_ADDOPTS
11751175

@@ -2408,7 +2408,7 @@ All the command-line flags can be obtained by running ``pytest --help``::
24082408
Plugins that must be present for pytest to run
24092409

24102410
Environment variables:
2411-
CI When set (regardless of value), pytest knows it is running in a CI process and does not truncate summary info
2411+
CI When set to a non-empty value, pytest knows it is running in a CI process and does not truncate summary info
24122412
BUILD_NUMBER Equivalent to CI
24132413
PYTEST_ADDOPTS Extra command line options
24142414
PYTEST_PLUGINS Comma-separated plugins to load during startup

src/_pytest/_io/terminalwriter.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,23 @@ def write(self, msg: str, *, flush: bool = False, **markup: bool) -> None:
161161

162162
msg = self.markup(msg, **markup)
163163

164-
try:
165-
self._file.write(msg)
166-
except UnicodeEncodeError:
167-
# Some environments don't support printing general Unicode
168-
# strings, due to misconfiguration or otherwise; in that case,
169-
# print the string escaped to ASCII.
170-
# When the Unicode situation improves we should consider
171-
# letting the error propagate instead of masking it (see #7475
172-
# for one brief attempt).
173-
msg = msg.encode("unicode-escape").decode("ascii")
174-
self._file.write(msg)
175-
176-
if flush:
177-
self.flush()
164+
self.write_raw(msg, flush=flush)
165+
166+
def write_raw(self, msg: str, *, flush: bool = False) -> None:
167+
try:
168+
self._file.write(msg)
169+
except UnicodeEncodeError:
170+
# Some environments don't support printing general Unicode
171+
# strings, due to misconfiguration or otherwise; in that case,
172+
# print the string escaped to ASCII.
173+
# When the Unicode situation improves we should consider
174+
# letting the error propagate instead of masking it (see #7475
175+
# for one brief attempt).
176+
msg = msg.encode("unicode-escape").decode("ascii")
177+
self._file.write(msg)
178+
179+
if flush:
180+
self.flush()
178181

179182
def line(self, s: str = "", **markup: bool) -> None:
180183
self.write(s, **markup)

src/_pytest/assertion/truncate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from __future__ import annotations
88

9-
from _pytest.assertion import util
9+
from _pytest.compat import running_on_ci
1010
from _pytest.config import Config
1111
from _pytest.nodes import Item
1212

@@ -43,7 +43,7 @@ def _get_truncation_parameters(item: Item) -> tuple[bool, int, int]:
4343

4444
verbose = item.config.get_verbosity(Config.VERBOSITY_ASSERTIONS)
4545

46-
should_truncate = verbose < 2 and not util.running_on_ci()
46+
should_truncate = verbose < 2 and not running_on_ci()
4747
should_truncate = should_truncate and (max_lines > 0 or max_chars > 0)
4848

4949
return should_truncate, max_lines, max_chars

0 commit comments

Comments
 (0)