[Checkins] SVN: martian/trunk/src/martian/ Merged jw-skip-tests branch 78220:HEAD

Jan-Wijbrand Kolman jw at infrae.com
Tue Jul 24 07:24:42 EDT 2007


Log message for revision 78306:
  Merged jw-skip-tests branch 78220:HEAD
  
  

Changed:
  U   martian/trunk/src/martian/scan.py
  U   martian/trunk/src/martian/scan.txt
  A   martian/trunk/src/martian/tests/withtestsmodules/
  A   martian/trunk/src/martian/tests/withtestspackages/

-=-
Modified: martian/trunk/src/martian/scan.py
===================================================================
--- martian/trunk/src/martian/scan.py	2007-07-24 11:07:39 UTC (rev 78305)
+++ martian/trunk/src/martian/scan.py	2007-07-24 11:24:41 UTC (rev 78306)
@@ -60,7 +60,7 @@
         """
         return os.path.join(os.path.dirname(self.path), name)
 
-    def getSubModuleInfos(self):
+    def getSubModuleInfos(self, exclude_tests=True):
         if not self.isPackage():
             return []
         directory = os.path.dirname(self.path)
@@ -70,7 +70,11 @@
             entry_path = os.path.join(directory, entry)
             name, ext = os.path.splitext(entry)
             dotted_name = self.dotted_name + '.' + name
-
+            # By default skip (functional) tests pacakges and modules
+            # XXX This make scan.py less generic and thus we might want to
+            # look for a different solution at some point.
+            if exclude_tests and (name in ['tests', 'ftests']):
+                continue
             # Case one: modules
             if (os.path.isfile(entry_path) and ext in ['.py', '.pyc']):
                 if name == '__init__':

Modified: martian/trunk/src/martian/scan.txt
===================================================================
--- martian/trunk/src/martian/scan.txt	2007-07-24 11:07:39 UTC (rev 78305)
+++ martian/trunk/src/martian/scan.txt	2007-07-24 11:24:41 UTC (rev 78306)
@@ -162,3 +162,53 @@
   >>> resource_path = cave_module_info.getResourcePath('cave-templates')
   >>> resource_path == expected_resource_path
   True
+
+Skipping test packages and modules
+----------------------------------
+
+By default functional tests and unit tests are skipped from the grokking
+procedure.
+
+Packages called 'tests' (the "de facto" standard name for packages containing
+unit tests) or 'ftests' (for functional tests) are skipped (and thus not
+grokked)::
+
+  >>> from martian.scan import ModuleInfo, module_info_from_dotted_name
+  >>> module_info = module_info_from_dotted_name(
+  ...     'martian.tests.withtestspackages')
+  >>> module_info
+  <ModuleInfo object for 'martian.tests.withtestspackages'>
+  >>> # Will *not* contain the module info for the tests and ftests packages
+  >>> print module_info.getSubModuleInfos()
+  [<ModuleInfo object for 'martian.tests.withtestspackages.subpackage'>]
+
+Likewise modules called tests.py or ftests.py are skipped::
+
+  >>> from martian.scan import ModuleInfo, module_info_from_dotted_name
+  >>> module_info = module_info_from_dotted_name(
+  ...     'martian.tests.withtestsmodules')
+  >>> module_info
+  <ModuleInfo object for 'martian.tests.withtestsmodules'>
+  >>> # Will *not* contain the module info for the tests and ftests modules
+  >>> print module_info.getSubModuleInfos()
+  [<ModuleInfo object for 'martian.tests.withtestsmodules.subpackage'>]
+
+You can still get to the module info of tests and ftests if you need to::
+
+  >>> module_info = module_info_from_dotted_name(
+  ...     'martian.tests.withtestspackages')
+  >>> module_info
+  <ModuleInfo object for 'martian.tests.withtestspackages'>
+  >>> print module_info.getSubModuleInfos(exclude_tests=False)
+  [<ModuleInfo object for 'martian.tests.withtestspackages.ftests'>,
+  <ModuleInfo object for 'martian.tests.withtestspackages.subpackage'>,
+  <ModuleInfo object for 'martian.tests.withtestspackages.tests'>]
+
+You can also explicitely grok tests and ftests packages::
+
+  >>> module_info = module_info_from_dotted_name(
+  ...     'martian.tests.withtestspackages.tests')
+  >>> module_info
+  <ModuleInfo object for 'martian.tests.withtestspackages.tests'>
+  >>> print module_info.getSubModuleInfos()
+  [<ModuleInfo object for 'martian.tests.withtestspackages.tests.subpackage'>]

Copied: martian/trunk/src/martian/tests/withtestsmodules (from rev 78305, martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules)

Copied: martian/trunk/src/martian/tests/withtestspackages (from rev 78305, martian/branches/jw-skip-tests/src/martian/tests/withtestspackages)



More information about the Checkins mailing list