diff --git a/CHANGES b/CHANGES index 2a7db00c7..49143543f 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,12 @@ $ pip install --user --upgrade --pre libvcs - _Add your latest changes from PRs here_ +## libvcs 0.16.5 (unreleased) + +### Bug fixes + +- Use pytest's public API when importing (#418) + ## libvcs 0.16.4 (2022-09-18) ### Infrastructure diff --git a/src/libvcs/conftest.py b/src/libvcs/conftest.py index 7a89a3c6c..4dd3149ec 100644 --- a/src/libvcs/conftest.py +++ b/src/libvcs/conftest.py @@ -3,14 +3,14 @@ import pytest -from _pytest.doctest import DoctestItem - @pytest.fixture(autouse=True) def add_doctest_fixtures( request: pytest.FixtureRequest, doctest_namespace: t.Dict[str, t.Any], ) -> None: + from _pytest.doctest import DoctestItem + if isinstance(request._pyfuncitem, DoctestItem): request.getfixturevalue("add_doctest_fixtures") request.getfixturevalue("set_home") diff --git a/src/libvcs/pytest_plugin.py b/src/libvcs/pytest_plugin.py index b0ff5a241..d84891f53 100644 --- a/src/libvcs/pytest_plugin.py +++ b/src/libvcs/pytest_plugin.py @@ -9,9 +9,6 @@ import pytest -from _pytest.doctest import DoctestItem -from _pytest.fixtures import SubRequest - from libvcs._internal.run import run from libvcs.sync.git import GitRemote, GitSync from libvcs.sync.hg import HgSync @@ -410,7 +407,7 @@ def svn_repo(projects_path: pathlib.Path, svn_remote_repo: pathlib.Path) -> SvnS @pytest.fixture def add_doctest_fixtures( - request: SubRequest, + request: pytest.FixtureRequest, doctest_namespace: dict[str, Any], tmp_path: pathlib.Path, set_home: pathlib.Path, @@ -420,6 +417,8 @@ def add_doctest_fixtures( create_hg_remote_repo: CreateProjectCallbackFixtureProtocol, git_repo: pathlib.Path, ) -> None: + from _pytest.doctest import DoctestItem + if not isinstance(request._pyfuncitem, DoctestItem): # Only run on doctest items return doctest_namespace["tmp_path"] = tmp_path diff --git a/tests/test_pytest_plugin.py b/tests/test_pytest_plugin.py index 467a5c489..0b7707547 100644 --- a/tests/test_pytest_plugin.py +++ b/tests/test_pytest_plugin.py @@ -4,8 +4,6 @@ import pytest -import _pytest.pytester - from libvcs.pytest_plugin import CreateProjectCallbackFixtureProtocol @@ -34,7 +32,7 @@ def test_create_svn_remote_repo( def test_plugin( - pytester: _pytest.pytester.Pytester, + pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch, ) -> None: # Initialize variables