[Numpy-svn] r8284 - trunk/numpy/f2py/tests

numpy-svn@scip... numpy-svn@scip...
Sat Mar 6 17:58:48 CST 2010


Author: ptvirtan
Date: 2010-03-06 17:58:48 -0600 (Sat, 06 Mar 2010)
New Revision: 8284

Modified:
   trunk/numpy/f2py/tests/test_return_character.py
   trunk/numpy/f2py/tests/test_return_complex.py
   trunk/numpy/f2py/tests/test_return_integer.py
   trunk/numpy/f2py/tests/test_return_logical.py
   trunk/numpy/f2py/tests/test_return_real.py
Log:
3K: f2py: don't use test generators in the tests -- they don't really work on Nose on Py3

Modified: trunk/numpy/f2py/tests/test_return_character.py
===================================================================
--- trunk/numpy/f2py/tests/test_return_character.py	2010-03-06 23:58:28 UTC (rev 8283)
+++ trunk/numpy/f2py/tests/test_return_character.py	2010-03-06 23:58:48 UTC (rev 8284)
@@ -1,24 +1,25 @@
 from numpy.testing import *
 from numpy import array
+from numpy.compat import asbytes
 import util
 
 class TestReturnCharacter(util.F2PyTest):
-    def _check_function(self, t):
+    def check_function(self, t):
         tname = t.__doc__.split()[0]
         if tname in ['t0','t1','s0','s1']:
-            assert t(23)=='2'
-            r = t('ab');assert r=='a',`r`
-            r = t(array('ab'));assert r=='a',`r`
-            r = t(array(77,'u1'));assert r=='M',`r`
+            assert t(23)==asbytes('2')
+            r = t('ab');assert r==asbytes('a'),`r`
+            r = t(array('ab'));assert r==asbytes('a'),`r`
+            r = t(array(77,'u1'));assert r==asbytes('M'),`r`
             #assert_raises(ValueError, t, array([77,87]))
             #assert_raises(ValueError, t, array(77))
         elif tname in ['ts','ss']:
-            assert t(23)=='23        ',`t(23)`
-            assert t('123456789abcdef')=='123456789a'
+            assert t(23)==asbytes('23        '),`t(23)`
+            assert t('123456789abcdef')==asbytes('123456789a')
         elif tname in ['t5','s5']:
-            assert t(23)=='23   ',`t(23)`
-            assert t('ab')=='ab   ',`t('ab')`
-            assert t('123456789abcdef')=='12345'
+            assert t(23)==asbytes('23   '),`t(23)`
+            assert t('ab')==asbytes('ab   '),`t('ab')`
+            assert t('123456789abcdef')==asbytes('12345')
         else:
             raise NotImplementedError
 
@@ -73,13 +74,8 @@
 
     def test_all(self):
         for name in "t0,t1,t5,s0,s1,s5,ss".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module, name))
 
-    def check_function(self, name):
-        t = getattr(self.module, name)
-        self._check_function(t)
-
-
 class TestF90ReturnCharacter(TestReturnCharacter):
     suffix = ".f90"
     code = """
@@ -135,12 +131,8 @@
 
     def test_all(self):
         for name in "t0,t1,t5,ts,s0,s1,s5,ss".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module.f90_return_char, name))
 
-    def check_function(self, name):
-        t = getattr(self.module.f90_return_char, name)
-        self._check_function(t)
-
 if __name__ == "__main__":
     import nose
     nose.runmodule()

Modified: trunk/numpy/f2py/tests/test_return_complex.py
===================================================================
--- trunk/numpy/f2py/tests/test_return_complex.py	2010-03-06 23:58:28 UTC (rev 8283)
+++ trunk/numpy/f2py/tests/test_return_complex.py	2010-03-06 23:58:48 UTC (rev 8284)
@@ -3,7 +3,7 @@
 import util
 
 class TestReturnComplex(util.F2PyTest):
-    def _check_function(self, t):
+    def check_function(self, t):
         tname = t.__doc__.split()[0]
         if tname in ['t0','t8','s0','s8']:
             err = 1e-5
@@ -99,13 +99,9 @@
 
     def test_all(self):
         for name in "t0,t8,t16,td,s0,s8,s16,sd".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module, name))
 
-    def check_function(self, name):
-        t = getattr(self.module, name)
-        self._check_function(t)
 
-
 class TestF90ReturnComplex(TestReturnComplex):
     suffix = ".f90"
     code = """
@@ -161,12 +157,8 @@
 
     def test_all(self):
         for name in "t0,t8,t16,td,s0,s8,s16,sd".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module.f90_return_complex, name))
 
