mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 20:37:39 -02:30
Merge pull request #10522 from AlanCoding/close_file
Close file before returning Resolves /home/alancoding/repos/tower-qa/tests/lib/plugins/pytest_restqa/plugin.py:122: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/alancoding/repos/tower-qa/scripts/resource_loading/data_latest_loading.yml' mode='r' encoding='UTF-8'> qe_config.resources = PseudoNamespace(yaml_file.load_file(config.option.resource_file)) We have this same pattern earlier in the file. Reviewed-by: Shane McDonald <me@shanemcd.com>
This commit is contained in:
@@ -89,9 +89,9 @@ def load_file(filename):
|
|||||||
path = local(filename)
|
path = local(filename)
|
||||||
|
|
||||||
if path.check():
|
if path.check():
|
||||||
fp = path.open()
|
with open(path, 'r') as fp:
|
||||||
# FIXME - support load_all()
|
# FIXME - support load_all()
|
||||||
return yaml.load(fp, Loader=Loader)
|
return yaml.load(fp, Loader=Loader)
|
||||||
else:
|
else:
|
||||||
msg = 'Unable to load data file at %s' % path
|
msg = 'Unable to load data file at %s' % path
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user