[Scipy-svn] r3266 - in trunk/scipy/weave: . tests

scipy-svn@scip... scipy-svn@scip...
Mon Aug 27 11:17:12 CDT 2007


Author: stefan
Date: 2007-08-27 11:16:49 -0500 (Mon, 27 Aug 2007)
New Revision: 3266

Modified:
   trunk/scipy/weave/size_check.py
   trunk/scipy/weave/tests/test_size_check.py
   trunk/scipy/weave/tests/test_wx_spec.py
   trunk/scipy/weave/wx_spec.py
Log:
The weave test suite is a mess.  Fix some of the tests.


Modified: trunk/scipy/weave/size_check.py
===================================================================
--- trunk/scipy/weave/size_check.py	2007-08-27 13:45:32 UTC (rev 3265)
+++ trunk/scipy/weave/size_check.py	2007-08-27 16:16:49 UTC (rev 3266)
@@ -162,11 +162,7 @@
     def __len__(self):
         return self.shape[0]
     def __getslice__(self,i,j):
-        # enabling the following would make class compatible with
-        # lists.  Its current incarnation is compatible with arrays.
-        # Both this and Numeric should have this FIXED to correspond
-        # to lists.
-        #i = max(i, 0); j = max(j, 0)
+        i = max(i, 0); j = max(j, 0)
         return self.__getitem__((slice(i,j),))
     def __getitem__(self,indices):
         # ayeyaya this is a mess

Modified: trunk/scipy/weave/tests/test_size_check.py
===================================================================
--- trunk/scipy/weave/tests/test_size_check.py	2007-08-27 13:45:32 UTC (rev 3265)
+++ trunk/scipy/weave/tests/test_size_check.py	2007-08-27 16:16:49 UTC (rev 3266)
@@ -93,7 +93,7 @@
     def check_error1(self):
         x,y = (5,),(4,)
         self.generic_error_test(x,y)
-        
+
     def check_error2(self):
         x,y = (5,5),(4,5)
         self.generic_error_test(x,y)
@@ -163,8 +163,6 @@
     def check_1d_2(self):
         self.generic_1d('a[-1:]')
     def check_1d_3(self):
-        # dummy_array is "bug for bug" equiv to numpy.numerix.array
-        # on wrapping of indices.
         self.generic_1d('a[-11:]')
     def check_1d_4(self):
         self.generic_1d('a[:1]')
@@ -246,7 +244,7 @@
                 end2 = random.choice(choices)
                 step2 = random.choice(choices)
                 if step in ['0',0]: step = 'None'
-                if step2 in ['0',0]: step2 = 'None'  
+                if step2 in ['0',0]: step2 = 'None'
                 expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)
                 self.generic_2d(expr)
             except IndexError:
@@ -263,7 +261,7 @@
                     val = random.choice(choices)
                     if (i+1) % 3 == 0 and val in ['0',0]:
                         val = 'None'
-                    idx.append(val)                    
+                    idx.append(val)
                 expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)
                 self.generic_3d(expr)
             except IndexError:

Modified: trunk/scipy/weave/tests/test_wx_spec.py
===================================================================
--- trunk/scipy/weave/tests/test_wx_spec.py	2007-08-27 13:45:32 UTC (rev 3265)
+++ trunk/scipy/weave/tests/test_wx_spec.py	2007-08-27 16:16:49 UTC (rev 3266)
@@ -13,35 +13,43 @@
 from weave import ext_tools, wx_spec
 restore_path()
 
-import wxPython
-import wxPython.wx
+import wx
 
 class test_wx_converter(NumpyTestCase):
+    def setUp(self):
+        self.app = wx.App()
+        self.s = wx_spec.wx_converter()
+
     def check_type_match_string(self,level=5):
-        s = wx_spec.wx_converter()
-        assert(not s.type_match('string') )
+        assert(not self.s.type_match('string') )
+
     def check_type_match_int(self,level=5):
-        s = wx_spec.wx_converter()
-        assert(not s.type_match(5))
+        assert(not self.s.type_match(5))
+
     def check_type_match_float(self,level=5):
-        s = wx_spec.wx_converter()
-        assert(not s.type_match(5.))
+        assert(not self.s.type_match(5.))
+
     def check_type_match_complex(self,level=5):
