Let's use TextMate to run the currently highlighted test in pytest.


TextMate is a cult favorite, and believe it or not it's actively supported and developed1.

TextMate has a rich toolkit for developers, including the ability to create Commands.

What are Commands?

Commands are scripts executed by the interpreter of your choice2. They can be created in Python, Bash, or any language you choose. For the example below, we'll work in bash.

  1. https://github.com/textmate/textmate/commits/master
  2. https://manual.macromates.com/en/commands

The Command


/usr/local/bin/pytest ${TM_FILEPATH} -k ${TM_CURRENT_WORD}

Try it out

This command is available to download via Dropbox, and also on Github.

To install:

  1. Double-click the .tmCommand file.
  2. TextMate will prompt you to select a bundle.
  • If you have a custom bundle, choose that one.
  • If you don't, choose Python.
  1. Click 'OK'
  2. You can now use the command by pressing F19.
  • You can customize this by editing the command.