Fix ResourceWarning: unclosed file

Fixing resource warnings as raised in
https://review.opendev.org/#/c/713807/

Change-Id: I2d7735751e504a10dbcf73a2fea832deeca664f0
This commit is contained in:
Alex Schultz 2020-04-07 14:16:39 -06:00
parent 60ea5a3a4b
commit 561bf0db29
1 changed files with 4 additions and 2 deletions

View File

@ -546,7 +546,8 @@ class TestCreateOvercloudRC(TestCase):
try:
utils.write_overcloudrc(stack_name, overcloudrcs,
config_directory=tempdir)
rc = open(rcfile, 'rt').read()
with open(rcfile, 'rt') as f:
rc = f.read()
self.assertEqual('overcloudrc', rc)
finally:
if os.path.exists(rcfile):
@ -561,7 +562,8 @@ class TestCreateTempestDeployerInput(TestCase):
with tempfile.NamedTemporaryFile() as cfgfile:
filepath = cfgfile.name
utils.create_tempest_deployer_input(filepath)
cfg = open(filepath, 'rt').read()
with open(filepath, 'rt') as f:
cfg = f.read()
# Just make a simple test, to make sure it created a proper file:
self.assertIn(
'[volume-feature-enabled]\nbootable = true', cfg)