mailRe: r22457 - /trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on March 12, 2014 - 12:28:
Hi Troels,

In this case, as you are testing a second functionality I would highly
recommend creating a second test by duplication.  Each unit test
should test one idea only.  As the time for unit tests are measured in
milliseconds, it does not matter if you create 10 to 20 unit tests for
each function tested.  This separation really helps with debugging.
If the test for the theta values fails, then you know that the problem
is theta.  If the test for the w_eff fails, then that is where the
problem is.  If both tests fails, then the problem is shared.

On a different note, unit tests should avoid calling user functions
(or their backends) and then test the result.  Unit tests are only for
checking the operation of single isolated functions.  In this unit
test, quite a lot more is happening.  When this is the case, when a
chain of different functions are executed, the test should be
converted into a system test.  System tests are for running a series
of operations and checking that the result is as expected.  This is
easy enough to change, just cut and paste the method in
test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
into test_suite/system_tests/relax_disp.py.  You'll see that the code
in test_suite/system_tests/relax_disp.py is more like that of the
current unit test.  For the system test, it would be also good to have
two tests.  This again is to be able to pinpoint the exact location of
a failure.

Regards,

Edward



On 12 March 2014 12:04,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Wed Mar 12 12:04:41 2014
New Revision: 22457

URL: http://svn.gna.org/viewcvs/relax?rev=22457&view=rev
Log:
Extendend unit test test_value_write_calc_rotating_frame_params() to also 
test writing of w_eff values.

Regarding sr #3124, (https://gna.org/support/index.php?3124) - Grace graphs 
production for R1rho analysis with R2_eff as function of Omega_eff.

Modified:
    
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py

Modified: 
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py?rev=22457&r1=22456&r2=22457&view=diff
==============================================================================
--- 
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
        (original)
+++ 
trunk/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
        Wed Mar 12 12:04:41 2014
@@ -780,19 +780,23 @@
         # Set filepaths.
         int_filepath = ds.tmpdir+sep+'int.out'
         theta_filepath = ds.tmpdir+sep+'theta.out'
+        w_eff_filepath = ds.tmpdir+sep+'w_eff.out'

         # Write out the intensity and theta parameter file.
         # The writing out of intensity file is to make sure the API 
function retains its function after modification for special parameters.
         value.write(param='intensities', file='int.out', dir=ds.tmpdir, 
scaling=1.0, force=True)
         value.write(param='theta', file='theta.out', dir=ds.tmpdir, 
scaling=1.0, force=True)
+        value.write(param='w_eff', file='w_eff.out', dir=ds.tmpdir, 
scaling=1.0, force=True)

         # Test the file exists.
         self.assert_(access(int_filepath, F_OK))
         self.assert_(access(theta_filepath, F_OK))
+        self.assert_(access(w_eff_filepath, F_OK))

         # Open the files for testing.
         int_file = open(int_filepath, 'r')
         theta_file = open(theta_filepath, 'r')
+        w_eff_file = open(w_eff_filepath, 'r')

         # Loop over the intensity file to test values.
         for line in int_file:
@@ -838,7 +842,32 @@
             elif linesplit[0] == "None" and linesplit[1] == "10" and 
linesplit[2] == "L":
                 self.assert_(linesplit[5] != "None")

+        # Loop over the w_eff file to test values.
+        for line in w_eff_file:
+            # Skip lines starting with #.
+            if line[0] == "#":
+                continue
+            # Print lines, not including newline character.
+            print(line[:-1])
+
+            # Split the line
+            linesplit = line.split()
+
+            # Assume values
+            if linesplit[0] == "None" and linesplit[1] == "5" and 
linesplit[2] == "I":
+                self.assert_(linesplit[5] != "None")
+            elif linesplit[0] == "None" and linesplit[1] == "6" and 
linesplit[2] == "S":
+                self.assert_(linesplit[5] != "None")
+            elif linesplit[0] == "None" and linesplit[1] == "8" and 
linesplit[2] == "S":
+                self.assert_(linesplit[5] != "None")
+            elif linesplit[0] == "None" and linesplit[1] == "9" and 
linesplit[2] == "A":
+                self.assert_(linesplit[5] != "None")
+            elif linesplit[0] == "None" and linesplit[1] == "10" and 
linesplit[2] == "L":
+                self.assert_(linesplit[5] != "None")
+
         # Close files
         int_file.close()
         theta_file.close()
-
+        w_eff_file.close()
+
+


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Wed Mar 12 12:40:32 2014