[Checkins] SVN: martian/branches/jw-skip-tests/src/martian/ Merge
skip-tests feature from older grok branch to martian.
Jan-Wijbrand Kolman
jw at infrae.com
Fri Jul 20 09:53:50 EDT 2007
Log message for revision 78222:
Merge skip-tests feature from older grok branch to martian.
Changed:
U martian/branches/jw-skip-tests/src/martian/scan.py
U martian/branches/jw-skip-tests/src/martian/scan.txt
A martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/
U martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/ftests.py
U martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/tests.py
A martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/
U martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/ftests/__init__.py
U martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/tests/__init__.py
-=-
Modified: martian/branches/jw-skip-tests/src/martian/scan.py
===================================================================
--- martian/branches/jw-skip-tests/src/martian/scan.py 2007-07-20 13:31:06 UTC (rev 78221)
+++ martian/branches/jw-skip-tests/src/martian/scan.py 2007-07-20 13:53:49 UTC (rev 78222)
@@ -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,9 @@
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
+ 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/branches/jw-skip-tests/src/martian/scan.txt
===================================================================
--- martian/branches/jw-skip-tests/src/martian/scan.txt 2007-07-20 13:31:06 UTC (rev 78221)
+++ martian/branches/jw-skip-tests/src/martian/scan.txt 2007-07-20 13:53:49 UTC (rev 78222)
@@ -162,3 +162,45 @@
>>> 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'>]
+
Copied: martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules (from rev 78221, grok/branches/jw-skip-tests/src/grok/tests/scan/withtestsmodules)
Modified: martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/ftests.py
===================================================================
--- grok/branches/jw-skip-tests/src/grok/tests/scan/withtestsmodules/ftests.py 2007-07-20 13:31:06 UTC (rev 78221)
+++ martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/ftests.py 2007-07-20 13:53:49 UTC (rev 78222)
@@ -1,12 +1,3 @@
-from zope.interface import Interface
-import grok
-
-class IClub(Interface):
- pass
-
-class Club(grok.GlobalUtility):
- grok.provides(IClub)
-
import unittest
def test_suite():
return unittest.TestSuite() # return an empty suite
Modified: martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/tests.py
===================================================================
--- grok/branches/jw-skip-tests/src/grok/tests/scan/withtestsmodules/tests.py 2007-07-20 13:31:06 UTC (rev 78221)
+++ martian/branches/jw-skip-tests/src/martian/tests/withtestsmodules/tests.py 2007-07-20 13:53:49 UTC (rev 78222)
@@ -1,12 +1,3 @@
-from zope.interface import Interface
-import grok
-
-class IClub(Interface):
- pass
-
-class Club(grok.GlobalUtility):
- grok.provides(IClub)
-
import unittest
def test_suite():
return unittest.TestSuite() # return an empty suite
Copied: martian/branches/jw-skip-tests/src/martian/tests/withtestspackages (from rev 78221, grok/branches/jw-skip-tests/src/grok/tests/scan/withtestspackages)
Modified: martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/ftests/__init__.py
===================================================================
--- grok/branches/jw-skip-tests/src/grok/tests/scan/withtestspackages/ftests/__init__.py 2007-07-20 13:31:06 UTC (rev 78221)
+++ martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/ftests/__init__.py 2007-07-20 13:53:49 UTC (rev 78222)
@@ -1,8 +0,0 @@
-from zope.interface import Interface
-import grok
-
-class IMammoth(Interface):
- pass
-
-class Mammoth(grok.GlobalUtility):
- grok.provides(IMammoth)
Modified: martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/tests/__init__.py
===================================================================
--- grok/branches/jw-skip-tests/src/grok/tests/scan/withtestspackages/tests/__init__.py 2007-07-20 13:31:06 UTC (rev 78221)
+++ martian/branches/jw-skip-tests/src/martian/tests/withtestspackages/tests/__init__.py 2007-07-20 13:53:49 UTC (rev 78222)
@@ -1,8 +0,0 @@
-from zope.interface import Interface
-import grok
-
-class IMammoth(Interface):
- pass
-
-class Mammoth(grok.GlobalUtility):
- grok.provides(IMammoth)
More information about the Checkins
mailing list