[Python-checkins] r71533 - in python/trunk/Lib/distutils: command/config.py tests/test_config_cmd.py

tarek.ziade python-checkins at python.org
Sun Apr 12 19:02:09 CEST 2009


Author: tarek.ziade
Date: Sun Apr 12 19:02:08 2009
New Revision: 71533

Log:
removed string usage and added a test for _clean

Modified:
   python/trunk/Lib/distutils/command/config.py
   python/trunk/Lib/distutils/tests/test_config_cmd.py

Modified: python/trunk/Lib/distutils/command/config.py
==============================================================================
--- python/trunk/Lib/distutils/command/config.py	(original)
+++ python/trunk/Lib/distutils/command/config.py	Sun Apr 12 19:02:08 2009
@@ -11,7 +11,7 @@
 
 __revision__ = "$Id$"
 
-import sys, os, string, re
+import sys, os, re
 
 from distutils.core import Command
 from distutils.errors import DistutilsExecError
@@ -81,7 +81,7 @@
         elif isinstance(self.library_dirs, str):
             self.library_dirs = self.library_dirs.split(os.pathsep)
 
-    def run (self):
+    def run(self):
         pass
 
 
@@ -156,7 +156,7 @@
         if not filenames:
             filenames = self.temp_files
             self.temp_files = []
-        log.info("removing: %s", string.join(filenames))
+        log.info("removing: %s", ' '.join(filenames))
         for filename in filenames:
             try:
                 os.remove(filename)
@@ -308,7 +308,7 @@
         else:
             body.append("  %s;" % func)
         body.append("}")
-        body = string.join(body, "\n") + "\n"
+        body = "\n".join(body) + "\n"
 
         return self.try_link(body, headers, include_dirs,
                              libraries, library_dirs)

Modified: python/trunk/Lib/distutils/tests/test_config_cmd.py
==============================================================================
--- python/trunk/Lib/distutils/tests/test_config_cmd.py	(original)
+++ python/trunk/Lib/distutils/tests/test_config_cmd.py	Sun Apr 12 19:02:08 2009
@@ -60,6 +60,24 @@
         self.assertEquals(cmd.libraries, ['one'])
         self.assertEquals(cmd.library_dirs, ['three', 'four'])
 
+    def test_clean(self):
+        # _clean removes files
+        tmp_dir = self.mkdtemp()
+        f1 = os.path.join(tmp_dir, 'one')
+        f2 = os.path.join(tmp_dir, 'two')
+
+        self.write_file(f1, 'xxx')
+        self.write_file(f2, 'xxx')
+
+        for f in (f1, f2):
+            self.assert_(os.path.exists(f))
+
+        pkg_dir, dist = self.create_dist()
+        cmd = config(dist)
+        cmd._clean(f1, f2)
+
+        for f in (f1, f2):
+            self.assert_(not os.path.exists(f))
 
 def test_suite():
     return unittest.makeSuite(ConfigTestCase)


More information about the Python-checkins mailing list