[Numpy-svn] r8138 - in trunk/numpy: compat core/tests

numpy-svn@scip... numpy-svn@scip...
Sat Feb 20 12:05:41 CST 2010


Author: ptvirtan
Date: 2010-02-20 12:05:41 -0600 (Sat, 20 Feb 2010)
New Revision: 8138

Modified:
   trunk/numpy/compat/py3k.py
   trunk/numpy/core/tests/test_multiarray.py
Log:
3K: BUG: core: fix some tests for Py3

Modified: trunk/numpy/compat/py3k.py
===================================================================
--- trunk/numpy/compat/py3k.py	2010-02-20 18:05:21 UTC (rev 8137)
+++ trunk/numpy/compat/py3k.py	2010-02-20 18:05:41 UTC (rev 8138)
@@ -3,7 +3,7 @@
 
 """
 
-__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception']
+__all__ = ['bytes', 'asbytes', 'isfileobj', 'getexception', 'strchar']
 
 import sys
 
@@ -16,9 +16,11 @@
         return s.encode('iso-8859-1')
     def isfileobj(f):
         return isinstance(f, io.IOBase)
+    strchar = 'U'
 else:
     bytes = str
     asbytes = str
+    strchar = 'S'
     def isfileobj(f):
         return isinstance(f, file)
 

Modified: trunk/numpy/core/tests/test_multiarray.py
===================================================================
--- trunk/numpy/core/tests/test_multiarray.py	2010-02-20 18:05:21 UTC (rev 8137)
+++ trunk/numpy/core/tests/test_multiarray.py	2010-02-20 18:05:41 UTC (rev 8138)
@@ -6,7 +6,7 @@
 from numpy.core import *
 from numpy.core.multiarray_tests import test_neighborhood_iterator, test_neighborhood_iterator_oob
 
-from numpy.compat import asbytes, getexception
+from numpy.compat import asbytes, getexception, strchar
 
 from test_print import in_foreign_locale
 
@@ -414,7 +414,7 @@
             strtype = '>i2'
         else:
             strtype = '<i2'
-        mydtype = [('name', 'S5'),('col2',strtype)]
+        mydtype = [('name', strchar + '5'),('col2',strtype)]
         r = np.array([('a', 1),('b', 255), ('c', 3), ('d', 258)],
                      dtype= mydtype)
         r.sort(order='col2')
@@ -1063,13 +1063,13 @@
             assert_raises(TypeError, np.dtype, [(('b', asbytes('a')), int)])
 
             dt = np.dtype([((asbytes('a'), 'b'), int)])
-            assert_raises(KeyError, dt.__getitem__, asbytes('a'))
+            assert_raises(ValueError, dt.__getitem__, asbytes('a'))
 
             x = np.array([(1,), (2,), (3,)], dtype=dt)
-            assert_raises(KeyError, x.__getitem__, asbytes('a'))
+            assert_raises(ValueError, x.__getitem__, asbytes('a'))
 
             y = x[0]
-            assert_raises(KeyError, y.__getitem__, asbytes('a'))
+            assert_raises(IndexError, y.__getitem__, asbytes('a'))
     else:
         def test_unicode_field_titles(self):
             # Unicode field titles are added to field dict on Py2
@@ -1087,8 +1087,8 @@
         def test_unicode_field_names(self):
             # Unicode field names are not allowed on Py2
             title = unicode('b')
-            assert_raises(TypeError, np.dtype, [(title, int)])
-            assert_raises(TypeError, np.dtype, [(('a', title), int)])
+            assert_raises(ValueError, np.dtype, [(title, int)])
+            assert_raises(ValueError, np.dtype, [(('a', title), int)])
 
 class TestView(TestCase):
     def test_basic(self):



More information about the Numpy-svn mailing list