示例#1
0
def getTestConfig(*args):
    cp = config(args[1:])
    try:
        cp.readfp(open(os.path.expandvars('$GIP_LOCATION/etc/gip_tests.conf')))
    except:
        pass

    interpolateConfig(cp)

    section = "gip_tests"
    if not cp.has_section(section):
        cp.add_section(section)

    if py23:
        p = optparse.OptionParser()
        p.add_option('-c', '--config', dest='config', help='Configuration file.', default='gip.conf')
        p.add_option('-f', '--format', dest='format', help='Unittest output format', default='xml')
        (options, args) = p.parse_args()
        xml = options.format
    else:
        keywordOpts, passedOpts, givenOpts = parseOpts(args)
        if keywordOpts["format"]:
             xml = keywordOpts["format"]
        if keywordOpts["f"]:
             xml = keywordOpts["f"]

    try:
        if xml == "xml":
            cp.set(section, "use_xml", "True")
        else:
            cp.set(section, "use_xml", "False")
    except:
        cp.set(section, "use_xml", "False")

    return cp
示例#2
0
def getTestConfig(*args):
    cp = config(args[1:])
    try:
        cp.readfp(open(os.path.expandvars('$GIP_LOCATION/etc/gip_tests.conf')))
    except:
        pass

    interpolateConfig(cp)

    section = "gip_tests"
    if not cp.has_section(section):
        cp.add_section(section)

    if py23:
        p = optparse.OptionParser()
        p.add_option('-c',
                     '--config',
                     dest='config',
                     help='Configuration file.',
                     default='gip.conf')
        p.add_option('-f',
                     '--format',
                     dest='format',
                     help='Unittest output format',
                     default='xml')
        (options, args) = p.parse_args()
        xml = options.format
    else:
        keywordOpts, passedOpts, givenOpts = parseOpts(args)
        if keywordOpts["format"]:
            xml = keywordOpts["format"]
        if keywordOpts["f"]:
            xml = keywordOpts["f"]

    try:
        if xml == "xml":
            cp.set(section, "use_xml", "True")
        else:
            cp.set(section, "use_xml", "False")
    except:
        cp.set(section, "use_xml", "False")

    return cp
示例#3
0
def generateTests(cp, cls, args=[]):
    """
    Given a class and args, generate a test case for every site in the BDII.

    @param cp: Site configuration
    @type cp: ConfigParser
    @param cls: Test class to use to generate a test suite.  It is assumed
        that the constructor for this class has signature cls(cp, site_name)
    @type cls: class
    @keyword args: List of sites; if it is not empty, then tests will only be
        generated for the given sites.
    """
    #sites = getSiteList(cp)
    try:
        sites = cp_get(cp, "gip_tests", "site_names", "")
        if len(sites) > 0:
            sites = [i.strip() for i in sites.split(',')]
        else:
            sites = getSiteList(cp)
    except:
        sites = getSiteList(cp)

    kw, passed, args = parseOpts(sys.argv[1:])
    tests = []
    for site in sites:
        if len(args) > 0 and site not in args:
            continue
        if site == 'local' or site == 'grid':
            continue
        case = cls(site, cp)
        
        # try to set the cp object for GipUnittest children.
        #  if not a GipUnittest child, then fail out and continue as normal
        try:
            case.setCp(cp)
        except:
            pass

        tests.append(case)
    return unittest.TestSuite(tests)
示例#4
0
def generateTests(cp, cls, args=[]):
    """
    Given a class and args, generate a test case for every site in the BDII.

    @param cp: Site configuration
    @type cp: ConfigParser
    @param cls: Test class to use to generate a test suite.  It is assumed
        that the constructor for this class has signature cls(cp, site_name)
    @type cls: class
    @keyword args: List of sites; if it is not empty, then tests will only be
        generated for the given sites.
    """
    #sites = getSiteList(cp)
    try:
        sites = cp_get(cp, "gip_tests", "site_names", "")
        if len(sites) > 0:
            sites = [i.strip() for i in sites.split(',')]
        else:
            sites = getSiteList(cp)
    except:
        sites = getSiteList(cp)

    kw, passed, args = parseOpts(sys.argv[1:])
    tests = []
    for site in sites:
        if len(args) > 0 and site not in args:
            continue
        if site == 'local' or site == 'grid':
            continue
        case = cls(site, cp)

        # try to set the cp object for GipUnittest children.
        #  if not a GipUnittest child, then fail out and continue as normal
        try:
            case.setCp(cp)
        except: