diff options
| author | Alex Grönholm <alex.gronholm@nextday.fi> | 2018-07-14 18:56:02 +0300 |
|---|---|---|
| committer | Alex Grönholm <alex.gronholm@nextday.fi> | 2018-07-17 15:02:50 +0300 |
| commit | e90cabb29e8e7ed89c6fa4ebfca5183433e134b6 (patch) | |
| tree | a11fa977ff41ca27dec7921961e89e433950f989 /tests/conftest.py | |
| parent | 4900abb3db380aaa2e49c035c4f54b7b3b14feab (diff) | |
| download | wheel-git-e90cabb29e8e7ed89c6fa4ebfca5183433e134b6.tar.gz | |
Build wheels into a temporary directory in the test setup phase
This avoids polluting the project directory and also avoids unicode issues when a py3 test suite encounters a unicode containing wheel.
Diffstat (limited to 'tests/conftest.py')
| -rw-r--r-- | tests/conftest.py | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 18cd748..1b8aa99 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,42 +5,33 @@ pytest local configuration plug-in import os.path import subprocess import sys -from shutil import rmtree import pytest @pytest.fixture(scope='session') -def wheels_and_eggs(): +def wheels_and_eggs(tmpdir_factory): """Build wheels and eggs from test distributions.""" test_distributions = "complex-dist", "simple.dist", "headers.dist", "unicode.dist" - files = [] pwd = os.path.abspath(os.curdir) this_dir = os.path.dirname(__file__) + build_dir = tmpdir_factory.mktemp('build') + dist_dir = tmpdir_factory.mktemp('dist') for dist in test_distributions: os.chdir(os.path.join(this_dir, 'testdata', dist)) - subprocess.check_call([sys.executable, 'setup.py', 'bdist_egg', 'bdist_wheel']) - dist_path = os.path.join(os.curdir, 'dist') - files.extend([os.path.abspath(os.path.join(dist_path, fname)) - for fname in os.listdir(dist_path) - if os.path.splitext(fname)[1] in ('.whl', '.egg')]) + subprocess.check_call([sys.executable, 'setup.py', + 'bdist_egg', '-b', str(build_dir), '-d', str(dist_dir), + 'bdist_wheel', '-b', str(build_dir), '-d', str(dist_dir)]) os.chdir(pwd) - yield files - - for dist in test_distributions: - for subdir in ('build', 'dist'): - try: - rmtree(os.path.join(this_dir, dist, subdir)) - except OSError: - pass + return sorted(str(fname) for fname in dist_dir.listdir() if fname.ext in ('.whl', '.egg')) @pytest.fixture(scope='session') def wheel_paths(wheels_and_eggs): - return sorted(fname for fname in wheels_and_eggs if fname.endswith('.whl')) + return [fname for fname in wheels_and_eggs if fname.endswith('.whl')] @pytest.fixture(scope='session') def egg_paths(wheels_and_eggs): - return sorted(fname for fname in wheels_and_eggs if fname.endswith('.egg')) + return [fname for fname in wheels_and_eggs if fname.endswith('.egg')] |
