Ensure tobiko package directory is not in the sys.path

Change-Id: If823022aa5f8355d4da1de7d0c3611b11ea072bc
This commit is contained in:
Federico Ressi 2021-07-16 12:59:36 +02:00
parent a2e39ffcfc
commit d087da357f
1 changed files with 12 additions and 0 deletions

View File

@ -13,6 +13,9 @@
# under the License.
from __future__ import absolute_import
import os
import sys
from tobiko.common import _asserts
from tobiko.common import _cached
from tobiko.common import _config
@ -32,6 +35,15 @@ from tobiko.common import _time
from tobiko.common import _utils
TOBIKO_PACKAGE_DIR = os.path.dirname(os.path.realpath(__file__))
# Ensure any tobiko package subdir is in sys.path
for path_dir in list(sys.path):
path_dir = os.path.realpath(path_dir)
if path_dir.startswith(TOBIKO_PACKAGE_DIR):
sys.path.remove(path_dir)
details_content = _detail.details_content
FailureException = _asserts.FailureException