-    def check_function(self, name):
-        t = getattr(self.module.f90_return_complex, name)
-        self._check_function(t)
-
 if __name__ == "__main__":
     import nose
     nose.runmodule()

Modified: trunk/numpy/f2py/tests/test_return_integer.py
===================================================================
--- trunk/numpy/f2py/tests/test_return_integer.py	2010-03-06 23:58:28 UTC (rev 8283)
+++ trunk/numpy/f2py/tests/test_return_integer.py	2010-03-06 23:58:48 UTC (rev 8284)
@@ -3,7 +3,7 @@
 import util
 
 class TestReturnInteger(util.F2PyTest):
-    def _check_function(self, t):
+    def check_function(self, t):
         assert t(123)==123,`t(123)`
         assert t(123.6)==123
         assert t(123l)==123
@@ -97,13 +97,9 @@
 
     def test_all(self):
         for name in "t0,t1,t2,t4,t8,s0,s1,s2,s4,s8".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module, name))
 
-    def check_function(self, name):
-        t = getattr(self.module, name)
-        self._check_function(t)
 
-
 class TestF90ReturnInteger(TestReturnInteger):
     suffix = ".f90"
     code = """
@@ -170,12 +166,8 @@
 
     def test_all(self):
         for name in "t0,t1,t2,t4,t8,s0,s1,s2,s4,s8".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module.f90_return_integer, name))
 
-    def check_function(self, name):
-        t = getattr(self.module.f90_return_integer, name)
-        self._check_function(t)
-
 if __name__ == "__main__":
     import nose
     nose.runmodule()

Modified: trunk/numpy/f2py/tests/test_return_logical.py
===================================================================
--- trunk/numpy/f2py/tests/test_return_logical.py	2010-03-06 23:58:28 UTC (rev 8283)
+++ trunk/numpy/f2py/tests/test_return_logical.py	2010-03-06 23:58:48 UTC (rev 8284)
@@ -3,7 +3,7 @@
 import util
 
 class TestReturnLogical(util.F2PyTest):
-    def _check_function(self, t):
+    def check_function(self, t):
         assert t(True)==1,`t(True)`
         assert t(False)==0,`t(False)`
         assert t(0)==0
@@ -107,12 +107,8 @@
 
     def test_all(self):
         for name in "t0,t1,t2,t4,s0,s1,s2,s4".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module, name))
 
-    def check_function(self, name):
-        t = getattr(self.module, name)
-        self._check_function(t)
-
 class TestF90ReturnLogical(TestReturnLogical):
     suffix = ".f90"
     code = """
@@ -179,12 +175,8 @@
 
     def test_all(self):
         for name in "t0,t1,t2,t4,t8,s0,s1,s2,s4,s8".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module.f90_return_logical, name))
 
-    def check_function(self, name):
-        t = getattr(self.module.f90_return_logical, name)
-        self._check_function(t)
-
 if __name__ == "__main__":
     import nose
     nose.runmodule()

Modified: trunk/numpy/f2py/tests/test_return_real.py
===================================================================
--- trunk/numpy/f2py/tests/test_return_real.py	2010-03-06 23:58:28 UTC (rev 8283)
+++ trunk/numpy/f2py/tests/test_return_real.py	2010-03-06 23:58:48 UTC (rev 8284)
@@ -4,7 +4,7 @@
 import util
 
 class TestReturnReal(util.F2PyTest):
-    def _check_function(self, t):
+    def check_function(self, t):
         if t.__doc__.split()[0] in ['t0','t4','s0','s4']:
             err = 1e-5
         else:
@@ -79,11 +79,8 @@
 
     def test_all(self):
         for name in "t4,t8,s4,s8".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module, name))
 
-    def check_function(self, name):
-        self._check_function(getattr(self.module, name))
-
 class TestF77ReturnReal(TestReturnReal):
     code = """
        function t0(value)
@@ -135,11 +132,8 @@
 
     def test_all(self):
         for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module, name))
 
-    def check_function(self, name):
-        self._check_function(getattr(self.module, name))
-
 class TestF90ReturnReal(TestReturnReal):
     suffix = ".f90"
     code = """
@@ -195,12 +189,9 @@
 
     def test_all(self):
         for name in "t0,t4,t8,td,s0,s4,s8,sd".split(","):
-            yield self.check_function, name
+            self.check_function(getattr(self.module.f90_return_real, name))
 
-    def check_function(self, name):
-        self._check_function(getattr(self.module.f90_return_real, name))
 
-
 if __name__ == "__main__":
     import nose
     nose.runmodule()



More information about the Numpy-svn mailing list