Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/13896.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The terminal progress plugin added in pytest 9.0 is now automatically disabled when iTerm2 is detected, it generated desktop notifications instead of the desired functionality.
12 changes: 10 additions & 2 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import datetime
from functools import partial
import inspect
import os
from pathlib import Path
import platform
import sys
Expand Down Expand Up @@ -299,8 +300,15 @@ def mywriter(tags, args):
config.trace.root.setprocessor("pytest:config", mywriter)

if reporter.isatty():
plugin = TerminalProgressPlugin(reporter)
config.pluginmanager.register(plugin, "terminalprogress")
# Some terminals interpret OSC 9;4 as desktop notification,
# skip on those we know (#13896).
should_skip_terminal_progress = (
# iTerm2 (reported on version 3.6.5).
"ITERM_SESSION_ID" in os.environ
)
if not should_skip_terminal_progress:
plugin = TerminalProgressPlugin(reporter)
config.pluginmanager.register(plugin, "terminalprogress")


def getreportopt(config: Config) -> str:
Expand Down
11 changes: 11 additions & 0 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3443,6 +3443,17 @@ def test_disabled_for_non_tty(self, pytester: pytest.Pytester) -> None:
plugin = config.pluginmanager.get_plugin("terminalprogress")
assert plugin is None

def test_disabled_for_iterm2(self, pytester: pytest.Pytester, monkeypatch) -> None:
"""Should not register the plugin on iTerm2 terminal since it interprets
OSC 9;4 as desktop notifications, not progress (#13896)."""
monkeypatch.setenv(
"ITERM_SESSION_ID", "w0t1p0:3DB6DF06-FE11-40C3-9A66-9E10A193A632"
)
with patch.object(sys.stdout, "isatty", return_value=True):
config = pytester.parseconfigure()
plugin = config.pluginmanager.get_plugin("terminalprogress")
assert plugin is None

@pytest.mark.parametrize(
["state", "progress", "expected"],
[
Expand Down