[Checkins] SVN: Products.PluginRegistry/trunk/Products/PluginRegistry/ Remove useless testing cruft.
Tres Seaver
tseaver at palladion.com
Thu Jul 1 17:26:06 EDT 2010
Log message for revision 114073:
Remove useless testing cruft.
Changed:
U Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py
D Products.PluginRegistry/trunk/Products/PluginRegistry/utils.py
-=-
Modified: Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py
===================================================================
--- Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py 2010-07-01 21:26:05 UTC (rev 114072)
+++ Products.PluginRegistry/trunk/Products/PluginRegistry/PluginRegistry.py 2010-07-01 21:26:06 UTC (rev 114073)
@@ -14,12 +14,14 @@
""" Classes: PluginRegistry
"""
import logging
+import os
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import manage_users as ManageUsers
from Acquisition import aq_parent
from Acquisition import aq_inner
from App.class_init import default__class_init__ as InitializeClass
+from App.Common import package_home
from App.ImageFile import ImageFile
from OFS.SimpleItem import SimpleItem
from Persistence import PersistentMapping
@@ -36,8 +38,11 @@
else:
_HAS_GENERIC_SETUP = True
-from Products.PluginRegistry.utils import _wwwdir
+product_dir = package_home(globals())
+product_prefix = os.path.join(os.path.split(product_dir)[:-1])
+_wwwdir = os.path.join( product_dir, 'www' )
+
logger = logging.getLogger('PluginRegistry')
class PluginRegistry(SimpleItem):
Deleted: Products.PluginRegistry/trunk/Products/PluginRegistry/utils.py
===================================================================
--- Products.PluginRegistry/trunk/Products/PluginRegistry/utils.py 2010-07-01 21:26:05 UTC (rev 114072)
+++ Products.PluginRegistry/trunk/Products/PluginRegistry/utils.py 2010-07-01 21:26:06 UTC (rev 114073)
@@ -1,132 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001 Zope Foundation and Contributors
-# Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL). A copy of the ZPL should accompany this
-# distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-import os
-import unittest
-
-from App.Common import package_home
-
-product_dir = package_home( globals() )
-product_prefix = os.path.join( os.path.split(product_dir)[:-1] )
-
-_wwwdir = os.path.join( product_dir, 'www' )
-
-#
-# Most of this module is shamelessly ripped off from Zope3.test
-#
-def remove_stale_bytecode( arg, dirname, names ):
- """
- Troll product, removing compiled turds whose source is now gone.
- """
- names = map( os.path.normcase, names )
-
- for name in names:
-
- if name.endswith( ".pyc" ) or name.endswith( ".pyo" ):
-
- srcname = name[:-1]
-
- if srcname not in names:
-
- fullname = os.path.join( dirname, name )
-
- if __debug__:
- print "Removing stale bytecode file", fullname
-
- os.unlink( fullname )
-
-class TestFileFinder:
-
- def __init__( self ):
- self.files = []
-
- def visit( self, prefix, dir, files ):
- """
- Visitor for os.path.walk: accumulates filenamse of unittests.
- """
- #if dir[-5:] != "tests":
- # return
-
- # ignore tests that aren't in packages
- if not "__init__.py" in files:
-
- if not files or files == ['CVS']:
- return
-
- if 0 and __debug__: # XXX: don't care!
- print "not a package", dir
-
- return
-
- for file in files:
-
- if file.startswith( prefix ) and file.endswith( ".py" ):
- path = os.path.join(dir, file)
- self.files.append(path)
-
-def find_unit_test_files( from_dir=product_dir, test_prefix='test' ):
- """
- Walk the product, return a list of all unittest files.
- """
- finder = TestFileFinder()
- os.path.walk( from_dir, finder.visit, test_prefix )
- return finder.files
-
-def module_name_from_path( path ):
- """
- Return the dotted module name matching the filesystem path.
- """
- assert path.endswith( '.py' )
- path = path[:-3]
- path = path[ len(product_prefix) + 1: ] # strip extraneous crap
- dirs = []
- while path:
- path, end = os.path.split( path )
- dirs.insert( 0, end )
- return ".".join( dirs )
-
-def get_suite( file ):
- """
- Retrieve a TestSuite from 'file'.
- """
- module_name = module_name_from_path( file )
- loader = unittest.defaultTestLoader
- try:
- suite = loader.loadTestsFromName( '%s.test_suite' % module_name )
- except AttributeError:
-
- try:
- suite = loader.loadTestsFromName( module_name )
- except ImportError, err:
- print "Error importing %s\n%s" % (module_name, err)
- raise
- return suite
-
-def allTests( from_dir=product_dir, test_prefix='test' ):
- """
- Walk the product and build a unittest.TestSuite aggregating tests.
- """
- os.path.walk( from_dir, remove_stale_bytecode, None )
- test_files = find_unit_test_files( from_dir, test_prefix )
- test_files.sort()
-
- suite = unittest.TestSuite()
-
- for test_file in test_files:
-
- s = get_suite( test_file )
- if s is not None:
- suite.addTest( s )
-
- return suite
More information about the checkins
mailing list