summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2006-04-26 20:33:14 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2006-04-26 20:33:14 +0000
commit7413032ea6011c74524aa5ecc384b2ae4964d6e9 (patch)
treeada306e2e863eff280421dc6a6f92c0daa7728cc
parentb01cd88166e84fd8510ad74c231a5aaf0ae4879d (diff)
downloadnumpy-7413032ea6011c74524aa5ecc384b2ae4964d6e9.tar.gz
Apply replace ScipyTestCase->NumpyTestCase. Fix tests for testoob.
-rw-r--r--numpy/core/tests/test_numerictypes.py31
-rw-r--r--numpy/core/tests/test_records.py5
-rw-r--r--numpy/core/tests/test_unicode.py52
-rw-r--r--numpy/doc/DISTUTILS.txt25
4 files changed, 58 insertions, 55 deletions
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py
index 9ad119785..0baab2c82 100644
--- a/numpy/core/tests/test_numerictypes.py
+++ b/numpy/core/tests/test_numerictypes.py
@@ -99,7 +99,7 @@ def normalize_descr(descr):
# Creation tests
############################################################
-class create_zeros(ScipyTestCase):
+class create_zeros:
"""Check the creation of heterogeneous arrays zero-valued"""
def check_zeros0D(self):
@@ -133,19 +133,18 @@ class create_zeros(ScipyTestCase):
assert_equal(h['z'], zeros((2,3), dtype='u1'))
-class test_create_zeros_plain(create_zeros):
+class test_create_zeros_plain(create_zeros, NumpyTestCase):
"""Check the creation of heterogeneous arrays zero-valued (plain)"""
_descr = Pdescr
-class test_create_zeros_nested(create_zeros):
+class test_create_zeros_nested(create_zeros, NumpyTestCase):
"""Check the creation of heterogeneous arrays zero-valued (nested)"""
_descr = Ndescr
-class create_values(ScipyTestCase):
+class create_values:
"""Check the creation of heterogeneous arrays with values"""
-
def check_tuple(self):
"""Check creation from tuples"""
h = array(self._buffer, dtype=self._descr)
@@ -174,25 +173,25 @@ class create_values(ScipyTestCase):
self.assert_(h.shape == (1,1))
-class test_create_values_plain_single(create_values):
+class test_create_values_plain_single(create_values, NumpyTestCase):
"""Check the creation of heterogeneous arrays (plain, single row)"""
_descr = Pdescr
multiple_rows = 0
_buffer = PbufferT[0]
-class test_create_values_plain_multiple(create_values):
+class test_create_values_plain_multiple(create_values, NumpyTestCase):
"""Check the creation of heterogeneous arrays (plain, multiple rows)"""
_descr = Pdescr
multiple_rows = 1
_buffer = PbufferT
-class test_create_values_nested_single(create_values):
+class test_create_values_nested_single(create_values, NumpyTestCase):
"""Check the creation of heterogeneous arrays (nested, single row)"""
_descr = Ndescr
multiple_rows = 0
_buffer = NbufferT[0]
-class test_create_values_nested_multiple(create_values):
+class test_create_values_nested_multiple(create_values, NumpyTestCase):
"""Check the creation of heterogeneous arrays (nested, multiple rows)"""
_descr = Ndescr
multiple_rows = 1
@@ -203,7 +202,7 @@ class test_create_values_nested_multiple(create_values):
# Reading tests
############################################################
-class read_values_plain(ScipyTestCase):
+class read_values_plain:
"""Check the reading of values in heterogeneous arrays (plain)"""
def check_access_fields(self):
@@ -223,19 +222,19 @@ class read_values_plain(ScipyTestCase):
self._buffer[1][2]], dtype='u1'))
-class test_read_values_plain_single(read_values_plain):
+class test_read_values_plain_single(read_values_plain, NumpyTestCase):
"""Check the creation of heterogeneous arrays (plain, single row)"""
_descr = Pdescr
multiple_rows = 0
_buffer = PbufferT[0]
-class test_read_values_plain_multiple(read_values_plain):
+class test_read_values_plain_multiple(read_values_plain, NumpyTestCase):
"""Check the values of heterogeneous arrays (plain, multiple rows)"""
_descr = Pdescr
multiple_rows = 1
_buffer = PbufferT
-class read_values_nested(ScipyTestCase):
+class read_values_nested:
"""Check the reading of values in heterogeneous arrays (nested)"""
@@ -320,13 +319,13 @@ class read_values_nested(ScipyTestCase):
self.assert_(h.dtype['Info']['Info2']['z3'].name == 'void64')
-class test_read_values_nested_single(read_values_nested):
+class test_read_values_nested_single(read_values_nested, NumpyTestCase):
"""Check the values of heterogeneous arrays (nested, single row)"""
_descr = Ndescr
multiple_rows = 0
_buffer = NbufferT[0]
-class test_read_values_nested_multiple(read_values_nested):
+class test_read_values_nested_multiple(read_values_nested, NumpyTestCase):
"""Check the values of heterogeneous arrays (nested, multiple rows)"""
_descr = Ndescr
multiple_rows = 1
@@ -334,4 +333,4 @@ class test_read_values_nested_multiple(read_values_nested):
if __name__ == "__main__":
- ScipyTest().run()
+ NumpyTest().run()
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
index 386734cab..bf43bc1c0 100644
--- a/numpy/core/tests/test_records.py
+++ b/numpy/core/tests/test_records.py
@@ -6,7 +6,7 @@ import numpy.core;reload(numpy.core)
from numpy.core import *
restore_path()
-class test_fromrecords(ScipyTestCase):
+class test_fromrecords(NumpyTestCase):
def check_fromrecords(self):
r = rec.fromrecords([[456,'dbe',1.2],[2,'de',1.3]],names='col1,col2,col3')
assert_equal(r[0].item(),(456, 'dbe', 1.2))
@@ -34,10 +34,11 @@ class test_fromrecords(ScipyTestCase):
def check_recarray_fromfile(self):
__path__ = _os.path.split(__file__)
+ print __file__
filename = _os.path.join(__path__[0], "testdata.fits")
fd = open(filename)
fd.seek(2880*2)
r = rec.fromfile(fd, formats='f8,i4,a5', shape=3, byteorder='big')
if __name__ == "__main__":
- ScipyTest().run()
+ NumpyTest().run()
diff --git a/numpy/core/tests/test_unicode.py b/numpy/core/tests/test_unicode.py
index 642019352..5072df268 100644
--- a/numpy/core/tests/test_unicode.py
+++ b/numpy/core/tests/test_unicode.py
@@ -18,7 +18,7 @@ ucs4_value = u'\U0010FFFF'
# Creation tests
############################################################
-class create_zeros(ScipyTestCase):
+class create_zeros:
"""Check the creation of zero-valued arrays"""
def content_test(self, ua, ua_scalar, nbytes):
@@ -55,20 +55,20 @@ class create_zeros(ScipyTestCase):
self.content_test(ua, ua[-1,-1,-1], 4*self.ulen*2*3*4)
-class test_create_zeros_1(create_zeros):
+class test_create_zeros_1(create_zeros, NumpyTestCase):
"""Check the creation of zero-valued arrays (size 1)"""
ulen = 1
-class test_create_zeros_2(create_zeros):
+class test_create_zeros_2(create_zeros, NumpyTestCase):
"""Check the creation of zero-valued arrays (size 2)"""
ulen = 2
-class test_create_zeros_1009(create_zeros):
+class test_create_zeros_1009(create_zeros, NumpyTestCase):
"""Check the creation of zero-valued arrays (size 1009)"""
ulen = 1009
-class create_values(ScipyTestCase):
+class create_values:
"""Check the creation of unicode arrays with values"""
def content_test(self, ua, ua_scalar, nbytes):
@@ -113,32 +113,32 @@ class create_values(ScipyTestCase):
self.content_test(ua, ua[-1,-1,-1], 4*self.ulen*2*3*4)
-class test_create_values_1_ucs2(create_values):
+class test_create_values_1_ucs2(create_values, NumpyTestCase):
"""Check the creation of valued arrays (size 1, UCS2 values)"""
ulen = 1
ucs_value = ucs2_value
-class test_create_values_1_ucs4(create_values):
+class test_create_values_1_ucs4(create_values, NumpyTestCase):
"""Check the creation of valued arrays (size 1, UCS4 values)"""
ulen = 1
ucs_value = ucs4_value
-class test_create_values_2_ucs2(create_values):
+class test_create_values_2_ucs2(create_values, NumpyTestCase):
"""Check the creation of valued arrays (size 2, UCS2 values)"""
ulen = 2
ucs_value = ucs2_value
-class test_create_values_2_ucs4(create_values):
+class test_create_values_2_ucs4(create_values, NumpyTestCase):
"""Check the creation of valued arrays (size 2, UCS4 values)"""
ulen = 2
ucs_value = ucs4_value
-class test_create_values_1009_ucs2(create_values):
+class test_create_values_1009_ucs2(create_values, NumpyTestCase):
"""Check the creation of valued arrays (size 1009, UCS2 values)"""
ulen = 1009
ucs_value = ucs2_value
-class test_create_values_1009_ucs4(create_values):
+class test_create_values_1009_ucs4(create_values, NumpyTestCase):
"""Check the creation of valued arrays (size 1009, UCS4 values)"""
ulen = 1009
ucs_value = ucs4_value
@@ -148,7 +148,7 @@ class test_create_values_1009_ucs4(create_values):
# Assignment tests
############################################################
-class assign_values(ScipyTestCase):
+class assign_values:
"""Check the assignment of unicode arrays with values"""
def content_test(self, ua, ua_scalar, nbytes):
@@ -198,32 +198,32 @@ class assign_values(ScipyTestCase):
self.content_test(ua, ua[-1,-1,-1], 4*self.ulen*2*3*4)
-class test_assign_values_1_ucs2(assign_values):
+class test_assign_values_1_ucs2(assign_values, NumpyTestCase):
"""Check the assignment of valued arrays (size 1, UCS2 values)"""
ulen = 1
ucs_value = ucs2_value
-class test_assign_values_1_ucs4(assign_values):
+class test_assign_values_1_ucs4(assign_values, NumpyTestCase):
"""Check the assignment of valued arrays (size 1, UCS4 values)"""
ulen = 1
ucs_value = ucs4_value
-class test_assign_values_2_ucs2(assign_values):
+class test_assign_values_2_ucs2(assign_values, NumpyTestCase):
"""Check the assignment of valued arrays (size 2, UCS2 values)"""
ulen = 2
ucs_value = ucs2_value
-class test_assign_values_2_ucs4(assign_values):
+class test_assign_values_2_ucs4(assign_values, NumpyTestCase):
"""Check the assignment of valued arrays (size 2, UCS4 values)"""
ulen = 2
ucs_value = ucs4_value
-class test_assign_values_1009_ucs2(assign_values):
+class test_assign_values_1009_ucs2(assign_values, NumpyTestCase):
"""Check the assignment of valued arrays (size 1009, UCS2 values)"""
ulen = 1009
ucs_value = ucs2_value
-class test_assign_values_1009_ucs4(assign_values):
+class test_assign_values_1009_ucs4(assign_values, NumpyTestCase):
"""Check the assignment of valued arrays (size 1009, UCS4 values)"""
ulen = 1009
ucs_value = ucs4_value
@@ -233,7 +233,7 @@ class test_assign_values_1009_ucs4(assign_values):
# Byteorder tests
############################################################
-class byteorder_values(ScipyTestCase):
+class byteorder_values:
"""Check the byteorder of unicode arrays in round-trip conversions"""
def check_values0D(self):
@@ -270,36 +270,36 @@ class byteorder_values(ScipyTestCase):
# Arrays must be equal after the round-trip
assert_equal(ua, ua3)
-class test_byteorder_1_ucs2(byteorder_values):
+class test_byteorder_1_ucs2(byteorder_values, NumpyTestCase):
"""Check the byteorder in unicode (size 1, UCS2 values)"""
ulen = 1
ucs_value = ucs2_value
-class test_byteorder_1_ucs4(byteorder_values):
+class test_byteorder_1_ucs4(byteorder_values, NumpyTestCase):
"""Check the byteorder in unicode (size 1, UCS4 values)"""
ulen = 1
ucs_value = ucs4_value
-class test_byteorder_2_ucs2(byteorder_values):
+class test_byteorder_2_ucs2(byteorder_values, NumpyTestCase):
"""Check the byteorder in unicode (size 2, UCS2 values)"""
ulen = 2
ucs_value = ucs2_value
-class test_byteorder_2_ucs4(byteorder_values):
+class test_byteorder_2_ucs4(byteorder_values, NumpyTestCase):
"""Check the byteorder in unicode (size 2, UCS4 values)"""
ulen = 2
ucs_value = ucs4_value
-class test_byteorder_1009_ucs2(byteorder_values):
+class test_byteorder_1009_ucs2(byteorder_values, NumpyTestCase):
"""Check the byteorder in unicode (size 1009, UCS2 values)"""
ulen = 1009
ucs_value = ucs2_value
-class test_byteorder_1009_ucs4(byteorder_values):
+class test_byteorder_1009_ucs4(byteorder_values, NumpyTestCase):
"""Check the byteorder in unicode (size 1009, UCS4 values)"""
ulen = 1009
ucs_value = ucs4_value
if __name__ == "__main__":
- ScipyTest().run()
+ NumpyTest().run()
diff --git a/numpy/doc/DISTUTILS.txt b/numpy/doc/DISTUTILS.txt
index de2c0b28e..eab331af8 100644
--- a/numpy/doc/DISTUTILS.txt
+++ b/numpy/doc/DISTUTILS.txt
@@ -459,8 +459,8 @@ So, the header a typical ``__init__.py`` file is::
from info import __doc__
...
- from numpy.testing import ScipyTest
- test = ScipyTest().test
+ from numpy.testing import NumpyTest
+ test = NumpyTest().test
The ``tests/`` directory
''''''''''''''''''''''''
@@ -468,7 +468,7 @@ The ``tests/`` directory
Ideally, every Python code, extension module, or subpackage in Scipy
package directory should have the corresponding ``test_<name>.py``
file in ``tests/`` directory. This file should define classes
-derived from ``ScipyTestCase`` (or from ``unittest.TestCase``) class
+derived from ``NumpyTestCase`` (or from ``unittest.TestCase``) class
and have names starting with ``test``. The methods of these classes
which names start with ``bench``, ``check``, or ``test``, are passed
on to unittest machinery. In addition, the value of the first optional
@@ -492,18 +492,21 @@ a Scipy package module ``numpy.xxx.yyy`` containing a function
# import modules that are located in the same directory as this file.
restore_path()
- class test_zzz(ScipyTestCase):
+ class test_zzz(NumpyTestCase):
def check_simple(self, level=1):
assert zzz()=='Hello from zzz'
#...
if __name__ == "__main__":
- ScipyTest().run()
+ NumpyTest().run()
-``ScipyTestCase`` is derived from ``unittest.TestCase`` and it
+``NumpyTestCase`` is derived from ``unittest.TestCase`` and it
basically only implements an additional method ``measure(self,
code_str, times=1)``.
+Note that all classes that are inherited from ``TestCase`` class, are
+picked up by the test runner when using ``testoob``.
+
``numpy.testing`` module provides also the following convenience
functions::
@@ -514,21 +517,21 @@ functions::
assert_array_almost_equal(x,y,decimal=6,err_msg='')
rand(*shape) # returns random array with a given shape
-``ScipyTest`` can be used for running ``tests/test_*.py`` scripts.
+``NumpyTest`` can be used for running ``tests/test_*.py`` scripts.
For instance, to run all test scripts of the module ``xxx``, execute
in Python:
- >>> ScipyTest('xxx').test(level=1,verbosity=1)
+ >>> NumpyTest('xxx').test(level=1,verbosity=1)
or equivalently,
>>> import xxx
- >>> ScipyTest(xxx).test(level=1,verbosity=1)
+ >>> NumpyTest(xxx).test(level=1,verbosity=1)
To run only tests for ``xxx.yyy`` module, execute:
- >>> ScipyTest('xxx.yyy').test(level=1,verbosity=1)
+ >>> NumpyTest('xxx.yyy').test(level=1,verbosity=1)
To take the level and verbosity parameters for tests from
-``sys.argv``, use ``ScipyTest.run()`` method (this is supported only
+``sys.argv``, use ``NumpyTest.run()`` method (this is supported only
when ``optparse`` is installed).