Skip to content

Commit

Permalink
Update tests for new resolver compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Dec 27, 2020
1 parent fd7c864 commit 4a6be49
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
23 changes: 21 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,28 @@

@pytest.fixture
def virtualenv_python(tmp_path):
"""Return a python executable path within an isolated virtualenv."""
"""Return a python executable path within an isolated virtualenv, using a pip
version that has the new resolver."""
venv = tmp_path / "venv"
subprocess.check_call([sys.executable, "-m", "virtualenv", str(venv)])
subprocess.check_call(
# TODO remove pip version pin
[sys.executable, "-m", "virtualenv", "--pip", "20.3.3", str(venv)]
)
if os.name == "nt":
python = venv / "Scripts" / "python.exe"
else:
python = venv / "bin" / "python"
return str(python)


@pytest.fixture
def virtualenv_python_legacy_resolver(tmp_path):
"""Return a python executable path within an isolated virtualenv, using a pip
version that has the legacy resolver."""
venv = tmp_path / "venv"
subprocess.check_call(
[sys.executable, "-m", "virtualenv", "--pip", "20.2.4", str(venv)]
)
if os.name == "nt":
python = venv / "Scripts" / "python.exe"
else:
Expand Down
16 changes: 11 additions & 5 deletions tests/test_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ def test_pip_upgrade_constraint_not_a_dep(virtualenv_python, testpkgs, tmp_path)
assert list(_freeze_filter(pip_freeze(virtualenv_python))) == []


def test_pip_upgrade_vcs_url(virtualenv_python, tmp_path):
def test_pip_upgrade_vcs_url(virtualenv_python_legacy_resolver, tmp_path):
"""Test upgrading a VCS URL."""
# TODO use the legacy resolver until pip supports URL constraints again
# (https://github.com/pypa/pip/issues/8253)
constraints = tmp_path / "requirements.txt.df"
(tmp_path / "setup.py").write_text(
textwrap.dedent(
Expand All @@ -286,15 +288,19 @@ def test_pip_upgrade_vcs_url(virtualenv_python, tmp_path):
)
# install tag 0.10.0
constraints.write_text("--no-index\ntoml @ git+https://github.com/uiri/toml@0.10.0")
pip_upgrade_project(virtualenv_python, constraints, project_root=tmp_path)
assert list(_freeze_filter(pip_freeze(virtualenv_python))) == [
pip_upgrade_project(
virtualenv_python_legacy_resolver, constraints, project_root=tmp_path
)
assert list(_freeze_filter(pip_freeze(virtualenv_python_legacy_resolver))) == [
"toml @ git+https://github.com/uiri/toml"
"@4935f616ef78c35a968b2473e806d7049eba9af1"
]
# upgrade to tag 0.10.1
constraints.write_text("toml @ git+https://github.com/uiri/toml@0.10.1")
pip_upgrade_project(virtualenv_python, constraints, project_root=tmp_path)
assert list(_freeze_filter(pip_freeze(virtualenv_python))) == [
pip_upgrade_project(
virtualenv_python_legacy_resolver, constraints, project_root=tmp_path
)
assert list(_freeze_filter(pip_freeze(virtualenv_python_legacy_resolver))) == [
"toml @ git+https://github.com/uiri/toml"
"@a86fc1fbd650a19eba313c3f642c9e2c679dc8d6"
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pip_list_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"requires": ["pkga"],
},
{"metadata": {"name": "pkgc", "version": "0.0.3"}},
{"metadata": {"name": "pkgc", "version": "0.0.2"}},
{
"metadata": {
"name": "pkgd",
Expand Down

0 comments on commit 4a6be49

Please sign in to comment.