vim-test icon indicating copy to clipboard operation
vim-test copied to clipboard

Python unit tests cannot be executed

Open sleepyhollo opened this issue 2 years ago • 3 comments

Bug Report

Current Behavior

Attempting a run a python test with vim-test fails with "python not found" error

Expected Behavior

Vim-test should be able to run the test.

Additional context/output

"python3 -m unittest tests.NAME_OF_TEST"
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

shell returned 9009

Press ENTER or type command to continue

Possible Solution

Maybe the issue is in the pyunit.vim file (here)). The plugin tries to use python3 when running the UTs in windows; apparently, windows does not have python3 support (stackoverflow answer).

Two solution approaches come to mind:

  1. Monkey patching that file to use python instead of python3
  2. adding a batch file accessible to path that links python3 to python. Note that the batch file should be accessible before window system files, otherwise it may start the windows app store when you run python3. Specifically, this means the path to where the batch file should be before the system paths in the environments PATH variable.

System details

Windows version: 10 OS architecture: 64 bit PowerShell version: 5.1.19041.3031 Additional software: I am having this problem when i am running vim from command prompt using the Windows Terminal Preview SW. However, the issue also happens with CMD

sleepyhollo avatar Jul 03 '23 15:07 sleepyhollo

What version of Python do you have installed and what Python test runner are you using?

codeinabox avatar Jul 07 '23 16:07 codeinabox

I've added logic https://github.com/vim-test/vim-test/pull/750 to detect the Python executable, so could you please update the plugin and try again

codeinabox avatar Aug 09 '23 10:08 codeinabox

Hello @sleepyhollo, could you please let me know if the latest version of vim-test fixes this issue

codeinabox avatar Jan 13 '24 17:01 codeinabox