Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on additional workspace folders that do not have a virtual environment #283

Open
MSLeiter opened this issue May 6, 2022 · 1 comment

Comments

@MSLeiter
Copy link

MSLeiter commented May 6, 2022

I'm getting the following error with the Python Test adapter and Pytest:
image

All the errors have a message like the following:

Test loading failed: Error: Error occurred during process execution: Error: spawn d:\code\mca_app\_simulink\.venv\Scripts\python.exe ENOENT
Error: Error occurred during process execution: Error: spawn d:\code\mca_app\_simulink\.venv\Scripts\python.exe ENOENT
	at ChildProcess.<anonymous> (c:\Users\Mike.Leiter\.vscode\extensions\littlefoxteam.vscode-python-test-adapter-0.7.1\out\src\processRunner.js:37:28)
	at Object.onceWrapper (events.js:422:26)
	at ChildProcess.emit (events.js:315:20)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
	at onErrorNT (internal/child_process.js:465:16)
	at processTicksAndRejections (internal/process/task_queues.js:80:21)

This is a workspace where I have added a bunch of reference folders that are not part of my code, but they have files I want to search, copy from, etc.

The extension is working great in Python folders that are properly setup for Pytest (though I don't really want it to run in folders that aren't part of this codebase - I don't see a way to stop it though). It appears for the errors that the Test Explorer is attempting to run pytest from a virtual environment in each folder. i.e. the Python Interpreter is setup as "./.venv" and therefore the Test Explorer is going to every folder in the workspace and running Python as though there must be a "./.venv" virtual environment in each folder. When it can't find the ./.venv/Scripts/python.exe file to run pytest with, it errors out.

Assuming this is the issue, I suggest a something like:

  1. In each workspace folder, check if the python executable exists as a file, if not, do not run discovery on that folder. It should probably display somehow that the folder was ignored - perhaps leave an entry for the folder in the list, but instead of a big, red error icon, add some neutral icon with a comment that the folder was ignored. If the user clicks on that row, it should still open the the output window where some additional details could be given (i.e. 'For folder "x", Python executable "y" could not be found. Skipping test discovery'.)
  2. Still give us an error (though a more understandable message would be great), but give us a way of turning off discovery for any given folder with a setting. Preferably, you could add folders to the list by just right-clicking them in the test explorer window and selecting a new option like "ignore this folder for test discovery in this workspace".

One or both of the above. I'd love to be able to quickly tell the test explorer to ignore several folders that I don't want it to discover tests in.

@kondratyev-nv
Copy link
Owner

@MSLeiter Thank you for the issue! Hm, maybe I'm missing something in your configuration, but the extension won't attempt to discover tests by default. Test discovery is triggered when one of the python.testing.unittestEnabled, python.testing.pyTestEnabled, or pythonTestExplorer.testFramework options is set. Is it possible that you see this error because you've enabled test discovery globally (e.g. in User settings or System settings)? Does it make sense for you to move this to the workplace settings?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants