mailRe: r3080 - /1.3/test_suite/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 Gary S. Thompson on March 06, 2007 - 09:45:
Edward d'Auvergne wrote:

The function arguments are definitely clearly described.


oh good!

Do you think
that the arguments of the command line usage of 'unit_test_runner.py'
should be sent in as the argument 'test_module' or the argument
'root_path'?  Is 'test_module' supposed to be a file name or module
name (eg. 'data/test_diff_tensor.py' vs 'data.test_diff_tensor')?


oh bad! obviously not quite well enough defined... a module name

From the parser usage string, I would assume the former.


For the argument 'rootSystemDirectory', could this not be changed to a
single string?  The second array element, the relative path, could
easily be determined by a function which converts all directories in
the first element to '..' (well actually 'os.pardir' to be
cross-platform compatible).  Oh, I just noticed but the directory
separators should be made OS independent and portable by using the
'sep' variable from the 'os' module.  It may be possible to also write
a function which determines these directories automatically, removing
the need for the argument (eg. walking up directories from os.getcwd()
until an executable file 'relax' is found).   Would it be possible to
determine the values of the 'root_unit_test_directory' argument
automatically as well?


There are a few things here

1. yes I should be using os.pardir() and I have bee trying to use os.sep, if it is missing its an oversight
2. both the unit test funtion and the system directoy function pass into a general directory searcher
so the second argument is needed
3. I could look for an executable relax file but I feel makes me more dystem dependant than looking for a directory structure



One last thing is do we need the 'test_pattern' argument? I think we
should enforce that unit test files must always start with 'test_' and
end in '.py'. Can you see exceptions to this rule requiring the
argument?


I don't in general see any exceptions to this rule , but I designed the setup to be general again. I guess the search string could be come an inrenal constant

Also do you think that we should have a single unit test
file per relax module?  I can see value in not enforcing this rule.
For example the 'specific_fns.model_free' module contains a very large
number of class methods.  This could be better served by a directory
such as 'test_suite/unit_tests/specific_fns/model_free/' and allowing
that directory to have a separate unit test model per class methods
(each containing numerous tests of that one method).  As each relax
function or method will require numerous tests for proper functioning,
proper throwing of RelaxErrors, etc, the unit test modules could
become quite large and unwieldy, especially if the self.setUp and
self.tearDown() methods need to be different for different
functions/methods.

It would be ideal to have one file per because then we can check for basic coverage and overlooked unit tests. However there is nothing to stop you adding imports to auxiliary classes to carry out the individual tests....

Sorry about the large number of questions,

Edward

no problem

regards
gary


On 3/5/07, Gary S. Thompson <garyt@xxxxxxxxxxxxxxx> wrote:

