From 1ed9150a667f631aa7115ae4eab2b25d1a59bcae Mon Sep 17 00:00:00 2001 From: Mark Colley Date: Fri, 20 Nov 2026 17:44:20 +0000 Subject: [PATCH 1/2] Fix pytest_addhooks deprecated tryfirst marker (#2420) --- CHANGELOG.md | 5 +++++ dash/testing/plugin.py | 2 +- tests/unit/test_testing.py | 21 ++++++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef3c33f9cf..03b600350e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 +- 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 diff --git a/dash/testing/plugin.py b/dash/testing/plugin.py index 1b917d7657..5146fc31a6 100644 --- a/dash/testing/plugin.py +++ b/dash/testing/plugin.py @@ -101,7 +101,7 @@ def pytest_addoption(parser): ) -@pytest.mark.tryfirst +@pytest.hookimpl(tryfirst=True) def pytest_addhooks(pluginmanager): if not _installed: return diff --git a/tests/unit/test_testing.py b/tests/unit/test_testing.py index b9c1cca344..b27a13bcad 100644 --- a/tests/unit/test_testing.py +++ b/tests/unit/test_testing.py @@ -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 + + 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 == [] From 8311d5cbe518907af8d2a9c6a334a8e5c5e95f6c Mon Sep 17 00:00:00 2001 From: Mark Colley Date: Fri, 20 Nov 2026 17:44:51 +0000 Subject: [PATCH 2/2] Add PR #4165 link to CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b600350e..a8620508ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ## [UNRELEASED] ### Fixed -- 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). +- [#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