Commit 0861296a authored by Jason R. Coombs's avatar Jason R. Coombs

Use io.open and its context for simpler reading of a file

parent 693f20d4
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment