[TIP] figleaf tests

C. Titus Brown ctb at msu.edu
Mon Jun 23 19:26:11 PDT 2008


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... :)

--titus



More information about the testing-in-python mailing list