forked from pypa/virtualenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pinned version are not working once periodic / manual updates ki…
…ck-in Fixes pypa#2203
- Loading branch information
Showing
4 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
from virtualenv.app_data import AppDataDiskFolder | ||
from virtualenv.seed.wheels.bundle import from_bundle | ||
from virtualenv.seed.wheels.embed import get_embed_wheel | ||
from virtualenv.seed.wheels.util import Version, Wheel | ||
from virtualenv.util.path import Path | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def next_pip_wheel(for_py_version): | ||
wheel = get_embed_wheel("pip", for_py_version) | ||
new_version = list(wheel.version_tuple) | ||
new_version[-1] += 1 | ||
new_name = wheel.name.replace(wheel.version, ".".join(str(i) for i in new_version)) | ||
return Wheel.from_path(Path(new_name)) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def app_data(tmp_path_factory, for_py_version, next_pip_wheel): | ||
temp_folder = tmp_path_factory.mktemp("module-app-data") | ||
app_data_ = AppDataDiskFolder(str(temp_folder)) | ||
app_data_.embed_update_log("pip", for_py_version).write( | ||
{ | ||
"completed": "2000-01-01T00:00:00.000000Z", | ||
"periodic": True, | ||
"started": "2000-01-01T00:00:00.000000Z", | ||
"versions": [ | ||
{ | ||
"filename": next_pip_wheel.name, | ||
"found_date": "2000-01-01T00:00:00.000000Z", | ||
"release_date": "2000-01-01T00:00:00.000000Z", | ||
} | ||
], | ||
} | ||
) | ||
yield app_data_ | ||
|
||
|
||
def test_version_embed(app_data, for_py_version): | ||
wheel = from_bundle("pip", Version.embed, for_py_version, [], app_data, False, os.environ) | ||
assert wheel is not None | ||
assert wheel.name == get_embed_wheel("pip", for_py_version).name | ||
|
||
|
||
def test_version_bundle(app_data, for_py_version, next_pip_wheel): | ||
wheel = from_bundle("pip", Version.bundle, for_py_version, [], app_data, False, os.environ) | ||
assert wheel is not None | ||
assert wheel.name == next_pip_wheel.name | ||
|
||
|
||
def test_version_pinned_not_found(app_data, for_py_version): | ||
wheel = from_bundle("pip", "0.0.0", for_py_version, [], app_data, False, os.environ) | ||
assert wheel is None | ||
|
||
|
||
def test_version_pinned_is_embed(app_data, for_py_version): | ||
expected_wheel = get_embed_wheel("pip", for_py_version) | ||
wheel = from_bundle("pip", expected_wheel.version, for_py_version, [], app_data, False, os.environ) | ||
assert wheel is not None | ||
assert wheel.name == expected_wheel.name | ||
|
||
|
||
def test_version_pinned_in_app_data(app_data, for_py_version, next_pip_wheel): | ||
wheel = from_bundle("pip", next_pip_wheel.version, for_py_version, [], app_data, False, os.environ) | ||
assert wheel is not None | ||
assert wheel.name == next_pip_wheel.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters