Merge "Fix many ResourceWarning messages in tox"
This commit is contained in:
commit
d69ece74d0
|
@ -16,7 +16,6 @@
|
||||||
import datetime
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import io
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
@ -338,7 +337,8 @@ class Conductor(manager.Manager):
|
||||||
for file in imported_yamls:
|
for file in imported_yamls:
|
||||||
file_path = os.path.join(
|
file_path = os.path.join(
|
||||||
csar_path, dir_of_parent_definition_file, file)
|
csar_path, dir_of_parent_definition_file, file)
|
||||||
file_data = yaml.safe_load(io.open(file_path))
|
with open(file_path) as f:
|
||||||
|
file_data = yaml.safe_load(f)
|
||||||
dest_file_path = os.path.abspath(file_path).split(
|
dest_file_path = os.path.abspath(file_path).split(
|
||||||
csar_path + '/')[-1]
|
csar_path + '/')[-1]
|
||||||
file_path_and_data[dest_file_path] = yaml.dump(file_data)
|
file_path_and_data[dest_file_path] = yaml.dump(file_data)
|
||||||
|
@ -356,8 +356,9 @@ class Conductor(manager.Manager):
|
||||||
# This is CSAR containing a TOSCA-Metadata directory, which
|
# This is CSAR containing a TOSCA-Metadata directory, which
|
||||||
# includes the TOSCA.meta metadata file providing an entry
|
# includes the TOSCA.meta metadata file providing an entry
|
||||||
# information for processing a CSAR file.
|
# information for processing a CSAR file.
|
||||||
tosca_meta_data = yaml.safe_load(io.open(os.path.join(
|
with open(os.path.join(
|
||||||
csar_path, 'TOSCA-Metadata', 'TOSCA.meta')))
|
csar_path, 'TOSCA-Metadata', 'TOSCA.meta')) as f:
|
||||||
|
tosca_meta_data = yaml.safe_load(f)
|
||||||
file_path_and_data['TOSCA-Metadata/TOSCA.meta'] = yaml.dump(
|
file_path_and_data['TOSCA-Metadata/TOSCA.meta'] = yaml.dump(
|
||||||
tosca_meta_data)
|
tosca_meta_data)
|
||||||
entry_defination_file = tosca_meta_data['Entry-Definitions']
|
entry_defination_file = tosca_meta_data['Entry-Definitions']
|
||||||
|
@ -371,7 +372,8 @@ class Conductor(manager.Manager):
|
||||||
os.listdir(csar_path),
|
os.listdir(csar_path),
|
||||||
key=lambda item: item.endswith(('yaml', '.yml')))[-1]
|
key=lambda item: item.endswith(('yaml', '.yml')))[-1]
|
||||||
src_path = os.path.join(csar_path, root_yaml_file)
|
src_path = os.path.join(csar_path, root_yaml_file)
|
||||||
file_data = yaml.safe_load(io.open(src_path))
|
with open(src_path) as f:
|
||||||
|
file_data = yaml.safe_load(f)
|
||||||
file_path_and_data[root_yaml_file] = yaml.dump(file_data)
|
file_path_and_data[root_yaml_file] = yaml.dump(file_data)
|
||||||
|
|
||||||
return file_path_and_data
|
return file_path_and_data
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import io
|
|
||||||
import os
|
import os
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -105,9 +104,9 @@ def get_expected_vnfd_data(zip_file=None):
|
||||||
'Definitions/etsi_nfv_sol001_common_types.yaml']
|
'Definitions/etsi_nfv_sol001_common_types.yaml']
|
||||||
file_path_and_data = {}
|
file_path_and_data = {}
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
with io.open(os.path.join(csar_temp_dir, file_name)) as f:
|
with open(os.path.join(csar_temp_dir, file_name)) as f:
|
||||||
file_path_and_data.update({file_name: yaml.dump(yaml.safe_load(
|
file_path_and_data.update({file_name: yaml.dump(
|
||||||
f))})
|
yaml.safe_load(f))})
|
||||||
|
|
||||||
shutil.rmtree(csar_temp_dir)
|
shutil.rmtree(csar_temp_dir)
|
||||||
return file_path_and_data
|
return file_path_and_data
|
||||||
|
|
|
@ -51,8 +51,8 @@ def dummy_get_vim(*args, **kwargs):
|
||||||
def _get_template(name):
|
def _get_template(name):
|
||||||
filename = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
filename = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
'../../etc/samples/' + str(name)))
|
'../../etc/samples/' + str(name)))
|
||||||
f = codecs.open(filename, encoding='utf-8', errors='strict')
|
with codecs.open(filename, encoding='utf-8', errors='strict') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
class FakeDriverManager(mock.Mock):
|
class FakeDriverManager(mock.Mock):
|
||||||
|
|
|
@ -27,8 +27,8 @@ def _get_template(name):
|
||||||
filename = os.path.join(
|
filename = os.path.join(
|
||||||
os.path.dirname(os.path.abspath(__file__)),
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
"../infra_drivers/openstack/data/", name)
|
"../infra_drivers/openstack/data/", name)
|
||||||
f = codecs.open(filename, encoding='utf-8', errors='strict')
|
with codecs.open(filename, encoding='utf-8', errors='strict') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
class TestToscaUtils(testtools.TestCase):
|
class TestToscaUtils(testtools.TestCase):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import datetime
|
import datetime
|
||||||
import io
|
|
||||||
import iso8601
|
import iso8601
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -249,9 +248,9 @@ def return_vnfd_data(csar_without_tosca_meta=False):
|
||||||
'Definitions/etsi_nfv_sol001_vnfd_types.yaml']
|
'Definitions/etsi_nfv_sol001_vnfd_types.yaml']
|
||||||
file_path_and_data = {}
|
file_path_and_data = {}
|
||||||
for file_name in file_names:
|
for file_name in file_names:
|
||||||
with io.open(os.path.join(csar_temp_dir, file_name)) as f:
|
with open(os.path.join(csar_temp_dir, file_name)) as f:
|
||||||
file_path_and_data.update({file_name: yaml.dump(yaml.safe_load(
|
file_path_and_data.update({file_name: yaml.dump(
|
||||||
f))})
|
yaml.safe_load(f))})
|
||||||
|
|
||||||
shutil.rmtree(csar_temp_dir)
|
shutil.rmtree(csar_temp_dir)
|
||||||
return file_path_and_data
|
return file_path_and_data
|
||||||
|
|
Loading…
Reference in New Issue