Author: mattip <matti.pi...@gmail.com>
Branch: 
Changeset: r59410:5b0bb368c5e1
Date: 2012-12-12 14:35 -0800
http://bitbucket.org/pypy/pypy/changeset/5b0bb368c5e1/

Log:    fix tests for -A

diff --git a/pypy/module/micronumpy/test/test_complex.py 
b/pypy/module/micronumpy/test/test_complex.py
--- a/pypy/module/micronumpy/test/test_complex.py
+++ b/pypy/module/micronumpy/test/test_complex.py
@@ -94,30 +94,42 @@
         cls.w_testcases128 = cls.space.wrap(list(parse_testfile(fname128)))
         cls.w_testcases64 = cls.space.wrap(list(parse_testfile(fname64)))
 
-        def cls_c_pow(space, args_w):
-            try:
-                retVal = c_pow(*map(space.unwrap, args_w))
-                return space.wrap(retVal)
-            except ValueError, e:
-                if option.runappdirect:
-                    raise
-                raise OperationError(cls.space.w_ValueError,
-                        cls.space.wrap(e.message))
-        cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
         cls.w_runAppDirect = cls.space.wrap(option.runappdirect)
         cls.w_isWindows = cls.space.wrap(os.name == 'nt')
 
-        def cls_rAlmostEqual(space, __args__):
-            args, kwargs = __args__.unpack()
-            args = map(space.unwrap, args)
-            kwargs = dict([
-                (k, space.unwrap(v))
-                for k, v in kwargs.iteritems()
-            ])
-            if '__pypy__' not in sys.builtin_module_names:
-                kwargs['isnumpy'] = True
-            return space.wrap(rAlmostEqual(*args, **kwargs))
-        cls.w_rAlmostEqual = cls.space.wrap(interp2app(cls_rAlmostEqual))
+        if cls.runappdirect:
+            def cls_rAlmostEqual(space, *args, **kwargs):
+                return rAlmostEqual(*args, **kwargs)
+            cls.w_rAlmostEqual = cls.space.wrap(cls_rAlmostEqual)
+            def cls_c_pow(space, *args):
+                return c_pow(*args)
+            cls.w_c_pow = cls.space.wrap(cls_c_pow)
+        else:
+            def cls_rAlmostEqual(space, __args__):
+                args, kwargs = __args__.unpack()
+                args = map(space.unwrap, args)
+                kwargs = dict([
+                    (k, space.unwrap(v))
+                    for k, v in kwargs.iteritems()
+                ])
+                if '__pypy__' not in sys.builtin_module_names:
+                    kwargs['isnumpy'] = True
+                return space.wrap(rAlmostEqual(*args, **kwargs))
+            cls.w_rAlmostEqual = cls.space.wrap(interp2app(cls_rAlmostEqual))
+            def cls_c_pow(space, args_w):
+                try:
+                    retVal = c_pow(*map(space.unwrap, args_w))
+                    return space.wrap(retVal)
+                except ZeroDivisionError, e:
+                    raise OperationError(cls.space.w_ZeroDivisionError,
+                            cls.space.wrap(e.message))
+                except OverflowError, e:
+                    raise OperationError(cls.space.w_OverflowError,
+                            cls.space.wrap(e.message))
+                except ValueError, e:
+                    raise OperationError(cls.space.w_ValueError,
+                            cls.space.wrap(e.message))
+            cls.w_c_pow = cls.space.wrap(interp2app(cls_c_pow))
 
     def test_fabs(self):
         from _numpypy import fabs, complex128
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to