diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-11-24 19:47:58 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-11-24 19:47:58 -0500 |
commit | 0861296a63b3fafd059759840fb62ba12d4e6adc (patch) | |
tree | 79190e3b431c98f5e220ed63355961bf63dd3252 | |
parent | 693f20d40fca6b41ac629665901c350cd3dcd4e8 (diff) | |
download | external_python_setuptools-0861296a63b3fafd059759840fb62ba12d4e6adc.tar.gz external_python_setuptools-0861296a63b3fafd059759840fb62ba12d4e6adc.tar.bz2 external_python_setuptools-0861296a63b3fafd059759840fb62ba12d4e6adc.zip |
Use io.open and its context for simpler reading of a file
-rw-r--r-- | setuptools/tests/test_develop.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index f0adcb18..ec655462 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -3,6 +3,7 @@ import os import site import sys +import io import pytest @@ -74,16 +75,12 @@ class TestDevelopTest: assert content == ['easy-install.pth', 'foo.egg-link'] # Check that we are using the right code. - egg_link_file = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt') - try: + fn = os.path.join(site.USER_SITE, 'foo.egg-link') + with io.open(fn) as egg_link_file: path = egg_link_file.read().split()[0].strip() - finally: - egg_link_file.close() - init_file = open(os.path.join(path, 'foo', '__init__.py'), 'rt') - try: + fn = os.path.join(path, 'foo', '__init__.py') + with io.open(fn) as init_file: init = init_file.read().strip() - finally: - init_file.close() if sys.version < "3": assert init == 'print "foo"' else: |