summaryrefslogtreecommitdiff
path: root/setuptools/tests/test_dist_info.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-01-01 16:26:19 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-01-01 16:26:19 -0500
commita476eca3548d454b7b9589f4e10c91c17e491c1f (patch)
treedc0f09e5cd54ac1485d50fc366827227e43d7100 /setuptools/tests/test_dist_info.py
parent8e8467a5abcaf920184dd07f6e0c092989aa12ff (diff)
downloadpython-setuptools-git-a476eca3548d454b7b9589f4e10c91c17e491c1f.tar.gz
Use contexts for opening files
Diffstat (limited to 'setuptools/tests/test_dist_info.py')
-rw-r--r--setuptools/tests/test_dist_info.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py
index 5f3b5952..812e6c46 100644
--- a/setuptools/tests/test_dist_info.py
+++ b/setuptools/tests/test_dist_info.py
@@ -43,8 +43,7 @@ class TestDistInfo:
versioned = os.path.join(self.tmpdir,
'VersionedDistribution-2.718.dist-info')
os.mkdir(versioned)
- metadata_file = open(os.path.join(versioned, 'METADATA'), 'w+')
- try:
+ with open(os.path.join(versioned, 'METADATA'), 'w+') as metadata_file:
metadata_file.write(DALS(
"""
Metadata-Version: 1.2
@@ -53,13 +52,10 @@ class TestDistInfo:
Provides-Extra: baz
Requires-Dist: quux (>=1.1); extra == 'baz'
"""))
- finally:
- metadata_file.close()
unversioned = os.path.join(self.tmpdir,
'UnversionedDistribution.dist-info')
os.mkdir(unversioned)
- metadata_file = open(os.path.join(unversioned, 'METADATA'), 'w+')
- try:
+ with open(os.path.join(unversioned, 'METADATA'), 'w+') as metadata_file:
metadata_file.write(DALS(
"""
Metadata-Version: 1.2
@@ -69,8 +65,6 @@ class TestDistInfo:
Provides-Extra: baz
Requires-Dist: quux (>=1.1); extra == 'baz'
"""))
- finally:
- metadata_file.close()
def teardown_method(self, method):
shutil.rmtree(self.tmpdir)