Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
be4f17f9
Commit
be4f17f9
authored
Jun 13, 2022
by
Randy Döring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chooser: prefer files that are not yanked
parent
b8faa51a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
2 deletions
+101
-2
src/poetry/installation/chooser.py
+1
-2
tests/installation/test_chooser.py
+100
-0
No files found.
src/poetry/installation/chooser.py
View file @
be4f17f9
...
@@ -198,8 +198,7 @@ class Chooser:
...
@@ -198,8 +198,7 @@ class Chooser:
has_allowed_hash
=
int
(
self
.
_is_link_hash_allowed_for_package
(
link
,
package
))
has_allowed_hash
=
int
(
self
.
_is_link_hash_allowed_for_package
(
link
,
package
))
# TODO: Proper yank value
yank_value
=
int
(
not
link
.
yanked
)
yank_value
=
0
return
(
return
(
has_allowed_hash
,
has_allowed_hash
,
...
...
tests/installation/test_chooser.py
View file @
be4f17f9
...
@@ -91,6 +91,26 @@ def mock_legacy(http: type[httpretty.httpretty]) -> None:
...
@@ -91,6 +91,26 @@ def mock_legacy(http: type[httpretty.httpretty]) -> None:
@pytest.fixture
()
@pytest.fixture
()
def
mock_legacy_partial_yank
(
http
:
type
[
httpretty
.
httpretty
])
->
None
:
def
callback
(
request
:
HTTPrettyRequest
,
uri
:
str
,
headers
:
dict
[
str
,
Any
]
)
->
list
[
int
|
dict
[
str
,
Any
]
|
str
]:
parts
=
uri
.
rsplit
(
"/"
)
name
=
parts
[
-
2
]
fixture
=
LEGACY_FIXTURES
/
(
name
+
"_partial_yank"
+
".html"
)
with
fixture
.
open
(
encoding
=
"utf-8"
)
as
f
:
return
[
200
,
headers
,
f
.
read
()]
http
.
register_uri
(
http
.
GET
,
re
.
compile
(
"^https://foo2.bar/simple/(.+?)$"
),
body
=
callback
,
)
@pytest.fixture
()
def
pool
()
->
Pool
:
def
pool
()
->
Pool
:
pool
=
Pool
()
pool
=
Pool
()
...
@@ -98,6 +118,9 @@ def pool() -> Pool:
...
@@ -98,6 +118,9 @@ def pool() -> Pool:
pool
.
add_repository
(
pool
.
add_repository
(
LegacyRepository
(
"foo"
,
"https://foo.bar/simple/"
,
disable_cache
=
True
)
LegacyRepository
(
"foo"
,
"https://foo.bar/simple/"
,
disable_cache
=
True
)
)
)
pool
.
add_repository
(
LegacyRepository
(
"foo2"
,
"https://foo2.bar/simple/"
,
disable_cache
=
True
)
)
return
pool
return
pool
...
@@ -267,6 +290,83 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes(
...
@@ -267,6 +290,83 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes(
@pytest.mark.parametrize
(
"source_type"
,
[
""
,
"legacy"
])
@pytest.mark.parametrize
(
"source_type"
,
[
""
,
"legacy"
])
def
test_chooser_chooses_yanked_if_no_others
(
env
:
MockEnv
,
mock_pypi
:
None
,
mock_legacy
:
None
,
source_type
:
str
,
pool
:
Pool
,
)
->
None
:
chooser
=
Chooser
(
pool
,
env
)
package
=
Package
(
"black"
,
"21.11b0"
)
files
=
[
{
"filename"
:
"black-21.11b0-py3-none-any.whl"
,
"hash"
:
"sha256:0b1f66cbfadcd332ceeaeecf6373d9991d451868d2e2219ad0ac1213fb701117"
,
# noqa: E501
}
]
if
source_type
==
"legacy"
:
package
=
Package
(
package
.
name
,
package
.
version
.
text
,
source_type
=
"legacy"
,
source_reference
=
"foo"
,
source_url
=
"https://foo.bar/simple/"
,
)
package
.
files
=
files
link
=
chooser
.
choose_for
(
package
)
assert
link
.
filename
==
"black-21.11b0-py3-none-any.whl"
assert
link
.
yanked
def
test_chooser_does_not_choose_yanked_if_others
(
mock_legacy
:
None
,
mock_legacy_partial_yank
:
None
,
pool
:
Pool
,
)
->
None
:
chooser
=
Chooser
(
pool
,
MockEnv
(
supported_tags
=
[
Tag
(
"py2"
,
"none"
,
"any"
)]))
package
=
Package
(
"futures"
,
"3.2.0"
)
files
=
[
{
"filename"
:
"futures-3.2.0-py2-none-any.whl"
,
"hash"
:
"sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1"
,
# noqa: E501
},
{
"filename"
:
"futures-3.2.0.tar.gz"
,
"hash"
:
"sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265"
,
# noqa: E501
},
]
package
=
Package
(
package
.
name
,
package
.
version
.
text
,
source_type
=
"legacy"
,
source_reference
=
"foo"
,
source_url
=
"https://foo.bar/simple/"
,
)
package_partial_yank
=
Package
(
package
.
name
,
package
.
version
.
text
,
source_type
=
"legacy"
,
source_reference
=
"foo2"
,
source_url
=
"https://foo2.bar/simple/"
,
)
package
.
files
=
files
package_partial_yank
.
files
=
files
link
=
chooser
.
choose_for
(
package
)
link_partial_yank
=
chooser
.
choose_for
(
package_partial_yank
)
assert
link
.
filename
==
"futures-3.2.0-py2-none-any.whl"
assert
link_partial_yank
.
filename
==
"futures-3.2.0.tar.gz"
@pytest.mark.parametrize
(
"source_type"
,
[
""
,
"legacy"
])
def
test_chooser_throws_an_error_if_package_hashes_do_not_match
(
def
test_chooser_throws_an_error_if_package_hashes_do_not_match
(
env
:
MockEnv
,
env
:
MockEnv
,
mock_pypi
:
None
,
mock_pypi
:
None
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment