File: all_cmf_tests.py

package info (click to toggle)
zope-cmf 1.3.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,540 kB
  • ctags: 2,579
  • sloc: python: 16,976; sh: 51; makefile: 41
file content (80 lines) | stat: -rw-r--r-- 1,639 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /usr/bin/env python
import unittest
import sys

#                  PackageName     Required?
CMF_PACKAGES = [ ( 'CMFCore',       1 )
               , ( 'CMFDefault',    1 )
               , ( 'CMFTopic',      1 )
               , ( 'CMFCalendar',   0 )
               , ( 'DCWorkflow',    0 )
               ]

PACKAGES_UNDER_TEST = []

def test_suite():

    import Zope

    try:
        Zope.startup()
    except AttributeError:  # Zope <= 2.6.0
        pass

    from Products.CMFCore.tests.base.utils import build_test_suite

    suite = unittest.TestSuite()

    packages = PACKAGES_UNDER_TEST or CMF_PACKAGES

    for package_name, required in packages:
        dotted = 'Products.%s.tests' % package_name
        suite.addTest( build_test_suite( dotted
                                       , [ 'test_all' ]
                                       , required=required
                                       ) )

    return suite

def usage():

    USAGE = """\
all_cmf_tests.py [-?] <package_name>*

where

  package_name is the list of packages to be tested
  default: %s
"""

    print USAGE % CMF_PACKAGES
    sys.exit( 2 )

def main():

    import getopt

    try:
        opts, args = getopt.getopt( sys.argv[1:], 'v?' )
    except getopt.GetoptError:
        usage()

    sys.argv[ 1: ] = []
    PASSTHROUGH = ( '-v', )

    for k, v in opts:

        if k in PASSTHROUGH:
            sys.argv.append( k )

        if k == '-?' or k == '--help':
            usage()

    for arg in args:
        PACKAGES_UNDER_TEST.append( ( arg, 1 ) )

    unittest.main(defaultTest='test_suite')

if __name__ == '__main__':

    main()