[Scipy-svn] r3803 - in branches/testing_cleanup/scipy: cluster/tests weave/tests
scipy-svn@scip...
scipy-svn@scip...
Tue Jan 8 16:52:23 CST 2008
Author: matthew.brett@gmail.com
Date: 2008-01-08 16:52:05 -0600 (Tue, 08 Jan 2008)
New Revision: 3803
Modified:
branches/testing_cleanup/scipy/cluster/tests/test_vq.py
branches/testing_cleanup/scipy/weave/tests/test_c_spec.py
branches/testing_cleanup/scipy/weave/tests/test_ext_tools.py
branches/testing_cleanup/scipy/weave/tests/test_inline_tools.py
branches/testing_cleanup/scipy/weave/tests/test_numpy_scalar_spec.py
branches/testing_cleanup/scipy/weave/tests/test_scxx_dict.py
branches/testing_cleanup/scipy/weave/tests/test_scxx_object.py
branches/testing_cleanup/scipy/weave/tests/test_scxx_sequence.py
branches/testing_cleanup/scipy/weave/tests/test_size_check.py
branches/testing_cleanup/scipy/weave/tests/test_slice_handler.py
branches/testing_cleanup/scipy/weave/tests/test_wx_spec.py
Log:
Moving over weave tests
Modified: branches/testing_cleanup/scipy/cluster/tests/test_vq.py
===================================================================
--- branches/testing_cleanup/scipy/cluster/tests/test_vq.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/cluster/tests/test_vq.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -131,7 +131,7 @@
code1 = kmeans2(data1, code, iter = 1)[0]
code2 = kmeans2(data1, code, iter = 2)[0]
- def test_kmeans2_init(self, level = 1):
+ def test_kmeans2_init(self):
"""Testing that kmeans2 init methods work."""
data = N.fromfile(open(DATAFILE1), sep = ", ")
data = data.reshape((200, 2))
Modified: branches/testing_cleanup/scipy/weave/tests/test_c_spec.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_c_spec.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_c_spec.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -66,19 +66,24 @@
class IntConverter(TestCase):
compiler = ''
- def test_type_match_string(self,level=5):
+ @dec.slow
+ def test_type_match_string(self):
s = c_spec.int_converter()
assert( not s.type_match('string') )
- def test_type_match_int(self,level=5):
+ @dec.slow
+ def test_type_match_int(self):
s = c_spec.int_converter()
assert(s.type_match(5))
- def test_type_match_float(self,level=5):
+ @dec.slow
+ def test_type_match_float(self):
s = c_spec.int_converter()
assert(not s.type_match(5.))
- def test_type_match_complex(self,level=5):
+ @dec.slow
+ def test_type_match_complex(self):
s = c_spec.int_converter()
assert(not s.type_match(5.+1j))
- def test_var_in(self,level=5):
+ @dec.slow
+ def test_var_in(self):
mod_name = 'int_var_in' + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -101,7 +106,8 @@
except TypeError:
pass
- def test_int_return(self,level=5):
+ @dec.slow
+ def test_int_return(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -121,19 +127,24 @@
class FloatConverter(TestCase):
compiler = ''
- def test_type_match_string(self,level=5):
+ @dec.slow
+ def test_type_match_string(self):
s = c_spec.float_converter()
assert( not s.type_match('string'))
- def test_type_match_int(self,level=5):
+ @dec.slow
+ def test_type_match_int(self):
s = c_spec.float_converter()
assert(not s.type_match(5))
- def test_type_match_float(self,level=5):
+ @dec.slow
+ def test_type_match_float(self):
s = c_spec.float_converter()
assert(s.type_match(5.))
- def test_type_match_complex(self,level=5):
+ @dec.slow
+ def test_type_match_complex(self):
s = c_spec.float_converter()
assert(not s.type_match(5.+1j))
- def test_float_var_in(self,level=5):
+ @dec.slow
+ def test_float_var_in(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -157,7 +168,8 @@
pass
- def test_float_return(self,level=5):
+ @dec.slow
+ def test_float_return(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -176,19 +188,24 @@
class ComplexConverter(TestCase):
compiler = ''
- def test_type_match_string(self,level=5):
+ @dec.slow
+ def test_type_match_string(self):
s = c_spec.complex_converter()
assert( not s.type_match('string') )
- def test_type_match_int(self,level=5):
+ @dec.slow
+ def test_type_match_int(self):
s = c_spec.complex_converter()
assert(not s.type_match(5))
- def test_type_match_float(self,level=5):
+ @dec.slow
+ def test_type_match_float(self):
s = c_spec.complex_converter()
assert(not s.type_match(5.))
- def test_type_match_complex(self,level=5):
+ @dec.slow
+ def test_type_match_complex(self):
s = c_spec.complex_converter()
assert(s.type_match(5.+1j))
- def test_complex_var_in(self,level=5):
+ @dec.slow
+ def test_complex_var_in(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -211,7 +228,8 @@
except TypeError:
pass
- def test_complex_return(self,level=5):
+ @dec.slow
+ def test_complex_return(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -234,7 +252,8 @@
class FileConverter(TestCase):
compiler = ''
- def test_py_to_file(self,level=5):
+ @dec.slow
+ def test_py_to_file(self):
import tempfile
file_name = tempfile.mktemp()
file = open(file_name,'w')
@@ -245,7 +264,8 @@
file.close()
file = open(file_name,'r')
assert(file.read() == "hello bob")
- def test_file_to_py(self,level=5):
+ @dec.slow
+ def test_file_to_py(self):
import tempfile
file_name = tempfile.mktemp()
# not sure I like Py::String as default -- might move to std::sting
@@ -275,7 +295,8 @@
class CallableConverter(TestCase):
compiler=''
- def test_call_function(self,level=5):
+ @dec.slow
+ def test_call_function(self):
import string
func = string.find
search_str = "hello world hello"
@@ -295,34 +316,43 @@
class SequenceConverter(TestCase):
compiler = ''
- def test_convert_to_dict(self,level=5):
+ @dec.slow
+ def test_convert_to_dict(self):
d = {}
inline_tools.inline("",['d'],compiler=self.compiler,force=1)
- def test_convert_to_list(self,level=5):
+ @dec.slow
+ def test_convert_to_list(self):
l = []
inline_tools.inline("",['l'],compiler=self.compiler,force=1)
- def test_convert_to_string(self,level=5):
+ @dec.slow
+ def test_convert_to_string(self):
s = 'hello'
inline_tools.inline("",['s'],compiler=self.compiler,force=1)
- def test_convert_to_tuple(self,level=5):
+ @dec.slow
+ def test_convert_to_tuple(self):
t = ()
inline_tools.inline("",['t'],compiler=self.compiler,force=1)
class StringConverter(TestCase):
compiler = ''
- def test_type_match_string(self,level=5):
+ @dec.slow
+ def test_type_match_string(self):
s = c_spec.string_converter()
assert( s.type_match('string') )
- def test_type_match_int(self,level=5):
+ @dec.slow
+ def test_type_match_int(self):
s = c_spec.string_converter()
assert(not s.type_match(5))
- def test_type_match_float(self,level=5):
+ @dec.slow
+ def test_type_match_float(self):
s = c_spec.string_converter()
assert(not s.type_match(5.))
- def test_type_match_complex(self,level=5):
+ @dec.slow
+ def test_type_match_complex(self):
s = c_spec.string_converter()
assert(not s.type_match(5.+1j))
- def test_var_in(self,level=5):
+ @dec.slow
+ def test_var_in(self):
mod_name = 'string_var_in'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -346,7 +376,8 @@
except TypeError:
pass
- def test_return(self,level=5):
+ @dec.slow
+ def test_return(self):
mod_name = 'string_return'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -365,15 +396,18 @@
class ListConverter(TestCase):
compiler = ''
- def test_type_match_bad(self,level=5):
+ @dec.slow
+ def test_type_match_bad(self):
s = c_spec.list_converter()
objs = [{},(),'',1,1.,1+1j]
for i in objs:
assert( not s.type_match(i) )
- def test_type_match_good(self,level=5):
+ @dec.slow
+ def test_type_match_good(self):
s = c_spec.list_converter()
assert(s.type_match([]))
- def test_var_in(self,level=5):
+ @dec.slow
+ def test_var_in(self):
mod_name = 'list_var_in'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -396,7 +430,8 @@
except TypeError:
pass
- def test_return(self,level=5):
+ @dec.slow
+ def test_return(self):
mod_name = 'list_return'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -414,7 +449,8 @@
c = test(b)
assert( c == ['hello'])
- def test_speed(self,level=5):
+ @dec.slow
+ def test_speed(self):
mod_name = 'list_speed'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -476,15 +512,18 @@
class TupleConverter(TestCase):
compiler = ''
- def test_type_match_bad(self,level=5):
+ @dec.slow
+ def test_type_match_bad(self):
s = c_spec.tuple_converter()
objs = [{},[],'',1,1.,1+1j]
for i in objs:
assert( not s.type_match(i) )
- def test_type_match_good(self,level=5):
+ @dec.slow
+ def test_type_match_good(self):
s = c_spec.tuple_converter()
assert(s.type_match((1,)))
- def test_var_in(self,level=5):
+ @dec.slow
+ def test_var_in(self):
mod_name = 'tuple_var_in'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -507,7 +546,8 @@
except TypeError:
pass
- def test_return(self,level=5):
+ @dec.slow
+ def test_return(self):
mod_name = 'tuple_return'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -537,15 +577,18 @@
# so that it can run on its own.
compiler=''
- def test_type_match_bad(self,level=5):
+ @dec.slow
+ def test_type_match_bad(self):
s = c_spec.dict_converter()
objs = [[],(),'',1,1.,1+1j]
for i in objs:
assert( not s.type_match(i) )
- def test_type_match_good(self,level=5):
+ @dec.slow
+ def test_type_match_good(self):
s = c_spec.dict_converter()
assert(s.type_match({}))
- def test_var_in(self,level=5):
+ @dec.slow
+ def test_var_in(self):
mod_name = 'dict_var_in'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -568,7 +611,8 @@
except TypeError:
pass
- def test_return(self,level=5):
+ @dec.slow
+ def test_return(self):
mod_name = 'dict_return'+self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
Modified: branches/testing_cleanup/scipy/weave/tests/test_ext_tools.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_ext_tools.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_ext_tools.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -19,12 +19,14 @@
class TestExtModule(TestCase):
#should really do some testing of where modules end up
- def test_simple(self,level=5):
+ @dec.slow
+ def test_simple(self):
""" Simplest possible module """
mod = ext_tools.ext_module('simple_ext_module')
mod.compile(location = build_dir)
import simple_ext_module
- def test_multi_functions(self,level=5):
+ @dec.slow
+ def test_multi_functions(self):
mod = ext_tools.ext_module('module_multi_function')
var_specs = []
code = ""
@@ -36,7 +38,8 @@
import module_multi_function
module_multi_function.test()
module_multi_function.test2()
- def test_with_include(self,level=5):
+ @dec.slow
+ def test_with_include(self):
# decalaring variables
a = 2.;
@@ -57,7 +60,8 @@
import ext_module_with_include
ext_module_with_include.test(a)
- def test_string_and_int(self,level=5):
+ @dec.slow
+ def test_string_and_int(self):
# decalaring variables
a = 2;b = 'string'
# declare module
@@ -73,7 +77,8 @@
c = ext_string_and_int.test(a,b)
assert(c == len(b))
- def test_return_tuple(self,level=5):
+ @dec.slow
+ def test_return_tuple(self):
# decalaring variables
a = 2
# declare module
@@ -96,7 +101,8 @@
class TestExtFunction(TestCase):
#should really do some testing of where modules end up
- def test_simple(self,level=5):
+ @dec.slow
+ def test_simple(self):
""" Simplest possible function """
mod = ext_tools.ext_module('simple_ext_function')
var_specs = []
Modified: branches/testing_cleanup/scipy/weave/tests/test_inline_tools.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_inline_tools.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_inline_tools.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -14,7 +14,8 @@
I'd like to benchmark these things somehow.
"""
- def test_exceptions(self,level=5):
+ @dec.slow
+ def test_exceptions(self):
a = 3
code = """
if (a < 2)
Modified: branches/testing_cleanup/scipy/weave/tests/test_numpy_scalar_spec.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_numpy_scalar_spec.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_numpy_scalar_spec.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -58,16 +58,21 @@
def setUp(self):
self.converter = numpy_complex_scalar_converter()
- def test_type_match_string(self,level=5):
+ @dec.slow
+ def test_type_match_string(self):
assert( not self.converter.type_match('string') )
- def test_type_match_int(self,level=5):
+ @dec.slow
+ def test_type_match_int(self):
assert( not self.converter.type_match(5))
- def test_type_match_float(self,level=5):
+ @dec.slow
+ def test_type_match_float(self):
assert( not self.converter.type_match(5.))
- def test_type_match_complex128(self,level=5):
+ @dec.slow
+ def test_type_match_complex128(self):
assert(self.converter.type_match(numpy.complex128(5.+1j)))
- def test_complex_var_in(self,level=5):
+ @dec.slow
+ def test_complex_var_in(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -90,7 +95,8 @@
except TypeError:
pass
- def test_complex_return(self,level=5):
+ @dec.slow
+ def test_complex_return(self):
mod_name = sys._getframe().f_code.co_name + self.compiler
mod_name = unique_mod(test_dir,mod_name)
mod = ext_tools.ext_module(mod_name)
@@ -107,7 +113,8 @@
c = test(b)
assert( c == 3.+3j)
- def test_inline(self, level=5):
+ @dec.slow
+ def test_inline(self):
a = numpy.complex128(1+1j)
result = inline_tools.inline("return_val=1.0/a;",['a'])
assert( result==.5-.5j)
Modified: branches/testing_cleanup/scipy/weave/tests/test_scxx_dict.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_scxx_dict.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_scxx_dict.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -15,7 +15,8 @@
# Check that construction from basic types is allowed and have correct
# reference counts
#------------------------------------------------------------------------
- def test_empty(self,level=5):
+ @dec.slow
+ def test_empty(self):
# strange int value used to try and make sure refcount is 2.
code = """
py::dict val;
@@ -27,7 +28,8 @@
class TestDictHasKey(TestCase):
- def test_obj(self,level=5):
+ @dec.slow
+ def test_obj(self):
class Foo:
pass
key = Foo()
@@ -38,7 +40,8 @@
"""
res = inline_tools.inline(code,['a','key'])
assert res
- def test_int(self,level=5):
+ @dec.slow
+ def test_int(self):
a = {}
a[1234] = 12345
code = """
@@ -46,7 +49,8 @@
"""
res = inline_tools.inline(code,['a'])
assert res
- def test_double(self,level=5):
+ @dec.slow
+ def test_double(self):
a = {}
a[1234.] = 12345
code = """
@@ -54,7 +58,8 @@
"""
res = inline_tools.inline(code,['a'])
assert res
- def test_complex(self,level=5):
+ @dec.slow
+ def test_complex(self):
a = {}
a[1+1j] = 12345
key = 1+1j
@@ -64,7 +69,8 @@
res = inline_tools.inline(code,['a','key'])
assert res
- def test_string(self,level=5):
+ @dec.slow
+ def test_string(self):
a = {}
a["b"] = 12345
code = """
@@ -72,7 +78,8 @@
"""
res = inline_tools.inline(code,['a'])
assert res
- def test_std_string(self,level=5):
+ @dec.slow
+ def test_std_string(self):
a = {}
a["b"] = 12345
key_name = "b"
@@ -81,7 +88,8 @@
"""
res = inline_tools.inline(code,['a','key_name'])
assert res
- def test_string_fail(self,level=5):
+ @dec.slow
+ def test_string_fail(self):
a = {}
a["b"] = 12345
code = """
@@ -99,10 +107,12 @@
res = inline_tools.inline(code,args)
assert res == a['b']
- def test_char(self,level=5):
+ @dec.slow
+ def test_char(self):
self.generic_get('return_val = a["b"];')
- def DOESNT_WORK_check_char_fail(self,level=5):
+ @dec.slow
+ def DOESNT_WORK_check_char_fail(self):
# We can't through a KeyError for dicts on RHS of
# = but not on LHS. Not sure how to deal with this.
try:
@@ -110,18 +120,21 @@
except KeyError:
pass
- def test_string(self,level=5):
+ @dec.slow
+ def test_string(self):
self.generic_get('return_val = a[std::string("b")];')
- def test_obj(self,level=5):
+ @dec.slow
+ def test_obj(self):
code = """
py::object name = "b";
return_val = a[name];
"""
self.generic_get(code,['a'])
- def DOESNT_WORK_check_obj_fail(self,level=5):
+ @dec.slow
+ def DOESNT_WORK_check_obj_fail(self):
# We can't through a KeyError for dicts on RHS of
# = but not on LHS. Not sure how to deal with this.
try:
@@ -164,37 +177,47 @@
assert before == after
assert before_overwritten == after_overwritten
- def test_new_int_int(self,level=5):
+ @dec.slow
+ def test_new_int_int(self):
key,val = 1234,12345
self.generic_new(key,val)
- def test_new_double_int(self,level=5):
+ @dec.slow
+ def test_new_double_int(self):
key,val = 1234.,12345
self.generic_new(key,val)
- def test_new_std_string_int(self,level=5):
+ @dec.slow
+ def test_new_std_string_int(self):
key,val = "hello",12345
self.generic_new(key,val)
- def test_new_complex_int(self,level=5):
+ @dec.slow
+ def test_new_complex_int(self):
key,val = 1+1j,12345
self.generic_new(key,val)
- def test_new_obj_int(self,level=5):
+ @dec.slow
+ def test_new_obj_int(self):
class Foo:
pass
key,val = Foo(),12345
self.generic_new(key,val)
- def test_overwrite_int_int(self,level=5):
+ @dec.slow
+ def test_overwrite_int_int(self):
key,val = 1234,12345
self.generic_overwrite(key,val)
- def test_overwrite_double_int(self,level=5):
+ @dec.slow
+ def test_overwrite_double_int(self):
key,val = 1234.,12345
self.generic_overwrite(key,val)
- def test_overwrite_std_string_int(self,level=5):
+ @dec.slow
+ def test_overwrite_std_string_int(self):
key,val = "hello",12345
self.generic_overwrite(key,val)
- def test_overwrite_complex_int(self,level=5):
+ @dec.slow
+ def test_overwrite_complex_int(self):
key,val = 1+1j,12345
self.generic_overwrite(key,val)
- def test_overwrite_obj_int(self,level=5):
+ @dec.slow
+ def test_overwrite_obj_int(self):
class Foo:
pass
key,val = Foo(),12345
@@ -216,46 +239,56 @@
after = sys.getrefcount(a), sys.getrefcount(key)
assert before[0] == after[0]
assert before[1] == after[1] + 1
- def test_int(self,level=5):
+ @dec.slow
+ def test_int(self):
key = 1234
self.generic(key)
- def test_double(self,level=5):
+ @dec.slow
+ def test_double(self):
key = 1234.
self.generic(key)
- def test_std_string(self,level=5):
+ @dec.slow
+ def test_std_string(self):
key = "hello"
self.generic(key)
- def test_complex(self,level=5):
+ @dec.slow
+ def test_complex(self):
key = 1+1j
self.generic(key)
- def test_obj(self,level=5):
+ @dec.slow
+ def test_obj(self):
class Foo:
pass
key = Foo()
self.generic(key)
class TestDictOthers(TestCase):
- def test_clear(self,level=5):
+ @dec.slow
+ def test_clear(self):
a = {}
a["hello"] = 1
inline_tools.inline("a.clear();",['a'])
assert not a
- def test_items(self,level=5):
+ @dec.slow
+ def test_items(self):
a = {}
a["hello"] = 1
items = inline_tools.inline("return_val = a.items();",['a'])
assert items == a.items()
- def test_values(self,level=5):
+ @dec.slow
+ def test_values(self):
a = {}
a["hello"] = 1
values = inline_tools.inline("return_val = a.values();",['a'])
assert values == a.values()
- def test_keys(self,level=5):
+ @dec.slow
+ def test_keys(self):
a = {}
a["hello"] = 1
keys = inline_tools.inline("return_val = a.keys();",['a'])
assert keys == a.keys()
- def test_update(self,level=5):
+ @dec.slow
+ def test_update(self):
a,b = {},{}
a["hello"] = 1
b["hello"] = 2
Modified: branches/testing_cleanup/scipy/weave/tests/test_scxx_object.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_scxx_object.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_scxx_object.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -14,7 +14,8 @@
# Check that construction from basic types is allowed and have correct
# reference counts
#------------------------------------------------------------------------
- def test_int(self,level=5):
+ @dec.slow
+ def test_int(self):
# strange int value used to try and make sure refcount is 2.
code = """
py::object val = 1001;
@@ -23,7 +24,8 @@
res = inline_tools.inline(code)
assert_equal(sys.getrefcount(res),2)
assert_equal(res,1001)
- def test_float(self,level=5):
+ @dec.slow
+ def test_float(self):
code = """
py::object val = (float)1.0;
return_val = val;
@@ -31,7 +33,8 @@
res = inline_tools.inline(code)
assert_equal(sys.getrefcount(res),2)
assert_equal(res,1.0)
- def test_double(self,level=5):
+ @dec.slow
+ def test_double(self):
code = """
py::object val = 1.0;
return_val = val;
@@ -39,7 +42,8 @@
res = inline_tools.inline(code)
assert_equal(sys.getrefcount(res),2)
assert_equal(res,1.0)
- def test_complex(self,level=5):
+ @dec.slow
+ def test_complex(self):
code = """
std::complex<double> num = std::complex<double>(1.0,1.0);
py::object val = num;
@@ -48,7 +52,8 @@
res = inline_tools.inline(code)
assert_equal(sys.getrefcount(res),2)
assert_equal(res,1.0+1.0j)
- def test_string(self,level=5):
+ @dec.slow
+ def test_string(self):
code = """
py::object val = "hello";
return_val = val;
@@ -57,7 +62,8 @@
assert_equal(sys.getrefcount(res),2)
assert_equal(res,"hello")
- def test_std_string(self,level=5):
+ @dec.slow
+ def test_std_string(self):
code = """
std::string s = std::string("hello");
py::object val = s;
@@ -71,14 +77,16 @@
#------------------------------------------------------------------------
# Check the object print protocol.
#------------------------------------------------------------------------
- def test_stdout(self,level=5):
+ @dec.slow
+ def test_stdout(self):
code = """
py::object val = "how now brown cow";
val.print(stdout);
"""
res = inline_tools.inline(code)
# visual check on this one.
- def test_stringio(self,level=5):
+ @dec.slow
+ def test_stringio(self):
import cStringIO
file_imposter = cStringIO.StringIO()
code = """
@@ -89,7 +97,8 @@
print file_imposter.getvalue()
assert_equal(file_imposter.getvalue(),"'how now brown cow'")
-## def test_failure(self,level=5):
+## @dec.slow
+## def test_failure(self):
## code = """
## FILE* file = 0;
## py::object val = "how now brown cow";
@@ -103,32 +112,37 @@
class TestObjectCast(TestCase):
- def test_int_cast(self,level=5):
+ @dec.slow
+ def test_int_cast(self):
code = """
py::object val = 1;
int raw_val = val;
"""
inline_tools.inline(code)
- def test_double_cast(self,level=5):
+ @dec.slow
+ def test_double_cast(self):
code = """
py::object val = 1.0;
double raw_val = val;
"""
inline_tools.inline(code)
- def test_float_cast(self,level=5):
+ @dec.slow
+ def test_float_cast(self):
code = """
py::object val = 1.0;
float raw_val = val;
"""
inline_tools.inline(code)
- def test_complex_cast(self,level=5):
+ @dec.slow
+ def test_complex_cast(self):
code = """
std::complex<double> num = std::complex<double>(1.0,1.0);
py::object val = num;
std::complex<double> raw_val = val;
"""
inline_tools.inline(code)
- def test_string_cast(self,level=5):
+ @dec.slow
+ def test_string_cast(self):
code = """
py::object val = "hello";
std::string raw_val = val;
@@ -149,7 +163,8 @@
# return "b"
class TestObjectHasattr(TestCase):
- def test_string(self,level=5):
+ @dec.slow
+ def test_string(self):
a = Foo()
a.b = 12345
code = """
@@ -157,7 +172,8 @@
"""
res = inline_tools.inline(code,['a'])
assert res
- def test_std_string(self,level=5):
+ @dec.slow
+ def test_std_string(self):
a = Foo()
a.b = 12345
attr_name = "b"
@@ -166,7 +182,8 @@
"""
res = inline_tools.inline(code,['a','attr_name'])
assert res
- def test_string_fail(self,level=5):
+ @dec.slow
+ def test_string_fail(self):
a = Foo()
a.b = 12345
code = """
@@ -174,7 +191,8 @@
"""
res = inline_tools.inline(code,['a'])
assert not res
- def test_inline(self,level=5):
+ @dec.slow
+ def test_inline(self):
""" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE
"""
a = Foo()
@@ -195,7 +213,8 @@
print 'before, after, after2:', before, after, after2
pass
- def test_func(self,level=5):
+ @dec.slow
+ def test_func(self):
a = Foo()
a.b = 12345
code = """
@@ -217,32 +236,38 @@
after = sys.getrefcount(a.b)
assert_equal(after,before)
- def test_char(self,level=5):
+ @dec.slow
+ def test_char(self):
self.generic_attr('return_val = a.attr("b");')
- def test_char_fail(self,level=5):
+ @dec.slow
+ def test_char_fail(self):
try:
self.generic_attr('return_val = a.attr("c");')
except AttributeError:
pass
- def test_string(self,level=5):
+ @dec.slow
+ def test_string(self):
self.generic_attr('return_val = a.attr(std::string("b"));')
- def test_string_fail(self,level=5):
+ @dec.slow
+ def test_string_fail(self):
try:
self.generic_attr('return_val = a.attr(std::string("c"));')
except AttributeError:
pass
- def test_obj(self,level=5):
+ @dec.slow
+ def test_obj(self):
code = """
py::object name = "b";
return_val = a.attr(name);
"""
self.generic_attr(code,['a'])
- def test_obj_fail(self,level=5):
+ @dec.slow
+ def test_obj_fail(self):
try:
code = """
py::object name = "c";
@@ -252,7 +277,8 @@
except AttributeError:
pass
- def test_attr_call(self,level=5):
+ @dec.slow
+ def test_attr_call(self):
a = Foo()
res = inline_tools.inline('return_val = a.attr("bar").call();',['a'])
first = sys.getrefcount(res)
@@ -277,27 +303,34 @@
res = inline_tools.inline(code,args)
assert_equal(a.b,desired)
- def test_existing_char(self,level=5):
+ @dec.slow
+ def test_existing_char(self):
self.generic_existing('a.set_attr("b","hello");',"hello")
- def test_new_char(self,level=5):
+ @dec.slow
+ def test_new_char(self):
self.generic_new('a.set_attr("b","hello");',"hello")
- def test_existing_string(self,level=5):
+ @dec.slow
+ def test_existing_string(self):
self.generic_existing('a.set_attr("b",std::string("hello"));',"hello")
- def test_new_string(self,level=5):
+ @dec.slow
+ def test_new_string(self):
self.generic_new('a.set_attr("b",std::string("hello"));',"hello")
- def test_existing_object(self,level=5):
+ @dec.slow
+ def test_existing_object(self):
code = """
py::object obj = "hello";
a.set_attr("b",obj);
"""
self.generic_existing(code,"hello")
- def test_new_object(self,level=5):
+ @dec.slow
+ def test_new_object(self):
code = """
py::object obj = "hello";
a.set_attr("b",obj);
"""
self.generic_new(code,"hello")
- def test_new_fail(self,level=5):
+ @dec.slow
+ def test_new_fail(self):
try:
code = """
py::object obj = 1;
@@ -307,19 +340,24 @@
except:
pass
- def test_existing_int(self,level=5):
+ @dec.slow
+ def test_existing_int(self):
self.generic_existing('a.set_attr("b",1);',1)
- def test_existing_double(self,level=5):
+ @dec.slow
+ def test_existing_double(self):
self.generic_existing('a.set_attr("b",1.0);',1.0)
- def test_existing_complex(self,level=5):
+ @dec.slow
+ def test_existing_complex(self):
code = """
std::complex<double> obj = std::complex<double>(1,1);
a.set_attr("b",obj);
"""
self.generic_existing(code,1+1j)
- def test_existing_char1(self,level=5):
+ @dec.slow
+ def test_existing_char1(self):
self.generic_existing('a.set_attr("b","hello");',"hello")
- def test_existing_string1(self,level=5):
+ @dec.slow
+ def test_existing_string1(self):
code = """
std::string obj = std::string("hello");
a.set_attr("b",obj);
@@ -334,15 +372,18 @@
res = inline_tools.inline(code,args)
assert not hasattr(a,"b")
- def test_char(self,level=5):
+ @dec.slow
+ def test_char(self):
self.generic('a.del("b");')
- def test_string(self,level=5):
+ @dec.slow
+ def test_string(self):
code = """
std::string name = std::string("b");
a.del(name);
"""
self.generic(code)
- def test_object(self,level=5):
+ @dec.slow
+ def test_object(self):
code = """
py::object name = py::object("b");
a.del(name);
@@ -350,11 +391,13 @@
self.generic(code)
class TestObjectCmp(TestCase):
- def test_equal(self,level=5):
+ @dec.slow
+ def test_equal(self):
a,b = 1,1
res = inline_tools.inline('return_val = (a == b);',['a','b'])
assert_equal(res,(a == b))
- def test_equal_objects(self,level=5):
+ @dec.slow
+ def test_equal_objects(self):
class Foo:
def __init__(self,x):
self.x = x
@@ -363,47 +406,58 @@
a,b = Foo(1),Foo(2)
res = inline_tools.inline('return_val = (a == b);',['a','b'])
assert_equal(res,(a == b))
- def test_lt(self,level=5):
+ @dec.slow
+ def test_lt(self):
a,b = 1,2
res = inline_tools.inline('return_val = (a < b);',['a','b'])
assert_equal(res,(a < b))
- def test_gt(self,level=5):
+ @dec.slow
+ def test_gt(self):
a,b = 1,2
res = inline_tools.inline('return_val = (a > b);',['a','b'])
assert_equal(res,(a > b))
- def test_gte(self,level=5):
+ @dec.slow
+ def test_gte(self):
a,b = 1,2
res = inline_tools.inline('return_val = (a >= b);',['a','b'])
assert_equal(res,(a >= b))
- def test_lte(self,level=5):
+ @dec.slow
+ def test_lte(self):
a,b = 1,2
res = inline_tools.inline('return_val = (a <= b);',['a','b'])
assert_equal(res,(a <= b))
- def test_not_equal(self,level=5):
+ @dec.slow
+ def test_not_equal(self):
a,b = 1,2
res = inline_tools.inline('return_val = (a != b);',['a','b'])
assert_equal(res,(a != b))
- def test_int(self,level=5):
+ @dec.slow
+ def test_int(self):
a = 1
res = inline_tools.inline('return_val = (a == 1);',['a'])
assert_equal(res,(a == 1))
- def test_int2(self,level=5):
+ @dec.slow
+ def test_int2(self):
a = 1
res = inline_tools.inline('return_val = (1 == a);',['a'])
assert_equal(res,(a == 1))
- def test_unsigned_long(self,level=5):
+ @dec.slow
+ def test_unsigned_long(self):
a = 1
res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])
assert_equal(res,(a == 1))
- def test_double(self,level=5):
+ @dec.slow
+ def test_double(self):
a = 1
res = inline_tools.inline('return_val = (a == 1.0);',['a'])
assert_equal(res,(a == 1.0))
- def test_char(self,level=5):
+ @dec.slow
+ def test_char(self):
a = "hello"
res = inline_tools.inline('return_val = (a == "hello");',['a'])
assert_equal(res,(a == "hello"))
- def test_std_string(self,level=5):
+ @dec.slow
+ def test_std_string(self):
a = "hello"
code = """
std::string hello = std::string("hello");
@@ -413,7 +467,8 @@
assert_equal(res,(a == "hello"))
class TestObjectRepr(TestCase):
- def test_repr(self,level=5):
+ @dec.slow
+ def test_repr(self):
class Foo:
def __str__(self):
return "str return"
@@ -429,7 +484,8 @@
assert_equal(res,"repr return")
class TestObjectStr(TestCase):
- def test_str(self,level=5):
+ @dec.slow
+ def test_str(self):
class Foo:
def __str__(self):
return "str return"
@@ -447,7 +503,8 @@
class TestObjectUnicode(TestCase):
# This ain't going to win awards for test of the year...
- def test_unicode(self,level=5):
+ @dec.slow
+ def test_unicode(self):
class Foo:
def __repr__(self):
return "repr return"
@@ -463,14 +520,16 @@
assert_equal(res,"unicode")
class TestObjectIsCallable(TestCase):
- def test_true(self,level=5):
+ @dec.slow
+ def test_true(self):
class Foo:
def __call__(self):
return 0
a= Foo()
res = inline_tools.inline('return_val = a.is_callable();',['a'])
assert res
- def test_false(self,level=5):
+ @dec.slow
+ def test_false(self):
class Foo:
pass
a= Foo()
@@ -478,13 +537,15 @@
assert not res
class TestObjectCall(TestCase):
- def test_noargs(self,level=5):
+ @dec.slow
+ def test_noargs(self):
def Foo():
return (1,2,3)
res = inline_tools.inline('return_val = Foo.call();',['Foo'])
assert_equal(res,(1,2,3))
assert_equal(sys.getrefcount(res),3) # should be 2?
- def test_args(self,level=5):
+ @dec.slow
+ def test_args(self):
def Foo(val1,val2):
return (val1,val2)
code = """
@@ -496,7 +557,8 @@
res = inline_tools.inline(code,['Foo'])
assert_equal(res,(1,"hello"))
assert_equal(sys.getrefcount(res),2)
- def test_args_kw(self,level=5):
+ @dec.slow
+ def test_args_kw(self):
def Foo(val1,val2,val3=1):
return (val1,val2,val3)
code = """
@@ -510,7 +572,8 @@
res = inline_tools.inline(code,['Foo'])
assert_equal(res,(1,"hello",3))
assert_equal(sys.getrefcount(res),2)
- def test_noargs_with_args(self,level=5):
+ @dec.slow
+ def test_noargs_with_args(self):
# calling a function that does take args with args
# should fail.
def Foo():
@@ -534,7 +597,8 @@
assert_equal(second,third)
class TestObjectMcall(TestCase):
- def test_noargs(self,level=5):
+ @dec.slow
+ def test_noargs(self):
a = Foo()
res = inline_tools.inline('return_val = a.mcall("bar");',['a'])
assert_equal(res,"bar results")
@@ -544,7 +608,8 @@
assert_equal(res,"bar results")
second = sys.getrefcount(res)
assert_equal(first,second)
- def test_args(self,level=5):
+ @dec.slow
+ def test_args(self):
a = Foo()
code = """
py::tuple args(2);
@@ -555,7 +620,8 @@
res = inline_tools.inline(code,['a'])
assert_equal(res,(1,"hello"))
assert_equal(sys.getrefcount(res),2)
- def test_args_kw(self,level=5):
+ @dec.slow
+ def test_args_kw(self):
a = Foo()
code = """
py::tuple args(2);
@@ -568,7 +634,8 @@
res = inline_tools.inline(code,['a'])
assert_equal(res,(1,"hello",3))
assert_equal(sys.getrefcount(res),2)
- def test_std_noargs(self,level=5):
+ @dec.slow
+ def test_std_noargs(self):
a = Foo()
method = "bar"
res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])
@@ -579,7 +646,8 @@
assert_equal(res,"bar results")
second = sys.getrefcount(res)
assert_equal(first,second)
- def test_std_args(self,level=5):
+ @dec.slow
+ def test_std_args(self):
a = Foo()
method = "bar2"
code = """
@@ -591,7 +659,8 @@
res = inline_tools.inline(code,['a','method'])
assert_equal(res,(1,"hello"))
assert_equal(sys.getrefcount(res),2)
- def test_std_args_kw(self,level=5):
+ @dec.slow
+ def test_std_args_kw(self):
a = Foo()
method = "bar3"
code = """
@@ -605,7 +674,8 @@
res = inline_tools.inline(code,['a','method'])
assert_equal(res,(1,"hello",3))
assert_equal(sys.getrefcount(res),2)
- def test_noargs_with_args(self,level=5):
+ @dec.slow
+ def test_noargs_with_args(self):
# calling a function that does take args with args
# should fail.
a = Foo()
@@ -628,7 +698,8 @@
assert_equal(second,third)
class TestObjectHash(TestCase):
- def test_hash(self,level=5):
+ @dec.slow
+ def test_hash(self):
class Foo:
def __hash__(self):
return 123
@@ -638,19 +709,22 @@
assert_equal(res,123)
class TestObjectIsTrue(TestCase):
- def test_true(self,level=5):
+ @dec.slow
+ def test_true(self):
class Foo:
pass
a= Foo()
res = inline_tools.inline('return_val = a.is_true();',['a'])
assert_equal(res,1)
- def test_false(self,level=5):
+ @dec.slow
+ def test_false(self):
a= None
res = inline_tools.inline('return_val = a.is_true();',['a'])
assert_equal(res,0)
class TestObjectType(TestCase):
- def test_type(self,level=5):
+ @dec.slow
+ def test_type(self):
class Foo:
pass
a= Foo()
@@ -658,21 +732,24 @@
assert_equal(res,type(a))
class TestObjectSize(TestCase):
- def test_size(self,level=5):
+ @dec.slow
+ def test_size(self):
class Foo:
def __len__(self):
return 10
a= Foo()
res = inline_tools.inline('return_val = a.size();',['a'])
assert_equal(res,len(a))
- def test_len(self,level=5):
+ @dec.slow
+ def test_len(self):
class Foo:
def __len__(self):
return 10
a= Foo()
res = inline_tools.inline('return_val = a.len();',['a'])
assert_equal(res,len(a))
- def test_length(self,level=5):
+ @dec.slow
+ def test_length(self):
class Foo:
def __len__(self):
return 10
@@ -682,34 +759,40 @@
from UserList import UserList
class TestObjectSetItemOpIndex(TestCase):
- def test_list_refcount(self,level=5):
+ @dec.slow
+ def test_list_refcount(self):
a = UserList([1,2,3])
# temporary refcount fix until I understand why it incs by one.
inline_tools.inline("a[1] = 1234;",['a'])
before1 = sys.getrefcount(a)
after1 = sys.getrefcount(a)
assert_equal(after1,before1)
- def test_set_int(self,level=5):
+ @dec.slow
+ def test_set_int(self):
a = UserList([1,2,3])
inline_tools.inline("a[1] = 1234;",['a'])
assert_equal(sys.getrefcount(a[1]),2)
assert_equal(a[1],1234)
- def test_set_double(self,level=5):
+ @dec.slow
+ def test_set_double(self):
a = UserList([1,2,3])
inline_tools.inline("a[1] = 123.0;",['a'])
assert_equal(sys.getrefcount(a[1]),2)
assert_equal(a[1],123.0)
- def test_set_char(self,level=5):
+ @dec.slow
+ def test_set_char(self):
a = UserList([1,2,3])
inline_tools.inline('a[1] = "bubba";',['a'])
assert_equal(sys.getrefcount(a[1]),2)
assert_equal(a[1],'bubba')
- def test_set_string(self,level=5):
+ @dec.slow
+ def test_set_string(self):
a = UserList([1,2,3])
inline_tools.inline('a[1] = std::string("sissy");',['a'])
assert_equal(sys.getrefcount(a[1]),2)
assert_equal(a[1],'sissy')
- def test_set_string(self,level=5):
+ @dec.slow
+ def test_set_string(self):
a = UserList([1,2,3])
inline_tools.inline('a[1] = std::complex<double>(1,1);',['a'])
assert_equal(sys.getrefcount(a[1]),2)
@@ -717,7 +800,8 @@
from UserDict import UserDict
class TestObjectSetItemOpKey(TestCase):
- def test_key_refcount(self,level=5):
+ @dec.slow
+ def test_key_refcount(self):
a = UserDict()
code = """
py::object one = 1;
@@ -751,7 +835,8 @@
assert_equal(val[0] + 1, val[1])
assert_equal(val[1], val[2])
- def test_set_double_exists(self,level=5):
+ @dec.slow
+ def test_set_double_exists(self):
a = UserDict()
key = 10.0
a[key] = 100.0
@@ -764,27 +849,31 @@
assert_equal(sys.getrefcount(key),5)
assert_equal(sys.getrefcount(a[key]),2)
assert_equal(a[key],123.0)
- def test_set_double_new(self,level=5):
+ @dec.slow
+ def test_set_double_new(self):
a = UserDict()
key = 1.0
inline_tools.inline('a[key] = 123.0;',['a','key'])
assert_equal(sys.getrefcount(key),4) # should be 3
assert_equal(sys.getrefcount(a[key]),2)
assert_equal(a[key],123.0)
- def test_set_complex(self,level=5):
+ @dec.slow
+ def test_set_complex(self):
a = UserDict()
key = 1+1j
inline_tools.inline("a[key] = 1234;",['a','key'])
assert_equal(sys.getrefcount(key),4) # should be 3
assert_equal(sys.getrefcount(a[key]),2)
assert_equal(a[key],1234)
- def test_set_char(self,level=5):
+ @dec.slow
+ def test_set_char(self):
a = UserDict()
inline_tools.inline('a["hello"] = 123.0;',['a'])
assert_equal(sys.getrefcount(a["hello"]),2)
assert_equal(a["hello"],123.0)
- def test_set_class(self,level=5):
+ @dec.slow
+ def test_set_class(self):
a = UserDict()
class Foo:
def __init__(self,val):
@@ -802,7 +891,8 @@
assert_equal(sys.getrefcount(key),4)
assert_equal(sys.getrefcount(a[key]),2)
assert_equal(a[key],'bubba')
- def test_set_from_member(self,level=5):
+ @dec.slow
+ def test_set_from_member(self):
a = UserDict()
a['first'] = 1
a['second'] = 2
@@ -810,7 +900,4 @@
assert_equal(a['first'],a['second'])
if __name__ == "__main__":
- import sys
- if len(sys.argv) == 1:
- sys.argv.extend(["--level=5"])
unittest.main()
Modified: branches/testing_cleanup/scipy/weave/tests/test_scxx_sequence.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_scxx_sequence.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_scxx_sequence.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -23,7 +23,8 @@
class _TestSequenceBase(TestCase):
seq_type = None
- def test_conversion(self,level=5):
+ @dec.slow
+ def test_conversion(self):
a = self.seq_type([1])
before = sys.getrefcount(a)
inline_tools.inline(" ",['a'])
@@ -35,7 +36,8 @@
#print '2nd,3rd:', before, after
assert(after == before)
- def test_in(self,level=5):
+ @dec.slow
+ def test_in(self):
""" Test the "in" method for lists. We'll assume
it works for sequences if it works here.
"""
@@ -87,7 +89,8 @@
res = inline_tools.inline(code,['a'])
assert res == 0
- def test_count(self,level=5):
+ @dec.slow
+ def test_count(self):
""" Test the "count" method for lists. We'll assume
it works for sequences if it works hre.
"""
@@ -121,7 +124,8 @@
res = inline_tools.inline(code,['a'])
assert res == 1
- def test_access_speed(self,level=5):
+ @dec.slow
+ def test_access_speed(self):
N = 1000000
print '%s access -- val = a[i] for N =', (self.seq_type, N)
a = self.seq_type([0]) * N
@@ -151,7 +155,8 @@
print 'weave:', t2 - t1
# Fails
- def test_access_set_speed(self,level=5):
+ @dec.slow
+ def test_access_set_speed(self):
N = 1000000
print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)
a = self.seq_type([0]) * N
@@ -181,7 +186,8 @@
class TestTuple(_TestSequenceBase):
seq_type = tuple
- def test_set_item_operator_equal_fail(self,level=5):
+ @dec.slow
+ def test_set_item_operator_equal_fail(self):
# Tuples should only allow setting of variables
# immediately after creation.
a = (1,2,3)
@@ -189,7 +195,8 @@
inline_tools.inline("a[1] = 1234;",['a'])
except TypeError:
pass
- def test_set_item_operator_equal(self,level=5):
+ @dec.slow
+ def test_set_item_operator_equal(self):
code = """
py::tuple a(3);
a[0] = 1;
@@ -202,7 +209,8 @@
# returned value should only have a single refcount
assert sys.getrefcount(a) == 2
- def test_set_item_index_error(self,level=5):
+ @dec.slow
+ def test_set_item_index_error(self):
code = """
py::tuple a(3);
a[4] = 1;
@@ -213,7 +221,8 @@
assert 0
except IndexError:
pass
- def test_get_item_operator_index_error(self,level=5):
+ @dec.slow
+ def test_get_item_operator_index_error(self):
code = """
py::tuple a(3);
py::object b = a[4]; // should fail.
@@ -226,7 +235,8 @@
class TestList(_TestSequenceBase):
seq_type = list
- def test_append_passed_item(self,level=5):
+ @dec.slow
+ def test_append_passed_item(self):
a = []
item = 1
@@ -243,7 +253,8 @@
after2 = sys.getrefcount(item)
assert after1 == before1
assert after2 == before2
- def test_append(self,level=5):
+ @dec.slow
+ def test_append(self):
a = []
# temporary refcount fix until I understand why it incs by one.
inline_tools.inline("a.append(1);",['a'])
@@ -277,7 +288,8 @@
after1 = sys.getrefcount(a)
assert after1 == before1
- def test_insert(self,level=5):
+ @dec.slow
+ def test_insert(self):
a = [1,2,3]
a.insert(1,234)
@@ -316,7 +328,8 @@
after1 = sys.getrefcount(a)
assert after1 == before1
- def test_set_item_operator_equal(self,level=5):
+ @dec.slow
+ def test_set_item_operator_equal(self):
a = self.seq_type([1,2,3])
# temporary refcount fix until I understand why it incs by one.
inline_tools.inline("a[1] = 1234;",['a'])
@@ -348,7 +361,8 @@
after1 = sys.getrefcount(a)
assert after1 == before1
- def test_set_item_operator_equal_created(self,level=5):
+ @dec.slow
+ def test_set_item_operator_equal_created(self):
code = """
py::list a(3);
a[0] = 1;
@@ -360,7 +374,8 @@
assert a == [1,2,3]
# returned value should only have a single refcount
assert sys.getrefcount(a) == 2
- def test_set_item_index_error(self,level=5):
+ @dec.slow
+ def test_set_item_index_error(self):
code = """
py::list a(3);
a[4] = 1;
@@ -370,7 +385,8 @@
assert 0
except IndexError:
pass
- def test_get_item_index_error(self,level=5):
+ @dec.slow
+ def test_get_item_index_error(self):
code = """
py::list a(3);
py::object o = a[4];
@@ -381,7 +397,8 @@
except IndexError:
pass
- def test_string_add_speed(self,level=5):
+ @dec.slow
+ def test_string_add_speed(self):
N = 1000000
print 'string add -- b[i] = a[i] + "blah" for N =', N
a = ["blah"] * N
@@ -407,7 +424,8 @@
t2 = time.time()
print 'weave:', t2 - t1
assert b == desired
- def test_int_add_speed(self,level=5):
+ @dec.slow
+ def test_int_add_speed(self):
N = 1000000
print 'int add -- b[i] = a[i] + 1 for N =', N
a = [0] * N
Modified: branches/testing_cleanup/scipy/weave/tests/test_size_check.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_size_check.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_size_check.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -13,7 +13,7 @@
class TestMakeSameLength(TestCase):
- def generic_test(self,x,y,desired):
+ def generic_check(self,x,y,desired):
actual = size_check.make_same_length(x,y)
desired = desired
assert_array_equal(actual,desired)
@@ -21,30 +21,30 @@
def test_scalar(self):
x,y = (),()
desired = empty,empty
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_scalar(self):
x,y = (),(1,2)
desired = array((1,1)),array((1,2))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_y_scalar(self):
x,y = (1,2),()
desired = array((1,2)),array((1,1))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_short(self):
x,y = (1,2),(1,2,3)
desired = array((1,1,2)),array((1,2,3))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_y_short(self):
x,y = (1,2,3),(1,2)
desired = array((1,2,3)),array((1,1,2))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
class TestBinaryOpSize(TestCase):
- def generic_test(self,x,y,desired):
+ def generic_check(self,x,y,desired):
actual = size_check.binary_op_size(x,y)
desired = desired
assert_array_equal(actual,desired)
- def generic_error_test(self,x,y):
+ def generic_error_check(self,x,y):
self.failUnlessRaises(ValueError, size_check.binary_op_size, x, y)
def desired_type(self,val):
@@ -52,54 +52,54 @@
def test_scalar(self):
x,y = (),()
desired = self.desired_type(())
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x1(self):
x,y = (1,),()
desired = self.desired_type((1,))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_y1(self):
x,y = (),(1,)
desired = self.desired_type((1,))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y(self):
x,y = (5,),(5,)
desired = self.desired_type((5,))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y2(self):
x,y = (5,10),(5,10)
desired = self.desired_type((5,10))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y3(self):
x,y = (5,10),(1,10)
desired = self.desired_type((5,10))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y4(self):
x,y = (1,10),(5,10)
desired = self.desired_type((5,10))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y5(self):
x,y = (5,1),(1,10)
desired = self.desired_type((5,10))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y6(self):
x,y = (1,10),(5,1)
desired = self.desired_type((5,10))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_x_y7(self):
x,y = (5,4,3,2,1),(3,2,1)
desired = self.desired_type((5,4,3,2,1))
- self.generic_test(x,y,desired)
+ self.generic_check(x,y,desired)
def test_error1(self):
x,y = (5,),(4,)
- self.generic_error_test(x,y)
+ self.generic_error_check(x,y)
def test_error2(self):
x,y = (5,5),(4,5)
- self.generic_error_test(x,y)
+ self.generic_error_check(x,y)
class TestDummyArray(TestBinaryOpSize):
- def generic_test(self,x,y,desired):
+ def generic_check(self,x,y,desired):
if type(x) is type(()):
x = ones(x)
if type(y) is type(()):
@@ -116,7 +116,7 @@
return size_check.dummy_array(array(val),1)
class TestDummyArrayIndexing(TestCase):
- def generic_test(self,ary,expr,desired):
+ def generic_check(self,ary,expr,desired):
a = size_check.dummy_array(ary)
actual = eval(expr).shape
#print desired, actual
@@ -124,7 +124,7 @@
def generic_wrap(self,a,expr):
desired = array(eval(expr).shape)
try:
- self.generic_test(a,expr,desired)
+ self.generic_check(a,expr,desired)
except IndexError:
if 0 not in desired:
msg = '%s raised IndexError in dummy_array, but forms\n' \
@@ -144,7 +144,7 @@
a = arange(10)
#print expr ,eval(expr)
desired = array(())
- self.generic_test(a,expr,desired)
+ self.generic_check(a,expr,desired)
def test_1d_index_0(self):
self.generic_1d_index('a[0]')
def test_1d_index_1(self):
@@ -302,7 +302,7 @@
pass
class TestExpressions(TestCase):
- def generic_test(self,expr,desired,**kw):
+ def generic_check(self,expr,desired,**kw):
import parser
ast_list = parser.expr(expr).tolist()
args = harvest_variables(ast_list)
@@ -331,7 +331,7 @@
desired = zeros(())
except:
desired = 'failed'
- self.generic_test(expr,desired,**kw)
+ self.generic_check(expr,desired,**kw)
def test_generic_1d(self):
a = arange(10)
expr = 'a[:]'
Modified: branches/testing_cleanup/scipy/weave/tests/test_slice_handler.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_slice_handler.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_slice_handler.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -23,7 +23,7 @@
raise AssertionError, msg.getvalue()
class TestBuildSliceAtom(TestCase):
- def generic_test(self,slice_vars,desired):
+ def generic_check(self,slice_vars,desired):
pos = slice_vars['pos']
ast_list = slice_handler.build_slice_atom(slice_vars,pos)
actual = ast_to_string(ast_list)
@@ -32,11 +32,11 @@
slice_vars = {'begin':'1', 'end':'2', 'step':'_stp',
'single_index':'_index','pos':0}
desired = 'slice(1,2-1)'
- self.generic_test(slice_vars,desired)
+ self.generic_check(slice_vars,desired)
class TestSlice(TestCase):
- def generic_test(self,suite_string,desired):
+ def generic_check(self,suite_string,desired):
import parser
ast_tuple = parser.suite(suite_string).totuple()
found, data = find_first_pattern(ast_tuple,indexed_array_pattern)
@@ -49,84 +49,84 @@
test ="a[:]"
desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_begin_2_slice(self):
"""match slice from a[1:]"""
test ="a[1:]"
desired = {'begin':'1', 'end':'_end', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_end_2_slice(self):
"""match slice from a[:2]"""
test ="a[:2]"
desired = {'begin':'_beg', 'end':'2', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_begin_end_2_slice(self):
"""match slice from a[1:2]"""
test ="a[1:2]"
desired = {'begin':'1', 'end':'2', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_empty_3_slice(self):
"""match slice from a[::]"""
test ="a[::]"
desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_begin_3_slice(self):
"""match slice from a[1::]"""
test ="a[1::]"
desired = {'begin':'1', 'end':'_end', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_end_3_slice(self):
"""match slice from a[:2:]"""
test ="a[:2:]"
desired = {'begin':'_beg', 'end':'2', 'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_stp3_slice(self):
"""match slice from a[::3]"""
test ="a[::3]"
desired = {'begin':'_beg', 'end':'_end', 'step':'3',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_begin_end_3_slice(self):
"""match slice from a[1:2:]"""
test ="a[1:2:]"
desired = {'begin':'1', 'end':'2','step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_begin_step_3_slice(self):
"""match slice from a[1::3]"""
test ="a[1::3]"
desired = {'begin':'1', 'end':'_end','step':'3',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_end_step_3_slice(self):
"""match slice from a[:2:3]"""
test ="a[:2:3]"
desired = {'begin':'_beg', 'end':'2', 'step':'3',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_begin_end_stp3_slice(self):
"""match slice from a[1:2:3]"""
test ="a[1:2:3]"
desired = {'begin':'1', 'end':'2', 'step':'3','single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_expr_3_slice(self):
"""match slice from a[:1+i+2:]"""
test ="a[:1+i+2:]"
desired = {'begin':'_beg', 'end':"1+i+2",'step':'_stp',
'single_index':'_index'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_single_index(self):
"""match slice from a[0]"""
test ="a[0]"
desired = {'begin':'_beg', 'end':"_end",'step':'_stp',
'single_index':'0'}
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def replace_whitespace(in_str):
out = in_str.replace(" ","")
@@ -135,7 +135,7 @@
return out
class TestTransformSlices(TestCase):
- def generic_test(self,suite_string,desired):
+ def generic_check(self,suite_string,desired):
import parser
ast_list = parser.suite(suite_string).tolist()
slice_handler.transform_slices(ast_list)
@@ -150,7 +150,7 @@
"""transform a[:] to slice notation"""
test ="a[:]"
desired = 'a[slice(_beg,_end,_stp)]'
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
def test_simple_expr(self):
"""transform a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])"""
test ="a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])"
@@ -158,7 +158,7 @@
" b[slice(_beg,_end), slice(1,1+2-1,3)] *"\
" (c[slice(1-2+i,_end), slice(_beg,_end)] -"\
" c[slice(_beg,_end), slice(_beg,_end)])"
- self.generic_test(test,desired)
+ self.generic_check(test,desired)
if __name__ == "__main__":
Modified: branches/testing_cleanup/scipy/weave/tests/test_wx_spec.py
===================================================================
--- branches/testing_cleanup/scipy/weave/tests/test_wx_spec.py 2008-01-08 20:14:01 UTC (rev 3802)
+++ branches/testing_cleanup/scipy/weave/tests/test_wx_spec.py 2008-01-08 22:52:05 UTC (rev 3803)
@@ -10,7 +10,7 @@
from scipy.testing import *
-from weave import ext_tools, wx_spec
+from scipy.weave import ext_tools, wx_spec
import wx
@@ -20,26 +20,33 @@
self.app = wx.App()
self.s = wx_spec.wx_converter()
- def test_type_match_string(self,level=5):
+ @dec.slow
+ def test_type_match_string(self):
assert(not self.s.type_match('string') )
- def test_type_match_int(self,level=5):
+ @dec.slow
+ def test_type_match_int(self):
assert(not self.s.type_match(5))
- def test_type_match_float(self,level=5):
+ @dec.slow
+ def test_type_match_float(self):
assert(not self.s.type_match(5.))
- def test_type_match_complex(self,level=5):
+ @dec.slow
+ def test_type_match_complex(self):
assert(not self.s.type_match(5.+1j))
- def test_type_match_complex(self,level=5):
+ @dec.slow
+ def test_type_match_complex(self):
assert(not self.s.type_match(5.+1j))
- def test_type_match_wxframe(self,level=5):
+ @dec.slow
+ def test_type_match_wxframe(self):
f=wx.Frame(None,-1,'bob')
assert(self.s.type_match(f))
- def test_var_in(self,level=5):
+ @dec.slow
+ def test_var_in(self):
mod = ext_tools.ext_module('wx_var_in',compiler='')
mod.customize.add_header('<wx/string.h>')
mod.customize.add_extra_compile_arg(' '.join(self.s.extra_compile_args))
@@ -69,7 +76,8 @@
except AttributeError:
pass
- def no_check_var_local(self,level=5):
+ @dec.slow
+ def no_check_var_local(self):
mod = ext_tools.ext_module('wx_var_local')
a = 'string'
code = 'a="hello";'
@@ -83,7 +91,8 @@
wx_var_local.test(b,q)
assert('a' == 'string')
- def no_test_no_check_return(self,level=5):
+ @dec.slow
+ def no_test_no_check_return(self):
mod = ext_tools.ext_module('wx_return')
a = 'string'
code = """
@@ -99,7 +108,4 @@
assert(c == 'hello')
if __name__ == "__main__":
- import sys
- if len(sys.argv) == 1:
- sys.argv.extend(["--level=5"])
- NumpyTest().test(10,10)
+ unittest.main()
More information about the Scipy-svn
mailing list