Dear All
as you can see I have updated the doc string for
Run_unit_tests.__init__ could you have a look and see if it makes sense
(the previous incarnation patently didn't ;-) )

note:
1 Please note that of course the implementation is trailing the
documentation...
2. There are FIXMES  and other notes still floating around

regards
gary

garyt@xxxxxxxxxxxxxxx wrote:

>Author: varioustoxins
>Date: Mon Mar 5 10:52:07 2007
>New Revision: 3080
>
>URL: http://svn.gna.org/viewcvs/relax?rev=3080&view=rev
>Log:
>improve command line docs and doc string for Run_unit_tests.__init__
>
>
>Modified:
> 1.3/test_suite/unit_tests/unit_test_runner.py
>
>Modified: 1.3/test_suite/unit_tests/unit_test_runner.py
>URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/unit_test_runner.py?rev=3080&r1=3079&r2=3080&view=diff


>==============================================================================

>--- 1.3/test_suite/unit_tests/unit_test_runner.py (original)
>+++ 1.3/test_suite/unit_tests/unit_test_runner.py Mon Mar 5 10:52:07 2007
>@@ -56,9 +56,14 @@
>
> import os,re,unittest,string,sys
> from optparse import OptionParser
>+from textwrap import dedent
>
> #import Tkinter as tk
> #import unittest.unittestgui as unitgui
>+
>+# constants
>+###########
>+PY_FILE_EXTENSION='py'
>
> # utility functions
> ###################
>@@ -287,23 +292,27 @@
>
> @type root_path: a string containing a directory name
> @param root_path: root path to start searching for modules to unit test
>- from usually this is the current working directory.
>+ from. Two special cases arise: if the string contains '.'
>+ the search starts from the current working directory, if the value is
>+ the special value TEST_SUITE defined in this file the root of the
>+ test suite is sought from the current working directory using
>+ find_unit_test_directory_path() and used instead.
>
> @type test_module: string
> @param test_module: the name of a module to unit test. If the variable
>- is None it will be interpreted as
>- the current working directory
>- contents. Otherwise it will be used as a module path from the
>+ is None a search for unit tests using <test-pattern> will start
>+ form <root_path>, otherwise it will be used as a module path from the
> current working directory.
>
>- @type test_pattern: a list of strings containing patterns
>- @param test_pattern: a list of patterns against which files will be
>+ FIXME: rename as testcase_file_pattern
>+ @type test_pattern: a list of strings containing regex patterns
>+ @param test_pattern: a list of regex patterns against which files will be
> tested to see if they are expected to contain unit tests. If
>- the file has the correct pattern the class
>- <fileName>.<capitalisedFileName> will be searched for
>- testCases e.g in the case of test_float.py the combination
>- would be test_float.Test_float.
>-
>+ the file has the correct pattern the module contained inside the
>+ file will be searched for testCases e.g in the case of test_float.py
>+ the module to be searched for would be test_float.Test_float.
>+
>+ FIXME: the following to options are search paths and should be named so
> @type rootSystemDirectory: a list containing a directory name followed by a
> relative path
> @param rootSystemDirectory: the directory from which the distribution
>@@ -312,13 +321,16 @@
> relative to the test suite. For the current setup
> in relax this is (\'test_suite\', /'..\'). The first string is a
> directory to match the second string is a relative path from that
>- directory to the system directory
>+ directory to the system directory. The search is started from the true
>+ value of root_path in the file system.
>
> @type root_unit_test_directory: a list containing a directory name followed by a
> relative path
> @param root_unit_test_directory: the directory from which all unit
> module directories descend. For the current setup in relax
>- this is (\'unit_tests\', \'.\').
>+ this is (\'unit_tests\', \'.\'). The search is started from the true
>+ value of root_path in the file system.
>+
> @type verbose: Boolean
> @param verbose: produce verbose output during testing e.g. directories
> searched root directories etc
>@@ -431,6 +443,7 @@
> elems = python_module_path.split('.')
> return os.sep.join(elems)
>
>+# FIXME: logic error two uses for self.testModule
> def paths_from_test_module(self, root_path):
> '''Determine the possible path of the self.test_module.
>
>@@ -441,6 +454,7 @@
> 2. the rootPath itself (self.testModule == None)
> 3. a file or directory relative to the unitTestRootPath
> 4. the unit test directory itself (self.testModule == None)
>+
>
> currently this assumes that if the last two names in testModule are
> the same barring an initial capital letter in the class name
>@@ -559,7 +573,33 @@
>
> parser.add_option("-v", "--verbose", dest="verbose",
> help="verbose test ouput", default=False, action='store_true')
>+
>+ usage="""
>+ %%prog [options] [<file-or-dir>...]
>+
>+ a program to find and run subsets of the relax unit test suite using pyunit.
>+ (details of how to write pyunit tests can be found in your python distributions
>+ library reference)
>+
>+
>+ arguments:
>+ <file-or-dir> = <file-path> | <dir-path> is a list which can contain
>+ inter-mixed directories and files
>+
>+ <file-path> = a file containing a test case class files of the same
>+ name with the first letter capitalised
>+
>+ e.g. maths_fns/test_chi2.py will be assumed to contain
>+ a test case class called Test_chi2
>+
>+ <dir-path> = a path which will be recursivley searched for <file-path>s
>+ which end in %s
>+ """ % PY_FILE_EXTENSION
>+
>+ parser.set_usage(dedent(usage))
>+
> (options, args) = parser.parse_args()
>+
>
> for arg in args:
> runner = Run_unit_tests(test_module=arg, verbose=options.verbose)
>
>
>_______________________________________________
>relax (http://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
>
>.
>
>
>



-- ------------------------------------------------------------------- Dr Gary Thompson Astbury Centre for Structural Molecular Biology, University of Leeds, Astbury Building, Leeds, LS2 9JT, West-Yorkshire, UK Tel. +44-113-3433024 email: garyt@xxxxxxxxxxxxxxx Fax +44-113-2331407 -------------------------------------------------------------------



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

This is the relax-devel mailing list
relax-devel@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-devel


.



--
-------------------------------------------------------------------
Dr Gary Thompson
Astbury Centre for Structural Molecular Biology,
University of Leeds, Astbury Building,
Leeds, LS2 9JT, West-Yorkshire, UK             Tel. +44-113-3433024
email: garyt@xxxxxxxxxxxxxxx                   Fax  +44-113-2331407
-------------------------------------------------------------------





Related Messages


Powered by MHonArc, Updated Wed Mar 07 08:40:25 2007