From 61cc16de5531b84c504e6e53f80b6d67b334ac61 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 21 Sep 2022 19:31:10 -0500 Subject: [PATCH 1/4] fix(pytest_plugin): Fix typing --- src/libvcs/pytest_plugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libvcs/pytest_plugin.py b/src/libvcs/pytest_plugin.py index b0ff5a241..9787e53b7 100644 --- a/src/libvcs/pytest_plugin.py +++ b/src/libvcs/pytest_plugin.py @@ -10,7 +10,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 @@ -410,7 +409,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, From f6b88f4c9e99409698feb10584aa3d719b0b4fb8 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 21 Sep 2022 19:32:16 -0500 Subject: [PATCH 2/4] fix(pytest_plugin,tests): Import DoctestItem deeper --- src/libvcs/conftest.py | 4 ++-- src/libvcs/pytest_plugin.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 9787e53b7..d84891f53 100644 --- a/src/libvcs/pytest_plugin.py +++ b/src/libvcs/pytest_plugin.py @@ -9,8 +9,6 @@ import pytest -from _pytest.doctest import DoctestItem - from libvcs._internal.run import run from libvcs.sync.git import GitRemote, GitSync from libvcs.sync.hg import HgSync @@ -419,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 From 5e5764b9dbe8e0ee2dcea8447954fba4831371f2 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 21 Sep 2022 19:39:54 -0500 Subject: [PATCH 3/4] fix(test_pytest_plugin): Use public API import for Pytester --- tests/test_pytest_plugin.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 From 4812d741442384de26fb7a95f9398a3014532d20 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 21 Sep 2022 19:40:58 -0500 Subject: [PATCH 4/4] docs(CHANGES): Note API tweaks --- CHANGES | 6 ++++++ 1 file changed, 6 insertions(+) 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