Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e899b711
Kaydet (Commit)
e899b711
authored
Mar 31, 2009
tarafından
Tarek Ziadé
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
more tests for the upload command
üst
ca2b8d28
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
8 deletions
+64
-8
upload.py
Lib/distutils/command/upload.py
+1
-1
test_upload.py
Lib/distutils/tests/test_upload.py
+63
-7
No files found.
Lib/distutils/command/upload.py
Dosyayı görüntüle @
e899b711
...
...
@@ -192,4 +192,4 @@ class upload(PyPIRCCommand):
self
.
announce
(
'Upload failed (
%
s):
%
s'
%
(
r
.
status
,
r
.
reason
),
log
.
ERROR
)
if
self
.
show_response
:
print
'-'
*
75
,
r
.
read
(),
'-'
*
75
self
.
announce
(
'-'
*
75
,
r
.
read
(),
'-'
*
75
)
Lib/distutils/tests/test_upload.py
Dosyayı görüntüle @
e899b711
...
...
@@ -2,6 +2,7 @@
import
sys
import
os
import
unittest
import
httplib
from
distutils.command.upload
import
upload
from
distutils.core
import
Distribution
...
...
@@ -18,17 +19,52 @@ index-servers =
[server1]
username:me
"""
class
Response
(
object
):
def
__init__
(
self
,
status
=
200
,
reason
=
'OK'
):
self
.
status
=
status
self
.
reason
=
reason
class
FakeConnection
(
object
):
def
__init__
(
self
):
self
.
requests
=
[]
self
.
headers
=
[]
self
.
body
=
''
def
__call__
(
self
,
netloc
):
return
self
def
connect
(
self
):
pass
endheaders
=
connect
def
putrequest
(
self
,
method
,
url
):
self
.
requests
.
append
((
method
,
url
))
def
putheader
(
self
,
name
,
value
):
self
.
headers
.
append
((
name
,
value
))
def
send
(
self
,
body
):
self
.
body
=
body
def
getresponse
(
self
):
return
Response
()
class
uploadTestCase
(
PyPIRCCommandTestCase
):
def
setUp
(
self
):
super
(
uploadTestCase
,
self
)
.
setUp
()
self
.
old_class
=
httplib
.
HTTPConnection
self
.
conn
=
httplib
.
HTTPConnection
=
FakeConnection
()
def
tearDown
(
self
):
httplib
.
HTTPConnection
=
self
.
old_class
super
(
uploadTestCase
,
self
)
.
tearDown
()
def
test_finalize_options
(
self
):
# new format
f
=
open
(
self
.
rc
,
'w'
)
f
.
write
(
PYPIRC
)
f
.
close
()
self
.
write_file
(
self
.
rc
,
PYPIRC
)
dist
=
Distribution
()
cmd
=
upload
(
dist
)
cmd
.
finalize_options
()
...
...
@@ -39,9 +75,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
def
test_saved_password
(
self
):
# file with no password
f
=
open
(
self
.
rc
,
'w'
)
f
.
write
(
PYPIRC_NOPASSWORD
)
f
.
close
()
self
.
write_file
(
self
.
rc
,
PYPIRC_NOPASSWORD
)
# make sure it passes
dist
=
Distribution
()
...
...
@@ -56,6 +90,28 @@ class uploadTestCase(PyPIRCCommandTestCase):
cmd
.
finalize_options
()
self
.
assertEquals
(
cmd
.
password
,
'xxx'
)
def
test_upload
(
self
):
tmp
=
self
.
mkdtemp
()
path
=
os
.
path
.
join
(
tmp
,
'xxx'
)
self
.
write_file
(
path
)
command
,
pyversion
,
filename
=
'xxx'
,
'2.6'
,
path
dist_files
=
[(
command
,
pyversion
,
filename
)]
self
.
write_file
(
self
.
rc
,
PYPIRC
)
# lets run it
pkg_dir
,
dist
=
self
.
create_dist
(
dist_files
=
dist_files
)
cmd
=
upload
(
dist
)
cmd
.
ensure_finalized
()
cmd
.
run
()
# what did we send ?
headers
=
dict
(
self
.
conn
.
headers
)
self
.
assertEquals
(
headers
[
'Content-length'
],
'2086'
)
self
.
assert_
(
headers
[
'Content-type'
]
.
startswith
(
'multipart/form-data'
))
self
.
assertEquals
(
self
.
conn
.
requests
,
[(
'POST'
,
'/pypi'
)])
self
.
assert_
(
'xxx'
in
self
.
conn
.
body
)
def
test_suite
():
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