[Scipy-svn] r3408 - trunk/scipy/io/nifti/tests

scipy-svn@scip... scipy-svn@scip...
Thu Oct 4 02:33:34 CDT 2007


Author: jarrod.millman
Date: 2007-10-04 02:33:32 -0500 (Thu, 04 Oct 2007)
New Revision: 3408

Added:
   trunk/scipy/io/nifti/tests/test_nifti.py
Removed:
   trunk/scipy/io/nifti/tests/test_fileio.py
   trunk/scipy/io/nifti/tests/test_main.py
   trunk/scipy/io/nifti/tests/test_utils.py
Log:
starting to integrate tests with NumpyTest


Deleted: trunk/scipy/io/nifti/tests/test_fileio.py
===================================================================
--- trunk/scipy/io/nifti/tests/test_fileio.py	2007-10-04 07:29:13 UTC (rev 3407)
+++ trunk/scipy/io/nifti/tests/test_fileio.py	2007-10-04 07:33:32 UTC (rev 3408)
@@ -1,81 +0,0 @@
-### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-#
-#    Unit tests for PyNIfTI file io
-#
-#    Copyright (C) 2007 by
-#    Michael Hanke <michael.hanke@gmail.com>
-#
-#    This is free software; you can redistribute it and/or
-#    modify it under the terms of the MIT License.
-#
-#    This package is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the COPYING
-#    file that comes with this package for more details.
-#
-### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-
-import unittest
-import md5
-import tempfile
-import shutil
-import os
-import numpy as np
-import scipy.io.nifti
-
-
-def md5sum(filename):
-    """ Generate MD5 hash string.
-    """
-    file = open( filename )
-    sum = md5.new()
-    while True:
-        data = file.read()
-        if not data:
-            break
-        sum.update(data)
-    return sum.hexdigest()
-
-
-class FileIOTests(unittest.TestCase):
-    def setUp(self):
-        self.workdir = tempfile.mkdtemp('pynifti_test')
-
-    def tearDown(self):
-        shutil.rmtree(self.workdir)
-
-    def testIdempotentLoadSaveCycle(self):
-        """ check if file is unchanged by load/save cycle.
-        """
-        md5_orig = md5sum('data/example4d.nii.gz')
-        nimg = nifti.NiftiImage('data/example4d.nii.gz')
-        nimg.save( os.path.join( self.workdir, 'iotest.nii.gz') )
-        md5_io =  md5sum( os.path.join( self.workdir, 'iotest.nii.gz') )
-
-        self.failUnlessEqual(md5_orig, md5_io)
-
-    def testQFormSetting(self):
-        nimg = nifti.NiftiImage('data/example4d.nii.gz')
-        # 4x4 identity matrix
-        ident = np.identity(4)
-        self.failIf( (nimg.qform == ident).all() )
-
-        # assign new qform
-        nimg.qform = ident
-        self.failUnless( (nimg.qform == ident).all() )
-
-        # test save/load cycle
-        nimg.save( os.path.join( self.workdir, 'qformtest.nii.gz') )
-        nimg2 = nifti.NiftiImage( os.path.join( self.workdir, 
-                                               'qformtest.nii.gz') )
-
-        self.failUnless( (nimg.qform == nimg2.qform).all() )
-
-
-def suite():
-    return unittest.makeSuite(FileIOTests)
-
-
-if __name__ == '__main__':
-    unittest.main()
-

Deleted: trunk/scipy/io/nifti/tests/test_main.py
===================================================================
--- trunk/scipy/io/nifti/tests/test_main.py	2007-10-04 07:29:13 UTC (rev 3407)
+++ trunk/scipy/io/nifti/tests/test_main.py	2007-10-04 07:33:32 UTC (rev 3408)
@@ -1,42 +0,0 @@
-### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-#
-#    Main unit test interface for PyNIfTI
-#
-#    Copyright (C) 2007 by
-#    Michael Hanke <michael.hanke@gmail.com>
-#
-#    This is free software; you can redistribute it and/or
-#    modify it under the terms of the MIT License.
-#
-#    This package is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the COPYING
-#    file that comes with this package for more details.
-#
-### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-
-import unittest
-
-# list all test modules (without .py extension)
-tests = [ 'test_fileio',
-          'test_utils',
-        ]
-
-
-# import all test modules
-for t in tests:
-    exec 'import ' + t
-
-
-if __name__ == '__main__':
-
-    # load all tests suites
-    suites = [ eval(t + '.suite()') for t in tests ]
-
-    # and make global test suite
-    ts = unittest.TestSuite( suites )
-
-    # finally run it
-    unittest.TextTestRunner().run( ts )
-
-

Copied: trunk/scipy/io/nifti/tests/test_nifti.py (from rev 3406, trunk/scipy/io/nifti/tests/test_fileio.py)

Deleted: trunk/scipy/io/nifti/tests/test_utils.py
===================================================================
--- trunk/scipy/io/nifti/tests/test_utils.py	2007-10-04 07:29:13 UTC (rev 3407)
+++ trunk/scipy/io/nifti/tests/test_utils.py	2007-10-04 07:33:32 UTC (rev 3408)
@@ -1,37 +0,0 @@
-### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-#
-#    Unit tests for PyNIfTI file io
-#
-#    Copyright (C) 2007 by
-#    Michael Hanke <michael.hanke@gmail.com>
-#
-#    This is free software; you can redistribute it and/or
-#    modify it under the terms of the MIT License.
-#
-#    This package is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the COPYING
-#    file that comes with this package for more details.
-#
-### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
-
-import scipy.io.nifti.utils
-import numpy
-import unittest
-
-
-class UtilsTests(unittest.TestCase):
-    def testZScoring(self):
-        # dataset: mean=2, std=1
-        data = numpy.array( (0,1,3,4,2,2,3,1,1,3,3,1,2,2,2,2) )
-        self.failUnlessEqual( data.mean(), 2.0 )
-        self.failUnlessEqual( data.std(), 1.0 )
-
-
-def suite():
-    return unittest.makeSuite(UtilsTests)
-
-
-if __name__ == '__main__':
-    unittest.main()
-



More information about the Scipy-svn mailing list