[TIP] Testing specific code

Matt Harrison matthewharrison at gmail.com
Thu Sep 3 13:20:07 PDT 2009

On Thu, Sep 3, 2009 at 1:20 PM, <exarkun at twistedmatrix.com> wrote:
> Twisted has some emacs integration code that binds F8 to run the tests for
> the active buffer.  If it's a test module, then it just runs that module.
>  If it's not, then it uses the buffer local 'test-case-name' to decide what
> tests to run.  Such variables are defined by a line like:
> # -*- test-case-name: foo.bar,baz.quux -*-
> Trial adopts this convention as well and can be asked to run the tests which
> apply to a particular module.

This sounds interesting.  A quick search for twisted emacs doesn't
reveal much.  Do you happen to know where this code lives?  I'd like
to be inspired by any good chunks in it :)

> As you say, this isn't as granular as just running the tests for a
> particular line or function.  I find that it's basically good enough,
> though.  I don't have any modules that have more than a handful of seconds
> worth of tests.
> I've also worked on a coverage collection tool.  I've thought about plugging
> this information into the test discovery code, so that the exact set of
> tests for a function can be run, with knowledge of what that set is derived
> from what previous test runs have done.  However, since the test-case-name
> thing works well enough now, I'm not really motivated to implement that.

As I mention in a previous reply, the exact set should be determinable
from walking up the call graph.  But if your current method is
sufficiently good, I'd like to give it a go.

More information about the testing-in-python mailing list