diff options
author | softwarefactory-project-zuul[bot] <33884098+softwarefactory-project-zuul[bot]@users.noreply.github.com> | 2021-06-28 19:52:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-28 19:52:37 +0200 |
commit | c09cad3e6dd7e83871f094ba8d9e0f983db98305 (patch) | |
tree | ca75af8e32fd7bec243f7b92260fef6c5f996d6f /awxkit | |
parent | Merge pull request #10536 from shanemcd/bump-19.2.2 (diff) | |
parent | Close file before returning (diff) | |
download | awx-c09cad3e6dd7e83871f094ba8d9e0f983db98305.tar.xz awx-c09cad3e6dd7e83871f094ba8d9e0f983db98305.zip |
Merge pull request #10522 from AlanCoding/close_file19.2.2
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>
Diffstat (limited to 'awxkit')
-rw-r--r-- | awxkit/awxkit/yaml_file.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/awxkit/awxkit/yaml_file.py b/awxkit/awxkit/yaml_file.py index 49924cef93..7adbe142d7 100644 --- a/awxkit/awxkit/yaml_file.py +++ b/awxkit/awxkit/yaml_file.py @@ -89,9 +89,9 @@ def load_file(filename): path = local(filename) if path.check(): - fp = path.open() - # FIXME - support load_all() - return yaml.load(fp, Loader=Loader) + with open(path, 'r') as fp: + # FIXME - support load_all() + return yaml.load(fp, Loader=Loader) else: msg = 'Unable to load data file at %s' % path raise Exception(msg) |