Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
25d5cb65
Commit
25d5cb65
authored
Jun 02, 2016
by
Berker Peksag
Browse files
Options
Browse Files
Download
Plain Diff
Issue #21776: Merge from 3.5
parents
4f2cc60a
29389166
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
8 deletions
+37
-8
command/upload.py
command/upload.py
+7
-7
tests/test_upload.py
tests/test_upload.py
+30
-1
No files found.
command/upload.py
View file @
25d5cb65
...
@@ -181,21 +181,21 @@ class upload(PyPIRCCommand):
...
@@ -181,21 +181,21 @@ class upload(PyPIRCCommand):
result
=
urlopen
(
request
)
result
=
urlopen
(
request
)
status
=
result
.
getcode
()
status
=
result
.
getcode
()
reason
=
result
.
msg
reason
=
result
.
msg
except
OSError
as
e
:
self
.
announce
(
str
(
e
),
log
.
ERROR
)
raise
except
HTTPError
as
e
:
except
HTTPError
as
e
:
status
=
e
.
code
status
=
e
.
code
reason
=
e
.
msg
reason
=
e
.
msg
except
OSError
as
e
:
self
.
announce
(
str
(
e
),
log
.
ERROR
)
raise
if
status
==
200
:
if
status
==
200
:
self
.
announce
(
'Server response (%s): %s'
%
(
status
,
reason
),
self
.
announce
(
'Server response (%s): %s'
%
(
status
,
reason
),
log
.
INFO
)
log
.
INFO
)
else
:
msg
=
'Upload failed (%s): %s'
%
(
status
,
reason
)
self
.
announce
(
msg
,
log
.
ERROR
)
raise
DistutilsError
(
msg
)
if
self
.
show_response
:
if
self
.
show_response
:
text
=
self
.
_read_pypi_response
(
result
)
text
=
self
.
_read_pypi_response
(
result
)
msg
=
'
\
n
'
.
join
((
'-'
*
75
,
text
,
'-'
*
75
))
msg
=
'
\
n
'
.
join
((
'-'
*
75
,
text
,
'-'
*
75
))
self
.
announce
(
msg
,
log
.
INFO
)
self
.
announce
(
msg
,
log
.
INFO
)
else
:
msg
=
'Upload failed (%s): %s'
%
(
status
,
reason
)
self
.
announce
(
msg
,
log
.
ERROR
)
raise
DistutilsError
(
msg
)
tests/test_upload.py
View file @
25d5cb65
"""Tests for distutils.command.upload."""
"""Tests for distutils.command.upload."""
import
os
import
os
import
unittest
import
unittest
import
unittest.mock
as
mock
from
urllib.request
import
HTTPError
from
test.support
import
run_unittest
from
test.support
import
run_unittest
from
distutils.command
import
upload
as
upload_mod
from
distutils.command
import
upload
as
upload_mod
from
distutils.command.upload
import
upload
from
distutils.command.upload
import
upload
from
distutils.core
import
Distribution
from
distutils.core
import
Distribution
from
distutils.errors
import
DistutilsError
from
distutils.errors
import
DistutilsError
from
distutils.log
import
INFO
from
distutils.log
import
ERROR
,
INFO
from
distutils.tests.test_config
import
PYPIRC
,
PyPIRCCommandTestCase
from
distutils.tests.test_config
import
PYPIRC
,
PyPIRCCommandTestCase
...
@@ -144,6 +147,32 @@ class uploadTestCase(PyPIRCCommandTestCase):
...
@@ -144,6 +147,32 @@ class uploadTestCase(PyPIRCCommandTestCase):
self
.
next_code
=
404
self
.
next_code
=
404
self
.
assertRaises
(
DistutilsError
,
self
.
test_upload
)
self
.
assertRaises
(
DistutilsError
,
self
.
test_upload
)
def
test_wrong_exception_order
(
self
):
tmp
=
self
.
mkdtemp
()
path
=
os
.
path
.
join
(
tmp
,
'xxx'
)
self
.
write_file
(
path
)
dist_files
=
[(
'xxx'
,
'2.6'
,
path
)]
# command, pyversion, filename
self
.
write_file
(
self
.
rc
,
PYPIRC_LONG_PASSWORD
)
pkg_dir
,
dist
=
self
.
create_dist
(
dist_files
=
dist_files
)
tests
=
[
(
OSError
(
'oserror'
),
'oserror'
,
OSError
),
(
HTTPError
(
'url'
,
400
,
'httperror'
,
{},
None
),
'Upload failed (400): httperror'
,
DistutilsError
),
]
for
exception
,
expected
,
raised_exception
in
tests
:
with
self
.
subTest
(
exception
=
type
(
exception
).
__name__
):
with
mock
.
patch
(
'distutils.command.upload.urlopen'
,
new
=
mock
.
Mock
(
side_effect
=
exception
)):
with
self
.
assertRaises
(
raised_exception
):
cmd
=
upload
(
dist
)
cmd
.
ensure_finalized
()
cmd
.
run
()
results
=
self
.
get_logs
(
ERROR
)
self
.
assertIn
(
expected
,
results
[
-
1
])
self
.
clear_logs
()
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
uploadTestCase
)
return
unittest
.
makeSuite
(
uploadTestCase
)
...
...
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