def run(tests, verbose=1):
    PIPE = subprocess.PIPE
    errors = []
    total = 0
    tot_err = 0
    tot_fail = 0
    total_time = 0.0
    cmd_base = get_test_runner()
    has_nose = 'nosetests' in cmd_base
    for test in tests:
        if verbose > 1 and has_nose:
            cmd = cmd_base + ['-v', test]
        else:
            cmd = cmd_base + [test]

        # Run the test in a subprocess.
        if verbose > 1:
            print('Running:', ' '.join(cmd))
        t1 = time.time()
        pipe = subprocess.Popen(cmd, stdout=PIPE, stderr=PIPE, close_fds=True)
        # Get the status, stdout and stderr.
        st = pipe.wait()
        t2 = time.time()
        out, err = pipe.communicate()

        # Calculate number of tests run, errors and failures based on output.
        res = re.search('Ran\s*(\d*)\s*test', err)
        nt = 1
        if res:
            nt = int(res.group(1))
        total += nt
        res = re.search('failures=(\d*)', err)
        nfail = 0
        if res:
            nfail = int(res.group(1))
        nerr = 0
        res = re.search('errors=(\d*)', err)
        if res:
            nerr = int(res.group(1))

        tot_err += nerr
        tot_fail += nfail

        # Print output catching any errors.
        if verbose > 0:
            nsuccess = nt - nerr - nfail
            res = '.'*nsuccess + 'F'*nfail + 'E'*nerr
            sys.stdout.write(res)
        if st != 0:
            errors.append([test, st, out, err, t2 - t1])

        if verbose > 1:
            print(out)
            print(err)
        sys.stdout.flush()
        total_time += t2 - t1

    print('\n' + '-'*70)
    print("Ran %d tests in %.4g seconds\n"%(total, total_time))

    errorcode = 0
    if len(errors) > 0:
        print('FAILED: there were %d failures and %d errors'\
                %(tot_fail, tot_err))
        for err in errors:
            test, st, out, err, t = err
            print('File:', test)
            print(out)
            print(err)
        errorcode = 1
    else:
        print('OK')
    return errorcode
Run the given tests.  Each test file is run as a unittest in a
dataset/ETHPy150Open enthought/mayavi/mayavi/tests/runtests.py/run