from numpy import *
from numpy.testing import *

from scipy.weave import inline_tools

class TestInline(TestCase):
    """ These are long running tests...

         I'd like to benchmark these things somehow.
    """
    @dec.slow
    def test_exceptions(self):
        a = 3
        code = """
               if (a < 2)
                  throw_error(PyExc_ValueError,
                              "the variable 'a' should not be less than 2");
               else
                   return_val = PyInt_FromLong(a+1);
               """
        result = inline_tools.inline(code,['a'])
        assert(result == 4)

        try:
            a = 1
            result = inline_tools.inline(code,['a'])
            assert(1) # should've thrown a ValueError
        except ValueError:
            pass

        from distutils.errors import DistutilsError, CompileError
        try:
            a = 'string'
            result = inline_tools.inline(code,['a'])
            assert(1) # should've gotten an error
        except:
            # ?CompileError is the error reported, but catching it doesn't work
            pass

if __name__ == "__main__":
    nose.run(argv=['', __file__])

@@ -609,16 +609,219 @@
  == 4)%0A%0A
+## Unfortunately, it is not always possible to catch distutils compiler%0A## errors, since SystemExit is used.  Until that is fixed, these tests%0A## cannot be run in the same process as the test suite.%0A%0A## 
         
@@ -817,32 +817,35 @@
 ##         try:%0A
+## 
             a = 
@@ -846,16 +846,19 @@
   a = 1%0A
+## 
         
@@ -894,32 +894,35 @@
 ine(code,%5B'a'%5D)%0A
+## 
             asse
@@ -955,24 +955,27 @@
  ValueError%0A
+## 
         exce
@@ -989,16 +989,19 @@
 eError:%0A
+## 
         
@@ -1010,24 +1010,26 @@
   pass%0A%0A
+##
         
 from dis
@@ -1020,16 +1020,17 @@
         
+ 
 from dis
@@ -1075,24 +1075,27 @@
 ompileError%0A
+## 
         try:
@@ -1095,16 +1095,19 @@
    try:%0A
+## 
         
@@ -1123,16 +1123,19 @@
 string'%0A
+## 
         
@@ -1171,32 +1171,35 @@
 ine(code,%5B'a'%5D)%0A
+## 
             asse
@@ -1232,24 +1232,26 @@
 n error%0A
+##
         
 except:%0A
@@ -1246,16 +1246,17 @@
     
+ 
 except:%0A
     
@@ -1251,16 +1251,19 @@
 except:%0A
+## 
         
@@ -1334,16 +1334,19 @@
 't work%0A
+## 
         

Disable weave tests that cause compilation failure, since this causes distutils to do a SystemExit, which break the test suite.