[TIP] Testing specific code
matthewharrison at gmail.com
Thu Sep 3 13:09:49 PDT 2009
On Tue, Sep 1, 2009 at 10:43 PM, C. Titus Brown<ctb at msu.edu> wrote:
> On Tue, Sep 01, 2009 at 03:46:02PM -0600, Matt Harrison wrote:
> -> I've been messing around more with pyconverage.el and have
> -> 'flymake-mode' enabled it. (For non-emacites, flymake-mode invokes a
> -> callback during save/editing to highlight borked code). So if you
> -> enable flymake-mode to show coverage data it will try and find a
> -> .coverage file and report on missing lines in your code.
> -> There's somewhat of a impedance mismatch between coverage code and
> -> flymake-mode, in that once you edit a file, there's no guarantees
> -> about line numbers matching up. As an idea to help deal with that and
> -> to help focus coverage attention on specific code points, I thought of
> -> an idea. (I'm assuming others here have probably thought of it before
> -> to). What I'd like to do is have a (emacs) command that says 'run
> -> tests for this function/method'. Then something
> -> (nose??/plugin??/emacs??) goes and finds tests that invoke that method
> -> and only runs those tests and reports coverage for them. A naive
> -> implementation would be a simple regex match for the function name and
> -> then look to see if it resides in a test. That way you can edit your
> -> codes and your tests and quickly retrieve relevant coverage
> -> information. Does this make sense?
> -> So before I go off and implement this I thought I'd ask if it already
> -> exists. I can't find it. Also feedback is good. Is there a better
> -> method/workflow? I'd imagine other's might find such functionality
> -> useful even without coverage information. ie when you are looking
> -> at/developing tests for code that is new to you. I would think a nose
> -> plugin would work best...
> Hi, Matt,
> this seems like a good use case for figleaf-sections, actually:
> You would be able to look up which tests executed the line of code or
> function in question...
Thanks for the hint. Looks like I'll have to add figleaf support now.
More information about the testing-in-python