The problem is the command being invalid. Your shell /bin/bash
searches for an executable, in this case python
(try which python
to see where it is located), which in turn requires specific arguments.
If test
is the path, assuming you are one directory down, the correct command would be:
:!python -m unittest ../test
As garyjohn explained here, you can change the (sub) shell directory (the one created by bash
) with :!cd
. Yet another alternative is to set Vim's current directory (:pwd
) with :cd
.
You will also find tons of plugins fulfilling this use case (run a program in the background, linter or compiler for example), vim-test comes up as the first Google result.
There is Syntastic, a fully-featured syntax checker but lacks asynchronous capability, blocking the terminal while waiting for the program to run. That may change since Vim 8 supports async jobs.
If you run Neovim, Neomake is the perfect match.
Though I switched to the Asynchronous Lint Engine and I am still using it today.
If you use a lot of other filetypes as well, combine one of these linters with the language pack polyglot and you are good to go!