Skip to content

Can't run tests in a symlinked folder #22938

Closed

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!

Activity

  1. roblourens commented on Feb 20, 2024

    @roblourens
    MemberAuthor

    This log is from macOS, because I didn't check my assigned OS, but I tried again on Linux and got exactly the same result.

  2. eleanorjboyd commented on Feb 20, 2024

    @eleanorjboyd
    Member

    Thank you! I will investigate this since it is a clear error

  3. roblourens commented on Mar 5, 2024

    @roblourens
    MemberAuthor

    FYI I noticed that since this has no labels or milestone, it was not part of the verification query

  4. eleanorjboyd commented on Mar 7, 2024

    @eleanorjboyd
    Member

    Thank you for the note! I had it as a TPI but this is a good callout that I didn't label it correctly.

  5. added 2 commits that reference this issue on Mar 28, 2024
  6. locked as resolved and limited conversation to collaborators on Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions