[TIP] Testing specific code
Matt Harrison
matthewharrison at gmail.com
Tue Sep 1 14:46:02 PDT 2009
Folks-
I've been messing around more with pyconverage.el[0] 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...
cheers,
-matt
0 - http://panela.blog-city.com/ann_pycoverageel.htm
More information about the testing-in-python
mailing list