diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7f85609..1158377 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,7 +40,7 @@ jobs: - uses: actions/checkout@v6 - name: Download Package - uses: actions/download-artifact@v7 + uses: actions/download-artifact@v8 with: name: Packages path: dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9cc7d1e..ef2b68a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v6 - name: Download Package - uses: actions/download-artifact@v7 + uses: actions/download-artifact@v8 with: name: Packages path: dist diff --git a/tests/test_pytest_mock.py b/tests/test_pytest_mock.py index 79d59e1..7be5729 100644 --- a/tests/test_pytest_mock.py +++ b/tests/test_pytest_mock.py @@ -28,6 +28,16 @@ NEWEST_FORMATTING = sys.version_info >= (3, 11, 7) +def syspath_insert_workaround(request: pytest.FixtureRequest, testdir: Any) -> None: + if pytest.__version__.split(".")[0] == "6": + # Avoid testdir.syspathinsert() which requires pkg_resources (setuptools) in + # pytest 6.2.5; insert directly instead (#169). + sys.path.insert(0, str(testdir.tmpdir)) + request.addfinalizer(lambda: sys.path.remove(str(testdir.tmpdir))) + else: + testdir.syspathinsert() + + @pytest.fixture def needs_assert_rewrite(pytestconfig): """ @@ -517,7 +527,9 @@ class Foo(Base): assert spy.spy_return_list == [20] -def test_callable_like_spy(testdir: Any, mocker: MockerFixture) -> None: +def test_callable_like_spy( + testdir: Any, mocker: MockerFixture, request: pytest.FixtureRequest +) -> None: testdir.makepyfile( uut=""" class CallLike(object): @@ -527,7 +539,7 @@ def __call__(self, x): call_like = CallLike() """ ) - testdir.syspathinsert() + syspath_insert_workaround(request, testdir) uut = __import__("uut") @@ -1158,7 +1170,7 @@ def doIt(self): assert len(warn_record) == 0 -def test_abort_patch_context_manager_with_stale_pyc(testdir: Any) -> None: +def test_abort_patch_context_manager_with_stale_pyc(testdir: Any, request: Any) -> None: """Ensure we don't trigger an error in case the frame where mocker.patch is being used doesn't have a 'context' (#169)""" import compileall @@ -1173,7 +1185,7 @@ def check(mocker): assert C.x == 2 """ ) - testdir.syspathinsert() + syspath_insert_workaround(request, testdir) testdir.makepyfile( """