-        s = wx_spec.wx_converter()
-        assert(not s.type_match(5.+1j))
+        assert(not self.s.type_match(5.+1j))
+
     def check_type_match_complex(self,level=5):
-        s = wx_spec.wx_converter()
-        assert(not s.type_match(5.+1j))
+        assert(not self.s.type_match(5.+1j))
+
     def check_type_match_wxframe(self,level=5):
-        s = wx_spec.wx_converter()
-        f=wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob')
-        assert(s.type_match(f))
+        f=wx.Frame(None,-1,'bob')
+        assert(self.s.type_match(f))
 
     def check_var_in(self,level=5):
         mod = ext_tools.ext_module('wx_var_in',compiler='msvc')
-        a = wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob')
+        mod.customize.add_header('<wx/string.h>')
+        mod.customize.add_extra_compile_arg(' '.join(self.s.extra_compile_args))
+        mod.customize.add_extra_link_arg(' '.join(self.s.extra_link_args))
+
+        a = wx.Frame(None,-1,'bob')
         code = """
-               a->SetTitle(wxString("jim"));
+               py::tuple args(1);
+               args[0] = py::object("jim");
+               a.mcall("SetTitle",args);
                """
         test = ext_tools.ext_function('test',code,['a'],locals(),globals())
         mod.add_function(test)
@@ -64,31 +72,34 @@
     def no_check_var_local(self,level=5):
         mod = ext_tools.ext_module('wx_var_local')
         a = 'string'
+        code = 'a="hello";'
         var_specs = ext_tools.assign_variable_types(['a'],locals())
-        code = 'a=Py::String("hello");'
-        test = ext_tools.ext_function('test',var_specs,code)
+        test = ext_tools.ext_function_from_specs('test',code,var_specs)
         mod.add_function(test)
         mod.compile()
         import wx_var_local
         b='bub'
         q={}
         wx_var_local.test(b,q)
-        assert(q['a'] == 'hello')
-    def no_check_return(self,level=5):
+        assert('a' == 'string')
+
+    def no_test_no_check_return(self,level=5):
         mod = ext_tools.ext_module('wx_return')
         a = 'string'
-        var_specs = ext_tools.assign_variable_types(['a'],locals())
         code = """
                a= Py::wx("hello");
                return_val = Py::new_reference_to(a);
                """
-        test = ext_tools.ext_function('test',var_specs,code)
+        test = ext_tools.ext_function('test',code,['a'],locals())
         mod.add_function(test)
         mod.compile()
         import wx_return
         b='bub'
         c = wx_return.test(b)
-        assert( c == 'hello')
+        assert(c == 'hello')
 
 if __name__ == "__main__":
+    import sys
+    if len(sys.argv) == 1:
+        sys.argv.extend(["--level=5"])
     NumpyTest().run()

Modified: trunk/scipy/weave/wx_spec.py
===================================================================
--- trunk/scipy/weave/wx_spec.py	2007-08-27 13:45:32 UTC (rev 3265)
+++ trunk/scipy/weave/wx_spec.py	2007-08-27 16:16:49 UTC (rev 3266)
@@ -1,16 +1,30 @@
 import common_info
 from c_spec import common_base_converter
 import sys,os
+import glob
 
-# these may need user configuration.
-if sys.platform == "win32":
-    wx_base = r'c:\third\wxpython-2.4.0.7'
-else:
-    # probably should do some more discovery here.
-    wx_base = '/usr/lib/wxPython'
+def find_base_dir():
+    searched_locations = ['c:\third\wxpython*',
+                          '/usr/lib/wx*']
 
+    candidate_locations = []
+    for pattern in searched_locations:
+        candidate_locations.extend(glob.glob(pattern))
+    candidate_locations.sort()
+
+    if len(candidate_locations) == 0:
+        raise RuntimeError("Could not locate wxPython base directory.")
+    else:
+        return candidate_locations[-1]
+
+wx_base = find_base_dir()
+
 def get_wxconfig(flag):
     wxconfig = os.path.join(wx_base,'bin','wx-config')
+    if not os.path.exists(wxconfig):
+        # Could not locate wx-config, assume it is on the path.
+        wxconfig = 'wx-config'
+
     import commands
     res,settings = commands.getstatusoutput(wxconfig + ' --' + flag)
     if res:



More information about the Scipy-svn mailing list