Fix resource warnings when running tests
There are some open calls that are not protected using with. Change-Id: I98a45c4df38c7a22282fa6abf911a1815fb6bbfa
This commit is contained in:
parent
2a3d4f842b
commit
58ad5123f1
|
@ -79,7 +79,8 @@ class ConfigValidator:
|
|||
log.info("validating %s" % self.config_file)
|
||||
|
||||
try:
|
||||
config = yaml.safe_load(open(self.config_file))
|
||||
with open(self.config_file) as f:
|
||||
config = yaml.safe_load(f)
|
||||
except Exception:
|
||||
log.exception('YAML parsing failed')
|
||||
return 1
|
||||
|
|
|
@ -229,7 +229,8 @@ def openConfig(path):
|
|||
# attempt to reload it.
|
||||
while True:
|
||||
try:
|
||||
config = yaml.safe_load(open(path))
|
||||
with open(path) as f:
|
||||
config = yaml.safe_load(f)
|
||||
break
|
||||
except IOError as e:
|
||||
if e.errno == 2:
|
||||
|
|
|
@ -55,7 +55,8 @@ class TestDriverAws(tests.DBTestCase):
|
|||
|
||||
ec2_template = os.path.join(
|
||||
os.path.dirname(__file__), '..', 'fixtures', 'aws.yaml')
|
||||
raw_config = yaml.safe_load(open(ec2_template))
|
||||
with open(ec2_template) as f:
|
||||
raw_config = yaml.safe_load(f)
|
||||
raw_config['zookeeper-servers'][0] = {
|
||||
'host': self.zookeeper_host,
|
||||
'port': self.zookeeper_port,
|
||||
|
|
Loading…
Reference in New Issue