Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]

### Fixed
- [#4165](https://github.com/plotly/dash/pull/4165) Use `@pytest.hookimpl(tryfirst=True)` on `pytest_addhooks` in `dash.testing.plugin` to eliminate `PytestRemovedIn10Warning` during pytest plugin registration and preserve compatibility with pytest 10. Fixes [#2420](https://github.com/plotly/dash/issues/2420).

## [4.5.1] - 2026-11-19

### Removed
Expand Down
2 changes: 1 addition & 1 deletion dash/testing/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def pytest_addoption(parser):
)


@pytest.mark.tryfirst
@pytest.hookimpl(tryfirst=True)
def pytest_addhooks(pluginmanager):
if not _installed:
return
Expand Down
21 changes: 20 additions & 1 deletion tests/unit/test_testing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
from dash.testing import ignore_register_page
import warnings

import pluggy
import pytest

from dash.testing import ignore_register_page, plugin
from dash import register_page


def test_tst001_ignore_register_page():
with ignore_register_page():
register_page("/")


def test_tst002_pytest_addhooks_uses_hookimpl():
opts = pluggy.PluginManager("pytest").parse_hookimpl_opts(plugin, "pytest_addhooks")
assert opts is not None and opts.get("tryfirst") is True

Check warning on line 17 in tests/unit/test_testing.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this composite assertion into separate assertions.

See more on https://sonarcloud.io/project/issues?id=plotly_dash&issues=AaH6D-O3V4gfAhYvARy0&open=AaH6D-O3V4gfAhYvARy0&pullRequest=4165

pm = pytest.PytestPluginManager()
with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always")
pm.register(plugin, name="dash_testing_hookimpl_check")
pm.unregister(name="dash_testing_hookimpl_check")

hook_warnings = [w for w in caught if "pytest_addhooks" in str(w.message)]
assert hook_warnings == []
Loading