-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for installation of the latest pypi version
Uses `pip install foo==` which will output all available versions to STDERR. The last package is then chosen. This API is deprecated ref pypa/pip#9139 but is seemingly kept around until a replacement is made.
- Loading branch information
1 parent
c98e982
commit da07fd0
Showing
7 changed files
with
125 additions
and
3 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
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
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,36 @@ | ||
from komodo.package_version import latest_pypi_version | ||
from subprocess import CalledProcessError | ||
from mock import patch | ||
import pytest | ||
import sys | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"cmd_stderr,expected_version", | ||
[ | ||
( | ||
"""ERROR: Could not find a version that satisfies the requirement equinor_libres== (from versions: 3.3.1a9, 7.2.0b0, 7.2.0rc0, 8.0.0rc0, 8.0.0, 8.0.1, 8.1.0rc0, 9.0.0b0, 9.0.0b1) | ||
ERROR: No matching distribution found for equinor_libres==""", | ||
"9.0.0b1", | ||
), | ||
( | ||
"""ERROR: Could not find a version that satisfies the requirement equinor_libres== (from versions: 0.1.0) | ||
ERROR: No matching distribution found for equinor_libres==""", | ||
"0.1.0", | ||
), | ||
( | ||
"""ERROR: Could not find a version that satisfies the requirement equinor_libres== (from versions: none) | ||
ERROR: No matching distribution found for equinor_libres==""", | ||
None, | ||
), | ||
], | ||
) | ||
def test_latest_pypi_version(cmd_stderr, expected_version): | ||
def _raise(*args, **kwargs): | ||
raise CalledProcessError( | ||
1, "", stderr=bytes(cmd_stderr.encode(sys.getfilesystemencoding())) | ||
) | ||
|
||
with patch("subprocess.check_output") as mock_check_output: | ||
mock_check_output.side_effect = _raise | ||
assert latest_pypi_version("equinor_libres") == expected_version |