summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-06-10 20:00:52 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-06-10 20:00:52 (GMT)
commit904a2ef2e20ad22d324da18a9c98cb65666babb8 (patch)
tree4fd0259310b09263c5c372a4e570d48b3873360b /Lib
parent87a8bcc221a6d3ca9a8d46838af5d0d21320e340 (diff)
downloadcpython-904a2ef2e20ad22d324da18a9c98cb65666babb8.zip
cpython-904a2ef2e20ad22d324da18a9c98cb65666babb8.tar.gz
cpython-904a2ef2e20ad22d324da18a9c98cb65666babb8.tar.bz2
Issue #20900: distutils register command now decodes HTTP responses correctly
Initial patch by ingrid.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/distutils/command/register.py6
-rw-r--r--Lib/distutils/tests/test_register.py14
-rw-r--r--Lib/distutils/tests/test_upload.py2
3 files changed, 18 insertions, 4 deletions
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index b49f86f..86343c8 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -296,9 +296,9 @@ Your selection [default 1]: ''', log.INFO)
result = 500, str(e)
else:
if self.show_response:
- data = result.read()
+ data = self._read_pypi_response(result)
result = 200, 'OK'
if self.show_response:
- dashes = '-' * 75
- self.announce('%s%r%s' % (dashes, data, dashes))
+ msg = '\n'.join(('-' * 75, data, '-' * 75))
+ self.announce(msg, log.INFO)
return result
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
index 6180133..01acf23 100644
--- a/Lib/distutils/tests/test_register.py
+++ b/Lib/distutils/tests/test_register.py
@@ -301,6 +301,20 @@ class RegisterTestCase(PyPIRCCommandTestCase):
results = self.get_logs(INFO)
self.assertEqual(results, ['running check', 'xxx'])
+ def test_show_response(self):
+ # test that the --show-response option return a well formatted response
+ cmd = self._get_cmd()
+ inputs = Inputs('1', 'tarek', 'y')
+ register_module.input = inputs.__call__
+ cmd.show_response = 1
+ try:
+ cmd.run()
+ finally:
+ del register_module.input
+
+ results = self.get_logs(INFO)
+ self.assertEqual(results[3], 75 * '-' + '\nxxx\n' + 75 * '-')
+
def test_suite():
return unittest.makeSuite(RegisterTestCase)
diff --git a/Lib/distutils/tests/test_upload.py b/Lib/distutils/tests/test_upload.py
index 19193d5..964aac7 100644
--- a/Lib/distutils/tests/test_upload.py
+++ b/Lib/distutils/tests/test_upload.py
@@ -140,7 +140,7 @@ class uploadTestCase(PyPIRCCommandTestCase):
# The PyPI response body was echoed
results = self.get_logs(INFO)
- self.assertIn('xyzzy\n', results[-1])
+ self.assertEqual(results[-1], 75 * '-' + '\nxyzzy\n' + 75 * '-')
def test_upload_fails(self):
self.next_msg = "Not Found"