--- tests/test_serving.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) Index: Werkzeug-2.2.3/tests/test_serving.py =================================================================== --- Werkzeug-2.2.3.orig/tests/test_serving.py +++ Werkzeug-2.2.3/tests/test_serving.py @@ -10,6 +10,7 @@ from pathlib import Path import pytest +import werkzeug from werkzeug import run_simple from werkzeug._reloader import _find_stat_paths from werkzeug._reloader import _find_watchdog_paths @@ -128,12 +129,15 @@ def test_windows_get_args_for_reloading( @pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning") @pytest.mark.parametrize("find", [_find_stat_paths, _find_watchdog_paths]) def test_exclude_patterns(find): - # Imported paths under sys.prefix will be included by default. + # Don’t use sys.prefix, we may have redefined PYTHONPATH and + # libraries elsewhere. + cur_prefix = str(Path(werkzeug.__file__).parents[1]) + # Imported paths under cur_prefix will be included by default. paths = find(set(), set()) - assert any(p.startswith(sys.prefix) for p in paths) + assert any(p.startswith(cur_prefix) for p in paths) # Those paths should be excluded due to the pattern. - paths = find(set(), {f"{sys.prefix}*"}) - assert not any(p.startswith(sys.prefix) for p in paths) + paths = find(set(), {f"{str(cur_prefix)}*"}) + assert not any(p.startswith(cur_prefix) for p in paths) @pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")