summaryrefslogtreecommitdiffstats
path: root/vnftest/common/utils.py
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2019-03-03 12:06:08 +0200
committerMoshe <moshehoa@amdocs.com>2019-03-03 12:21:08 +0200
commit480cee41e7ebe28feb4fb77955afcd0f3295fba4 (patch)
tree112e2d919fe16dcaf71346b3d0035c2aad6bd8d6 /vnftest/common/utils.py
parente10a5af4bb80d0a9ad4b0bd56959091ba5ff4a9a (diff)
Allow multiple contexts per test case
Issue-ID: VNFSDK-350 Change-Id: Ib189a748bd41c48ef55959cecf221971d15099b5 Signed-off-by: Moshe <moshehoa@amdocs.com> refactor context handling Change-Id: Ic2bcdbcc98addeeef2cecd42c025a6a25b630b07 Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/common/utils.py')
-rw-r--r--vnftest/common/utils.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/vnftest/common/utils.py b/vnftest/common/utils.py
index 882403f..dfd32d5 100644
--- a/vnftest/common/utils.py
+++ b/vnftest/common/utils.py
@@ -475,7 +475,6 @@ def load_resource(path, mode="r"):
try:
return open(path, mode)
except Exception:
- logger.info("path not loaded as file, trying load as package")
split_path = os.path.split(path)
package = split_path[0].replace("/", ".")
if not pkg_resources.resource_exists(package, split_path[1]):
@@ -483,6 +482,18 @@ def load_resource(path, mode="r"):
return pkg_resources.resource_stream(package, split_path[1])
+def resource_abs_path(path, mode="r"):
+ try:
+ open(path, mode)
+ return path
+ except Exception:
+ split_path = os.path.split(path)
+ package = split_path[0].replace("/", ".")
+ if not pkg_resources.resource_exists(package, split_path[1]):
+ raise ResourceNotFound(resource=path)
+ return pkg_resources.resource_filename(package, split_path[1])
+
+
def format(in_obj, params):
if isinstance(in_obj, list):
ret_list = []