Author: bugman Date: Sat Jan 5 20:44:13 2008 New Revision: 4366 URL: http://svn.gna.org/viewcvs/relax?rev=4366&view=rev Log: Converted all of the relaxation curve fitting system/functional tests to the new unittest framework. Modified: 1.3/test_suite/system_tests/__init__.py 1.3/test_suite/system_tests/main.py 1.3/test_suite/system_tests/relax_fit.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=4366&r1=4365&r2=4366&view=diff ============================================================================== --- 1.3/test_suite/system_tests/__init__.py (original) +++ 1.3/test_suite/system_tests/__init__.py Sat Jan 5 20:44:13 2008 @@ -32,6 +32,7 @@ from generic import Generic from model_free import Mf from model_selection import Modsel +from relax_fit import Relax_fit from test_pipe_create import Test_pipe_create @@ -71,6 +72,7 @@ suite_array.append(TestLoader().loadTestsFromTestCase(Generic)) suite_array.append(TestLoader().loadTestsFromTestCase(Mf)) suite_array.append(TestLoader().loadTestsFromTestCase(Modsel)) + suite_array.append(TestLoader().loadTestsFromTestCase(Relax_fit)) suite_array.append(TestLoader().loadTestsFromTestCase(Test_pipe_create)) # Add the relax namespace to each TestCase object. 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=4366&r1=4365&r2=4366&view=diff ============================================================================== --- 1.3/test_suite/system_tests/main.py (original) +++ 1.3/test_suite/system_tests/main.py Sat Jan 5 20:44:13 2008 @@ -29,7 +29,6 @@ # Import the tests. from jw_mapping import Jw -from relax_fit import Relax_fit from sequence import Sequence @@ -73,22 +72,6 @@ # Execute the tests. self.exec_tests(self.seq_test_array) - - - # Relaxation curve-fitting tests. - ################################# - - # Heading. - heading("The relaxation curve-fitting tests") - - # Initialise the array containing each test element. - self.relax_fit_test_array = [] - - # Loading Sparky peak heights. - self.relax_fit_test_array.append(Relax_fit(self.relax, 'read_sparky')) - - # Execute the tests. - self.exec_tests(self.relax_fit_test_array) # Reduced spectral density mapping tests. @@ -178,21 +161,6 @@ summary_line(test.name, test.passed) - # Relaxation curve-fitting tests. - ################################# - - # Heading. - sys.stdout.write("\nThe relaxation curve-fitting tests:\n") - - # Loop over the tests. - for test in self.relax_fit_test_array: - # Synopsis. - global_pass = global_pass and test.passed - - # Print the summary line. - summary_line(test.name, test.passed) - - # Reduced spectral density Mapping tests. ######################################### Modified: 1.3/test_suite/system_tests/relax_fit.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/system_tests/relax_fit.py?rev=4366&r1=4365&r2=4366&view=diff ============================================================================== --- 1.3/test_suite/system_tests/relax_fit.py (original) +++ 1.3/test_suite/system_tests/relax_fit.py Sat Jan 5 20:44:13 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. # # # @@ -22,38 +22,33 @@ # Python module imports. import sys +from unittest import TestCase # relax module imports. from data import Data as relax_data_store -# The relax data storage object. +class Relax_fit(TestCase): + """Class for testing various aspects specific to relaxation curve-fitting.""" + + def setUp(self): + """Set up for all the functional tests.""" + + # Create the data pipe. + self.relax.interpreter._Pipe.create('mf', 'mf') + def tearDown(self): + """Reset the relax data storage object.""" -class Relax_fit: - def __init__(self, relax, test_name): - """Class for testing various aspects specific to relaxation curve-fitting.""" - - self.relax = relax - - # Sparky loading test. - if test_name == 'read_sparky': - # The name of the test. - self.name = "Loading of Sparky peak heights" - - # The test. - self.test = self.read_sparky + relax_data_store.__reset__() - def read_sparky(self, pipe): + def test_read_sparky(self): """The Sparky peak height loading test.""" # Load the original state. self.relax.interpreter._State.load(file='rx.save', dir=sys.path[-1] + '/test_suite/system_tests/data/curve_fitting') - - # Create the data pipe. - self.relax.interpreter._Pipe.create(pipe, 'mf') # Load the Lupin Ap4Aase sequence. self.relax.interpreter._Sequence.read(file="Ap4Aase.seq", dir=sys.path[-1] + "/test_suite/system_tests/data") @@ -65,44 +60,21 @@ # Test the integrity of the data. ################################# - # Print out. - print "\nTesting the integrity of the loaded data.\n" - # Loop over the residues of the original data. for i in xrange(len(relax_data_store['rx'].mol[0].res)): # Aliases orig_data = relax_data_store['rx'].mol[0].res[i] - new_data = relax_data_store[pipe].mol[0].res[i] - - # Residue alias. - self.orig_res = `orig_data.num` + orig_data.name - self.new_res = `new_data.num` + new_data.name + new_data = relax_data_store[relax_data_store.current_pipe].mol[0].res[i] # Residue numbers. - if orig_data.num != new_data.num: - self.print_error('residue numbers') - return + self.assertEqual(orig_data.num, new_data.num) # Residue names. - if orig_data.name != new_data.name: - self.print_error('residue names') - return + self.assertEqual(orig_data.name, new_data.name) # Skip unselected residues. if not orig_data.spin[0].select: continue # The intensity. - if orig_data.spin[0].intensities[0][0] != new_data.spin[0].intensities[0][0]: - self.print_error('intensities') - return - - # Success. - print "The data structures have been created successfully." - return 1 - - - def print_error(self, name): - """Function for printing a residue mismatch.""" - - print "The " + name + " of " + self.orig_res + " and " + self.new_res + " do not match." + self.assertEqual(orig_data.spin[0].intensities[0][0], new_data.spin[0].intensities[0][0])