~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/__init__.py

  • Committer: Francis J. Lacoste
  • Date: 2011-07-08 20:31:48 UTC
  • mfrom: (13397 devel)
  • mto: This revision was merged to the branch mainline in revision 13501.
  • Revision ID: francis.lacoste@canonical.com-20110708203148-mzcn7o91cn2nm830
Merge devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    datetime,
57
57
    timedelta,
58
58
    )
 
59
from fnmatch import fnmatchcase
59
60
from inspect import (
60
61
    getargspec,
61
62
    getmro,
931
932
def build_yui_unittest_suite(app_testing_path, yui_test_class):
932
933
    suite = unittest.TestSuite()
933
934
    testing_path = os.path.join(config.root, 'lib', app_testing_path)
934
 
    unit_test_names = [
935
 
        file_name for file_name in os.listdir(testing_path)
936
 
        if file_name.startswith('test_') and file_name.endswith('.html')]
937
 
    for unit_test_name in unit_test_names:
938
 
        test_path = os.path.join(app_testing_path, unit_test_name)
 
935
    unit_test_names = _harvest_yui_test_files(testing_path)
 
936
    for unit_test_path in unit_test_names:
939
937
        test_case = yui_test_class()
940
 
        test_case.initialize(test_path)
 
938
        test_case.initialize(unit_test_path)
941
939
        suite.addTest(test_case)
942
940
    return suite
943
941
 
944
942
 
 
943
def _harvest_yui_test_files(file_path):
 
944
    for dirpath, dirnames, filenames in os.walk(file_path):
 
945
        for filename in filenames:
 
946
            if fnmatchcase(filename, "test_*.html"):
 
947
                yield os.path.join(dirpath, filename)
 
948
 
 
949
 
945
950
class ZopeTestInSubProcess:
946
951
    """Run tests in a sub-process, respecting Zope idiosyncrasies.
947
952