summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2005-12-26 07:49:25 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2005-12-26 07:49:25 +0000
commita1d00598a3a406e965cd3e07a6ebf95e4c50198b (patch)
tree069b66cab8bd31be325de284bbb8603595271a11
parent36e55fb0bfd3f55f2ece8cbf68a7b912df6de9e6 (diff)
downloadnumpy-a1d00598a3a406e965cd3e07a6ebf95e4c50198b.tar.gz
Renamed scipy.test module to scipy.testing. Clean up testing.
-rw-r--r--scipy/__init__.py4
-rw-r--r--scipy/base/__init__.py6
-rw-r--r--scipy/base/info.py2
-rw-r--r--scipy/base/tests/test_function_base.py35
-rw-r--r--scipy/base/tests/test_getlimits.py18
-rw-r--r--scipy/base/tests/test_index_tricks.py12
-rw-r--r--scipy/base/tests/test_ma.py3
-rw-r--r--scipy/base/tests/test_matrix.py6
-rw-r--r--scipy/base/tests/test_polynomial.py2
-rw-r--r--scipy/base/tests/test_records.py13
-rw-r--r--scipy/base/tests/test_shape_base.py30
-rw-r--r--scipy/base/tests/test_twodim_base.py19
-rw-r--r--scipy/base/tests/test_type_check.py33
-rw-r--r--scipy/base/tests/test_ufunclike.py2
-rw-r--r--scipy/base/tests/test_umath.py6
-rw-r--r--scipy/corefft/__init__.py2
-rw-r--r--scipy/corefft/tests/test_helper.py2
-rw-r--r--scipy/corelinalg/__init__.py2
-rw-r--r--scipy/distutils/__init__.py4
-rw-r--r--scipy/distutils/tests/test_misc_util.py2
-rw-r--r--scipy/random/__init__.py2
-rw-r--r--scipy/setup.py2
-rw-r--r--scipy/test/__init__.py4
-rw-r--r--scipy/test/auto_test.py810
-rw-r--r--scipy/test/info.py12
-rw-r--r--scipy/test/testing.py825
-rw-r--r--scipy/testing/__init__.py4
-rw-r--r--scipy/testing/info.py30
-rw-r--r--scipy/testing/scipy_test_version.py (renamed from scipy/test/scipy_test_version.py)0
-rw-r--r--scipy/testing/scipytest.py385
-rwxr-xr-xscipy/testing/setup.py16
-rwxr-xr-xscipy/testing/setup_scipy_test.py (renamed from scipy/test/setup_scipy_test.py)0
-rw-r--r--scipy/testing/testing.py261
-rw-r--r--scipy/testing/utils.py210
-rw-r--r--scipy/weave/__init__.py6
-rw-r--r--scipy/weave/blitz_tools.py2
-rw-r--r--scipy/weave/info.py (renamed from scipy/weave/info_weave.py)1
-rwxr-xr-xscipy/weave/setup.py2
-rw-r--r--scipy/weave/tests/test_ast_tools.py11
-rw-r--r--scipy/weave/tests/test_blitz_tools.py17
-rw-r--r--scipy/weave/tests/test_build_tools.py9
-rw-r--r--scipy/weave/tests/test_c_spec.py25
-rw-r--r--scipy/weave/tests/test_catalog.py14
-rw-r--r--scipy/weave/tests/test_ext_tools.py12
-rw-r--r--scipy/weave/tests/test_inline_tools.py10
-rw-r--r--scipy/weave/tests/test_scxx.py4
-rw-r--r--scipy/weave/tests/test_scxx_dict.py17
-rw-r--r--scipy/weave/tests/test_scxx_object.py47
-rw-r--r--scipy/weave/tests/test_scxx_sequence.py8
-rw-r--r--scipy/weave/tests/test_size_check.py62
-rw-r--r--scipy/weave/tests/test_slice_handler.py10
-rw-r--r--scipy/weave/tests/test_standard_array_spec.py11
-rw-r--r--scipy/weave/tests/test_wx_spec.py7
-rw-r--r--scipy/weave/tests/weave_test_utils.py8
-rw-r--r--scipy/weave/weave_version.py29
55 files changed, 1132 insertions, 1944 deletions
diff --git a/scipy/__init__.py b/scipy/__init__.py
index fe31bcbb9..d9db0e4bd 100644
--- a/scipy/__init__.py
+++ b/scipy/__init__.py
@@ -248,7 +248,9 @@ if show_core_config is None:
else:
from core_version import version as __core_version__
- pkgload('test','base','corefft','corelinalg','random',verbose=SCIPY_IMPORT_VERBOSE)
+ pkgload('testing','base','corefft','corelinalg','random',
+ verbose=SCIPY_IMPORT_VERBOSE)
+
test = ScipyTest('scipy').test
diff --git a/scipy/base/__init__.py b/scipy/base/__init__.py
index 2cffbf759..c8c28efe9 100644
--- a/scipy/base/__init__.py
+++ b/scipy/base/__init__.py
@@ -30,5 +30,7 @@ del nt
from utils import *
-from scipy.test.testing import ScipyTest
-test = ScipyTest('scipy.base').test
+__all__ = filter(lambda s:not s.startswith('_'),dir())
+
+from scipy.testing import ScipyTest
+test = ScipyTest().test
diff --git a/scipy/base/info.py b/scipy/base/info.py
index 8d9c1bea6..b4c4b4e8c 100644
--- a/scipy/base/info.py
+++ b/scipy/base/info.py
@@ -204,5 +204,5 @@ Threading tricks
ParallelExec -- Execute commands in parallel thread.
"""
-depends = ['test']
+depends = ['testing']
global_symbols = ['*']
diff --git a/scipy/base/tests/test_function_base.py b/scipy/base/tests/test_function_base.py
index 25d143315..e727568a8 100644
--- a/scipy/base/tests/test_function_base.py
+++ b/scipy/base/tests/test_function_base.py
@@ -1,14 +1,13 @@
-import unittest
import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base)
from scipy.base import *
del sys.path[0]
-class test_any(unittest.TestCase):
+class test_any(ScipyTestCase):
def check_basic(self):
y1 = [0,0,1,0]
y2 = [0,0,0,0]
@@ -23,7 +22,7 @@ class test_any(unittest.TestCase):
assert_array_equal(sometrue(y1),[1,1,0])
assert_array_equal(sometrue(y1,axis=1),[0,1,1])
-class test_all(unittest.TestCase):
+class test_all(ScipyTestCase):
def check_basic(self):
y1 = [0,1,1,0]
y2 = [0,0,0,0]
@@ -39,7 +38,7 @@ class test_all(unittest.TestCase):
assert_array_equal(alltrue(y1),[0,0,1])
assert_array_equal(alltrue(y1,axis=1),[0,0,1])
-class test_average(unittest.TestCase):
+class test_average(ScipyTestCase):
def check_basic(self):
y1 = array([1,2,3])
assert(average(y1) == 2.)
@@ -58,7 +57,7 @@ class test_average(unittest.TestCase):
assert_array_equal(y5.mean(0), average(y5, 0))
assert_array_equal(y5.mean(1), average(y5, 1))
-class test_logspace(unittest.TestCase):
+class test_logspace(ScipyTestCase):
def check_basic(self):
y = logspace(0,6)
assert(len(y)==50)
@@ -69,7 +68,7 @@ class test_logspace(unittest.TestCase):
y = logspace(0,6,num=7)
assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])
-class test_linspace(unittest.TestCase):
+class test_linspace(ScipyTestCase):
def check_basic(self):
y = linspace(0,10)
assert(len(y)==50)
@@ -87,7 +86,7 @@ class test_linspace(unittest.TestCase):
y = list(linspace(0,1,2.5))
assert y == [0.0, 1.0]
-class test_amax(unittest.TestCase):
+class test_amax(ScipyTestCase):
def check_basic(self):
a = [3,4,5,10,-3,-5,6.0]
assert_equal(amax(a),10.0)
@@ -97,7 +96,7 @@ class test_amax(unittest.TestCase):
assert_equal(amax(b,axis=0),[8.0,10.0,9.0])
assert_equal(amax(b,axis=1),[9.0,10.0,8.0])
-class test_amin(unittest.TestCase):
+class test_amin(ScipyTestCase):
def check_basic(self):
a = [3,4,5,10,-3,-5,6.0]
assert_equal(amin(a),-5.0)
@@ -107,7 +106,7 @@ class test_amin(unittest.TestCase):
assert_equal(amin(b,axis=0),[3.0,3.0,2.0])
assert_equal(amin(b,axis=1),[3.0,4.0,2.0])
-class test_ptp(unittest.TestCase):
+class test_ptp(ScipyTestCase):
def check_basic(self):
a = [3,4,5,10,-3,-5,6.0]
assert_equal(ptp(a),15.0)
@@ -117,7 +116,7 @@ class test_ptp(unittest.TestCase):
assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])
assert_equal(ptp(b),[6.0,6.0,6.0])
-class test_cumsum(unittest.TestCase):
+class test_cumsum(ScipyTestCase):
def check_basic(self):
ba = [1,2,10,11,6,5,4]
ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]
@@ -133,7 +132,7 @@ class test_cumsum(unittest.TestCase):
[5,11,18,27],
[10,13,17,22]],ctype))
-class test_prod(unittest.TestCase):
+class test_prod(ScipyTestCase):
def check_basic(self):
ba = [1,2,10,11,6,5,4]
ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]
@@ -151,7 +150,7 @@ class test_prod(unittest.TestCase):
array([50,36,84,180],ctype))
assert_array_equal(prod(a2),array([24, 1890, 600],ctype))
-class test_cumprod(unittest.TestCase):
+class test_cumprod(ScipyTestCase):
def check_basic(self):
ba = [1,2,10,11,6,5,4]
ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]
@@ -176,7 +175,7 @@ class test_cumprod(unittest.TestCase):
[ 5, 30, 210, 1890],
[10, 30, 120, 600]],ctype))
-class test_diff(unittest.TestCase):
+class test_diff(ScipyTestCase):
def check_basic(self):
x = [1,4,6,7,12]
out = array([3,2,1,5])
@@ -197,7 +196,7 @@ class test_diff(unittest.TestCase):
assert_array_equal(diff(x,axis=0),out3)
assert_array_equal(diff(x,n=2,axis=0),out4)
-class test_angle(unittest.TestCase):
+class test_angle(ScipyTestCase):
def check_basic(self):
x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]
y = angle(x)
@@ -208,7 +207,7 @@ class test_angle(unittest.TestCase):
assert_array_almost_equal(y,yo,11)
assert_array_almost_equal(z,zo,11)
-class test_trim_zeros(unittest.TestCase):
+class test_trim_zeros(ScipyTestCase):
""" only testing for integer splits.
"""
def check_basic(self):
@@ -225,7 +224,7 @@ class test_trim_zeros(unittest.TestCase):
assert_array_equal(res,array([1,0,2,3,0,4]))
-class test_extins(unittest.TestCase):
+class test_extins(ScipyTestCase):
def check_basic(self):
a = array([1,3,2,1,2,3,3])
b = extract(a>1,a)
@@ -243,7 +242,7 @@ class test_extins(unittest.TestCase):
insert(a,mask,c)
assert_array_equal(a,ac)
-class test_vectorize(unittest.TestCase):
+class test_vectorize(ScipyTestCase):
def check_simple(self):
def addsubtract(a,b):
if a > b:
diff --git a/scipy/base/tests/test_getlimits.py b/scipy/base/tests/test_getlimits.py
index 2a3a727fa..99a6f5160 100644
--- a/scipy/base/tests/test_getlimits.py
+++ b/scipy/base/tests/test_getlimits.py
@@ -1,40 +1,34 @@
""" Test functions for limits module.
-
- Currently empty -- not sure how to test these values
- and routines as they are machine dependent. Suggestions?
"""
-import unittest
-import sys
-
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base)
from scipy.base.getlimits import finfo
from scipy import single,double,longdouble
-del sys.path[0]
+restore_path()
##################################################
-class test_python_float(unittest.TestCase):
+class test_python_float(ScipyTestCase):
def check_singleton(self):
ftype = finfo(float)
ftype2 = finfo(float)
assert_equal(id(ftype),id(ftype2))
-class test_single(unittest.TestCase):
+class test_single(ScipyTestCase):
def check_singleton(self):
ftype = finfo(single)
ftype2 = finfo(single)
assert_equal(id(ftype),id(ftype2))
-class test_double(unittest.TestCase):
+class test_double(ScipyTestCase):
def check_singleton(self):
ftype = finfo(double)
ftype2 = finfo(double)
assert_equal(id(ftype),id(ftype2))
-class test_longdouble(unittest.TestCase):
+class test_longdouble(ScipyTestCase):
def check_singleton(self,level=2):
ftype = finfo(longdouble)
ftype2 = finfo(longdouble)
diff --git a/scipy/base/tests/test_index_tricks.py b/scipy/base/tests/test_index_tricks.py
index b6aab7011..96e9dff84 100644
--- a/scipy/base/tests/test_index_tricks.py
+++ b/scipy/base/tests/test_index_tricks.py
@@ -1,13 +1,11 @@
-import unittest
-import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base)
from scipy.base import *
-del sys.path[0]
+restore_path()
-class test_grid(unittest.TestCase):
+class test_grid(ScipyTestCase):
def check_basic(self):
a = mgrid[-1:1:10j]
b = mgrid[-1:1:0.1]
@@ -32,7 +30,7 @@ class test_grid(unittest.TestCase):
assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)
assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)
-class test_concatenator(unittest.TestCase):
+class test_concatenator(ScipyTestCase):
def check_1d(self):
assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))
b = ones(5)
@@ -52,4 +50,4 @@ class test_concatenator(unittest.TestCase):
assert_array_equal(d[5:,:],c)
if __name__ == "__main__":
- ScipyTest('scipy.base.index_tricks').run()
+ ScipyTest().run()
diff --git a/scipy/base/tests/test_ma.py b/scipy/base/tests/test_ma.py
index 91d775e30..51d38172f 100644
--- a/scipy/base/tests/test_ma.py
+++ b/scipy/base/tests/test_ma.py
@@ -1,8 +1,7 @@
-import unittest
import scipy
import types, time
from scipy.base.ma import *
-from scipy.test.testing import ScipyTestCase, ScipyTest
+from scipy.testing import ScipyTestCase, ScipyTest
def eq(v,w):
result = allclose(v,w)
if not result:
diff --git a/scipy/base/tests/test_matrix.py b/scipy/base/tests/test_matrix.py
index b504af8a2..59b0a131e 100644
--- a/scipy/base/tests/test_matrix.py
+++ b/scipy/base/tests/test_matrix.py
@@ -1,11 +1,9 @@
-import unittest
-import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base)
from scipy.base import *
-del sys.path[0]
+restore_path()
class test_ctor(ScipyTestCase):
def test_basic(self):
diff --git a/scipy/base/tests/test_polynomial.py b/scipy/base/tests/test_polynomial.py
index 421368e67..51d4b5707 100644
--- a/scipy/base/tests/test_polynomial.py
+++ b/scipy/base/tests/test_polynomial.py
@@ -73,7 +73,7 @@ poly1d([ 2.])
(poly1d([ 1., -1.]), poly1d([ 0.]))
"""
-from scipy.test.testing import *
+from scipy.testing import *
import doctest
def test_suite(level=1):
diff --git a/scipy/base/tests/test_records.py b/scipy/base/tests/test_records.py
index 97790e4f7..9fbb22404 100644
--- a/scipy/base/tests/test_records.py
+++ b/scipy/base/tests/test_records.py
@@ -1,29 +1,28 @@
-import unittest
-import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base)
from scipy.base import *
from scipy.base import records as rec
+restore_path()
class test_fromrecords(ScipyTestCase):
def check_fromrecords(self):
r = rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3')
assert_equal(r[0].toscalar(),(456, 'dbe', 1.2))
- def check_method_array(ScipyTestCase):
+ def check_method_array(self):
r = rec.array('abcdefg'*100,formats='i2,a3,i4',shape=3,byteorder='big')
assert_equal(r[1].toscalar(),(25444, 'efg', 1633837924))
- def check_method_array2(ScipyTestCase):
+ def check_method_array2(self):
r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')
assert_equal(r[1].toscalar(),(2, 22.0, 'b'))
- def check_recarray_slices(ScipyTestCase):
+ def check_recarray_slices(self):
r=rec.array([(1,11,'a'),(2,22,'b'),(3,33,'c'),(4,44,'d'),(5,55,'ex'),(6,66,'f'),(7,77,'g')],formats='u1,f4,a1')
assert_equal(r[1::2][1].toscalar(),(4, 44.0, 'd'))
-del sys.path[0]
+
if __name__ == "__main__":
ScipyTest().run()
diff --git a/scipy/base/tests/test_shape_base.py b/scipy/base/tests/test_shape_base.py
index 1b92f48b2..005868e96 100644
--- a/scipy/base/tests/test_shape_base.py
+++ b/scipy/base/tests/test_shape_base.py
@@ -1,7 +1,5 @@
-import unittest
-import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;
from scipy.base import *
@@ -17,7 +15,7 @@ class test_apply_along_axis(ScipyTestCase):
a = ones((10,101),'d')
assert_array_equal(apply_along_axis(len,0,a),len(a)*ones(shape(a)[1]))
-class test_array_split(unittest.TestCase):
+class test_array_split(ScipyTestCase):
def check_integer_0_split(self):
a = arange(10)
try:
@@ -120,7 +118,7 @@ class test_array_split(unittest.TestCase):
array([]),array([])]
compare_results(res,desired)
-class test_split(unittest.TestCase):
+class test_split(ScipyTestCase):
"""* This function is essentially the same as array_split,
except that it test if splitting will result in an
equal split. Only test for this case.
@@ -139,7 +137,7 @@ class test_split(unittest.TestCase):
except ValueError:
pass
-class test_atleast_1d(unittest.TestCase):
+class test_atleast_1d(ScipyTestCase):
def check_0D_array(self):
a = array(1); b = array(2);
res=map(atleast_1d,[a,b])
@@ -170,7 +168,7 @@ class test_atleast_1d(unittest.TestCase):
assert(atleast_1d(3.0).shape == (1,))
assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))
-class test_atleast_2d(unittest.TestCase):
+class test_atleast_2d(ScipyTestCase):
def check_0D_array(self):
a = array(1); b = array(2);
res=map(atleast_2d,[a,b])
@@ -199,7 +197,7 @@ class test_atleast_2d(unittest.TestCase):
assert(atleast_2d([3j,1]).shape == (1,2))
assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))
-class test_atleast_3d(unittest.TestCase):
+class test_atleast_3d(ScipyTestCase):
def check_0D_array(self):
a = array(1); b = array(2);
res=map(atleast_3d,[a,b])
@@ -222,7 +220,7 @@ class test_atleast_3d(unittest.TestCase):
desired = [a,b]
assert_array_equal(res,desired)
-class test_hstack(unittest.TestCase):
+class test_hstack(ScipyTestCase):
def check_0D_array(self):
a = array(1); b = array(2);
res=hstack([a,b])
@@ -239,7 +237,7 @@ class test_hstack(unittest.TestCase):
desired = array([[1,1],[2,2]])
assert_array_equal(res,desired)
-class test_vstack(unittest.TestCase):
+class test_vstack(ScipyTestCase):
def check_0D_array(self):
a = array(1); b = array(2);
res=vstack([a,b])
@@ -261,7 +259,7 @@ class test_vstack(unittest.TestCase):
desired = array([[1,2],[1,2]])
assert_array_equal(res,desired)
-class test_dstack(unittest.TestCase):
+class test_dstack(ScipyTestCase):
def check_0D_array(self):
a = array(1); b = array(2);
res=dstack([a,b])
@@ -286,7 +284,7 @@ class test_dstack(unittest.TestCase):
""" array_split has more comprehensive test of splitting.
only do simple test on hsplit, vsplit, and dsplit
"""
-class test_hsplit(unittest.TestCase):
+class test_hsplit(ScipyTestCase):
""" only testing for integer splits.
"""
def check_0D_array(self):
@@ -308,7 +306,7 @@ class test_hsplit(unittest.TestCase):
desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]
compare_results(res,desired)
-class test_vsplit(unittest.TestCase):
+class test_vsplit(ScipyTestCase):
""" only testing for integer splits.
"""
def check_1D_array(self):
@@ -325,7 +323,7 @@ class test_vsplit(unittest.TestCase):
desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]
compare_results(res,desired)
-class test_dsplit(unittest.TestCase):
+class test_dsplit(ScipyTestCase):
""" only testing for integer splits.
"""
def check_2D_array(self):
@@ -346,7 +344,7 @@ class test_dsplit(unittest.TestCase):
array([[[3,4],[3,4]],[[3,4],[3,4]]])]
compare_results(res,desired)
-class test_squeeze(unittest.TestCase):
+class test_squeeze(ScipyTestCase):
def check_basic(self):
a = rand(20,10,10,1,1)
b = rand(20,1,10,1,20)
@@ -363,4 +361,4 @@ def compare_results(res,desired):
if __name__ == "__main__":
- ScipyTest('scipy.base.shape_base').run()
+ ScipyTest().run()
diff --git a/scipy/base/tests/test_twodim_base.py b/scipy/base/tests/test_twodim_base.py
index 0d73f5127..b061d4a5d 100644
--- a/scipy/base/tests/test_twodim_base.py
+++ b/scipy/base/tests/test_twodim_base.py
@@ -2,14 +2,11 @@
"""
-import unittest
-
-import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base)
from scipy.base import *
-del sys.path[0]
+restore_path()
##################################################
@@ -19,7 +16,7 @@ def get_mat(n):
data = add.outer(data,data)
return data
-class test_eye(unittest.TestCase):
+class test_eye(ScipyTestCase):
def check_basic(self):
assert_equal(eye(4),array([[1,0,0,0],
[0,1,0,0],
@@ -55,7 +52,7 @@ class test_eye(unittest.TestCase):
[1,0,0],
[0,1,0]]))
-class test_diag(unittest.TestCase):
+class test_diag(ScipyTestCase):
def check_vector(self):
vals = (100*arange(5)).astype('l')
b = zeros((5,5))
@@ -84,7 +81,7 @@ class test_diag(unittest.TestCase):
b[k] = vals[k+2,k]
assert_equal(diag(vals,-2),b[:3])
-class test_fliplr(unittest.TestCase):
+class test_fliplr(ScipyTestCase):
def check_basic(self):
self.failUnlessRaises(ValueError, fliplr, ones(4))
a = get_mat(4)
@@ -96,7 +93,7 @@ class test_fliplr(unittest.TestCase):
[5,4,3]]
assert_equal(fliplr(a),b)
-class test_flipud(unittest.TestCase):
+class test_flipud(ScipyTestCase):
def check_basic(self):
a = get_mat(4)
b = a[::-1,:]
@@ -107,7 +104,7 @@ class test_flipud(unittest.TestCase):
[0,1,2]]
assert_equal(flipud(a),b)
-class test_rot90(unittest.TestCase):
+class test_rot90(ScipyTestCase):
def check_basic(self):
self.failUnlessRaises(ValueError, rot90, ones(4))
@@ -134,4 +131,4 @@ class test_rot90(unittest.TestCase):
assert_equal(rot90(a,k=k),b4)
if __name__ == "__main__":
- ScipyTest('scipy.base.twodim_base').run()
+ ScipyTest().run()
diff --git a/scipy/base/tests/test_type_check.py b/scipy/base/tests/test_type_check.py
index b7e7996b6..aac24bd6e 100644
--- a/scipy/base/tests/test_type_check.py
+++ b/scipy/base/tests/test_type_check.py
@@ -1,12 +1,11 @@
-import unittest
import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
import scipy.base;reload(scipy.base);reload(scipy.base.type_check)
from scipy.base import *
-del sys.path[0]
+restore_path()
def assert_all(x):
assert(all(x)), x
@@ -60,7 +59,7 @@ class test_mintypecode(ScipyTestCase):
#assert_equal(mintypecode('idF',savespace=1),'F')
assert_equal(mintypecode('idD'),'D')
-class test_isscalar(unittest.TestCase):
+class test_isscalar(ScipyTestCase):
def check_basic(self):
assert(isscalar(3))
assert(not isscalar([3]))
@@ -69,7 +68,7 @@ class test_isscalar(unittest.TestCase):
assert(isscalar(10L))
assert(isscalar(4.0))
-class test_real(unittest.TestCase):
+class test_real(ScipyTestCase):
def check_real(self):
y = rand(10,)
assert_array_equal(y,real(y))
@@ -78,7 +77,7 @@ class test_real(unittest.TestCase):
y = rand(10,)+1j*rand(10,)
assert_array_equal(y.real,real(y))
-class test_imag(unittest.TestCase):
+class test_imag(ScipyTestCase):
def check_real(self):
y = rand(10,)
assert_array_equal(0,imag(y))
@@ -87,7 +86,7 @@ class test_imag(unittest.TestCase):
y = rand(10,)+1j*rand(10,)
assert_array_equal(y.imag,imag(y))
-class test_iscomplex(unittest.TestCase):
+class test_iscomplex(ScipyTestCase):
def check_fail(self):
z = array([-1,0,1])
res = iscomplex(z)
@@ -97,7 +96,7 @@ class test_iscomplex(unittest.TestCase):
res = iscomplex(z)
assert_array_equal(res,[1,0,0])
-class test_isreal(unittest.TestCase):
+class test_isreal(ScipyTestCase):
def check_pass(self):
z = array([-1,0,1j])
res = isreal(z)
@@ -107,21 +106,21 @@ class test_isreal(unittest.TestCase):
res = isreal(z)
assert_array_equal(res,[0,1,1])
-class test_iscomplexobj(unittest.TestCase):
+class test_iscomplexobj(ScipyTestCase):
def check_basic(self):
z = array([-1,0,1])
assert(not iscomplexobj(z))
z = array([-1j,0,-1])
assert(iscomplexobj(z))
-class test_isrealobj(unittest.TestCase):
+class test_isrealobj(ScipyTestCase):
def check_basic(self):
z = array([-1,0,1])
assert(isrealobj(z))
z = array([-1j,0,-1])
assert(not isrealobj(z))
-class test_isnan(unittest.TestCase):
+class test_isnan(ScipyTestCase):
def check_goodvalues(self):
z = array((-1.,0.,1.))
res = isnan(z) == 0
@@ -141,7 +140,7 @@ class test_isnan(unittest.TestCase):
def check_complex1(self):
assert_all(isnan(array(0+0j)/0.) == 1)
-class test_isfinite(unittest.TestCase):
+class test_isfinite(ScipyTestCase):
def check_goodvalues(self):
z = array((-1.,0.,1.))
res = isfinite(z) == 1
@@ -161,7 +160,7 @@ class test_isfinite(unittest.TestCase):
def check_complex1(self):
assert_all(isfinite(array(1+1j)/0.) == 0)
-class test_isinf(unittest.TestCase):
+class test_isinf(ScipyTestCase):
def check_goodvalues(self):
z = array((-1.,0.,1.))
res = isinf(z) == 0
@@ -180,21 +179,21 @@ class test_isinf(unittest.TestCase):
# assert_all(isinf(log(-1.)) == 0)
# assert_all(isnan(log(-1.)) == 1)
-class test_isposinf(unittest.TestCase):
+class test_isposinf(ScipyTestCase):
def check_generic(self):
vals = isposinf(array((-1.,0,1))/0.)
assert(vals[0] == 0)
assert(vals[1] == 0)
assert(vals[2] == 1)
-class test_isneginf(unittest.TestCase):
+class test_isneginf(ScipyTestCase):
def check_generic(self):
vals = isneginf(array((-1.,0,1))/0.)
assert(vals[0] == 1)
assert(vals[1] == 0)
assert(vals[2] == 0)
-class test_nan_to_num(unittest.TestCase):
+class test_nan_to_num(ScipyTestCase):
def check_generic(self):
vals = nan_to_num(array((-1.,0,1))/0.)
assert_all(vals[0] < -1e10) and assert_all(isfinite(vals[0]))
@@ -224,7 +223,7 @@ class test_nan_to_num(unittest.TestCase):
#assert_all(vals.real < -1e10) and assert_all(isfinite(vals))
-class test_real_if_close(unittest.TestCase):
+class test_real_if_close(ScipyTestCase):
def check_basic(self):
a = rand(10)
b = real_if_close(a+1e-15j)
diff --git a/scipy/base/tests/test_ufunclike.py b/scipy/base/tests/test_ufunclike.py
index 7fd5f6e11..ca06140c7 100644
--- a/scipy/base/tests/test_ufunclike.py
+++ b/scipy/base/tests/test_ufunclike.py
@@ -53,7 +53,7 @@ array([ 2.169925 , 1.20163386, 2.70043972])
"""
-from scipy.test.testing import *
+from scipy.testing import *
import doctest
def test_suite(level=1):
diff --git a/scipy/base/tests/test_umath.py b/scipy/base/tests/test_umath.py
index 5e9e2150f..9cd99f7e1 100644
--- a/scipy/base/tests/test_umath.py
+++ b/scipy/base/tests/test_umath.py
@@ -1,8 +1,8 @@
-import sys
-from scipy.test.testing import *
+
+from scipy.testing import *
set_package_path()
from scipy.base.umath import minimum, maximum
-del sys.path[0]
+restore_path()
class test_maximum(ScipyTestCase):
diff --git a/scipy/corefft/__init__.py b/scipy/corefft/__init__.py
index 98064bddd..0a72b86bd 100644
--- a/scipy/corefft/__init__.py
+++ b/scipy/corefft/__init__.py
@@ -18,5 +18,5 @@ else:
ifft2 = scipy.fftpack.ifft2
-from scipy.test.testing import ScipyTest
+from scipy.testing import ScipyTest
test = ScipyTest().test
diff --git a/scipy/corefft/tests/test_helper.py b/scipy/corefft/tests/test_helper.py
index 7bbae9301..f962096f6 100644
--- a/scipy/corefft/tests/test_helper.py
+++ b/scipy/corefft/tests/test_helper.py
@@ -4,7 +4,7 @@
"""
import sys
-from scipy.test.testing import *
+from scipy.testing import *
set_package_path()
from scipy.corefft import fftshift,ifftshift,fftfreq
del sys.path[0]
diff --git a/scipy/corelinalg/__init__.py b/scipy/corelinalg/__init__.py
index 4a35ae720..561ab3438 100644
--- a/scipy/corelinalg/__init__.py
+++ b/scipy/corelinalg/__init__.py
@@ -21,5 +21,5 @@ else:
-from scipy.test.testing import ScipyTest
+from scipy.testing import ScipyTest
test = ScipyTest().test
diff --git a/scipy/distutils/__init__.py b/scipy/distutils/__init__.py
index 183448c98..08cd57559 100644
--- a/scipy/distutils/__init__.py
+++ b/scipy/distutils/__init__.py
@@ -12,5 +12,5 @@ except ImportError:
_INSTALLED = False
if _INSTALLED:
- from scipy.test.testing import ScipyTest
- test = ScipyTest('scipy.distutils').test
+ from scipy.testing import ScipyTest
+ test = ScipyTest().test
diff --git a/scipy/distutils/tests/test_misc_util.py b/scipy/distutils/tests/test_misc_util.py
index c5ac67052..4ca21ea13 100644
--- a/scipy/distutils/tests/test_misc_util.py
+++ b/scipy/distutils/tests/test_misc_util.py
@@ -1,5 +1,5 @@
import sys
-from scipy.test.testing import *
+from scipy.testing import *
from scipy.distutils.misc_util import appendpath
from os.path import join, sep
diff --git a/scipy/random/__init__.py b/scipy/random/__init__.py
index d57c3ce19..203f8df8d 100644
--- a/scipy/random/__init__.py
+++ b/scipy/random/__init__.py
@@ -15,5 +15,5 @@ def __RandomState_ctor():
"""
return RandomState()
-from scipy.test.testing import ScipyTest
+from scipy.testing import ScipyTest
test = ScipyTest().test
diff --git a/scipy/setup.py b/scipy/setup.py
index 6b6ca89be..7c4e335cb 100644
--- a/scipy/setup.py
+++ b/scipy/setup.py
@@ -6,7 +6,7 @@ def configuration(parent_package='',top_path=None):
config = Configuration('scipy',parent_package,top_path)
config.add_subpackage('distutils')
config.add_subpackage('weave')
- config.add_subpackage('test')
+ config.add_subpackage('testing')
config.add_subpackage('f2py')
config.add_subpackage('base')
config.add_subpackage('lib')
diff --git a/scipy/test/__init__.py b/scipy/test/__init__.py
deleted file mode 100644
index 3c6e340a7..000000000
--- a/scipy/test/__init__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-
-from info import __doc__
-from scipy_test_version import scipy_test_version as __version__
-from testing import ScipyTest
diff --git a/scipy/test/auto_test.py b/scipy/test/auto_test.py
deleted file mode 100644
index c86014c8f..000000000
--- a/scipy/test/auto_test.py
+++ /dev/null
@@ -1,810 +0,0 @@
-""" Auto test tools for SciPy
-
- Do not run this as root! If you enter something
- like /usr as your test directory, it'll delete
- /usr/bin, usr/lib, etc. So don't do it!!!
-
-
- Author: Eric Jones (eric@enthought.com)
-"""
-from distutils import file_util
-from distutils import dir_util
-from distutils.errors import DistutilsFileError
-#import tarfile
-import sys, os, stat, time
-import gzip
-import tempfile, cStringIO
-import urllib
-import logging
-
-if sys.platform == 'cygwin':
- local_repository = "/cygdrive/i/tarballs"
-elif sys.platform == 'win32':
- local_repository = "i:\tarballs"
-else:
- local_repository = "/home/shared/tarballs"
-
-local_mail_server = "enthought.com"
-
-python_ftp_url = "ftp://ftp.python.org/pub/python"
-numeric_url = "http://prdownloads.sourceforge.net/numpy"
-f2py_url = "http://cens.ioc.ee/projects/f2py2e/2.x"
-scipy_url = "ftp://www.scipy.org/pub"
-blas_url = "http://www.netlib.org/blas"
-lapack_url = "http://www.netlib.org/lapack"
-#atlas_url = "http://prdownloads.sourceforge.net/math-atlas"
-atlas_url = "http://www.scipy.org/Members/eric"
-
-
-#-----------------------------------------------------------------------------
-# Generic installation class.
-# built to handle downloading/untarring/building/installing arbitrary software
-#-----------------------------------------------------------------------------
-
-class package_installation:
- def __init__(self,version='', dst_dir = '.',
- logger = None, python_exe='python'):
- #---------------------------------------------------------------------
- # These should be defined in sub-class before calling this
- # constructor
- #---------------------------------------------------------------------
- #
- #self.package_url -- The name of the url where tarball can be found.
- #self.package_base_name -- The base name of the source tarball.
- #self.package_dir_name -- Top level directory of unpacked tarball
- #self.tarball_suffix -- usually tar.gz or .tgz
- #self.build_type -- 'make' or 'setup' for makefile or python setup file
-
- # Version of the software package.
- self.version = version
-
- # Only used by packages built with setup.py
- self.python_exe = python_exe
-
- # Directory where package is unpacked/built/installed
- self.dst_dir = os.path.abspath(dst_dir)
-
- if not logger:
- self.logger = logging
- else:
- self.logger = logger
-
- # make sure the destination exists
- make_dir(self.dst_dir,logger=self.logger)
-
- # Construct any derived names built from the above names.
- self.init_names()
-
- def init_names(self):
- self.package_dir = os.path.join(self.dst_dir,self.package_dir_name)
- self.tarball = self.package_base_name + '.' + self.tarball_suffix
-
- def get_source(self):
- """ Grab the source tarball from a repository.
-
- Try a local repository first. If the file isn't found,
- grab it from an ftp site.
- """
- local_found = 0
- if self.local_source_up_to_date():
- try:
- self.get_source_local()
- local_found = 1
- except DistutilsFileError:
- pass
-
- if not local_found:
- self.get_source_ftp()
-
- def local_source_up_to_date(self):
- """ Hook to test whether a file found in the repository is current
- """
- return 1
-
- def get_source_local(self):
- """ Grab the requested tarball from a local repository of source
- tarballs. If it doesn't exist, an error is raised.
- """
- file = os.path.join(local_repository,self.tarball)
- dst_file = os.path.join(self.dst_dir,self.tarball)
- self.logger.info("Searching local repository for %s" % file)
- try:
- copy_file(file,dst_file,self.logger)
- except DistutilsFileError, msg:
- self.logger.info("Not found:",msg)
- raise
-
- def get_source_ftp(self):
- """ Grab requested tarball from a ftp site specified as a url.
- """
- url = '/'.join([self.package_url,self.tarball])
-
- self.logger.info('Opening: %s' % url)
- f = urllib.urlopen(url)
- self.logger.info('Downloading: this may take a while')
- contents = f.read(-1)
- f.close()
- self.logger.info('Finished download (size=%d)' % len(contents))
-
- output_file = os.path.join(self.dst_dir,self.tarball)
- write_file(output_file,contents,self.logger)
-
- # Put file in local repository so we don't have to download it again.
- self.logger.info("Caching file in repository" )
- src_file = output_file
- repos_file = os.path.join(local_repository,self.tarball)
- copy_file(src_file,repos_file,self.logger)
-
- def unpack_source(self,sub_dir = None):
- """ equivalent to 'tar -xzvf file' in the given sub_dir
- """
- tarfile = os.path.join(self.dst_dir,self.tarball)
- old_dir = None
-
- # copy and move into sub directory if it is specified.
- if sub_dir:
- dst_dir = os.path.join(self.dst_dir,sub_dir)
- dst_file = os.path.join(dst_dir,self.tarball)
- copy_file(tarfile,dst_file)
- change_dir(dst_dir,self.logger)
- try:
- try:
- # occasionally the tarball is not zipped, try this first.
- untar_file(self.tarball,self.dst_dir,
- self.logger,silent_failure=1)
- except:
- # otherwise, handle the fact that it is zipped
- dst = os.path.join(self.dst_dir,'tmp.tar')
- decompress_file(tarfile,dst,self.logger)
- untar_file(dst,self.dst_dir,self.logger)
- remove_file(dst,self.logger)
- finally:
- if old_dir:
- unchange_dir(self.logger)
-
- #def auto_configure(self):
- # cmd = os.path.join('.','configure')
- # try:
- # text = run_command(cmd,self.package_dir,self.logger,log_output=0)
- # except ValueError, e:
- # status, text = e
- # self.logger.exception('Configuration Error:\n'+text)
- def auto_configure(self):
- cmd = os.path.join('.','configure')
- text = run_command(cmd,self.package_dir,self.logger)
-
- def build_with_make(self):
- cmd = 'make'
- text = run_command(cmd,self.package_dir,self.logger)
-
- def install_with_make(self, prefix = None):
- if prefix is None:
- prefix = os.path.abspath(self.dst_dir)
- cmd = 'make install prefix=%s' % prefix
- text = run_command(cmd,self.package_dir,self.logger)
-
- def python_setup(self):
- cmd = self.python_exe + ' setup.py install'
- text = run_command(cmd,self.package_dir,self.logger)
-
- def _make(self,**kw):
- """ This generally needs to be overrridden in the derived class,
- but this will suffice for the standard configure/make process.
- """
- self.logger.info("### Begin Configure: %s" % self.package_base_name)
- self.auto_configure()
- self.logger.info("### Finished Configure: %s" % self.package_base_name)
- self.logger.info("### Begin Build: %s" % self.package_base_name)
- self.build_with_make()
- self.logger.info("### Finished Build: %s" % self.package_base_name)
- self.logger.info("### Begin Install: %s" % self.package_base_name)
- self.install_with_make()
- self.logger.info("### Finished Install: %s" % self.package_base_name)
-
- def install(self):
- self.logger.info('####### Building: %s' % self.package_base_name)
- self.logger.info(' Version: %s' % self.version)
- self.logger.info(' Url: %s' % self.package_url)
- self.logger.info(' Install dir: %s' % self.dst_dir)
- self.logger.info(' Package dir: %s' % self.package_dir)
- self.logger.info(' Suffix: %s' % self.tarball_suffix)
- self.logger.info(' Build type: %s' % self.build_type)
-
- self.logger.info("### Begin Get Source: %s" % self.package_base_name)
- self.get_source()
- self.unpack_source()
- self.logger.info("### Finished Get Source: %s" % self.package_base_name)
-
- if self.build_type == 'setup':
- self.python_setup()
- else:
- self._make()
- self.logger.info('####### Finished Building: %s' % self.package_base_name)
-
-#-----------------------------------------------------------------------------
-# Installation class for Python itself.
-#-----------------------------------------------------------------------------
-
-class python_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- # Specialization for Python.
- self.package_base_name = 'Python-'+version
- self.package_dir_name = self.package_base_name
- self.package_url = '/'.join([python_ftp_url,version])
- self.tarball_suffix = 'tgz'
- self.build_type = 'make'
-
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
- def write_install_config(self):
- """ Make doesn't seem to install scripts in the correct places.
-
- Writing this to the python directory will solve the problem.
- [install_script]
- install-dir=<directory_name>
- """
- self.logger.info('### Writing Install Script Hack')
- text = "[install_scripts]\n"\
- "install-dir='%s'" % os.path.join(self.dst_dir,'bin')
- file = os.path.join(self.package_dir,'setup.cfg')
- write_file(file,text,self.logger,mode='w')
- self.logger.info('### Finished writing Install Script Hack')
-
- def install_with_make(self):
- """ Scripts were failing to install correctly, so a setuo.cfg
- file is written to force installation in the correct place.
- """
- self.write_install_config()
- package_installation.install_with_make(self)
-
- def get_exe_name(self):
- pyname = os.path.join('.','python')
- cmd = pyname + """ -c "import sys;print '%d.%d' % sys.version_info[:2]" """
- text = run_command(cmd,self.package_dir,self.logger)
- exe = os.path.join(self.dst_dir,'bin','python'+text)
- return exe
-
-#-----------------------------------------------------------------------------
-# Installation class for Blas.
-#-----------------------------------------------------------------------------
-
-class blas_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- # Specialization for for "slow" blas
- self.package_base_name = 'blas'
- self.package_dir_name = 'BLAS'
- self.package_url = blas_url
- self.tarball_suffix = 'tgz'
- self.build_type = 'make'
-
- self.platform = 'LINUX'
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
- def unpack_source(self,subdir=None):
- """ Dag. blas.tgz doesn't have directory information -- its
- just a tar ball of fortran source code. untar it in the
- BLAS directory
- """
- package_installation.unpack_source(self,self.package_dir_name)
-
- def auto_configure(self):
- # nothing to do.
- pass
- def build_with_make(self, **kw):
- libname = 'blas_LINUX.a'
- cmd = 'g77 -funroll-all-loops -fno-f2c -O3 -c *.f;ar -cru %s' % libname
- text = run_command(cmd,self.package_dir,self.logger)
-
- def install_with_make(self, **kw):
- # not really using make -- we'll just copy the file over.
- src_file = os.path.join(self.package_dir,'blas_%s.a' % self.platform)
- dst_file = os.path.join(self.dst_dir,'lib','libblas.a')
- self.logger.info("Installing blas")
- copy_file(src_file,dst_file,self.logger)
-
-#-----------------------------------------------------------------------------
-# Installation class for Lapack.
-#-----------------------------------------------------------------------------
-
-class lapack_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- # Specialization for Lapack 3.0 + updates
- self.package_base_name = 'lapack'
- self.package_dir_name = 'LAPACK'
- self.package_url = lapack_url
- self.tarball_suffix = 'tgz'
- self.build_type = 'make'
-
- self.platform = 'LINUX'
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
- def auto_configure(self):
- # perhaps this should actually override auto_conifgure
- # before make, we need to copy the appropriate setup file in.
- # should work anywhere g77 works...
- make_inc = 'make.inc.' + self.platform
- src_file = os.path.join(self.package_dir,'INSTALL',make_inc)
- dst_file = os.path.join(self.package_dir,'make.inc')
- copy_file(src_file,dst_file,self.logger)
-
- def build_with_make(self, **kw):
- cmd = 'make install lapacklib'
- text = run_command(cmd,self.package_dir,self.logger)
-
- def install_with_make(self, **kw):
- # not really using make -- we'll just copy the file over.
- src_file = os.path.join(self.package_dir,'lapack_%s.a' % self.platform)
- dst_file = os.path.join(self.dst_dir,'lib','liblapack.a')
- copy_file(src_file,dst_file,self.logger)
-
-#-----------------------------------------------------------------------------
-# Installation class for Numeric
-#-----------------------------------------------------------------------------
-
-class numeric_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- self.package_base_name = 'Numeric-'+version
- self.package_dir_name = self.package_base_name
- self.package_url = numeric_url
- self.tarball_suffix = 'tar.gz'
- self.build_type = 'setup'
-
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
-
-#-----------------------------------------------------------------------------
-# Installation class for f2py
-#-----------------------------------------------------------------------------
-
-class f2py_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- # Typical file format: F2PY-2.13.175-1250.tar.gz
- self.package_base_name = 'F2PY-'+version
- self.package_dir_name = self.package_base_name
- self.package_url = f2py_url
- self.tarball_suffix = 'tar.gz'
- self.build_type = 'setup'
-
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
-
-#-----------------------------------------------------------------------------
-# Installation class for Atlas.
-# This is a binary install *NOT* a source install.
-# The source install is a pain to automate.
-#-----------------------------------------------------------------------------
-
-class atlas_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- #self.package_base_name = 'atlas' + version
- #self.package_dir_name = 'ATLAS'
- self.package_base_name = 'atlas-RH7.1-PIII'
- self.package_dir_name = 'atlas'
- self.package_url = atlas_url
- self.tarball_suffix = 'tgz'
- self.build_type = 'make'
-
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
- def auto_configure(self,**kw):
- pass
- def build_with_make(self,**kw):
- pass
- def install_with_make(self, **kw):
- # just copy the tree over.
- dst = os.path.join(self.dst_dir,'lib','atlas')
- self.logger.info("Installing Atlas")
- copy_tree(self.package_dir,dst,self.logger)
-
-#-----------------------------------------------------------------------------
-# Installation class for scipy
-#-----------------------------------------------------------------------------
-
-class scipy_installation(package_installation):
-
- def __init__(self,version='', dst_dir = '.',logger=None,python_exe='python'):
-
- self.package_base_name = 'scipy_snapshot'
- self.package_dir_name = 'scipy'
- self.package_url = scipy_url
- self.tarball_suffix = 'tgz'
- self.build_type = 'setup'
-
- package_installation.__init__(self,version,dst_dir,logger,python_exe)
-
- def local_source_up_to_date(self):
- """ Hook to test whether a file found in the repository is current
- """
- file = os.path.join(local_repository,self.tarball)
- up_to_date = 0
- try:
- file_time = os.stat(file)[stat.ST_MTIME]
- fyear,fmonth,fday = time.localtime(file_time)[:3]
- year,month,day = time.localtime()[:3]
- if fyear == year and fmonth == month and fday == day:
- up_to_date = 1
- self.logger.info("Repository file up to date: %s" % file)
- except OSError, msg:
- pass
- return up_to_date
-
-#-----------------------------------------------------------------------------
-# Utilities
-#-----------------------------------------------------------------------------
-
-
-#if os.name == 'nt':
-# def exec_command(command):
-# """ not sure how to get exit status on nt. """
-# in_pipe,out_pipe = os.popen4(command)
-# in_pipe.close()
-# text = out_pipe.read()
-# return 0, text
-#else:
-# import commands
-# exec_command = commands.getstatusoutput
-
-# This may not work on Win98... The above stuff was to handle these machines.
-import commands
-exec_command = commands.getstatusoutput
-
-def copy_file(src,dst,logger=None):
- if not logger:
- logger = logging
- logger.info("Copying %s->%s" % (src,dst))
- try:
- file_util.copy_file(src,dst)
- except Exception, e:
- logger.exception("Copy Failed")
- raise
-
-def copy_tree(src,dst,logger=None):
- if not logger:
- logger = logging
- logger.info("Copying directory tree %s->%s" % (src,dst))
- try:
- dir_util.copy_tree(src,dst)
- except Exception, e:
- logger.exception("Copy Failed")
- raise
-
-def remove_tree(directory,logger=None):
- if not logger:
- logger = logging
- logger.info("Removing directory tree %s" % directory)
- try:
- dir_util.remove_tree(directory)
- except Exception, e:
- logger.exception("Remove failed: %s" % e)
- raise
-
-def remove_file(file,logger=None):
- if not logger:
- logger = logging
- logger.info("Remove file %s" % file)
- try:
- os.remove(file)
- except Exception, e:
- logger.exception("Remove failed")
- raise
-
-def write_file(file,contents,logger=None,mode='wb'):
- if not logger:
- logger = logging
- logger.info('Write file: %s' % file)
- try:
- new_file = open(file,mode)
- new_file.write(contents)
- new_file.close()
- except Exception, e:
- logger.exception("Write failed")
- raise
-
-def make_dir(name,logger=None):
- if not logger:
- logger = logging
- logger.info('Make directory: %s' % name)
- try:
- dir_util.mkpath(os.path.abspath(name))
- except Exception, e:
- logger.exception("Make Directory failed")
- raise
-
-# I know, I know...
-old_dir = []
-
-def change_dir(d, logger = None):
- if not logger:
- logger = logging
- global old_dir
- cwd = os.getcwd()
- old_dir.append(cwd)
- d = os.path.abspath(d)
- if d != old_dir[-1]:
- logger.info("Change directory: %s" % d)
- try:
- os.chdir(d)
- except Exception, e:
- logger.exception("Change directory failed")
- raise
- #if d == '.':
- # import sys,traceback
- # f = sys._getframe()
- # traceback.print_stack(f)
-
-def unchange_dir(logger=None):
- if not logger:
- logger = logging
- global old_dir
- try:
- cwd = os.getcwd()
- d = old_dir.pop(-1)
- try:
- if d != cwd:
- logger.info("Change directory : %s" % d)
- os.chdir(d)
- except Exception, e:
- logger.exception("Change directory failed")
- raise
- except IndexError:
- logger.exception("Change directory failed")
-
-def decompress_file(src,dst,logger = None):
- if not logger:
- logger = logging
- logger.info("Upacking %s->%s" % (src,dst))
- try:
- f = gzip.open(src,'rb')
- contents = f.read(-1)
- f = open(dst, 'wb')
- f.write(contents)
- except Exception, e:
- logger.exception("Unpack failed")
- raise
-
-
-def untar_file(file,dst_dir='.',logger = None,silent_failure = 0):
- if not logger:
- logger = logging
- logger.info("Untarring file: %s" % (file))
- try:
- run_command('tar -xf ' + file,directory = dst_dir,
- logger=logger, silent_failure = silent_failure)
- except Exception, e:
- if not silent_failure:
- logger.exception("Untar failed")
- raise
-
-def unpack_file(file,logger = None):
- """ equivalent to 'tar -xzvf file'
- """
- dst = 'tmp.tar'
- decompress_file(file,dst,logger)
- untar_file(dst.logger)
- remove_file(dst,logger)
-
-
-def run_command(cmd,directory='.',logger=None,silent_failure = 0):
- if not logger:
- logger = logging
- change_dir(directory,logger)
- try:
- msg = 'Running: %s' % cmd
- logger.info(msg)
- status,text = exec_command(cmd)
- if status and silent_failure:
- msg = '(failed silently)'
- logger.info(msg)
- if status and text and not silent_failure:
- logger.error('Command Failed (status=%d)\n'% status +text)
- finally:
- unchange_dir(logger)
- if status:
- raise ValueError, (status,text)
- return text
-
-def mail_report(from_addr,to_addr,subject,mail_server,
- build_log, test_results,info):
-
- msg = ''
- msg = msg + 'To: %s\n' % to_addr
- msg = msg + 'Subject: %s\n' % subject
- msg = msg + '\r\n\r\n'
-
- for k,v in info.items():
- msg = msg + '%s: %s\n' % (k,v)
- msg = msg + test_results + '\n'
- msg = msg + '-----------------------------\n'
- msg = msg + '-------- BUILD LOG -------\n'
- msg = msg + '-----------------------------\n'
- msg = msg + build_log
- print msg
-
- # mail results
- import smtplib
- server = smtplib.SMTP(mail_server)
- server.sendmail(from_addr, to_addr, msg)
- server.quit()
-
-
-def full_scipy_build(build_dir = '.',
- test_level = 10,
- python_version = '2.2.1',
- numeric_version = '21.0',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot'):
-
- # for now the atlas version is ignored. Only the
- # binaries for RH are supported at the moment.
-
- build_info = {'python_version' : python_version,
- 'test_level' : test_level,
- 'numeric_version': numeric_version,
- 'f2py_version' : f2py_version,
- 'atlas_version' : atlas_version,
- 'scipy_version' : scipy_version}
-
- dst_dir = os.path.join(build_dir,sys.platform)
-
- logger = logging.Logger("SciPy Test")
- fmt = logging.Formatter(logging.BASIC_FORMAT)
- log_stream = cStringIO.StringIO()
- stream_handler = logging.StreamHandler(log_stream)
- stream_handler.setFormatter(fmt)
- logger.addHandler(stream_handler)
- # also write to stderr
- stderr = logging.StreamHandler()
- stderr.setFormatter(fmt)
- logger.addHandler(stderr)
-
- try:
- try:
-
- # before doing anything, we need to wipe the
- # /bin, /lib, /man, and /include directories
- # in dst_dir. Don't run as root.
- make_dir(dst_dir,logger=logger)
- change_dir(dst_dir , logger)
- for d in ['bin','lib','man','include']:
- try: remove_tree(d, logger)
- except OSError: pass
- unchange_dir(logger)
-
- python = python_installation(version=python_version,
- logger = logger,
- dst_dir = dst_dir)
- python.install()
-
- python_name = python.get_exe_name()
-
- numeric = numeric_installation(version=numeric_version,
- dst_dir = dst_dir,
- logger = logger,
- python_exe=python_name)
- numeric.install()
-
- f2py = f2py_installation(version=f2py_version,
- logger = logger,
- dst_dir = dst_dir,
- python_exe=python_name)
- f2py.install()
-
- # download files don't have a version specified
- #lapack = lapack_installation(version='',
- # dst_dir = dst_dir
- # python_exe=python_name)
- #lapack.install()
-
- # download files don't have a version specified
- #blas = blas_installation(version='',
- # logger = logger,
- # dst_dir = dst_dir,
- # python_exe=python_name)
- #blas.install()
-
- # ATLAS
- atlas = atlas_installation(version=atlas_version,
- logger = logger,
- dst_dir = dst_dir,
- python_exe=python_name)
- atlas.install()
-
- # version not currently used -- need to fix this.
- scipy = scipy_installation(version=scipy_version,
- logger = logger,
- dst_dir = dst_dir,
- python_exe=python_name)
- scipy.install()
-
- # The change to tmp makes sure there isn't a scipy directory in
- # the local scope.
- # All tests are run.
- logger.info('Beginning Test')
- cmd = python_name +' -c "import sys,scipy;suite=scipy.test(%d);"'\
- % test_level
- test_results = run_command(cmd, logger=logger,
- directory = tempfile.gettempdir())
- build_info['results'] = 'test completed (check below for pass/fail)'
- except Exception, msg:
- test_results = ''
- build_info['results'] = 'build failed: %s' % msg
- logger.exception('Build failed')
- finally:
- to_addr = "scipy-testlog@scipy.org"
- from_addr = "scipy-test@enthought.com"
- subject = '%s,py%s,num%s,scipy%s' % (sys.platform,python_version,
- numeric_version,scipy_version)
- build_log = log_stream.getvalue()
- mail_report(from_addr,to_addr,subject,local_mail_server,
- build_log,test_results,build_info)
-
-if __name__ == '__main__':
- build_dir = '/tmp/scipy_test'
- level = 10
-
- full_scipy_build(build_dir = build_dir,
- test_level = level,
- python_version = '2.2.1',
- numeric_version = '21.0',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot')
-
- # an older python
- full_scipy_build(build_dir = build_dir,
- test_level = level,
- python_version = '2.1.3',
- numeric_version = '21.0',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot')
-
- # an older numeric
- full_scipy_build(build_dir = build_dir,
- test_level = level,
- python_version = '2.1.3',
- numeric_version = '20.3',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot')
-
- # This fails because multiarray doesn't have
- # arange defined.
- """
- full_scipy_build(build_dir = build_dir,
- test_level = level,
- python_version = '2.1.3',
- numeric_version = '20.0.0',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot')
-
- full_scipy_build(build_dir = build_dir,
- test_level = level,
- python_version = '2.1.3',
- numeric_version = '19.0.0',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot')
-
- full_scipy_build(build_dir = build_dir,
- test_level = level,
- python_version = '2.1.3',
- numeric_version = '18.4.1',
- f2py_version = '2.13.175-1250',
- atlas_version = '3.3.14',
- scipy_version = 'snapshot')
- """
diff --git a/scipy/test/info.py b/scipy/test/info.py
deleted file mode 100644
index 8b481fe52..000000000
--- a/scipy/test/info.py
+++ /dev/null
@@ -1,12 +0,0 @@
-"""
-Scipy testing tools
-===================
-
-Modules
--------
-
- testing -- useful tools for scipy-style testing sites.
-
-"""
-
-global_symbols = ['ScipyTest']
diff --git a/scipy/test/testing.py b/scipy/test/testing.py
deleted file mode 100644
index 7272c9cd0..000000000
--- a/scipy/test/testing.py
+++ /dev/null
@@ -1,825 +0,0 @@
-"""
-Unit-testing
-------------
-
- ScipyTest -- Scipy tests site manager
- ScipyTestCase -- unittest.TestCase with measure method
- IgnoreException -- raise when checking disabled feature ('ignoring' is displayed)
- set_package_path -- prepend package build directory to path
- set_local_path -- prepend local directory (to tests files) to path
- restore_path -- restore path after set_package_path
-
-Timing tools
-------------
-
- jiffies -- return 1/100ths of a second that the current process has used
- memusage -- virtual memory size in bytes of the running python [linux]
-
-Utility functions
------------------
-
- assert_equal -- assert equality
- assert_almost_equal -- assert equality with decimal tolerance
- assert_approx_equal -- assert equality with significant digits tolerance
- assert_array_equal -- assert arrays equality
- assert_array_almost_equal -- assert arrays equality with decimal tolerance
- assert_array_less -- assert arrays less-ordering
- rand -- array of random numbers from given shape
-
-"""
-
-__all__ = []
-
-import os,sys,time,glob,string,traceback,unittest
-import types
-import imp
-
-#
-# Imports from scipy.base must be done at the end of this file.
-#
-
-DEBUG = 0
-
-__all__.append('set_package_path')
-def set_package_path(level=1):
- """ Prepend package directory to sys.path.
-
- set_package_path should be called from a test_file.py that
- satisfies the following tree structure:
-
- <somepath>/<somedir>/test_file.py
-
- Then the first existing path name from the following list
-
- <somepath>/build/lib.<platform>-<version>
- <somepath>/..
-
- is prepended to sys.path.
- The caller is responsible for removing this path by using
-
- restore_path()
- """
- from distutils.util import get_platform
- from scipy.distutils.misc_util import get_frame
- f = get_frame(level)
- if f.f_locals['__name__']=='__main__':
- testfile = sys.argv[0]
- else:
- testfile = f.f_locals['__file__']
- d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))
- d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))
- if not os.path.isdir(d1):
- d1 = os.path.dirname(d)
- if DEBUG:
- print 'Inserting %r to sys.path' % (d1)
- sys.path.insert(0,d1)
-
-__all__.append('set_local_path')
-def set_local_path(reldir='', level=1):
- """ Prepend local directory to sys.path.
-
- The caller is responsible for removing this path by using
-
- restore_path()
- """
- from scipy.distutils.misc_util import get_frame
- f = get_frame(level)
- if f.f_locals['__name__']=='__main__':
- testfile = sys.argv[0]
- else:
- testfile = f.f_locals['__file__']
- local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)
- if DEBUG:
- print 'Inserting %r to sys.path' % (local_path)
- sys.path.insert(0,local_path)
-
-__all__.append('restore_path')
-def restore_path():
- if DEBUG:
- print 'Removing %r from sys.path' % (sys.path[0])
- del sys.path[0]
-
-__all__.extend(['jiffies','memusage'])
-if sys.platform[:5]=='linux':
- def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),
- _load_time=time.time()):
- """ Return number of jiffies (1/100ths of a second) that this
- process has been scheduled in user mode. See man 5 proc. """
- try:
- f=open(_proc_pid_stat,'r')
- l = f.readline().split(' ')
- f.close()
- return int(l[13])
- except:
- return int(100*(time.time()-_load_time))
-
- def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):
- """ Return virtual memory size in bytes of the running python.
- """
- try:
- f=open(_proc_pid_stat,'r')
- l = f.readline().split(' ')
- f.close()
- return int(l[22])
- except:
- return
-else:
- # os.getpid is not in all platforms available.
- # Using time is safe but inaccurate, especially when process
- # was suspended or sleeping.
- def jiffies(_load_time=time.time()):
- """ Return number of jiffies (1/100ths of a second) that this
- process has been scheduled in user mode. [Emulation with time.time]. """
- return int(100*(time.time()-_load_time))
-
- def memusage():
- """ Return memory usage of running python. [Not implemented]"""
- return
-
-__all__.append('ScipyTestCase')
-class ScipyTestCase (unittest.TestCase):
-
- def measure(self,code_str,times=1):
- """ Return elapsed time for executing code_str in the
- namespace of the caller for given times.
- """
- frame = sys._getframe(1)
- locs,globs = frame.f_locals,frame.f_globals
- code = compile(code_str,
- 'ScipyTestCase runner for '+self.__class__.__name__,
- 'exec')
- i = 0
- elapsed = jiffies()
- while i<times:
- i += 1
- exec code in globs,locs
- elapsed = jiffies() - elapsed
- return 0.01*elapsed
-
- def __call__(self, result=None):
- if result is None:
- return unittest.TestCase.__call__(self, result)
-
- nof_errors = len(result.errors)
- save_stream = result.stream
- result.stream = _dummy_stream(save_stream)
- unittest.TestCase.__call__(self, result)
- if nof_errors != len(result.errors):
- test, errstr = result.errors[-1]
- if type(errstr) is type(()):
- errstr = str(errstr[0])
- else:
- errstr = errstr.split('\n')[-2]
- l = len(result.stream.data)
- if errstr.startswith('IgnoreException:'):
- if l==1:
- assert result.stream.data[-1]=='E',`result.stream.data`
- result.stream.data[-1] = 'i'
- else:
- assert result.stream.data[-1]=='ERROR\n',`result.stream.data`
- result.stream.data[-1] = 'ignoring\n'
- del result.errors[-1]
- map(save_stream.write, result.stream.data)
- result.stream = save_stream
-
-class _dummy_stream:
- def __init__(self,stream):
- self.data = []
- self.stream = stream
- def write(self,message):
- if not self.data and not message.startswith('E'):
- self.stream.write(message)
- self.stream.flush()
- message = ''
- self.data.append(message)
- def writeln(self,message):
- self.write(message+'\n')
-
-__all__.append('IgnoreException')
-class IgnoreException(Exception):
- "Ignoring this exception due to disabled feature"
-
-#------------
-
-def _get_all_method_names(cls):
- names = dir(cls)
- if sys.version[:3]<='2.1':
- for b in cls.__bases__:
- for n in dir(b)+_get_all_method_names(b):
- if n not in names:
- names.append(n)
- return names
-
-# for debug build--check for memory leaks during the test.
-class _SciPyTextTestResult(unittest._TextTestResult):
- def startTest(self, test):
- unittest._TextTestResult.startTest(self, test)
- if self.showAll:
- N = len(sys.getobjects(0))
- self._totnumobj = N
- self._totrefcnt = sys.gettotalrefcount()
-
- def stopTest(self, test):
- if self.showAll:
- N = len(sys.getobjects(0))
- self.stream.write("objects: %d ===> %d; " % (self._totnumobj, N))
- self.stream.write("refcnts: %d ===> %d\n" % (self._totrefcnt,
- sys.gettotalrefcount()))
-
-class SciPyTextTestRunner(unittest.TextTestRunner):
- def _makeResult(self):
- return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)
-
-__all__.append('ScipyTest')
-class ScipyTest:
- """ Scipy tests site manager.
-
- Usage:
- >>> ScipyTest(<package>).test(level=1,verbosity=2)
-
- <package> is package name or its module object.
-
- Package is supposed to contain a directory tests/
- with test_*.py files where * refers to the names of submodules.
-
- test_*.py files are supposed to define a classes, derived
- from ScipyTestCase or unittest.TestCase, with methods having
- names starting with test or bench or check.
-
- And that is it! No need to implement test or test_suite functions
- in each .py file.
-
- Also old styled test_suite(level=1) hooks are supported but
- soon to be removed.
- """
- def __init__(self, package=None):
- if package is None:
- from scipy.distutils.misc_util import get_frame
- f = get_frame(1)
- package = f.f_locals['__name__']
- self.package = package
-
- def _module_str(self, module):
- filename = module.__file__[-30:]
- if filename!=module.__file__:
- filename = '...'+filename
- return '<module %s from %s>' % (`module.__name__`, `filename`)
-
- def _get_method_names(self,clsobj,level):
- names = []
- for mthname in _get_all_method_names(clsobj):
- if mthname[:5] not in ['bench','check'] \
- and mthname[:4] not in ['test']:
- continue
- mth = getattr(clsobj, mthname)
- if type(mth) is not types.MethodType:
- continue
- d = mth.im_func.func_defaults
- if d is not None:
- mthlevel = d[0]
- else:
- mthlevel = 1
- if level>=mthlevel:
- if mthname not in names:
- names.append(mthname)
- for base in clsobj.__bases__:
- for n in self._get_method_names(base,level):
- if n not in names:
- names.append(n)
- return names
-
- def _get_module_tests(self,module,level,verbosity):
- mstr = self._module_str
- d,f = os.path.split(module.__file__)
-
- short_module_name = os.path.splitext(os.path.basename(f))[0]
- if short_module_name=='__init__':
- short_module_name = module.__name__.split('.')[-1]
-
- test_dir = os.path.join(d,'tests')
- test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')
-
- local_test_dir = os.path.join(os.getcwd(),'tests')
- local_test_file = os.path.join(local_test_dir,
- 'test_'+short_module_name+'.py')
- if os.path.basename(os.path.dirname(local_test_dir)) \
- == os.path.basename(os.path.dirname(test_dir)) \
- and os.path.isfile(local_test_file):
- test_file = local_test_file
-
- if not os.path.isfile(test_file):
- if short_module_name[:5]=='info_' \
- and short_module_name[5:]==module.__name__.split('.')[-2]:
- return []
- if short_module_name in ['__cvs_version__','__svn_version__']:
- return []
- if short_module_name[-8:]=='_version' \
- and short_module_name[:-8]==module.__name__.split('.')[-2]:
- return []
- if verbosity>1:
- print test_file
- print ' !! No test file %r found for %s' \
- % (os.path.basename(test_file), mstr(module))
- return []
-
- try:
- if sys.version[:3]=='2.1':
- # Workaround for Python 2.1 .pyc file generator bug
- import random
- pref = '-nopyc'+`random.randint(1,100)`
- else:
- pref = ''
- f = open(test_file,'r')
- test_module = imp.load_module(\
- module.__name__+'.test_'+short_module_name+pref,
- f, test_file+pref,('.py', 'r', 1))
- f.close()
- if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):
- os.remove(test_file+pref+'c')
- except:
- print ' !! FAILURE importing tests for ', mstr(module)
- print ' ',
- output_exception()
- return []
- return self._get_suite_list(test_module, level, module.__name__)
-
- def _get_suite_list(self, test_module, level, module_name='__main__'):
- mstr = self._module_str
- if hasattr(test_module,'test_suite'):
- # Using old styled test suite
- try:
- total_suite = test_module.test_suite(level)
- return total_suite._tests
- except:
- print ' !! FAILURE building tests for ', mstr(test_module)
- print ' ',
- output_exception()
- return []
- suite_list = []
- for name in dir(test_module):
- obj = getattr(test_module, name)
- if type(obj) is not type(unittest.TestCase) \
- or not issubclass(obj, unittest.TestCase) \
- or obj.__name__[:4] != 'test':
- continue
- for mthname in self._get_method_names(obj,level):
- suite = obj(mthname)
- if getattr(suite,'isrunnable',lambda mthname:1)(mthname):
- suite_list.append(suite)
- print ' Found',len(suite_list),'tests for',module_name
- return suite_list
-
- def test(self,level=1,verbosity=1):
- """ Run Scipy module test suite with level and verbosity.
- """
- if type(self.package) is type(''):
- exec 'import %s as this_package' % (self.package)
- else:
- this_package = self.package
-
- package_name = this_package.__name__
-
- suites = []
- for name, module in sys.modules.items():
- if package_name != name[:len(package_name)] \
- or module is None:
- continue
- if os.path.basename(os.path.dirname(module.__file__))=='tests':
- continue
- suites.extend(self._get_module_tests(module, level, verbosity))
-
- suites.extend(self._get_suite_list(sys.modules[package_name], level))
-
- all_tests = unittest.TestSuite(suites)
- #if hasattr(sys,'getobjects'):
- # runner = SciPyTextTestRunner(verbosity=verbosity)
- #else:
- runner = unittest.TextTestRunner(verbosity=verbosity)
- # Use the builtin displayhook. If the tests are being run
- # under IPython (for instance), any doctest test suites will
- # fail otherwise.
- old_displayhook = sys.displayhook
- sys.displayhook = sys.__displayhook__
- try:
- runner.run(all_tests)
- finally:
- sys.displayhook = old_displayhook
- return runner
-
- def run(self):
- """ Run Scipy module test suite with level and verbosity
- taken from sys.argv. Requires optparse module.
- """
- try:
- from optparse import OptionParser
- except ImportError:
- print 'Failed to import optparse module, ignoring.'
- return self.test()
- usage = r'usage: %prog [-v <verbosity>] [-l <level>]'
- parser = OptionParser(usage)
- parser.add_option("-v", "--verbosity",
- action="store",
- dest="verbosity",
- default=1,
- type='int')
- parser.add_option("-l", "--level",
- action="store",
- dest="level",
- default=1,
- type='int')
- (options, args) = parser.parse_args()
- self.test(options.level,options.verbosity)
-
-#------------
-
-def remove_ignored_patterns(files,pattern):
- from fnmatch import fnmatch
- good_files = []
- for file in files:
- if not fnmatch(file,pattern):
- good_files.append(file)
- return good_files
-
-def remove_ignored_files(original,ignored_files,cur_dir):
- """ This is actually expanded to do pattern matching.
-
- """
- if not ignored_files: ignored_files = []
- ignored_modules = map(lambda x: x+'.py',ignored_files)
- ignored_packages = ignored_files[:]
- # always ignore setup.py and __init__.py files
- ignored_files = ['setup.py','setup_*.py','__init__.py']
- ignored_files += ignored_modules + ignored_packages
- ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),
- ignored_files)
- #print 'ignored:', ignored_files
- #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,
- # original)
- good_files = original
- for pattern in ignored_files:
- good_files = remove_ignored_patterns(good_files,pattern)
-
- return good_files
-
-__all__.append('harvest_modules')
-def harvest_modules(package,ignore=None):
- """* Retreive a list of all modules that live within a package.
-
- Only retreive files that are immediate children of the
- package -- do not recurse through child packages or
- directories. The returned list contains actual modules, not
- just their names.
- *"""
- d,f = os.path.split(package.__file__)
-
- # go through the directory and import every py file there.
- common_dir = os.path.join(d,'*.py')
- py_files = glob.glob(common_dir)
- #py_files.remove(os.path.join(d,'__init__.py'))
- #py_files.remove(os.path.join(d,'setup.py'))
-
- py_files = remove_ignored_files(py_files,ignore,d)
- #print 'py_files:', py_files
- try:
- prefix = package.__name__
- except:
- prefix = ''
-
- all_modules = []
- for file in py_files:
- d,f = os.path.split(file)
- base,ext = os.path.splitext(f)
- mod = prefix + '.' + base
- #print 'module: import ' + mod
- try:
- exec ('import ' + mod)
- all_modules.append(eval(mod))
- except:
- print 'FAILURE to import ' + mod
- output_exception()
-
- return all_modules
-
-__all__.append('harvest_packages')
-def harvest_packages(package,ignore = None):
- """ Retreive a list of all sub-packages that live within a package.
-
- Only retreive packages that are immediate children of this
- package -- do not recurse through child packages or
- directories. The returned list contains actual package objects, not
- just their names.
- """
- join = os.path.join
-
- d,f = os.path.split(package.__file__)
-
- common_dir = os.path.abspath(d)
- all_files = os.listdir(d)
-
- all_files = remove_ignored_files(all_files,ignore,'')
- #print 'all_files:', all_files
- try:
- prefix = package.__name__
- except:
- prefix = ''
- all_packages = []
- for directory in all_files:
- path = join(common_dir,directory)
- if os.path.isdir(path) and \
- os.path.exists(join(path,'__init__.py')):
- sub_package = prefix + '.' + directory
- #print 'sub-package import ' + sub_package
- try:
- exec ('import ' + sub_package)
- all_packages.append(eval(sub_package))
- except:
- print 'FAILURE to import ' + sub_package
- output_exception()
- return all_packages
-
-__all__.append('harvest_modules_and_packages')
-def harvest_modules_and_packages(package,ignore=None):
- """ Retreive list of all packages and modules that live within a package.
-
- See harvest_packages() and harvest_modules()
- """
- all = harvest_modules(package,ignore) + harvest_packages(package,ignore)
- return all
-
-__all__.append('harvest_test_suites')
-def harvest_test_suites(package,ignore = None,level=10):
- """
- package -- the module to test. This is an actual module object
- (not a string)
- ignore -- a list of module names to omit from the tests
- level -- a value between 1 and 10. 1 will run the minimum number
- of tests. This is a fast "smoke test". Tests that take
- longer to run should have higher numbers ranging up to 10.
- """
- suites=[]
- test_modules = harvest_modules_and_packages(package,ignore)
- #for i in test_modules:
- # print i.__name__
- for module in test_modules:
- if hasattr(module,'test_suite'):
- try:
- suite = module.test_suite(level=level)
- if suite:
- suites.append(suite)
- else:
- print " !! FAILURE without error - shouldn't happen",
- print module.__name__
- except:
- print ' !! FAILURE building test for ', module.__name__
- print ' ',
- output_exception()
- else:
- try:
- print 'No test suite found for ', module.__name__
- except AttributeError:
- # __version__.py getting replaced by a string throws a kink
- # in checking for modules, so we think is a module has
- # actually been overwritten
- print 'No test suite found for ', str(module)
- total_suite = unittest.TestSuite(suites)
- return total_suite
-
-__all__.append('module_test')
-def module_test(mod_name,mod_file,level=10):
- """*
-
- *"""
- #print 'testing', mod_name
- d,f = os.path.split(mod_file)
-
- # insert the tests directory to the python path
- test_dir = os.path.join(d,'tests')
- sys.path.insert(0,test_dir)
-
- # call the "test_xxx.test()" function for the appropriate
- # module.
-
- # This should deal with package naming issues correctly
- short_mod_name = string.split(mod_name,'.')[-1]
- test_module = 'test_' + short_mod_name
- test_string = 'import %s;reload(%s);%s.test(%d)' % \
- ((test_module,)*3 + (level,))
-
- # This would be better cause it forces a reload of the orginal
- # module. It doesn't behave with packages however.
- #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \
- # ((mod_name,) + (test_module,)*3)
- exec(test_string)
-
- # remove test directory from python path.
- sys.path = sys.path[1:]
-
-__all__.append('module_test_suite')
-def module_test_suite(mod_name,mod_file,level=10):
- #try:
- print ' creating test suite for:', mod_name
- d,f = os.path.split(mod_file)
-
- # insert the tests directory to the python path
- test_dir = os.path.join(d,'tests')
- sys.path.insert(0,test_dir)
-
- # call the "test_xxx.test()" function for the appropriate
- # module.
-
- # This should deal with package naming issues correctly
- short_mod_name = string.split(mod_name,'.')[-1]
- test_module = 'test_' + short_mod_name
- test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \
- ((test_module,)*3+(level,))
- #print test_string
- exec(test_string)
-
- # remove test directory from python path.
- sys.path = sys.path[1:]
- return suite
- #except:
- # print ' !! FAILURE loading test suite from', test_module, ':'
- # print ' ',
- # output_exception()
-
-
-# Utility function to facilitate testing.
-
-__all__.append('assert_equal')
-def assert_equal(actual,desired,err_msg='',verbose=1):
- """ Raise an assertion if two items are not
- equal. I think this should be part of unittest.py
- """
- if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):
- return assert_array_equal(actual, desired, err_msg)
- msg = '\nItems are not equal:\n' + err_msg
- try:
- if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):
- msg = msg \
- + 'DESIRED: ' + repr(desired) \
- + '\nACTUAL: ' + repr(actual)
- except:
- msg = msg \
- + 'DESIRED: ' + repr(desired) \
- + '\nACTUAL: ' + repr(actual)
- assert desired == actual, msg
-
-__all__.append('assert_almost_equal')
-def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):
- """ Raise an assertion if two items are not
- equal. I think this should be part of unittest.py
- """
- if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):
- return assert_array_almost_equal(actual, desired, decimal, err_msg)
- msg = '\nItems are not equal:\n' + err_msg
- try:
- if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):
- msg = msg \
- + 'DESIRED: ' + repr(desired) \
- + '\nACTUAL: ' + repr(actual)
- except:
- msg = msg \
- + 'DESIRED: ' + repr(desired) \
- + '\nACTUAL: ' + repr(actual)
- assert round(abs(desired - actual),decimal) == 0, msg
-
-__all__.append('assert_approx_equal')
-def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):
- """ Raise an assertion if two items are not
- equal. I think this should be part of unittest.py
- Approximately equal is defined as the number of significant digits
- correct
- """
- msg = '\nItems are not equal to %d significant digits:\n' % significant
- msg += err_msg
- actual, desired = map(float, (actual, desired))
- # Normalized the numbers to be in range (-10.0,10.0)
- scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))
- try:
- sc_desired = desired/scale
- except ZeroDivisionError:
- sc_desired = 0.0
- try:
- sc_actual = actual/scale
- except ZeroDivisionError:
- sc_actual = 0.0
- try:
- if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):
- msg = msg \
- + 'DESIRED: ' + repr(desired) \
- + '\nACTUAL: ' + repr(actual)
- except:
- msg = msg \
- + 'DESIRED: ' + repr(desired) \
- + '\nACTUAL: ' + repr(actual)
- assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg
-
-
-__all__.append('assert_array_equal')
-def assert_array_equal(x,y,err_msg=''):
- x,y = asarray(x), asarray(y)
- msg = '\nArrays are not equal'
- try:
- assert 0 in [len(shape(x)),len(shape(y))] \
- or (len(shape(x))==len(shape(y)) and \
- alltrue(equal(shape(x),shape(y)))),\
- msg + ' (shapes %s, %s mismatch):\n\t' \
- % (shape(x),shape(y)) + err_msg
- reduced = ravel(equal(x,y))
- cond = alltrue(reduced)
- if not cond:
- s1 = array2string(x,precision=16)
- s2 = array2string(y,precision=16)
- if len(s1)>120: s1 = s1[:120] + '...'
- if len(s2)>120: s2 = s2[:120] + '...'
- match = 100-100.0*reduced.tolist().count(1)/len(reduced)
- msg = msg + ' (mismatch %s%%):\n\tArray 1: %s\n\tArray 2: %s' % (match,s1,s2)
- assert cond,\
- msg + '\n\t' + err_msg
- except ValueError:
- raise ValueError, msg
-
-__all__.append('assert_array_almost_equal')
-def assert_array_almost_equal(x,y,decimal=6,err_msg=''):
- x = asarray(x)
- y = asarray(y)
- msg = '\nArrays are not almost equal'
- try:
- cond = alltrue(equal(shape(x),shape(y)))
- if not cond:
- msg = msg + ' (shapes mismatch):\n\t'\
- 'Shape of array 1: %s\n\tShape of array 2: %s' % (shape(x),shape(y))
- assert cond, msg + '\n\t' + err_msg
- reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))
- cond = alltrue(reduced)
- if not cond:
- s1 = array2string(x,precision=decimal+1)
- s2 = array2string(y,precision=decimal+1)
- if len(s1)>120: s1 = s1[:120] + '...'
- if len(s2)>120: s2 = s2[:120] + '...'
- match = 100-100.0*reduced.tolist().count(1)/len(reduced)
- msg = msg + ' (mismatch %s%%):\n\tArray 1: %s\n\tArray 2: %s' % (match,s1,s2)
- assert cond,\
- msg + '\n\t' + err_msg
- except ValueError:
- print sys.exc_value
- print shape(x),shape(y)
- print x, y
- raise ValueError, 'arrays are not almost equal'
-
-__all__.append('assert_array_less')
-def assert_array_less(x,y,err_msg=''):
- x,y = asarray(x), asarray(y)
- msg = '\nArrays are not less-ordered'
- try:
- assert alltrue(equal(shape(x),shape(y))),\
- msg + ' (shapes mismatch):\n\t' + err_msg
- reduced = ravel(less(x,y))
- cond = alltrue(reduced)
- if not cond:
- s1 = array2string(x,precision=16)
- s2 = array2string(y,precision=16)
- if len(s1)>120: s1 = s1[:120] + '...'
- if len(s2)>120: s2 = s2[:120] + '...'
- match = 100-100.0*reduced.tolist().count(1)/len(reduced)
- msg = msg + ' (mismatch %s%%):\n\tArray 1: %s\n\tArray 2: %s' % (match,s1,s2)
- assert cond,\
- msg + '\n\t' + err_msg
- except ValueError:
- print shape(x),shape(y)
- raise ValueError, 'arrays are not less-ordered'
-
-__all__.append('rand')
-def rand(*args):
- """Returns an array of random numbers with the given shape.
-
- This only uses the standard library, so it is useful for testing purposes.
- """
- import random
- results = zeros(args,Float64)
- f = results.flat
- for i in range(len(f)):
- f[i] = random.random()
- return results
-
-def output_exception():
- try:
- type, value, tb = sys.exc_info()
- info = traceback.extract_tb(tb)
- #this is more verbose
- #traceback.print_exc()
- filename, lineno, function, text = info[-1] # last line only
- print "%s:%d: %s: %s (in %s)" %\
- (filename, lineno, type.__name__, str(value), function)
- finally:
- type = value = tb = None # clean up
-
-from scipy.base import alltrue, equal, shape, ravel, around, zeros,\
- Float64, asarray, less_equal, array2string, less, ArrayType
-
-try:
- from scipy.base import math
-except ImportError,msg:
- print msg
- import math
diff --git a/scipy/testing/__init__.py b/scipy/testing/__init__.py
new file mode 100644
index 000000000..bb6cfacdc
--- /dev/null
+++ b/scipy/testing/__init__.py
@@ -0,0 +1,4 @@
+
+from info import __doc__
+from utils import *
+from scipytest import *
diff --git a/scipy/testing/info.py b/scipy/testing/info.py
new file mode 100644
index 000000000..9b5caa074
--- /dev/null
+++ b/scipy/testing/info.py
@@ -0,0 +1,30 @@
+"""
+Scipy testing tools
+===================
+
+Scipy-style unit-testing
+------------------------
+
+ ScipyTest -- Scipy tests site manager
+ ScipyTestCase -- unittest.TestCase with measure method
+ IgnoreException -- raise when checking disabled feature, it'll be ignored
+ set_package_path -- prepend package build directory to path
+ set_local_path -- prepend local directory (to tests files) to path
+ restore_path -- restore path after set_package_path
+
+Utility functions
+-----------------
+
+ jiffies -- return 1/100ths of a second that the current process has used
+ memusage -- virtual memory size in bytes of the running python [linux]
+ rand -- array of random numbers from given shape
+ assert_equal -- assert equality
+ assert_almost_equal -- assert equality with decimal tolerance
+ assert_approx_equal -- assert equality with significant digits tolerance
+ assert_array_equal -- assert arrays equality
+ assert_array_almost_equal -- assert arrays equality with decimal tolerance
+ assert_array_less -- assert arrays less-ordering
+
+"""
+
+global_symbols = ['ScipyTest']
diff --git a/scipy/test/scipy_test_version.py b/scipy/testing/scipy_test_version.py
index 8f27d48a8..8f27d48a8 100644
--- a/scipy/test/scipy_test_version.py
+++ b/scipy/testing/scipy_test_version.py
diff --git a/scipy/testing/scipytest.py b/scipy/testing/scipytest.py
new file mode 100644
index 000000000..b2aea7b72
--- /dev/null
+++ b/scipy/testing/scipytest.py
@@ -0,0 +1,385 @@
+
+import os
+import sys
+import imp
+import types
+import unittest
+import traceback
+
+__all__ = ['set_package_path', 'set_local_path', 'restore_path',
+ 'IgnoreException', 'ScipyTestCase', 'ScipyTest']
+
+DEBUG=0
+get_frame = sys._getframe
+from utils import jiffies
+
+
+class IgnoreException(Exception):
+ "Ignoring this exception due to disabled feature"
+
+
+def set_package_path(level=1):
+ """ Prepend package directory to sys.path.
+
+ set_package_path should be called from a test_file.py that
+ satisfies the following tree structure:
+
+ <somepath>/<somedir>/test_file.py
+
+ Then the first existing path name from the following list
+
+ <somepath>/build/lib.<platform>-<version>
+ <somepath>/..
+
+ is prepended to sys.path.
+ The caller is responsible for removing this path by using
+
+ restore_path()
+ """
+ from distutils.util import get_platform
+ f = get_frame(level)
+ if f.f_locals['__name__']=='__main__':
+ testfile = sys.argv[0]
+ else:
+ testfile = f.f_locals['__file__']
+ d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))
+ d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))
+ if not os.path.isdir(d1):
+ d1 = os.path.dirname(d)
+ if DEBUG:
+ print 'Inserting %r to sys.path' % (d1)
+ sys.path.insert(0,d1)
+ return
+
+
+def set_local_path(reldir='', level=1):
+ """ Prepend local directory to sys.path.
+
+ The caller is responsible for removing this path by using
+
+ restore_path()
+ """
+ f = get_frame(level)
+ if f.f_locals['__name__']=='__main__':
+ testfile = sys.argv[0]
+ else:
+ testfile = f.f_locals['__file__']
+ local_path = os.path.join(os.path.dirname(os.path.abspath(testfile)),reldir)
+ if DEBUG:
+ print 'Inserting %r to sys.path' % (local_path)
+ sys.path.insert(0,local_path)
+ return
+
+
+def restore_path():
+ if DEBUG:
+ print 'Removing %r from sys.path' % (sys.path[0])
+ del sys.path[0]
+ return
+
+
+def output_exception():
+ try:
+ type, value, tb = sys.exc_info()
+ info = traceback.extract_tb(tb)
+ #this is more verbose
+ #traceback.print_exc()
+ filename, lineno, function, text = info[-1] # last line only
+ print "%s:%d: %s: %s (in %s)" %\
+ (filename, lineno, type.__name__, str(value), function)
+ finally:
+ type = value = tb = None # clean up
+ return
+
+
+class _dummy_stream:
+ def __init__(self,stream):
+ self.data = []
+ self.stream = stream
+ def write(self,message):
+ if not self.data and not message.startswith('E'):
+ self.stream.write(message)
+ self.stream.flush()
+ message = ''
+ self.data.append(message)
+ def writeln(self,message):
+ self.write(message+'\n')
+
+
+class ScipyTestCase (unittest.TestCase):
+
+ def measure(self,code_str,times=1):
+ """ Return elapsed time for executing code_str in the
+ namespace of the caller for given times.
+ """
+ frame = get_frame(1)
+ locs,globs = frame.f_locals,frame.f_globals
+ code = compile(code_str,
+ 'ScipyTestCase runner for '+self.__class__.__name__,
+ 'exec')
+ i = 0
+ elapsed = jiffies()
+ while i<times:
+ i += 1
+ exec code in globs,locs
+ elapsed = jiffies() - elapsed
+ return 0.01*elapsed
+
+ def __call__(self, result=None):
+ if result is None:
+ return unittest.TestCase.__call__(self, result)
+
+ nof_errors = len(result.errors)
+ save_stream = result.stream
+ result.stream = _dummy_stream(save_stream)
+ unittest.TestCase.__call__(self, result)
+ if nof_errors != len(result.errors):
+ test, errstr = result.errors[-1]
+ if type(errstr) is type(()):
+ errstr = str(errstr[0])
+ else:
+ errstr = errstr.split('\n')[-2]
+ l = len(result.stream.data)
+ if errstr.startswith('IgnoreException:'):
+ if l==1:
+ assert result.stream.data[-1]=='E',`result.stream.data`
+ result.stream.data[-1] = 'i'
+ else:
+ assert result.stream.data[-1]=='ERROR\n',`result.stream.data`
+ result.stream.data[-1] = 'ignoring\n'
+ del result.errors[-1]
+ map(save_stream.write, result.stream.data)
+ result.stream = save_stream
+
+def _get_all_method_names(cls):
+ names = dir(cls)
+ if sys.version[:3]<='2.1':
+ for b in cls.__bases__:
+ for n in dir(b)+_get_all_method_names(b):
+ if n not in names:
+ names.append(n)
+ return names
+
+
+# for debug build--check for memory leaks during the test.
+class _SciPyTextTestResult(unittest._TextTestResult):
+ def startTest(self, test):
+ unittest._TextTestResult.startTest(self, test)
+ if self.showAll:
+ N = len(sys.getobjects(0))
+ self._totnumobj = N
+ self._totrefcnt = sys.gettotalrefcount()
+ return
+
+ def stopTest(self, test):
+ if self.showAll:
+ N = len(sys.getobjects(0))
+ self.stream.write("objects: %d ===> %d; " % (self._totnumobj, N))
+ self.stream.write("refcnts: %d ===> %d\n" % (self._totrefcnt,
+ sys.gettotalrefcount()))
+ return
+
+class SciPyTextTestRunner(unittest.TextTestRunner):
+ def _makeResult(self):
+ return _SciPyTextTestResult(self.stream, self.descriptions, self.verbosity)
+
+
+class ScipyTest:
+ """ Scipy tests site manager.
+
+ Usage:
+ >>> ScipyTest(<package>).test(level=1,verbosity=2)
+
+ <package> is package name or its module object.
+
+ Package is supposed to contain a directory tests/
+ with test_*.py files where * refers to the names of submodules.
+
+ test_*.py files are supposed to define a classes, derived
+ from ScipyTestCase or unittest.TestCase, with methods having
+ names starting with test or bench or check.
+
+ And that is it! No need to implement test or test_suite functions
+ in each .py file.
+
+ Also old styled test_suite(level=1) hooks are supported but
+ soon to be removed.
+ """
+ def __init__(self, package=None):
+ if package is None:
+ from scipy.distutils.misc_util import get_frame
+ f = get_frame(1)
+ package = f.f_locals['__name__']
+ self.package = package
+
+ def _module_str(self, module):
+ filename = module.__file__[-30:]
+ if filename!=module.__file__:
+ filename = '...'+filename
+ return '<module %s from %s>' % (`module.__name__`, `filename`)
+
+ def _get_method_names(self,clsobj,level):
+ names = []
+ for mthname in _get_all_method_names(clsobj):
+ if mthname[:5] not in ['bench','check'] \
+ and mthname[:4] not in ['test']:
+ continue
+ mth = getattr(clsobj, mthname)
+ if type(mth) is not types.MethodType:
+ continue
+ d = mth.im_func.func_defaults
+ if d is not None:
+ mthlevel = d[0]
+ else:
+ mthlevel = 1
+ if level>=mthlevel:
+ if mthname not in names:
+ names.append(mthname)
+ for base in clsobj.__bases__:
+ for n in self._get_method_names(base,level):
+ if n not in names:
+ names.append(n)
+ return names
+
+ def _get_module_tests(self,module,level,verbosity):
+ mstr = self._module_str
+ d,f = os.path.split(module.__file__)
+
+ short_module_name = os.path.splitext(os.path.basename(f))[0]
+ if short_module_name=='__init__':
+ short_module_name = module.__name__.split('.')[-1]
+
+ test_dir = os.path.join(d,'tests')
+ test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')
+
+ local_test_dir = os.path.join(os.getcwd(),'tests')
+ local_test_file = os.path.join(local_test_dir,
+ 'test_'+short_module_name+'.py')
+ if os.path.basename(os.path.dirname(local_test_dir)) \
+ == os.path.basename(os.path.dirname(test_dir)) \
+ and os.path.isfile(local_test_file):
+ test_file = local_test_file
+
+ if not os.path.isfile(test_file):
+ if short_module_name[:5]=='info_' \
+ and short_module_name[5:]==module.__name__.split('.')[-2]:
+ return []
+ if short_module_name in ['__cvs_version__','__svn_version__']:
+ return []
+ if short_module_name[-8:]=='_version' \
+ and short_module_name[:-8]==module.__name__.split('.')[-2]:
+ return []
+ if verbosity>1:
+ print test_file
+ print ' !! No test file %r found for %s' \
+ % (os.path.basename(test_file), mstr(module))
+ return []
+
+ try:
+ if sys.version[:3]=='2.1':
+ # Workaround for Python 2.1 .pyc file generator bug
+ import random
+ pref = '-nopyc'+`random.randint(1,100)`
+ else:
+ pref = ''
+ f = open(test_file,'r')
+ test_module = imp.load_module(\
+ module.__name__+'.test_'+short_module_name+pref,
+ f, test_file+pref,('.py', 'r', 1))
+ f.close()
+ if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):
+ os.remove(test_file+pref+'c')
+ except:
+ print ' !! FAILURE importing tests for ', mstr(module)
+ print ' ',
+ output_exception()
+ return []
+ return self._get_suite_list(test_module, level, module.__name__)
+
+ def _get_suite_list(self, test_module, level, module_name='__main__'):
+ mstr = self._module_str
+ if hasattr(test_module,'test_suite'):
+ # Using old styled test suite
+ try:
+ total_suite = test_module.test_suite(level)
+ return total_suite._tests
+ except:
+ print ' !! FAILURE building tests for ', mstr(test_module)
+ print ' ',
+ output_exception()
+ return []
+ suite_list = []
+ for name in dir(test_module):
+ obj = getattr(test_module, name)
+ if type(obj) is not type(unittest.TestCase) \
+ or not issubclass(obj, unittest.TestCase) \
+ or obj.__name__[:4] != 'test':
+ continue
+ for mthname in self._get_method_names(obj,level):
+ suite = obj(mthname)
+ if getattr(suite,'isrunnable',lambda mthname:1)(mthname):
+ suite_list.append(suite)
+ print ' Found',len(suite_list),'tests for',module_name
+ return suite_list
+
+ def test(self,level=1,verbosity=1):
+ """ Run Scipy module test suite with level and verbosity.
+ """
+ if type(self.package) is type(''):
+ exec 'import %s as this_package' % (self.package)
+ else:
+ this_package = self.package
+
+ package_name = this_package.__name__
+
+ suites = []
+ for name, module in sys.modules.items():
+ if package_name != name[:len(package_name)] \
+ or module is None:
+ continue
+ if os.path.basename(os.path.dirname(module.__file__))=='tests':
+ continue
+ suites.extend(self._get_module_tests(module, level, verbosity))
+
+ suites.extend(self._get_suite_list(sys.modules[package_name], level))
+
+ all_tests = unittest.TestSuite(suites)
+ #if hasattr(sys,'getobjects'):
+ # runner = SciPyTextTestRunner(verbosity=verbosity)
+ #else:
+ runner = unittest.TextTestRunner(verbosity=verbosity)
+ # Use the builtin displayhook. If the tests are being run
+ # under IPython (for instance), any doctest test suites will
+ # fail otherwise.
+ old_displayhook = sys.displayhook
+ sys.displayhook = sys.__displayhook__
+ try:
+ runner.run(all_tests)
+ finally:
+ sys.displayhook = old_displayhook
+ return runner
+
+ def run(self):
+ """ Run Scipy module test suite with level and verbosity
+ taken from sys.argv. Requires optparse module.
+ """
+ try:
+ from optparse import OptionParser
+ except ImportError:
+ print 'Failed to import optparse module, ignoring.'
+ return self.test()
+ usage = r'usage: %prog [-v <verbosity>] [-l <level>]'
+ parser = OptionParser(usage)
+ parser.add_option("-v", "--verbosity",
+ action="store",
+ dest="verbosity",
+ default=1,
+ type='int')
+ parser.add_option("-l", "--level",
+ action="store",
+ dest="level",
+ default=1,
+ type='int')
+ (options, args) = parser.parse_args()
+ self.test(options.level,options.verbosity)
+ return
diff --git a/scipy/testing/setup.py b/scipy/testing/setup.py
new file mode 100755
index 000000000..0f7764f07
--- /dev/null
+++ b/scipy/testing/setup.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+def configuration(parent_package='',top_path=None):
+ from scipy.distutils.misc_util import Configuration
+ config = Configuration('testing',parent_package,top_path)
+ return config
+
+if __name__ == '__main__':
+ from scipy.distutils.core import setup
+ setup(maintainer = "SciPy Developers",
+ maintainer_email = "scipy-dev@scipy.org",
+ description = "SciPy test module",
+ url = "http://www.scipy.org",
+ license = "SciPy License (BSD Style)",
+ **configuration(top_path='').todict()
+ )
diff --git a/scipy/test/setup_scipy_test.py b/scipy/testing/setup_scipy_test.py
index 6495ffa90..6495ffa90 100755
--- a/scipy/test/setup_scipy_test.py
+++ b/scipy/testing/setup_scipy_test.py
diff --git a/scipy/testing/testing.py b/scipy/testing/testing.py
new file mode 100644
index 000000000..4a2dfad9c
--- /dev/null
+++ b/scipy/testing/testing.py
@@ -0,0 +1,261 @@
+"""
+
+
+
+
+
+
+"""
+
+__all__ = []
+
+import os,sys,time,glob,string,traceback,unittest
+import types
+import imp
+
+#
+# Imports from scipy.base must be done at the end of this file.
+#
+
+DEBUG = 0
+
+
+__all__.append('ScipyTestCase')
+
+
+
+
+
+
+#------------
+
+
+
+#------------
+
+def remove_ignored_patterns(files,pattern):
+ from fnmatch import fnmatch
+ good_files = []
+ for file in files:
+ if not fnmatch(file,pattern):
+ good_files.append(file)
+ return good_files
+
+def remove_ignored_files(original,ignored_files,cur_dir):
+ """ This is actually expanded to do pattern matching.
+
+ """
+ if not ignored_files: ignored_files = []
+ ignored_modules = map(lambda x: x+'.py',ignored_files)
+ ignored_packages = ignored_files[:]
+ # always ignore setup.py and __init__.py files
+ ignored_files = ['setup.py','setup_*.py','__init__.py']
+ ignored_files += ignored_modules + ignored_packages
+ ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),
+ ignored_files)
+ #print 'ignored:', ignored_files
+ #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,
+ # original)
+ good_files = original
+ for pattern in ignored_files:
+ good_files = remove_ignored_patterns(good_files,pattern)
+
+ return good_files
+
+__all__.append('harvest_modules')
+def harvest_modules(package,ignore=None):
+ """* Retreive a list of all modules that live within a package.
+
+ Only retreive files that are immediate children of the
+ package -- do not recurse through child packages or
+ directories. The returned list contains actual modules, not
+ just their names.
+ *"""
+ d,f = os.path.split(package.__file__)
+
+ # go through the directory and import every py file there.
+ common_dir = os.path.join(d,'*.py')
+ py_files = glob.glob(common_dir)
+ #py_files.remove(os.path.join(d,'__init__.py'))
+ #py_files.remove(os.path.join(d,'setup.py'))
+
+ py_files = remove_ignored_files(py_files,ignore,d)
+ #print 'py_files:', py_files
+ try:
+ prefix = package.__name__
+ except:
+ prefix = ''
+
+ all_modules = []
+ for file in py_files:
+ d,f = os.path.split(file)
+ base,ext = os.path.splitext(f)
+ mod = prefix + '.' + base
+ #print 'module: import ' + mod
+ try:
+ exec ('import ' + mod)
+ all_modules.append(eval(mod))
+ except:
+ print 'FAILURE to import ' + mod
+ output_exception()
+
+ return all_modules
+
+__all__.append('harvest_packages')
+def harvest_packages(package,ignore = None):
+ """ Retreive a list of all sub-packages that live within a package.
+
+ Only retreive packages that are immediate children of this
+ package -- do not recurse through child packages or
+ directories. The returned list contains actual package objects, not
+ just their names.
+ """
+ join = os.path.join
+
+ d,f = os.path.split(package.__file__)
+
+ common_dir = os.path.abspath(d)
+ all_files = os.listdir(d)
+
+ all_files = remove_ignored_files(all_files,ignore,'')
+ #print 'all_files:', all_files
+ try:
+ prefix = package.__name__
+ except:
+ prefix = ''
+ all_packages = []
+ for directory in all_files:
+ path = join(common_dir,directory)
+ if os.path.isdir(path) and \
+ os.path.exists(join(path,'__init__.py')):
+ sub_package = prefix + '.' + directory
+ #print 'sub-package import ' + sub_package
+ try:
+ exec ('import ' + sub_package)
+ all_packages.append(eval(sub_package))
+ except:
+ print 'FAILURE to import ' + sub_package
+ output_exception()
+ return all_packages
+
+__all__.append('harvest_modules_and_packages')
+def harvest_modules_and_packages(package,ignore=None):
+ """ Retreive list of all packages and modules that live within a package.
+
+ See harvest_packages() and harvest_modules()
+ """
+ all = harvest_modules(package,ignore) + harvest_packages(package,ignore)
+ return all
+
+__all__.append('harvest_test_suites')
+def harvest_test_suites(package,ignore = None,level=10):
+ """
+ package -- the module to test. This is an actual module object
+ (not a string)
+ ignore -- a list of module names to omit from the tests
+ level -- a value between 1 and 10. 1 will run the minimum number
+ of tests. This is a fast "smoke test". Tests that take
+ longer to run should have higher numbers ranging up to 10.
+ """
+ suites=[]
+ test_modules = harvest_modules_and_packages(package,ignore)
+ #for i in test_modules:
+ # print i.__name__
+ for module in test_modules:
+ if hasattr(module,'test_suite'):
+ try:
+ suite = module.test_suite(level=level)
+ if suite:
+ suites.append(suite)
+ else:
+ print " !! FAILURE without error - shouldn't happen",
+ print module.__name__
+ except:
+ print ' !! FAILURE building test for ', module.__name__
+ print ' ',
+ output_exception()
+ else:
+ try:
+ print 'No test suite found for ', module.__name__
+ except AttributeError:
+ # __version__.py getting replaced by a string throws a kink
+ # in checking for modules, so we think is a module has
+ # actually been overwritten
+ print 'No test suite found for ', str(module)
+ total_suite = unittest.TestSuite(suites)
+ return total_suite
+
+__all__.append('module_test')
+def module_test(mod_name,mod_file,level=10):
+ """*
+
+ *"""
+ #print 'testing', mod_name
+ d,f = os.path.split(mod_file)
+
+ # insert the tests directory to the python path
+ test_dir = os.path.join(d,'tests')
+ sys.path.insert(0,test_dir)
+
+ # call the "test_xxx.test()" function for the appropriate
+ # module.
+
+ # This should deal with package naming issues correctly
+ short_mod_name = string.split(mod_name,'.')[-1]
+ test_module = 'test_' + short_mod_name
+ test_string = 'import %s;reload(%s);%s.test(%d)' % \
+ ((test_module,)*3 + (level,))
+
+ # This would be better cause it forces a reload of the orginal
+ # module. It doesn't behave with packages however.
+ #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \
+ # ((mod_name,) + (test_module,)*3)
+ exec(test_string)
+
+ # remove test directory from python path.
+ sys.path = sys.path[1:]
+
+__all__.append('module_test_suite')
+def module_test_suite(mod_name,mod_file,level=10):
+ #try:
+ print ' creating test suite for:', mod_name
+ d,f = os.path.split(mod_file)
+
+ # insert the tests directory to the python path
+ test_dir = os.path.join(d,'tests')
+ sys.path.insert(0,test_dir)
+
+ # call the "test_xxx.test()" function for the appropriate
+ # module.
+
+ # This should deal with package naming issues correctly
+ short_mod_name = string.split(mod_name,'.')[-1]
+ test_module = 'test_' + short_mod_name
+ test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \
+ ((test_module,)*3+(level,))
+ #print test_string
+ exec(test_string)
+
+ # remove test directory from python path.
+ sys.path = sys.path[1:]
+ return suite
+ #except:
+ # print ' !! FAILURE loading test suite from', test_module, ':'
+ # print ' ',
+ # output_exception()
+
+
+
+__all__.append('rand')
+
+
+
+
+from scipy.base import alltrue, equal, shape, ravel, around, zeros,\
+ Float64, asarray, less_equal, array2string, less, ArrayType
+
+try:
+ from scipy.base import math
+except ImportError,msg:
+ print msg
+ import math
diff --git a/scipy/testing/utils.py b/scipy/testing/utils.py
new file mode 100644
index 000000000..362f30fec
--- /dev/null
+++ b/scipy/testing/utils.py
@@ -0,0 +1,210 @@
+"""
+Utility function to facilitate testing.
+"""
+
+import os
+import sys
+import time
+import math
+
+__all__ = ['assert_equal', 'assert_almost_equal','assert_approx_equal',
+ 'assert_array_equal', 'assert_array_less',
+ 'assert_array_almost_equal', 'jiffies', 'memusage', 'rand']
+
+def rand(*args):
+ """Returns an array of random numbers with the given shape.
+
+ This only uses the standard library, so it is useful for testing purposes.
+ """
+ import random
+ from scipy.base import zeros, Float64
+ results = zeros(args,Float64)
+ f = results.flat
+ for i in range(len(f)):
+ f[i] = random.random()
+ return results
+
+if sys.platform[:5]=='linux':
+ def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),
+ _load_time=time.time()):
+ """ Return number of jiffies (1/100ths of a second) that this
+ process has been scheduled in user mode. See man 5 proc. """
+ try:
+ f=open(_proc_pid_stat,'r')
+ l = f.readline().split(' ')
+ f.close()
+ return int(l[13])
+ except:
+ return int(100*(time.time()-_load_time))
+
+ def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):
+ """ Return virtual memory size in bytes of the running python.
+ """
+ try:
+ f=open(_proc_pid_stat,'r')
+ l = f.readline().split(' ')
+ f.close()
+ return int(l[22])
+ except:
+ return
+else:
+ # os.getpid is not in all platforms available.
+ # Using time is safe but inaccurate, especially when process
+ # was suspended or sleeping.
+ def jiffies(_load_time=time.time()):
+ """ Return number of jiffies (1/100ths of a second) that this
+ process has been scheduled in user mode. [Emulation with time.time]. """
+ return int(100*(time.time()-_load_time))
+
+ def memusage():
+ """ Return memory usage of running python. [Not implemented]"""
+ return
+
+def assert_equal(actual,desired,err_msg='',verbose=1):
+ """ Raise an assertion if two items are not
+ equal. I think this should be part of unittest.py
+ """
+ from scipy.base import ArrayType
+ if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):
+ return assert_array_equal(actual, desired, err_msg)
+ msg = '\nItems are not equal:\n' + err_msg
+ try:
+ if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):
+ msg = msg \
+ + 'DESIRED: ' + repr(desired) \
+ + '\nACTUAL: ' + repr(actual)
+ except:
+ msg = msg \
+ + 'DESIRED: ' + repr(desired) \
+ + '\nACTUAL: ' + repr(actual)
+ assert desired == actual, msg
+
+
+def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):
+ """ Raise an assertion if two items are not
+ equal. I think this should be part of unittest.py
+ """
+ from scipy.base import ArrayType
+ if isinstance(actual, ArrayType) or isinstance(desired, ArrayType):
+ return assert_array_almost_equal(actual, desired, decimal, err_msg)
+ msg = '\nItems are not equal:\n' + err_msg
+ try:
+ if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):
+ msg = msg \
+ + 'DESIRED: ' + repr(desired) \
+ + '\nACTUAL: ' + repr(actual)
+ except:
+ msg = msg \
+ + 'DESIRED: ' + repr(desired) \
+ + '\nACTUAL: ' + repr(actual)
+ assert round(abs(desired - actual),decimal) == 0, msg
+
+
+def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):
+ """ Raise an assertion if two items are not
+ equal. I think this should be part of unittest.py
+ Approximately equal is defined as the number of significant digits
+ correct
+ """
+ msg = '\nItems are not equal to %d significant digits:\n' % significant
+ msg += err_msg
+ actual, desired = map(float, (actual, desired))
+ if desired==actual:
+ return
+ # Normalized the numbers to be in range (-10.0,10.0)
+ scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual))))))
+ try:
+ sc_desired = desired/scale
+ except ZeroDivisionError:
+ sc_desired = 0.0
+ try:
+ sc_actual = actual/scale
+ except ZeroDivisionError:
+ sc_actual = 0.0
+ try:
+ if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):
+ msg = msg \
+ + 'DESIRED: ' + repr(desired) \
+ + '\nACTUAL: ' + repr(actual)
+ except:
+ msg = msg \
+ + 'DESIRED: ' + repr(desired) \
+ + '\nACTUAL: ' + repr(actual)
+ assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg
+
+
+def assert_array_equal(x,y,err_msg=''):
+ from scipy.base import asarray, alltrue, equal, shape, ravel, array2string
+ x,y = asarray(x), asarray(y)
+ msg = '\nArrays are not equal'
+ try:
+ assert 0 in [len(shape(x)),len(shape(y))] \
+ or (len(shape(x))==len(shape(y)) and \
+ alltrue(equal(shape(x),shape(y)))),\
+ msg + ' (shapes %s, %s mismatch):\n\t' \
+ % (shape(x),shape(y)) + err_msg
+ reduced = ravel(equal(x,y))
+ cond = alltrue(reduced)
+ if not cond:
+ s1 = array2string(x,precision=16)
+ s2 = array2string(y,precision=16)
+ if len(s1)>120: s1 = s1[:120] + '...'
+ if len(s2)>120: s2 = s2[:120] + '...'
+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)
+ msg = msg + ' (mismatch %s%%):\n\tArray 1: %s\n\tArray 2: %s' % (match,s1,s2)
+ assert cond,\
+ msg + '\n\t' + err_msg
+ except ValueError:
+ raise ValueError, msg
+
+
+def assert_array_almost_equal(x,y,decimal=6,err_msg=''):
+ from scipy.base import asarray, alltrue, equal, shape, ravel,\
+ array2string, less_equal, around
+ x = asarray(x)
+ y = asarray(y)
+ msg = '\nArrays are not almost equal'
+ try:
+ cond = alltrue(equal(shape(x),shape(y)))
+ if not cond:
+ msg = msg + ' (shapes mismatch):\n\t'\
+ 'Shape of array 1: %s\n\tShape of array 2: %s' % (shape(x),shape(y))
+ assert cond, msg + '\n\t' + err_msg
+ reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))
+ cond = alltrue(reduced)
+ if not cond:
+ s1 = array2string(x,precision=decimal+1)
+ s2 = array2string(y,precision=decimal+1)
+ if len(s1)>120: s1 = s1[:120] + '...'
+ if len(s2)>120: s2 = s2[:120] + '...'
+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)
+ msg = msg + ' (mismatch %s%%):\n\tArray 1: %s\n\tArray 2: %s' % (match,s1,s2)
+ assert cond,\
+ msg + '\n\t' + err_msg
+ except ValueError:
+ print sys.exc_value
+ print shape(x),shape(y)
+ print x, y
+ raise ValueError, 'arrays are not almost equal'
+
+def assert_array_less(x,y,err_msg=''):
+ from scipy.base import asarray, alltrue, less, equal, shape, ravel, array2string
+ x,y = asarray(x), asarray(y)
+ msg = '\nArrays are not less-ordered'
+ try:
+ assert alltrue(equal(shape(x),shape(y))),\
+ msg + ' (shapes mismatch):\n\t' + err_msg
+ reduced = ravel(less(x,y))
+ cond = alltrue(reduced)
+ if not cond:
+ s1 = array2string(x,precision=16)
+ s2 = array2string(y,precision=16)
+ if len(s1)>120: s1 = s1[:120] + '...'
+ if len(s2)>120: s2 = s2[:120] + '...'
+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)
+ msg = msg + ' (mismatch %s%%):\n\tArray 1: %s\n\tArray 2: %s' % (match,s1,s2)
+ assert cond,\
+ msg + '\n\t' + err_msg
+ except ValueError:
+ print shape(x),shape(y)
+ raise ValueError, 'arrays are not less-ordered'
diff --git a/scipy/weave/__init__.py b/scipy/weave/__init__.py
index eea8d383c..4948cfb57 100644
--- a/scipy/weave/__init__.py
+++ b/scipy/weave/__init__.py
@@ -2,7 +2,7 @@
# weave - C/C++ integration
#
-from info_weave import __doc__
+from info import __doc__
from weave_version import weave_version as __version__
try:
@@ -18,5 +18,5 @@ try:
except:
pass
-from scipy.test.testing import ScipyTest
-test = ScipyTest('weave').test
+from scipy.testing import ScipyTest
+test = ScipyTest().test
diff --git a/scipy/weave/blitz_tools.py b/scipy/weave/blitz_tools.py
index a006d5a65..024444389 100644
--- a/scipy/weave/blitz_tools.py
+++ b/scipy/weave/blitz_tools.py
@@ -1,6 +1,5 @@
import parser
import string
-import copy
import os,sys
import ast_tools
import token,symbol
@@ -11,6 +10,7 @@ import converters
from ast_tools import *
from scipy.base import *
+import copy
from types import *
import inline_tools
diff --git a/scipy/weave/info_weave.py b/scipy/weave/info.py
index 72af7312b..346164db2 100644
--- a/scipy/weave/info_weave.py
+++ b/scipy/weave/info.py
@@ -9,3 +9,4 @@ C/C++ integration
"""
postpone_import = 1
standalone = 1
+ignore = 1
diff --git a/scipy/weave/setup.py b/scipy/weave/setup.py
index 8117343f1..bda6e0a06 100755
--- a/scipy/weave/setup.py
+++ b/scipy/weave/setup.py
@@ -19,4 +19,4 @@ if __name__ == '__main__':
author_email = "eric@enthought.com",
licence = "SciPy License (BSD Style)",
url = 'http://www.scipy.org',
- **configuration(parent_path='').todict())
+ **configuration(top_path='').todict())
diff --git a/scipy/weave/tests/test_ast_tools.py b/scipy/weave/tests/test_ast_tools.py
index bddba5ed3..efb2dc8b2 100644
--- a/scipy/weave/tests/test_ast_tools.py
+++ b/scipy/weave/tests/test_ast_tools.py
@@ -1,10 +1,5 @@
-import unittest
-from scipy_base.numerix import *
-# The following try/except so that non-SciPy users can still use blitz
-from scipy_base.numeric import RandomArray
-import time
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import ast_tools
restore_path()
@@ -13,7 +8,7 @@ set_local_path()
from weave_test_utils import *
restore_path()
-class test_harvest_variables(unittest.TestCase):
+class test_harvest_variables(ScipyTestCase):
""" Not much testing going on here, but
at least it is a flame test.
"""
@@ -33,4 +28,4 @@ class test_harvest_variables(unittest.TestCase):
self.generic_test(expr,desired)
if __name__ == "__main__":
- ScipyTest('weave.ast_tools').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_blitz_tools.py b/scipy/weave/tests/test_blitz_tools.py
index 198df2e09..c7fb717b2 100644
--- a/scipy/weave/tests/test_blitz_tools.py
+++ b/scipy/weave/tests/test_blitz_tools.py
@@ -1,21 +1,20 @@
-import unittest
-from scipy_base.numerix import *
-# The following try/except so that non-SciPy users can still use blitz
-from scipy_base.numerix import RandomArray
import os
import time
-from scipy_test.testing import *
+from scipy.base import *
+
+from scipy.testing import *
set_package_path()
from weave import blitz_tools
+from weave.ast_tools import harvest_variables
restore_path()
+
set_local_path()
from weave_test_utils import *
restore_path()
-from weave.ast_tools import harvest_variables
-class test_ast_to_blitz_expr(unittest.TestCase):
+class test_ast_to_blitz_expr(ScipyTestCase):
def generic_test(self,expr,desired):
import parser
@@ -58,7 +57,7 @@ class test_ast_to_blitz_expr(unittest.TestCase):
'-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'
self.generic_test(expr,desired)
-class test_blitz(unittest.TestCase):
+class test_blitz(ScipyTestCase):
"""* These are long running tests...
I'd like to benchmark these things somehow.
@@ -176,4 +175,4 @@ class test_blitz(unittest.TestCase):
self.generic_2d(expr,Complex64)
if __name__ == "__main__":
- ScipyTest('weave.blitz_tools').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_build_tools.py b/scipy/weave/tests/test_build_tools.py
index 9c43c5a4c..d6a9a1887 100644
--- a/scipy/weave/tests/test_build_tools.py
+++ b/scipy/weave/tests/test_build_tools.py
@@ -2,10 +2,9 @@
# tests for MingW32Compiler
# don't know how to test gcc_exists() and msvc_exists()...
-import unittest
import os, sys, tempfile
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import build_tools
restore_path()
@@ -13,7 +12,7 @@ restore_path()
def is_writable(val):
return os.access(val,os.W_OK)
-class test_configure_build_dir(unittest.TestCase):
+class test_configure_build_dir(ScipyTestCase):
def check_default(self):
" default behavior is to return current directory "
d = build_tools.configure_build_dir()
@@ -47,7 +46,7 @@ class test_configure_temp_dir(test_configure_build_dir):
assert(d == tempfile.gettempdir())
assert(is_writable(d))
-class test_configure_sys_argv(unittest.TestCase):
+class test_configure_sys_argv(ScipyTestCase):
def check_simple(self):
build_dir = 'build_dir'
temp_dir = 'temp_dir'
@@ -64,4 +63,4 @@ class test_configure_sys_argv(unittest.TestCase):
assert(pre_argv == sys.argv[:])
if __name__ == "__main__":
- ScipyTest('weave.build_tools').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_c_spec.py b/scipy/weave/tests/test_c_spec.py
index ce63595e2..38d77f3e7 100644
--- a/scipy/weave/tests/test_c_spec.py
+++ b/scipy/weave/tests/test_c_spec.py
@@ -1,4 +1,3 @@
-import unittest
import time
import os,sys
@@ -9,7 +8,7 @@ import os,sys
global test_dir
test_dir = ''
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import inline_tools,ext_tools,c_spec
from weave.build_tools import msvc_exists, gcc_exists
@@ -49,7 +48,7 @@ def print_assert_equal(test_string,actual,desired):
# Scalar conversion test classes
# int, float, complex
#----------------------------------------------------------------------------
-class test_int_converter(unittest.TestCase):
+class test_int_converter(ScipyTestCase):
compiler = ''
def check_type_match_string(self,level=5):
s = c_spec.int_converter()
@@ -104,7 +103,7 @@ class test_int_converter(unittest.TestCase):
assert( c == 3)
-class test_float_converter(unittest.TestCase):
+class test_float_converter(ScipyTestCase):
compiler = ''
def check_type_match_string(self,level=5):
s = c_spec.float_converter()
@@ -159,7 +158,7 @@ class test_float_converter(unittest.TestCase):
c = test(b)
assert( c == 3.)
-class test_complex_converter(unittest.TestCase):
+class test_complex_converter(ScipyTestCase):
compiler = ''
def check_type_match_string(self,level=5):
s = c_spec.complex_converter()
@@ -217,7 +216,7 @@ class test_complex_converter(unittest.TestCase):
# File conversion tests
#----------------------------------------------------------------------------
-class test_file_converter(unittest.TestCase):
+class test_file_converter(ScipyTestCase):
compiler = ''
def check_py_to_file(self,level=5):
import tempfile
@@ -251,14 +250,14 @@ class test_file_converter(unittest.TestCase):
# Instance conversion tests
#----------------------------------------------------------------------------
-class test_instance_converter(unittest.TestCase):
+class test_instance_converter(ScipyTestCase):
pass
#----------------------------------------------------------------------------
# Callable object conversion tests
#----------------------------------------------------------------------------
-class test_callable_converter(unittest.TestCase):
+class test_callable_converter(ScipyTestCase):
compiler=''
def check_call_function(self,level=5):
import string
@@ -278,7 +277,7 @@ class test_callable_converter(unittest.TestCase):
desired = func(search_str,sub_str)
assert(desired == actual)
-class test_sequence_converter(unittest.TestCase):
+class test_sequence_converter(ScipyTestCase):
compiler = ''
def check_convert_to_dict(self,level=5):
d = {}
@@ -293,7 +292,7 @@ class test_sequence_converter(unittest.TestCase):
t = ()
inline_tools.inline("",['t'],compiler=self.compiler,force=1)
-class test_string_converter(unittest.TestCase):
+class test_string_converter(ScipyTestCase):
compiler = ''
def check_type_match_string(self,level=5):
s = c_spec.string_converter()
@@ -348,7 +347,7 @@ class test_string_converter(unittest.TestCase):
c = test(b)
assert( c == 'hello')
-class test_list_converter(unittest.TestCase):
+class test_list_converter(ScipyTestCase):
compiler = ''
def check_type_match_bad(self,level=5):
s = c_spec.list_converter()
@@ -459,7 +458,7 @@ class test_list_converter(unittest.TestCase):
print 'python:', t2 - t1
assert( sum1 == sum2 and sum1 == sum3)
-class test_tuple_converter(unittest.TestCase):
+class test_tuple_converter(ScipyTestCase):
compiler = ''
def check_type_match_bad(self,level=5):
s = c_spec.tuple_converter()
@@ -512,7 +511,7 @@ class test_tuple_converter(unittest.TestCase):
assert( c == ('hello',None))
-class test_dict_converter(unittest.TestCase):
+class test_dict_converter(ScipyTestCase):
def check_type_match_bad(self,level=5):
s = c_spec.dict_converter()
objs = [[],(),'',1,1.,1+1j]
diff --git a/scipy/weave/tests/test_catalog.py b/scipy/weave/tests/test_catalog.py
index 3de951260..ac2f42be3 100644
--- a/scipy/weave/tests/test_catalog.py
+++ b/scipy/weave/tests/test_catalog.py
@@ -1,8 +1,7 @@
-import unittest
import sys, os
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import catalog
restore_path()
@@ -11,7 +10,8 @@ set_local_path()
from weave_test_utils import *
restore_path()
-class test_default_dir(unittest.TestCase):
+
+class test_default_dir(ScipyTestCase):
def check_is_writable(self):
path = catalog.default_dir()
name = os.path.join(path,'dummy_catalog')
@@ -22,10 +22,10 @@ class test_default_dir(unittest.TestCase):
test_file.close()
os.remove(name)
-class test_os_dependent_catalog_name(unittest.TestCase):
+class test_os_dependent_catalog_name(ScipyTestCase):
pass
-class test_catalog_path(unittest.TestCase):
+class test_catalog_path(ScipyTestCase):
def check_default(self):
in_path = catalog.default_dir()
path = catalog.catalog_path(in_path)
@@ -64,7 +64,7 @@ class test_catalog_path(unittest.TestCase):
path = catalog.catalog_path(in_path)
assert (path is None)
-class test_get_catalog(unittest.TestCase):
+class test_get_catalog(ScipyTestCase):
""" This only tests whether new catalogs are created correctly.
And whether non-existent return None correctly with read mode.
Putting catalogs in the right place is all tested with
@@ -98,7 +98,7 @@ class test_get_catalog(unittest.TestCase):
self.remove_dir(pardir)
assert(cat is not None)
-class test_catalog(unittest.TestCase):
+class test_catalog(ScipyTestCase):
def clear_environ(self):
if os.environ.has_key('PYTHONCOMPILED'):
diff --git a/scipy/weave/tests/test_ext_tools.py b/scipy/weave/tests/test_ext_tools.py
index 48aab2612..c8a15e341 100644
--- a/scipy/weave/tests/test_ext_tools.py
+++ b/scipy/weave/tests/test_ext_tools.py
@@ -1,7 +1,7 @@
-import unittest
+
import time
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import ext_tools, c_spec
try:
@@ -17,7 +17,7 @@ restore_path()
build_dir = empty_temp_dir()
print 'building extensions here:', build_dir
-class test_ext_module(unittest.TestCase):
+class test_ext_module(ScipyTestCase):
#should really do some testing of where modules end up
def check_simple(self,level=5):
""" Simplest possible module """
@@ -94,7 +94,7 @@ class test_ext_module(unittest.TestCase):
c,d = ext_return_tuple.test(a)
assert(c==a and d == a+1)
-class test_ext_function(unittest.TestCase):
+class test_ext_function(ScipyTestCase):
#should really do some testing of where modules end up
def check_simple(self,level=5):
""" Simplest possible function """
@@ -107,7 +107,7 @@ class test_ext_function(unittest.TestCase):
import simple_ext_function
simple_ext_function.test()
-class test_assign_variable_types(unittest.TestCase):
+class test_assign_variable_types(ScipyTestCase):
def check_assign_variable_types(self):
try:
from scipy_base.numerix import arange, Float32, Float64
@@ -135,4 +135,4 @@ class test_assign_variable_types(unittest.TestCase):
print_assert_equal(expr,actual,desired)
if __name__ == "__main__":
- ScipyTest('weave.ext_tools').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_inline_tools.py b/scipy/weave/tests/test_inline_tools.py
index 2d197cd19..4ce7bfa1c 100644
--- a/scipy/weave/tests/test_inline_tools.py
+++ b/scipy/weave/tests/test_inline_tools.py
@@ -1,7 +1,7 @@
-import unittest
-from scipy_base.numerix import *
-from scipy_test.testing import *
+from scipy.base import *
+
+from scipy.testing import *
set_package_path()
from weave import inline_tools
restore_path()
@@ -9,7 +9,7 @@ set_local_path()
from test_scxx import *
restore_path()
-class test_inline(unittest.TestCase):
+class test_inline(ScipyTestCase):
""" These are long running tests...
I'd like to benchmark these things somehow.
@@ -43,4 +43,4 @@ class test_inline(unittest.TestCase):
pass
if __name__ == "__main__":
- ScipyTest('weave.inline_tools').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_scxx.py b/scipy/weave/tests/test_scxx.py
index 4a2a568fc..b7a8945eb 100644
--- a/scipy/weave/tests/test_scxx.py
+++ b/scipy/weave/tests/test_scxx.py
@@ -4,7 +4,7 @@ import unittest
import time
import os,sys
-from scipy_test.testing import *
+from scipy.testing import *
set_local_path()
from test_scxx_object import *
from test_scxx_sequence import *
@@ -12,5 +12,5 @@ from test_scxx_dict import *
restore_path()
if __name__ == "__main__":
- ScipyTest('weave.inline_tools').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_scxx_dict.py b/scipy/weave/tests/test_scxx_dict.py
index 1edcb417c..f25561576 100644
--- a/scipy/weave/tests/test_scxx_dict.py
+++ b/scipy/weave/tests/test_scxx_dict.py
@@ -1,16 +1,15 @@
""" Test refcounting and behavior of SCXX.
"""
-import unittest
import time
import os,sys
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import inline_tools
restore_path()
-class test_dict_construct(unittest.TestCase):
+class test_dict_construct(ScipyTestCase):
#------------------------------------------------------------------------
# Check that construction from basic types is allowed and have correct
# reference counts
@@ -26,7 +25,7 @@ class test_dict_construct(unittest.TestCase):
assert res == {}
-class test_dict_has_key(unittest.TestCase):
+class test_dict_has_key(ScipyTestCase):
def check_obj(self,level=5):
class foo:
pass
@@ -90,7 +89,7 @@ class test_dict_has_key(unittest.TestCase):
res = inline_tools.inline(code,['a'])
assert not res
-class test_dict_get_item_op(unittest.TestCase):
+class test_dict_get_item_op(ScipyTestCase):
def generic_get(self,code,args=['a']):
a = {}
@@ -133,7 +132,7 @@ class test_dict_get_item_op(unittest.TestCase):
except KeyError:
pass
-class test_dict_set_operator(unittest.TestCase):
+class test_dict_set_operator(ScipyTestCase):
def generic_new(self,key,val):
# test that value is set correctly and that reference counts
# on dict, key, and val are being handled correctly.
@@ -200,7 +199,7 @@ class test_dict_set_operator(unittest.TestCase):
key,val = foo(),12345
self.generic_overwrite(key,val)
-class test_dict_del(unittest.TestCase):
+class test_dict_del(ScipyTestCase):
def generic(self,key):
# test that value is set correctly and that reference counts
# on dict, key, are being handled correctly. after deletion,
@@ -234,7 +233,7 @@ class test_dict_del(unittest.TestCase):
key = foo()
self.generic(key)
-class test_dict_others(unittest.TestCase):
+class test_dict_others(ScipyTestCase):
def check_clear(self,level=5):
a = {}
a["hello"] = 1
@@ -263,4 +262,4 @@ class test_dict_others(unittest.TestCase):
assert a == b
if __name__ == "__main__":
- ScipyTest('weave.scxx').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_scxx_object.py b/scipy/weave/tests/test_scxx_object.py
index 8e93698cf..ea6a22b25 100644
--- a/scipy/weave/tests/test_scxx_object.py
+++ b/scipy/weave/tests/test_scxx_object.py
@@ -1,15 +1,14 @@
""" Test refcounting and behavior of SCXX.
"""
-import unittest
import time
import os,sys
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import inline_tools
restore_path()
-class test_object_construct(unittest.TestCase):
+class test_object_construct(ScipyTestCase):
#------------------------------------------------------------------------
# Check that construction from basic types is allowed and have correct
# reference counts
@@ -67,7 +66,7 @@ class test_object_construct(unittest.TestCase):
assert sys.getrefcount(res) == 2
assert res == "hello"
-class test_object_print(unittest.TestCase):
+class test_object_print(ScipyTestCase):
#------------------------------------------------------------------------
# Check the object print protocol.
#------------------------------------------------------------------------
@@ -102,7 +101,7 @@ class test_object_print(unittest.TestCase):
pass
-class test_object_cast(unittest.TestCase):
+class test_object_cast(ScipyTestCase):
def check_int_cast(self,level=5):
code = """
py::object val = 1;
@@ -148,7 +147,7 @@ class str_obj:
def __str__(self):
return "b"
-class test_object_hasattr(unittest.TestCase):
+class test_object_hasattr(ScipyTestCase):
def check_string(self,level=5):
a = foo()
a.b = 12345
@@ -204,7 +203,7 @@ class test_object_hasattr(unittest.TestCase):
res = inline_tools.inline(code,['a'])
assert res
-class test_object_attr(unittest.TestCase):
+class test_object_attr(ScipyTestCase):
def generic_attr(self,code,args=['a']):
a = foo()
@@ -262,7 +261,7 @@ class test_object_attr(unittest.TestCase):
assert res == "bar results"
assert first == second
-class test_object_set_attr(unittest.TestCase):
+class test_object_set_attr(ScipyTestCase):
def generic_existing(self, code, desired):
args = ['a']
@@ -326,7 +325,7 @@ class test_object_set_attr(unittest.TestCase):
"""
self.generic_existing(code,"hello")
-class test_object_del(unittest.TestCase):
+class test_object_del(ScipyTestCase):
def generic(self, code):
args = ['a']
a = foo()
@@ -349,7 +348,7 @@ class test_object_del(unittest.TestCase):
"""
self.generic(code)
-class test_object_cmp(unittest.TestCase):
+class test_object_cmp(ScipyTestCase):
def check_equal(self,level=5):
a,b = 1,1
res = inline_tools.inline('return_val = (a == b);',['a','b'])
@@ -412,7 +411,7 @@ class test_object_cmp(unittest.TestCase):
res = inline_tools.inline(code,['a'])
assert res == (a == "hello")
-class test_object_repr(unittest.TestCase):
+class test_object_repr(ScipyTestCase):
def check_repr(self,level=5):
class foo:
def __str__(self):
@@ -428,7 +427,7 @@ class test_object_repr(unittest.TestCase):
assert first == second
assert res == "repr return"
-class test_object_str(unittest.TestCase):
+class test_object_str(ScipyTestCase):
def check_str(self,level=5):
class foo:
def __str__(self):
@@ -445,7 +444,7 @@ class test_object_str(unittest.TestCase):
print res
assert res == "str return"
-class test_object_unicode(unittest.TestCase):
+class test_object_unicode(ScipyTestCase):
# This ain't going to win awards for test of the year...
def check_unicode(self,level=5):
class foo:
@@ -462,7 +461,7 @@ class test_object_unicode(unittest.TestCase):
assert first == second
assert res == "unicode"
-class test_object_is_callable(unittest.TestCase):
+class test_object_is_callable(ScipyTestCase):
def check_true(self,level=5):
class foo:
def __call__(self):
@@ -477,7 +476,7 @@ class test_object_is_callable(unittest.TestCase):
res = inline_tools.inline('return_val = a.is_callable();',['a'])
assert not res
-class test_object_call(unittest.TestCase):
+class test_object_call(ScipyTestCase):
def check_noargs(self,level=5):
def foo():
return (1,2,3)
@@ -533,7 +532,7 @@ class test_object_call(unittest.TestCase):
# first should == second, but the weird refcount error
assert second == third
-class test_object_mcall(unittest.TestCase):
+class test_object_mcall(ScipyTestCase):
def check_noargs(self,level=5):
a = foo()
res = inline_tools.inline('return_val = a.mcall("bar");',['a'])
@@ -627,7 +626,7 @@ class test_object_mcall(unittest.TestCase):
# first should == second, but the weird refcount error
assert second == third
-class test_object_hash(unittest.TestCase):
+class test_object_hash(ScipyTestCase):
def check_hash(self,level=5):
class foo:
def __hash__(self):
@@ -637,7 +636,7 @@ class test_object_hash(unittest.TestCase):
print 'hash:', res
assert res == 123
-class test_object_is_true(unittest.TestCase):
+class test_object_is_true(ScipyTestCase):
def check_true(self,level=5):
class foo:
pass
@@ -649,7 +648,7 @@ class test_object_is_true(unittest.TestCase):
res = inline_tools.inline('return_val = a.is_true();',['a'])
assert res == 0
-class test_object_is_true(unittest.TestCase):
+class test_object_is_true(ScipyTestCase):
def check_false(self,level=5):
class foo:
pass
@@ -661,7 +660,7 @@ class test_object_is_true(unittest.TestCase):
res = inline_tools.inline('return_val = a.not();',['a'])
assert res == 1
-class test_object_type(unittest.TestCase):
+class test_object_type(ScipyTestCase):
def check_type(self,level=5):
class foo:
pass
@@ -669,7 +668,7 @@ class test_object_type(unittest.TestCase):
res = inline_tools.inline('return_val = a.type();',['a'])
assert res == type(a)
-class test_object_size(unittest.TestCase):
+class test_object_size(ScipyTestCase):
def check_size(self,level=5):
class foo:
def __len__(self):
@@ -693,7 +692,7 @@ class test_object_size(unittest.TestCase):
assert res == len(a)
from UserList import UserList
-class test_object_set_item_op_index(unittest.TestCase):
+class test_object_set_item_op_index(ScipyTestCase):
def check_list_refcount(self,level=5):
a = UserList([1,2,3])
# temporary refcount fix until I understand why it incs by one.
@@ -728,7 +727,7 @@ class test_object_set_item_op_index(unittest.TestCase):
assert a[1] == 1+1j
from UserDict import UserDict
-class test_object_set_item_op_key(unittest.TestCase):
+class test_object_set_item_op_key(ScipyTestCase):
def check_key_refcount(self,level=5):
a = UserDict()
code = """
@@ -819,4 +818,4 @@ class test_object_set_item_op_key(unittest.TestCase):
assert a['first'] == a['second']
if __name__ == "__main__":
- ScipyTest('weave.scxx').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_scxx_sequence.py b/scipy/weave/tests/test_scxx_sequence.py
index 1aef62598..b5f8b59fc 100644
--- a/scipy/weave/tests/test_scxx_sequence.py
+++ b/scipy/weave/tests/test_scxx_sequence.py
@@ -1,10 +1,10 @@
""" Test refcounting and behavior of SCXX.
"""
-import unittest
+
import time
import os,sys
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import inline_tools
restore_path()
@@ -20,7 +20,7 @@ restore_path()
from UserList import UserList
-class _test_sequence_base(unittest.TestCase):
+class _test_sequence_base(ScipyTestCase):
seq_type = None
def check_conversion(self,level=5):
@@ -434,5 +434,5 @@ class test_list(_test_sequence_base):
assert b == desired
if __name__ == "__main__":
- ScipyTest('weave.scxx').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_size_check.py b/scipy/weave/tests/test_size_check.py
index d0ad020b3..6cb6b7621 100644
--- a/scipy/weave/tests/test_size_check.py
+++ b/scipy/weave/tests/test_size_check.py
@@ -1,42 +1,22 @@
-import unittest, os
-from scipy_base.numerix import *
-from scipy_test.testing import *
+import os
+from scipy.base import *
+from scipy.testing import *
set_package_path()
from weave import size_check
from weave.ast_tools import *
restore_path()
-import scipy_base.numerix as nx
+import scipy.base as nx
empty = array(())
-def array_assert_equal(test_string,actual,desired):
- """this should probably be in scipy_test.testing
- """
- import pprint
- try:
- assert(all(equal(actual,desired)))
- except AssertionError:
- try:
- # kluge for bug in scipy_base.numerix
- assert (len(actual[0]) == len(actual[1]) ==
- len(desired[0]) == len(desired[1]) == 0)
- except:
- import cStringIO
- msg = cStringIO.StringIO()
- msg.write(test_string)
- msg.write(' failed\nACTUAL: \n')
- pprint.pprint(actual,msg)
- msg.write('DESIRED: \n')
- pprint.pprint(desired,msg)
- raise AssertionError, msg.getvalue()
-class test_make_same_length(unittest.TestCase):
+class test_make_same_length(ScipyTestCase):
def generic_test(self,x,y,desired):
actual = size_check.make_same_length(x,y)
desired = desired
- array_assert_equal('',actual,desired)
+ assert_array_equal('',actual,desired)
def check_scalar(self):
x,y = (),()
@@ -59,11 +39,11 @@ class test_make_same_length(unittest.TestCase):
desired = array((1,2,3)),array((1,1,2))
self.generic_test(x,y,desired)
-class test_binary_op_size(unittest.TestCase):
+class test_binary_op_size(ScipyTestCase):
def generic_test(self,x,y,desired):
actual = size_check.binary_op_size(x,y)
desired = desired
- array_assert_equal('',actual,desired)
+ assert_array_equal('',actual,desired)
def generic_error_test(self,x,y):
try:
actual = size_check.binary_op_size(x,y)
@@ -122,7 +102,7 @@ class test_binary_op_size(unittest.TestCase):
self.generic_error_test(x,y)
class test_dummy_array(test_binary_op_size):
- def array_assert_equal(self,test_string,actual,desired):
+ def assert_array_equal(self,test_string,actual,desired):
"""this should probably be in scipy_test.testing
"""
import pprint
@@ -148,7 +128,7 @@ class test_dummy_array(test_binary_op_size):
for op in ops:
actual = eval('xx' + op + 'yy')
desired = desired
- self.array_assert_equal('',actual,desired)
+ self.assert_array_equal('',actual,desired)
def generic_error_test(self,x,y):
try:
self.generic_test('',x,y)
@@ -158,8 +138,8 @@ class test_dummy_array(test_binary_op_size):
def desired_type(self,val):
return size_check.dummy_array(array(val),1)
-class test_dummy_array_indexing(unittest.TestCase):
- def array_assert_equal(self,test_string,actual,desired):
+class test_dummy_array_indexing(ScipyTestCase):
+ def assert_array_equal(self,test_string,actual,desired):
"""this should probably be in scipy_test.testing
"""
import pprint
@@ -178,7 +158,7 @@ class test_dummy_array_indexing(unittest.TestCase):
a = size_check.dummy_array(ary)
actual = eval(expr).shape
#print desired, actual
- self.array_assert_equal(expr,actual,desired)
+ self.assert_array_equal(expr,actual,desired)
def generic_wrap(self,a,expr):
#print expr ,eval(expr)
desired = array(eval(expr).shape)
@@ -324,27 +304,27 @@ class test_dummy_array_indexing(unittest.TestCase):
except IndexError:
pass
-class test_reduction(unittest.TestCase):
+class test_reduction(ScipyTestCase):
def check_1d_0(self):
a = ones((5,))
actual = size_check.reduction(a,0)
desired = size_check.dummy_array((),1)
- array_assert_equal('',actual.shape,desired.shape)
+ assert_array_equal('',actual.shape,desired.shape)
def check_2d_0(self):
a = ones((5,10))
actual = size_check.reduction(a,0)
desired = size_check.dummy_array((10,),1)
- array_assert_equal('',actual.shape,desired.shape)
+ assert_array_equal('',actual.shape,desired.shape)
def check_2d_1(self):
a = ones((5,10))
actual = size_check.reduction(a,1)
desired = size_check.dummy_array((5,),1)
- array_assert_equal('',actual.shape,desired.shape)
+ assert_array_equal('',actual.shape,desired.shape)
def check_3d_0(self):
a = ones((5,6,7))
actual = size_check.reduction(a,1)
desired = size_check.dummy_array((5,7),1)
- array_assert_equal('',actual.shape,desired.shape)
+ assert_array_equal('',actual.shape,desired.shape)
def check_error0(self):
a = ones((5,))
try:
@@ -358,8 +338,8 @@ class test_reduction(unittest.TestCase):
except ValueError:
pass
-class test_expressions(unittest.TestCase):
- def array_assert_equal(self,test_string,actual,desired):
+class test_expressions(ScipyTestCase):
+ def assert_array_equal(self,test_string,actual,desired):
"""this should probably be in scipy_test.testing
"""
import pprint
@@ -389,7 +369,7 @@ class test_expressions(unittest.TestCase):
if actual is 'failed' and desired is 'failed':
return
try:
- self.array_assert_equal(expr,actual,desired)
+ self.assert_array_equal(expr,actual,desired)
except:
print 'EXPR:',expr
print 'ACTUAL:',actual
diff --git a/scipy/weave/tests/test_slice_handler.py b/scipy/weave/tests/test_slice_handler.py
index ce6a7a75d..75483ffcf 100644
--- a/scipy/weave/tests/test_slice_handler.py
+++ b/scipy/weave/tests/test_slice_handler.py
@@ -1,7 +1,5 @@
-import unittest
-# Was getting a weird "no module named slice_handler error with this.
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import slice_handler
from weave.slice_handler import indexed_array_pattern
@@ -24,7 +22,7 @@ def print_assert_equal(test_string,actual,desired):
pprint.pprint(desired,msg)
raise AssertionError, msg.getvalue()
-class test_build_slice_atom(unittest.TestCase):
+class test_build_slice_atom(ScipyTestCase):
def generic_test(self,slice_vars,desired):
pos = slice_vars['pos']
ast_list = slice_handler.build_slice_atom(slice_vars,pos)
@@ -36,7 +34,7 @@ class test_build_slice_atom(unittest.TestCase):
desired = 'slice(1,2-1)'
self.generic_test(slice_vars,desired)
-class test_slice(unittest.TestCase):
+class test_slice(ScipyTestCase):
def generic_test(self,suite_string,desired):
import parser
@@ -137,7 +135,7 @@ def replace_whitespace(in_str):
out = string.replace(out,"\n","")
return out
-class test_transform_slices(unittest.TestCase):
+class test_transform_slices(ScipyTestCase):
def generic_test(self,suite_string,desired):
import parser
ast_list = parser.suite(suite_string).tolist()
diff --git a/scipy/weave/tests/test_standard_array_spec.py b/scipy/weave/tests/test_standard_array_spec.py
index 5ce5667b2..3688857fe 100644
--- a/scipy/weave/tests/test_standard_array_spec.py
+++ b/scipy/weave/tests/test_standard_array_spec.py
@@ -1,9 +1,6 @@
-import unittest
-from scipy_base.numerix import *
-from scipy_base.numerix import RandomArray
-import time
-from scipy_test.testing import *
+from scipy.base import *
+from scipy.testing import *
set_package_path()
from weave import standard_array_spec
restore_path()
@@ -31,7 +28,7 @@ def print_assert_equal(test_string,actual,desired):
pprint.pprint(desired,msg)
raise AssertionError, msg.getvalue()
-class test_array_converter(unittest.TestCase):
+class test_array_converter(ScipyTestCase):
def check_type_match_string(self):
s = standard_array_spec.array_converter()
assert( not s.type_match('string') )
@@ -43,5 +40,5 @@ class test_array_converter(unittest.TestCase):
assert(s.type_match(arange(4)))
if __name__ == "__main__":
- ScipyTest('weave.standard_array_spec').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/test_wx_spec.py b/scipy/weave/tests/test_wx_spec.py
index 829123579..47f27da7b 100644
--- a/scipy/weave/tests/test_wx_spec.py
+++ b/scipy/weave/tests/test_wx_spec.py
@@ -7,9 +7,8 @@ check_var_local -- tests wheter a variable is passed in , modified,
check_return -- test whether a variable is passed in, modified, and
then returned as a function return value correctly
"""
-import unittest
-from scipy_test.testing import *
+from scipy.testing import *
set_package_path()
from weave import ext_tools, wx_spec
restore_path()
@@ -17,7 +16,7 @@ restore_path()
import wxPython
import wxPython.wx
-class test_wx_converter(unittest.TestCase):
+class test_wx_converter(ScipyTestCase):
def check_type_match_string(self,level=5):
s = wx_spec.wx_converter()
assert(not s.type_match('string') )
@@ -92,4 +91,4 @@ class test_wx_converter(unittest.TestCase):
assert( c == 'hello')
if __name__ == "__main__":
- ScipyTest('weave.wx_spec').run()
+ ScipyTest().run()
diff --git a/scipy/weave/tests/weave_test_utils.py b/scipy/weave/tests/weave_test_utils.py
index 9189a4619..2ee67bb2b 100644
--- a/scipy/weave/tests/weave_test_utils.py
+++ b/scipy/weave/tests/weave_test_utils.py
@@ -26,10 +26,10 @@ def print_assert_equal(test_string,actual,desired):
###################################################
# mainly used by catalog tests
###################################################
-from scipy_distutils.misc_util import add_grandparent_to_path,restore_path
-add_grandparent_to_path(__name__)
-import catalog
+from scipy.testing import set_package_path, restore_path
+set_package_path()
+from weave import catalog
restore_path()
import glob
@@ -168,5 +168,3 @@ def move_file (src, dst,
(src, dst, src, msg)
return dst
-
- \ No newline at end of file
diff --git a/scipy/weave/weave_version.py b/scipy/weave/weave_version.py
index 0f549815c..78ef899f2 100644
--- a/scipy/weave/weave_version.py
+++ b/scipy/weave/weave_version.py
@@ -1,27 +1,12 @@
major = 0
-minor = 3
-micro = 3
+minor = 4
+micro = 0
#release_level = 'alpha'
release_level = ''
-try:
- from __cvs_version__ import cvs_version
- cvs_minor = cvs_version[-3]
- cvs_serial = cvs_version[-1]
-except ImportError,msg:
- cvs_minor = 0
- cvs_serial = 0
-if cvs_minor or cvs_serial:
- if release_level:
- weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\
- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())
- else:
- weave_version = '%(major)d.%(minor)d.%(micro)d'\
- '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())
+if release_level:
+ weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\
+ % (locals ())
else:
- if release_level:
- weave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\
- % (locals ())
- else:
- weave_version = '%(major)d.%(minor)d.%(micro)d'\
- % (locals ())
+ weave_version = '%(major)d.%(minor)d.%(micro)d'\
+ % (locals ())