[pypy-dev] custom classes in applevel tests
pjenvey at underboss.org
Mon Apr 30 23:55:50 CEST 2012
On Apr 28, 2012, at 5:32 PM, Benjamin Peterson wrote:
> 2012/4/28 Timo Paulssen <timo at wakelift.de>:
>> Hello there,
>> I was writing a few test cases for numpypy to make sure it behaves like
>> numpy does when confronted with objects that have either an __int__, an
>> __index__ or both (rule of thumb: index is prefered, but int is accepted in
>> absence of index).
>> Now, I wrote six tests that use three custom objects (one set for getitem,
>> one set for setitem and one test each for int only, int and index and index
>> I couldn't put those classes outside the applevel test (this is about
>> pypy/module/micronumpy/test/test_numarray.py btw) because there's some kind
>> of separation going on there. I *thought* the way to do it was to put it
>> inside the applevel test class and have its name start with w_, but that
>> wasn't it either.
> Yes, this only works for functions. You probably want to use
> space.appexec in setup_class().
You can just make a w_ function that returns the class (better than an appexec blob). E.g. see get_MockRawIO in test_textio:
More information about the pypy-dev