diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-22 18:13:51 +0100 |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-12-22 18:13:51 +0100 |
| commit | a9d129418d7569a12e225e130711524a89868eca (patch) | |
| tree | f95478d1bc6ad320d0b165341b174c5799bd50f0 /tests/test_upload.py | |
| parent | 13766f65fc959da18e5d775ceb7a25ed71ed401e (diff) | |
| download | python-setuptools-git-a9d129418d7569a12e225e130711524a89868eca.tar.gz | |
Fix TypeError on "setup.py upload --show-response".
Diffstat (limited to 'tests/test_upload.py')
| -rw-r--r-- | tests/test_upload.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_upload.py b/tests/test_upload.py index fbf80e38..8532369a 100644 --- a/tests/test_upload.py +++ b/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') self.assertTrue(headers['Content-type'].startswith('multipart/form-data')) @@ -120,6 +130,11 @@ class uploadTestCase(PyPIRCCommandTestCase): 'https://pypi.python.org/pypi') self.assertIn(b'xxx', 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) |
