mailr26190 - 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 on October 07, 2014 - 16:11:
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))




Related Messages


Powered by MHonArc, Updated Tue Oct 07 16:40:02 2014