diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-10-10 10:49:54 +0100 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-10-10 10:49:54 +0100 |
commit | 94fc39cb62df19e85b07658f2fa5d0b4a7bf9303 (patch) | |
tree | 1c44a301f7eb2662ccc03f97685b449e2251069e /setuptools/tests/test_develop.py | |
parent | e3f7235a944f5758780de74aac548e27a09e39a3 (diff) | |
download | external_python_setuptools-94fc39cb62df19e85b07658f2fa5d0b4a7bf9303.tar.gz external_python_setuptools-94fc39cb62df19e85b07658f2fa5d0b4a7bf9303.tar.bz2 external_python_setuptools-94fc39cb62df19e85b07658f2fa5d0b4a7bf9303.zip |
Fixed some resource leaks.
--HG--
branch : distribute
extra : source : 98c929e25fee11a99eb125dd9a13521321d68dd3
Diffstat (limited to 'setuptools/tests/test_develop.py')
-rw-r--r-- | setuptools/tests/test_develop.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index ecd2212d..0813959d 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -43,7 +43,7 @@ class TestDevelopTest(unittest.TestCase): f = open(init, 'w') f.write(INIT_PY) f.close() - + os.chdir(self.dir) self.old_base = site.USER_BASE site.USER_BASE = tempfile.mkdtemp() @@ -53,7 +53,7 @@ class TestDevelopTest(unittest.TestCase): def tearDown(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return - + os.chdir(self.old_cwd) shutil.rmtree(self.dir) shutil.rmtree(site.USER_BASE) @@ -89,8 +89,16 @@ class TestDevelopTest(unittest.TestCase): self.assertEqual(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. - path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() - init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() + f = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') + try: + path = f.read().split()[0].strip() + finally: + f.close() + f = open(os.path.join(path, 'foo', '__init__.py'), 'rt') + try: + init = f.read().strip() + finally: + f.close() if sys.version < "3": self.assertEqual(init, 'print "foo"') else: @@ -112,4 +120,3 @@ class TestDevelopTest(unittest.TestCase): pass finally: os.chdir(old_dir) - |