summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-12-27 16:00:54 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-12-27 16:00:54 (GMT)
commit9203501bae35a7a6fbec2287324382075177872d (patch)
tree1ade1461976906524369405232bb36ac704c7148 /Lib
parentdb5fe667311745a2bc86355620354449721545f3 (diff)
downloadcpython-9203501bae35a7a6fbec2287324382075177872d.zip
cpython-9203501bae35a7a6fbec2287324382075177872d.tar.gz
cpython-9203501bae35a7a6fbec2287324382075177872d.tar.bz2
Merged revisions 67889-67892,67895,67898,67904-67907,67912,67918,67920-67921,67923-67924,67926-67927,67930,67943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ................ r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line sphinx.web is long gone ................ r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line update readme ................ r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line there are way too many places which need to have the current version added ................ r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines Merged revisions 67809 via svnmerge from svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3 ........ r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line fix logic error ........ ................ r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines Add Tarek for work on distutils. ................ r67898 | benjamin.peterson | 2008-12-21 15:00:53 -0600 (Sun, 21 Dec 2008) | 1 line compute DISTVERSION with patchlevel.py ................ r67904 | benjamin.peterson | 2008-12-22 14:44:58 -0600 (Mon, 22 Dec 2008) | 1 line less attitude ................ r67905 | benjamin.peterson | 2008-12-22 14:51:15 -0600 (Mon, 22 Dec 2008) | 1 line fix #4720: the format to PyArg_ParseTupleAndKeywords can now start with '|' ................ r67906 | benjamin.peterson | 2008-12-22 14:52:53 -0600 (Mon, 22 Dec 2008) | 1 line add NEWS note ................ r67907 | benjamin.peterson | 2008-12-22 16:12:19 -0600 (Mon, 22 Dec 2008) | 1 line silence compiler warning ................ r67912 | georg.brandl | 2008-12-23 06:37:21 -0600 (Tue, 23 Dec 2008) | 2 lines Fix missing "svn" command. ................ r67918 | georg.brandl | 2008-12-23 09:44:25 -0600 (Tue, 23 Dec 2008) | 2 lines Markup fix. ................ r67920 | benjamin.peterson | 2008-12-23 14:09:28 -0600 (Tue, 23 Dec 2008) | 1 line use a global variable, so the compiler doesn't optimize the assignment out ................ r67921 | benjamin.peterson | 2008-12-23 14:12:33 -0600 (Tue, 23 Dec 2008) | 1 line make global static ................ r67923 | benjamin.peterson | 2008-12-24 09:10:27 -0600 (Wed, 24 Dec 2008) | 1 line #4736 BufferRWPair.closed shouldn't try to call another property as a function ................ r67924 | benjamin.peterson | 2008-12-24 10:10:05 -0600 (Wed, 24 Dec 2008) | 1 line pretend exceptions don't exist a while longer ................ r67926 | tarek.ziade | 2008-12-24 13:10:05 -0600 (Wed, 24 Dec 2008) | 1 line fixed #4400 : distutils .pypirc default generated file was broken. ................ r67927 | benjamin.peterson | 2008-12-26 17:26:30 -0600 (Fri, 26 Dec 2008) | 1 line python version is included in file name now ................ r67930 | hirokazu.yamamoto | 2008-12-26 22:19:48 -0600 (Fri, 26 Dec 2008) | 2 lines Issue #4740: Use HIGHEST_PROTOCOL in pickle test. (There is no behavior difference in 2.x because HIGHEST_PROTOCOL == 2) ................ r67943 | alexandre.vassalotti | 2008-12-27 04:02:59 -0600 (Sat, 27 Dec 2008) | 2 lines Fix bogus unicode tests in pickletester. ................
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/register.py17
-rw-r--r--Lib/distutils/config.py4
-rw-r--r--Lib/distutils/tests/test_config.py29
-rw-r--r--Lib/distutils/tests/test_register.py109
-rw-r--r--Lib/io.py2
-rw-r--r--Lib/lib2to3/main.py3
-rw-r--r--Lib/test/pickletester.py4
-rw-r--r--Lib/test/test_io.py3
8 files changed, 158 insertions, 13 deletions
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index 045cbb6..bd9b8c0 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -143,13 +143,14 @@ class register(PyPIRCCommand):
# get the user's login info
choices = '1 2 3 4'.split()
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,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
4. quit
-Your selection [default 1]: ''', end=' ')
- choice = input()
+Your selection [default 1]: ''', log.INFO)
+ choice = raw_input()
if not choice:
choice = '1'
elif choice not in choices:
@@ -169,12 +170,16 @@ Your selection [default 1]: ''', end=' ')
# send the info to the server and report the result
code, result = self.post_to_server(self.build_post_data('submit'),
auth)
- print('Server response (%s): %s'%(code, result))
+ self.announce('Server response (%s): %s' % (code, result),
+ log.INFO)
# possibly save the login
if not self.has_config and code == 200:
- print('I can store your PyPI login so future submissions will be faster.')
- print('(the login will be stored in %s)' % self._get_rc_file())
+ self.announce(('I can store your PyPI login so future '
+ 'submissions will be faster.'), log.INFO)
+ self.announce('(the login will be stored in %s)' % \
+ self._get_rc_file(), log.INFO)
+
choice = 'X'
while choice.lower() not in 'yn':
choice = input('Save your login (y/N)?')
diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py
index 0ecfe0c..73f3260 100644
--- a/Lib/distutils/config.py
+++ b/Lib/distutils/config.py
@@ -10,8 +10,8 @@ from configparser import ConfigParser
from distutils.cmd import Command
DEFAULT_PYPIRC = """\
-[pypirc]
-servers =
+[distutils]
+index-servers =
pypi
[pypi]
diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py
index 016ba4c..bdc9b2b 100644
--- a/Lib/distutils/tests/test_config.py
+++ b/Lib/distutils/tests/test_config.py
@@ -5,6 +5,8 @@ import unittest
from distutils.core import PyPIRCCommand
from distutils.core import Distribution
+from distutils.log import set_threshold
+from distutils.log import WARN
from distutils.tests import support
@@ -32,6 +34,17 @@ username:tarek
password:secret
"""
+WANTED = """\
+[distutils]
+index-servers =
+ pypi
+
+[pypi]
+username:tarek
+password:xxx
+"""
+
+
class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
def setUp(self):
@@ -53,6 +66,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
finalize_options = initialize_options
self._cmd = command
+ self.old_threshold = set_threshold(WARN)
def tearDown(self):
"""Removes the patch."""
@@ -62,6 +76,7 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
os.environ['HOME'] = self._old_home
if os.path.exists(self.rc):
os.remove(self.rc)
+ set_threshold(self.old_threshold)
def test_server_registration(self):
# This test makes sure PyPIRCCommand knows how to:
@@ -96,6 +111,20 @@ class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
('server', 'server-login'), ('username', 'tarek')]
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():
return unittest.makeSuite(PyPIRCCommandTestCase)
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
new file mode 100644
index 0000000..3a3a3b7
--- /dev/null
+++ b/Lib/distutils/tests/test_register.py
@@ -0,0 +1,109 @@
+"""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")
diff --git a/Lib/io.py b/Lib/io.py
index 96b3e5d..6b51810 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -1157,7 +1157,7 @@ class BufferedRWPair(BufferedIOBase):
@property
def closed(self):
- return self.writer.closed()
+ return self.writer.closed
class BufferedRandom(BufferedWriter, BufferedReader):
diff --git a/Lib/lib2to3/main.py b/Lib/lib2to3/main.py
index f551feb..a73149a 100644
--- a/Lib/lib2to3/main.py
+++ b/Lib/lib2to3/main.py
@@ -40,7 +40,8 @@ class StdoutRefactoringTool(refactor.RefactoringTool):
# Actually write the new file
super(StdoutRefactoringTool, self).write_file(new_text,
filename, old_text)
- shutil.copymode(filename, backup)
+ if not self.nobackups:
+ shutil.copymode(filename, backup)
def print_output(self, lines):
for line in lines:
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index f65093a..ad9230c 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -484,8 +484,8 @@ class AbstractPickleTests(unittest.TestCase):
self.assertRaises(ValueError, self.loads, buf)
def test_unicode(self):
- endcases = ['', '<\\u>', '<\\\u1234>', '<\n>', '<\\>',
- '<\\\U00012345>']
+ endcases = [u'', u'<\\u>', u'<\\\u1234>', u'<\n>',
+ u'<\\>', u'<\\\U00012345>']
for proto in protocols:
for u in endcases:
p = self.dumps(u, proto)
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 1733440..0fc017f 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -553,8 +553,9 @@ class BufferedRWPairTest(unittest.TestCase):
r = MockRawIO(())
w = MockRawIO()
pair = io.BufferedRWPair(r, w)
+ self.assertFalse(pair.closed)
- # XXX need implementation
+ # XXX More Tests
class BufferedRandomTest(unittest.TestCase):