Skip to content

Can't run tests in a symlinked folder #22938

@roblourens

Description

@roblourens

Testing #22936

I click the run button and get this error in the Test Results pane

CLIENT: Server listening on port 61520...
Received JSON data in run script
Running pytest with args: ['-p', 'vscode_pytest', '--rootdir=/private/tmp/parent/symlink_to_target_folder', '/private/tmp/parent/symlink_to_target_folder/test_example.py::test_addition', '/private/tmp/parent/symlink_to_target_folder/test_example2.py::test_addition']
============================= test session starts ==============================
platform darwin -- Python 3.9.6, pytest-8.0.1, pluggy-1.4.0
rootdir: /private/tmp/parent/symlink_to_target_folder
collected 2 items
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/roblou/.vscode-insiders/extensions/ms-python.python-2024.1.10511008/pythonFiles/vscode_pytest/__init__.py", line 695, in get_node_path
INTERNALERROR>     rel_path = path.relative_to(pathlib.Path.cwd())
INTERNALERROR>   File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/pathlib.py", line 929, in relative_to
INTERNALERROR>     raise ValueError("{!r} is not in the subpath of {!r}"
INTERNALERROR> ValueError: '/private/tmp/parent/symlink_to_target_folder/test_example.py' is not in the subpath of '/private/tmp/parent/target_folder' OR one path is relative and the other is absolute.
INTERNALERROR> 
INTERNALERROR> During handling of the above exception, another exception occurred:
INTERNALERROR> 
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/main.py", line 273, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/main.py", line 327, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 138, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 121, in _multicall
INTERNALERROR>     teardown.throw(exception)  # type: ignore[union-attr]
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/logging.py", line 796, in pytest_runtestloop
INTERNALERROR>     return (yield)  # Run all the tests.
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 102, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/main.py", line 352, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_hooks.py", line 501, in __call__
INTERNALERROR>     return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_manager.py", line 119, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 181, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_result.py", line 99, in get_result
INTERNALERROR>     raise exc.with_traceback(exc.__traceback__)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/warnings.py", line 109, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/assertion/__init__.py", line 175, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/unittest.py", line 411, in pytest_runtest_protocol
INTERNALERROR>     res = yield
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 166, in _multicall
INTERNALERROR>     teardown.throw(outcome._exception)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/_pytest/faulthandler.py", line 85, in pytest_runtest_protocol
INTERNALERROR>     return (yield)
INTERNALERROR>   File "/private/tmp/parent/target_folder/.venv/lib/python3.9/site-packages/pluggy/_callers.py", line 87, in _multicall
INTERNALERROR>     next(wrapper_gen)  # first yield
INTERNALERROR>   File "/Users/roblou/.vscode-insiders/extensions/ms-python.python-2024.1.10511008/pythonFiles/vscode_pytest/__init__.py", line 272, in pytest_runtest_protocol
INTERNALERROR>     map_id_to_path[item.nodeid] = get_node_path(item)
INTERNALERROR>   File "/Users/roblou/.vscode-insiders/extensions/ms-python.python-2024.1.10511008/pythonFiles/vscode_pytest/__init__.py", line 701, in get_node_path
INTERNALERROR>     raise VSCodePytestError(
INTERNALERROR> vscode_pytest.VSCodePytestError: Error occurred while calculating symlink equivalent from node path: '/private/tmp/parent/symlink_to_target_folder/test_example.py' is not in the subpath of '/private/tmp/parent/target_folder' OR one path is relative and the other is absolute.
INTERNALERROR>  SYMLINK_PATH: {SYMLINK_PATH}, 
INTERNALERROR>  node path: {path}, 
INTERNALERROR>  cwd: {{pathlib.Path.cwd()}}
Plugin warning[vscode-pytest]: SYMLINK set, adjusting cwd.

============================ no tests ran in 0.08s =============================
Finished running tests!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions