Remove module references __file__
authorCédric Ollivier <cedric.ollivier@orange.com>
Sun, 18 Jun 2017 07:10:19 +0000 (09:10 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sun, 18 Jun 2017 23:08:39 +0000 (01:08 +0200)
It allows functest to be run directly from a zip file [1].

[1] https://setuptools.readthedocs.io/en/latest/setuptools.html#setting-the-zip-safe-flag

Change-Id: I596a71e8cf2bed6dd79655bd5beeb047876a188c
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
functest/tests/unit/utils/test_functest_utils.py
functest/utils/env.py

index d84a320..6f7976e 100644 (file)
@@ -8,6 +8,7 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 
 import logging
+import pkg_resources
 import os
 import time
 import unittest
@@ -56,8 +57,8 @@ class FunctestUtilsTesting(unittest.TestCase):
         self.testcase_dict = {'case_name': 'testname',
                               'criteria': self.criteria}
         self.parameter = 'general.openstack.image_name'
-        self.config_yaml = os.path.normpath(os.path.join(os.path.dirname(
-            os.path.abspath(__file__)), '../../../ci/config_functest.yaml'))
+        self.config_yaml = pkg_resources.resource_filename(
+            'functest', 'ci/config_functest.yaml')
         self.db_url_env = 'http://foo/testdb'
         self.testcases_yaml = "test_testcases_yaml"
         self.file_yaml = {'general': {'openstack': {'image_name':
index 3724ec9..0174588 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+import pkg_resources
 import os
 import re
 
@@ -16,8 +17,8 @@ default_envs = {
     'BUILD_TAG': None,
     'OS_ENDPOINT_TYPE': None,
     'OS_AUTH_URL': None,
-    'CONFIG_FUNCTEST_YAML': os.path.normpath(os.path.join(os.path.dirname(
-        os.path.abspath(__file__)), '../ci/config_functest.yaml'))
+    'CONFIG_FUNCTEST_YAML': pkg_resources.resource_filename(
+        'functest', 'ci/config_functest.yaml')
 }