mailRe: r26190 - in /trunk/test_suite: test_suite_runner.py unit_tests/unit_test_runner.py


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

Header


Content

Posted by Edward d'Auvergne on October 08, 2014 - 09:18:
Hi,

In case you haven't seen this commit - you may find it quite useful as
a relax developer.  Prior to this, to check one unit test you had to
run every last unit test.  Although Gary's unit_test_runner.py script
could handle running individual unit test modules, running the script
directly has regressed, as it was never tested in the test suite, and
the script is currently non-functional from the command line.  However
with this change you can now specify the unit test module to run when
running the tests from within relax.  For example:

$ relax -u _pipe_control.test_value

This will only run the tests in the
test_suite.unit_tests._pipe_control.test_value module.  The unit test
printouts have also been modified so that the test name and test
module are separated so that it is easier to identify what you should
supply as a command line option.  This restoration of Gary's unit test
feature should be a very useful aid for relax development!

Regards,

Edward



On 7 October 2014 16:11,  <edward@xxxxxxxxxxxxx> wrote:
Author: bugman
Date: Tue Oct  7 16:11:38 2014
New Revision: 26190

URL: http://svn.gna.org/viewcvs/relax?rev=26190&view=rev
Log:
Big improvement for running the relax unit tests via the relax command line 
options.

The unit test module path is now accepted as a command line option.  This 
brings more capabilities
of Gary Thompson's test_suite/unit_tests/unit_test_runner.py script into 
the relax command line.
The _pipe_control/test_value unit test module path can be specified as, for 
example, one of
'test_suite.unit_tests._pipe_control.test_value', 
'test_suite/unit_tests/_pipe_control/test_value',
'_pipe_control.test_value', '_pipe_control/test_value'.  This allows 
individual modules of tests to
be run, rather than having to execute all unit tests, which is very useful 
for debugging.


Modified:
    trunk/test_suite/test_suite_runner.py
    trunk/test_suite/unit_tests/unit_test_runner.py

Modified: trunk/test_suite/test_suite_runner.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/test_suite_runner.py?rev=26190&r1=26189&r2=26190&view=diff
==============================================================================
--- trunk/test_suite/test_suite_runner.py       (original)
+++ trunk/test_suite/test_suite_runner.py       Tue Oct  7 16:11:38 2014
@@ -231,7 +231,7 @@
             # Run the tests.
             unit_runner = 
Unit_test_runner(root_path=status.install_path+os.sep+'test_suite'+os.sep+'unit_tests')
             self.runner.category = 'unit'
-            self.unit_result = unit_runner.run(runner=self.runner)
+            self.unit_result = unit_runner.run(self.tests, 
runner=self.runner)

             # Print out a summary of the test suite.
             if summary:

Modified: trunk/test_suite/unit_tests/unit_test_runner.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/unit_test_runner.py?rev=26190&r1=26189&r2=26190&view=diff
==============================================================================
--- trunk/test_suite/unit_tests/unit_test_runner.py     (original)
+++ trunk/test_suite/unit_tests/unit_test_runner.py     Tue Oct  7 16:11:38 
2014
@@ -5,7 +5,7 @@
 #                         (see https://gna.org/users/varioustoxins         
    #
 #                                      for contact details)                
    #
 #                                                                          
    #
-# Copyright (C) 2007-2013 Edward d'Auvergne                                
    #
+# Copyright (C) 2007-2014 Edward d'Auvergne                                
    #
 #                                                                          
    #
 #                                                                          
    #
 # This file is part of the program relax.                                  
    #
@@ -577,9 +577,11 @@
         return result


-    def run(self, runner=None):
+    def run(self, tests=None, runner=None):
         """Run a unit test or set of unit tests.

+        @keyword tests:     The list of system tests to perform.
+        @type tests:        list of str
         @keyword runner:    A unit test runner such as TextTestRunner.  
None indicates use of the default unit test runner.  For an example of how 
to write a test runner see the python documentation for TextTestRunner in 
the python source.
         @type runner:       Unit test runner instance (TextTestRunner, 
BaseGUITestRunner subclass, etc.)
         @return:            A string indicating success or failure of the 
unit tests run.
@@ -598,7 +600,27 @@
             print('----------------')
             print('')

-        module_paths = self.paths_from_test_module(self.test_module)
+        # The test module path for individual tests.
+        if tests:
+            # Initialise the list of paths.
+            module_paths = []
+
+            # Loop over each test.
+            for test in tests:
+                # Strip out the leading 'test_suite.unit_tests.' if 
present.
+                test = test.replace('test_suite.unit_tests.', '')
+                test = test.replace('test_suite%sunit_tests%s' % (os.sep, 
os.sep), '')
+
+                # Replace the Python '.' separator with the system's path 
separator.
+                test = test.replace('.', os.sep)
+
+                # Append to the module path list.
+                module_paths += 
self.paths_from_test_module(self.test_module+os.sep+test)
+
+        # The test module path for all tests.
+        else:
+            module_paths = self.paths_from_test_module(self.test_module)
+
         if self.verbose:
             print("%-22s %s" % ('Test module:', self.test_module))
             print("%-22s %s" % ('Root path', self.root_path))


_______________________________________________
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 Oct 08 10:00:12 2014