[pypy-dev] Re: Objects and types in the stdobjspace

Michael Hudson mwh at python.net
Thu Jun 12 14:10:22 MEST 2003


Michael Hudson <mwh at python.net> writes:

> roccomoretti at netscape.net (Rocco Moretti) writes:
>
>> Michael Hudson <mwh at python.net> wrote:
>>
>>>roccomoretti at netscape.net (Rocco Moretti) writes:
>>
>>>> Secondly, the testing framework as written will only run tests at the
>>>> interpreter level. Some tests (such as test_exceptcomp and test_exec)
>>>> should be run at the application level.
>>>
>>>Yes.  I don't see how to easily and gracefully allow this.
>>
>> Naming convention? test_excptcomp_app.py and test_exec_app.py for example?
>
> Could do.  But what would such a file look like?  I don't think pypy
> can import unittest yet, and I doubt that's something we really want
> to do.

I've had another idea: give unittest_w.TestCase_w a metaclass that
looks for methods called 'test_app_whatever' and arrange for such
methods to be called as objectspace methods.

So, e.g. 

    def test_trivial(self):
        x = self.codetest('''
def g(): return 42''', 'g', [])
        self.assertEquals(x, 42)

becomes:

    def test_app_trivial(self):
        def g():
            return 42
        self.assertEquals(g(), 42)

I have an implementation of this (attached), but it was significantly
more of a pain than I would have liked (mostly because 2.2's unittest
doesn't cope with TestCase classes being new-style...).

It also only works in the standard object space, and only really works
there by fluke (it's the self.assertEquals business that casues the
problems -- can probably try harder and come up with a better solution).

Cheers,
M.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: app-space-tests.diff
Type: text/x-patch
Size: 10635 bytes
Desc: not available
Url : http://codespeak.net/pipermail/pypy-dev/attachments/20030612/156c285d/app-space-tests.bin
-------------- next part --------------

-- 
  And then the character-only displays went away (leading to
  increasingly silly graphical effects and finally to ads on
  web pages).                      -- John W. Baxter, comp.lang.python


More information about the pypy-dev mailing list