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
e4c75bb5
Kaydet (Commit)
e4c75bb5
authored
Ara 24, 2008
tarafından
Tarek Ziadé
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fixed #4400 : distutils .pypirc default generated file was broken.
üst
42d19e6a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
7 deletions
+153
-7
register.py
Lib/distutils/command/register.py
+11
-5
config.py
Lib/distutils/config.py
+2
-2
test_config.py
Lib/distutils/tests/test_config.py
+29
-0
test_register.py
Lib/distutils/tests/test_register.py
+109
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/distutils/command/register.py
Dosyayı görüntüle @
e4c75bb5
...
@@ -141,12 +141,14 @@ class register(PyPIRCCommand):
...
@@ -141,12 +141,14 @@ class register(PyPIRCCommand):
# get the user's login info
# get the user's login info
choices
=
'1 2 3 4'
.
split
()
choices
=
'1 2 3 4'
.
split
()
while
choice
not
in
choices
:
while
choice
not
in
choices
:
print
'''We need to know who you are, so please choose either:
self
.
announce
(
'''
\
We need to know who you are, so please choose either:
1. use your existing login,
1. use your existing login,
2. register as a new user,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
3. have the server generate a new password for you (and email it to you), or
4. quit
4. quit
Your selection [default 1]: '''
,
Your selection [default 1]: '''
,
log
.
INFO
)
choice
=
raw_input
()
choice
=
raw_input
()
if
not
choice
:
if
not
choice
:
choice
=
'1'
choice
=
'1'
...
@@ -167,12 +169,16 @@ Your selection [default 1]: ''',
...
@@ -167,12 +169,16 @@ Your selection [default 1]: ''',
# send the info to the server and report the result
# send the info to the server and report the result
code
,
result
=
self
.
post_to_server
(
self
.
build_post_data
(
'submit'
),
code
,
result
=
self
.
post_to_server
(
self
.
build_post_data
(
'submit'
),
auth
)
auth
)
print
'Server response (
%
s):
%
s'
%
(
code
,
result
)
self
.
announce
(
'Server response (
%
s):
%
s'
%
(
code
,
result
),
log
.
INFO
)
# possibly save the login
# possibly save the login
if
not
self
.
has_config
and
code
==
200
:
if
not
self
.
has_config
and
code
==
200
:
print
'I can store your PyPI login so future submissions will be faster.'
self
.
announce
((
'I can store your PyPI login so future '
print
'(the login will be stored in
%
s)'
%
self
.
_get_rc_file
()
'submissions will be faster.'
),
log
.
INFO
)
self
.
announce
(
'(the login will be stored in
%
s)'
%
\
self
.
_get_rc_file
(),
log
.
INFO
)
choice
=
'X'
choice
=
'X'
while
choice
.
lower
()
not
in
'yn'
:
while
choice
.
lower
()
not
in
'yn'
:
choice
=
raw_input
(
'Save your login (y/N)?'
)
choice
=
raw_input
(
'Save your login (y/N)?'
)
...
...
Lib/distutils/config.py
Dosyayı görüntüle @
e4c75bb5
...
@@ -10,8 +10,8 @@ from ConfigParser import ConfigParser
...
@@ -10,8 +10,8 @@ from ConfigParser import ConfigParser
from
distutils.cmd
import
Command
from
distutils.cmd
import
Command
DEFAULT_PYPIRC
=
"""
\
DEFAULT_PYPIRC
=
"""
\
[
pypirc
]
[
distutils
]
servers =
index-
servers =
pypi
pypi
[pypi]
[pypi]
...
...
Lib/distutils/tests/test_config.py
Dosyayı görüntüle @
e4c75bb5
...
@@ -5,6 +5,8 @@ import unittest
...
@@ -5,6 +5,8 @@ import unittest
from
distutils.core
import
PyPIRCCommand
from
distutils.core
import
PyPIRCCommand
from
distutils.core
import
Distribution
from
distutils.core
import
Distribution
from
distutils.log
import
set_threshold
from
distutils.log
import
WARN
from
distutils.tests
import
support
from
distutils.tests
import
support
...
@@ -32,6 +34,17 @@ username:tarek
...
@@ -32,6 +34,17 @@ username:tarek
password:secret
password:secret
"""
"""
WANTED
=
"""
\
[distutils]
index-servers =
pypi
[pypi]
username:tarek
password:xxx
"""
class
PyPIRCCommandTestCase
(
support
.
TempdirManager
,
unittest
.
TestCase
):
class
PyPIRCCommandTestCase
(
support
.
TempdirManager
,
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -53,6 +66,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -53,6 +66,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
finalize_options
=
initialize_options
finalize_options
=
initialize_options
self
.
_cmd
=
command
self
.
_cmd
=
command
self
.
old_threshold
=
set_threshold
(
WARN
)
def
tearDown
(
self
):
def
tearDown
(
self
):
"""Removes the patch."""
"""Removes the patch."""
...
@@ -62,6 +76,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -62,6 +76,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
os
.
environ
[
'HOME'
]
=
self
.
_old_home
os
.
environ
[
'HOME'
]
=
self
.
_old_home
if
os
.
path
.
exists
(
self
.
rc
):
if
os
.
path
.
exists
(
self
.
rc
):
os
.
remove
(
self
.
rc
)
os
.
remove
(
self
.
rc
)
set_threshold
(
self
.
old_threshold
)
def
test_server_registration
(
self
):
def
test_server_registration
(
self
):
# This test makes sure PyPIRCCommand knows how to:
# This test makes sure PyPIRCCommand knows how to:
...
@@ -98,6 +113,20 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
...
@@ -98,6 +113,20 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
(
'server'
,
'server-login'
),
(
'username'
,
'tarek'
)]
(
'server'
,
'server-login'
),
(
'username'
,
'tarek'
)]
self
.
assertEquals
(
config
,
waited
)
self
.
assertEquals
(
config
,
waited
)
def
test_server_empty_registration
(
self
):
cmd
=
self
.
_cmd
(
self
.
dist
)
rc
=
cmd
.
_get_rc_file
()
self
.
assert_
(
not
os
.
path
.
exists
(
rc
))
cmd
.
_store_pypirc
(
'tarek'
,
'xxx'
)
self
.
assert_
(
os
.
path
.
exists
(
rc
))
content
=
open
(
rc
)
.
read
()
self
.
assertEquals
(
content
,
WANTED
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
PyPIRCCommandTestCase
)
return
unittest
.
makeSuite
(
PyPIRCCommandTestCase
)
...
...
Lib/distutils/tests/test_register.py
0 → 100644
Dosyayı görüntüle @
e4c75bb5
"""Tests for distutils.command.register."""
import
sys
import
os
import
unittest
from
distutils.command.register
import
register
from
distutils.core
import
Distribution
from
distutils.tests
import
support
from
distutils.tests.test_config
import
PYPIRC
,
PyPIRCCommandTestCase
class
RawInputs
(
object
):
"""Fakes user inputs."""
def
__init__
(
self
,
*
answers
):
self
.
answers
=
answers
self
.
index
=
0
def
__call__
(
self
,
prompt
=
''
):
try
:
return
self
.
answers
[
self
.
index
]
finally
:
self
.
index
+=
1
WANTED_PYPIRC
=
"""
\
[distutils]
index-servers =
pypi
[pypi]
username:tarek
password:xxx
"""
class
registerTestCase
(
PyPIRCCommandTestCase
):
def
test_create_pypirc
(
self
):
# this test makes sure a .pypirc file
# is created when requested.
# let's create a fake distribution
# and a register instance
dist
=
Distribution
()
dist
.
metadata
.
url
=
'xxx'
dist
.
metadata
.
author
=
'xxx'
dist
.
metadata
.
author_email
=
'xxx'
dist
.
metadata
.
name
=
'xxx'
dist
.
metadata
.
version
=
'xxx'
cmd
=
register
(
dist
)
# we shouldn't have a .pypirc file yet
self
.
assert_
(
not
os
.
path
.
exists
(
self
.
rc
))
# patching raw_input and getpass.getpass
# so register gets happy
#
# Here's what we are faking :
# use your existing login (choice 1.)
# Username : 'tarek'
# Password : 'xxx'
# Save your login (y/N)? : 'y'
inputs
=
RawInputs
(
'1'
,
'tarek'
,
'y'
)
from
distutils.command
import
register
as
register_module
register_module
.
raw_input
=
inputs
.
__call__
def
_getpass
(
prompt
):
return
'xxx'
register_module
.
getpass
.
getpass
=
_getpass
class
FakeServer
(
object
):
def
__init__
(
self
):
self
.
calls
=
[]
def
__call__
(
self
,
*
args
):
# we want to compare them, so let's store
# something comparable
els
=
args
[
0
]
.
items
()
els
.
sort
()
self
.
calls
.
append
(
tuple
(
els
))
return
200
,
'OK'
cmd
.
post_to_server
=
pypi_server
=
FakeServer
()
# let's run the command
cmd
.
run
()
# we should have a brand new .pypirc file
self
.
assert_
(
os
.
path
.
exists
(
self
.
rc
))
# with the content similar to WANTED_PYPIRC
content
=
open
(
self
.
rc
)
.
read
()
self
.
assertEquals
(
content
,
WANTED_PYPIRC
)
# now let's make sure the .pypirc file generated
# really works : we shouldn't be asked anything
# if we run the command again
def
_no_way
(
prompt
=
''
):
raise
AssertionError
(
prompt
)
register_module
.
raw_input
=
_no_way
cmd
.
run
()
# let's see what the server received : we should
# have 2 similar requests
self
.
assert_
(
len
(
pypi_server
.
calls
),
2
)
self
.
assert_
(
pypi_server
.
calls
[
0
],
pypi_server
.
calls
[
1
])
def
test_suite
():
return
unittest
.
makeSuite
(
registerTestCase
)
if
__name__
==
"__main__"
:
unittest
.
main
(
defaultTest
=
"test_suite"
)
Misc/NEWS
Dosyayı görüntüle @
e4c75bb5
...
@@ -86,6 +86,8 @@ Core and Builtins
...
@@ -86,6 +86,8 @@ Core and Builtins
Library
Library
-------
-------
- Issue #4400: .pypirc default generated file was broken in distutils.
- Issue #4736: io.BufferedRWPair's closed property now functions properly.
- Issue #4736: io.BufferedRWPair's closed property now functions properly.
- Issue #3954: Fix a potential SystemError in _hotshot.logreader error
- Issue #3954: Fix a potential SystemError in _hotshot.logreader error
...
...
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