My favorites | Sign in
Project Logo
                
Search
for
Updated Apr 07, 2007 by kumar.mcmillan
Labels: Featured
Recipes  

Recipes for using nosetty. Feel free to email or submit additions. Thanks!

Using nosetty with outputsave

If you have the outputsave plugin installed and enabled, say, with options like...

nosetests --tty --with-outputsave --save-directory=output

then if there was a capture, you get a new command prompt:

type "o" to open stdout

Using nosetty with your editor

Nosetty is designed to run in a shell and communicate with an external editor (it supports several). This is just one way to do things. If you want to run nosetests within your editor itself, you may want to try the machineout plugin by Max Ischenko. That said, nosetty works best with editor commands that activate a separate GUI application (a forked process), so that control isn't lost in the shell you are running tests in. However, this is just convenient, not mandatory.

NOTE : The following options can also be set by environment variables. see nosetests --help for details. Also, the standard $EDITOR variable will be recognized as a last-resort default for --tty-editor. This means that the default configuration of nosetty might even work for your editor.

Specifying an edit command

The command line option --tty-edit-cmd can contain one or more of the following format strings:

  • %(editor)s
    • replaced with the value of --tty-editor
  • %(lineno)s
    • replaced with the line number of the trace point selected. this might be 0 if no line number can be detected
  • %(lineindex)s
    • new in 0.3.6
    • replaced with a zero-based line number
  • %(filename)s
    • replaced with the absolute path to file of the trace point selected.

The default value of --tty-edit-cmd is the one that works in the most editors: %(editor)s +%(lineno)s %(filename)s

Emacs

for emacs/emacsclient:

First make sure you're running emacs server -- put (server-start) in your .emacs, or if you just want to try, put it in some elisp file, select it, and M-x eval-region.

nosetests --tty --tty-editor=emacsclient --tty-edit-cmd="%(editor)s +%(lineno)s %(filename)s"

This will pop the file up in a new buffer (if you didn't already have it open, or bring up the old buffer if you did)... make your edits, then C-x # to send it back to emacsclient, which will exit, and you can continue on your merry way in the tty.

NOTE: if you're trying out the emacs snapshot on ubuntu, but haven't chosen it as your active version yet, set --tty-editor=emacsclient.emacs-snapshot

VIM

For use with gvim (the GUI version of vim) :

nosetests --tty --tty-editor=gvim --tty-edit-cmd="%(editor)s --remote +%(lineno)s %(filename)s"

TextMate

To interact with TextMate for Mac OS X using its mate command:

nosetests --tty --tty-editor=mate --tty-edit-cmd="%(editor)s %(filename)s --line %(lineno)s"

This will open the file if not already open, or else bring it to the front.

TextWrangler

You can interact with TextWrangler for Mac OS X using its edit command. The Installer prompts you to install edit but if you don't have it on your system there is an "Install Command Line Tools" button in the preferences.

nosetests --tty --tty-editor=edit --tty-edit-cmd="%(editor)s +%(lineno)s %(filename)s"

BBEdit

...Exactly like TextWrangler above except the editor option is --tty-editor=bbedit. The same "Install Command Line Tools" button exists in preferences if you installed BBEdit without the bbedit command.

Kate (KDE Advanced Text Editor)

To use Kate with nosetty one can simply do:

nosetests --tty --tty-editor=kate --tty-edit-cmd="%(editor)s -u -l %(lineindex)s %(filename)s"

Sign in to add a comment
Hosted by Google Code