aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2012-10-10 10:49:54 +0100
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2012-10-10 10:49:54 +0100
commit94fc39cb62df19e85b07658f2fa5d0b4a7bf9303 (patch)
tree1c44a301f7eb2662ccc03f97685b449e2251069e /setuptools/tests
parente3f7235a944f5758780de74aac548e27a09e39a3 (diff)
downloadexternal_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')
-rw-r--r--setuptools/tests/server.py1
-rw-r--r--setuptools/tests/test_develop.py17
-rw-r--r--setuptools/tests/test_dist_info.py43
-rw-r--r--setuptools/tests/test_easy_install.py2
4 files changed, 39 insertions, 24 deletions
diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py
index 0e7407bb..ae2381e3 100644
--- a/setuptools/tests/server.py
+++ b/setuptools/tests/server.py
@@ -51,6 +51,7 @@ class IndexServer(HTTPServer):
# ignore any errors; all that's important is the request
pass
self.thread.join()
+ self.socket.close()
def base_url(self):
port = self.server_port
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)
-
diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py
index 623ccc47..93ab8816 100644
--- a/setuptools/tests/test_dist_info.py
+++ b/setuptools/tests/test_dist_info.py
@@ -50,27 +50,34 @@ class TestDistInfo(unittest.TestCase):
versioned = os.path.join(self.tmpdir,
'VersionedDistribution-2.718.dist-info')
os.mkdir(versioned)
- open(os.path.join(versioned, 'METADATA'), 'w+').write(DALS(
- """
- Metadata-Version: 1.2
- Name: VersionedDistribution
- Requires-Dist: splort (4)
- Provides-Extra: baz
- Requires-Dist: quux (>=1.1); extra == 'baz'
- """))
-
+ f = open(os.path.join(versioned, 'METADATA'), 'w+')
+ try:
+ f.write(DALS(
+ """
+ Metadata-Version: 1.2
+ Name: VersionedDistribution
+ Requires-Dist: splort (4)
+ Provides-Extra: baz
+ Requires-Dist: quux (>=1.1); extra == 'baz'
+ """))
+ finally:
+ f.close()
unversioned = os.path.join(self.tmpdir,
'UnversionedDistribution.dist-info')
os.mkdir(unversioned)
- open(os.path.join(unversioned, 'METADATA'), 'w+').write(DALS(
- """
- Metadata-Version: 1.2
- Name: UnversionedDistribution
- Version: 0.3
- Requires-Dist: splort (==4)
- Provides-Extra: baz
- Requires-Dist: quux (>=1.1); extra == 'baz'
- """))
+ f = open(os.path.join(unversioned, 'METADATA'), 'w+')
+ try:
+ f.write(DALS(
+ """
+ Metadata-Version: 1.2
+ Name: UnversionedDistribution
+ Version: 0.3
+ Requires-Dist: splort (==4)
+ Provides-Extra: baz
+ Requires-Dist: quux (>=1.1); extra == 'baz'
+ """))
+ finally:
+ f.close()
def tearDown(self):
shutil.rmtree(self.tmpdir)
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index aab4b617..34faeaad 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -233,7 +233,7 @@ class TestUserInstallTest(unittest.TestCase):
f = open(egg_file, 'w')
try:
f.write('Name: foo\n')
- except:
+ finally:
f.close()
sys.path.append(target)