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
a5c38466
Unverified
Commit
a5c38466
authored
Jan 15, 2023
by
Beryl S
Committed by
GitHub
Jan 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
uploader: fix HTTP status code handling for redirects (#7160)
parent
df9d3c91
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
+27
-1
src/poetry/publishing/uploader.py
+1
-1
tests/publishing/test_uploader.py
+26
-0
No files found.
src/poetry/publishing/uploader.py
View file @
a5c38466
...
...
@@ -266,7 +266,7 @@ class Uploader:
f
" - Uploading <c1>{file.name}</c1> <fg=green>
%
percent
%%
</>"
)
bar
.
finish
()
elif
resp
.
status_code
==
301
:
elif
300
<=
resp
.
status_code
<
400
:
if
self
.
_io
.
output
.
is_decorated
():
self
.
_io
.
overwrite
(
f
" - Uploading <c1>{file.name}</c1> <error>FAILED</>"
...
...
tests/publishing/test_uploader.py
View file @
a5c38466
...
...
@@ -65,6 +65,32 @@ def test_uploader_properly_handles_nonstandard_errors(
assert
str
(
e
.
value
)
==
f
"HTTP Error 400: Bad Request | {content}"
@pytest.mark.parametrize
(
"status, body"
,
[
(
308
,
"Permanent Redirect"
),
(
307
,
"Temporary Redirect"
),
(
304
,
"Not Modified"
),
(
303
,
"See Other"
),
(
302
,
"Found"
),
(
301
,
"Moved Permanently"
),
(
300
,
"Multiple Choices"
),
],
)
def
test_uploader_properly_handles_redirects
(
http
:
type
[
httpretty
.
httpretty
],
uploader
:
Uploader
,
status
:
int
,
body
:
str
):
http
.
register_uri
(
http
.
POST
,
"https://foo.com"
,
status
=
status
,
body
=
body
)
with
pytest
.
raises
(
UploadError
)
as
e
:
uploader
.
upload
(
"https://foo.com"
)
assert
(
str
(
e
.
value
)
==
"Redirects are not supported. Is the URL missing a trailing slash?"
)
def
test_uploader_properly_handles_301_redirects
(
http
:
type
[
httpretty
.
httpretty
],
uploader
:
Uploader
):
...
...
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