[TIP] figleaf tests

Ondrej Certik ondrej at certik.cz
Mon Jun 23 23:32:19 PDT 2008

On Tue, Jun 24, 2008 at 4:26 AM, C. Titus Brown <ctb at msu.edu> wrote:
> On Mon, Jun 23, 2008 at 09:37:41PM -0400, Ned Batchelder wrote:
> -> I've been down these paths too, and I completely understand Titus' wariness.
> ->
> -> I think the stdlib module trace.py has the right idea: rather than
> -> analyze the code at all, simply compile it, and look at the table of
> -> line numbers in the code object.  This is by definition the set of lines
> -> that sys.settrace can return, and is very simple to read.  It has the
> -> advantage that as the compiler changes from version to version, changing
> -> the lines that can be returned, trace.py is immune to the changes.
> Hmm, I didn't realize that the table of line numbers in the code object
> is the set of lines that can be returned by sys.settrace!  That makes my
> life *much* easier, thanks!
> -> For more exotic ideas along these lines, you can lie about line numbers:
> -> http://nedbatchelder.com/blog/200804/wicked_hack_python_bytecode_tracing.html
> Ummm... :)

Wow, I didn't know that, thanks Ned!

I was just playing with:


and it really works and produce the correct line numbers. :)

So now we just need to adapt your line hack example from:


and that should be it.

I am also actually flying soon, but I'll try to hack on it in the plane.


More information about the testing-in-python mailing list