Commit 2e077b73 authored by Sviatoslav Sydorenko's avatar Sviatoslav Sydorenko

Make `test_pip_upgrade_from_source` xdist-friendly

parent 08ded165
import pathlib
import shutil
import pytest
from . import contexts
SRC_DIR = pathlib.Path(__file__).parents[2]
@pytest.fixture
def user_override(monkeypatch):
"""
......@@ -21,3 +27,25 @@ def user_override(monkeypatch):
def tmpdir_cwd(tmpdir):
with tmpdir.as_cwd() as orig:
yield orig
@pytest.fixture
def src_dir():
"""The project source directory available via fixture."""
return SRC_DIR
@pytest.fixture
def tmp_src(src_dir, tmp_path):
"""Make a copy of the source dir under `$tmp/src`.
This fixture is useful whenever it's necessary to run `setup.py`
or `pip install` against the source directory when there's no
control over the number of simultaneous invocations. Such
concurrent runs create and delete directories with the same names
under the target directory and so they influence each other's runs
when they are not being executed sequentially.
"""
tmp_src_path = tmp_path / 'src'
shutil.copytree(src_dir, tmp_src_path)
return tmp_src_path
......@@ -85,7 +85,7 @@ def _get_pip_versions():
@pytest.mark.parametrize('pip_version', _get_pip_versions())
def test_pip_upgrade_from_source(pip_version, virtualenv):
def test_pip_upgrade_from_source(pip_version, tmp_src, virtualenv):
"""
Check pip can upgrade setuptools from source.
"""
......@@ -104,7 +104,7 @@ def test_pip_upgrade_from_source(pip_version, virtualenv):
virtualenv.run(' && '.join((
'python setup.py -q sdist -d {dist}',
'python setup.py -q bdist_wheel -d {dist}',
)).format(dist=dist_dir), cd=SOURCE_DIR)
)).format(dist=dist_dir), cd=tmp_src)
sdist = glob.glob(os.path.join(dist_dir, '*.zip'))[0]
wheel = glob.glob(os.path.join(dist_dir, '*.whl'))[0]
# Then update from wheel.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment