From f227d40752911b27e602d068b06a089ccfd8558e Mon Sep 17 00:00:00 2001 From: Kyle Stewart <4b796c65+bitbucket@gmail.com> Date: Thu, 17 Mar 2016 20:55:55 -0700 Subject: Use context managers during tests. Needed for test_egg_re and test_compatibility_tags to pass with the stricter rules. --- wheel/test/test_basic.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wheel/test/test_basic.py b/wheel/test/test_basic.py index e69fef9..6bd46b1 100644 --- a/wheel/test/test_basic.py +++ b/wheel/test/test_basic.py @@ -63,12 +63,13 @@ def test_findable(): def test_egg_re(): """Make sure egg_info_re matches.""" - egg_names = open(pkg_resources.resource_filename('wheel', 'eggnames.txt')) - for line in egg_names: - line = line.strip() - if not line: - continue - assert egg2wheel.egg_info_re.match(line), line + egg_names_path = pkg_resources.resource_filename('wheel', 'eggnames.txt') + with open(egg_names_path) as egg_names: + for line in egg_names: + line = line.strip() + if not line: + continue + assert egg2wheel.egg_info_re.match(line), line def test_compatibility_tags(): """Test compatibilty tags are working.""" @@ -117,7 +118,8 @@ def test_pydist(): import jsonschema def open_json(filename): - return json.loads(open(filename, 'rb').read().decode('utf-8')) + with open(filename, 'rb') as json_file: + return json.loads(json_file.read().decode('utf-8')) pymeta_schema = open_json(resource_filename('wheel.test', 'pydist-schema.json')) -- cgit v1.2.1