diff --git a/bin/run_test.py b/bin/run_test.py index 746061c4..cbf8bee3 100755 --- a/bin/run_test.py +++ b/bin/run_test.py @@ -3,10 +3,20 @@ from __future__ import print_function import os, sys, subprocess, shutil +project_root = os.path.dirname(os.path.dirname(__file__)) +test_utils_dir = os.path.join(project_root, 'test', 'shared') + def single_run(test_project): + # set up an environment that gives access to the test utils + env = os.environ.copy() + env.update({ + 'PYTHONPATH': test_utils_dir, + }) + # run the test subprocess.check_call( - [sys.executable, '-m', 'pytest', '-v', os.path.join(test_project, 'cibuildwheel_test.py')] + [sys.executable, '-m', 'pytest', '-v', os.path.join(test_project, 'cibuildwheel_test.py')], + env=env, ) # clean up diff --git a/test/01_basic/cibuildwheel_test.py b/test/01_basic/cibuildwheel_test.py index 28b83184..008b8086 100644 --- a/test/01_basic/cibuildwheel_test.py +++ b/test/01_basic/cibuildwheel_test.py @@ -1,11 +1,10 @@ import subprocess, sys, os from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) - import utils def test(): + project_dir = os.path.dirname(__file__) + # build the wheels subprocess.check_call([sys.executable, '-m', 'cibuildwheel', project_dir]) diff --git a/test/02_test/cibuildwheel_test.py b/test/02_test/cibuildwheel_test.py index b6518cb1..9ec4fa56 100644 --- a/test/02_test/cibuildwheel_test.py +++ b/test/02_test/cibuildwheel_test.py @@ -1,11 +1,9 @@ import subprocess, sys, os from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) - import utils def test(): + project_dir = os.path.dirname(__file__) # set up the environment env = os.environ.copy() env['CIBW_TEST_REQUIRES'] = 'nose' diff --git a/test/03_before_build/cibuildwheel_test.py b/test/03_before_build/cibuildwheel_test.py index 9caec0a8..5ce69243 100644 --- a/test/03_before_build/cibuildwheel_test.py +++ b/test/03_before_build/cibuildwheel_test.py @@ -1,11 +1,9 @@ import subprocess, sys, os from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) - import utils def test(): + project_dir = os.path.dirname(__file__) # set up the environment env = os.environ.copy() # write python version information to a temporary file, this is checked diff --git a/test/04_build_skip/cibuildwheel_test.py b/test/04_build_skip/cibuildwheel_test.py index 5cecd275..db8d4e9a 100644 --- a/test/04_build_skip/cibuildwheel_test.py +++ b/test/04_build_skip/cibuildwheel_test.py @@ -1,11 +1,10 @@ import subprocess, sys, os from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) - import utils def test(): + project_dir = os.path.dirname(__file__) + # set up the environment env = os.environ.copy() env['CIBW_BUILD'] = 'cp3?-*' diff --git a/test/05_environment/cibuildwheel_test.py b/test/05_environment/cibuildwheel_test.py index 3303aaff..7a707d91 100644 --- a/test/05_environment/cibuildwheel_test.py +++ b/test/05_environment/cibuildwheel_test.py @@ -1,10 +1,10 @@ import subprocess, sys, os from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) import utils def test(): + project_dir = os.path.dirname(__file__) + # set up the environment env = os.environ.copy() # write some information into the CIBW_ENVIRONMENT, for expansion and diff --git a/test/06_docker_images/cibuildwheel_test.py b/test/06_docker_images/cibuildwheel_test.py index 51686c78..de65c0e6 100644 --- a/test/06_docker_images/cibuildwheel_test.py +++ b/test/06_docker_images/cibuildwheel_test.py @@ -1,10 +1,9 @@ import subprocess, sys, os, pytest from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) import utils def test(): + project_dir = os.path.dirname(__file__) if not sys.platform.startswith('linux'): pytest.skip('the docker test is only relevant to the linux build') diff --git a/test/07_ssl/cibuildwheel_test.py b/test/07_ssl/cibuildwheel_test.py index ec3cc1aa..97676b3a 100644 --- a/test/07_ssl/cibuildwheel_test.py +++ b/test/07_ssl/cibuildwheel_test.py @@ -1,10 +1,9 @@ import subprocess, sys, os from glob import glob -project_dir = os.path.dirname(__file__) -sys.path.append(os.path.join(os.path.dirname(project_dir), 'shared')) import utils def test(): + project_dir = os.path.dirname(__file__) # this test checks that SSL is working in the build environment using # some checks in setup.py. diff --git a/test/shared/utils.py b/test/shared/utils.py index e4eca4cb..fe5c1743 100644 --- a/test/shared/utils.py +++ b/test/shared/utils.py @@ -1,3 +1,9 @@ +''' +Utility functions used by the cibuildwheel tests. + +This file is added to the PYTHONPATH in the test runner at bin/run_test.py. +''' + import subprocess, sys def cibuildwheel_get_build_identifiers(project_path, env=None):