summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Stewart <4b796c65+bitbucket@gmail.com>2016-03-17 20:55:55 -0700
committerKyle Stewart <4b796c65+bitbucket@gmail.com>2016-03-17 20:55:55 -0700
commitf227d40752911b27e602d068b06a089ccfd8558e (patch)
tree4eff4b3c07bd77aea31ab3a3258568929e8fd11a
parentb7fd6b36c366386c80d9704b38a793cca714e5f1 (diff)
downloadwheel-f227d40752911b27e602d068b06a089ccfd8558e.tar.gz
Use context managers during tests.
Needed for test_egg_re and test_compatibility_tags to pass with the stricter rules.
-rw-r--r--wheel/test/test_basic.py16
1 files 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'))