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
6880fd6f
Commit
6880fd6f
authored
Jul 24, 2020
by
Sébastien Eustace
Committed by
Arun Babu Neelicattu
Jul 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors on Python 2.7 when a file could not be downloaded
parent
02d4d0c4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletions
+39
-1
poetry/installation/executor.py
+5
-1
tests/installation/test_executor.py
+34
-0
No files found.
poetry/installation/executor.py
View file @
6880fd6f
...
...
@@ -583,7 +583,11 @@ class Executor(object):
archive
=
self
.
_download_archive
(
operation
,
link
)
except
BaseException
:
cache_directory
=
self
.
_chef
.
get_cache_directory_for_link
(
link
)
cache_directory
.
joinpath
(
link
.
filename
)
.
unlink
(
missing_ok
=
True
)
cached_file
=
cache_directory
.
joinpath
(
link
.
filename
)
# We can't use unlink(missing_ok=True) because it's not available
# in pathlib2 for Python 2.7
if
cached_file
.
exists
():
cached_file
.
unlink
()
raise
...
...
tests/installation/test_executor.py
View file @
6880fd6f
...
...
@@ -2,6 +2,7 @@
from
__future__
import
unicode_literals
import
re
import
shutil
import
pytest
...
...
@@ -179,3 +180,36 @@ Package operations: 1 install, 0 updates, 0 removals
"""
assert
expected
==
io
.
fetch_output
()
def
test_executor_should_delete_incomplete_downloads
(
config
,
io
,
tmp_dir
,
mocker
,
pool
,
mock_file_downloads
):
fixture
=
Path
(
__file__
)
.
parent
.
parent
.
joinpath
(
"fixtures/distributions/demo-0.1.0-py2.py3-none-any.whl"
)
destination_fixture
=
Path
(
tmp_dir
)
/
"tomlkit-0.5.3-py2.py3-none-any.whl"
shutil
.
copyfile
(
str
(
fixture
),
str
(
destination_fixture
))
mocker
.
patch
(
"poetry.installation.executor.Executor._download_archive"
,
side_effect
=
Exception
(
"Download error"
),
)
mocker
.
patch
(
"poetry.installation.chef.Chef.get_cached_archive_for_link"
,
side_effect
=
lambda
link
:
link
,
)
mocker
.
patch
(
"poetry.installation.chef.Chef.get_cache_directory_for_link"
,
return_value
=
Path
(
tmp_dir
),
)
config
=
Config
()
config
.
merge
({
"cache-dir"
:
tmp_dir
})
env
=
MockEnv
(
path
=
Path
(
tmp_dir
))
executor
=
Executor
(
env
,
pool
,
config
,
io
)
with
pytest
.
raises
(
Exception
,
match
=
"Download error"
):
executor
.
_download
(
Install
(
Package
(
"tomlkit"
,
"0.5.3"
)))
assert
not
destination_fixture
.
exists
()
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