Arfrever Frehtes Taifersar Arahesis avatar Arfrever Frehtes Taifersar Arahesis committed 5061b9e

Fix some DeprecationWarnings and ResourceWarnings.

Comments (0)

Files changed (4)

 ------
 
 * Fix test suite with Python 2.6.
+* Fix some DeprecationWarnings and ResourceWarnings.
 
 ------
 0.6.31
     from distutils import dir_util, file_util, util, log
     log.set_verbosity(1)
     fl = FileList()
-    for line in open("MANIFEST.in"):
+    manifest_file = open("MANIFEST.in")
+    for line in manifest_file:
         fl.process_template_line(line)
+    manifest_file.close()
     dir_util.create_tree(tmp_src, fl.files)
     outfiles_2to3 = []
     dist_script = os.path.join("build", "src", "distribute_setup.py")
 
 d = {}
 init_path = convert_path('setuptools/command/__init__.py')
-exec(open(init_path).read(), d)
+init_file = open(init_path)
+exec(init_file.read(), d)
+init_file.close()
 
 SETUP_COMMANDS = d['__all__']
 VERSION = "0.6.32"
     _before_install()
 
 # return contents of reStructureText file with linked issue references
-def _linkified(rstfile):
+def _linkified(rst_path):
     bitroot = 'http://bitbucket.org/tarek/distribute'
     revision = re.compile(r'\b(issue\s*#?\d+)\b', re.M | re.I)
 
-    rstext = open(rstfile).read()    
+    rst_file = open(rst_path)
+    rst_content = rst_file.read()
+    rst_file.close()
 
-    anchors = revision.findall(rstext) # ['Issue #43', ...]
+    anchors = revision.findall(rst_content) # ['Issue #43', ...]
     anchors = sorted(set(anchors))
-    rstext = revision.sub(r'`\1`_', rstext)
-    rstext += "\n"
+    rst_content = revision.sub(r'`\1`_', rst_content)
+    rst_content += "\n"
     for x in anchors:
         issue = re.findall(r'\d+', x)[0]
-        rstext += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue)
-    rstext += "\n"
-    return rstext
+        rst_content += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue)
+    rst_content += "\n"
+    return rst_content
+
+readme_file = open('README.txt')
+long_description = readme_file.read() + _linkified('CHANGES.txt')
+readme_file.close()
 
 dist = setup(
     name="distribute",
     author="The fellowship of the packaging",
     author_email="distutils-sig@python.org",
     license="PSF or ZPL",
-    long_description = open('README.txt').read() + _linkified('CHANGES.txt'),
+    long_description = long_description,
     keywords = "CPAN PyPI distutils eggs package management",
     url = "http://packages.python.org/distribute",
     test_suite = 'setuptools.tests',

setuptools/tests/test_easy_install.py

         f = open(egg_file, 'w')
         try:
             f.write('Name: foo\n')
-        except:
+        finally:
             f.close()
 
         sys.path.append(target)
 
             lines = stdout.splitlines()
             self.assertTrue(len(lines) > 0)
-            self.assert_(lines[-1].strip(), 'test_pkg')
+            self.assertTrue(lines[-1].strip(), 'test_pkg')
 
         try:
             tempdir_context(setup_and_run)

setuptools/tests/test_markerlib.py

         
         os_name = os.name
         
-        self.assert_(interpret(""))
+        self.assertTrue(interpret(""))
         
-        self.assert_(interpret("os.name != 'buuuu'"))
-        self.assert_(interpret("python_version > '1.0'"))
-        self.assert_(interpret("python_version < '5.0'"))
-        self.assert_(interpret("python_version <= '5.0'"))
-        self.assert_(interpret("python_version >= '1.0'"))
-        self.assert_(interpret("'%s' in os.name" % os_name))
-        self.assert_(interpret("'buuuu' not in os.name"))
+        self.assertTrue(interpret("os.name != 'buuuu'"))
+        self.assertTrue(interpret("python_version > '1.0'"))
+        self.assertTrue(interpret("python_version < '5.0'"))
+        self.assertTrue(interpret("python_version <= '5.0'"))
+        self.assertTrue(interpret("python_version >= '1.0'"))
+        self.assertTrue(interpret("'%s' in os.name" % os_name))
+        self.assertTrue(interpret("'buuuu' not in os.name"))
         
         self.assertFalse(interpret("os.name == 'buuuu'"))
         self.assertFalse(interpret("python_version < '1.0'"))
         
         environment = default_environment()
         environment['extra'] = 'test'
-        self.assert_(interpret("extra == 'test'", environment))
+        self.assertTrue(interpret("extra == 'test'", environment))
         self.assertFalse(interpret("extra == 'doc'", environment))
         
         def raises_nameError():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.