- Revision
- 11240
- Author
- bear
- Date
- 2006-07-22 14:10:24 -0700 (Sat, 22 Jul 2006)
Log Message
Move run_tests.py to the tools/ directory - this required changing any import for in in the unit tests.
Also added a platform text to the About Box
bug 5631
Also added a platform text to the About Box
bug 5631
Modified Paths
- trunk/chandler/application/AboutBox.py
- trunk/chandler/application/Utility.py
- 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/profile_tests.py
Added Paths
Removed Paths
Diff
Modified: trunk/chandler/application/AboutBox.py (11239 => 11240)
--- trunk/chandler/application/AboutBox.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/application/AboutBox.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -17,6 +17,7 @@ import wx, wx.html, os, sys from i18n import OSAFMessageFactory as _ import i18n +import Utility import Globals class AboutBox(wx.Dialog): @@ -106,13 +107,14 @@ replaceValues = { - "pix": _getRelImagePath("pixel.gif"), - "ab": _getRelImagePath("about.png"), - "ver": _("Version: %(versionNumber)s") % {"versionNumber": version}, - "abt": _("About Chandler"), - "ex": _("Experimentally usable calendar"), - "ch": _("Chandler"), - "osa": _("Open Source Applications Foundation"), + "pix": _getRelImagePath("pixel.gif"), + "ab": _getRelImagePath("about.png"), + "ver": _("Version: %(versionNumber)s") % {"versionNumber": version}, + "abt": _("About Chandler"), + "ex": _("Experimentally usable calendar"), + "plat": Utility.getPlatformName(), + "ch": _("Chandler"), + "osa": _("Open Source Applications Foundation"), "loc": _("For more info: %(chandlerWebURL)s") % \ {"chandlerWebURL": "<a href="" #This is a bummer the % in the width attribute was causing the @@ -138,6 +140,7 @@ <tr><td><center><font face="verdana, arial, helvetica, sans-serif" size="4" color="black"><strong>%(ch)s</strong></font></center></td></tr> <tr><td><img src="" width="1" height="15"></td></tr> <tr><td><center><font face="helvetica, arial, sans-serif" size="2" color="black">%(ver)s</font></center></td></tr> +<tr><td><center><font face="helvetica, arial, sans-serif" size="2" color="black">%(plat)s</font></center></td></tr> <tr><td><img src="" width="1" height="2"></td></tr> <tr><td><center><font face="helvetica, arial, sans-serif" size="2" color="black"> %(loc)s </font></center></td></tr> <tr><td><img src="" width="1" height="10"></td></tr>
Modified: trunk/chandler/application/Utility.py (11239 => 11240)
--- trunk/chandler/application/Utility.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/application/Utility.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -157,6 +157,26 @@ return desktopDir return homeDir +def getPlatformName(): + import platform + + platformName = 'Unknown' + + if os.name == 'nt': + platformName = 'Windows' + elif os.name == 'posix': + if sys.platform == 'darwin': + if platform.processor() == 'i386': + platformName = 'Mac OS X (intel)' + else: + platformName = 'Mac OS X (ppc)' + elif sys.platform == 'cygwin': + platformName = 'Windows (Cygwin)' + else: + platformName = 'Linux' + + return platformName + def initOptions(**kwds): """ Load and parse the command line options, with overrides in **kwds.
Modified: trunk/chandler/application/tests/TestEggParcels.py (11239 => 11240)
--- trunk/chandler/application/tests/TestEggParcels.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/application/tests/TestEggParcels.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -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 run_tests import ScanningLoader + from tools.run_tests import ScanningLoader unittest.main( module=None, testLoader = ScanningLoader(), argv=["unittest", this_module]
Modified: trunk/chandler/application/tests/TestSchemaAPI.py (11239 => 11240)
--- trunk/chandler/application/tests/TestSchemaAPI.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/application/tests/TestSchemaAPI.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -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 run_tests import ScanningLoader + from tools.run_tests import ScanningLoader unittest.main( module=None, testLoader = ScanningLoader(), argv=["unittest", this_module]
Modified: trunk/chandler/application/tests/__init__.py (11239 => 11240)
--- trunk/chandler/application/tests/__init__.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/application/tests/__init__.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -29,7 +29,7 @@ def suite(): """Unit test suite; run by testing 'application.tests.suite'""" - from run_tests import ScanningLoader + from tools.run_tests import ScanningLoader from unittest import defaultTestLoader, TestSuite loader = ScanningLoader() return TestSuite(
Modified: trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py (11239 => 11240)
--- trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/parcels/osaf/pim/calendar/tests/TestTimeZone.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -352,7 +352,7 @@ def suite(): """Unit test suite; run by testing 'parcels.osaf.sharing.tests.suite'""" - from run_tests import ScanningLoader + from tools.run_tests import ScanningLoader from unittest import defaultTestLoader, TestSuite loader = ScanningLoader() return TestSuite(
Modified: trunk/chandler/parcels/osaf/sharing/tests/__init__.py (11239 => 11240)
--- trunk/chandler/parcels/osaf/sharing/tests/__init__.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/parcels/osaf/sharing/tests/__init__.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -26,7 +26,7 @@ def suite(): """Unit test suite; run by testing 'parcels.osaf.sharing.tests.suite'""" - from run_tests import ScanningLoader + from tools.run_tests import ScanningLoader from unittest import defaultTestLoader, TestSuite loader = ScanningLoader() return TestSuite(
Modified: trunk/chandler/parcels/osaf/tests/TestScripting.py (11239 => 11240)
--- trunk/chandler/parcels/osaf/tests/TestScripting.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/parcels/osaf/tests/TestScripting.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -29,6 +29,6 @@ if __name__=='__main__': - from run_tests import ScanningLoader + from tools.run_tests import ScanningLoader unittest.main(testLoader = ScanningLoader())
Modified: trunk/chandler/parcels/osaf/tests/TestStartups.py (11239 => 11240)
--- trunk/chandler/parcels/osaf/tests/TestStartups.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/parcels/osaf/tests/TestStartups.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -82,6 +82,6 @@ signal(SIGALRM, timeout) alarm(90) - from run_tests import ScanningLoader + from tools.run_tests import ScanningLoader unittest.main(testLoader = ScanningLoader())
Modified: trunk/chandler/profile_tests.py (11239 => 11240)
--- trunk/chandler/profile_tests.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/profile_tests.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -40,7 +40,7 @@ """ import sys -from run_tests import ScanningLoader +from tools.run_tests import ScanningLoader from unittest import main from hotshot import Profile from hotshot.stats import load
Deleted: trunk/chandler/run_tests.py (11239 => 11240)
--- trunk/chandler/run_tests.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/run_tests.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -1,114 +0,0 @@ -"""run_tests.py -- Run specified tests or suites - -Usage ------ - -Run tests in a specific module:: - - RunPython -m run_tests repository.tests.TestText - -Run a specific test class:: - - RunPython -m run_tests repository.tests.TestText.TestText - -Run a specific test method:: - - RunPython -m run_tests repository.tests.TestText.TestText.testAppend - -Run all tests in a suite:: - - RunPython -m run_tests application.tests.TestSchemaAPI.suite - -Run all tests in all modules in a package and its sub-packages:: - - RunPython -m run_tests application.tests - -Run all tests in Chandler:: - - RunPython -m run_tests application crypto osaf repository - - -A '-v' option can be included after 'run_tests' to print the name and -status of each test as it runs. Normally, just a '.' is printed for each -passing test, and an E or F for errors or failing tests. However, since -some of Chandler's tests produce considerable console output of their -own, it may be hard to see the status dots and letters, so you may -prefer the output produced by '-v'. - -If you have doctests or other tests not based on the Python unittest -module, you should add them to an 'additional_tests' function in your -module, in order for run_test's test finder to be able to locate them. -The function should return a 'unittest.TestSuite' object (such as is -returned by 'doctest.DocFileSuite' or 'doctest.DocTestSuite'). - -Logging is configured in the same manner as for Chandler or headless.py, -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 - -(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 - -from unittest import TestLoader, main -from application import Utility - -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 - print __doc__ - sys.exit(2) - - options = Utility.initOptions() - Utility.initProfileDir(options) - Utility.initI18n(options) - Utility.initLogging(options) - - # Rebuild the command line for unittest.main - args = [sys.argv[0]] - if options.verbose: - args.append('-v') - if options.quiet: - args.append('-q') - # options.args has all the leftover arguments from Utility - sys.argv = args + options.args - - - main(module=None, testLoader=ScanningLoader()) -
Deleted: trunk/chandler/schema_status.py (11239 => 11240)
--- trunk/chandler/schema_status.py 2006-07-22 20:49:33 UTC (rev 11239) +++ trunk/chandler/schema_status.py 2006-07-22 21:10:24 UTC (rev 11240) @@ -1,210 +0,0 @@ -from application import schema -from application.Parcel import Manager as ParcelManager -from application.Parcel import Parcel -from repository.schema.Kind import Kind -from repository.persistence.RepositoryView import NullRepositoryView -import sys, logging, os - -# pre-import any command line arguments so errors can be reported sooner -report_on = [(arg, schema.importString(arg))for arg in sys.argv[1:]] - -for chatty in 'Parcel', 'Inbound': - # Silence talkative loggers - logger = logging.getLogger(chatty) - logger.setLevel(logging.WARNING) - -logging.getLogger().addHandler(logging.StreamHandler()) - -rep = NullRepositoryView() -schema.initRepository(rep) - -manager = ParcelManager.get( - rep, path=[os.path.join(os.path.dirname(__file__),'parcels')] -) - -manager.loadParcels() #['http://osafoundation.org/parcels/osaf/contentmodel']) - -classKinds = {} -allKinds = set() - -def scan_parcel(item): - for child in item.iterChildren(): - if isinstance(child,Parcel): - scan_parcel(child) - elif isinstance(child,Kind): - classKinds.setdefault(child.getItemClass(),[]).append(child) - allKinds.add(child) - -scan_parcel(rep.findPath('//parcels')) - - -goodKinds = 0 -unloadable = [] -non_schema = [] -diff_supers = [] -diff_attrs = [] -diff_clouds = [] -diff_path = [] -missing = [] -derived_non_schema = [] -all = set() -bad = set() -imports_needed = {} -details = {} - -def mismatch(classname,how,what): - details.setdefault(classname,{}).setdefault(how,[]).append(what) - -def name_of(cls): - return "%s.%s" % ( - getattr(cls,'__module__','*generated*'),cls.__name__ - ) - -def item_names_of(item,attr): - return set(thing.itsName for thing in getattr(item,attr,())) - -for cls, kinds in classKinds.items(): - classname = name_of(cls) - all.add(classname) - - if classname.startswith('repository.schema.Kind.class_'): - missing.extend(kind.itsPath for kind in kinds) - bad.add(classname) - continue - - if len(kinds)>1: - print - print "Multiple kinds for class", classname+':' - for kind in kinds: - print " ",kind.itsPath - bad.add(classname) - continue - - for kind in kinds: - modname = '.'.join(str(kind.itsPath).split('/')[3:-1]) - module = schema.importString(modname) - if cls not in module.__dict__.values(): - imports_needed.setdefault(modname,[]).append(classname) - - if not isinstance(cls,schema.ItemClass) and cls not in schema.nrv._schema_cache: - if schema.Base in cls.__bases__: - non_schema.append(classname) - else: - for b in cls.__mro__: - if schema.Base in b.__bases__: - non_schema.append(name_of(b)) - derived_non_schema.append(classname) - continue - - try: - item = schema.itemFor(cls) - except: - unloadable.append(classname) - continue - - _hash = item.hashItem() - attrs = item_names_of(item,'attributes') - clouds = item_names_of(item,'clouds') - supers = [sk.itsName for sk in item.superKinds] - - for kind in kinds: - if kind.itsPath<>item.itsPath: - diff_path.append(classname) - if kind.itsName<>item.itsName: - print - print classname, "has a different name than", kind.itsPath - - if attrs<>item_names_of(kind,'attributes'): - diff_attrs.append(classname) - else: - for attr in attrs: - a_item = item.attributes.getByAlias(attr) - a_kind = kind.attributes.getByAlias(attr) - if a_item.hashItem() <> a_kind.hashItem(): - mismatch(classname,"attributes",attr) - - if clouds<>item_names_of(kind,'clouds'): - diff_clouds.append(classname) - else: - for cloud in clouds: - e_item = item_names_of(item.clouds.getByAlias(cloud),'endpoints') - e_kind = item_names_of(kind.clouds.getByAlias(cloud),'endpoints') - if e_item<>e_kind: - mismatch(classname,"clouds",cloud) - # else: check endpoint details against each other - - if supers<>[sk.itsName for sk in kind.superKinds]: - diff_supers.append(classname) - - - -def report(title,items): - if items: - print - print - print title - for name in sorted(items): - print " ",name - -for title,items in [ - ("Other kinds that need a class created for them", missing), - ("Classes that should subclass schema.Item",non_schema), - ("Classes that inherit from classes that should subclass schema.Item", - derived_non_schema), - ("Classes whose schema couldn't be loaded (e.g. due to name conflicts)", - unloadable), - ("Classes whose path isn't correct (missing/wrong __parcel__?)", - diff_path), - ("Classes whose superclasses don't match their parcel.xml superKinds", - diff_supers), - ("Classes with different or missing attributes (compared to parcel.xml)", - diff_attrs), - ("Classes with different or missing clouds (compared to parcel.xml)", - diff_clouds), -]: - items = set(items) - bad |= items - report(title,items) - -for modname,classnames in imports_needed.items(): - report("Classes that should be imported by "+modname+":", classnames) - bad |= set(classnames) - - - -def report_details(clsname): - for name, items in details[clsname].items(): - report( - "Inconsistent %s for %s:" % (name,clsname), - items - ) - bad.add(clsname) - del details[clsname] - - -for name, ob in report_on: - if ob in classKinds: - report_details(name_of(ob)) - else: - prefix = name+'.' - for clsname,info in details.items(): - if clsname.startswith(prefix): - report_details(clsname) - -report( - "Classes w/other issues (use names as arguments, to get more details):", - details -) -bad |= set(details) - -good = all - bad -report( - "Ready to add optional metadata, then remove from parcel.xml", - good -) - -print -print -print len(classKinds), "classes for", len(allKinds), -print "kinds (%s good)" % len(good) -
Copied: trunk/chandler/tools/run_tests.py (from rev 11238, trunk/chandler/run_tests.py) ( => )
_______________________________________________ Commits mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/commits
