@@ -0,0 +1,1792 @@
+#!/usr/bin/env python%0A%22%22%22%0ATests a .whl file by installing it and pytest into a virtual environment and%0Arunning the test suite.%0A%0ARequires pip to be installed, as well as 'virtualenv' on Python 2.%0A%22%22%22%0A%0Aimport os%0Aimport sys%0Aimport shutil%0Aimport subprocess%0Aimport tempfile%0Afrom optparse import OptionParser%0A%0A%0Adef test_wheel(wheel, verbose=False):%0A    envdir = tempfile.mkdtemp(prefix=%22venv-%22)%0A    print(%22Setting up virtual environment in %7B0%7D%22.format(envdir))%0A%0A    if sys.version_info %3E= (3, 0):%0A        subprocess.call(%5Bsys.executable, %22-m%22, %22venv%22, %22--clear%22, envdir%5D)%0A    else:%0A        subprocess.call(%5Bsys.executable, %22-m%22, %22virtualenv%22, %22--clear%22, envdir%5D)%0A%0A    # Install pytest into the environment, as well as our wheel.%0A    if sys.platform == %22win32%22:%0A        pip = os.path.join(envdir, %22Scripts%22, %22pip.exe%22)%0A    else:%0A        pip = os.path.join(envdir, %22bin%22, %22pip%22)%0A    if subprocess.call(%5Bpip, %22install%22, %22pytest%22, wheel%5D) != 0:%0A        shutil.rmtree(envdir)%0A        sys.exit(1)%0A%0A    # Run the test suite.%0A    if sys.platform == %22win32%22:%0A        python = os.path.join(envdir, %22Scripts%22, %22python.exe%22)%0A    else:%0A        python = os.path.join(envdir, %22bin%22, %22python%22)%0A    test_cmd = %5Bpython, %22-m%22, %22pytest%22, %22tests%22%5D%0A    if verbose:%0A        test_cmd.append(%22--verbose%22)%0A%0A    exit_code = subprocess.call(test_cmd)%0A    shutil.rmtree(envdir)%0A%0A    if exit_code != 0:%0A        sys.exit(exit_code)%0A%0A%0Aif __name__ == %22__main__%22:%0A    parser = OptionParser(usage=%22%25prog %5Boptions%5D file...%22)%0A    parser.add_option('', '--verbose', dest = 'verbose', help = 'Enable verbose output', action = 'store_true', default = False)%0A    (options, args) = parser.parse_args()%0A%0A    if not args:%0A        parser.print_usage()%0A        sys.exit(1)%0A%0A    for arg in args:%0A        test_wheel(arg, verbose=options.verbose)%0A

Add script to run test suite on a wheel in a virtualenv