- Revision
- 11254
- Author
- bear
- Date
- 2006-07-25 12:43:07 -0700 (Tue, 25 Jul 2006)
Log Message
bumping launchers relver to remove the tools/ directory from PYTHONPATH
this also requires a change (again) to run_tests.py and profile_tests.py
this time the ScanningLoader class has been extracted to a new util.test_finder.py
module for use by unit tests.
bug 6390
this also requires a change (again) to run_tests.py and profile_tests.py
this time the ScanningLoader class has been extracted to a new util.test_finder.py
module for use by unit tests.
bug 6390
Modified Paths
- trunk/chandler/Makefile
- trunk/chandler/application/tests/TestEggParcels.py
- trunk/chandler/application/tests/TestSchemaAPI.py
- trunk/chandler/application/tests/__init__.py
- trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py
- trunk/chandler/parcels/osaf/sharing/tests/__init__.py
- trunk/chandler/parcels/osaf/tests/TestScripting.py
- trunk/chandler/parcels/osaf/tests/TestStartups.py
- trunk/chandler/tools/profile_tests.py
- trunk/chandler/tools/run_tests.py
Diff
Modified: trunk/chandler/Makefile (11253 => 11254)
--- trunk/chandler/Makefile 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/Makefile 2006-07-25 19:43:07 UTC (rev 11254) @@ -65,7 +65,7 @@ # When a version changes, the ARCHIVES lists below needs to be updated. # these get installed into release or debug -ARCHIVES=$(CHANDLERARCHIVES)/Launchers-$(SNAP)-0.8-$(BP)9.tar.gz \ +ARCHIVES=$(CHANDLERARCHIVES)/Launchers-$(SNAP)-0.8-$(BP)A.tar.gz \ $(CHANDLERARCHIVES)/chandlerdb-$(SNAP)-0.6-$(BP)33.tar.gz \ $(CHANDLERARCHIVES)/db-$(SNAP)-4.4.20-$(BP)5.tar.gz \ $(CHANDLERARCHIVES)/python-$(SNAP)-2.4.3-$(BP)3.tar.gz \
Modified: trunk/chandler/application/tests/TestEggParcels.py (11253 => 11254)
--- trunk/chandler/application/tests/TestEggParcels.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/application/tests/TestEggParcels.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -34,7 +34,7 @@ if __name__=='__main__': # This module can't be safely run as __main__, so it has to be re-imported # and have *that* copy run. - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader unittest.main( module=None, testLoader = ScanningLoader(), argv=["unittest", this_module]
Modified: trunk/chandler/application/tests/TestSchemaAPI.py (11253 => 11254)
--- trunk/chandler/application/tests/TestSchemaAPI.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/application/tests/TestSchemaAPI.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -154,7 +154,7 @@ if __name__=='__main__': # This module can't be safely run as __main__, so it has to be re-imported # and have *that* copy run. - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader unittest.main( module=None, testLoader = ScanningLoader(), argv=["unittest", this_module]
Modified: trunk/chandler/application/tests/__init__.py (11253 => 11254)
--- trunk/chandler/application/tests/__init__.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/application/tests/__init__.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -29,7 +29,7 @@ def suite(): """Unit test suite; run by testing 'application.tests.suite'""" - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader from unittest import defaultTestLoader, TestSuite loader = ScanningLoader() return TestSuite(
Modified: trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py (11253 => 11254)
--- trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -352,7 +352,7 @@ def suite(): """Unit test suite; run by testing 'parcels.osaf.sharing.tests.suite'""" - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader from unittest import defaultTestLoader, TestSuite loader = ScanningLoader() return TestSuite(
Modified: trunk/chandler/parcels/osaf/sharing/tests/__init__.py (11253 => 11254)
--- trunk/chandler/parcels/osaf/sharing/tests/__init__.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/parcels/osaf/sharing/tests/__init__.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -26,7 +26,7 @@ def suite(): """Unit test suite; run by testing 'parcels.osaf.sharing.tests.suite'""" - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader from unittest import defaultTestLoader, TestSuite loader = ScanningLoader() return TestSuite(
Modified: trunk/chandler/parcels/osaf/tests/TestScripting.py (11253 => 11254)
--- trunk/chandler/parcels/osaf/tests/TestScripting.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/parcels/osaf/tests/TestScripting.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -29,6 +29,6 @@ if __name__=='__main__': - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader unittest.main(testLoader = ScanningLoader())
Modified: trunk/chandler/parcels/osaf/tests/TestStartups.py (11253 => 11254)
--- trunk/chandler/parcels/osaf/tests/TestStartups.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/parcels/osaf/tests/TestStartups.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -82,6 +82,6 @@ signal(SIGALRM, timeout) alarm(90) - from tools.run_tests import ScanningLoader + from util.test_finder import ScanningLoader unittest.main(testLoader = ScanningLoader())
Modified: trunk/chandler/tools/profile_tests.py (11253 => 11254)
--- trunk/chandler/tools/profile_tests.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/tools/profile_tests.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -1,23 +1,24 @@ -"""profile_tests.py -- Profile specified tests or suites +""" +profile_tests.py -- Profile specified tests or suites Usage ----- Profile tests in a specific module:: - RunPython -m profile_tests repository.tests.TestText + RunPython ./tools/profile_tests.py repository.tests.TestText Profile a specific test class:: - RunPython -m profile_tests repository.tests.TestText.TestText + RunPython ./tools/profile_tests.py repository.tests.TestText.TestText Profile a specific test method:: - RunPython -m profile_tests repository.tests.TestText.TestText.testAppend + RunPython ./tools/profile_tests.py repository.tests.TestText.TestText.testAppend Profile all tests in a suite:: - RunPython -m profile_tests repository.tests.suite + RunPython ./tools/profile_tests.py repository.tests.suite By default, the top 10 routines (by time consumed) will be printed, and the profile statistics will be saved in 'profile.dat'. However, if @@ -40,7 +41,7 @@ """ import sys -from tools.run_tests import ScanningLoader +from util.test_finder import ScanningLoader from unittest import main from hotshot import Profile from hotshot.stats import load @@ -55,13 +56,13 @@ sys.exit(2) stats_file = "profile.dat" - + try: ProfilingMain(module=None, testLoader=ScanningLoader()) except SystemExit: # prevent unittest.main() from forcing an early exit pass - + s = load(stats_file) s.sort_stats("time") s.print_stats(10)
Modified: trunk/chandler/tools/run_tests.py (11253 => 11254)
--- trunk/chandler/tools/run_tests.py 2006-07-25 19:28:59 UTC (rev 11253) +++ trunk/chandler/tools/run_tests.py 2006-07-25 19:43:07 UTC (rev 11254) @@ -1,31 +1,32 @@ -"""run_tests.py -- Run specified tests or suites +""" +run_tests.py -- Run specified tests or suites Usage ----- Run tests in a specific module:: - RunPython -m run_tests repository.tests.TestText + RunPython ./tools/run_tests.py repository.tests.TestText Run a specific test class:: - RunPython -m run_tests repository.tests.TestText.TestText + RunPython ./tools/run_tests.py repository.tests.TestText.TestText Run a specific test method:: - RunPython -m run_tests repository.tests.TestText.TestText.testAppend + RunPython ./tools/run_tests.py repository.tests.TestText.TestText.testAppend Run all tests in a suite:: - RunPython -m run_tests application.tests.TestSchemaAPI.suite + RunPython ./tools/run_tests.py application.tests.TestSchemaAPI.suite Run all tests in all modules in a package and its sub-packages:: - RunPython -m run_tests application.tests + RunPython ./tools/run_tests.py application.tests Run all tests in Chandler:: - RunPython -m run_tests application crypto osaf repository + RunPython ./tools/run_tests.py application crypto osaf repository A '-v' option can be included after 'run_tests' to print the name and @@ -45,50 +46,20 @@ i.e. by setting the CHANDLERLOGCONFIG environment variable or the -L <file> command line argument to specify a logging configuration file. For example: - RunPython -m run_tests -L custom.conf -v application osaf + RunPython ./tools/run_tests.py -L custom.conf -v application osaf (Note: specifying package names on the 'run_tests' command line will cause *all* modules in all sub-packages of that package to be imported.) """ -import sys, os +import sys -from unittest import TestLoader, main +from unittest import main from application import Utility +from util import test_finder -class ScanningLoader(TestLoader): - def loadTestsFromModule(self, module): - """Return a suite of all tests cases contained in the given module""" - - tests = [TestLoader.loadTestsFromModule(self,module)] - - if hasattr(module, "additional_tests"): - tests.append(module.additional_tests()) - - if hasattr(module, '__path__'): - for dir in module.__path__: - for file in os.listdir(dir): - if file.endswith('.py') and file!='__init__.py': - if file.lower().startswith('test'): - submodule = module.__name__+'.'+file[:-3] - else: - continue - else: - subpkg = os.path.join(dir,file,'__init__.py') - if os.path.exists(subpkg): - submodule = module.__name__+'.'+file - else: - continue - tests.append(self.loadTestsFromName(submodule)) - - if len(tests)>1: - return self.suiteClass(tests) - else: - return tests[0] # don't create a nested suite for only one return - - if __name__ == '__main__': if len(sys.argv)<2 or sys.argv[1] in ('-h','--help'): # XXX @@ -109,6 +80,5 @@ # options.args has all the leftover arguments from Utility sys.argv = args + options.args + main(module=None, testLoader=test_finder.ScanningLoader()) - main(module=None, testLoader=ScanningLoader()) -
_______________________________________________ Commits mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/commits
