I'm writing some threaded python code in vim. When I run my tests, with
:! py.test test_me.py
Sometimes they hang and cannot be killed with ctrl-C. So I have to background vim (actually the shell the tests are running in) and pkill py.test. Is there a better way to kill the hanging test suite? 
I tried mapping :map ,k:! pkill py.test but this doesn't work since while the tests are running my input is going to the shell running the test, not vim.
EDIT:
I'm looking for a way to kill the test process that is quicker than ctrl-Z, pkill py.test, fg <cr> to return to editing. Ideally just a hotkey.
When you do :! in Vim, you effectively put Vim into background and the running process, in this case py.test, gets the focus. That means you can't tell Vim to kill the process for you since Vim is not getting keystrokes from you.
Ctrl-Z puts Vim into background while running py.test because Vim is the parent process of py.test. Thus the shell goes through the chain then puts all children as well as the parent into background.
I would suggest that you open another terminal window and do all the housekeeping chores there.
kill a shell created by vim when ctrl-C doesn't work