Skip to content

Commit 32abab5

Browse files
Fix test isolation: reset backend/inferred_backend in autouse fixture
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/98169524-606e-47a4-9c6b-b498a66104d0 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
1 parent 62e9919 commit 32abab5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import pytest
88

99
from usethis._backend.uv.call import call_uv_subprocess
10-
from usethis._config import usethis_config
10+
from usethis._config import BACKEND_DEFAULT, usethis_config
1111
from usethis._console import _cached_warn_print, get_icon_mode
1212
from usethis._file.pyproject_toml.io_ import PyprojectTOMLManager
1313
from usethis._subprocess import call_subprocess
1414
from usethis._test import change_cwd, is_offline
1515
from usethis._tool.impl.spec.import_linter import _importlinter_warn_no_packages_found
16+
from usethis._types.backend import BackendEnum
1617

1718
if "UV_PYTHON" in os.environ:
1819
# To allow test subprocesses to use different versions of Python than the one
@@ -27,6 +28,9 @@ def clear_functools_caches():
2728
_cached_warn_print.cache_clear()
2829
get_icon_mode.cache_clear()
2930
_importlinter_warn_no_packages_found.cache_clear()
31+
# Reset backend state to prevent stale inferred_backend from contaminating tests.
32+
usethis_config.backend = BackendEnum(BACKEND_DEFAULT)
33+
usethis_config.inferred_backend = None
3034

3135

3236
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)