diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-22 17:14:56 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-22 17:14:56 (GMT) |
commit | 20d5adea6a9dd5a752f2d8bb2b0cef0ee7cf386e (patch) | |
tree | dcbd9ab66d76647d49e94e1521d72ed4254428e2 /Lib/distutils/tests | |
parent | a936c40ede4583f8ac94362eced17325ae780abc (diff) | |
parent | 335a5128e54809b789cb82f05a913df1198fe40e (diff) | |
download | cpython-20d5adea6a9dd5a752f2d8bb2b0cef0ee7cf386e.zip cpython-20d5adea6a9dd5a752f2d8bb2b0cef0ee7cf386e.tar.gz cpython-20d5adea6a9dd5a752f2d8bb2b0cef0ee7cf386e.tar.bz2 |
Fix TypeError on "setup.py upload --show-response".
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r-- | Lib/distutils/tests/test_upload.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/distutils/tests/test_upload.py b/Lib/distutils/tests/test_upload.py index 1fcba88..f53eb26 100644 --- a/Lib/distutils/tests/test_upload.py +++ b/Lib/distutils/tests/test_upload.py @@ -6,6 +6,7 @@ from test.support import run_unittest from distutils.command import upload as upload_mod from distutils.command.upload import upload from distutils.core import Distribution +from distutils.log import INFO from distutils.tests.test_config import PYPIRC, PyPIRCCommandTestCase @@ -48,6 +49,14 @@ class FakeOpen(object): self.req = None self.msg = 'OK' + def getheader(self, name, default=None): + return { + 'content-type': 'text/plain; charset=utf-8', + }.get(name.lower(), default) + + def read(self): + return b'xyzzy' + def getcode(self): return 200 @@ -108,10 +117,11 @@ class uploadTestCase(PyPIRCCommandTestCase): # lets run it pkg_dir, dist = self.create_dist(dist_files=dist_files) cmd = upload(dist) + cmd.show_response = 1 cmd.ensure_finalized() cmd.run() - # what did we send ? + # what did we send ? headers = dict(self.last_open.req.headers) self.assertEqual(headers['Content-length'], '2087') content_type = headers['Content-type'] @@ -121,6 +131,11 @@ class uploadTestCase(PyPIRCCommandTestCase): self.assertEqual(self.last_open.req.get_full_url(), expected_url) self.assertTrue(b'xxx' in self.last_open.req.data) + # The PyPI response body was echoed + results = self.get_logs(INFO) + self.assertIn('xyzzy\n', results[-1]) + + def test_suite(): return unittest.makeSuite(uploadTestCase) |