
Michael Hudson <mwh@python.net> wrote:
Michael Hudson <mwh@python.net> writes:
roccomoretti@netscape.net (Rocco Moretti) writes:
Before I realized that metaclasses were involved, I first thought of using a special subclass of TestCase - probably by overloading TestCase.__call__() to appropriately wrap the function before it is run.
Yes, that would probably work.
And it does, after a fashion. Well, it works fine as far as I can tell, it's just that running the assertFoo methods in app-space *too* (what the attached does) isn't ideal. OTOH, the fact that doing so *works* is something we can be proud of.
Glad to hear it works! Re: running method in appspace - I hoped that was something that was "fixed" with the addition of the PyByteCode Object. I'm assuming (as I wasn't at the sprint and haven't heard about it otherwise) that a regular bytecode object gets run on the CPython interpreter, and a PyByteCode object gets run on the PyPy interpreter. Although that's what I assume, I haven't been able to confirm this in the code, as I loose track of the control flow after calling ObjSpace.call(). (I started tracking from the CALL_FUNCTION opcode in opcode.py)
The only decision to be made is: do we distinguish between app-space tests by a naming convention (as attached: any test starting test_app_ runs in app space) or by inheriting from a different TestCase subclass? I can't make my mind up which I prefer.
I'd vote for seperate TestCases. App space should be suitably separated from interpreter level such that we avoid confusion. This also allows setup () and teardown() methods to work semi-sanely. It will also give a consistent interface to the assert*() methods (whether they are being called from interpreter level or app. level.)
In either case, I want to check something like this in, soon. The implementation can be made more elegant/faster in due course.
I'm +1 on checkin - as you say, it doesn't break anything, and we can always improve it later. -Rocco __________________________________________________________________ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now! http://aim.aol.com/aimnew/Aim/register.adp?promo=380455