[Python-checkins] distutils2: Branch merge

tarek.ziade python-checkins at python.org
Sat Oct 2 00:52:19 CEST 2010


tarek.ziade pushed 00abdfe2a4bd to distutils2:

http://hg.python.org/distutils2/rev/00abdfe2a4bd
changeset:   694:00abdfe2a4bd
parent:      693:4ddf7feadf0f
parent:      668:ea174f2c7d8e
user:        ?ric Araujo <merwok at netwok.org>
date:        Wed Sep 08 03:25:35 2010 +0200
summary:     Branch merge
files:       

diff --git a/src/distutils2/command/build_clib.py b/src/distutils2/command/build_clib.py
--- a/src/distutils2/command/build_clib.py
+++ b/src/distutils2/command/build_clib.py
@@ -32,9 +32,9 @@
     description = "build C/C++ libraries used by Python extensions"
 
     user_options = [
-        ('build-clib', 'b',
+        ('build-clib=', 'b',
          "directory to build C/C++ libraries to"),
-        ('build-temp', 't',
+        ('build-temp=', 't',
          "directory to put temporary build by-products"),
         ('debug', 'g',
          "compile with debugging information"),
diff --git a/src/distutils2/command/upload.py b/src/distutils2/command/upload.py
--- a/src/distutils2/command/upload.py
+++ b/src/distutils2/command/upload.py
@@ -7,7 +7,10 @@
 from urllib2 import urlopen, Request, HTTPError
 from base64 import standard_b64encode
 import urlparse
-import StringIO as StringIO
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
 try:
     from hashlib import md5
 except ImportError:
@@ -135,7 +138,7 @@
         boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
         sep_boundary = '\n--' + boundary
         end_boundary = sep_boundary + '--'
-        body = StringIO.StringIO()
+        body = StringIO()
         file_fields = ('content', 'gpg_signature')
 
         for key, values in data.items():
@@ -198,5 +201,7 @@
         else:
             self.announce('Upload failed (%s): %s' % (status, reason),
                           log.ERROR)
+
         if self.show_response:
-            self.announce('-'*75, result.read(), '-'*75)
+            msg = '\n'.join(('-' * 75, result.read(), '-' * 75))
+            self.announce(msg, log.INFO)
diff --git a/src/distutils2/command/upload_docs.py b/src/distutils2/command/upload_docs.py
--- a/src/distutils2/command/upload_docs.py
+++ b/src/distutils2/command/upload_docs.py
@@ -1,5 +1,13 @@
-import base64, httplib, os.path, socket, urlparse, zipfile
-from cStringIO import StringIO
+import os
+import base64
+import httplib
+import socket
+import urlparse
+import zipfile
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
 
 from distutils2 import log
 from distutils2.command.upload import upload
@@ -144,4 +152,5 @@
                           log.ERROR)
 
         if self.show_response:
-            print "\n".join(['-'*75, r.read(), '-'*75])
+            msg = '\n'.join(('-' * 75, r.read(), '-' * 75))
+            self.announce(msg, log.INFO)
diff --git a/src/distutils2/tests/test_build_ext.py b/src/distutils2/tests/test_build_ext.py
--- a/src/distutils2/tests/test_build_ext.py
+++ b/src/distutils2/tests/test_build_ext.py
@@ -280,8 +280,8 @@
         finally:
             os.chdir(old_wd)
         self.assertTrue(os.path.exists(so_file))
-        self.assertEqual(os.path.splitext(so_file)[-1],
-                          sysconfig.get_config_var('SO'))
+        so_ext = sysconfig.get_config_var('SO')
+        self.assertTrue(so_file.endswith(so_ext))
         so_dir = os.path.dirname(so_file)
         self.assertEqual(so_dir, other_tmp_dir)
 
@@ -289,8 +289,7 @@
         cmd.run()
         so_file = cmd.get_outputs()[0]
         self.assertTrue(os.path.exists(so_file))
-        self.assertEqual(os.path.splitext(so_file)[-1],
-                          sysconfig.get_config_var('SO'))
+        self.assertTrue(so_file.endswith(so_ext))
         so_dir = os.path.dirname(so_file)
         self.assertEqual(so_dir, cmd.build_lib)
 
diff --git a/src/distutils2/tests/test_upload_docs.py b/src/distutils2/tests/test_upload_docs.py
--- a/src/distutils2/tests/test_upload_docs.py
+++ b/src/distutils2/tests/test_upload_docs.py
@@ -186,26 +186,13 @@
         self.assertRaises(DistutilsOptionError, self.cmd.ensure_finalized)
 
     def test_show_response(self):
-        orig_stdout = sys.stdout
-        write_args = []
+        self.prepare_command()
+        self.cmd.show_response = True
+        self.cmd.run()
+        record = self.logs[-1][1]
 
-        class MockStdIn(object):
-            def write(self, arg):
-                write_args.append(arg)
-            def flush(self):
-                pass
-
-        sys.stdout = MockStdIn()
-        try:
-            self.prepare_command()
-            self.cmd.show_response = True
-            self.cmd.run()
-        finally:
-            sys.stdout = orig_stdout
-
-        self.assertTrue(write_args[0], "should report the response")
-        self.assertIn(self.pypi.default_response_data + "\n",
-                      '\n'.join(write_args))
+        self.assertTrue(record, "should report the response")
+        self.assertIn(self.pypi.default_response_data, record)
 
 def test_suite():
     return unittest.makeSuite(UploadDocsTestCase)

--
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list