[py-dev] revision 7936 makes it harder to see failing source compiled from a string

holger krekel hpk at trillke.net
Wed Dec 22 11:39:05 CET 2004


On Tue, Dec 21, 2004 at 20:21 -0600, Matthew Scott wrote:

> Love py.test!  :)

great to hear! 
 
> But for now, I find that I am going to revert to revision 7935 and stay 
> at that for a little while 'til the dust settles.

i see. 
 
> Here's why.  Take this test which canonically distills the problem:
> 
> # test_7935_vs_7936.py
> import imp
> from py.magic.dyncode import compile
> import sys
> def test_it():
>     src = 'def foo():\n assert 1 == 0\n'
>     name = 'abc-123'
>     module = imp.new_module(name)
>     code = compile(src, name, 'exec')
>     exec code in module.__dict__
>     sys.modules[name] = module
>     module.foo()
> 
> If you run it against revision 7936 or higher, you get the following 
> error as the cause of the failure:

OK, 7935/7936 was indeed the middle of some larger refactoring. 

I have added your above test so that 

    py.test py/documentation/example/test/failure_demo.py 

will show the output.  Please look at the end of that file
to see the way this is done now.  (it's basically the 
same as above but the py.magic.dyncode.* namespace is gone 
in favour of more higher level introspection/dynamic code helpers 
in py.code.*).  Feedback appreciated although i figure
i need to write some documetnation about py.code first 
unless you are willing to look a bit at the tests especially
in py/code/testing/test_source.py ... 

have fun, 

    holger



More information about the Pytest-dev mailing list