diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-01 16:26:19 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-01 16:26:19 -0500 |
| commit | a476eca3548d454b7b9589f4e10c91c17e491c1f (patch) | |
| tree | dc0f09e5cd54ac1485d50fc366827227e43d7100 /setuptools/tests/test_dist_info.py | |
| parent | 8e8467a5abcaf920184dd07f6e0c092989aa12ff (diff) | |
| download | python-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.py | 10 |
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) |
