Author: bugman Date: Sat Jan 5 20:19:57 2008 New Revision: 4362 URL: http://svn.gna.org/viewcvs/relax?rev=4362&view=rev Log: Converted all of the diffusion tensor system/functional tests to the new unittest framework. Modified: 1.3/test_suite/system_tests/__init__.py 1.3/test_suite/system_tests/diffusion_tensor.py 1.3/test_suite/system_tests/main.py Modified: 1.3/test_suite/system_tests/__init__.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/__init__.py?rev=4362&r1=4361&r2=4362&view=diff ============================================================================== --- 1.3/test_suite/system_tests/__init__.py (original) +++ 1.3/test_suite/system_tests/__init__.py Sat Jan 5 20:19:57 2008 @@ -29,6 +29,7 @@ # relax system/functional test module imports. from test_pipe_create import Test_pipe_create from model_free import Mf +from diffusion_tensor import Diffusion_tensor __all__ = ['angles', @@ -64,6 +65,7 @@ suite_array = [] suite_array.append(TestLoader().loadTestsFromTestCase(Test_pipe_create)) suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) + suite_array.append(TestLoader().loadTestsFromTestCase(Diffusion_tensor)) # Add the relax namespace to each TestCase object. for i in xrange(len(suite_array)): Modified: 1.3/test_suite/system_tests/diffusion_tensor.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/diffusion_tensor.py?rev=4362&r1=4361&r2=4362&view=diff ============================================================================== --- 1.3/test_suite/system_tests/diffusion_tensor.py (original) +++ 1.3/test_suite/system_tests/diffusion_tensor.py Sat Jan 5 20:19:57 2008 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2006-2007 Edward d'Auvergne # +# Copyright (C) 2006-2008 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -20,104 +20,18 @@ # # ############################################################################### -import sys +# Python module imports. +from unittest import TestCase + +# relax module imports. +from data import Data as relax_data_store -class Diffusion_tensor: - def __init__(self, relax, test_name): - """Class for testing various aspects specific to the diffusion tensor.""" +class Diffusion_tensor(TestCase): + """Class for testing various aspects specific to the diffusion tensor.""" - self.relax = relax - - # Initialisation test. - if test_name == 'init': - self.name = "The user function diffusion_tensor.init()" - self.test = self.init - - # Deletion test. - if test_name == 'delete': - self.name = "The user function diffusion_tensor.delete()" - self.test = self.delete - - # Display test. - if test_name == 'display': - self.name = "The user function diffusion_tensor.display()" - self.test = self.display - - # Copy test. - if test_name == 'copy': - self.name = "The user function diffusion_tensor.copy()" - self.test = self.copy - - - def copy(self, pipe): - """The copy test.""" - - # Initialise. - self.initialise_tensors() - - # Create three additional data pipes for copying the spherical, spheroidal, and ellipsoidal diffusion data. - self.relax.interpreter._Pipe.create('sphere2', 'mf') - self.relax.interpreter._Pipe.create('spheroid2', 'mf') - self.relax.interpreter._Pipe.create('ellipsoid2', 'mf') - - # Delete the data. - self.relax.interpreter._Diffusion_tensor.copy('sphere', 'sphere2') - self.relax.interpreter._Diffusion_tensor.copy('spheroid', 'spheroid2') - self.relax.interpreter._Diffusion_tensor.copy('ellipsoid', 'ellipsoid2') - - # Success. - return 1 - - - def delete(self, pipe): - """The deletion test.""" - - # Initialise. - self.initialise_tensors() - - # Delete the data. - self.relax.interpreter._Pipe.switch('sphere') - self.relax.interpreter._Diffusion_tensor.delete() - self.relax.interpreter._Pipe.switch('spheroid') - self.relax.interpreter._Diffusion_tensor.delete() - self.relax.interpreter._Pipe.switch('ellipsoid') - self.relax.interpreter._Diffusion_tensor.delete() - - # Success. - return 1 - - - def display(self, pipe): - """The display test.""" - - # Initialise some tensors. - self.initialise_tensors() - - # Display the data. - self.relax.interpreter._Pipe.switch('sphere') - self.relax.interpreter._Diffusion_tensor.display() - self.relax.interpreter._Pipe.switch('spheroid') - self.relax.interpreter._Diffusion_tensor.display() - self.relax.interpreter._Pipe.switch('ellipsoid') - self.relax.interpreter._Diffusion_tensor.display() - - # Success. - return 1 - - - def init(self, pipe): - """The initialisation test.""" - - # Initialise some tensors. - self.initialise_tensors() - - # Success. - return 1 - - - def initialise_tensors(self): - """Fucntion for initialising a spherical, spheroidal, and ellipsoidal diffusion tensor.""" + def setUp(self): + """Function for initialising a spherical, spheroidal, and ellipsoidal diffusion tensor.""" # Create three data pipes for spherical, spheroidal, and ellipsoidal diffusion. self.relax.interpreter._Pipe.create('sphere', 'mf') @@ -131,3 +45,47 @@ self.relax.interpreter._Diffusion_tensor.init((2e-8, 1.3, 60-360, 290), param_types=2, spheroid_type='prolate', fixed=1) self.relax.interpreter._Pipe.switch('ellipsoid') self.relax.interpreter._Diffusion_tensor.init((9e-8, 5e6, 0.3, 60+360, 290, 100), fixed=0) + + + def tearDown(self): + """Reset the relax data storage object.""" + + relax_data_store.__reset__() + + + def test_copy(self): + """The user function diffusion_tensor.copy().""" + + # Create three additional data pipes for copying the spherical, spheroidal, and ellipsoidal diffusion data. + self.relax.interpreter._Pipe.create('sphere2', 'mf') + self.relax.interpreter._Pipe.create('spheroid2', 'mf') + self.relax.interpreter._Pipe.create('ellipsoid2', 'mf') + + # Delete the data. + self.relax.interpreter._Diffusion_tensor.copy('sphere', 'sphere2') + self.relax.interpreter._Diffusion_tensor.copy('spheroid', 'spheroid2') + self.relax.interpreter._Diffusion_tensor.copy('ellipsoid', 'ellipsoid2') + + + def test_delete(self): + """The user function diffusion_tensor.delete().""" + + # Delete the data. + self.relax.interpreter._Pipe.switch('sphere') + self.relax.interpreter._Diffusion_tensor.delete() + self.relax.interpreter._Pipe.switch('spheroid') + self.relax.interpreter._Diffusion_tensor.delete() + self.relax.interpreter._Pipe.switch('ellipsoid') + self.relax.interpreter._Diffusion_tensor.delete() + + + def test_display(self): + """The user function diffusion_tensor.display().""" + + # Display the data. + self.relax.interpreter._Pipe.switch('sphere') + self.relax.interpreter._Diffusion_tensor.display() + self.relax.interpreter._Pipe.switch('spheroid') + self.relax.interpreter._Diffusion_tensor.display() + self.relax.interpreter._Pipe.switch('ellipsoid') + self.relax.interpreter._Diffusion_tensor.display() Modified: 1.3/test_suite/system_tests/main.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/main.py?rev=4362&r1=4361&r2=4362&view=diff ============================================================================== --- 1.3/test_suite/system_tests/main.py (original) +++ 1.3/test_suite/system_tests/main.py Sat Jan 5 20:19:57 2008 @@ -29,7 +29,6 @@ # Import the tests. from angles import Angles -from diffusion_tensor import Diffusion_tensor from generic import Generic from jw_mapping import Jw from model_selection import Modsel @@ -77,25 +76,6 @@ # Execute the tests. self.exec_tests(self.seq_test_array) - - - # Diffusion tensor tests. - ######################### - - # Heading. - heading("The diffusion tensor tests") - - # Initialise the array containing each test element. - self.diff_tensor_test_array = [] - - # User function tests. - self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'init')) - self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'delete')) - self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'display')) - self.diff_tensor_test_array.append(Diffusion_tensor(self.relax, 'copy')) - - # Execute the tests. - self.exec_tests(self.diff_tensor_test_array) # Angle calculation tests. @@ -249,21 +229,6 @@ summary_line(test.name, test.passed) - # Diffusion tensor tests. - ######################### - - # Heading. - sys.stdout.write("\nThe diffusion tensor tests:\n") - - # Loop over the tests. - for test in self.diff_tensor_test_array: - # Synopsis. - global_pass = global_pass and test.passed - - # Print the summary line. - summary_line(test.name, test.passed) - - # Angle calculation tests. ##########################