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
b7a6d8ad
Commit
b7a6d8ad
authored
Oct 28, 2018
by
Paul Ganssle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add failing test for issue #1381
parent
83fb2385
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
setuptools/tests/test_upload.py
setuptools/tests/test_upload.py
+59
-0
No files found.
setuptools/tests/test_upload.py
View file @
b7a6d8ad
import
mock
import
os
import
re
from
distutils
import
log
from
distutils.version
import
StrictVersion
import
pytest
import
six
from
setuptools.command.upload
import
upload
from
setuptools.dist
import
Distribution
def
_parse_upload_body
(
body
):
boundary
=
u'
\
r
\
n
----------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
entries
=
[]
name_re
=
re
.
compile
(
u'^Content-Disposition: form-data; name="([^
\
"
]+)"'
)
for
entry
in
body
.
split
(
boundary
):
pair
=
entry
.
split
(
u'
\
r
\
n
\
r
\
n
'
)
if
not
len
(
pair
)
==
2
:
continue
key
,
value
=
map
(
six
.
text_type
.
strip
,
pair
)
m
=
name_re
.
match
(
key
)
if
m
is
not
None
:
key
=
m
.
group
(
1
)
entries
.
append
((
key
,
value
))
return
entries
class
TestUploadTest
:
@
pytest
.
mark
.
xfail
(
reason
=
'Issue #1381'
)
@
mock
.
patch
(
'setuptools.command.upload.urlopen'
)
def
test_upload_metadata
(
self
,
patch
,
tmpdir
):
dist
=
Distribution
()
dist
.
metadata
.
metadata_version
=
StrictVersion
(
'2.1'
)
content
=
os
.
path
.
join
(
str
(
tmpdir
),
"test_upload_metadata_content"
)
with
open
(
content
,
'w'
)
as
f
:
f
.
write
(
"Some content"
)
dist
.
dist_files
=
[(
'xxx'
,
'3.7'
,
content
)]
patch
.
return_value
=
mock
.
Mock
()
patch
.
return_value
.
getcode
.
return_value
=
200
cmd
=
upload
(
dist
)
cmd
.
announce
=
mock
.
Mock
()
cmd
.
username
=
'user'
cmd
.
password
=
'hunter2'
cmd
.
ensure_finalized
()
cmd
.
run
()
# Make sure we did the upload
patch
.
assert_called_once
()
# Make sure the metadata version is correct in the headers
request
=
patch
.
call_args_list
[
0
][
0
][
0
]
body
=
request
.
data
.
decode
(
'utf-8'
)
entries
=
dict
(
_parse_upload_body
(
body
))
assert
entries
[
'metadata_version'
]
==
'2.1'
def
test_warns_deprecation
(
self
):
dist
=
Distribution
()
dist
.
dist_files
=
[(
mock
.
Mock
(),
mock
.
Mock
(),
mock
.
Mock
())]
...
...
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